diff --git a/src/gamecode/creport.c b/src/gamecode/creport.c index 6bea30d8e..bdeddc230 100644 --- a/src/gamecode/creport.c +++ b/src/gamecode/creport.c @@ -913,7 +913,7 @@ static void cr_output_unit(FILE * F, const region * r, const faction * f, pr = 0; if (f == u->faction || omniscient(f)) { show = u->items; - } else if (itemcloak == false && mode >= see_unit && !(a_fshidden + } else if (!itemcloak && mode >= see_unit && !(a_fshidden && a_fshidden->data.ca[1] == 1 && effskill(u, SK_STEALTH) >= 3)) { int n = report_items(u->items, result, MAX_INVENTORY, u, f); assert(n >= 0); diff --git a/src/gamecode/laws.c b/src/gamecode/laws.c index 47a0d0727..7014f981e 100644 --- a/src/gamecode/laws.c +++ b/src/gamecode/laws.c @@ -1712,7 +1712,7 @@ static int name_cmd(unit * u, struct order *ord) switch (p) { case P_ALLIANCE: - if (foreign == false && f_get_alliance(u->faction)) { + if (!foreign && f_get_alliance(u->faction)) { alliance *al = u->faction->alliance; faction *lead = alliance_get_leader(al); if (lead == u->faction) { @@ -1729,7 +1729,7 @@ static int name_cmd(unit * u, struct order *ord) return rename_building(u, ord, b, getstrtoken()); case P_FACTION: - if (foreign == true) { + if (foreign) { faction *f; f = getfaction(); @@ -1767,7 +1767,7 @@ static int name_cmd(unit * u, struct order *ord) break; case P_SHIP: - if (foreign == true) { + if (foreign) { ship *sh = getship(r); unit *uo; @@ -1822,7 +1822,7 @@ static int name_cmd(unit * u, struct order *ord) break; case P_UNIT: - if (foreign == true) { + if (foreign) { unit *u2 = getunit(r, u->faction); if (!u2 || !cansee(u->faction, r, u2, 0)) { @@ -1981,7 +1981,7 @@ static int mail_cmd(unit * u, struct order *ord) } } - if (see == false) { + if (!see) { cmistake(u, ord, 66, MSG_MESSAGE); break; } @@ -2007,7 +2007,7 @@ static int mail_cmd(unit * u, struct order *ord) } } - if (see == false) { + if (!see) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "feedback_unit_not_found", "")); return 0; @@ -2171,7 +2171,7 @@ static int password_cmd(unit * u, struct order *ord) } } free(u->faction->passw); - if (pwok == false) { + if (!pwok) { cmistake(u, ord, 283, MSG_EVENT); u->faction->passw = strdup(itoa36(rng_int())); } else { @@ -3510,7 +3510,7 @@ static void setdefaults(unit * u) /* Wenn die Einheit handelt, muß der Default-Befehl gelöscht * werden. */ - if (trade == true) { + if (trade) { /* fset(u, UFL_LONGACTION|UFL_NOTMOVING); */ set_order(&u->thisorder, NULL); } diff --git a/src/items/phoenixcompass.c b/src/items/phoenixcompass.c index fe35d444e..e26adfa8e 100644 --- a/src/items/phoenixcompass.c +++ b/src/items/phoenixcompass.c @@ -84,7 +84,7 @@ use_phoenixcompass(struct unit *u, const struct item_type *itype, * at the same distance was found and the device is confused */ if (closest_phoenix == NULL - || closest_phoenix->region == u->region || confusion == true) { + || closest_phoenix->region == u->region || confusion) { add_message(&u->faction->msgs, msg_message("phoenixcompass_confusion", "unit region command", u, u->region, ord)); return 0; diff --git a/src/kernel/battle.c b/src/kernel/battle.c index 1abf5ad82..ad01108b5 100644 --- a/src/kernel/battle.c +++ b/src/kernel/battle.c @@ -1742,7 +1742,7 @@ void do_combatmagic(battle * b, combatmagic_t was) continue; ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang)); - if (cancast(mage, sp, 1, 1, ord) == false) { + if (!cancast(mage, sp, 1, 1, ord)) { free_order(ord); continue; } @@ -1761,7 +1761,7 @@ void do_combatmagic(battle * b, combatmagic_t was) if (power <= 0) { /* Effekt von Antimagie */ report_failed_spell(b, mage, sp); pay_spell(mage, sp, level, 1); - } else if (fumble(r, mage, sp, sp->level)) { + } else if (fumble(r, mage, sp, level)) { report_failed_spell(b, mage, sp); pay_spell(mage, sp, level, 1); } else { @@ -1837,7 +1837,7 @@ static void do_combatspell(troop at) return; } ord = create_order(K_CAST, lang, "'%s'", spell_name(sp, lang)); - if (cancast(caster, sp, 1, 1, ord) == false) { + if (!cancast(caster, sp, 1, 1, ord)) { fi->magic = 0; /* Kann nicht mehr Zaubern, kämpft nichtmagisch weiter */ return; } @@ -1846,7 +1846,7 @@ static void do_combatspell(troop at) if ((sl = get_combatspelllevel(caster, 1)) > 0) level = MIN(level, sl); - if (fumble(r, caster, sp, sp->level) == true) { + if (fumble(r, caster, sp, level)) { report_failed_spell(b, caster, sp); pay_spell(caster, sp, level, 1); return; @@ -3100,7 +3100,7 @@ static void print_header(battle * b) WARN_STATIC_BUFFER(); first = true; } - if (seematrix(f, s) == true) + if (seematrix(f, s)) lastf = sidename(s); else lastf = LOC(f->locale, "unknown_faction_dative"); diff --git a/src/kernel/curse.c b/src/kernel/curse.c index ce18998b6..016b96212 100644 --- a/src/kernel/curse.c +++ b/src/kernel/curse.c @@ -615,7 +615,7 @@ static void do_transfer_curse(curse * c, unit * u, unit * u2, int n) break; } - if (dogive == true) { + if (dogive) { curse *cnew = make_curse(c->magician, &u2->attribs, c->type, c->vigour, c->duration, c->effect, men); cnew->flags = c->flags; diff --git a/src/kernel/item.c b/src/kernel/item.c index f72bce744..e6380f400 100644 --- a/src/kernel/item.c +++ b/src/kernel/item.c @@ -1071,8 +1071,8 @@ static int add_resourcename_cb(const void * match, const void * key, size_t keyl if (name && transliterate(buffer, sizeof(buffer), name)) { size_t len = strlen(buffer); assert(len+sizeof(rtype)region, u, sp) == false) { + if (!knowsspell(u->region, u, sp)) { /* Fehler 'Spell not found' */ cmistake(u, ord, 173, MSG_MAGIC); return; @@ -976,7 +976,7 @@ cancast(unit * u, const spell * sp, int level, int range, struct order * ord) int itemanz; resource *reslist = NULL; - if (knowsspell(u->region, u, sp) == false) { + if (!knowsspell(u->region, u, sp)) { /* Diesen Zauber kennt die Einheit nicht */ cmistake(u, ord, 173, MSG_MAGIC); return false; @@ -1325,10 +1325,10 @@ boolean fumble(region * r, unit * u, const spell * sp, int cast_grade) if (sp->magietyp == M_DRAIG) { patzer += CHAOSPATZERCHANCE; } - if (is_cursed(u->attribs, C_MBOOST, 0) == true) { + if (is_cursed(u->attribs, C_MBOOST, 0)) { patzer += CHAOSPATZERCHANCE; } - if (is_cursed(u->attribs, C_FUMBLE, 0) == true) { + if (is_cursed(u->attribs, C_FUMBLE, 0)) { patzer += CHAOSPATZERCHANCE; } @@ -2830,7 +2830,7 @@ void magic(void) /* Prüfen, ob die realen Kosten für die gewünschten Stufe bezahlt * werden können */ - if (cancast(u, sp, co->level, co->distance, ord) == false) { + if (!cancast(u, sp, co->level, co->distance, ord)) { /* die Fehlermeldung wird in cancast generiert */ continue; } diff --git a/src/kernel/move.c b/src/kernel/move.c index f43655a3a..c7a669d9a 100644 --- a/src/kernel/move.c +++ b/src/kernel/move.c @@ -1790,7 +1790,7 @@ sail(unit * u, order * ord, boolean move_on_land, region_list ** routep) break; } } else { - if (check_takeoff(sh, current_point, next_point) == false) { + if (!check_takeoff(sh, current_point, next_point)) { /* Schiff kann nicht ablegen */ cmistake(u, ord, 182, MSG_MOVE); break; @@ -2265,8 +2265,7 @@ static void piracy_cmd(unit * u, struct order *ord) region *rc = rconnect(r, dir); aff[dir].value = 0; aff[dir].target = 0; - if (rc && fval(rc->terrain, SWIM_INTO) - && check_takeoff(sh, r, rc) == true) { + if (rc && fval(rc->terrain, SWIM_INTO) && check_takeoff(sh, r, rc)) { for (sh2 = rc->ships; sh2; sh2 = sh2->next) { unit *cap = ship_owner(sh2); diff --git a/src/kernel/move_test.c b/src/kernel/move_test.c index 8b7bf4408..492722253 100644 --- a/src/kernel/move_test.c +++ b/src/kernel/move_test.c @@ -26,9 +26,9 @@ static void test_building_type_exists(CuTest * tc) b = new_building(btype, r, default_locale); CuAssertPtrNotNull(tc, b); - CuAssertTrue(tc, buildingtype_exists(r, NULL, true) == false); - CuAssertTrue(tc, buildingtype_exists(r, btype, true) == true); - CuAssertTrue(tc, buildingtype_exists(r, btype2, true) == false); + CuAssertTrue(tc, !buildingtype_exists(r, NULL, true)); + CuAssertTrue(tc, buildingtype_exists(r, btype, true)); + CuAssertTrue(tc, !buildingtype_exists(r, btype2, true)); } CuSuite *get_move_suite(void) diff --git a/src/kernel/spell.c b/src/kernel/spell.c index 36bdcaa10..654a2d19d 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -52,7 +52,8 @@ spell * create_spell(const char * name, unsigned int id) size_t len = strlen(name); assert(len+sizeof(sp)race, r, sk); skill += att_modification(u, sk); - if (noitem == false) { + if (!noitem) { skill = item_modification(u, sk, skill); } skill = skillmod(u->attribs, u, r, sk, skill, SMF_ALWAYS); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 123c1cf04..84fbe5b19 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1490,6 +1490,9 @@ static int parse_spells(xmlDocPtr doc) assert(propValue != NULL); sp = create_spell((const char *)propValue, index); xmlFree(propValue); + if (!sp) { + continue; + } propValue = xmlGetProp(node, BAD_CAST "parameters"); if (propValue) {