diff --git a/src/alchemy.c b/src/alchemy.c index 11a205869..7eac102fb 100644 --- a/src/alchemy.c +++ b/src/alchemy.c @@ -61,7 +61,7 @@ void herbsearch(unit * u, int max) return; } - if (is_guarded(r, u, GUARD_PRODUCE)) { + if (is_guarded(r, u)) { cmistake(u, u->thisorder, 70, MSG_EVENT); return; } diff --git a/src/alchemy.test.c b/src/alchemy.test.c index 7fd2da8e1..c281a1c98 100644 --- a/src/alchemy.test.c +++ b/src/alchemy.test.c @@ -30,7 +30,7 @@ static void test_herbsearch(CuTest * tc) rc = rc_get_or_create("dragon"); rc->flags |= RCF_UNARMEDGUARD; u2 = test_create_unit(test_create_faction(rc), r); - guard(u2, GUARD_PRODUCE); + setguard(u2, true); f = test_create_faction(0); u = test_create_unit(f, r); @@ -41,14 +41,14 @@ static void test_herbsearch(CuTest * tc) test_clear_messages(f); set_level(u, SK_HERBALISM, 1); - CuAssertPtrEquals(tc, u2, is_guarded(r, u, GUARD_PRODUCE)); + CuAssertPtrEquals(tc, u2, is_guarded(r, u)); herbsearch(u, INT_MAX); CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error70")); CuAssertPtrEquals(tc, 0, test_find_messagetype(f->msgs, "error59")); test_clear_messages(f); - guard(u2, GUARD_NONE); - CuAssertPtrEquals(tc, 0, is_guarded(r, u, GUARD_PRODUCE)); + setguard(u2, false); + CuAssertPtrEquals(tc, 0, is_guarded(r, u)); CuAssertPtrEquals(tc, 0, (void *)rherbtype(r)); herbsearch(u, INT_MAX); CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error108")); diff --git a/src/battle.c b/src/battle.c index fb411d778..5bf35f191 100644 --- a/src/battle.c +++ b/src/battle.c @@ -2425,7 +2425,7 @@ side *make_side(battle * b, const faction * f, const group * g, else { unit *u; for (u = b->region->units; u; u = u->next) { - if (is_guard(u, HELP_ALL)) { + if (is_guard(u)) { if (alliedunit(u, f, HELP_GUARD)) { flags |= SIDE_HASGUARDS; break; @@ -2726,7 +2726,7 @@ static void aftermath(battle * b) } scale_number(du, df->run.number); du->hp = df->run.hp; - setguard(du, GUARD_NONE); + setguard(du, false); /* must leave ships or buildings, or a stealthy hobbit * can hold castles indefinitely */ if (!fval(r->terrain, SEA_REGION)) { @@ -2763,7 +2763,7 @@ static void aftermath(battle * b) /* Distribute Loot */ loot_items(df); - setguard(du, GUARD_NONE); + setguard(du, true); scale_number(du, 0); } else { @@ -3878,7 +3878,7 @@ static void flee(const troop dt) fig->run.hp += fig->person[dt.index].hp; ++fig->run.number; - setguard(u, GUARD_NONE); + setguard(u, false); kill_troop(dt); } @@ -3941,7 +3941,7 @@ static bool start_battle(region * r, battle ** bp) if ((u->ship != NULL && !fval(r->terrain, SEA_REGION)) || (lsh = leftship(u)) != NULL) { - if (is_guarded(r, u, GUARD_TRAVELTHRU)) { + if (is_guarded(r, u)) { if (lsh) { cmistake(u, ord, 234, MSG_BATTLE); } diff --git a/src/bind_unit.c b/src/bind_unit.c index 3f3848e78..576678642 100755 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -258,18 +258,15 @@ static int tolua_unit_set_flags(lua_State * L) static int tolua_unit_get_guard(lua_State * L) { unit *self = (unit *)tolua_tousertype(L, 1, 0); - if (is_guard(self, GUARD_ALL)) { - lua_pushinteger(L, getguard(self)); - return 1; - } - return 0; + lua_pushboolean(L, is_guard(self)); + return 1; } static int tolua_unit_set_guard(lua_State * L) { unit *self = (unit *)tolua_tousertype(L, 1, 0); unsigned int flags = (unsigned int)tolua_tonumber(L, 2, 0); - setguard(self, flags); + setguard(self, flags!=0); return 0; } diff --git a/src/creport.c b/src/creport.c index 5e7442030..0eb2d4abb 100644 --- a/src/creport.c +++ b/src/creport.c @@ -849,7 +849,7 @@ void cr_output_unit(stream *out, const region * r, const faction * f, assert(u->ship->region); stream_printf(out, "%d;Schiff\n", u->ship->no); } - if (is_guard(u, GUARD_ALL) != 0) { + if (is_guard(u)) { stream_printf(out, "%d;bewacht\n", 1); } if ((b = usiege(u)) != NULL) { diff --git a/src/economy.c b/src/economy.c index dd6efa890..1836c1305 100644 --- a/src/economy.c +++ b/src/economy.c @@ -459,7 +459,7 @@ static void recruit(unit * u, struct order *ord, request ** recruitorders) /* this is a very special case because the recruiting unit may be empty * at this point and we have to look at the creating unit instead. This * is done in cansee, which is called indirectly by is_guarded(). */ - if (is_guarded(r, u, GUARD_RECRUIT)) { + if (is_guarded(r, u)) { cmistake(u, ord, 70, MSG_EVENT); return; } @@ -929,7 +929,7 @@ static void allocate_resource(unit * u, const resource_type * rtype, int want) if (itype->rtype && (itype->rtype == get_resourcetype(R_IRON) || itype->rtype == rt_find("laen"))) { unit *u2; for (u2 = r->units; u2; u2 = u2->next) { - if (is_guard(u, GUARD_ALL) + if (is_guard(u) && !fval(u2, UFL_ISNEW) && u2->number && !alliedunit(u2, u->faction, HELP_GUARD)) { ADDMSG(&u->faction->msgs, @@ -1246,7 +1246,7 @@ static void create_item(unit * u, const item_type * itype, int want) { if (itype->construction && fval(itype->rtype, RTF_LIMITED)) { #if GUARD_DISABLES_PRODUCTION == 1 - if (is_guarded(u->region, u, GUARD_PRODUCE)) { + if (is_guarded(u->region, u)) { cmistake(u, u->thisorder, 70, MSG_EVENT); return; } @@ -1548,11 +1548,11 @@ static void buy(unit * u, request ** buyorders, struct order *ord) keyword_t kwd; const char *s; - if (u->ship && is_guarded(r, u, GUARD_CREWS)) { + if (u->ship && is_guarded(r, u)) { cmistake(u, ord, 69, MSG_INCOME); return; } - if (u->ship && is_guarded(r, u, GUARD_CREWS)) { + if (u->ship && is_guarded(r, u)) { cmistake(u, ord, 69, MSG_INCOME); return; } @@ -1866,7 +1866,7 @@ static bool sell(unit * u, request ** sellorders, struct order *ord) caravan_bt = bt_find("caravan"); } - if (u->ship && is_guarded(r, u, GUARD_CREWS)) { + if (u->ship && is_guarded(r, u)) { cmistake(u, ord, 69, MSG_INCOME); return false; } @@ -2581,7 +2581,7 @@ void entertain_cmd(unit * u, struct order *ord) cmistake(u, ord, 60, MSG_INCOME); return; } - if (u->ship && is_guarded(r, u, GUARD_CREWS)) { + if (u->ship && is_guarded(r, u)) { cmistake(u, ord, 69, MSG_INCOME); return; } @@ -2678,7 +2678,7 @@ static int do_work(unit * u, order * ord, request * o) cmistake(u, ord, 60, MSG_INCOME); return -1; } - if (u->ship && is_guarded(r, u, GUARD_CREWS)) { + if (u->ship && is_guarded(r, u)) { if (ord) cmistake(u, ord, 69, MSG_INCOME); return -1; @@ -2815,7 +2815,7 @@ void tax_cmd(unit * u, struct order *ord, request ** taxorders) u->wants = _min(n * effskill(u, SK_TAXING, 0) * taxperlevel, max); } - u2 = is_guarded(r, u, GUARD_TAX); + u2 = is_guarded(r, u); if (u2) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "region_guarded", "guard", u2)); @@ -2870,7 +2870,7 @@ void loot_cmd(unit * u, struct order *ord, request ** lootorders) return; } - u2 = is_guarded(r, u, GUARD_TAX); + u2 = is_guarded(r, u); if (u2) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "region_guarded", "guard", u2)); diff --git a/src/guard.c b/src/guard.c index ac8809534..86af55f85 100644 --- a/src/guard.c +++ b/src/guard.c @@ -56,31 +56,15 @@ void update_guards(void) for (u = r->units; u; u = u->next) { if (fval(u, UFL_GUARD)) { if (can_start_guarding(u) != E_GUARD_OK) { - setguard(u, GUARD_NONE); + setguard(u, false); } } } } } -unsigned int guard_flags(const unit * u) +void setguard(unit * u, bool enabled) { - // TODO: this should be a property of the race, like race.guard_flags - unsigned int flags = - GUARD_CREWS | GUARD_LANDING | GUARD_TRAVELTHRU | GUARD_TAX; - // TODO: configuration, not define -#if GUARD_DISABLES_PRODUCTION == 1 - flags |= GUARD_PRODUCE; -#endif -#if GUARD_DISABLES_RECRUIT == 1 - flags |= GUARD_RECRUIT; -#endif - return flags; -} - -void setguard(unit * u, unsigned int flags) -{ - bool enabled = (flags!=GUARD_NONE); if (!enabled) { freset(u, UFL_GUARD); } else { @@ -91,24 +75,16 @@ void setguard(unit * u, unsigned int flags) } } -unsigned int getguard(const unit * u) +void guard(unit * u) { - assert(fval(u, UFL_GUARD) || (u->building && u == building_owner(u->building)) - || !"you're doing it wrong! check is_guard first"); - return guard_flags(u); + setguard(u, true); } -void guard(unit * u, unsigned int mask) -{ - unsigned int flags = guard_flags(u); - setguard(u, flags & mask); -} - -static bool is_guardian_u(const unit * guard, unit * u, unsigned int mask) +static bool is_guardian_u(const unit * guard, unit * u) { if (guard->faction == u->faction) return false; - if (is_guard(guard, mask) == 0) + if (is_guard(guard) == 0) return false; if (alliedunit(guard, u->faction, HELP_GUARD)) return false; @@ -145,12 +121,12 @@ static bool is_guardian_r(const unit * guard) return fval(u_race(guard), RCF_UNARMEDGUARD) || is_monsters(guard->faction) || (armedmen(guard, true) > 0); } -bool is_guard(const struct unit * u, unsigned int mask) +bool is_guard(const struct unit * u) { - return is_guardian_r(u) && (getguard(u) & mask) != 0; + return is_guardian_r(u); } -unit *is_guarded(region * r, unit * u, unsigned int mask) +unit *is_guarded(region * r, unit * u) { unit *u2; int noguards = 1; @@ -166,7 +142,7 @@ unit *is_guarded(region * r, unit * u, unsigned int mask) for (u2 = r->units; u2; u2 = u2->next) { if (is_guardian_r(u2)) { noguards = 0; - if (is_guardian_u(u2, u, mask)) { + if (is_guardian_u(u2, u)) { /* u2 is our guard. stop processing (we might have to go further next time) */ return u2; } diff --git a/src/guard.h b/src/guard.h index d88db3b49..4743230d3 100644 --- a/src/guard.h +++ b/src/guard.h @@ -11,29 +11,13 @@ extern "C" { typedef enum { E_GUARD_OK, E_GUARD_UNARMED, E_GUARD_NEWBIE, E_GUARD_FLEEING } guard_t; -#define GUARD_NONE 0 -#define GUARD_TAX 1 - /* Verhindert Steuereintreiben */ -#define GUARD_TRAVELTHRU 8 - /* Blockiert Durchreisende */ -#define GUARD_LANDING 16 - /* Verhindert Ausstieg + Weiterreise */ -#define GUARD_CREWS 32 - /* Verhindert Unterhaltung auf Schiffen */ -#define GUARD_RECRUIT 64 - /* Verhindert Rekrutieren */ -#define GUARD_PRODUCE 128 - /* Verhindert Abbau von Resourcen mit RTF_LIMITED */ -#define GUARD_ALL 0xFFFF - guard_t can_start_guarding(const struct unit * u); void update_guards(void); - unsigned int getguard(const struct unit * u); - void setguard(struct unit * u, unsigned int flags); - void guard(struct unit * u, unsigned int mask); + void setguard(struct unit * u, bool enabled); + void guard(struct unit *u); - struct unit *is_guarded(struct region *r, struct unit *u, unsigned int mask); - bool is_guard(const struct unit *u, unsigned int mask); + struct unit *is_guarded(struct region *r, struct unit *u); + bool is_guard(const struct unit *u); #ifdef __cplusplus } diff --git a/src/guard.test.c b/src/guard.test.c index 149b3df01..e1b8e406c 100644 --- a/src/guard.test.c +++ b/src/guard.test.c @@ -48,7 +48,7 @@ static void test_guard_unskilled(CuTest * tc) ug = test_create_unit(test_create_faction(0), r); i_change(&ug->items, itype, 1); set_level(ug, SK_MELEE, 1); - setguard(ug, GUARD_ALL); + setguard(ug, true); CuAssertPtrEquals(tc, 0, is_guarded(r, u, GUARD_PRODUCE)); test_cleanup(); } @@ -67,7 +67,7 @@ static void test_guard_armed(CuTest * tc) ug = test_create_unit(test_create_faction(0), r); i_change(&ug->items, itype, 1); set_level(ug, SK_MELEE, 2); - setguard(ug, GUARD_ALL); + setguard(ug, true); CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); test_cleanup(); } @@ -85,7 +85,7 @@ static void test_is_guard(CuTest * tc) ug = test_create_unit(test_create_faction(0), r); i_change(&ug->items, itype, 1); set_level(ug, SK_MELEE, 2); - setguard(ug, GUARD_ALL); + setguard(ug, true); CuAssertIntEquals(tc, 1, armedmen(ug, false)); CuAssertTrue(tc, is_guard(ug, GUARD_RECRUIT)); set_level(ug, SK_MELEE, 1); @@ -109,7 +109,7 @@ static void test_guard_unarmed(CuTest * tc) r = test_create_region(0, 0, 0); u = test_create_unit(test_create_faction(0), r); ug = test_create_unit(test_create_faction(rc), r); - setguard(ug, GUARD_ALL); + setguard(ug, true); CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); test_cleanup(); } @@ -123,7 +123,7 @@ static void test_guard_monsters(CuTest * tc) r = test_create_region(0, 0, 0); u = test_create_unit(test_create_faction(0), r); ug = test_create_unit(get_monsters(), r); - setguard(ug, GUARD_ALL); + setguard(ug, true); CuAssertPtrEquals(tc, ug, is_guarded(r, u, GUARD_PRODUCE)); test_cleanup(); } diff --git a/src/kernel/build.c b/src/kernel/build.c index 6bc953241..f963797fd 100644 --- a/src/kernel/build.c +++ b/src/kernel/build.c @@ -113,7 +113,7 @@ static void destroy_road(unit * u, int nmax, struct order *ord) } for (u2 = r->units; u2; u2 = u2->next) { - if (u2->faction != u->faction && is_guard(u2, GUARD_TAX) + if (u2->faction != u->faction && is_guard(u2) && cansee(u2->faction, u->region, u, 0) && !alliedunit(u, u2->faction, HELP_GUARD)) { cmistake(u, ord, 70, MSG_EVENT); diff --git a/src/kernel/unit.c b/src/kernel/unit.c index ad8377254..f43ef53bc 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -948,7 +948,7 @@ void move_unit(unit * u, region * r, unit ** ulist) if (!ulist) ulist = (&r->units); if (u->region) { - setguard(u, GUARD_NONE); + setguard(u, false); fset(u, UFL_MOVED); if (u->ship || u->building) { /* can_leave must be checked in travel_i */ diff --git a/src/laws.c b/src/laws.c index a2f7f0044..47cb4b13a 100755 --- a/src/laws.c +++ b/src/laws.c @@ -2556,7 +2556,7 @@ int guard_off_cmd(unit * u, struct order *ord) init_order(ord); if (getparam(u->faction->locale) == P_NOT) { - setguard(u, GUARD_NONE); + setguard(u, false); } return 0; } @@ -2698,7 +2698,7 @@ int guard_on_cmd(unit * u, struct order *ord) else { int err = can_start_guarding(u); if (err == E_GUARD_OK) { - guard(u, GUARD_ALL); + setguard(u, true); } else if (err == E_GUARD_UNARMED) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "unit_unarmed", "")); @@ -4171,7 +4171,7 @@ int siege_cmd(unit * u, order * ord) return 80; } - if (!is_guard(u, GUARD_TRAVELTHRU)) { + if (!is_guard(u)) { /* abbruch, wenn die einheit nicht vorher die region bewacht - als * warnung fuer alle anderen! */ cmistake(u, ord, 81, MSG_EVENT); @@ -4485,7 +4485,7 @@ cansee(const faction * f, const region * r, const unit * u, int modifier) return false; /* simple visibility, just gotta have a unit in the region to see 'em */ - if (is_guard(u, GUARD_ALL) != 0 || usiege(u) || u->building || u->ship) { + if (is_guard(u) || usiege(u) || u->building || u->ship) { return true; } @@ -4524,7 +4524,7 @@ bool cansee_unit(const unit * u, const unit * target, int modifier) else { int n, rings, o; - if (is_guard(target, GUARD_ALL) != 0 || usiege(target) || target->building + if (is_guard(target) || usiege(target) || target->building || target->ship) { return true; } @@ -4568,7 +4568,7 @@ cansee_durchgezogen(const faction * f, const region * r, const unit * u, else { int rings; - if (is_guard(u, GUARD_ALL) != 0 || usiege(u) || u->building || u->ship) { + if (is_guard(u) || usiege(u) || u->building || u->ship) { return true; } diff --git a/src/monsters.c b/src/monsters.c index 258175b43..3301f157a 100644 --- a/src/monsters.c +++ b/src/monsters.c @@ -202,7 +202,7 @@ static order *get_money_for_dragon(region * r, unit * udragon, int wanted) /* falls der drache launisch ist, oder das regionssilber knapp, greift er alle an * und holt sich Silber von Einheiten, vorausgesetzt er bewacht bereits */ money = 0; - if (attacks && is_guard(udragon, GUARD_TAX)) { + if (attacks && is_guard(udragon)) { money += monster_attacks(udragon, true, true); } @@ -735,7 +735,7 @@ void plan_monsters(faction * f) setstatus(u, ST_FIGHT); /* all monsters fight */ } - if (attacking && (!r->land || is_guard(u, GUARD_TAX))) { + if (attacking && (!r->land || is_guard(u))) { monster_attacks(u, true, false); } diff --git a/src/monsters.test.c b/src/monsters.test.c index 6797a9ce0..ca793891c 100644 --- a/src/monsters.test.c +++ b/src/monsters.test.c @@ -74,7 +74,7 @@ static void test_monsters_attack(CuTest * tc) create_monsters(&f, &f2, &u, &m); - guard(m, GUARD_TAX); + setguard(m, true); config_set("rules.monsters.attack_chance", "1"); @@ -111,7 +111,7 @@ static void test_monsters_waiting(CuTest * tc) unit *u, *m; create_monsters(&f, &f2, &u, &m); - guard(m, GUARD_TAX); + setguard(m, true); fset(m, UFL_ISNEW); monster_attacks(m, false, false); CuAssertPtrEquals(tc, 0, find_order("attack 1", m)); @@ -150,8 +150,8 @@ static void test_monsters_attack_not(CuTest * tc) create_monsters(&f, &f2, &u, &m); - guard(m, GUARD_TAX); - guard(u, GUARD_TAX); + setguard(m, true); + setguard(u, true); config_set("rules.monsters.attack_chance", "0"); @@ -170,7 +170,7 @@ static void test_dragon_attacks_the_rich(CuTest * tc) create_monsters(&f, &f2, &u, &m); init_resources(); - guard(m, GUARD_TAX); + setguard(m, true); set_level(m, SK_WEAPONLESS, 10); rsetmoney(findregion(0, 0), 1); diff --git a/src/move.c b/src/move.c index ac7c46083..78232480f 100644 --- a/src/move.c +++ b/src/move.c @@ -934,7 +934,7 @@ static unit *bewegung_blockiert_von(unit * reisender, region * r) if (fval(u_race(reisender), RCF_ILLUSIONARY)) return NULL; for (u = r->units; u; u = u->next) { - if (is_guard(u, GUARD_TRAVELTHRU)) { + if (is_guard(u)) { int sk = effskill(u, SK_PERCEPTION, r); if (invisible(reisender, u) >= reisender->number) continue; @@ -1615,7 +1615,7 @@ static const region_list *travel_route(unit * u, /* the unit has moved at least one region */ int walkmode; - setguard(u, GUARD_NONE); + setguard(u, false); cycle_route(ord, u, steps); if (mode == TRAVEL_RUNNING) { @@ -1643,7 +1643,7 @@ static const region_list *travel_route(unit * u, /* make orders for the followers */ } fset(u, UFL_LONGACTION | UFL_NOTMOVING); - setguard(u, GUARD_NONE); + setguard(u, false); assert(u->region == current); return iroute; } @@ -2141,7 +2141,7 @@ static void travel(unit * u, region_list ** routep) sh = NULL; } if (sh) { - unit *guard = is_guarded(r, u, GUARD_LANDING); + unit *guard = is_guarded(r, u); if (guard) { ADDMSG(&u->faction->msgs, msg_feedback(u, u->thisorder, "region_guarded", "guard", guard)); diff --git a/src/report.c b/src/report.c index c7093da73..e9a0681ba 100644 --- a/src/report.c +++ b/src/report.c @@ -1671,7 +1671,7 @@ static void guards(stream *out, const region * r, const faction * see) /* Bewachung */ for (u = r->units; u; u = u->next) { - if (is_guard(u, GUARD_ALL) != 0) { + if (is_guard(u) != 0) { faction *f = u->faction; faction *fv = visible_faction(see, u); diff --git a/src/reports.c b/src/reports.c index 5a7f29a10..b99cda5fc 100644 --- a/src/reports.c +++ b/src/reports.c @@ -582,7 +582,7 @@ size_t size) } } } - if (is_guard(u, GUARD_ALL) != 0) { + if (is_guard(u)) { bufp = STRLCPY(bufp, ", ", size); bufp = STRLCPY(bufp, LOC(f->locale, "unit_guards"), size); } diff --git a/src/spells.c b/src/spells.c index c48c777f0..e4ca75fbc 100644 --- a/src/spells.c +++ b/src/spells.c @@ -2196,7 +2196,7 @@ static int sp_ironkeeper(castorder * co) /*keeper->age = cast_level + 2; */ setstatus(keeper, ST_AVOID); /* kaempft nicht */ - setguard(keeper, GUARD_ALL); + setguard(keeper, true); fset(keeper, UFL_ISNEW); /* Parteitarnen, damit man nicht sofort weiß, wer dahinter steckt */ if (rule_stealth_anon()) { @@ -2386,7 +2386,6 @@ void patzer_peasantmob(const castorder * co) create_unit(r, f, n, get_race(RC_PEASANT), 0, LOC(f->locale, "angry_mob"), NULL); fset(u, UFL_ISNEW); - /* guard(u, GUARD_ALL); hier zu frueh! Befehl BEWACHE setzten */ addlist(&u->orders, create_order(K_GUARD, lang, NULL)); set_order(&u->thisorder, default_order(lang)); a = a_new(&at_unitdissolve); @@ -3746,7 +3745,7 @@ static int sp_rallypeasantmob(castorder * co) rsetpeasants(r, rpeasants(r) + u->number); rsetmoney(r, rmoney(r) + get_money(u)); set_money(u, 0); - setguard(u, GUARD_NONE); + setguard(u, false); set_number(u, 0); erfolg = cast_level; } @@ -3813,7 +3812,7 @@ static int sp_raisepeasantmob(castorder * co) create_unit(r, monsters, n, get_race(RC_PEASANT), 0, LOC(monsters->locale, "furious_mob"), NULL); fset(u, UFL_ISNEW); - guard(u, GUARD_ALL); + setguard(u, true); a = a_new(&at_unitdissolve); a->data.ca[0] = 1; /* An rpeasants(r). */ a->data.ca[1] = 15; /* 15% */ diff --git a/src/spells/combatspells.c b/src/spells/combatspells.c index bcbbb1b52..bf122729a 100644 --- a/src/spells/combatspells.c +++ b/src/spells/combatspells.c @@ -1437,7 +1437,7 @@ int sp_denyattack(struct castorder * co) leave(mage, false); } /* und bewachen nicht */ - setguard(mage, GUARD_NONE); + setguard(mage, false); /* irgendwie den langen befehl sperren */ /* fset(fi, FIG_ATTACKED); */ @@ -1800,7 +1800,7 @@ int sp_undeadhero(struct castorder * co) unit_setinfo(u, NULL); } setstatus(u, du->status); - setguard(u, GUARD_NONE); + setguard(u, false); for (ilist = &du->items; *ilist;) { item *itm = *ilist; int loot = itm->number * j / du->number; diff --git a/src/spy.c b/src/spy.c index 9b8fe4601..01a419aba 100644 --- a/src/spy.c +++ b/src/spy.c @@ -463,7 +463,7 @@ static void sink_ship(region * r, ship * sh, unit * saboteur) } leave_ship(u); if (r != safety) { - setguard(u, GUARD_NONE); + setguard(u, false); } while (u->items) { i_remove(&u->items, u->items);