"giving heros to another faction"
This commit is contained in:
Enno Rehling 2007-12-19 21:49:19 +00:00
parent 8d430e77d5
commit 1e9081a290
6 changed files with 22 additions and 13 deletions

View File

@ -150,7 +150,7 @@ give_men(int n, unit * u, unit * u2, struct order * ord)
/* Snotlings können nicht an Bauern übergeben werden. */
error = 307;
#ifdef HEROES
} else if (u2 && u2->number>0 && fval(u, UFL_HERO)!=fval(u2, UFL_HERO)) {
} else if (fval(u, UFL_HERO) || (u2 && fval(u2, UFL_HERO))) {
error = 75;
#endif
} else if ((u && unit_has_cursed_item(u)) || (u2 && unit_has_cursed_item(u2))) {

View File

@ -84,7 +84,7 @@ use_speedsail(struct unit * u, const struct item_type * itype, int amount, struc
c_setflag(c, CURSE_NOAGE);
ADDMSG(&u->faction->msgs, msg_message("use_speedsail", "unit speed", u, SPEEDSAIL_EFFECT));
itype->rtype->uchange(u, itype->rtype, -1);
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
return 0;
}
@ -149,7 +149,7 @@ use_antimagiccrystal(unit * u, const struct item_type * itype, int amount, struc
create_curse(u, &r->attribs, ct_find("antimagiczone"), force, duration, var, 0);
}
}
use_pooled(u, rt_crystal, GET_SLACK|GET_RESERVE|GET_POOLED_SLACK, amount);
use_pooled(u, rt_crystal, GET_DEFAULT, amount);
ADDMSG(&u->faction->msgs, msg_message("use_antimagiccrystal",
"unit region", u, r));
return 0;
@ -172,7 +172,7 @@ use_instantartsculpture(struct unit * u, const struct item_type * itype,
ADDMSG(&u->region->msgs, msg_message("artsculpture_create", "unit region",
u, u->region));
itype->rtype->uchange(u, itype->rtype, -1);
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
return 0;
}
@ -194,7 +194,7 @@ use_instantartacademy(struct unit * u, const struct item_type * itype,
ADDMSG(&u->region->msgs, msg_message(
"artacademy_create", "unit region", u, u->region));
itype->rtype->uchange(u, itype->rtype, -1);
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
return 0;
}
@ -209,7 +209,7 @@ use_bagpipeoffear(struct unit * u, const struct item_type * itype,
int money;
variant effect;
if(get_curse(u->region->attribs, ct_find("depression"))) {
if (get_curse(u->region->attribs, ct_find("depression"))) {
cmistake(u, ord, 58, MSG_MAGIC);
return -1;
}
@ -235,7 +235,7 @@ static int
use_aurapotion50(struct unit * u, const struct item_type * itype,
int amount, struct order * ord)
{
if(!is_mage(u)) {
if (!is_mage(u)) {
cmistake(u, ord, 214, MSG_MAGIC);
return -1;
}
@ -245,7 +245,7 @@ use_aurapotion50(struct unit * u, const struct item_type * itype,
ADDMSG(&u->faction->msgs, msg_message("aurapotion50",
"unit region command", u, u->region, ord));
itype->rtype->uchange(u, itype->rtype, -1);
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
return 0;
}

View File

@ -428,7 +428,7 @@ try_destruction(unit * u, unit * u2, const ship *sh, int skilldiff)
ADDMSG(&u2->faction->msgs, msg_message(destruction_detected_msg, "ship unit", sh, u));
/* tell the enemy whodunit: */
if (u2) {
ADDMSG(&u2->faction->msgs, msg_message(detect_failure_msg, "ship unit", sh, u));
ADDMSG(&u2->faction->msgs, msg_message(detect_failure_msg, "ship", sh));
}
return 0;
} else {

View File

@ -17,6 +17,7 @@
/* kernel includes */
#include <kernel/item.h>
#include <kernel/pool.h>
#include <kernel/region.h>
#include <kernel/faction.h>
#include <kernel/unit.h>
@ -109,7 +110,7 @@ useonother_trappedairelemental(struct unit * u, int shipId,
ship *sh;
variant effect;
if(shipId <= 0) {
if (shipId <= 0) {
cmistake(u, ord, 20, MSG_MOVE);
return -1;
}
@ -127,7 +128,7 @@ useonother_trappedairelemental(struct unit * u, int shipId,
ADDMSG(&u->faction->msgs, msg_message("trappedairelemental_success",
"unit region command ship", u, u->region, ord, sh));
itype->rtype->uchange(u, itype->rtype, -1);
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
return 0;
}

View File

@ -452,7 +452,7 @@ b_nameroad(const border * b, const region * r, const struct faction * f, int gfl
} else {
int percent = max(1, 100*local/r->terrain->max_road);
if (local) {
snprintf(buffer, sizeof(buffer), LOC(f->locale, mkname("border", "road_percent")), percent);
snprintf(buffer, sizeof(buffer), LOC(f->locale, mkname("border", "a_road_percent")), percent);
} else {
return LOC(f->locale, mkname("border", "a_road_connection"));
}

View File

@ -448,6 +448,7 @@ i_add(item ** pi, item * i)
}
if (*pi && (*pi)->type==i->type) {
(*pi)->number += i->number;
assert((*pi)->number>=0);
i_free(i);
} else {
i->next = *pi;
@ -469,6 +470,7 @@ i_merge(item ** pi, item ** si)
}
if (*pi && (*pi)->type==i->type) {
(*pi)->number += i->number;
assert((*pi)->number>=0);
i_free(i_remove(&i, i));
} else {
itmp = i->next;
@ -562,6 +564,7 @@ i_new(const item_type * itype, int size)
i->next = NULL;
i->type = itype;
i->number = size;
assert(i->number>=0);
return i;
}
@ -628,6 +631,7 @@ set_item(unit * u, item_t it, int value)
i = i_add(&u->items, i_new(type, value));
} else {
i->number = value;
assert(i->number>=0);
}
return value;
}
@ -995,7 +999,10 @@ set_money(unit * u, int v)
return v;
}
if ((*ip)!=NULL) {
if (v) (*ip)->number = v;
if (v) {
(*ip)->number = v;
assert((*ip)->number>=0);
}
else i_remove(ip, *ip);
}
return v;
@ -1014,6 +1021,7 @@ change_money(unit * u, int v)
item * i = *ip;
if (i->number + v != 0) {
i->number += v;
assert(i->number>=0);
return i->number;
}
else i_free(i_remove(ip, *ip));