Crashbug in der Auswertung, reference count bei magie-message nicht richtig (ADDMSG Makro)

This commit is contained in:
Enno Rehling 2004-04-18 12:30:01 +00:00
parent a6e923896d
commit ea0ff4f57e
3 changed files with 73 additions and 94 deletions

View File

@ -68,7 +68,7 @@ extern const struct messageclass * mc_find(const char * name);
/* convenience, deprecated */ /* convenience, deprecated */
extern struct message * new_message(struct faction * receiver, const char * signature, ...); extern struct message * new_message(struct faction * receiver, const char * signature, ...);
#define ADDMSG(msgs, mcreate) { message * m = mcreate; if (m) { add_message(msgs, m); msg_release(m); } } #define ADDMSG(msgs, mcreate) { message * m = mcreate; assert (m->refcount==1); if (m) { add_message(msgs, m); msg_release(m); } }
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -454,8 +454,8 @@ report_effect(region * r, unit * mage, message * seen, message * unseen)
} }
/* Ist niemand von der Partei des Magiers in der Region, dem Magier /* Ist niemand von der Partei des Magiers in der Region, dem Magier
* nochmal gesondert melden */ * nochmal gesondert melden */
if(!fval(mage->faction, FL_DH)) { if (!fval(mage->faction, FL_DH)) {
ADDMSG(&mage->faction->msgs, seen); add_message(&mage->faction->msgs, seen);
} }
msg_release(seen); msg_release(seen);
if (unseen) msg_release(unseen); if (unseen) msg_release(unseen);
@ -1746,7 +1746,7 @@ sp_great_drought(castorder *co)
sprintf(buf, "%s ruft das Feuer der Sonne auf %s hinab.", sprintf(buf, "%s ruft das Feuer der Sonne auf %s hinab.",
cansee(u->faction, r, mage, 0)? unitname(mage) : "Jemand", cansee(u->faction, r, mage, 0)? unitname(mage) : "Jemand",
regionid(r)); regionid(r));
if(rterrain(r) != T_OCEAN){ if (rterrain(r) != T_OCEAN){
if(rterrain(r) == T_SWAMP && terraform){ if(rterrain(r) == T_SWAMP && terraform){
scat(" Eis schmilzt und verwandelt sich in Morast. Reißende " scat(" Eis schmilzt und verwandelt sich in Morast. Reißende "
"Ströme spülen die mageren Felder weg und ersäufen " "Ströme spülen die mageren Felder weg und ersäufen "
@ -1772,7 +1772,7 @@ sp_great_drought(castorder *co)
} }
} }
} }
if(!fval(mage->faction, FL_DH)){ if (!fval(mage->faction, FL_DH)){
ADDMSG(&mage->faction->msgs, msg_message( ADDMSG(&mage->faction->msgs, msg_message(
"drought_effect", "mage region", mage, r)); "drought_effect", "mage region", mage, r));
} }
@ -3004,11 +3004,10 @@ wall_move(const border * b, struct unit * u, const struct region * from, const s
hp = min (u->hp, hp); hp = min (u->hp, hp);
u->hp -= hp; u->hp -= hp;
if (u->hp) { if (u->hp) {
ADDMSG(&u->faction->msgs, ADDMSG(&u->faction->msgs, msg_message("firewall_damage",
msg_message( "firewall_damage", "region unit", from, u)); "region unit", from, u));
} }
else ADDMSG(&u->faction->msgs, else ADDMSG(&u->faction->msgs, msg_message("firewall_death", "region unit", from, u));
msg_message( "firewall_death", "region unit", from, u));
if (u->number>u->hp) { if (u->number>u->hp) {
scale_number(u, u->hp); scale_number(u, u->hp);
u->hp = u->number; u->hp = u->number;
@ -3037,7 +3036,6 @@ border_type bt_firewall = {
static int static int
sp_firewall(castorder *co) sp_firewall(castorder *co)
{ {
unit * u;
border * b; border * b;
wall_data * fd; wall_data * fd;
attrib * a; attrib * a;
@ -3087,19 +3085,10 @@ sp_firewall(castorder *co)
} }
/* melden, 1x pro Partei */ /* melden, 1x pro Partei */
for (u = r->units; u; u = u->next) freset(u->faction, FL_DH); {
message * seen = msg_message("firewall_effect", "mage region", mage, r);
for (u = r->units; u; u = u->next ) { message * unseen = msg_message("firewall_effect", "mage region", NULL, r);
if(!fval(u->faction, FL_DH) ) { report_effect(r, mage, seen, unseen);
fset(u->faction, FL_DH);
ADDMSG(&u->faction->msgs, msg_message(
"firewall_effect", "mage region",
cansee(u->faction, r, mage, 0) ? mage:NULL, r));
}
}
if(!fval(mage->faction, FL_DH)){
ADDMSG(&mage->faction->msgs, msg_message(
"firewall_effect", "mage region", mage, r));
} }
return cast_level; return cast_level;
@ -3136,7 +3125,6 @@ border_type bt_wisps = {
static int static int
sp_wisps(castorder *co) sp_wisps(castorder *co)
{ {
unit * u;
border * b; border * b;
wall_data * fd; wall_data * fd;
region * r2; region * r2;
@ -3164,19 +3152,10 @@ sp_wisps(castorder *co)
a_add(&b->attribs, a_new(&at_countdown))->data.i = cast_level; a_add(&b->attribs, a_new(&at_countdown))->data.i = cast_level;
/* melden, 1x pro Partei */ /* melden, 1x pro Partei */
for (u = r->units; u; u = u->next) freset(u->faction, FL_DH); {
message * seen = msg_message("wisps_effect", "mage region", mage, r);
for(u = r->units; u; u = u->next ) { message * unseen = msg_message("wisps_effect", "mage region", NULL, r);
if(!fval(u->faction, FL_DH) ) { report_effect(r, mage, seen, unseen);
fset(u->faction, FL_DH);
ADDMSG(&u->faction->msgs, msg_message(
"wisps_effect", "mage region",
cansee(u->faction, r, mage, 0) ? mage:NULL, r));
}
}
if(!fval(mage->faction, FL_DH)){
ADDMSG(&mage->faction->msgs, msg_message(
"wisps_effect", "mage region", mage, r));
} }
return cast_level; return cast_level;
@ -7299,8 +7278,7 @@ sp_becomewyrm(castorder *co)
mage->race = new_race[RC_WYRM]; mage->race = new_race[RC_WYRM];
addspell(mage, SPL_WYRMODEM); addspell(mage, SPL_WYRMODEM);
ADDMSG(&mage->faction->msgs, msg_message( ADDMSG(&mage->faction->msgs, msg_message("becomewyrm", "mage", mage));
"becomewyrm", "mage", mage));
return co->level; return co->level;
} }

View File

@ -900,6 +900,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="extended" type="string"/>
</type> </type>
<text locale="de">"$unit($mage) ruft das Feuer der Sonne auf $region($region) herab."</text> <text locale="de">"$unit($mage) ruft das Feuer der Sonne auf $region($region) herab."</text>
</message> </message>