diff --git a/src/kernel/connection.c b/src/kernel/connection.c index f10fbc53d..6eccf1f0c 100644 --- a/src/kernel/connection.c +++ b/src/kernel/connection.c @@ -211,7 +211,7 @@ border_type *find_bordertype(const char *name) { border_type *bt = bordertypes; - while (bt && strcmp(bt->__name, name)) + while (bt && strcmp(bt->__name, name)!=0) bt = bt->next; return bt; } @@ -620,7 +620,6 @@ int read_borders(gamedata *data) assert(type || !"connection type not registered"); } - READ_INT(store, &bid); if (data->version < UIDHASH_VERSION) { int fx, fy, tx, ty; @@ -639,9 +638,7 @@ int read_borders(gamedata *data) to = findregionbyid(tid); } if (!to || !from) { - if (!to || !from) { - log_error("%s connection %d has missing regions", zText, bid); - } + log_error("%s connection %d has missing regions", zText, bid); if (type->read) { // skip ahead connection dummy; @@ -650,7 +647,7 @@ int read_borders(gamedata *data) continue; } - if (to == from && type && from) { + if (to == from && from) { direction_t dir = (direction_t)(rng_int() % MAXDIRECTIONS); region *r = rconnect(from, dir); log_error("[read_borders] invalid %s in %s\n", type->__name, regionname(from, NULL)); @@ -659,7 +656,7 @@ int read_borders(gamedata *data) } if (type->read) { connection *b = new_border(type, from, to); - nextborder--; /* new_border erhöht den Wert */ + nextborder--; /* new_border erh�ht den Wert */ b->id = bid; assert(bid <= nextborder); type->read(b, data); diff --git a/src/kernel/jsonconf.c b/src/kernel/jsonconf.c index 6e60fc90c..d12238566 100644 --- a/src/kernel/jsonconf.c +++ b/src/kernel/jsonconf.c @@ -796,7 +796,7 @@ static void json_settings(cJSON *json) { else { char value[32]; if (child->type == cJSON_Number && child->valuedouble && child->valueintvaluedouble) { - _snprintf(value, sizeof(value), "%lf", child->valuedouble); + _snprintf(value, sizeof(value), "%f", child->valuedouble); } else { _snprintf(value, sizeof(value), "%d", child->valueint); diff --git a/src/kernel/ship.c b/src/kernel/ship.c index d01d0a788..6898630ff 100644 --- a/src/kernel/ship.c +++ b/src/kernel/ship.c @@ -297,10 +297,9 @@ int crew_skill(const ship *sh) { int shipspeed(const ship * sh, const unit * u) { - int k = sh->type->range; attrib *a; struct curse *c; - int bonus; + int k, bonus; assert(sh); if (!u) u = ship_owner(sh); @@ -310,6 +309,7 @@ int shipspeed(const ship * sh, const unit * u) assert(sh->type->construction); assert(sh->type->construction->improvement == NULL); /* sonst ist construction::size nicht ship_type::maxsize */ + k = sh->type->range; if (sh->size != sh->type->construction->maxsize) return 0; @@ -417,7 +417,7 @@ static unit * ship_owner_ex(const ship * sh, const struct faction * last_owner) { unit *u, *heir = 0; - /* Eigentümer tot oder kein Eigentümer vorhanden. Erste lebende Einheit + /* Eigent�mer tot oder kein Eigent�mer vorhanden. Erste lebende Einheit * nehmen. */ for (u = sh->region->units; u; u = u->next) { if (u->ship == sh) { diff --git a/src/move.test.c b/src/move.test.c index 5c89166c8..bc93ec124 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -273,10 +273,10 @@ void setup_drift (struct drift_fixture *fix) { fix->st_boat->cabins = 20000; fix->u = test_create_unit(fix->f = test_create_faction(0), fix->r=findregion(-1,0)); - assert(fix->r); + assert(fix->r && fix->u && fix->f); set_level(fix->u, SK_SAILING, fix->st_boat->sumskill); u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat)); - assert(fix->f && fix->u && fix->sh); + assert(fix->sh); } static void test_ship_no_overload(CuTest *tc) { diff --git a/src/piracy.test.c b/src/piracy.test.c index affb6f5c4..82e4e55b7 100644 --- a/src/piracy.test.c +++ b/src/piracy.test.c @@ -83,12 +83,12 @@ static void test_piracy_cmd(CuTest * tc) { t_ocean = get_or_create_terrain("ocean"); st_boat = st_get_or_create("boat"); u2 = test_create_unit(test_create_faction(0), test_create_region(1, 0, t_ocean)); - u_set_ship(u2, test_create_ship(u2->region, st_boat)); assert(u2); + u_set_ship(u2, test_create_ship(u2->region, st_boat)); u = test_create_unit(f = test_create_faction(0), r = test_create_region(0, 0, t_ocean)); + assert(f && u); set_level(u, SK_SAILING, st_boat->sumskill); u_set_ship(u, test_create_ship(u->region, st_boat)); - assert(f && u); f->locale = get_or_create_locale("de"); u->thisorder = create_order(K_PIRACY, f->locale, "%s", itoa36(u2->faction->no)); diff --git a/src/reports.c b/src/reports.c index fa39f0a85..f4c38712c 100644 --- a/src/reports.c +++ b/src/reports.c @@ -489,13 +489,14 @@ size_t size) building *b; bool isbattle = (bool)(mode == seen_battle); item *itm, *show = NULL; - faction *fv = visible_faction(f, u); + faction *fv; char *bufp = buf; int result = 0; item results[MAX_INVENTORY]; + assert(f); bufp = STRLCPY(bufp, unitname(u), size); - + fv = visible_faction(f, u); if (!isbattle) { attrib *a_otherfaction = a_find(u->attribs, &at_otherfaction); if (u->faction == f) { @@ -770,7 +771,7 @@ size_t size) } dh = 0; - if (!getarnt && f) { + if (!getarnt) { if (alliedfaction(rplane(u->region), f, fv, HELP_ALL)) { dh = 1; } diff --git a/src/upkeep.test.c b/src/upkeep.test.c index b4f2ae412..e84402d4b 100644 --- a/src/upkeep.test.c +++ b/src/upkeep.test.c @@ -81,10 +81,11 @@ void test_upkeep_from_pool(CuTest * tc) i_silver = it_find("money"); assert(i_silver); r = findregion(0, 0); + assert(r); u1 = test_create_unit(test_create_faction(test_create_race("human")), r); assert(u1); u2 = test_create_unit(u1->faction, r); - assert(r && u1 && u2); + assert(u2); config_set("rules.food.flags", "0"); i_change(&u1->items, i_silver, 30);