forked from github/server
"giving heros to another faction"
This commit is contained in:
parent
8d430e77d5
commit
1e9081a290
6 changed files with 22 additions and 13 deletions
|
@ -150,7 +150,7 @@ give_men(int n, unit * u, unit * u2, struct order * ord)
|
||||||
/* Snotlings können nicht an Bauern übergeben werden. */
|
/* Snotlings können nicht an Bauern übergeben werden. */
|
||||||
error = 307;
|
error = 307;
|
||||||
#ifdef HEROES
|
#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;
|
error = 75;
|
||||||
#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))) {
|
||||||
|
|
|
@ -84,7 +84,7 @@ use_speedsail(struct unit * u, const struct item_type * itype, int amount, struc
|
||||||
c_setflag(c, CURSE_NOAGE);
|
c_setflag(c, CURSE_NOAGE);
|
||||||
|
|
||||||
ADDMSG(&u->faction->msgs, msg_message("use_speedsail", "unit speed", u, SPEEDSAIL_EFFECT));
|
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;
|
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);
|
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",
|
ADDMSG(&u->faction->msgs, msg_message("use_antimagiccrystal",
|
||||||
"unit region", u, r));
|
"unit region", u, r));
|
||||||
return 0;
|
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",
|
ADDMSG(&u->region->msgs, msg_message("artsculpture_create", "unit region",
|
||||||
u, u->region));
|
u, u->region));
|
||||||
|
|
||||||
itype->rtype->uchange(u, itype->rtype, -1);
|
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ use_instantartacademy(struct unit * u, const struct item_type * itype,
|
||||||
ADDMSG(&u->region->msgs, msg_message(
|
ADDMSG(&u->region->msgs, msg_message(
|
||||||
"artacademy_create", "unit region", u, u->region));
|
"artacademy_create", "unit region", u, u->region));
|
||||||
|
|
||||||
itype->rtype->uchange(u, itype->rtype, -1);
|
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ use_bagpipeoffear(struct unit * u, const struct item_type * itype,
|
||||||
int money;
|
int money;
|
||||||
variant effect;
|
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);
|
cmistake(u, ord, 58, MSG_MAGIC);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ static int
|
||||||
use_aurapotion50(struct unit * u, const struct item_type * itype,
|
use_aurapotion50(struct unit * u, const struct item_type * itype,
|
||||||
int amount, struct order * ord)
|
int amount, struct order * ord)
|
||||||
{
|
{
|
||||||
if(!is_mage(u)) {
|
if (!is_mage(u)) {
|
||||||
cmistake(u, ord, 214, MSG_MAGIC);
|
cmistake(u, ord, 214, MSG_MAGIC);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ use_aurapotion50(struct unit * u, const struct item_type * itype,
|
||||||
ADDMSG(&u->faction->msgs, msg_message("aurapotion50",
|
ADDMSG(&u->faction->msgs, msg_message("aurapotion50",
|
||||||
"unit region command", u, u->region, ord));
|
"unit region command", u, u->region, ord));
|
||||||
|
|
||||||
itype->rtype->uchange(u, itype->rtype, -1);
|
use_pooled(u, itype->rtype, GET_DEFAULT, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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));
|
ADDMSG(&u2->faction->msgs, msg_message(destruction_detected_msg, "ship unit", sh, u));
|
||||||
/* tell the enemy whodunit: */
|
/* tell the enemy whodunit: */
|
||||||
if (u2) {
|
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;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
/* kernel includes */
|
/* kernel includes */
|
||||||
#include <kernel/item.h>
|
#include <kernel/item.h>
|
||||||
|
#include <kernel/pool.h>
|
||||||
#include <kernel/region.h>
|
#include <kernel/region.h>
|
||||||
#include <kernel/faction.h>
|
#include <kernel/faction.h>
|
||||||
#include <kernel/unit.h>
|
#include <kernel/unit.h>
|
||||||
|
@ -109,7 +110,7 @@ useonother_trappedairelemental(struct unit * u, int shipId,
|
||||||
ship *sh;
|
ship *sh;
|
||||||
variant effect;
|
variant effect;
|
||||||
|
|
||||||
if(shipId <= 0) {
|
if (shipId <= 0) {
|
||||||
cmistake(u, ord, 20, MSG_MOVE);
|
cmistake(u, ord, 20, MSG_MOVE);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +128,7 @@ useonother_trappedairelemental(struct unit * u, int shipId,
|
||||||
ADDMSG(&u->faction->msgs, msg_message("trappedairelemental_success",
|
ADDMSG(&u->faction->msgs, msg_message("trappedairelemental_success",
|
||||||
"unit region command ship", u, u->region, ord, sh));
|
"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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -452,7 +452,7 @@ b_nameroad(const border * b, const region * r, const struct faction * f, int gfl
|
||||||
} else {
|
} else {
|
||||||
int percent = max(1, 100*local/r->terrain->max_road);
|
int percent = max(1, 100*local/r->terrain->max_road);
|
||||||
if (local) {
|
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 {
|
} else {
|
||||||
return LOC(f->locale, mkname("border", "a_road_connection"));
|
return LOC(f->locale, mkname("border", "a_road_connection"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -448,6 +448,7 @@ i_add(item ** pi, item * i)
|
||||||
}
|
}
|
||||||
if (*pi && (*pi)->type==i->type) {
|
if (*pi && (*pi)->type==i->type) {
|
||||||
(*pi)->number += i->number;
|
(*pi)->number += i->number;
|
||||||
|
assert((*pi)->number>=0);
|
||||||
i_free(i);
|
i_free(i);
|
||||||
} else {
|
} else {
|
||||||
i->next = *pi;
|
i->next = *pi;
|
||||||
|
@ -469,6 +470,7 @@ i_merge(item ** pi, item ** si)
|
||||||
}
|
}
|
||||||
if (*pi && (*pi)->type==i->type) {
|
if (*pi && (*pi)->type==i->type) {
|
||||||
(*pi)->number += i->number;
|
(*pi)->number += i->number;
|
||||||
|
assert((*pi)->number>=0);
|
||||||
i_free(i_remove(&i, i));
|
i_free(i_remove(&i, i));
|
||||||
} else {
|
} else {
|
||||||
itmp = i->next;
|
itmp = i->next;
|
||||||
|
@ -562,6 +564,7 @@ i_new(const item_type * itype, int size)
|
||||||
i->next = NULL;
|
i->next = NULL;
|
||||||
i->type = itype;
|
i->type = itype;
|
||||||
i->number = size;
|
i->number = size;
|
||||||
|
assert(i->number>=0);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,6 +631,7 @@ set_item(unit * u, item_t it, int value)
|
||||||
i = i_add(&u->items, i_new(type, value));
|
i = i_add(&u->items, i_new(type, value));
|
||||||
} else {
|
} else {
|
||||||
i->number = value;
|
i->number = value;
|
||||||
|
assert(i->number>=0);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -995,7 +999,10 @@ set_money(unit * u, int v)
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
if ((*ip)!=NULL) {
|
if ((*ip)!=NULL) {
|
||||||
if (v) (*ip)->number = v;
|
if (v) {
|
||||||
|
(*ip)->number = v;
|
||||||
|
assert((*ip)->number>=0);
|
||||||
|
}
|
||||||
else i_remove(ip, *ip);
|
else i_remove(ip, *ip);
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
|
@ -1014,6 +1021,7 @@ change_money(unit * u, int v)
|
||||||
item * i = *ip;
|
item * i = *ip;
|
||||||
if (i->number + v != 0) {
|
if (i->number + v != 0) {
|
||||||
i->number += v;
|
i->number += v;
|
||||||
|
assert(i->number>=0);
|
||||||
return i->number;
|
return i->number;
|
||||||
}
|
}
|
||||||
else i_free(i_remove(ip, *ip));
|
else i_free(i_remove(ip, *ip));
|
||||||
|
|
Loading…
Reference in a new issue