code cleanup: removed all old cases of new_message being called, and the function itself.

This commit is contained in:
Enno Rehling 2006-01-08 11:33:10 +00:00
parent f1b344f7e9
commit 6ad7a5562e
15 changed files with 98 additions and 212 deletions

View file

@ -1818,12 +1818,11 @@ expandbuying(region * r, request * buyorders)
attrib * a = a_find(u->attribs, &at_luxuries); attrib * a = a_find(u->attribs, &at_luxuries);
item * itm; item * itm;
if (a==NULL) continue; if (a==NULL) continue;
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("buy", "unit money", u, u->n));
"buy%u:unit%i:money", u, u->n));
for (itm=(item*)a->data.v; itm; itm=itm->next) { for (itm=(item*)a->data.v; itm; itm=itm->next) {
if (itm->number) { if (itm->number) {
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("buyamount",
"buyamount%u:unit%i:amount%X:resource", u, itm->number, itm->type->rtype)); "unit amount resource", u, itm->number, itm->type->rtype));
} }
} }
a_remove(&u->attribs, a); a_remove(&u->attribs, a);
@ -2477,8 +2476,8 @@ breedtrees(region *r, unit *u, int raw)
produceexp(u, SK_HERBALISM, u->number); produceexp(u, SK_HERBALISM, u->number);
use_pooled(u, rtype, GET_DEFAULT, n); use_pooled(u, rtype, GET_DEFAULT, n);
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("plant",
"plant%u:unit%r:region%i:amount%X:herb", u, r, planted, rtype)); "unit region amount herb", u, r, planted, rtype));
} }
static void static void
@ -2562,8 +2561,8 @@ breedhorses(region *r, unit *u)
produceexp(u, SK_HORSE_TRAINING, u->number); produceexp(u, SK_HORSE_TRAINING, u->number);
} }
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("raised",
"raised%u:unit%i:amount", u, gezuechtet)); "unit amount", u, gezuechtet));
} }
static void static void
@ -2648,16 +2647,16 @@ research_cmd(unit *u, struct order * ord)
const item_type *itype = rherbtype(r); const item_type *itype = rherbtype(r);
if (itype != NULL) { if (itype != NULL) {
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("researchherb",
"researchherb%u:unit%r:region%s:amount%X:herb", u, r, "unit region amount herb",
rough_amount(rherbs(r), 100), itype->rtype)); u, r, rough_amount(rherbs(r), 100), itype->rtype));
} else { } else {
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("researchherb_none",
"researchherb_none%u:unit%r:region", u, r)); "unit region", u, r));
} }
} else { } else {
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("researchherb_none",
"researchherb_none%u:unit%r:region", u, r)); "unit region", u, r));
} }
} }
@ -2741,31 +2740,23 @@ steal_cmd(unit * u, struct order * ord, request ** stealorders)
if (n == 0) { if (n == 0) {
/* Wahrnehmung == Tarnung */ /* Wahrnehmung == Tarnung */
if (u->race != new_race[RC_GOBLIN] || eff_skill(u, SK_STEALTH, r) <= 3) { if (u->race != new_race[RC_GOBLIN] || eff_skill(u, SK_STEALTH, r) <= 3) {
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("stealfail", "unit target", u, u2));
"stealfail%u:unit%u:target", u, u2)); ADDMSG(&u2->faction->msgs, msg_message("stealdetect", "unit", u2));
add_message(&u2->faction->msgs, new_message(u2->faction, return;
"stealdetect%u:unit", u2));
return;
} else { } else {
add_message(&u2->faction->msgs, new_message(u2->faction, ADDMSG(&u2->faction->msgs, msg_message("thiefdiscover", "unit target", u, u2));
"thiefdiscover%u:unit%u:target", u, u2)); ADDMSG(&u->faction->msgs, msg_message("stealfatal", "unit target", u, u2));
add_message(&u->faction->msgs, new_message(u->faction, n = 1;
"stealfatal%u:unit%u:target", u, u2));
n = 1;
goblin = true; goblin = true;
} }
} else if (n < 0) { } else if (n < 0) {
/* Wahrnehmung > Tarnung */ /* Wahrnehmung > Tarnung */
if (u->race != new_race[RC_GOBLIN] || eff_skill(u, SK_STEALTH, r) <= 3) { if (u->race != new_race[RC_GOBLIN] || eff_skill(u, SK_STEALTH, r) <= 3) {
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("stealfatal", "unit target", u, u2));
"stealfatal%u:unit%u:target", u, u2)); ADDMSG(&u2->faction->msgs, msg_message("thiefdiscover", "unit target", u, u2));
return;
add_message(&u2->faction->msgs, new_message(u2->faction,
"thiefdiscover%u:unit%u:target", u, u2));
return;
} else { /* Goblin-Spezialdiebstahl, Meldung an Beklauten */ } else { /* Goblin-Spezialdiebstahl, Meldung an Beklauten */
add_message(&u2->faction->msgs, new_message(u2->faction, ADDMSG(&u2->faction->msgs, msg_message("thiefdiscover", "unit target", u, u2));
"thiefdiscover%u:unit%u:target", u, u2));
n = 1; n = 1;
goblin = true; goblin = true;
} }

View file

@ -1525,11 +1525,11 @@ name_cmd(unit * u, struct order * ord)
uo = buildingowner(r, b); uo = buildingowner(r, b);
if (uo) { if (uo) {
if (cansee(uo->faction, r, u, 0)) { if (cansee(uo->faction, r, u, 0)) {
add_message(&uo->faction->msgs, new_message(uo->faction, ADDMSG(&uo->faction->msgs, msg_message("renamed_building_seen",
"renamed_building_seen%b:building%u:renamer%r:region", b, u, r)); "building renamer region", b, u, r));
} else { } else {
add_message(&uo->faction->msgs, new_message(uo->faction, ADDMSG(&uo->faction->msgs, msg_message("renamed_building_notseen",
"renamed_building_notseen%b:building%r:region", b, r)); "building region", b, r));
} }
} }
s = &b->name; s = &b->name;
@ -1629,11 +1629,11 @@ name_cmd(unit * u, struct order * ord)
uo = shipowner(sh); uo = shipowner(sh);
if (uo) { if (uo) {
if (cansee(uo->faction, r, u, 0)) { if (cansee(uo->faction, r, u, 0)) {
add_message(&uo->faction->msgs, new_message(uo->faction, ADDMSG(&uo->faction->msgs, msg_message("renamed_ship_seen",
"renamed_ship_seen%h:ship%u:renamer%r:region", sh, u, r)); "ship renamer region", sh, u, r));
} else { } else {
add_message(&uo->faction->msgs, new_message(uo->faction, ADDMSG(&uo->faction->msgs, msg_message("renamed_ship_notseen",
"renamed_ship_notseen%h:ship%r:region", sh, r)); "ship region", sh, r));
} }
} }
s = &sh->name; s = &sh->name;
@ -1667,11 +1667,11 @@ name_cmd(unit * u, struct order * ord)
} }
} }
if (cansee(u2->faction, r, u, 0)) { if (cansee(u2->faction, r, u, 0)) {
add_message(&u2->faction->msgs, new_message(u2->faction, ADDMSG(&u2->faction->msgs, msg_message("renamed_seen",
"renamed_seen%u:renamer%u:renamed%r:region", u, u2, r)); "renamer renamed region", u, u2, r));
} else { } else {
add_message(&u2->faction->msgs, new_message(u2->faction, ADDMSG(&u2->faction->msgs, msg_message("renamed_notseen",
"renamed_notseen%u:renamed%r:region", u2, r)); "renamed region", u2, r));
} }
s = &u2->name; s = &u2->name;
} else { } else {

View file

@ -69,8 +69,8 @@ lucky_silver(const unit *u)
i_change(&((unit *)u)->items, i_silver, max); i_change(&((unit *)u)->items, i_silver, max);
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("lucky_item",
"lucky_item%u:unit%X:item%d:amount", u, i_silver->rtype, max)); "unit item amount", u, i_silver->rtype, max));
} }
typedef struct luckyitem { typedef struct luckyitem {
@ -115,9 +115,8 @@ lucky_item(const unit *u)
amount = 5 + rand()%10 +rand()%10; amount = 5 + rand()%10 +rand()%10;
i_change(&((unit *)u)->items, itype, amount); i_change(&((unit *)u)->items, itype, amount);
ADDMSG(&u->faction->msgs, msg_message("lucky_item",
add_message(&u->faction->msgs, new_message(u->faction, "unit item amount", u, itype->rtype, amount));
"lucky_item%u:unit%X:item%d:amount", u, itype->rtype, amount));
} }
static void static void
@ -147,9 +146,8 @@ lucky_magic_item(const unit *u)
amount = 1 + rand()%luck; amount = 1 + rand()%luck;
i_change(&((unit *)u)->items, itype, amount); i_change(&((unit *)u)->items, itype, amount);
ADDMSG(&u->faction->msgs, msg_message("lucky_item",
add_message(&u->faction->msgs, new_message(u->faction, "unit item amount", u, itype->rtype, amount));
"lucky_item%u:unit%X:item%d:amount", u, itype->rtype, amount));
#endif #endif
} }

View file

@ -700,16 +700,15 @@ drown(region *r)
if (amphibian_level) { if (amphibian_level) {
int dead = damage_unit(u, "5d1", false, false); int dead = damage_unit(u, "5d1", false, false);
if (dead) { if (dead) {
ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("drown_amphibian_dead",
"drown_amphibian_dead%d:amount%u:unit%r:region",dead, u, r)); "amount unit region", dead, u, r));
} else { } else {
ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("drown_amphibian_nodead",
"drown_amphibian_nodead%u:unit%r:region",u, r)); "unit region",u, r));
} }
} else if (!(canswim(u) || canfly(u))) { } else if (!(canswim(u) || canfly(u))) {
scale_number(u, 0); scale_number(u, 0);
ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("drown", "unit region", u, r));
"drown%u:unit%r:region", u, r));
} }
if (*up==u) up=&u->next; if (*up==u) up=&u->next;
} }
@ -779,17 +778,17 @@ volcano_outbreak(region *r)
unit * u = *up; unit * u = *up;
int dead = damage_unit(u, "4d10", true, false); int dead = damage_unit(u, "4d10", true, false);
if (dead) { if (dead) {
ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("volcano_dead",
"volcano_dead%u:unit%r:region%i:dead", u, r, dead)); "unit region dead", u, r, dead));
} }
if (!fval(u->faction, FL_DH)) { if (!fval(u->faction, FL_DH)) {
fset(u->faction, FL_DH); fset(u->faction, FL_DH);
if (rn) { if (rn) {
ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("volcanooutbreak",
"volcanooutbreak%r:regionv%r:regionn", r, rn)); "regionv regionn", r, rn));
} else { } else {
ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("volcanooutbreaknn",
"volcanooutbreaknn%r:region", r)); "region", r));
} }
} }
if (u==*up) up=&u->next; if (u==*up) up=&u->next;
@ -818,12 +817,12 @@ volcano_outbreak(region *r)
unit * u = *up; unit * u = *up;
int dead = damage_unit(u, "3d10", true, false); int dead = damage_unit(u, "3d10", true, false);
if (dead) { if (dead) {
ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("volcano_dead",
"volcano_dead%u:unit%r:region%i:dead", u, rn, dead)); "unit region dead", u, rn, dead));
} }
if (!fval(u->faction, FL_DH)) { if (!fval(u->faction, FL_DH)) {
ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("volcano_dead",
"volcano_dead%u:unit%r:region%i:dead", u, r, dead)); "unit region dead", u, r, dead));
fset(u->faction, FL_DH); fset(u->faction, FL_DH);
} }
if (u==*up) up=&u->next; if (u==*up) up=&u->next;
@ -895,8 +894,8 @@ move_iceberg(region *r)
for (u=r->units; u; u=u->next) freset(u->faction, FL_DH); 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)) { for (u=r->units; u; u=u->next) if (!fval(u->faction, FL_DH)) {
fset(u->faction, FL_DH); fset(u->faction, FL_DH);
ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("iceberg_drift",
"iceberg_drift%r:region%d:dir", r, dir)); "region dir", r, dir));
} }
x = r->x; x = r->x;
@ -948,12 +947,14 @@ move_iceberg(region *r)
if (fval(sh, FL_DH)) { if (fval(sh, FL_DH)) {
u = captain(sh, r); u = captain(sh, r);
if (sh->damage>=sh->size * DAMAGE_SCALE) { if (sh->damage>=sh->size * DAMAGE_SCALE) {
if (u) ADDMSG(&u->faction->msgs, new_message(u->faction, if (u!=NULL) {
"overrun_by_iceberg_des%h:ship", sh)); ADDMSG(&u->faction->msgs, msg_message("overrun_by_iceberg_des",
"ship", sh));
}
destroy_ship(sh); destroy_ship(sh);
} else { } else if (u!=NULL) {
if (u) ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("overrun_by_iceberg",
"overrun_by_iceberg%h:ship", sh)); "ship", sh));
} }
} }
sh = shn; sh = shn;
@ -968,8 +969,7 @@ move_iceberg(region *r)
for (u=r->units; u; u=u->next) freset(u->faction, FL_DH); 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)) { for (u=r->units; u; u=u->next) if (!fval(u->faction, FL_DH)) {
fset(u->faction, FL_DH); fset(u->faction, FL_DH);
ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("iceberg_land", "region", r));
"iceberg_land%r:region", r));
} }
} }
} }

View file

@ -108,9 +108,9 @@ spy_cmd(unit * u, struct order * ord)
observechance = 1.0 - (eff_skill(u, SK_SPY, r) * 0.05) observechance = 1.0 - (eff_skill(u, SK_SPY, r) * 0.05)
+ (eff_skill(target, SK_OBSERVATION, r) * 0.02); + (eff_skill(target, SK_OBSERVATION, r) * 0.02);
if (chance(observechance)){ if (chance(observechance)) {
add_message(&target->faction->msgs, new_message(target->faction, ADDMSG(&target->faction->msgs, msg_message("spydetect",
"spydetect%u:spy%u:target", observe>0?u:NULL, target)); "spy target", observe>0?u:NULL, target));
} }
return 0; return 0;
} }

View file

@ -50,8 +50,7 @@ use_skillpotion(struct unit * u, const struct item_type * itype, int amount, str
++sv; ++sv;
} }
} }
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("skillpotion_use", "unit", u));
"skillpotion_use%u:unit", u));
res_changeitem(u, itype->rtype, -amount); res_changeitem(u, itype->rtype, -amount);
return 0; return 0;
@ -72,8 +71,7 @@ use_manacrystal(struct unit * u, const struct item_type * itype, int amount, str
change_spellpoints(u, sp); change_spellpoints(u, sp);
} }
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("manacrystal_use", "unit aura", u, sp));
"manacrystal_use%u:unit%i:aura", u, sp));
res_changeitem(u, itype->rtype, -amount); res_changeitem(u, itype->rtype, -amount);
return 0; return 0;

View file

@ -81,8 +81,8 @@ herbsearch(region * r, unit * u, int max)
ADDMSG(&u->faction->msgs, msg_message("herbfound", ADDMSG(&u->faction->msgs, msg_message("herbfound",
"unit region amount herb", u, r, herbsfound, whichherb->rtype)); "unit region amount herb", u, r, herbsfound, whichherb->rtype));
} else { } else {
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("researchherb_none",
"researchherb_none%u:unit%r:region", u, u->region)); "unit region", u, u->region));
} }
} }
@ -114,8 +114,8 @@ use_potion(unit * u, const item_type * itype, int amount, struct order *ord)
} }
if (r->land==0) holz=0; if (r->land==0) holz=0;
rsettrees(r, 1, rtrees(r, 1) + holz); rsettrees(r, 1, rtrees(r, 1) + holz);
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("growtree_effect",
"growtree_effect%u:mage%i:amount", u, holz)); "mage amount", u, holz));
} else if (ptype==oldpotiontype[P_HEAL]) { } else if (ptype==oldpotiontype[P_HEAL]) {
return EUNUSABLE; return EUNUSABLE;
} else if (ptype==oldpotiontype[P_HEILWASSER]) { } else if (ptype==oldpotiontype[P_HEILWASSER]) {

View file

@ -2760,8 +2760,8 @@ hunger(int number, unit * u)
if (dead) { if (dead) {
/* Gestorbene aus der Einheit nehmen, /* Gestorbene aus der Einheit nehmen,
* Sie bekommen keine Beerdingung. */ * Sie bekommen keine Beerdingung. */
ADDMSG(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("starvation",
"starvation%u:unit%r:region%i:dead%i:live", u, r, dead, u->number-dead)); "unit region dead live", u, r, dead, u->number-dead));
scale_number(u, u->number - dead); scale_number(u, u->number - dead);
deathcounts(r, dead); deathcounts(r, dead);
@ -2772,8 +2772,8 @@ hunger(int number, unit * u)
/* Meldung nur, wenn noch keine für Tote generiert. */ /* Meldung nur, wenn noch keine für Tote generiert. */
if (dead == 0) { if (dead == 0) {
/* Durch unzureichende Ernährung wird %s geschwächt */ /* Durch unzureichende Ernährung wird %s geschwächt */
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("malnourish",
"malnourish%u:unit%r:region", u, r)); "unit region", u, r));
} }
} }
return (dead || hpsub); return (dead || hpsub);

View file

@ -638,8 +638,8 @@ use_tacticcrystal(region * r, unit * u, int amount, struct order * ord)
unused(ord); unused(ord);
} }
use_pooled(u, oldresourcetype[R_TACTICCRYSTAL], GET_DEFAULT, amount); use_pooled(u, oldresourcetype[R_TACTICCRYSTAL], GET_DEFAULT, amount);
add_message(&u->faction->msgs, ADDMSG(&u->faction->msgs, msg_message("use_tacticcrystal",
new_message(u->faction, "use_tacticcrystal%u:unit%r:region", u, r)); "unit region", u, r));
return; return;
} }

View file

@ -334,8 +334,8 @@ buy_special(unit *u, struct order * ord, fspecial_t special)
if (a2) { if (a2) {
if(a2->data.sa[1] < fspecials[special].maxlevel) { if(a2->data.sa[1] < fspecials[special].maxlevel) {
a2->data.sa[1]++; a2->data.sa[1]++;
add_message(&f->msgs, new_message(f, ADDMSG(&f->msgs, msg_message("new_fspecial_level",
"new_fspecial_level%S:special%d:level", special, a2->data.sa[1])); "special level", special, a2->data.sa[1]));
} else { } else {
cmistake(u, ord, 251, MSG_EVENT); cmistake(u, ord, 251, MSG_EVENT);
return; return;
@ -344,7 +344,7 @@ buy_special(unit *u, struct order * ord, fspecial_t special)
a2 = a_add(&f->attribs, a_new(&at_faction_special)); a2 = a_add(&f->attribs, a_new(&at_faction_special));
a2->data.sa[0] = (short)special; a2->data.sa[0] = (short)special;
a2->data.sa[1] = 1; a2->data.sa[1] = 1;
add_message(&f->msgs, new_message(f, "new_fspecial%S:special", special)); ADDMSG(&f->msgs, msg_message("new_fspecial", "special", special));
} }
} }
@ -458,8 +458,7 @@ prayer_cmd(unit * u, struct order * ord)
u->faction->karma -= karma_cost; u->faction->karma -= karma_cost;
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("pray_success", "unit", u));
"pray_success%u:unit",u));
switch (p) { switch (p) {
case P_AURA: case P_AURA:

View file

@ -1634,9 +1634,9 @@ verify_targets(castorder *co)
spobj->data.i = b->no; spobj->data.i = b->no;
spobj->flag = TARGET_RESISTS; spobj->flag = TARGET_RESISTS;
resists++; resists++;
add_message(&mage->faction->msgs, new_message(mage->faction, ADDMSG(&mage->faction->msgs, msg_message("spellbuildingresists",
"spellbuildingresists%u:unit%r:region%s:command%d:id", "unit region command id",
mage, mage->region, co->order, spobj->data.i)); mage, mage->region, co->order, spobj->data.i));
break; break;
} }
success++; success++;
@ -1702,9 +1702,8 @@ verify_targets(castorder *co)
if ((sp->sptyp & TESTRESISTANCE)) { if ((sp->sptyp & TESTRESISTANCE)) {
if (target_resists_magic(mage, target_r, TYP_REGION, 0)) { if (target_resists_magic(mage, target_r, TYP_REGION, 0)) {
/* Fehlermeldung */ /* Fehlermeldung */
add_message(&mage->faction->msgs, new_message(mage->faction, ADDMSG(&mage->faction->msgs, msg_message("spellregionresists",
"spellregionresists%u:unit%r:region%s:command", "unit region command", mage, mage->region, co->order));
mage, mage->region, co->order));
spobj->flag = TARGET_RESISTS; spobj->flag = TARGET_RESISTS;
resists++; resists++;
} else { } else {

View file

@ -207,102 +207,6 @@ msg_message(const char * name, const char* sig, ...)
return msg_create(mtype, args); return msg_create(mtype, args);
} }
message *
new_message(struct faction * receiver, const char* sig, ...)
/* compatibility function, to keep the old function calls valid *
* all old messagetypes are converted into a message with ONLY string parameters,
* this function will convert given parameters to a string representation
* based on the signature - like render() once did */
{
const message_type * mtype;
va_list marker;
const char * signature = strchr(sig, '%');
char buffer[128];
int i=0;
const char * c = sig;
variant args[16];
memset(args, 0, sizeof(args));
assert(signature-sig < sizeof(buffer));
strnzcpy(buffer, sig, signature-sig);
mtype = mt_find(buffer);
if (!mtype) {
log_error(("trying to create message of unknown type \"%s\"\n", buffer));
return NULL;
}
while(*c!='%') buffer[i++] = *(c++);
buffer[i] = 0;
va_start(marker, sig);
while (*c) {
char type;
char *p = buffer;
assert(*c=='%');
type = *(++c);
/*
case 'f': (*ep)->type = IT_FACTION; break;
case 'u': (*ep)->type = IT_UNIT; break;
case 'r': (*ep)->type = IT_REGION; break;
case 'h': (*ep)->type = IT_SHIP; break;
case 'b': (*ep)->type = IT_BUILDING; break;
case 'X': (*ep)->type = IT_RESOURCETYPE; break;
case 'x': (*ep)->type = IT_RESOURCE; break;
case 't': (*ep)->type = IT_SKILL; break;
case 's': (*ep)->type = IT_STRING; break;
case 'i': (*ep)->type = IT_INT; break;
case 'd': (*ep)->type = IT_DIRECTION; break;
case 'S': (*ep)->type = IT_FSPECIAL; break;
*/
c+=2;
while (*c && isalnum(*(unsigned char*)c)) *(p++) = *(c++);
*p = '\0';
for (i=0;i!=mtype->nparameters;++i) {
if (!strcmp(buffer, mtype->pnames[i])) break;
}
if (i==mtype->nparameters) {
log_error(("unknown message-parameter for %s: %s (%p)\n", mtype->name, buffer, va_arg(marker, void*)));
continue;
}
switch(type) {
case 's':
args[i].v = (void*)va_arg(marker, const char *);
break;
case 'f':
args[i].v = (void*)va_arg(marker, const struct faction*);
break;
case 'u':
args[i].v = (void*)va_arg(marker, const struct unit*);
break;
case 'r':
args[i].v = (void*)va_arg(marker, const struct region*);
break;
case 'h':
args[i].v = (void*)va_arg(marker, const struct ship*);
break;
case 'b':
args[i].v = (void*)va_arg(marker, const struct building*);
break;
case 'X':
args[i].v = (void*)va_arg(marker, const resource_type *);
break;
case 't':
case 'i':
args[i].i = va_arg(marker, int);
break;
case 'd':
args[i].i = i;
break;
case 'S':
default:
args[i].v = NULL;
}
}
va_end(marker);
return msg_create(mtype, args);
}
static void static void
caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level) caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
{ {

View file

@ -58,9 +58,6 @@ extern struct messageclass * msgclasses;
extern const struct messageclass * mc_add(const char * name); extern const struct messageclass * mc_add(const char * name);
extern const struct messageclass * mc_find(const char * name); 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) { assert(m->refcount>=1); add_message(msgs, m); msg_release(m); } } #define ADDMSG(msgs, mcreate) { message * m = mcreate; if (m) { assert(m->refcount>=1); add_message(msgs, m); msg_release(m); } }
extern void cmistake(const struct unit * u, struct order *ord, int mno, int mtype); extern void cmistake(const struct unit * u, struct order *ord, int mno, int mtype);

View file

@ -194,7 +194,7 @@ age_hurting(attrib * a) {
if (u->building==b) { if (u->building==b) {
if (u->faction->magiegebiet==M_CHAOS) { if (u->faction->magiegebiet==M_CHAOS) {
active ++; active ++;
add_message(&b->region->msgs, new_message(NULL, "praytoigjarjuk%u:unit", u)); ADDMSG(&b->region->msgs, msg_message("praytoigjarjuk", "unit", u));
} }
} }
} }
@ -202,7 +202,7 @@ age_hurting(attrib * a) {
int i; int i;
if (u->faction->magiegebiet!=M_CHAOS) { if (u->faction->magiegebiet!=M_CHAOS) {
for (i=0;i!=active;++i) u->hp = (u->hp+1) / 2; /* make them suffer, but not die */ for (i=0;i!=active;++i) u->hp = (u->hp+1) / 2; /* make them suffer, but not die */
add_message(&b->region->msgs, new_message(NULL, "cryinpain%u:unit", u)); ADDMSG(&b->region->msgs, msg_message("cryinpain", "unit", u));
} }
} }
return 1; return 1;

View file

@ -23,6 +23,7 @@
/* libc includes */ /* libc includes */
#include <stdlib.h> #include <stdlib.h>
#include <assert.h>
#define ILLUSIONMAX 6 #define ILLUSIONMAX 6
@ -31,12 +32,11 @@ age_illusion(unit *u)
{ {
if (u->faction->race!=new_race[RC_ILLUSION]) { if (u->faction->race!=new_race[RC_ILLUSION]) {
if (u->age == ILLUSIONMAX) { if (u->age == ILLUSIONMAX) {
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("warnillusiondissolve",
"warnillusiondissolve%u:unit", u)); "unit", u));
} else if (u->age > ILLUSIONMAX) { } else if (u->age > ILLUSIONMAX) {
set_number(u, 0); set_number(u, 0);
add_message(&u->faction->msgs, new_message(u->faction, ADDMSG(&u->faction->msgs, msg_message("illusiondissolve", "unit", u));
"illusiondissolve%u:unit", u));
} }
} }
} }