- Bugfix Patzermeldungen,

- Entfernte Befehle kriegen next=NULL, assert desselben.
This commit is contained in:
Enno Rehling 2004-06-27 12:19:58 +00:00
parent df476c5d7c
commit 075ab8d997
8 changed files with 93 additions and 88 deletions

View file

@ -3210,66 +3210,67 @@ new_units (void)
unit *u, *u2; unit *u, *u2;
/* neue einheiten werden gemacht und ihre befehle (bis zum "ende" zu /* neue einheiten werden gemacht und ihre befehle (bis zum "ende" zu
* ihnen rueberkopiert, damit diese einheiten genauso wie die alten * ihnen rueberkopiert, damit diese einheiten genauso wie die alten
* einheiten verwendet werden koennen. */ * einheiten verwendet werden koennen. */
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
for (u = r->units; u; u = u->next) { for (u = r->units; u; u = u->next) {
order ** ordp = &u->orders; order ** ordp = &u->orders;
while (*ordp) { while (*ordp) {
order * makeord = *ordp; order * makeord = *ordp;
if (get_keyword(makeord) == K_MAKE) { if (get_keyword(makeord) == K_MAKE) {
init_tokens(makeord); init_tokens(makeord);
skip_token(); skip_token();
if (getparam(u->faction->locale) == P_TEMP) { if (getparam(u->faction->locale) == P_TEMP) {
char * name; char * name;
int g, alias; int g, alias;
int mu = maxunits(u->faction); int mu = maxunits(u->faction);
order ** newordersp; order ** newordersp;
if(u->faction->no_units >= mu) { if(u->faction->no_units >= mu) {
sprintf(buf, "Eine Partei darf aus nicht mehr als %d " sprintf(buf, "Eine Partei darf aus nicht mehr als %d "
"Einheiten bestehen.", mu); "Einheiten bestehen.", mu);
mistake(u, makeord, buf, MSG_PRODUCE); mistake(u, makeord, buf, MSG_PRODUCE);
ordp = &makeord->next; ordp = &makeord->next;
while (*ordp) { while (*ordp) {
order * ord = *ordp; order * ord = *ordp;
if (get_keyword(ord) == K_END) break; if (get_keyword(ord) == K_END) break;
*ordp = ord->next; *ordp = ord->next;
free_order(ord); ord->next = NULL;
} free_order(ord);
continue; }
} continue;
alias = getid(); }
alias = getid();
name = strdup(getstrtoken()); name = strdup(getstrtoken());
if (name && strlen(name)==0) name = NULL; if (name && strlen(name)==0) name = NULL;
u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u); u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u);
if (name!=NULL) free(name); if (name!=NULL) free(name);
fset(u2, UFL_ISNEW); fset(u2, UFL_ISNEW);
a_add(&u2->attribs, a_new(&at_alias))->data.i = alias; a_add(&u2->attribs, a_new(&at_alias))->data.i = alias;
g = getguard(u); g = getguard(u);
if (g) setguard(u2, g); if (g) setguard(u2, g);
else setguard(u, GUARD_NONE); else setguard(u, GUARD_NONE);
ordp = &makeord->next; ordp = &makeord->next;
newordersp = &u2->orders; newordersp = &u2->orders;
while (*ordp) { while (*ordp) {
order * ord = *ordp; order * ord = *ordp;
if (get_keyword(ord) == K_END) break; if (get_keyword(ord) == K_END) break;
*ordp = ord->next; *ordp = ord->next;
ord->next = NULL; ord->next = NULL;
*newordersp = ord; *newordersp = ord;
newordersp = &ord->next; newordersp = &ord->next;
} }
} }
} }
if (*ordp==makeord) ordp=&makeord->next; if (*ordp==makeord) ordp=&makeord->next;
} }
} }
} }
} }
@ -3543,6 +3544,7 @@ defaultorders (void)
set_order(&u->lastorder, parse_order(getstrtoken(), u->faction->locale)); set_order(&u->lastorder, parse_order(getstrtoken(), u->faction->locale));
free_order(u->lastorder); /* parse_order & set_order have both increased the refcount */ free_order(u->lastorder); /* parse_order & set_order have both increased the refcount */
*ordp = ord->next; *ordp = ord->next;
ord->next = NULL;
free_order(ord); free_order(ord);
} }
else ordp = &ord->next; else ordp = &ord->next;

View file

@ -437,7 +437,7 @@ set_movement_order(unit * u, const region * target, int moves, boolean (*allowed
} }
set_order(&u->lastorder, parse_order(buf, u->faction->locale)); set_order(&u->lastorder, parse_order(buf, u->faction->locale));
free_order(u->lastorder); /* parse_order & set_order have both increased the refcount */ free_order(u->lastorder); /* parse_order & set_order have both increased the refcount */
return true; return true;
} }
@ -765,7 +765,7 @@ learn_monster(unit *u)
sprintf(buf, "%s %s", locale_string(u->faction->locale, keywords[K_STUDY]), sprintf(buf, "%s %s", locale_string(u->faction->locale, keywords[K_STUDY]),
skillname(sv->id, u->faction->locale)); skillname(sv->id, u->faction->locale));
set_order(&u->thisorder, parse_order(buf, u->faction->locale)); set_order(&u->thisorder, parse_order(buf, u->faction->locale));
free_order(u->thisorder); /* parse_order & set_order have both increased the refcount */ free_order(u->thisorder); /* parse_order & set_order have both increased the refcount */
break; break;
} }
} }

View file

@ -1384,7 +1384,7 @@ randomevents(void)
name_unit(u); name_unit(u);
set_order(&u->lastorder, parse_order(keywords[K_WAIT], u->faction->locale)); set_order(&u->lastorder, parse_order(keywords[K_WAIT], u->faction->locale));
free_order(u->lastorder); /* parse_order & set_order have each increased the refcount */ free_order(u->lastorder); /* parse_order & set_order have each increased the refcount */
/* add message to the region */ /* add message to the region */
ADDMSG(&r->msgs, ADDMSG(&r->msgs,
@ -1451,8 +1451,8 @@ randomevents(void)
u->hp = unit_max_hp(u) * u->number; u->hp = unit_max_hp(u) * u->number;
deathcounts(r, -undead); deathcounts(r, -undead);
set_order(&u->lastorder, parse_order(keywords[K_WAIT], u->faction->locale)); set_order(&u->lastorder, parse_order(keywords[K_WAIT], u->faction->locale));
free_order(u->lastorder); /* parse_order & set_order have each increased the refcount */ free_order(u->lastorder); /* parse_order & set_order have each increased the refcount */
name_unit(u); name_unit(u);
log_printf("%d %s in %s.\n", u->number, log_printf("%d %s in %s.\n", u->number,
@ -1527,8 +1527,8 @@ randomevents(void)
rsettrees(r, trees); rsettrees(r, trees);
#endif #endif
u = createunit(r, findfaction(MONSTER_FACTION),treemen, new_race[RC_TREEMAN]); u = createunit(r, findfaction(MONSTER_FACTION),treemen, new_race[RC_TREEMAN]);
set_order(&u->lastorder, parse_order(keywords[K_WAIT], u->faction->locale)); set_order(&u->lastorder, parse_order(keywords[K_WAIT], u->faction->locale));
free_order(u->lastorder); /* parse_order & set_order have each increased the refcount */ free_order(u->lastorder); /* parse_order & set_order have each increased the refcount */
/* guard(u, GUARD_ALL); kein auto-guard! erst in monster.c! */ /* guard(u, GUARD_ALL); kein auto-guard! erst in monster.c! */
set_level(u, SK_OBSERVATION, 2); set_level(u, SK_OBSERVATION, 2);

View file

@ -925,7 +925,7 @@ build_building(unit * u, const building_type * btype, int want)
else else
sprintf(buffer, "%s %d %s %s", locale_string(u->faction->locale, keywords[K_MAKE]), want-built, string2, buildingid(b)); sprintf(buffer, "%s %d %s %s", locale_string(u->faction->locale, keywords[K_MAKE]), want-built, string2, buildingid(b));
set_order(&u->lastorder, parse_order(buffer, u->faction->locale)); set_order(&u->lastorder, parse_order(buffer, u->faction->locale));
free_order(u->lastorder); free_order(u->lastorder);
b->size += built; b->size += built;
update_lighthouse(b); update_lighthouse(b);
@ -1248,6 +1248,7 @@ do_misc(boolean lasttry)
* erfolgreich und wir löschen ihn, damit er im * erfolgreich und wir löschen ihn, damit er im
* zweiten Versuch nicht nochmal ausgeführt wird. */ * zweiten Versuch nicht nochmal ausgeführt wird. */
*ordp = ord->next; *ordp = ord->next;
ord->next = NULL;
free_order(ord); free_order(ord);
leave(r, u); leave(r, u);
u->building = b; u->building = b;

View file

@ -832,7 +832,7 @@ cycle_route(unit *u, int gereist)
strcat(neworder, tail); strcat(neworder, tail);
set_order(&u->lastorder, parse_order(neworder, u->faction->locale)); set_order(&u->lastorder, parse_order(neworder, u->faction->locale));
free_order(u->lastorder); /* parse_order & set_order have each increased the refcount */ free_order(u->lastorder); /* parse_order & set_order have each increased the refcount */
} }
static void static void
@ -1926,7 +1926,7 @@ piracy_cmd(unit *u, struct order * ord)
sprintf(buf, "%s %s", locale_string(u->faction->locale, keywords[K_MOVE]), sprintf(buf, "%s %s", locale_string(u->faction->locale, keywords[K_MOVE]),
locale_string(u->faction->locale, directions[target_dir])); locale_string(u->faction->locale, directions[target_dir]));
set_order(&u->thisorder, parse_order(buf, u->faction->locale)); set_order(&u->thisorder, parse_order(buf, u->faction->locale));
free_order(u->thisorder); /* parse_order & set_order have each increased the refcount */ free_order(u->thisorder); /* parse_order & set_order have each increased the refcount */
/* Bewegung ausführen */ /* Bewegung ausführen */
init_tokens(u->thisorder); init_tokens(u->thisorder);

View file

@ -63,6 +63,7 @@ void
free_order(order * ord) free_order(order * ord)
{ {
if (ord!=NULL && --ord->_refcount==0) { if (ord!=NULL && --ord->_refcount==0) {
assert(ord->next==NULL);
if (ord->_str!=NULL) free(ord->_str); if (ord->_str!=NULL) free(ord->_str);
free(ord); free(ord);
} }
@ -89,6 +90,7 @@ free_orders(order ** olist)
while (*olist) { while (*olist) {
order * ord = *olist; order * ord = *olist;
*olist = ord->next; *olist = ord->next;
ord->next = NULL;
free_order(ord); free_order(ord);
} }
} }

View file

@ -195,11 +195,11 @@ magicanalyse_region(region *r, unit *mage, double force)
if (chance(probability)) { /* Analyse geglückt */ if (chance(probability)) { /* Analyse geglückt */
if(c->flag & CURSE_NOAGE) { if(c->flag & CURSE_NOAGE) {
ADDMSG(&mage->faction->msgs, msg_message( ADDMSG(&mage->faction->msgs, msg_message(
"analyse_region_noage", "mage region spell", "analyse_region_noage", "mage region curse",
mage, r, LOC(lang, mkname("spell", c->type->cname)))); mage, r, LOC(lang, mkname("spell", c->type->cname))));
} else { } else {
ADDMSG(&mage->faction->msgs, msg_message( ADDMSG(&mage->faction->msgs, msg_message(
"analyse_region_age", "mage region spell months", "analyse_region_age", "mage region curse months",
mage, r, LOC(lang, mkname("spell", c->type->cname)), mon)); mage, r, LOC(lang, mkname("spell", c->type->cname)), mon));
} }
} else { } else {
@ -236,11 +236,11 @@ magicanalyse_unit(unit *u, unit *mage, double force)
if (chance(probability)) { /* Analyse geglückt */ if (chance(probability)) { /* Analyse geglückt */
if(c->flag & CURSE_NOAGE){ if(c->flag & CURSE_NOAGE){
ADDMSG(&mage->faction->msgs, msg_message( ADDMSG(&mage->faction->msgs, msg_message(
"analyse_unit_noage", "mage unit spell", "analyse_unit_noage", "mage unit curse",
mage, u, LOC(lang, mkname("spell", c->type->cname)))); mage, u, LOC(lang, mkname("spell", c->type->cname))));
}else{ }else{
ADDMSG(&mage->faction->msgs, msg_message( ADDMSG(&mage->faction->msgs, msg_message(
"analyse_unit_age", "mage unit spell months", "analyse_unit_age", "mage unit curse months",
mage, u, LOC(lang, mkname("spell", c->type->cname)), mon)); mage, u, LOC(lang, mkname("spell", c->type->cname)), mon));
} }
} else { } else {
@ -278,11 +278,11 @@ magicanalyse_building(building *b, unit *mage, double force)
if (chance(probability)) { /* Analyse geglückt */ if (chance(probability)) { /* Analyse geglückt */
if(c->flag & CURSE_NOAGE){ if(c->flag & CURSE_NOAGE){
ADDMSG(&mage->faction->msgs, msg_message( ADDMSG(&mage->faction->msgs, msg_message(
"analyse_building_age", "mage building spell", "analyse_building_age", "mage building curse",
mage, b, LOC(lang, mkname("spell", c->type->cname)))); mage, b, LOC(lang, mkname("spell", c->type->cname))));
}else{ }else{
ADDMSG(&mage->faction->msgs, msg_message( ADDMSG(&mage->faction->msgs, msg_message(
"analyse_building_age", "mage building spell months", "analyse_building_age", "mage building curse months",
mage, b, LOC(lang, mkname("spell", c->type->cname)), mon)); mage, b, LOC(lang, mkname("spell", c->type->cname)), mon));
} }
} else { } else {
@ -320,11 +320,11 @@ magicanalyse_ship(ship *sh, unit *mage, double force)
if (chance(probability)) { /* Analyse geglückt */ if (chance(probability)) { /* Analyse geglückt */
if(c->flag & CURSE_NOAGE){ if(c->flag & CURSE_NOAGE){
ADDMSG(&mage->faction->msgs, msg_message( ADDMSG(&mage->faction->msgs, msg_message(
"analyse_ship_noage", "mage ship spell", "analyse_ship_noage", "mage ship curse",
mage, sh, LOC(lang, mkname("spell", c->type->cname)))); mage, sh, LOC(lang, mkname("spell", c->type->cname))));
}else{ }else{
ADDMSG(&mage->faction->msgs, msg_message( ADDMSG(&mage->faction->msgs, msg_message(
"analyse_ship_age", "mage ship spell months", "analyse_ship_age", "mage ship curse months",
mage, sh, LOC(lang, mkname("spell", c->type->cname)), mon)); mage, sh, LOC(lang, mkname("spell", c->type->cname)), mon));
} }
} else { } else {
@ -8534,7 +8534,7 @@ static spell spelldaten[] =
}, },
{ {
SPL_DRAIG_DESTROY_MAGIC, "draigdestroymagic", NULL, SPL_DRAIG_DESTROY_MAGIC, "draigdestroymagic", NULL,
"ZAUBERE [REGION x y] [STUFE n] \'Pentagramm\' REGIONn" "ZAUBERE [REGION x y] [STUFE n] \'Pentagramm\' REGION\n"
"ZAUBERE [REGION x y] [STUFE n] \'Pentagramm\' EINHEIT <Einheit-Nr>\n" "ZAUBERE [REGION x y] [STUFE n] \'Pentagramm\' EINHEIT <Einheit-Nr>\n"
"ZAUBERE [REGION x y] [STUFE n] \'Pentagramm\' GEBÄUDE <Gebäude-Nr>\n" "ZAUBERE [REGION x y] [STUFE n] \'Pentagramm\' GEBÄUDE <Gebäude-Nr>\n"
"ZAUBERE [REGION x y] [STUFE n] \'Pentagramm\' SCHIFF <Schiff-Nr>", "ZAUBERE [REGION x y] [STUFE n] \'Pentagramm\' SCHIFF <Schiff-Nr>",

View file

@ -1025,7 +1025,7 @@
<type> <type>
<arg name="mage" type="unit"/> <arg name="mage" type="unit"/>
<arg name="ship" type="ship"/> <arg name="ship" type="ship"/>
<arg name="spell" type="string"/> <arg name="curse" type="string"/>
<arg name="months" type="int"/> <arg name="months" type="int"/>
</type> </type>
<text locale="de">"$unit($mage) fand heraus, dass auf $ship($ship) der Zauber $spell liegt, der noch etwa $int($months) Wochen bestehen bleibt."</text> <text locale="de">"$unit($mage) fand heraus, dass auf $ship($ship) der Zauber $spell liegt, der noch etwa $int($months) Wochen bestehen bleibt."</text>
@ -1036,7 +1036,7 @@
<type> <type>
<arg name="mage" type="unit"/> <arg name="mage" type="unit"/>
<arg name="building" type="building"/> <arg name="building" type="building"/>
<arg name="spell" type="string"/> <arg name="curse" type="string"/>
<arg name="months" type="int"/> <arg name="months" type="int"/>
</type> </type>
<text locale="de">"$unit($mage) fand heraus, dass auf $building($building) der Zauber $spell liegt, der noch etwa $int($months) Wochen bestehen bleibt."</text> <text locale="de">"$unit($mage) fand heraus, dass auf $building($building) der Zauber $spell liegt, der noch etwa $int($months) Wochen bestehen bleibt."</text>
@ -1047,7 +1047,7 @@
<type> <type>
<arg name="mage" type="unit"/> <arg name="mage" type="unit"/>
<arg name="unit" type="unit"/> <arg name="unit" type="unit"/>
<arg name="spell" type="string"/> <arg name="curse" type="string"/>
<arg name="months" type="int"/> <arg name="months" type="int"/>
</type> </type>
<text locale="de">"$unit($mage) fand heraus, dass auf $unit($unit) der Zauber $spell liegt, der noch etwa $int($months) Wochen bestehen bleibt."</text> <text locale="de">"$unit($mage) fand heraus, dass auf $unit($unit) der Zauber $spell liegt, der noch etwa $int($months) Wochen bestehen bleibt."</text>
@ -1058,7 +1058,7 @@
<type> <type>
<arg name="mage" type="unit"/> <arg name="mage" type="unit"/>
<arg name="region" type="region"/> <arg name="region" type="region"/>
<arg name="spell" type="string"/> <arg name="curse" type="string"/>
<arg name="months" type="int"/> <arg name="months" type="int"/>
</type> </type>
<text locale="de">"$unit($mage) fand heraus, dass auf $region($region) der Zauber $spell liegt, der noch etwa $int($months) Wochen bestehen bleibt."</text> <text locale="de">"$unit($mage) fand heraus, dass auf $region($region) der Zauber $spell liegt, der noch etwa $int($months) Wochen bestehen bleibt."</text>
@ -1069,7 +1069,7 @@
<type> <type>
<arg name="mage" type="unit"/> <arg name="mage" type="unit"/>
<arg name="ship" type="ship"/> <arg name="ship" type="ship"/>
<arg name="spell" type="string"/> <arg name="curse" type="string"/>
</type> </type>
<text locale="de">"$unit($mage) fand heraus, dass auf $ship($ship) der Zauber $spell liegt, dessen Kraft ausreicht, um noch Jahrhunderte bestehen zu bleiben."</text> <text locale="de">"$unit($mage) fand heraus, dass auf $ship($ship) der Zauber $spell liegt, dessen Kraft ausreicht, um noch Jahrhunderte bestehen zu bleiben."</text>
<text locale="fr">"$unit($mage) discovers that $ship($ship) is charmed with $spell, which will last for centuries."</text> <text locale="fr">"$unit($mage) discovers that $ship($ship) is charmed with $spell, which will last for centuries."</text>
@ -1079,7 +1079,7 @@
<type> <type>
<arg name="mage" type="unit"/> <arg name="mage" type="unit"/>
<arg name="building" type="building"/> <arg name="building" type="building"/>
<arg name="spell" type="string"/> <arg name="curse" type="string"/>
</type> </type>
<text locale="de">"$unit($mage) fand heraus, dass auf $building($building) der Zauber $spell liegt, dessen Kraft ausreicht, um noch Jahrhunderte bestehen zu bleiben."</text> <text locale="de">"$unit($mage) fand heraus, dass auf $building($building) der Zauber $spell liegt, dessen Kraft ausreicht, um noch Jahrhunderte bestehen zu bleiben."</text>
<text locale="fr">"$unit($mage) discovers that $building($building) is charmed with $spell, which will last for centuries."</text> <text locale="fr">"$unit($mage) discovers that $building($building) is charmed with $spell, which will last for centuries."</text>
@ -1089,7 +1089,7 @@
<type> <type>
<arg name="mage" type="unit"/> <arg name="mage" type="unit"/>
<arg name="unit" type="unit"/> <arg name="unit" type="unit"/>
<arg name="spell" type="string"/> <arg name="curse" type="string"/>
</type> </type>
<text locale="de">"$unit($mage) fand heraus, dass auf $unit($unit) der Zauber $spell liegt, dessen Kraft ausreicht, um noch Jahrhunderte bestehen zu bleiben."</text> <text locale="de">"$unit($mage) fand heraus, dass auf $unit($unit) der Zauber $spell liegt, dessen Kraft ausreicht, um noch Jahrhunderte bestehen zu bleiben."</text>
<text locale="fr">"$unit($mage) discovers that $unit($unit) is charmed with $spell, which will last for centuries."</text> <text locale="fr">"$unit($mage) discovers that $unit($unit) is charmed with $spell, which will last for centuries."</text>
@ -1099,7 +1099,7 @@
<type> <type>
<arg name="mage" type="unit"/> <arg name="mage" type="unit"/>
<arg name="region" type="region"/> <arg name="region" type="region"/>
<arg name="spell" type="string"/> <arg name="curse" type="string"/>
</type> </type>
<text locale="de">"$unit($mage) fand heraus, dass auf $region($region) der Zauber $spell liegt, dessen Kraft ausreicht, um noch Jahrhunderte bestehen zu bleiben."</text> <text locale="de">"$unit($mage) fand heraus, dass auf $region($region) der Zauber $spell liegt, dessen Kraft ausreicht, um noch Jahrhunderte bestehen zu bleiben."</text>
<text locale="fr">"$unit($mage) discovers that $region($region) is charmed with $spell, which will last for centuries."</text> <text locale="fr">"$unit($mage) discovers that $region($region) is charmed with $spell, which will last for centuries."</text>
@ -1274,8 +1274,8 @@
<arg name="region" type="region"/> <arg name="region" type="region"/>
<arg name="spell" type="spell"/> <arg name="spell" type="spell"/>
</type> </type>
<text locale="de">"$unit($unit) unterläuft in $region($region) beim Zaubern von $spell ein Patzer:"</text> <text locale="de">"$unit($unit) unterläuft in $region($region) beim Zaubern von $spell($spell) ein Patzer:"</text>
<text locale="en">"$unit($unit) fumbles while casting $spell in $region($region):"</text> <text locale="en">"$unit($unit) fumbles while casting $spell($spell) in $region($region):"</text>
</message> </message>
<message name="patzer3" section="magic"> <message name="patzer3" section="magic">
<type> <type>