comparison to boolean values is bad form.

This commit is contained in:
Enno Rehling 2012-05-23 00:09:19 -07:00
parent 22ccb5cf95
commit eea6bdb888
12 changed files with 34 additions and 31 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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");

View File

@ -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;

View File

@ -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)<sizeof(buffer));
cb_new_kv(buffer, &rtype, sizeof(rtype), buffer);
cb_insert(cb, buffer, len+1+sizeof(rtype));
len = cb_new_kv(buffer, len, &rtype, sizeof(rtype), buffer);
cb_insert(cb, buffer, len);
}
}
return 0;

View File

@ -598,7 +598,7 @@ void set_combatspell(unit * u, spell * sp, struct order *ord, int level)
}
/* knowsspell prüft auf ist_magier, ist_spruch, kennt_spruch */
if (knowsspell(u->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;
}

View File

@ -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);

View File

@ -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)

View File

@ -52,7 +52,8 @@ spell * create_spell(const char * name, unsigned int id)
size_t len = strlen(name);
assert(len+sizeof(sp)<sizeof(buffer));
if (find_spell(name)) {
if (cb_find_str(&cb_spells, name)) {
log_error("create_spell: duplicate name '%s'\n", name);
return 0;
}

View File

@ -1301,7 +1301,7 @@ get_modifier(const unit * u, skill_t sk, int level, const region * r,
skill += rc_skillmod(u->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);

View File

@ -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) {