diff --git a/src/common/gamecode/give.c b/src/common/gamecode/give.c index c607e3aba..caaed27d0 100644 --- a/src/common/gamecode/give.c +++ b/src/common/gamecode/give.c @@ -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))) { diff --git a/src/common/gamecode/items.c b/src/common/gamecode/items.c index 20b391640..a7fa35e4b 100644 --- a/src/common/gamecode/items.c +++ b/src/common/gamecode/items.c @@ -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; } diff --git a/src/common/gamecode/spy.c b/src/common/gamecode/spy.c index 2afd2dbf6..d48b82c50 100644 --- a/src/common/gamecode/spy.c +++ b/src/common/gamecode/spy.c @@ -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 { diff --git a/src/common/items/artrewards.c b/src/common/items/artrewards.c index 07efe87c1..eaa7005fd 100644 --- a/src/common/items/artrewards.c +++ b/src/common/items/artrewards.c @@ -17,6 +17,7 @@ /* kernel includes */ #include +#include #include #include #include @@ -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; } diff --git a/src/common/kernel/border.c b/src/common/kernel/border.c index 51f73514b..c9b72f8dc 100644 --- a/src/common/kernel/border.c +++ b/src/common/kernel/border.c @@ -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")); } diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index e4c9fabae..f75564c2c 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -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));