forked from github/server
cppcheck: DMAXHASH was unused.
cppcheck: remove warnings, reduce variable scopes.
This commit is contained in:
parent
d802f6ea67
commit
fc2506ee83
16 changed files with 77 additions and 122 deletions
26
src/give.c
26
src/give.c
|
@ -158,13 +158,15 @@ static bool limited_give(const item_type * type)
|
||||||
int give_quota(const unit * src, const unit * dst, const item_type * type,
|
int give_quota(const unit * src, const unit * dst, const item_type * type,
|
||||||
int n)
|
int n)
|
||||||
{
|
{
|
||||||
double divisor;
|
|
||||||
|
|
||||||
if (!limited_give(type)) {
|
if (!limited_give(type)) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
if (dst && src && src->faction != dst->faction) {
|
if (dst && src && src->faction != dst->faction) {
|
||||||
divisor = config_get_flt("rules.items.give_divisor", 1);
|
static int config;
|
||||||
|
static double divisor = 1.0;
|
||||||
|
if (config_changed(&config)) {
|
||||||
|
divisor = config_get_flt("rules.items.give_divisor", divisor);
|
||||||
|
}
|
||||||
assert(divisor <= 0 || divisor >= 1);
|
assert(divisor <= 0 || divisor >= 1);
|
||||||
if (divisor >= 1) {
|
if (divisor >= 1) {
|
||||||
/* predictable > correct: */
|
/* predictable > correct: */
|
||||||
|
@ -305,8 +307,6 @@ static bool rule_transfermen(void)
|
||||||
|
|
||||||
message * give_men(int n, unit * u, unit * u2, struct order *ord)
|
message * give_men(int n, unit * u, unit * u2, struct order *ord)
|
||||||
{
|
{
|
||||||
ship *sh;
|
|
||||||
int k = 0;
|
|
||||||
int error = 0;
|
int error = 0;
|
||||||
message * msg;
|
message * msg;
|
||||||
int maxt = max_transfers();
|
int maxt = max_transfers();
|
||||||
|
@ -391,7 +391,7 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_skill(u, SK_ALCHEMY) || has_skill(u2, SK_ALCHEMY)) {
|
if (has_skill(u, SK_ALCHEMY) || has_skill(u2, SK_ALCHEMY)) {
|
||||||
k = count_skill(u2->faction, SK_ALCHEMY);
|
int k = count_skill(u2->faction, SK_ALCHEMY);
|
||||||
|
|
||||||
/* Falls die Zieleinheit keine Alchemisten sind, werden sie nun
|
/* Falls die Zieleinheit keine Alchemisten sind, werden sie nun
|
||||||
* welche. */
|
* welche. */
|
||||||
|
@ -414,6 +414,14 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
|
ship *sh = leftship(u);
|
||||||
|
|
||||||
|
/* Einheiten von Schiffen können nicht NACH in von
|
||||||
|
* Nicht-alliierten bewachten Regionen ausführen */
|
||||||
|
if (sh) {
|
||||||
|
set_leftship(u2, sh);
|
||||||
|
}
|
||||||
|
|
||||||
if (u2->number == 0) {
|
if (u2->number == 0) {
|
||||||
set_racename(&u2->attribs, get_racename(u->attribs));
|
set_racename(&u2->attribs, get_racename(u->attribs));
|
||||||
u_setrace(u2, u_race(u));
|
u_setrace(u2, u_race(u));
|
||||||
|
@ -426,12 +434,6 @@ message * give_men(int n, unit * u, unit * u2, struct order *ord)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Einheiten von Schiffen können nicht NACH in von
|
|
||||||
* Nicht-alliierten bewachten Regionen ausführen */
|
|
||||||
sh = leftship(u);
|
|
||||||
if (sh) {
|
|
||||||
set_leftship(u2, sh);
|
|
||||||
}
|
|
||||||
transfermen(u, u2, n);
|
transfermen(u, u2, n);
|
||||||
if (maxt >= 0 && u->faction != u2->faction) {
|
if (maxt >= 0 && u->faction != u2->faction) {
|
||||||
u2->faction->newbies += n;
|
u2->faction->newbies += n;
|
||||||
|
|
23
src/gmtool.c
23
src/gmtool.c
|
@ -137,10 +137,10 @@ int umvwaddnstr(WINDOW *w, int y, int x, const char * str, int len) {
|
||||||
|
|
||||||
static void init_curses(void)
|
static void init_curses(void)
|
||||||
{
|
{
|
||||||
int fg, bg;
|
|
||||||
initscr();
|
initscr();
|
||||||
|
|
||||||
if (has_colors() || force_color) {
|
if (has_colors() || force_color) {
|
||||||
|
int fg, bg;
|
||||||
short bcol = COLOR_BLACK;
|
short bcol = COLOR_BLACK;
|
||||||
short hcol = COLOR_MAGENTA;
|
short hcol = COLOR_MAGENTA;
|
||||||
start_color();
|
start_color();
|
||||||
|
@ -316,11 +316,11 @@ static void paint_map(window * wnd, const state * st)
|
||||||
int yp = (lines - vy - 1) * THEIGHT;
|
int yp = (lines - vy - 1) * THEIGHT;
|
||||||
for (vx = 0; vx != cols; ++vx) {
|
for (vx = 0; vx != cols; ++vx) {
|
||||||
map_region *mr = mr_get(&st->display, vx, vy);
|
map_region *mr = mr_get(&st->display, vx, vy);
|
||||||
int attr = 0;
|
|
||||||
int hl = 0;
|
|
||||||
int xp = vx * TWIDTH + (vy & 1) * TWIDTH / 2;
|
int xp = vx * TWIDTH + (vy & 1) * TWIDTH / 2;
|
||||||
int nx, ny;
|
int nx, ny;
|
||||||
if (mr) {
|
if (mr) {
|
||||||
|
int attr = 0;
|
||||||
|
int hl = 0;
|
||||||
cnormalize(&mr->coord, &nx, &ny);
|
cnormalize(&mr->coord, &nx, &ny);
|
||||||
if (tagged_region(st->selected, nx, ny)) {
|
if (tagged_region(st->selected, nx, ny)) {
|
||||||
attr |= A_REVERSE;
|
attr |= A_REVERSE;
|
||||||
|
@ -335,10 +335,10 @@ static void paint_map(window * wnd, const state * st)
|
||||||
|
|
||||||
map_region *cursor_region(const view * v, const coordinate * c)
|
map_region *cursor_region(const view * v, const coordinate * c)
|
||||||
{
|
{
|
||||||
coordinate relpos;
|
|
||||||
int cx, cy;
|
|
||||||
|
|
||||||
if (c) {
|
if (c) {
|
||||||
|
int cx, cy;
|
||||||
|
coordinate relpos;
|
||||||
|
|
||||||
relpos.x = c->x - v->topleft.x;
|
relpos.x = c->x - v->topleft.x;
|
||||||
relpos.y = c->y - v->topleft.y;
|
relpos.y = c->y - v->topleft.y;
|
||||||
cy = relpos.y;
|
cy = relpos.y;
|
||||||
|
@ -435,13 +435,14 @@ static void paint_info_region(window * wnd, const state * st)
|
||||||
{
|
{
|
||||||
WINDOW *win = wnd->handle;
|
WINDOW *win = wnd->handle;
|
||||||
int size = getmaxx(win) - 2;
|
int size = getmaxx(win) - 2;
|
||||||
int line = 0, maxline = getmaxy(win) - 2;
|
int maxline = getmaxy(win) - 2;
|
||||||
map_region *mr = cursor_region(&st->display, &st->cursor);
|
map_region *mr = cursor_region(&st->display, &st->cursor);
|
||||||
|
|
||||||
UNUSED_ARG(st);
|
UNUSED_ARG(st);
|
||||||
werase(win);
|
werase(win);
|
||||||
wxborder(win);
|
wxborder(win);
|
||||||
if (mr && mr->r) {
|
if (mr && mr->r) {
|
||||||
|
int line = 0;
|
||||||
const region *r = mr->r;
|
const region *r = mr->r;
|
||||||
if (r->land) {
|
if (r->land) {
|
||||||
umvwaddnstr(win, line++, 1, (char *)r->land->name, size);
|
umvwaddnstr(win, line++, 1, (char *)r->land->name, size);
|
||||||
|
@ -717,10 +718,10 @@ static void select_regions(state * st, int selectmode)
|
||||||
doupdate();
|
doupdate();
|
||||||
findmode = getch();
|
findmode = getch();
|
||||||
if (findmode == 'n') { /* none */
|
if (findmode == 'n') { /* none */
|
||||||
int i;
|
|
||||||
sprintf(sbuffer, "%snone", status);
|
sprintf(sbuffer, "%snone", status);
|
||||||
statusline(st->wnd_status->handle, sbuffer);
|
statusline(st->wnd_status->handle, sbuffer);
|
||||||
if (selectmode & MODE_SELECT) {
|
if (selectmode & MODE_SELECT) {
|
||||||
|
int i;
|
||||||
for (i = 0; i != MAXTHASH; ++i) {
|
for (i = 0; i != MAXTHASH; ++i) {
|
||||||
tag **tp = &st->selected->tags[i];
|
tag **tp = &st->selected->tags[i];
|
||||||
while (*tp) {
|
while (*tp) {
|
||||||
|
@ -945,7 +946,6 @@ static void handlekey(state * st, int c)
|
||||||
static int findmode = 0;
|
static int findmode = 0;
|
||||||
region *r;
|
region *r;
|
||||||
char sbuffer[80];
|
char sbuffer[80];
|
||||||
static char kbuffer[80];
|
|
||||||
int n, nx, ny, minpop, maxpop;
|
int n, nx, ny, minpop, maxpop;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -1328,6 +1328,7 @@ static void handlekey(state * st, int c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wnd == NULL) {
|
if (wnd == NULL) {
|
||||||
|
static char kbuffer[80];
|
||||||
if (kbuffer[0] == 0) {
|
if (kbuffer[0] == 0) {
|
||||||
strcpy(kbuffer, "getch:");
|
strcpy(kbuffer, "getch:");
|
||||||
}
|
}
|
||||||
|
@ -1399,9 +1400,9 @@ void run_mapper(void)
|
||||||
int split = 20;
|
int split = 20;
|
||||||
state *st;
|
state *st;
|
||||||
point tl;
|
point tl;
|
||||||
char sbuffer[512];
|
|
||||||
|
|
||||||
if (!new_players) {
|
if (!new_players) {
|
||||||
|
char sbuffer[512];
|
||||||
path_join(basepath(), "newfactions", sbuffer, sizeof(sbuffer));
|
path_join(basepath(), "newfactions", sbuffer, sizeof(sbuffer));
|
||||||
new_players = read_newfactions(sbuffer);
|
new_players = read_newfactions(sbuffer);
|
||||||
}
|
}
|
||||||
|
@ -1443,8 +1444,6 @@ void run_mapper(void)
|
||||||
view *vi = &st->display;
|
view *vi = &st->display;
|
||||||
|
|
||||||
getbegyx(hwinmap, x, y);
|
getbegyx(hwinmap, x, y);
|
||||||
width = getmaxx(hwinmap) - x;
|
|
||||||
height = getmaxy(hwinmap) - y;
|
|
||||||
coor2point(&st->cursor, &p);
|
coor2point(&st->cursor, &p);
|
||||||
|
|
||||||
if (st->cursor.pl != vi->pl) {
|
if (st->cursor.pl != vi->pl) {
|
||||||
|
|
|
@ -254,10 +254,10 @@ use_item_lua(unit *u, const item_type *itype, int amount, struct order *ord)
|
||||||
lua_State *L = (lua_State *)global.vm_state;
|
lua_State *L = (lua_State *)global.vm_state;
|
||||||
int len, result = 0;
|
int len, result = 0;
|
||||||
char fname[64];
|
char fname[64];
|
||||||
int (*callout)(unit *, const item_type *, int, struct order *);
|
|
||||||
|
|
||||||
len = snprintf(fname, sizeof(fname), "use_%s", itype->rtype->_name);
|
len = snprintf(fname, sizeof(fname), "use_%s", itype->rtype->_name);
|
||||||
if (len > 0 && (size_t)len < sizeof(fname)) {
|
if (len > 0 && (size_t)len < sizeof(fname)) {
|
||||||
|
int(*callout)(unit *, const item_type *, int, struct order *);
|
||||||
callout = (int(*)(unit *, const item_type *, int, struct order *))get_function(fname);
|
callout = (int(*)(unit *, const item_type *, int, struct order *))get_function(fname);
|
||||||
if (callout) {
|
if (callout) {
|
||||||
return callout(u, itype, amount, ord);
|
return callout(u, itype, amount, ord);
|
||||||
|
@ -283,7 +283,8 @@ use_item_lua(unit *u, const item_type *itype, int amount, struct order *ord)
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
if (itype->flags & ITF_POTION) {
|
if (itype->flags & ITF_POTION) {
|
||||||
return use_potion(u, itype, amount, ord);
|
return use_potion(u, itype, amount, ord);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
log_error("no such callout: %s", fname);
|
log_error("no such callout: %s", fname);
|
||||||
}
|
}
|
||||||
log_error("use(%s) calling '%s': not a function.\n", unitname(u), fname);
|
log_error("use(%s) calling '%s': not a function.\n", unitname(u), fname);
|
||||||
|
|
|
@ -121,14 +121,14 @@ use_antimagiccrystal(unit * u, const struct item_type *itype, int amount,
|
||||||
struct order *ord)
|
struct order *ord)
|
||||||
{
|
{
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
const resource_type *rt_crystal = NULL;
|
const resource_type *rt_crystal;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
rt_crystal = rt_find("antimagic");
|
rt_crystal = rt_find("antimagic");
|
||||||
assert(rt_crystal != NULL);
|
assert(rt_crystal != NULL);
|
||||||
|
|
||||||
for (i = 0; i != amount; ++i) {
|
for (i = 0; i != amount; ++i) {
|
||||||
int effect, duration = 2;
|
int effect;
|
||||||
double force;
|
double force;
|
||||||
spell *sp = find_spell("antimagiczone");
|
spell *sp = find_spell("antimagiczone");
|
||||||
attrib **ap = &r->attribs;
|
attrib **ap = &r->attribs;
|
||||||
|
@ -172,6 +172,7 @@ struct order *ord)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (force > 0) {
|
if (force > 0) {
|
||||||
|
int duration = 2;
|
||||||
create_curse(u, &r->attribs, &ct_antimagiczone, force, duration,
|
create_curse(u, &r->attribs, &ct_antimagiczone, force, duration,
|
||||||
effect, 0);
|
effect, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ static void test_manacrystal(CuTest *tc) {
|
||||||
static void test_skillpotion(CuTest *tc) {
|
static void test_skillpotion(CuTest *tc) {
|
||||||
unit *u;
|
unit *u;
|
||||||
const struct item_type *itype;
|
const struct item_type *itype;
|
||||||
skill* pSkill = NULL;
|
skill* pSkill;
|
||||||
int initialWeeks_Entertainment = 0;
|
int initialWeeks_Entertainment = 0;
|
||||||
int initialWeeks_Stamina = 0;
|
int initialWeeks_Stamina = 0;
|
||||||
int initialWeeks_Magic = 0;
|
int initialWeeks_Magic = 0;
|
||||||
|
|
|
@ -124,7 +124,7 @@ static void json_maintenance_i(cJSON *json, maintenance *mt) {
|
||||||
static void json_maintenance(cJSON *json, maintenance **mtp) {
|
static void json_maintenance(cJSON *json, maintenance **mtp) {
|
||||||
cJSON *child;
|
cJSON *child;
|
||||||
maintenance *mt;
|
maintenance *mt;
|
||||||
int i, size = 1;
|
int size = 1;
|
||||||
|
|
||||||
if (json->type == cJSON_Array) {
|
if (json->type == cJSON_Array) {
|
||||||
size = cJSON_GetArraySize(json);
|
size = cJSON_GetArraySize(json);
|
||||||
|
@ -135,6 +135,7 @@ static void json_maintenance(cJSON *json, maintenance **mtp) {
|
||||||
}
|
}
|
||||||
*mtp = mt = (struct maintenance *) calloc(sizeof(struct maintenance), size + 1);
|
*mtp = mt = (struct maintenance *) calloc(sizeof(struct maintenance), size + 1);
|
||||||
if (json->type == cJSON_Array) {
|
if (json->type == cJSON_Array) {
|
||||||
|
int i;
|
||||||
for (i = 0, child = json->child; child; child = child->next, ++i) {
|
for (i = 0, child = json->child; child; child = child->next, ++i) {
|
||||||
if (child->type == cJSON_Object) {
|
if (child->type == cJSON_Object) {
|
||||||
json_maintenance_i(child, mt + i);
|
json_maintenance_i(child, mt + i);
|
||||||
|
|
|
@ -27,7 +27,7 @@ static int report_json(const char *filename, report_context * ctx, const char *c
|
||||||
if (config_get_int("jsreport.enabled", 0) != 0) {
|
if (config_get_int("jsreport.enabled", 0) != 0) {
|
||||||
FILE * F = fopen(filename, "w");
|
FILE * F = fopen(filename, "w");
|
||||||
if (F) {
|
if (F) {
|
||||||
int x, y, minx = INT_MAX, maxx = INT_MIN, miny = INT_MAX, maxy = INT_MIN;
|
int minx = INT_MAX, maxx = INT_MIN, miny = INT_MAX, maxy = INT_MIN;
|
||||||
seen_region *sr;
|
seen_region *sr;
|
||||||
region *r;
|
region *r;
|
||||||
/* traverse all regions */
|
/* traverse all regions */
|
||||||
|
@ -44,12 +44,13 @@ static int report_json(const char *filename, report_context * ctx, const char *c
|
||||||
else if (tx > maxx) maxx = tx;
|
else if (tx > maxx) maxx = tx;
|
||||||
}
|
}
|
||||||
if (maxx >= minx && maxy >= miny) {
|
if (maxx >= minx && maxy >= miny) {
|
||||||
int w = maxx - minx + 1, h = maxy - miny + 1;
|
int y, w = maxx - minx + 1, h = maxy - miny + 1;
|
||||||
fputs("{ \"orientation\":\"hexagonal\",\"staggeraxis\":\"y\",", F);
|
fputs("{ \"orientation\":\"hexagonal\",\"staggeraxis\":\"y\",", F);
|
||||||
fprintf(F, "\"staggerindex\":\"%s\", \"height\":%d, \"width\":%d, \"layers\":[", (miny & 1) ? "odd" : "even", h, w);
|
fprintf(F, "\"staggerindex\":\"%s\", \"height\":%d, \"width\":%d, \"layers\":[", (miny & 1) ? "odd" : "even", h, w);
|
||||||
fprintf(F, "{ \"height\":%d, \"width\":%d, ", h, w);
|
fprintf(F, "{ \"height\":%d, \"width\":%d, ", h, w);
|
||||||
fputs("\"visible\":true, \"opacity\":1, \"type\":\"tilelayer\", \"name\":\"terrain\", \"x\":0, \"y\":0, \"data\":[", F);
|
fputs("\"visible\":true, \"opacity\":1, \"type\":\"tilelayer\", \"name\":\"terrain\", \"x\":0, \"y\":0, \"data\":[", F);
|
||||||
for (y = miny; y <= maxy; ++y) {
|
for (y = miny; y <= maxy; ++y) {
|
||||||
|
int x;
|
||||||
for (x = minx; x <= maxx; ++x) {
|
for (x = minx; x <= maxx; ++x) {
|
||||||
int data = 0;
|
int data = 0;
|
||||||
int tx = x, ty = y;
|
int tx = x, ty = y;
|
||||||
|
|
|
@ -233,7 +233,6 @@ alliedfaction(const struct plane *pl, const struct faction *f,
|
||||||
/* Die Gruppe von Einheit u hat helfe zu f2 gesetzt. */
|
/* Die Gruppe von Einheit u hat helfe zu f2 gesetzt. */
|
||||||
int alliedunit(const unit * u, const faction * f2, int mode)
|
int alliedunit(const unit * u, const faction * f2, int mode)
|
||||||
{
|
{
|
||||||
ally *sf;
|
|
||||||
int automode;
|
int automode;
|
||||||
|
|
||||||
assert(u);
|
assert(u);
|
||||||
|
@ -242,6 +241,7 @@ int alliedunit(const unit * u, const faction * f2, int mode)
|
||||||
if (u->faction == f2)
|
if (u->faction == f2)
|
||||||
return mode;
|
return mode;
|
||||||
if (u->faction != NULL && f2 != NULL) {
|
if (u->faction != NULL && f2 != NULL) {
|
||||||
|
ally *sf;
|
||||||
plane *pl;
|
plane *pl;
|
||||||
|
|
||||||
if (mode & HELP_FIGHT) {
|
if (mode & HELP_FIGHT) {
|
||||||
|
|
|
@ -350,7 +350,7 @@ building *new_building(const struct building_type * btype, region * r,
|
||||||
{
|
{
|
||||||
building **bptr = &r->buildings;
|
building **bptr = &r->buildings;
|
||||||
building *b = (building *)calloc(1, sizeof(building));
|
building *b = (building *)calloc(1, sizeof(building));
|
||||||
const char *bname = 0;
|
const char *bname;
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
|
|
||||||
b->no = newcontainerid();
|
b->no = newcontainerid();
|
||||||
|
@ -363,15 +363,13 @@ building *new_building(const struct building_type * btype, region * r,
|
||||||
*bptr = b;
|
*bptr = b;
|
||||||
|
|
||||||
update_lighthouse(b);
|
update_lighthouse(b);
|
||||||
if (!bname) {
|
|
||||||
bname = LOC(lang, btype->_name);
|
bname = LOC(lang, btype->_name);
|
||||||
}
|
|
||||||
if (!bname) {
|
if (!bname) {
|
||||||
bname = LOC(lang, parameters[P_GEBAEUDE]);
|
bname = LOC(lang, parameters[P_GEBAEUDE]);
|
||||||
}
|
|
||||||
if (!bname) {
|
if (!bname) {
|
||||||
bname = parameters[P_GEBAEUDE];
|
bname = parameters[P_GEBAEUDE];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
assert(bname);
|
assert(bname);
|
||||||
snprintf(buffer, sizeof(buffer), "%s %s", bname, itoa36(b->no));
|
snprintf(buffer, sizeof(buffer), "%s %s", bname, itoa36(b->no));
|
||||||
b->name = str_strdup(bname);
|
b->name = str_strdup(bname);
|
||||||
|
|
|
@ -156,9 +156,10 @@ connection *get_borders(const region * r1, const region * r2)
|
||||||
|
|
||||||
connection *new_border(border_type * type, region * from, region * to)
|
connection *new_border(border_type * type, region * from, region * to)
|
||||||
{
|
{
|
||||||
connection *b, **bp = get_borders_i(from, to);
|
connection *b, **bp;
|
||||||
|
|
||||||
assert(from && to);
|
assert(from && to);
|
||||||
|
bp = get_borders_i(from, to);
|
||||||
while (*bp) {
|
while (*bp) {
|
||||||
bp = &(*bp)->next;
|
bp = &(*bp)->next;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +243,7 @@ void b_read(connection * b, gamedata * data)
|
||||||
assert(!"invalid variant type in connection");
|
assert(!"invalid variant type in connection");
|
||||||
result = 0;
|
result = 0;
|
||||||
}
|
}
|
||||||
assert(result >= 0 || "EOF encountered?");
|
assert(result >= 0 || !"EOF encountered?");
|
||||||
}
|
}
|
||||||
|
|
||||||
void b_write(const connection * b, storage * store)
|
void b_write(const connection * b, storage * store)
|
||||||
|
@ -559,8 +560,7 @@ static bool b_validroad(const connection * b)
|
||||||
|
|
||||||
static bool b_rvisibleroad(const connection * b, const region * r)
|
static bool b_rvisibleroad(const connection * b, const region * r)
|
||||||
{
|
{
|
||||||
int x = b->data.i;
|
int x = (r == b->from) ? b->data.sa[0] : b->data.sa[1];
|
||||||
x = (r == b->from) ? b->data.sa[0] : b->data.sa[1];
|
|
||||||
if (x == 0) {
|
if (x == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -609,7 +609,6 @@ curse *create_curse(unit * magician, attrib ** ap, const curse_type * ct,
|
||||||
|
|
||||||
static void do_transfer_curse(curse * c, const unit * u, unit * u2, int n)
|
static void do_transfer_curse(curse * c, const unit * u, unit * u2, int n)
|
||||||
{
|
{
|
||||||
int cursedmen = 0;
|
|
||||||
int men = get_cursedmen(u, c);
|
int men = get_cursedmen(u, c);
|
||||||
bool dogive = false;
|
bool dogive = false;
|
||||||
const curse_type *ct = c->type;
|
const curse_type *ct = c->type;
|
||||||
|
@ -622,6 +621,7 @@ static void do_transfer_curse(curse * c, const unit * u, unit * u2, int n)
|
||||||
|
|
||||||
case CURSE_SPREADMODULO:
|
case CURSE_SPREADMODULO:
|
||||||
{
|
{
|
||||||
|
int cursedmen = 0;
|
||||||
int i;
|
int i;
|
||||||
int u_number = u->number;
|
int u_number = u->number;
|
||||||
for (i = 0; i < n + 1 && u_number > 0; i++) {
|
for (i = 0; i < n + 1 && u_number > 0; i++) {
|
||||||
|
|
|
@ -60,8 +60,8 @@ static void test_get_equipment(CuTest * tc)
|
||||||
eq = get_equipment("catapult");
|
eq = get_equipment("catapult");
|
||||||
CuAssertPtrEquals(tc, NULL, eq);
|
CuAssertPtrEquals(tc, NULL, eq);
|
||||||
eq = create_equipment("catapult");
|
eq = create_equipment("catapult");
|
||||||
eq = get_equipment("catapult");
|
|
||||||
CuAssertPtrNotNull(tc, eq);
|
CuAssertPtrNotNull(tc, eq);
|
||||||
|
CuAssertPtrEquals(tc, eq, get_equipment("catapult"));
|
||||||
CuAssertStrEquals(tc, "catapult", equipment_name(eq));
|
CuAssertStrEquals(tc, "catapult", equipment_name(eq));
|
||||||
eq = get_equipment("catapultammo123");
|
eq = get_equipment("catapultammo123");
|
||||||
CuAssertPtrNotNull(tc, eq);
|
CuAssertPtrNotNull(tc, eq);
|
||||||
|
|
|
@ -874,17 +874,6 @@ int writepasswd(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_factions(void) {
|
void free_factions(void) {
|
||||||
#ifdef DMAXHASH
|
|
||||||
int i;
|
|
||||||
for (i = 0; i != DMAXHASH; ++i) {
|
|
||||||
while (deadhash[i]) {
|
|
||||||
dead *d = deadhash[i];
|
|
||||||
deadhash[i] = d->nexthash;
|
|
||||||
free(d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
free_flist(&factions);
|
free_flist(&factions);
|
||||||
free_flist(&dead_factions);
|
free_flist(&dead_factions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ static void test_set_email(CuTest *tc) {
|
||||||
|
|
||||||
sprintf(email, "enno");
|
sprintf(email, "enno");
|
||||||
faction_setemail(f, email);
|
faction_setemail(f, email);
|
||||||
email[0] = 0;
|
CuAssertTrue(tc, email != f->email);
|
||||||
CuAssertStrEquals(tc, "enno", f->email);
|
CuAssertStrEquals(tc, "enno", f->email);
|
||||||
CuAssertStrEquals(tc, "enno", faction_getemail(f));
|
CuAssertStrEquals(tc, "enno", faction_getemail(f));
|
||||||
faction_setemail(f, "bugs@eressea.de");
|
faction_setemail(f, "bugs@eressea.de");
|
||||||
|
|
|
@ -53,7 +53,7 @@ static void test_group_readwrite_dead_faction(CuTest *tc) {
|
||||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||||
write_game(&data);
|
write_game(&data);
|
||||||
free_gamedata();
|
free_gamedata();
|
||||||
f = f2 = NULL;
|
f = NULL;
|
||||||
data.strm.api->rewind(data.strm.handle);
|
data.strm.api->rewind(data.strm.handle);
|
||||||
read_game(&data);
|
read_game(&data);
|
||||||
mstream_done(&data.strm);
|
mstream_done(&data.strm);
|
||||||
|
|
|
@ -358,42 +358,6 @@ int gift_items(unit * u, int flags)
|
||||||
|
|
||||||
static unit *deleted_units = NULL;
|
static unit *deleted_units = NULL;
|
||||||
|
|
||||||
#define DMAXHASH 7919
|
|
||||||
#undef DMAXHASH /* TODO: makes dfindhash slow! */
|
|
||||||
#ifdef DMAXHASH
|
|
||||||
typedef struct dead {
|
|
||||||
struct dead *nexthash;
|
|
||||||
faction *f;
|
|
||||||
int no;
|
|
||||||
} dead;
|
|
||||||
|
|
||||||
static dead *deadhash[DMAXHASH];
|
|
||||||
|
|
||||||
static void dhash(int no, faction * f)
|
|
||||||
{
|
|
||||||
dead *hash = (dead *)calloc(1, sizeof(dead));
|
|
||||||
dead *old = deadhash[no % DMAXHASH];
|
|
||||||
hash->no = no;
|
|
||||||
hash->f = f;
|
|
||||||
deadhash[no % DMAXHASH] = hash;
|
|
||||||
hash->nexthash = old;
|
|
||||||
}
|
|
||||||
|
|
||||||
faction *dfindhash(int no)
|
|
||||||
{
|
|
||||||
dead *old;
|
|
||||||
|
|
||||||
if (no < 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (old = deadhash[no % DMAXHASH]; old; old = old->nexthash) {
|
|
||||||
if (old->no == no) {
|
|
||||||
return old->f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
struct faction *dfindhash(int no) {
|
struct faction *dfindhash(int no) {
|
||||||
unit *u;
|
unit *u;
|
||||||
|
|
||||||
|
@ -404,7 +368,6 @@ struct faction *dfindhash(int no) {
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int remove_unit(unit ** ulist, unit * u)
|
int remove_unit(unit ** ulist, unit * u)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue