forked from github/server
code cleanup: removed all old cases of new_message being called, and the function itself.
This commit is contained in:
parent
f1b344f7e9
commit
6ad7a5562e
15 changed files with 98 additions and 212 deletions
|
@ -1818,12 +1818,11 @@ expandbuying(region * r, request * buyorders)
|
|||
attrib * a = a_find(u->attribs, &at_luxuries);
|
||||
item * itm;
|
||||
if (a==NULL) continue;
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"buy%u:unit%i:money", u, u->n));
|
||||
ADDMSG(&u->faction->msgs, msg_message("buy", "unit money", u, u->n));
|
||||
for (itm=(item*)a->data.v; itm; itm=itm->next) {
|
||||
if (itm->number) {
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"buyamount%u:unit%i:amount%X:resource", u, itm->number, itm->type->rtype));
|
||||
ADDMSG(&u->faction->msgs, msg_message("buyamount",
|
||||
"unit amount resource", u, itm->number, itm->type->rtype));
|
||||
}
|
||||
}
|
||||
a_remove(&u->attribs, a);
|
||||
|
@ -2477,8 +2476,8 @@ breedtrees(region *r, unit *u, int raw)
|
|||
produceexp(u, SK_HERBALISM, u->number);
|
||||
use_pooled(u, rtype, GET_DEFAULT, n);
|
||||
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"plant%u:unit%r:region%i:amount%X:herb", u, r, planted, rtype));
|
||||
ADDMSG(&u->faction->msgs, msg_message("plant",
|
||||
"unit region amount herb", u, r, planted, rtype));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2562,8 +2561,8 @@ breedhorses(region *r, unit *u)
|
|||
produceexp(u, SK_HORSE_TRAINING, u->number);
|
||||
}
|
||||
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"raised%u:unit%i:amount", u, gezuechtet));
|
||||
ADDMSG(&u->faction->msgs, msg_message("raised",
|
||||
"unit amount", u, gezuechtet));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2648,16 +2647,16 @@ research_cmd(unit *u, struct order * ord)
|
|||
const item_type *itype = rherbtype(r);
|
||||
|
||||
if (itype != NULL) {
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"researchherb%u:unit%r:region%s:amount%X:herb", u, r,
|
||||
rough_amount(rherbs(r), 100), itype->rtype));
|
||||
ADDMSG(&u->faction->msgs, msg_message("researchherb",
|
||||
"unit region amount herb",
|
||||
u, r, rough_amount(rherbs(r), 100), itype->rtype));
|
||||
} else {
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"researchherb_none%u:unit%r:region", u, r));
|
||||
ADDMSG(&u->faction->msgs, msg_message("researchherb_none",
|
||||
"unit region", u, r));
|
||||
}
|
||||
} else {
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"researchherb_none%u:unit%r:region", u, r));
|
||||
ADDMSG(&u->faction->msgs, msg_message("researchherb_none",
|
||||
"unit region", u, r));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2741,31 +2740,23 @@ steal_cmd(unit * u, struct order * ord, request ** stealorders)
|
|||
if (n == 0) {
|
||||
/* Wahrnehmung == Tarnung */
|
||||
if (u->race != new_race[RC_GOBLIN] || eff_skill(u, SK_STEALTH, r) <= 3) {
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"stealfail%u:unit%u:target", u, u2));
|
||||
add_message(&u2->faction->msgs, new_message(u2->faction,
|
||||
"stealdetect%u:unit", u2));
|
||||
return;
|
||||
ADDMSG(&u->faction->msgs, msg_message("stealfail", "unit target", u, u2));
|
||||
ADDMSG(&u2->faction->msgs, msg_message("stealdetect", "unit", u2));
|
||||
return;
|
||||
} else {
|
||||
add_message(&u2->faction->msgs, new_message(u2->faction,
|
||||
"thiefdiscover%u:unit%u:target", u, u2));
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"stealfatal%u:unit%u:target", u, u2));
|
||||
n = 1;
|
||||
ADDMSG(&u2->faction->msgs, msg_message("thiefdiscover", "unit target", u, u2));
|
||||
ADDMSG(&u->faction->msgs, msg_message("stealfatal", "unit target", u, u2));
|
||||
n = 1;
|
||||
goblin = true;
|
||||
}
|
||||
} else if (n < 0) {
|
||||
/* Wahrnehmung > Tarnung */
|
||||
if (u->race != new_race[RC_GOBLIN] || eff_skill(u, SK_STEALTH, r) <= 3) {
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"stealfatal%u:unit%u:target", u, u2));
|
||||
|
||||
add_message(&u2->faction->msgs, new_message(u2->faction,
|
||||
"thiefdiscover%u:unit%u:target", u, u2));
|
||||
return;
|
||||
ADDMSG(&u->faction->msgs, msg_message("stealfatal", "unit target", u, u2));
|
||||
ADDMSG(&u2->faction->msgs, msg_message("thiefdiscover", "unit target", u, u2));
|
||||
return;
|
||||
} else { /* Goblin-Spezialdiebstahl, Meldung an Beklauten */
|
||||
add_message(&u2->faction->msgs, new_message(u2->faction,
|
||||
"thiefdiscover%u:unit%u:target", u, u2));
|
||||
ADDMSG(&u2->faction->msgs, msg_message("thiefdiscover", "unit target", u, u2));
|
||||
n = 1;
|
||||
goblin = true;
|
||||
}
|
||||
|
|
|
@ -1525,11 +1525,11 @@ name_cmd(unit * u, struct order * ord)
|
|||
uo = buildingowner(r, b);
|
||||
if (uo) {
|
||||
if (cansee(uo->faction, r, u, 0)) {
|
||||
add_message(&uo->faction->msgs, new_message(uo->faction,
|
||||
"renamed_building_seen%b:building%u:renamer%r:region", b, u, r));
|
||||
ADDMSG(&uo->faction->msgs, msg_message("renamed_building_seen",
|
||||
"building renamer region", b, u, r));
|
||||
} else {
|
||||
add_message(&uo->faction->msgs, new_message(uo->faction,
|
||||
"renamed_building_notseen%b:building%r:region", b, r));
|
||||
ADDMSG(&uo->faction->msgs, msg_message("renamed_building_notseen",
|
||||
"building region", b, r));
|
||||
}
|
||||
}
|
||||
s = &b->name;
|
||||
|
@ -1629,11 +1629,11 @@ name_cmd(unit * u, struct order * ord)
|
|||
uo = shipowner(sh);
|
||||
if (uo) {
|
||||
if (cansee(uo->faction, r, u, 0)) {
|
||||
add_message(&uo->faction->msgs, new_message(uo->faction,
|
||||
"renamed_ship_seen%h:ship%u:renamer%r:region", sh, u, r));
|
||||
ADDMSG(&uo->faction->msgs, msg_message("renamed_ship_seen",
|
||||
"ship renamer region", sh, u, r));
|
||||
} else {
|
||||
add_message(&uo->faction->msgs, new_message(uo->faction,
|
||||
"renamed_ship_notseen%h:ship%r:region", sh, r));
|
||||
ADDMSG(&uo->faction->msgs, msg_message("renamed_ship_notseen",
|
||||
"ship region", sh, r));
|
||||
}
|
||||
}
|
||||
s = &sh->name;
|
||||
|
@ -1667,11 +1667,11 @@ name_cmd(unit * u, struct order * ord)
|
|||
}
|
||||
}
|
||||
if (cansee(u2->faction, r, u, 0)) {
|
||||
add_message(&u2->faction->msgs, new_message(u2->faction,
|
||||
"renamed_seen%u:renamer%u:renamed%r:region", u, u2, r));
|
||||
ADDMSG(&u2->faction->msgs, msg_message("renamed_seen",
|
||||
"renamer renamed region", u, u2, r));
|
||||
} else {
|
||||
add_message(&u2->faction->msgs, new_message(u2->faction,
|
||||
"renamed_notseen%u:renamed%r:region", u2, r));
|
||||
ADDMSG(&u2->faction->msgs, msg_message("renamed_notseen",
|
||||
"renamed region", u2, r));
|
||||
}
|
||||
s = &u2->name;
|
||||
} else {
|
||||
|
|
|
@ -69,8 +69,8 @@ lucky_silver(const unit *u)
|
|||
|
||||
i_change(&((unit *)u)->items, i_silver, max);
|
||||
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"lucky_item%u:unit%X:item%d:amount", u, i_silver->rtype, max));
|
||||
ADDMSG(&u->faction->msgs, msg_message("lucky_item",
|
||||
"unit item amount", u, i_silver->rtype, max));
|
||||
}
|
||||
|
||||
typedef struct luckyitem {
|
||||
|
@ -115,9 +115,8 @@ lucky_item(const unit *u)
|
|||
amount = 5 + rand()%10 +rand()%10;
|
||||
|
||||
i_change(&((unit *)u)->items, itype, amount);
|
||||
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"lucky_item%u:unit%X:item%d:amount", u, itype->rtype, amount));
|
||||
ADDMSG(&u->faction->msgs, msg_message("lucky_item",
|
||||
"unit item amount", u, itype->rtype, amount));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -147,9 +146,8 @@ lucky_magic_item(const unit *u)
|
|||
amount = 1 + rand()%luck;
|
||||
|
||||
i_change(&((unit *)u)->items, itype, amount);
|
||||
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"lucky_item%u:unit%X:item%d:amount", u, itype->rtype, amount));
|
||||
ADDMSG(&u->faction->msgs, msg_message("lucky_item",
|
||||
"unit item amount", u, itype->rtype, amount));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -700,16 +700,15 @@ drown(region *r)
|
|||
if (amphibian_level) {
|
||||
int dead = damage_unit(u, "5d1", false, false);
|
||||
if (dead) {
|
||||
ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"drown_amphibian_dead%d:amount%u:unit%r:region",dead, u, r));
|
||||
ADDMSG(&u->faction->msgs, msg_message("drown_amphibian_dead",
|
||||
"amount unit region", dead, u, r));
|
||||
} else {
|
||||
ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"drown_amphibian_nodead%u:unit%r:region",u, r));
|
||||
ADDMSG(&u->faction->msgs, msg_message("drown_amphibian_nodead",
|
||||
"unit region",u, r));
|
||||
}
|
||||
} else if (!(canswim(u) || canfly(u))) {
|
||||
scale_number(u, 0);
|
||||
ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"drown%u:unit%r:region", u, r));
|
||||
ADDMSG(&u->faction->msgs, msg_message("drown", "unit region", u, r));
|
||||
}
|
||||
if (*up==u) up=&u->next;
|
||||
}
|
||||
|
@ -779,17 +778,17 @@ volcano_outbreak(region *r)
|
|||
unit * u = *up;
|
||||
int dead = damage_unit(u, "4d10", true, false);
|
||||
if (dead) {
|
||||
ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"volcano_dead%u:unit%r:region%i:dead", u, r, dead));
|
||||
ADDMSG(&u->faction->msgs, msg_message("volcano_dead",
|
||||
"unit region dead", u, r, dead));
|
||||
}
|
||||
if (!fval(u->faction, FL_DH)) {
|
||||
fset(u->faction, FL_DH);
|
||||
if (rn) {
|
||||
ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"volcanooutbreak%r:regionv%r:regionn", r, rn));
|
||||
} else {
|
||||
ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"volcanooutbreaknn%r:region", r));
|
||||
ADDMSG(&u->faction->msgs, msg_message("volcanooutbreak",
|
||||
"regionv regionn", r, rn));
|
||||
} else {
|
||||
ADDMSG(&u->faction->msgs, msg_message("volcanooutbreaknn",
|
||||
"region", r));
|
||||
}
|
||||
}
|
||||
if (u==*up) up=&u->next;
|
||||
|
@ -818,12 +817,12 @@ volcano_outbreak(region *r)
|
|||
unit * u = *up;
|
||||
int dead = damage_unit(u, "3d10", true, false);
|
||||
if (dead) {
|
||||
ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"volcano_dead%u:unit%r:region%i:dead", u, rn, dead));
|
||||
ADDMSG(&u->faction->msgs, msg_message("volcano_dead",
|
||||
"unit region dead", u, rn, dead));
|
||||
}
|
||||
if (!fval(u->faction, FL_DH)) {
|
||||
ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"volcano_dead%u:unit%r:region%i:dead", u, r, dead));
|
||||
ADDMSG(&u->faction->msgs, msg_message("volcano_dead",
|
||||
"unit region dead", u, r, dead));
|
||||
fset(u->faction, FL_DH);
|
||||
}
|
||||
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) if (!fval(u->faction, FL_DH)) {
|
||||
fset(u->faction, FL_DH);
|
||||
ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"iceberg_drift%r:region%d:dir", r, dir));
|
||||
ADDMSG(&u->faction->msgs, msg_message("iceberg_drift",
|
||||
"region dir", r, dir));
|
||||
}
|
||||
|
||||
x = r->x;
|
||||
|
@ -948,12 +947,14 @@ move_iceberg(region *r)
|
|||
if (fval(sh, FL_DH)) {
|
||||
u = captain(sh, r);
|
||||
if (sh->damage>=sh->size * DAMAGE_SCALE) {
|
||||
if (u) ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"overrun_by_iceberg_des%h:ship", sh));
|
||||
if (u!=NULL) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("overrun_by_iceberg_des",
|
||||
"ship", sh));
|
||||
}
|
||||
destroy_ship(sh);
|
||||
} else {
|
||||
if (u) ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"overrun_by_iceberg%h:ship", sh));
|
||||
} else if (u!=NULL) {
|
||||
ADDMSG(&u->faction->msgs, msg_message("overrun_by_iceberg",
|
||||
"ship", sh));
|
||||
}
|
||||
}
|
||||
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) if (!fval(u->faction, FL_DH)) {
|
||||
fset(u->faction, FL_DH);
|
||||
ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"iceberg_land%r:region", r));
|
||||
ADDMSG(&u->faction->msgs, msg_message("iceberg_land", "region", r));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,9 +108,9 @@ spy_cmd(unit * u, struct order * ord)
|
|||
observechance = 1.0 - (eff_skill(u, SK_SPY, r) * 0.05)
|
||||
+ (eff_skill(target, SK_OBSERVATION, r) * 0.02);
|
||||
|
||||
if (chance(observechance)){
|
||||
add_message(&target->faction->msgs, new_message(target->faction,
|
||||
"spydetect%u:spy%u:target", observe>0?u:NULL, target));
|
||||
if (chance(observechance)) {
|
||||
ADDMSG(&target->faction->msgs, msg_message("spydetect",
|
||||
"spy target", observe>0?u:NULL, target));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -50,8 +50,7 @@ use_skillpotion(struct unit * u, const struct item_type * itype, int amount, str
|
|||
++sv;
|
||||
}
|
||||
}
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"skillpotion_use%u:unit", u));
|
||||
ADDMSG(&u->faction->msgs, msg_message("skillpotion_use", "unit", u));
|
||||
|
||||
res_changeitem(u, itype->rtype, -amount);
|
||||
return 0;
|
||||
|
@ -72,8 +71,7 @@ use_manacrystal(struct unit * u, const struct item_type * itype, int amount, str
|
|||
change_spellpoints(u, sp);
|
||||
}
|
||||
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"manacrystal_use%u:unit%i:aura", u, sp));
|
||||
ADDMSG(&u->faction->msgs, msg_message("manacrystal_use", "unit aura", u, sp));
|
||||
|
||||
res_changeitem(u, itype->rtype, -amount);
|
||||
return 0;
|
||||
|
|
|
@ -81,8 +81,8 @@ herbsearch(region * r, unit * u, int max)
|
|||
ADDMSG(&u->faction->msgs, msg_message("herbfound",
|
||||
"unit region amount herb", u, r, herbsfound, whichherb->rtype));
|
||||
} else {
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"researchherb_none%u:unit%r:region", u, u->region));
|
||||
ADDMSG(&u->faction->msgs, msg_message("researchherb_none",
|
||||
"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;
|
||||
rsettrees(r, 1, rtrees(r, 1) + holz);
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"growtree_effect%u:mage%i:amount", u, holz));
|
||||
ADDMSG(&u->faction->msgs, msg_message("growtree_effect",
|
||||
"mage amount", u, holz));
|
||||
} else if (ptype==oldpotiontype[P_HEAL]) {
|
||||
return EUNUSABLE;
|
||||
} else if (ptype==oldpotiontype[P_HEILWASSER]) {
|
||||
|
|
|
@ -2760,8 +2760,8 @@ hunger(int number, unit * u)
|
|||
if (dead) {
|
||||
/* Gestorbene aus der Einheit nehmen,
|
||||
* Sie bekommen keine Beerdingung. */
|
||||
ADDMSG(&u->faction->msgs, new_message(u->faction,
|
||||
"starvation%u:unit%r:region%i:dead%i:live", u, r, dead, u->number-dead));
|
||||
ADDMSG(&u->faction->msgs, msg_message("starvation",
|
||||
"unit region dead live", u, r, dead, u->number-dead));
|
||||
|
||||
scale_number(u, u->number - dead);
|
||||
deathcounts(r, dead);
|
||||
|
@ -2772,8 +2772,8 @@ hunger(int number, unit * u)
|
|||
/* Meldung nur, wenn noch keine für Tote generiert. */
|
||||
if (dead == 0) {
|
||||
/* Durch unzureichende Ernährung wird %s geschwächt */
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"malnourish%u:unit%r:region", u, r));
|
||||
ADDMSG(&u->faction->msgs, msg_message("malnourish",
|
||||
"unit region", u, r));
|
||||
}
|
||||
}
|
||||
return (dead || hpsub);
|
||||
|
|
|
@ -638,8 +638,8 @@ use_tacticcrystal(region * r, unit * u, int amount, struct order * ord)
|
|||
unused(ord);
|
||||
}
|
||||
use_pooled(u, oldresourcetype[R_TACTICCRYSTAL], GET_DEFAULT, amount);
|
||||
add_message(&u->faction->msgs,
|
||||
new_message(u->faction, "use_tacticcrystal%u:unit%r:region", u, r));
|
||||
ADDMSG(&u->faction->msgs, msg_message("use_tacticcrystal",
|
||||
"unit region", u, r));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -334,8 +334,8 @@ buy_special(unit *u, struct order * ord, fspecial_t special)
|
|||
if (a2) {
|
||||
if(a2->data.sa[1] < fspecials[special].maxlevel) {
|
||||
a2->data.sa[1]++;
|
||||
add_message(&f->msgs, new_message(f,
|
||||
"new_fspecial_level%S:special%d:level", special, a2->data.sa[1]));
|
||||
ADDMSG(&f->msgs, msg_message("new_fspecial_level",
|
||||
"special level", special, a2->data.sa[1]));
|
||||
} else {
|
||||
cmistake(u, ord, 251, MSG_EVENT);
|
||||
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->data.sa[0] = (short)special;
|
||||
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;
|
||||
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"pray_success%u:unit",u));
|
||||
ADDMSG(&u->faction->msgs, msg_message("pray_success", "unit", u));
|
||||
|
||||
switch (p) {
|
||||
case P_AURA:
|
||||
|
|
|
@ -1634,9 +1634,9 @@ verify_targets(castorder *co)
|
|||
spobj->data.i = b->no;
|
||||
spobj->flag = TARGET_RESISTS;
|
||||
resists++;
|
||||
add_message(&mage->faction->msgs, new_message(mage->faction,
|
||||
"spellbuildingresists%u:unit%r:region%s:command%d:id",
|
||||
mage, mage->region, co->order, spobj->data.i));
|
||||
ADDMSG(&mage->faction->msgs, msg_message("spellbuildingresists",
|
||||
"unit region command id",
|
||||
mage, mage->region, co->order, spobj->data.i));
|
||||
break;
|
||||
}
|
||||
success++;
|
||||
|
@ -1702,9 +1702,8 @@ verify_targets(castorder *co)
|
|||
if ((sp->sptyp & TESTRESISTANCE)) {
|
||||
if (target_resists_magic(mage, target_r, TYP_REGION, 0)) {
|
||||
/* Fehlermeldung */
|
||||
add_message(&mage->faction->msgs, new_message(mage->faction,
|
||||
"spellregionresists%u:unit%r:region%s:command",
|
||||
mage, mage->region, co->order));
|
||||
ADDMSG(&mage->faction->msgs, msg_message("spellregionresists",
|
||||
"unit region command", mage, mage->region, co->order));
|
||||
spobj->flag = TARGET_RESISTS;
|
||||
resists++;
|
||||
} else {
|
||||
|
|
|
@ -207,102 +207,6 @@ msg_message(const char * name, const char* sig, ...)
|
|||
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
|
||||
caddmessage(region * r, faction * f, const char *s, msg_t mtype, int level)
|
||||
{
|
||||
|
|
|
@ -58,9 +58,6 @@ extern struct messageclass * msgclasses;
|
|||
extern const struct messageclass * mc_add(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); } }
|
||||
|
||||
extern void cmistake(const struct unit * u, struct order *ord, int mno, int mtype);
|
||||
|
|
|
@ -194,7 +194,7 @@ age_hurting(attrib * a) {
|
|||
if (u->building==b) {
|
||||
if (u->faction->magiegebiet==M_CHAOS) {
|
||||
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;
|
||||
if (u->faction->magiegebiet!=M_CHAOS) {
|
||||
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;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
/* libc includes */
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define ILLUSIONMAX 6
|
||||
|
||||
|
@ -31,12 +32,11 @@ age_illusion(unit *u)
|
|||
{
|
||||
if (u->faction->race!=new_race[RC_ILLUSION]) {
|
||||
if (u->age == ILLUSIONMAX) {
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"warnillusiondissolve%u:unit", u));
|
||||
ADDMSG(&u->faction->msgs, msg_message("warnillusiondissolve",
|
||||
"unit", u));
|
||||
} else if (u->age > ILLUSIONMAX) {
|
||||
set_number(u, 0);
|
||||
add_message(&u->faction->msgs, new_message(u->faction,
|
||||
"illusiondissolve%u:unit", u));
|
||||
ADDMSG(&u->faction->msgs, msg_message("illusiondissolve", "unit", u));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue