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 */
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
}

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
* nochmal gesondert melden */
if(!fval(mage->faction, FL_DH)) {
ADDMSG(&mage->faction->msgs, seen);
if (!fval(mage->faction, FL_DH)) {
add_message(&mage->faction->msgs, seen);
}
msg_release(seen);
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.",
cansee(u->faction, r, mage, 0)? unitname(mage) : "Jemand",
regionid(r));
if(rterrain(r) != T_OCEAN){
if (rterrain(r) != T_OCEAN){
if(rterrain(r) == T_SWAMP && terraform){
scat(" Eis schmilzt und verwandelt sich in Morast. Reißende "
"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(
"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);
u->hp -= hp;
if (u->hp) {
ADDMSG(&u->faction->msgs,
msg_message( "firewall_damage", "region unit", from, u));
ADDMSG(&u->faction->msgs, msg_message("firewall_damage",
"region unit", from, u));
}
else ADDMSG(&u->faction->msgs,
msg_message( "firewall_death", "region unit", from, u));
else ADDMSG(&u->faction->msgs, msg_message("firewall_death", "region unit", from, u));
if (u->number>u->hp) {
scale_number(u, u->hp);
u->hp = u->number;
@ -3037,7 +3036,6 @@ border_type bt_firewall = {
static int
sp_firewall(castorder *co)
{
unit * u;
border * b;
wall_data * fd;
attrib * a;
@ -3087,19 +3085,10 @@ sp_firewall(castorder *co)
}
/* melden, 1x pro Partei */
for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
for (u = r->units; u; u = u->next ) {
if(!fval(u->faction, FL_DH) ) {
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));
{
message * seen = msg_message("firewall_effect", "mage region", mage, r);
message * unseen = msg_message("firewall_effect", "mage region", NULL, r);
report_effect(r, mage, seen, unseen);
}
return cast_level;
@ -3136,7 +3125,6 @@ border_type bt_wisps = {
static int
sp_wisps(castorder *co)
{
unit * u;
border * b;
wall_data * fd;
region * r2;
@ -3164,19 +3152,10 @@ sp_wisps(castorder *co)
a_add(&b->attribs, a_new(&at_countdown))->data.i = cast_level;
/* melden, 1x pro Partei */
for (u = r->units; u; u = u->next) freset(u->faction, FL_DH);
for(u = r->units; u; u = u->next ) {
if(!fval(u->faction, FL_DH) ) {
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));
{
message * seen = msg_message("wisps_effect", "mage region", mage, r);
message * unseen = msg_message("wisps_effect", "mage region", NULL, r);
report_effect(r, mage, seen, unseen);
}
return cast_level;
@ -7299,8 +7278,7 @@ sp_becomewyrm(castorder *co)
mage->race = new_race[RC_WYRM];
addspell(mage, SPL_WYRMODEM);
ADDMSG(&mage->faction->msgs, msg_message(
"becomewyrm", "mage", mage));
ADDMSG(&mage->faction->msgs, msg_message("becomewyrm", "mage", mage));
return co->level;
}

View File

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