remove TROLLSAVE code

remove more cvector usage
This commit is contained in:
Enno Rehling 2011-02-27 12:14:33 -08:00
parent 1fbe46ddfe
commit 342e7ee249
3 changed files with 15 additions and 35 deletions

View file

@ -2301,9 +2301,9 @@ add_tactics(tactics * ta, fighter * fig, int value)
if (value == 0 || value < ta->value) if (value == 0 || value < ta->value)
return; return;
if (value > ta->value) if (value > ta->value)
cv_kill(&ta->fighters); ql_free(ta->fighters);
cv_pushback(&ta->fighters, fig); ql_push(&ta->fighters, fig);
cv_pushback(&fig->side->battle->leaders, fig); ql_push(&fig->side->battle->leaders, fig);
ta->value = value; ta->value = value;
} }
@ -2630,10 +2630,6 @@ aftermath(battle * b)
bfaction * bf; bfaction * bf;
boolean ships_damaged = (boolean)(b->turn+(b->has_tactics_turn?1:0)>2); /* only used for ship damage! */ boolean ships_damaged = (boolean)(b->turn+(b->has_tactics_turn?1:0)>2); /* only used for ship damage! */
#ifdef TROLLSAVE
int *trollsave = calloc(2 * cv_size(&b->factions), sizeof(int));
#endif
for (s=b->sides;s!=b->sides+b->nsides;++s) { for (s=b->sides;s!=b->sides+b->nsides;++s) {
fighter * df; fighter * df;
for (df = s->fighters; df; df=df->next) { for (df = s->fighters; df; df=df->next) {
@ -2641,21 +2637,6 @@ aftermath(battle * b)
int dead = dead_fighters(df); int dead = dead_fighters(df);
int pr_mercy = 0; int pr_mercy = 0;
#ifdef TROLLSAVE
/* Trolle können regenerieren */
if (df->alive > 0 && dead>0 && du->race == new_race[RC_TROLL]) {
for (i = 0; i != dead; ++i) {
if (chance(TROLL_REGENERATION)) {
++df->alive;
++s->alive;
++s->battle->alive;
++trollsave[s->index];
/* do not change dead here, or loop will not terminate! recalculate later */
}
}
dead = dead_fighters(df);
}
#endif
/* Regeneration durch PR_MERCY */ /* Regeneration durch PR_MERCY */
if (dead>0 && pr_mercy) { if (dead>0 && pr_mercy) {
for (i = 0; i != dead; ++i) { for (i = 0; i != dead; ++i) {
@ -2918,9 +2899,6 @@ aftermath(battle * b)
if (*sp==sh) sp=&sh->next; if (*sp==sh) sp=&sh->next;
} }
} }
#ifdef TROLLSAVE
free(trollsave);
#endif
reorder_fleeing(r); reorder_fleeing(r);
@ -3146,7 +3124,7 @@ print_stats(battle * b)
b->max_tactics = 0; b->max_tactics = 0;
for (s=b->sides;s!=b->sides+b->nsides;++s) { for (s=b->sides;s!=b->sides+b->nsides;++s) {
if (cv_size(&s->leader.fighters)) { if (!ql_empty(s->leader.fighters)) {
b->max_tactics = MAX(b->max_tactics, s->leader.value); b->max_tactics = MAX(b->max_tactics, s->leader.value);
} }
} }
@ -3154,8 +3132,11 @@ print_stats(battle * b)
if (b->max_tactics > 0) { if (b->max_tactics > 0) {
for (s=b->sides;s!=b->sides+b->nsides;++s) { for (s=b->sides;s!=b->sides+b->nsides;++s) {
if (s->leader.value == b->max_tactics) { if (s->leader.value == b->max_tactics) {
fighter *tf; quicklist *ql;
cv_foreach(tf, s->leader.fighters) { int qi;
for (qi=0,ql=s->leader.fighters;ql;ql_advance(&ql, &qi, 1)) {
fighter *tf = (fighter *)ql_get(ql, qi);
unit *u = tf->unit; unit *u = tf->unit;
message * m = NULL; message * m = NULL;
if (!is_attacker(tf)) { if (!is_attacker(tf)) {
@ -3165,7 +3146,7 @@ print_stats(battle * b)
} }
message_all(b, m); message_all(b, m);
msg_release(m); msg_release(m);
} cv_next(tf); }
} }
} }
} }
@ -3603,7 +3584,7 @@ make_battle(region * r)
static void static void
free_side(side * si) free_side(side * si)
{ {
cv_kill(&si->leader.fighters); ql_free(si->leader.fighters);
} }
static void static void
@ -3651,7 +3632,7 @@ free_battle(battle * b)
} }
free_side(s); free_side(s);
} }
cv_kill(&b->leaders); ql_free(b->leaders);
cv_foreach(meffect, b->meffects) { cv_foreach(meffect, b->meffects) {
free(meffect); free(meffect);
} }
@ -4329,7 +4310,7 @@ do_battle(region * r)
for (sh=r->ships; sh; sh=sh->next) freset(sh, SF_DAMAGED); for (sh=r->ships; sh; sh=sh->next) freset(sh, SF_DAMAGED);
/* Gibt es eine Taktikrunde ? */ /* Gibt es eine Taktikrunde ? */
if (cv_size(&b->leaders)) { if (!ql_empty(b->leaders)) {
b->turn = 0; b->turn = 0;
b->has_tactics_turn = true; b->has_tactics_turn = true;
} else { } else {

View file

@ -58,7 +58,7 @@ extern "C" {
} bfaction; } bfaction;
typedef struct tactics { typedef struct tactics {
cvector fighters; struct quicklist * fighters;
int value; int value;
} tactics; } tactics;
@ -93,7 +93,7 @@ extern "C" {
} side; } side;
typedef struct battle { typedef struct battle {
cvector leaders; struct quicklist * leaders;
struct region *region; struct region *region;
struct plane *plane; struct plane *plane;
bfaction * factions; bfaction * factions;

View file

@ -35,7 +35,6 @@ struct _dictionary_;
#define SHIPDAMAGE /* Schiffsbeschädigungen */ #define SHIPDAMAGE /* Schiffsbeschädigungen */
#define INSECT_POTION /* Spezialtrank für Insekten */ #define INSECT_POTION /* Spezialtrank für Insekten */
#define ORCIFICATION /* giving snotlings to the peasants gets counted */ #define ORCIFICATION /* giving snotlings to the peasants gets counted */
#undef TROLLSAVE /* saving throw for dead trolls */
#define ALLIED(f1, f2) (f1==f2 || (f1->alliance && f1->alliance==f2->alliance)) #define ALLIED(f1, f2) (f1==f2 || (f1->alliance && f1->alliance==f2->alliance))