Bugfix givemen und warning bei Versuch des Mißbrauch

This commit is contained in:
Enno Rehling 2004-01-25 09:16:00 +00:00
parent 375a55b882
commit ea9e58b018
1 changed files with 95 additions and 94 deletions

View File

@ -506,113 +506,114 @@ TODO: Einen Trigger benutzen!
static void static void
givemen(int n, unit * u, unit * u2, const char * cmd) givemen(int n, unit * u, unit * u2, const char * cmd)
{ {
ship *sh; ship *sh;
int k = 0; int k = 0;
int error = 0; int error = 0;
if (u2 && u->faction != u2->faction && u->faction->age < giverestriction()) { if (u2 && u->faction != u2->faction && u->faction->age < giverestriction()) {
ADDMSG(&u->faction->msgs, msg_error(u, cmd, "giverestriction", ADDMSG(&u->faction->msgs, msg_error(u, cmd, "giverestriction",
"turns", giverestriction())); "turns", giverestriction()));
return; return;
} else if (u == u2) { } else if (u == u2) {
error = 10; error = 10;
#if RACE_ADJUSTMENTS #if RACE_ADJUSTMENTS
} else if (!u2 && u->race == new_race[RC_SNOTLING]) { } else if (!u2 && u->race == new_race[RC_SNOTLING]) {
/* Snotlings können nicht an Bauern übergeben werden. */ /* Snotlings können nicht an Bauern übergeben werden. */
error = 307; error = 307;
#endif #endif
} else if ((u && unit_has_cursed_item(u)) || (u2 && unit_has_cursed_item(u2))) { } else if ((u && unit_has_cursed_item(u)) || (u2 && unit_has_cursed_item(u2))) {
error = 78; error = 78;
} else if (fval(u, UFL_LOCKED) || fval(u, UFL_HUNGER) || is_cursed(u->attribs, C_SLAVE, 0)) { } else if (fval(u, UFL_LOCKED) || fval(u, UFL_HUNGER) || is_cursed(u->attribs, C_SLAVE, 0)) {
error = 74; error = 74;
} else if (u2 && (fval(u2, UFL_LOCKED)|| is_cursed(u2->attribs, C_SLAVE, 0))) { } else if (u2 && (fval(u2, UFL_LOCKED)|| is_cursed(u2->attribs, C_SLAVE, 0))) {
error = 75; error = 75;
} else if (u2 != (unit *) NULL } else if (u2 && u2->faction != u->faction && ucontact(u2, u) == 0) {
&& u2->faction != u->faction error = 73;
&& ucontact(u2, u) == 0) { } else if (u2 && (has_skill(u, SK_MAGIC) || has_skill(u2, SK_MAGIC))) {
error = 73; error = 158;
} else if (u2 && (has_skill(u, SK_MAGIC) || has_skill(u2, SK_MAGIC))) { } else if (u2 && fval(u, UFL_WERE) != fval(u2, UFL_WERE)) {
error = 158; error = 312;
} else if (u2 && fval(u, UFL_WERE) != fval(u2, UFL_WERE)) { } else if (u2 && u2->number!=0 && u2->race != u->race) {
error = 312; log_warning(("Partei %s versucht %s an %s zu übergeben.\n",
} else { itoa36(u->faction->no), u->race->_name[0],
if (n > u->number) n = u->number; u2->race->_name[1]));
if (n == 0) { error = 139;
error = 96; } else {
} else if (u2 && u->faction != u2->faction) { if (n > u->number) n = u->number;
if (u2->faction->newbies + n > MAXNEWBIES) { if (n == 0) {
error = 129; error = 96;
} else if (u->race != u2->faction->race) { } else if (u2 && u->faction != u2->faction) {
if (u2->faction->race != new_race[RC_HUMAN]) { if (u2->faction->newbies + n > MAXNEWBIES) {
error = 120; error = 129;
} else if (count_migrants(u2->faction) + n > count_max_migrants(u2->faction)) { } else if (u->race != u2->faction->race) {
error = 128; if (u2->faction->race != new_race[RC_HUMAN]) {
} error = 120;
else if (teure_talente(u) || teure_talente(u2)) { } else if (count_migrants(u2->faction) + n > count_max_migrants(u2->faction)) {
error = 154; error = 128;
} else if (u2->number!=0) { }
error = 139; else if (teure_talente(u) || teure_talente(u2)) {
} error = 154;
} } else if (u2->number!=0) {
} error = 139;
} }
if (u2 && (has_skill(u, SK_ALCHEMY) || has_skill(u2, SK_ALCHEMY))) { }
}
}
k = count_skill(u2->faction, SK_ALCHEMY); if (u2 && (has_skill(u, SK_ALCHEMY) || has_skill(u2, SK_ALCHEMY))) {
k = count_skill(u2->faction, SK_ALCHEMY);
/* Falls die Zieleinheit keine Alchemisten sind, werden sie nun /* Falls die Zieleinheit keine Alchemisten sind, werden sie nun
* welche. */ * welche. */
if (!has_skill(u2, SK_ALCHEMY) && has_skill(u, SK_ALCHEMY)) if (!has_skill(u2, SK_ALCHEMY) && has_skill(u, SK_ALCHEMY))
k += u2->number; k += u2->number;
/* Wenn in eine Alchemisteneinheit Personen verschoben werden */ /* Wenn in eine Alchemisteneinheit Personen verschoben werden */
if (has_skill(u2, SK_ALCHEMY) && !has_skill(u, SK_ALCHEMY)) if (has_skill(u2, SK_ALCHEMY) && !has_skill(u, SK_ALCHEMY))
k += n; k += n;
/* Wenn Parteigrenzen überschritten werden */ /* Wenn Parteigrenzen überschritten werden */
if (u2->faction != u->faction) if (u2->faction != u->faction)
k += n; k += n;
/* wird das Alchemistenmaximum ueberschritten ? */ /* wird das Alchemistenmaximum ueberschritten ? */
if (k > max_skill(u2->faction, SK_ALCHEMY)) { if (k > max_skill(u2->faction, SK_ALCHEMY)) {
error = 156; error = 156;
} }
} }
if (!error) { if (error==0) {
if (u2 && u2->number == 0) { if (u2 && u2->number == 0) {
set_racename(&u2->attribs, get_racename(u->attribs)); set_racename(&u2->attribs, get_racename(u->attribs));
u2->race = u->race; u2->race = u->race;
u2->irace = u->irace; u2->irace = u->irace;
} else if (u2 && u2->race != u->race) { } else if (u2) {
error = 139; /* Einheiten von Schiffen können nicht NACH in von
} else if (u2) { * Nicht-alliierten bewachten Regionen ausführen */
/* Einheiten von Schiffen können nicht NACH in von sh = leftship(u);
* Nicht-alliierten bewachten Regionen ausführen */ if (sh) set_leftship(u2, sh);
sh = leftship(u);
if (sh) set_leftship(u2, sh);
transfermen(u, u2, n); transfermen(u, u2, n);
if (u->faction != u2->faction) { if (u->faction != u2->faction) {
u2->faction->newbies += n; u2->faction->newbies += n;
} }
} else { } else {
if (getunitpeasants) { if (getunitpeasants) {
#ifdef ORCIFICATION #ifdef ORCIFICATION
if (u->race == new_race[RC_ORC] && !fval(u->region, RF_ORCIFIED)) { if (u->race == new_race[RC_ORC] && !fval(u->region, RF_ORCIFIED)) {
attrib *a = a_find(u->region->attribs, &at_orcification); attrib *a = a_find(u->region->attribs, &at_orcification);
if (!a) a = a_add(&u->region->attribs, a_new(&at_orcification)); if (!a) a = a_add(&u->region->attribs, a_new(&at_orcification));
a->data.i += n; a->data.i += n;
} }
#endif #endif
transfermen(u, NULL, n); transfermen(u, NULL, n);
} else { } else {
error = 159; error = 159;
} }
} }
} }
addgive(u, u2, n, R_PERSON, cmd, error); addgive(u, u2, n, R_PERSON, cmd, error);
} }
void void