"Astraler Ruf findet Einheiten nicht"

Fehlerkontrolle muss in den spell selbst hinein, weil SEARCHGLOBAL nicht testet, aber wegen Einheit in anderer Region noetig.
Meldung ueber fehlende Einheit fuer Zauber in eigene Funktion gesplittet.
This commit is contained in:
Enno Rehling 2007-03-04 20:26:31 +00:00
parent 2576f781d4
commit 6c8c7ae592
3 changed files with 46 additions and 22 deletions

View File

@ -1518,6 +1518,24 @@ verify_building(region * r, unit * mage, const spell * sp, spllprm * spobj, orde
return true;
}
message *
msg_unitnotfound(const struct unit * mage, struct order * ord, const struct spllprm * spobj)
{
/* Einheit nicht gefunden */
char tbuf[20];
const char * uid;
if (spobj->typ==SPP_UNIT) {
uid = itoa36(spobj->data.i);
} else {
sprintf(tbuf, "%s %s", LOC(mage->faction->locale,
parameters[P_TEMP]), itoa36(spobj->data.i));
uid = tbuf;
}
return msg_message("spellunitnotfound",
"unit region command id", mage, mage->region, ord, uid);
}
static boolean
verify_unit(region * r, unit * mage, const spell * sp, spllprm * spobj, order * ord)
{
@ -1544,19 +1562,8 @@ verify_unit(region * r, unit * mage, const spell * sp, spllprm * spobj, order *
if (u==NULL) {
/* Einheit nicht gefunden */
char * uid;
spobj->flag = TARGET_NOTFOUND;
if (spobj->typ==SPP_UNIT) {
uid = strdup(itoa36(spobj->data.i));
} else {
char tbuf[20];
sprintf(tbuf, "%s %s", LOC(mage->faction->locale,
parameters[P_TEMP]), itoa36(spobj->data.i));
uid = strdup(tbuf);
}
ADDMSG(&mage->faction->msgs, msg_message("spellunitnotfound",
"unit region command id", mage, mage->region, ord, uid));
ADDMSG(&mage->faction->msgs, msg_unitnotfound(mage, ord, spobj));
return false;
}
/* Einheit wurde gefunden, pointer setzen */
@ -1598,13 +1605,13 @@ verify_targets(castorder *co)
switch(spobj->typ) {
case SPP_TEMP:
case SPP_UNIT:
case SPP_UNIT:
if (!verify_unit(target_r, mage, sp, spobj, co->order)) ++failed;
break;
case SPP_BUILDING:
case SPP_BUILDING:
if (!verify_building(target_r, mage, sp, spobj, co->order)) ++failed;
break;
case SPP_SHIP:
case SPP_SHIP:
if (!verify_ship(target_r, mage, sp, spobj, co->order)) ++failed;
break;
default:

View File

@ -371,6 +371,8 @@ extern struct unit * has_clone(struct unit * mage);
extern const char * spell_info(const struct spell * sp, const struct locale * lang);
extern const char * spell_name(const struct spell * sp, const struct locale * lang);
extern struct message * msg_unitnotfound(const struct unit * mage, struct order * ord, const struct spllprm * spobj);
#ifdef __cplusplus
}
#endif

View File

@ -5365,9 +5365,7 @@ sp_dreamreading(castorder *co)
/* Illusionen und Untote abfangen. */
if (fval(u->race, RCF_UNDEAD|RCF_ILLUSIONARY)) {
ADDMSG(&mage->faction->msgs, msg_message(
"spellunitnotfound", "unit region command id",
mage, mage->region, co->order, strdup(itoa36(u->no))));
ADDMSG(&mage->faction->msgs, msg_unitnotfound(mage, co->order, pa->param[0]));
return 0;
}
@ -5844,12 +5842,29 @@ sp_pullastral(castorder *co)
/* für jede Einheit in der Kommandozeile */
for (n = 1; n < pa->length; n++) {
if (pa->param[n]->flag == TARGET_NOTFOUND) continue;
spllprm * spobj = pa->param[n];
if (spobj->flag == TARGET_NOTFOUND) continue;
u = pa->param[n]->data.u;
u = spobj->data.u;
if (u->region!=r) {
/* Report this as unit not found */
char * uid;
if (spobj->typ==SPP_UNIT) {
uid = strdup(itoa36(spobj->data.i));
} else {
char tbuf[20];
sprintf(tbuf, "%s %s", LOC(mage->faction->locale,
parameters[P_TEMP]), itoa36(spobj->data.i));
uid = strdup(tbuf);
}
ADDMSG(&mage->faction->msgs, msg_unitnotfound(mage, co->order, spobj));
return false;
}
if (!ucontact(u, mage)) {
if (power > 12 && pa->param[n]->flag != TARGET_RESISTS && can_survive(u, rt)) {
if (power > 12 && spobj->flag != TARGET_RESISTS && can_survive(u, rt)) {
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order, "feedback_no_contact_no_resist", "target", u));
ADDMSG(&u->faction->msgs, msg_message("send_astral", "unit target", mage, u));
} else {
@ -9000,7 +9015,7 @@ static spelldata spelldaten[] =
"ZAUBER [STUFE n] \'Astraler Ruf\' <Ziel-X> <Ziel-Y> <Einheit-Nr> "
"[<Einheit-Nr> ...]",
"ru+",
M_ASTRAL, (UNITSPELL | SPELLLEVEL), 7, 6,
M_ASTRAL, (UNITSPELL | SEARCHGLOBAL | SPELLLEVEL), 7, 6,
{
{ "aura", 2, SPC_LEVEL },
{ 0, 0, 0 },