forked from github/server
cppcheck warnings
This commit is contained in:
parent
b7dcee7e08
commit
079a55fe41
3 changed files with 13 additions and 16 deletions
|
@ -476,14 +476,14 @@ static int count_materials(unit *u, const construction *type, int n, int complet
|
||||||
|
|
||||||
assert(canuse >= 0);
|
assert(canuse >= 0);
|
||||||
if (type->reqsize > 1) {
|
if (type->reqsize > 1) {
|
||||||
int need, prebuilt;
|
int prebuilt = required(completed, type->reqsize,
|
||||||
prebuilt =
|
type->materials[c].number);
|
||||||
required(completed, type->reqsize, type->materials[c].number);
|
while (n > 0) {
|
||||||
for (; n;) {
|
int need =
|
||||||
need =
|
|
||||||
required(completed + n, type->reqsize, type->materials[c].number);
|
required(completed + n, type->reqsize, type->materials[c].number);
|
||||||
if (need - prebuilt <= canuse)
|
if (need - prebuilt <= canuse) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
--n; /* TODO: optimieren? */
|
--n; /* TODO: optimieren? */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -704,7 +704,7 @@ build_building(unit * u, const building_type * btype, int id, int want, order *
|
||||||
* gefunden wurde, dann wird nicht einfach eine neue erbaut. Ansonsten
|
* gefunden wurde, dann wird nicht einfach eine neue erbaut. Ansonsten
|
||||||
* baut man an der eigenen burg weiter. */
|
* baut man an der eigenen burg weiter. */
|
||||||
|
|
||||||
/* Wenn die angegebene Nummer falsch ist, KEINE Burg bauen! */
|
/* Wenn die angegebene Nummer falsch ist, KEINE Burg bauen! */
|
||||||
if (id > 0) { /* eine Nummer angegeben, keine neue Burg bauen */
|
if (id > 0) { /* eine Nummer angegeben, keine neue Burg bauen */
|
||||||
b = findbuilding(id);
|
b = findbuilding(id);
|
||||||
if (!b || b->region != u->region) { /* eine Burg mit dieser Nummer gibt es hier nicht */
|
if (!b || b->region != u->region) { /* eine Burg mit dieser Nummer gibt es hier nicht */
|
||||||
|
@ -893,12 +893,12 @@ static void build_ship(unit * u, ship * sh, int want)
|
||||||
|
|
||||||
if (n)
|
if (n)
|
||||||
ADDMSG(&u->faction->msgs,
|
ADDMSG(&u->faction->msgs,
|
||||||
msg_message("buildship", "ship unit size", sh, u, n));
|
msg_message("buildship", "ship unit size", sh, u, n));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
create_ship(unit * u, const struct ship_type *newtype, int want,
|
create_ship(unit * u, const struct ship_type *newtype, int want,
|
||||||
order * ord)
|
order * ord)
|
||||||
{
|
{
|
||||||
ship *sh;
|
ship *sh;
|
||||||
int msize;
|
int msize;
|
||||||
|
@ -940,7 +940,7 @@ order * ord)
|
||||||
}
|
}
|
||||||
new_order =
|
new_order =
|
||||||
create_order(K_MAKE, u->faction->locale, "%s %i", LOC(u->faction->locale,
|
create_order(K_MAKE, u->faction->locale, "%s %i", LOC(u->faction->locale,
|
||||||
parameters[P_SHIP]), sh->no);
|
parameters[P_SHIP]), sh->no);
|
||||||
replace_order(&u->orders, ord, new_order);
|
replace_order(&u->orders, ord, new_order);
|
||||||
free_order(new_order);
|
free_order(new_order);
|
||||||
|
|
||||||
|
|
|
@ -247,7 +247,7 @@ static void test_buildingowner_resets_when_empty(CuTest * tc)
|
||||||
u_set_building(u, bld);
|
u_set_building(u, bld);
|
||||||
CuAssertPtrEquals(tc, u, building_owner(bld));
|
CuAssertPtrEquals(tc, u, building_owner(bld));
|
||||||
u->number = 0;
|
u->number = 0;
|
||||||
CuAssertPtrEquals(tc, 0, building_owner(bld));
|
CuAssertPtrEquals(tc, NULL, building_owner(bld));
|
||||||
u->number = 1;
|
u->number = 1;
|
||||||
CuAssertPtrEquals(tc, u, building_owner(bld));
|
CuAssertPtrEquals(tc, u, building_owner(bld));
|
||||||
test_teardown();
|
test_teardown();
|
||||||
|
|
|
@ -121,10 +121,8 @@ static unit *unitorders(input *in, faction *f)
|
||||||
|
|
||||||
static faction *factionorders(void)
|
static faction *factionorders(void)
|
||||||
{
|
{
|
||||||
faction *f = NULL;
|
|
||||||
int fid = getid();
|
int fid = getid();
|
||||||
|
faction *f = findfaction(fid);
|
||||||
f = findfaction(fid);
|
|
||||||
|
|
||||||
if (f != NULL && !fval(f, FFL_NPC)) {
|
if (f != NULL && !fval(f, FFL_NPC)) {
|
||||||
char token[128];
|
char token[128];
|
||||||
|
@ -231,9 +229,8 @@ int readorders(const char *filename)
|
||||||
{
|
{
|
||||||
input in;
|
input in;
|
||||||
int result;
|
int result;
|
||||||
|
FILE *F = fopen(filename, "r");
|
||||||
|
|
||||||
FILE *F = NULL;
|
|
||||||
F = fopen(filename, "r");
|
|
||||||
if (!F) {
|
if (!F) {
|
||||||
perror(filename);
|
perror(filename);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in a new issue