From 3e48b9b9669caef30402d84b002f89aa7efaba66 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 8 Jun 2015 16:51:41 +0200 Subject: [PATCH 01/17] libxml 1.9.x seems to be a bit pickier about how XML catalogs are written. --- conf/e2/catalog.xml | 6 ++-- conf/e2/config.xml | 64 +++++++++++++++++++++---------------------- conf/e3/catalog.xml | 6 ++-- conf/e3/config.xml | 60 ++++++++++++++++++++-------------------- conf/e4/catalog.xml | 6 ++-- conf/e4/config.xml | 60 ++++++++++++++++++++-------------------- res/armor.xml | 14 +++++----- res/e3a/buildings.xml | 2 +- res/e3a/races.xml | 8 +++--- res/e3a/resources.xml | 14 +++++----- res/e3a/weapons.xml | 44 ++++++++++++++--------------- res/weapons.xml | 42 ++++++++++++++-------------- 12 files changed, 163 insertions(+), 163 deletions(-) diff --git a/conf/e2/catalog.xml b/conf/e2/catalog.xml index a66bf0428..d0c7333aa 100644 --- a/conf/e2/catalog.xml +++ b/conf/e2/catalog.xml @@ -5,12 +5,12 @@ diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 914fd2796..6cb50a1be 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -1,36 +1,36 @@ - + - - - + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - + + + + + @@ -43,11 +43,11 @@ - - - - - + + + + + diff --git a/conf/e3/catalog.xml b/conf/e3/catalog.xml index beb8b55c9..9987e72c8 100644 --- a/conf/e3/catalog.xml +++ b/conf/e3/catalog.xml @@ -5,12 +5,12 @@ diff --git a/conf/e3/config.xml b/conf/e3/config.xml index dac778015..89eccdea9 100644 --- a/conf/e3/config.xml +++ b/conf/e3/config.xml @@ -1,32 +1,32 @@ - - - - - - - - - + + + + + + + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -39,11 +39,11 @@ - - - - - + + + + + diff --git a/conf/e4/catalog.xml b/conf/e4/catalog.xml index beb8b55c9..9987e72c8 100644 --- a/conf/e4/catalog.xml +++ b/conf/e4/catalog.xml @@ -5,12 +5,12 @@ diff --git a/conf/e4/config.xml b/conf/e4/config.xml index 641bfb25b..197dc4b69 100644 --- a/conf/e4/config.xml +++ b/conf/e4/config.xml @@ -1,32 +1,32 @@ - - - - - - - - - + + + + + + + + + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -39,11 +39,11 @@ - - - - - + + + + + diff --git a/res/armor.xml b/res/armor.xml index f24ddcd35..f26848da2 100644 --- a/res/armor.xml +++ b/res/armor.xml @@ -2,12 +2,12 @@ - - - - - - - + + + + + + + diff --git a/res/e3a/buildings.xml b/res/e3a/buildings.xml index 227a2e47a..d95f5ce86 100644 --- a/res/e3a/buildings.xml +++ b/res/e3a/buildings.xml @@ -1,7 +1,7 @@ - + diff --git a/res/e3a/races.xml b/res/e3a/races.xml index d5e3831c4..46427ba92 100644 --- a/res/e3a/races.xml +++ b/res/e3a/races.xml @@ -3,10 +3,10 @@ - - - - + + + + diff --git a/res/e3a/resources.xml b/res/e3a/resources.xml index 4ab29a5b6..32a79d52e 100644 --- a/res/e3a/resources.xml +++ b/res/e3a/resources.xml @@ -2,13 +2,13 @@ - - - - - - - + + + + + + + diff --git a/res/e3a/weapons.xml b/res/e3a/weapons.xml index 91748d64e..052266a02 100644 --- a/res/e3a/weapons.xml +++ b/res/e3a/weapons.xml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/weapons.xml b/res/weapons.xml index 0cab11ad0..d0b508012 100644 --- a/res/weapons.xml +++ b/res/weapons.xml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + From 2967cd59cf00ce236bb658e090525f3e527df746 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 8 Jun 2015 20:53:40 +0200 Subject: [PATCH 02/17] replace pushnumber with pushinteger where applicable (prep for Lua 5.3). also kill an unreferenced string. --- res/core/de/strings.xml | 5 ----- src/bind_building.c | 4 ++-- src/bind_faction.c | 28 ++++++++++++++-------------- src/bind_gmtool.c | 6 +++--- src/bind_message.c | 18 +++++++++--------- src/bind_monsters.c | 2 +- src/bind_region.c | 18 +++++++++--------- src/bind_ship.c | 6 +++--- src/bind_sqlite.c | 2 +- src/bind_storage.c | 4 ++-- src/bind_unit.c | 2 +- src/bindings.c | 26 +++++++++++++------------- src/helpers.c | 16 ++++++++-------- 13 files changed, 66 insertions(+), 71 deletions(-) diff --git a/res/core/de/strings.xml b/res/core/de/strings.xml index 51a24c4d4..351a7e376 100644 --- a/res/core/de/strings.xml +++ b/res/core/de/strings.xml @@ -275,11 +275,6 @@ - - Tresen - counter - - wenige few diff --git a/src/bind_building.c b/src/bind_building.c index 8b89d2618..f52789700 100644 --- a/src/bind_building.c +++ b/src/bind_building.c @@ -114,7 +114,7 @@ static int tolua_building_set_name(lua_State * L) static int tolua_building_get_size(lua_State * L) { building *self = (building *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, self->size); + lua_pushinteger(L, self->size); return 1; } @@ -145,7 +145,7 @@ static int tolua_building_get_units(lua_State * L) static int tolua_building_get_id(lua_State * L) { building *self = (building *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->no); + lua_pushinteger(L, self->no); return 1; } diff --git a/src/bind_faction.c b/src/bind_faction.c index 1846ea957..23b450618 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -84,28 +84,28 @@ int tolua_faction_add_item(lua_State * L) static int tolua_faction_get_maxheroes(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)maxheroes(self)); + lua_pushinteger(L, maxheroes(self)); return 1; } static int tolua_faction_get_heroes(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)countheroes(self)); + lua_pushinteger(L, countheroes(self)); return 1; } static int tolua_faction_get_score(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->score); + lua_pushinteger(L, self->score); return 1; } static int tolua_faction_get_id(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->no); + lua_pushinteger(L, self->no); return 1; } @@ -148,7 +148,7 @@ static int tolua_faction_set_magic(lua_State * L) static int tolua_faction_get_age(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->age); + lua_pushinteger(L, self->age); return 1; } @@ -163,7 +163,7 @@ static int tolua_faction_set_age(lua_State * L) static int tolua_faction_get_flags(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->flags); + lua_pushinteger(L, self->flags); return 1; } @@ -178,7 +178,7 @@ static int tolua_faction_set_flags(lua_State * L) static int tolua_faction_get_options(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->options); + lua_pushinteger(L, self->options); return 1; } @@ -193,7 +193,7 @@ static int tolua_faction_set_options(lua_State * L) static int tolua_faction_get_lastturn(lua_State * L) { faction *self = (faction *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->lastorders); + lua_pushinteger(L, self->lastorders); return 1; } @@ -245,7 +245,7 @@ static int tolua_faction_get_policy(lua_State * L) } } - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -283,8 +283,8 @@ static int tolua_faction_normalize(lua_State * L) int nx = r->x, ny = r->y; pnormalize(&nx, &ny, pl); adjust_coordinates(f, &nx, &ny, pl); - tolua_pushnumber(L, (lua_Number)nx); - tolua_pushnumber(L, (lua_Number)ny); + lua_pushinteger(L, nx); + lua_pushinteger(L, ny); return 2; } return 0; @@ -319,8 +319,8 @@ static int tolua_faction_get_origin(lua_State * L) y = 0; } - tolua_pushnumber(L, (lua_Number)x); - tolua_pushnumber(L, (lua_Number)y); + lua_pushinteger(L, x); + lua_pushinteger(L, y); return 2; } @@ -443,7 +443,7 @@ static int tolua_faction_set_name(lua_State * L) static int tolua_faction_get_uid(lua_State * L) { faction *f = (faction *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, f->subscription); + lua_pushinteger(L, f->subscription); return 1; } diff --git a/src/bind_gmtool.c b/src/bind_gmtool.c index ec2535e16..3c07bb3b7 100644 --- a/src/bind_gmtool.c +++ b/src/bind_gmtool.c @@ -153,7 +153,7 @@ static int tolua_make_island(lua_State * L) int n = (int)tolua_tonumber(L, 4, s / 3); n = build_island_e3(NULL, x, y, n, s); - tolua_pushnumber(L, n); + lua_pushinteger(L, n); return 1; } @@ -166,8 +166,8 @@ static void lua_paint_info(struct window *wnd, const struct state *st) int nx = st->cursor.x, ny = st->cursor.y; pnormalize(&nx, &ny, st->cursor.pl); lua_rawgeti(L, LUA_REGISTRYINDEX, paint_handle); - tolua_pushnumber(L, nx); - tolua_pushnumber(L, ny); + lua_pushinteger(L, nx); + lua_pushinteger(L, ny); if (lua_pcall(L, 2, 1, 0) != 0) { const char *error = lua_tostring(L, -1); log_error("paint function failed: %s\n", error); diff --git a/src/bind_message.c b/src/bind_message.c index 75ff5821b..bbbd2bc0b 100644 --- a/src/bind_message.c +++ b/src/bind_message.c @@ -214,7 +214,7 @@ static int tolua_msg_set_string(lua_State * L) const char *param = tolua_tostring(L, 2, 0); const char *value = tolua_tostring(L, 3, 0); int result = msg_set_string(lmsg, param, value); - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -224,7 +224,7 @@ static int tolua_msg_set_int(lua_State * L) const char *param = tolua_tostring(L, 2, 0); int value = (int)tolua_tonumber(L, 3, 0); int result = msg_set_int(lmsg, param, value); - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -234,7 +234,7 @@ static int tolua_msg_set_resource(lua_State * L) const char *param = tolua_tostring(L, 2, 0); const char *value = tolua_tostring(L, 3, 0); int result = msg_set_resource(lmsg, param, value); - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -244,7 +244,7 @@ static int tolua_msg_set_unit(lua_State * L) const char *param = tolua_tostring(L, 2, 0); unit *value = (unit *)tolua_tousertype(L, 3, 0); int result = msg_set_unit(lmsg, param, value); - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -254,7 +254,7 @@ static int tolua_msg_set_region(lua_State * L) const char *param = tolua_tostring(L, 2, 0); region *value = (region *)tolua_tousertype(L, 3, 0); int result = msg_set_region(lmsg, param, value); - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -270,7 +270,7 @@ static int tolua_msg_set(lua_State * L) else if (tolua_isusertype(L, 3, TOLUA_CAST "unit", 0, &err)) { return tolua_msg_set_unit(L); } - tolua_pushnumber(L, (lua_Number)-1); + lua_pushinteger(L, -1); return 1; } @@ -279,7 +279,7 @@ static int tolua_msg_send_region(lua_State * L) lua_message *lmsg = (lua_message *)tolua_tousertype(L, 1, 0); region *r = (region *)tolua_tousertype(L, 2, 0); int result = msg_send_region(lmsg, r); - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -293,7 +293,7 @@ static int tolua_msg_report_action(lua_State * L) lmsg->msg = msg_create(lmsg->mtype, lmsg->args); } result = report_action(r, u, lmsg->msg, flags); - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -303,7 +303,7 @@ static int tolua_msg_send_faction(lua_State * L) faction *f = (faction *)tolua_tousertype(L, 2, 0); if (f && lmsg) { int result = msg_send_faction(lmsg, f); - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } return 0; diff --git a/src/bind_monsters.c b/src/bind_monsters.c index 8897da0d1..a106ec638 100644 --- a/src/bind_monsters.c +++ b/src/bind_monsters.c @@ -21,7 +21,7 @@ static int tolua_levitate_ship(lua_State * L) float power = (float)tolua_tonumber(L, 3, 0); int duration = (int)tolua_tonumber(L, 4, 0); int cno = levitate_ship(sh, mage, power, duration); - tolua_pushnumber(L, (lua_Number)cno); + lua_pushinteger(L, cno); return 1; } diff --git a/src/bind_region.c b/src/bind_region.c index 792f15ac0..1b0157718 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -62,7 +62,7 @@ int tolua_regionlist_next(lua_State * L) static int tolua_region_get_id(lua_State * L) { region *self = (region *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->uid); + lua_pushinteger(L, self->uid); return 1; } @@ -85,14 +85,14 @@ static int tolua_region_set_blocked(lua_State * L) static int tolua_region_get_x(lua_State * L) { region *self = (region *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->x); + lua_pushinteger(L, self->x); return 1; } static int tolua_region_get_y(lua_State * L) { region *self = (region *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->y); + lua_pushinteger(L, self->y); return 1; } @@ -199,7 +199,7 @@ static int tolua_region_set_name(lua_State * L) static int tolua_region_get_morale(lua_State * L) { region *r = (region *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, region_get_morale(r)); + lua_pushinteger(L, region_get_morale(r)); return 1; } @@ -323,7 +323,7 @@ static int tolua_region_get_resourcelevel(lua_State * L) const rawmaterial *rm; for (rm = r->resources; rm; rm = rm->next) { if (rm->type->rtype == rtype) { - tolua_pushnumber(L, (lua_Number)rm->level); + lua_pushinteger(L, rm->level); return 1; } } @@ -389,7 +389,7 @@ static int tolua_region_get_resource(lua_State * L) } } - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -613,7 +613,7 @@ static int tolua_plane_set_name(lua_State * L) static int tolua_plane_get_id(lua_State * L) { plane *self = (plane *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->id); + lua_pushinteger(L, self->id); return 1; } @@ -623,8 +623,8 @@ static int tolua_plane_normalize(lua_State * L) int x = (int)tolua_tonumber(L, 2, 0); int y = (int)tolua_tonumber(L, 3, 0); pnormalize(&x, &y, self); - tolua_pushnumber(L, (lua_Number)x); - tolua_pushnumber(L, (lua_Number)y); + lua_pushinteger(L, x); + lua_pushinteger(L, y); return 2; } diff --git a/src/bind_ship.c b/src/bind_ship.c index 7dd1b02f6..595be35dd 100644 --- a/src/bind_ship.c +++ b/src/bind_ship.c @@ -45,7 +45,7 @@ int tolua_shiplist_next(lua_State * L) static int tolua_ship_get_id(lua_State * L) { ship *self = (ship *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->no); + lua_pushinteger(L, self->no); return 1; } @@ -152,7 +152,7 @@ tolua_ship_tostring(lua_State * L) static int tolua_ship_get_flags(lua_State * L) { ship *self = (ship *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->flags); + lua_pushinteger(L, self->flags); return 1; } @@ -179,7 +179,7 @@ static int tolua_ship_get_coast(lua_State * L) { ship *self = (ship *)tolua_tousertype(L, 1, 0); if (self->coast) { - tolua_pushnumber(L, self->coast); + lua_pushinteger(L, self->coast); return 1; } return 0; diff --git a/src/bind_sqlite.c b/src/bind_sqlite.c index e2c0e69e3..e8c9b7565 100644 --- a/src/bind_sqlite.c +++ b/src/bind_sqlite.c @@ -44,7 +44,7 @@ static int tolua_db_execute(lua_State * L) int res = sqlite3_exec(db, sql, 0, 0, 0); - tolua_pushnumber(L, (LUA_NUMBER)res); + lua_pushinteger(L, res); return 1; } diff --git a/src/bind_storage.c b/src/bind_storage.c index d0fea8244..acdf1e046 100644 --- a/src/bind_storage.c +++ b/src/bind_storage.c @@ -77,7 +77,7 @@ static int tolua_storage_read_float(lua_State * L) gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0); float num; READ_FLT(data->store, &num); - tolua_pushnumber(L, (lua_Number)num); + lua_pushnumber(L, num); return 1; } @@ -86,7 +86,7 @@ static int tolua_storage_read_int(lua_State * L) gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0); int num; READ_INT(data->store, &num); - tolua_pushnumber(L, (lua_Number)num); + lua_pushinteger(L, num); return 1; } diff --git a/src/bind_unit.c b/src/bind_unit.c index 4f262114c..200c53b9b 100755 --- a/src/bind_unit.c +++ b/src/bind_unit.c @@ -160,7 +160,7 @@ static int tolua_unit_set_group(lua_State * L) { unit *self = (unit *)tolua_tousertype(L, 1, 0); int result = join_group(self, tolua_tostring(L, 2, 0)); - tolua_pushnumber(L, result); + lua_pushinteger(L, result); return 1; } diff --git a/src/bindings.c b/src/bindings.c index 098499a23..849678f25 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -123,7 +123,7 @@ static int tolua_quicklist_iter(lua_State * L) void *data = ql_get(ql, index); tolua_pushusertype(L, data, TOLUA_CAST type); ql_advance(qlp, &index, 1); - tolua_pushnumber(L, index); + lua_pushinteger(L, index); lua_replace(L, lua_upvalueindex(2)); return 1; } @@ -282,14 +282,14 @@ static int tolua_set_turn(lua_State * L) static int tolua_get_turn(lua_State * L) { - tolua_pushnumber(L, (lua_Number)turn); + lua_pushinteger(L, turn); return 1; } static int tolua_atoi36(lua_State * L) { const char *s = tolua_tostring(L, 1, 0); - tolua_pushnumber(L, (lua_Number)atoi36(s)); + lua_pushinteger(L, atoi36(s)); return 1; } @@ -303,7 +303,7 @@ static int tolua_itoa36(lua_State * L) static int tolua_dice_rand(lua_State * L) { const char *s = tolua_tostring(L, 1, 0); - tolua_pushnumber(L, dice_rand(s)); + lua_pushinteger(L, dice_rand(s)); return 1; } @@ -320,7 +320,7 @@ static int tolua_addequipment(lua_State * L) result = 0; } } - lua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -426,7 +426,7 @@ static int tolua_get_nmrs(lua_State * L) } result = nmrs[n]; } - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -451,7 +451,7 @@ static int tolua_equipment_setitem(lua_State * L) result = 0; } } - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -465,7 +465,7 @@ static int tolua_spawn_braineaters(lua_State * L) static int tolua_init_reports(lua_State * L) { int result = init_reports(); - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -475,7 +475,7 @@ static int tolua_write_report(lua_State * L) if (f) { time_t ltime = time(0); int result = write_reports(f, ltime); - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); } else { tolua_pushstring(L, "function expects a faction, got nil"); @@ -488,7 +488,7 @@ static int tolua_write_reports(lua_State * L) int result; init_reports(); result = reports(); - tolua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -568,7 +568,7 @@ static int tolua_write_map(lua_State * L) static int tolua_read_turn(lua_State * L) { int cturn = current_turn(); - tolua_pushnumber(L, (lua_Number)cturn); + lua_pushinteger(L, cturn); return 1; } @@ -661,7 +661,7 @@ static int tolua_get_alliance_factions(lua_State * L) static int tolua_get_alliance_id(lua_State * L) { alliance *self = (alliance *)tolua_tousertype(L, 1, 0); - tolua_pushnumber(L, (lua_Number)self->id); + lua_pushinteger(L, self->id); return 1; } @@ -1069,7 +1069,7 @@ static void parse_inifile(lua_State * L, dictionary * d, const char *section) tolua_pushstring(L, str_value); } else { - tolua_pushnumber(L, num_value); + lua_pushnumber(L, num_value); } lua_rawset(L, -3); } diff --git a/src/helpers.c b/src/helpers.c index 4690023e9..29038afb3 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -58,7 +58,7 @@ lua_giveitem(unit * s, unit * d, const item_type * itype, int n, struct order *o tolua_pushusertype(L, s, TOLUA_CAST "unit"); tolua_pushusertype(L, d, TOLUA_CAST "unit"); tolua_pushstring(L, iname); - tolua_pushnumber(L, (lua_Number)n); + lua_pushinteger(L, n); if (lua_pcall(L, 4, 1, 0) != 0) { const char *error = lua_tostring(L, -1); @@ -121,7 +121,7 @@ produce_resource(region * r, const resource_type * rtype, int norders) lua_getglobal(L, fname); if (lua_isfunction(L, -1)) { tolua_pushusertype(L, (void *)r, TOLUA_CAST "region"); - tolua_pushnumber(L, (lua_Number)norders); + lua_pushinteger(L, norders); if (lua_pcall(L, 2, 0, 0) != 0) { const char *error = lua_tostring(L, -1); @@ -177,8 +177,8 @@ static int lua_callspell(castorder * co) int nparam = 4; tolua_pushusertype(L, r, TOLUA_CAST "region"); tolua_pushusertype(L, caster, TOLUA_CAST "unit"); - tolua_pushnumber(L, (lua_Number)co->level); - tolua_pushnumber(L, (lua_Number)co->force); + lua_pushinteger(L, co->level); + lua_pushnumber(L, co->force); if (co->sp->parameter && co->par->length) { const char *synp = co->sp->parameter; int i = 0; @@ -267,7 +267,7 @@ lua_changeresource(unit * u, const struct resource_type *rtype, int delta) lua_getglobal(L, fname); if (lua_isfunction(L, -1)) { tolua_pushusertype(L, u, TOLUA_CAST "unit"); - tolua_pushnumber(L, (lua_Number)delta); + lua_pushinteger(L, delta); if (lua_pcall(L, 2, 1, 0) != 0) { const char *error = lua_tostring(L, -1); @@ -363,7 +363,7 @@ lua_wage(const region * r, const faction * f, const race * rc, int in_turn) tolua_pushusertype(L, (void *)r, TOLUA_CAST "region"); tolua_pushusertype(L, (void *)f, TOLUA_CAST "faction"); tolua_pushstring(L, rc ? rc->_name : 0); - tolua_pushnumber(L, (lua_Number)in_turn); + lua_pushinteger(L, in_turn); if (lua_pcall(L, 3, 1, 0) != 0) { const char *error = lua_tostring(L, -1); @@ -416,7 +416,7 @@ static double lua_building_taxes(building * b, int level) lua_getglobal(L, fname); if (lua_isfunction(L, -1)) { tolua_pushusertype(L, (void *)b, TOLUA_CAST "building"); - tolua_pushnumber(L, level); + lua_pushinteger(L, level); if (lua_pcall(L, 2, 1, 0) != 0) { const char *error = lua_tostring(L, -1); @@ -508,7 +508,7 @@ struct order *ord) lua_getglobal(L, fname); if (lua_isfunction(L, -1)) { tolua_pushusertype(L, (void *)u, TOLUA_CAST "unit"); - tolua_pushnumber(L, (lua_Number)amount); + lua_pushinteger(L, amount); if (lua_pcall(L, 2, 1, 0) != 0) { const char *error = lua_tostring(L, -1); From 84f8a9f74618c7d85f77842c02ffdb413a5792d2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 8 Jun 2015 21:15:07 +0200 Subject: [PATCH 03/17] calculate simple default scores for items that do not have one defined in XML. --- src/kernel/xmlreader.c | 11 ++++++++--- src/modules/score.c | 17 +++++++++++++++++ src/modules/score.h | 7 +++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 7179238ab..b4b1da708 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -31,6 +31,10 @@ without prior permission by the authors of Eressea. #include "vortex.h" +#if SCORE_MODULE +#include +#endif + /* util includes */ #include #include @@ -766,9 +770,6 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) itype->weight = xml_ivalue(node, "weight", 0); itype->capacity = xml_ivalue(node, "capacity", 0); itype->flags |= flags; -#if SCORE_MODULE - itype->score = xml_ivalue(node, "score", 0); -#endif /* reading item/construction */ xpath->node = node; @@ -855,6 +856,10 @@ static item_type *xml_readitem(xmlXPathContextPtr xpath, resource_type * rtype) } xmlFree(propValue); } +#if SCORE_MODULE + itype->score = xml_ivalue(node, "score", 0); + if (!itype->score) itype->score = default_score(itype); +#endif xmlXPathFreeObject(result); return itype; diff --git a/src/modules/score.c b/src/modules/score.c index bf3e472e1..26788199c 100644 --- a/src/modules/score.c +++ b/src/modules/score.c @@ -24,6 +24,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* kernel includes */ #include #include +#include #include #include #include @@ -214,4 +215,20 @@ void score(void) } } +int default_score(const item_type *itype) { + int result = 0; + if (itype->construction) { + requirement *req = itype->construction->materials; + while (req->number) { + int score = req->rtype->itype ? req->rtype->itype->score : 10; + result += score * req->number * 2; + ++req; + } + } + else { + result = 10; + } + return result; +} + #endif diff --git a/src/modules/score.h b/src/modules/score.h index 0cbe6b749..7ffdf64e5 100644 --- a/src/modules/score.h +++ b/src/modules/score.h @@ -26,8 +26,11 @@ extern "C" { #error "must define SCORE_MODULE to use this module" #endif - extern void score(void); - extern int average_score_of_age(int age, int a); + struct item_type; + + void score(void); + int average_score_of_age(int age, int a); + int default_score(const struct item_type *itype); #ifdef __cplusplus } From 4e33e59d646647ab6ac87b4442ad70f27c271ab8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 8 Jun 2015 21:19:17 +0200 Subject: [PATCH 04/17] more lua_pushinteger conversion for lua 5.3 --- src/bind_dict.c | 2 +- src/bind_faction.c | 2 +- src/bind_region.c | 8 ++++---- src/bindings.c | 10 +++++----- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/bind_dict.c b/src/bind_dict.c index 28bcc5d81..32d3c498d 100644 --- a/src/bind_dict.c +++ b/src/bind_dict.c @@ -47,7 +47,7 @@ static int tolua_dict_get(lua_State * L) lua_pushnil(L); break; case TINTEGER: - lua_pushnumber(L, (lua_Number)val.i); + lua_pushinteger(L, val.i); break; case TREAL: lua_pushnumber(L, (lua_Number)val.f); diff --git a/src/bind_faction.c b/src/bind_faction.c index 23b450618..585cdcf35 100644 --- a/src/bind_faction.c +++ b/src/bind_faction.c @@ -77,7 +77,7 @@ int tolua_faction_add_item(lua_State * L) result = i ? i->number : 0; } /* if (itype!=NULL) */ } - lua_pushnumber(L, result); + lua_pushinteger(L, result); return 1; } diff --git a/src/bind_region.c b/src/bind_region.c index 1b0157718..f726bc8a6 100644 --- a/src/bind_region.c +++ b/src/bind_region.c @@ -524,7 +524,7 @@ static int tolua_region_get_age(lua_State * L) region *self = (region *)tolua_tousertype(L, 1, 0); if (self) { - lua_pushnumber(L, self->age); + lua_pushinteger(L, self->age); return 1; } return 0; @@ -638,8 +638,8 @@ static int tolua_plane_tostring(lua_State * L) static int tolua_plane_get_size(lua_State * L) { plane *pl = (plane *)tolua_tousertype(L, 1, 0); - lua_pushnumber(L, plane_width(pl)); - lua_pushnumber(L, plane_height(pl)); + lua_pushinteger(L, plane_width(pl)); + lua_pushinteger(L, plane_height(pl)); return 2; } @@ -657,7 +657,7 @@ static int tolua_distance(lua_State * L) pnormalize(&x1, &y1, pl); pnormalize(&x2, &y2, pl); result = koor_distance(x1, y1, x2, y2); - lua_pushnumber(L, result); + lua_pushinteger(L, result); return 1; } diff --git a/src/bindings.c b/src/bindings.c index 849678f25..6e61dc186 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -139,7 +139,7 @@ int tolua_quicklist_push(struct lua_State *L, const char *list_type, *qlist_ptr = list; luaL_getmetatable(L, list_type); lua_setmetatable(L, -2); - lua_pushnumber(L, 0); + lua_pushinteger(L, 0); lua_pushstring(L, elem_type); lua_pushcclosure(L, tolua_quicklist_iter, 3); /* OBS: this closure has multiple upvalues (list, index, type_name) */ } @@ -219,7 +219,7 @@ static int tolua_setkey(lua_State * L) static int tolua_rng_int(lua_State * L) { - lua_pushnumber(L, (lua_Number)rng_int()); + lua_pushinteger(L, rng_int()); return 1; } @@ -227,7 +227,7 @@ static int tolua_read_orders(lua_State * L) { const char *filename = tolua_tostring(L, 1, 0); int result = readorders(filename); - lua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 1; } @@ -534,7 +534,7 @@ static int tolua_process_orders(lua_State * L) static int tolua_write_passwords(lua_State * L) { int result = writepasswd(); - lua_pushnumber(L, (lua_Number)result); + lua_pushinteger(L, result); return 0; } @@ -982,7 +982,7 @@ static int tolua_get_spell_school(lua_State * L) static int tolua_get_spell_level(lua_State * L) { spell *self = (spell *) tolua_tousertype(L, 1, 0); - lua_pushnumber(L, self->level); + lua_pushinteger(L, self->level); return 1; } #endif From 8ecf51b057d3ed5eabeb740f9fa3df090367e06f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 8 Jun 2015 22:23:07 +0200 Subject: [PATCH 05/17] cmake will use LD_LUA and LD_TOLUA environment variables to search --- CMakeLists.txt | 12 +++++------- cmake | 2 +- s/cmake-init | 16 +++++++++++++++- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cfd54e3e..800851655 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,11 @@ project (eressea-server C) enable_testing() +find_package (LibXml2) +find_package (SQLite3) +find_package (Curses) +find_package (Lua REQUIRED) +find_package (ToLua REQUIRED) INCLUDE (CheckIncludeFiles) INCLUDE (CheckSymbolExists) @@ -57,13 +62,6 @@ CONFIGURE_FILE ( INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/include) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_AUTOCONF") - -find_package (LibXml2) -find_package (SQLite3) -find_package (Curses) -find_package (Lua REQUIRED) -find_package (ToLua REQUIRED) - add_subdirectory (cutest) add_subdirectory (crypto) add_subdirectory (cJSON) diff --git a/cmake b/cmake index cd779ba36..2e4a409c0 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit cd779ba36efb4045a040af170588a8dfe496d7b9 +Subproject commit 2e4a409c0b2b6b1150ea424289552a199b374c7a diff --git a/s/cmake-init b/s/cmake-init index 913aef82b..d283f97eb 100755 --- a/s/cmake-init +++ b/s/cmake-init @@ -10,6 +10,7 @@ done [ -z $BUILD ] && BUILD=Debug MACHINE=`uname -m` +[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang" [ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" [ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" [ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc" @@ -33,7 +34,20 @@ if [ -d $HOME/usr ]; then PREFIX_PATH=$HOME/usr:$HOME/usr/local:$PREFIX_PATH fi -cmake .. \ +if [ -z $PC_LUA ] && [ -e /opt/include/lua.h ]; then +PC_LUA=/opt/include +fi +if [ -z $PC_TOLUA ] && [ -e /opt/include/tolua.h ]; then +PC_TOLUA=/opt/include +fi +if [ ! -z $PC_TOLUA ]; then +PC_ARGS="$PC_ARGS -DPC_TOLUA_INCLUDEDIR=$PC_TOLUA/include -DPC_TOLUA_LIBDIR=$PC_TOLUA/lib" +fi +if [ ! -z $PC_LUA ]; then +PC_ARGS="$PC_ARGS -DPC_LUA_INCLUDEDIR=$PC_LUA/include -DPC_LUA_LIBDIR=$PC_LUA/lib" +fi + +cmake .. $PC_ARGS \ -DCMAKE_MODULE_PATH=$PWD/../cmake/Modules \ -DCMAKE_BUILD_TYPE=$BUILD \ -DCMAKE_LIBRARY_PATH=$LIBRARY_PATH \ From 8080adcd2b827fc86c8f399bb9b1d3fffd53a4f1 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Tue, 9 Jun 2015 08:36:45 +0200 Subject: [PATCH 06/17] travis build now runs a full turn for acceptance. * new cmake module (lus/tolua changes). * valgrind suppression for glibc strtod problems. --- cmake | 2 +- s/travis-build | 11 +++++++++-- tests/ubuntu-12_04.supp | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/cmake b/cmake index 2e4a409c0..ce0a1c882 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 2e4a409c0b2b6b1150ea424289552a199b374c7a +Subproject commit ce0a1c882fa44b882c29cc8c68012295328dc352 diff --git a/s/travis-build b/s/travis-build index 4724d04b0..29efda196 100755 --- a/s/travis-build +++ b/s/travis-build @@ -23,18 +23,24 @@ make } test_valgrind_report () { -cd tests +cd $ROOT/tests ln -sf ../scripts/config.lua valgrind --suppressions=ubuntu-12_04.supp --error-exitcode=1 $BUILD/eressea/eressea -v0 -t184 ../scripts/reports.lua } +test_valgrind_turn () { +cd $ROOT/tests +ln -sf ../scripts/config.lua +valgrind --suppressions=ubuntu-12_04.supp --error-exitcode=1 $BUILD/eressea/eressea -v0 -t184 ../scripts/run-turn.lua +} + test_unittests() { $BUILD/eressea/test_eressea } cleanup() { cd $ROOT/tests -rm -rf reports score eressea.log* config.lua +rm -rf reports score eressea.log* config.lua data/185.dat datum passwd parteien parteien.full turn } test_server() { @@ -59,5 +65,6 @@ build test_unittests test_server test_valgrind_report +test_valgrind_turn cleanup diff --git a/tests/ubuntu-12_04.supp b/tests/ubuntu-12_04.supp index 29862fa2b..3d6ae2974 100644 --- a/tests/ubuntu-12_04.supp +++ b/tests/ubuntu-12_04.supp @@ -1,3 +1,4 @@ +# old zlib version { zlib1g-dev-1:1.2.3.4.dfsg Memcheck:Cond @@ -14,3 +15,23 @@ fun:read_xml fun:init_data } + +# https://sourceware.org/bugzilla/show_bug.cgi?id=14404 +{ + glibc-bug-14404-1 + Memcheck:Addr8 + fun:__GI___strncasecmp_l + fun:____strtod_l_internal +} +{ + glibc-bug-14404-2 + Memcheck:Cond + fun:__GI___strncasecmp_l + fun:____strtod_l_internal +} +{ + glibc-bug-14404-3 + Memcheck:Value8 + fun:__GI___strncasecmp_l + fun:____strtod_l_internal +} From 272653f8baea43c0a53ff8c12ab4699669c2961d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 12 Jun 2015 18:05:56 +0200 Subject: [PATCH 07/17] fixing sea serpents with empty names, again. https://bugs.eressea.de/view.php?id=2057 --- src/kernel/save.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/kernel/save.c b/src/kernel/save.c index 25169d4af..fdfe9aad9 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -618,13 +618,13 @@ unit *read_unit(struct gamedata *data) } READ_STR(data->store, obuf, sizeof(obuf)); - u->_name = _strdup(obuf); + u->_name = obuf[0] ? _strdup(obuf) : 0; if (lomem) { READ_STR(data->store, NULL, 0); } else { READ_STR(data->store, obuf, sizeof(obuf)); - u->display = _strdup(obuf); + u->display = obuf[0] ? _strdup(obuf) : 0; } READ_INT(data->store, &number); set_number(u, number); From ff3fdb62cd39a692dc3394ae580dd1202274db44 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 17 Jun 2015 07:29:22 +0200 Subject: [PATCH 08/17] enable valgrind suppressions for QA previews --- CMakeLists.txt | 2 +- s/preview | 3 ++- s/runtests | 1 + s/travis-build | 5 +++-- {tests => share}/ubuntu-12_04.supp | 0 5 files changed, 7 insertions(+), 4 deletions(-) rename {tests => share}/ubuntu-12_04.supp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 800851655..004248570 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,4 +73,4 @@ add_subdirectory (src eressea) install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.xml") install(DIRECTORY res conf DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.json") install(DIRECTORY scripts DESTINATION ${CMAKE_INSTALL_PREFIX} FILES_MATCHING PATTERN "*.lua") - +install(DIRECTORY share DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/s/preview b/s/preview index 12752738f..bb336a5f8 100755 --- a/s/preview +++ b/s/preview @@ -80,10 +80,11 @@ ln -f $LIVE/data/$turn.dat data/ rm -rf reports mkdir -p reports +SUPP="$SERVER/share/ubuntu-12_04.supp" SERVER="$SOURCE/build-x86_64-gcc-Debug/eressea/eressea" VALGRIND=$(which valgrind) if [ ! -z $VALGRIND ]; then -SERVER="$VALGRIND --leak-check=no $SERVER" +SERVER="$VALGRIND --suppressions=$SUPP --error-exitcode=1 --leak-check=no $SERVER" fi $SERVER -v$verbose -t$turn -re$game $SOURCE/scripts/run-turn.lua let turn=$turn+1 diff --git a/s/runtests b/s/runtests index eaf4ba8d8..df0777ca9 100755 --- a/s/runtests +++ b/s/runtests @@ -7,6 +7,7 @@ while [ ! -d $ROOT/.git ]; do done MACHINE=`uname -m` +[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang" [ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" [ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" [ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc" diff --git a/s/travis-build b/s/travis-build index 29efda196..b34340266 100755 --- a/s/travis-build +++ b/s/travis-build @@ -2,6 +2,7 @@ set -e ROOT=`pwd` +SUPP=../share/ubuntu-12_04.supp MACHINE=`uname -m` [ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" [ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" @@ -25,13 +26,13 @@ make test_valgrind_report () { cd $ROOT/tests ln -sf ../scripts/config.lua -valgrind --suppressions=ubuntu-12_04.supp --error-exitcode=1 $BUILD/eressea/eressea -v0 -t184 ../scripts/reports.lua +valgrind --suppressions=$SUPP --error-exitcode=1 $BUILD/eressea/eressea -v0 -t184 ../scripts/reports.lua } test_valgrind_turn () { cd $ROOT/tests ln -sf ../scripts/config.lua -valgrind --suppressions=ubuntu-12_04.supp --error-exitcode=1 $BUILD/eressea/eressea -v0 -t184 ../scripts/run-turn.lua +valgrind --suppressions=$SUPP --error-exitcode=1 $BUILD/eressea/eressea -v0 -t184 ../scripts/run-turn.lua } test_unittests() { diff --git a/tests/ubuntu-12_04.supp b/share/ubuntu-12_04.supp similarity index 100% rename from tests/ubuntu-12_04.supp rename to share/ubuntu-12_04.supp From 32bd8c4353de4ff7afff57b0fa79cf5af7d81be3 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 17 Jun 2015 07:50:35 +0200 Subject: [PATCH 09/17] make preview script valgrind use suppression file, closing issue #154 --- s/build | 1 + s/preview | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/s/build b/s/build index 068a669a1..2f689a1f9 100755 --- a/s/build +++ b/s/build @@ -6,6 +6,7 @@ done [ -z $BUILD ] && BUILD=Debug MACHINE=`uname -m` +[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang" [ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" [ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" [ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc" diff --git a/s/preview b/s/preview index bb336a5f8..bafbae3ac 100755 --- a/s/preview +++ b/s/preview @@ -1,5 +1,12 @@ #!/bin/bash +MACHINE=`uname -m` +[ -z "$CC" ] && [ ! -z `which clang` ] && CC="clang" +[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc" +[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc" +[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc" +BUILD="build-$MACHINE-$CC-Debug" + function usage() { cat <] [-g ] [-f ] command [args] @@ -80,8 +87,8 @@ ln -f $LIVE/data/$turn.dat data/ rm -rf reports mkdir -p reports -SUPP="$SERVER/share/ubuntu-12_04.supp" -SERVER="$SOURCE/build-x86_64-gcc-Debug/eressea/eressea" +SUPP="$SOURCE/share/ubuntu-12_04.supp" +SERVER="$SOURCE/$BUILD/eressea/eressea" VALGRIND=$(which valgrind) if [ ! -z $VALGRIND ]; then SERVER="$VALGRIND --suppressions=$SUPP --error-exitcode=1 --leak-check=no $SERVER" @@ -148,7 +155,7 @@ case "$1" in ;; "run") if [ $turn -eq 0 ]; then - [ -f $LIVE/turn ] || abort "missing turn file, and no turn specified" + [ -f $LIVE/turn ] || abort "missing turn file in $LIVE, and no turn specified" let turn=$(cat $LIVE/turn)-1 fi run From e6b3a6da65f3644ccc1324aecd89dde2733e1558 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 17 Jun 2015 07:54:56 +0200 Subject: [PATCH 10/17] suppress valgrind warning form issue #227 --- src/battle.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/battle.c b/src/battle.c index db2dbc3ca..9fb58751d 100644 --- a/src/battle.c +++ b/src/battle.c @@ -901,7 +901,9 @@ static void rmtroop(troop dt) rmfighter(df, 1); assert(dt.index >= 0 && dt.index < df->unit->number); - df->person[dt.index] = df->person[df->alive - df->removed]; + if (dt.index!=df->alive-df->removed) { + df->person[dt.index] = df->person[df->alive - df->removed]; + } if (df->removed) { df->person[df->alive - df->removed] = df->person[df->alive]; } From 52578486487fdf8cf60751b9e14a2b5ca1298c35 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 17 Jun 2015 08:06:01 +0200 Subject: [PATCH 11/17] do not install crontab, except on eresseaserver. fixes issue #226 --- s/install | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/s/install b/s/install index 39c91174a..9d2d5f4b0 100755 --- a/s/install +++ b/s/install @@ -2,7 +2,7 @@ ROOT=$(pwd) while [ ! -d $ROOT/.git ]; do ROOT=$(dirname $ROOT) - if [ "$ROOT" == "/" ; then + if [ "/" = "$ROOT" ]; then echo "could not find root, are you in the git repository?" exit fi @@ -25,4 +25,8 @@ programs="create-orders backup-eressea run-turn" for prg in ${programs} ; do install -v $ROOT/process/$prg $DEST/bin/ done -crontab $ROOT/process/cron/crontab + +# install crontab, but only on the eressea server: +HOST=`hostname` + +[ "eressea" = "$HOST" ] && crontab $ROOT/process/cron/crontab From b630c9ee457dcb383d9a7e09f80209e2825ecdd9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 17 Jun 2015 08:07:47 +0200 Subject: [PATCH 12/17] oops. the name of the server is gruenbaer, not eressea --- s/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/s/install b/s/install index 9d2d5f4b0..a59c8aa46 100755 --- a/s/install +++ b/s/install @@ -29,4 +29,4 @@ done # install crontab, but only on the eressea server: HOST=`hostname` -[ "eressea" = "$HOST" ] && crontab $ROOT/process/cron/crontab +[ "gruenbaer" = "$HOST" ] && crontab $ROOT/process/cron/crontab From f27d60e1b2a716d55849bc9bb2bc5778d10b6be4 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 18 Jun 2015 00:01:11 +0200 Subject: [PATCH 13/17] disable force_leave code, it is too surprising --- conf/e2/config.xml | 2 +- conf/e3/config.xml | 2 +- conf/e4/config.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index 6cb50a1be..cf3ae2b02 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -97,7 +97,7 @@ - + diff --git a/conf/e3/config.xml b/conf/e3/config.xml index 89eccdea9..958db184f 100644 --- a/conf/e3/config.xml +++ b/conf/e3/config.xml @@ -120,7 +120,7 @@ - + diff --git a/conf/e4/config.xml b/conf/e4/config.xml index 197dc4b69..eb881901c 100644 --- a/conf/e4/config.xml +++ b/conf/e4/config.xml @@ -118,7 +118,7 @@ - + From e7bffb75331100faababf120e50948835c0bca38 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 19 Jun 2015 07:53:11 +0200 Subject: [PATCH 14/17] implement post-combat forced leave from ship/building --- src/battle.c | 3 +++ src/laws.c | 7 ++++++- src/laws.h | 6 +++++- src/laws.test.c | 16 ++++++++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/battle.c b/src/battle.c index 9fb58751d..18e506192 100644 --- a/src/battle.c +++ b/src/battle.c @@ -4307,6 +4307,9 @@ void do_battle(region * r) /* Auswirkungen berechnen: */ aftermath(b); + if (rule_force_leave(FORCE_LEAVE_POSTCOMBAT)) { + force_leave(b->region); + } /* Hier ist das Gefecht beendet, und wir können die * Hilfsstrukturen * wieder löschen: */ diff --git a/src/laws.c b/src/laws.c index fcb7b10ca..b93482716 100755 --- a/src/laws.c +++ b/src/laws.c @@ -4337,6 +4337,11 @@ void force_leave(region *r) { } } +bool rule_force_leave(int flags) { + int rules = get_param_int(global.parameters, "rules.owners.force_leave", 0); + return (rules&flags) == flags; +} + static void maintain_buildings_1(region * r) { maintain_buildings(r, false); @@ -4438,7 +4443,7 @@ void init_processor(void) add_proc_unit(p, follow_unit, "Folge auf Einheiten setzen"); p += 10; /* rest rng again before economics */ - if (get_param_int(global.parameters, "rules.owners.force_leave", 0)) { + if (rule_force_leave(FORCE_LEAVE_ALL)) { add_proc_region(p, force_leave, "kick non-allies out of buildings/ships"); } add_proc_region(p, economics, "Zerstoeren, Geben, Rekrutieren, Vergessen"); diff --git a/src/laws.h b/src/laws.h index 4f4188448..6da5ed5de 100755 --- a/src/laws.h +++ b/src/laws.h @@ -105,9 +105,13 @@ extern "C" { bool seefaction(const struct faction *f, const struct region *r, const struct unit *u, int modifier); int armedmen(const struct unit *u, bool siege_weapons); - void force_leave(struct region *r); int peasant_luck_effect(int peasants, int luck, int maxp, double variance); + #define FORCE_LEAVE_POSTCOMBAT 1 + #define FORCE_LEAVE_ALL 2 + bool rule_force_leave(int flag); + void force_leave(struct region *r); + #ifdef __cplusplus } #endif diff --git a/src/laws.test.c b/src/laws.test.c index 609b93d03..4c9f43ba5 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -230,6 +230,21 @@ static void test_display_cmd(CuTest *tc) { test_cleanup(); } +static void test_rule_force_leave(CuTest *tc) { + set_param(&global.parameters, "rules.owners.force_leave", "0"); + CuAssertIntEquals(tc, false, rule_force_leave(FORCE_LEAVE_ALL)); + CuAssertIntEquals(tc, false, rule_force_leave(FORCE_LEAVE_POSTCOMBAT)); + set_param(&global.parameters, "rules.owners.force_leave", "1"); + CuAssertIntEquals(tc, false, rule_force_leave(FORCE_LEAVE_ALL)); + CuAssertIntEquals(tc, true, rule_force_leave(FORCE_LEAVE_POSTCOMBAT)); + set_param(&global.parameters, "rules.owners.force_leave", "2"); + CuAssertIntEquals(tc, true, rule_force_leave(FORCE_LEAVE_ALL)); + CuAssertIntEquals(tc, false, rule_force_leave(FORCE_LEAVE_POSTCOMBAT)); + set_param(&global.parameters, "rules.owners.force_leave", "3"); + CuAssertIntEquals(tc, true, rule_force_leave(FORCE_LEAVE_ALL)); + CuAssertIntEquals(tc, true, rule_force_leave(FORCE_LEAVE_POSTCOMBAT)); +} + static void test_force_leave_buildings(CuTest *tc) { ally *al; region *r; @@ -779,6 +794,7 @@ CuSuite *get_laws_suite(void) SUITE_ADD_TEST(suite, test_enter_building); SUITE_ADD_TEST(suite, test_enter_ship); SUITE_ADD_TEST(suite, test_display_cmd); + SUITE_ADD_TEST(suite, test_rule_force_leave); SUITE_ADD_TEST(suite, test_force_leave_buildings); SUITE_ADD_TEST(suite, test_force_leave_ships); SUITE_ADD_TEST(suite, test_force_leave_ships_on_ocean); From 9b7a4e813ba91b2e5e12e9f2aa0fed014286fed9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 19 Jun 2015 13:17:01 +0200 Subject: [PATCH 15/17] functional test for forced leave configuration. functional test for forced leave after combat. functional test for MAKE TEMP. error handling for Lua function building.create(). reduce some errors to warnings. initialize race.battle_flags correctly (when not created through XML). re-initialize processor in case config has changed. handle missing translation of combat status, with error message. --- scripts/tests/config.lua | 1 - scripts/tests/init.lua | 1 + scripts/tests/laws.lua | 114 +++++++++++++++++++++++++++++++++++++++ src/battle.c | 1 - src/bind_building.c | 9 +++- src/kernel/config.c | 2 +- src/kernel/race.c | 1 + src/kernel/xmlreader.c | 2 +- src/laws.c | 16 +++--- src/reports.c | 12 ++++- src/util/bsdstring.c | 1 + 11 files changed, 147 insertions(+), 13 deletions(-) create mode 100644 scripts/tests/laws.lua diff --git a/scripts/tests/config.lua b/scripts/tests/config.lua index b24da72bc..d21ecda1e 100644 --- a/scripts/tests/config.lua +++ b/scripts/tests/config.lua @@ -36,4 +36,3 @@ function test_read_ship() s = ship.create(nil, "boat") assert_not_nil(s) end - diff --git a/scripts/tests/init.lua b/scripts/tests/init.lua index 57477be1d..d54236e2d 100644 --- a/scripts/tests/init.lua +++ b/scripts/tests/init.lua @@ -7,3 +7,4 @@ require 'tests.pool' require 'tests.regions' require 'tests.settings' require 'tests.study' +require 'tests.laws' diff --git a/scripts/tests/laws.lua b/scripts/tests/laws.lua new file mode 100644 index 000000000..f0fef15a9 --- /dev/null +++ b/scripts/tests/laws.lua @@ -0,0 +1,114 @@ +require "lunit" + +module("tests.laws", package.seeall, lunit.testcase) + +function setup() + eressea.free_game() + conf = [[{ + "races": { + "human" : {} + }, + "terrains" : { + "plain": { "flags" : [ "land", "walk", "sail" ] } + }, + "keywords" : { + "de": { + "attack" : "ATTACKIERE", + "maketemp" : "MACHETEMP", + "end" : "ENDE", + "recruit" : "REKRUTIERE" + } + }, + "buildings" : { + "castle" : {} + } + }]] + + eressea.config.reset() + eressea.config.parse(conf) +end + +function test_force_leave_on() + local r = region.create(0, 0, "plain") + local f1 = faction.create("owner@eressea.de") + local f2 = faction.create("guest@eressea.de") + local u1 = unit.create(f1, r, 1) + local u2 = unit.create(f2, r, 1) + local b1 = building.create(r, "castle") + u1.building = b1 + u2.building = b1 + eressea.settings.set("rules.owners.force_leave", "2") + process_orders() + assert_equal(b1, u1.building) + assert_equal(nil, u2.building) +end + +function test_force_leave_off() + local r = region.create(0, 0, "plain") + local f1 = faction.create("owner@eressea.de") + local f2 = faction.create("guest@eressea.de") + local u1 = unit.create(f1, r, 1) + local u2 = unit.create(f2, r, 1) + local b1 = building.create(r, "castle") + u1.building = b1 + u2.building = b1 + eressea.settings.set("rules.owners.force_leave", "0") + process_orders() + assert_equal(b1, u1.building) + assert_equal(b1, u2.building) +end + +function test_make_temp() + local r = region.create(0, 0, "plain") + local f1 = faction.create("owner@eressea.de", "human", "de") + local u1 = unit.create(f1, r, 10) + local u, u2 + + u1.building = building.create(r, "castle") + u1.status = 1 + u1:clear_orders() + u1:add_order("MACHETEMP 1 Hodor") + u1:add_order("REKRUTIERE 1") + u1:add_order("ENDE") + process_orders() + for u in r.units do + if u~=u1 then + u2 = u + break + end + end + assert_not_equal(nil, u2) + assert_not_equal(nil, u2.building) + assert_equal(1, u2.number) + assert_equal(1, u2.status) + assert_equal("Hodor", u2.name) +end + +function test_force_leave_postcombat() + local r = region.create(0, 0, "plain") + local f1 = faction.create("owner@eressea.de", "human", "de") + local f2 = faction.create("guest@eressea.de", "human", "de") + local u1 = unit.create(f1, r, 10) + local u2 = unit.create(f2, r, 10) + local u, u3 + local b1 = building.create(r, "castle") + u1.building = b1 + u2.building = b1 + eressea.settings.set("rules.owners.force_leave", "1") + u1:clear_orders() + u1:add_order("ATTACKIERE " .. itoa36(u2.id)) + u2:clear_orders() + u2:add_order("MACHETEMP 2 Hodor") + u2:add_order("REKRUTIERE 1") + u2:add_order("ENDE") + process_orders() + for u in r.units do + if u~=u1 and u~=u2 then + u3 = u + break + end + end + assert_not_equal(nil, u3) + assert_equal(nil, u3.building) + assert_equal(1, u3.number) +end diff --git a/src/battle.c b/src/battle.c index 18e506192..e06d45979 100644 --- a/src/battle.c +++ b/src/battle.c @@ -3946,7 +3946,6 @@ static bool start_battle(region * r, battle ** bp) unit *u; bool fighting = false; - /* list_foreach geht nicht, wegen flucht */ for (u = r->units; u != NULL; u = u->next) { if (fval(u, UFL_LONGACTION)) continue; diff --git a/src/bind_building.c b/src/bind_building.c index f52789700..aa9ba8e79 100644 --- a/src/bind_building.c +++ b/src/bind_building.c @@ -20,6 +20,7 @@ without prior permission by the authors of Eressea. #include #include +#include #include #include @@ -190,7 +191,13 @@ static int tolua_building_create(lua_State * L) { region *r = (region *)tolua_tousertype(L, 1, 0); const char *bname = tolua_tostring(L, 2, 0); - if (bname) { + if (!r) { + log_error("building.create expects a region as argument 1"); + } + if (!bname) { + log_error("building.create expects a name as argument 2"); + } + if (bname) { const building_type *btype = bt_find(bname); if (btype) { building *b = new_building(btype, r, default_locale); diff --git a/src/kernel/config.c b/src/kernel/config.c index 6a5815499..d298f77d7 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -991,7 +991,7 @@ void init_locale(struct locale *lang) addtoken(tokens, name, var); } else { - log_error("no translation for magic school %s in locale %s", tok, locale_name(lang)); + log_warning("no translation for magic school %s in locale %s", tok, locale_name(lang)); } tok = strtok(NULL, " "); } diff --git a/src/kernel/race.c b/src/kernel/race.c index 81af9d9a1..2c86c5e51 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -183,6 +183,7 @@ race *rc_get_or_create(const char *zName) rc->recruit_multi = 1.0F; rc->regaura = 1.0F; rc->speed = 1.0F; + rc->battle_flags = BF_CANATTACK; if (strchr(zName, ' ') != NULL) { log_error("race '%s' has an invalid name. remove spaces\n", zName); assert(strchr(zName, ' ') == NULL); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index b4b1da708..1343b3908 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1726,7 +1726,7 @@ static int parse_races(xmlDocPtr doc) if (xml_bvalue(node, "resistpierce", false)) rc->battle_flags |= BF_RES_PIERCE; if (xml_bvalue(node, "canattack", true)) - rc->battle_flags |= BF_CANATTACK; + rc->battle_flags |= BF_CANATTACK; // TODO: invert this flag, so rc_get_or_create gets simpler for (child = node->children; child; child = child->next) { if (strcmp((const char *)child->name, "ai") == 0) { diff --git a/src/laws.c b/src/laws.c index b93482716..46c471cd5 100755 --- a/src/laws.c +++ b/src/laws.c @@ -3346,7 +3346,7 @@ void new_units(void) } u2 = create_unit(r, u->faction, 0, u->faction->race, alias, name, u); if (name != NULL) - free(name); + free(name); // TODO: use a buffer on the stack instead? fset(u2, UFL_ISNEW); a_add(&u2->attribs, a_new(&at_alias))->data.i = alias; @@ -4378,6 +4378,12 @@ void init_processor(void) { int p; + while (processors) { + processor * next = processors->next; + free(processors); + processors = next; + } + p = 10; add_proc_global(p, new_units, "Neue Einheiten erschaffen"); @@ -4528,13 +4534,9 @@ void init_processor(void) void processorders(void) { - static int init = 0; + init_processor(); - if (!init) { - init_processor(); - init = 1; - } - update_spells(); + update_spells(); process(); /*************************************************/ diff --git a/src/reports.c b/src/reports.c index 4d71d29b0..be2114f97 100644 --- a/src/reports.c +++ b/src/reports.c @@ -114,8 +114,18 @@ const char *combatstatus[] = { const char *report_kampfstatus(const unit * u, const struct locale *lang) { static char fsbuf[64]; // FIXME: static return value + const char * status = LOC(lang, combatstatus[u->status]); - strlcpy(fsbuf, LOC(lang, combatstatus[u->status]), sizeof(fsbuf)); + if (!status) { + const char *lname = locale_name(lang); + struct locale *wloc = get_or_create_locale(lname); + log_error("no translation for combat status %s in %s", combatstatus[u->status], lname); + locale_setstring(wloc, combatstatus[u->status], combatstatus[u->status]); + strlcpy(fsbuf, combatstatus[u->status], sizeof(fsbuf)); + } + else { + strlcpy(fsbuf, status, sizeof(fsbuf)); + } if (fval(u, UFL_NOAID)) { strcat(fsbuf, ", "); strcat(fsbuf, LOC(lang, "status_noaid")); diff --git a/src/util/bsdstring.c b/src/util/bsdstring.c index 4205b9480..865e0198e 100644 --- a/src/util/bsdstring.c +++ b/src/util/bsdstring.c @@ -31,6 +31,7 @@ size_t strlcpy(char *dst, const char *src, size_t siz) register const char *s = src; register size_t n = siz; + assert(src && dst); /* Copy as many bytes as will fit */ if (n != 0 && --n != 0) { do { From 5afd58fafff385dd4d6e65ddffd5613da6097430 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 19 Jun 2015 13:37:15 +0200 Subject: [PATCH 16/17] Revert "disable force_leave code, it is too surprising" This reverts commit f27d60e1b2a716d55849bc9bb2bc5778d10b6be4. --- conf/e2/config.xml | 2 +- conf/e3/config.xml | 2 +- conf/e4/config.xml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/e2/config.xml b/conf/e2/config.xml index cf3ae2b02..6cb50a1be 100644 --- a/conf/e2/config.xml +++ b/conf/e2/config.xml @@ -97,7 +97,7 @@ - + diff --git a/conf/e3/config.xml b/conf/e3/config.xml index 958db184f..89eccdea9 100644 --- a/conf/e3/config.xml +++ b/conf/e3/config.xml @@ -120,7 +120,7 @@ - + diff --git a/conf/e4/config.xml b/conf/e4/config.xml index eb881901c..197dc4b69 100644 --- a/conf/e4/config.xml +++ b/conf/e4/config.xml @@ -118,7 +118,7 @@ - + From 659aa6c9734e9c8c540d58e2c990f559edc408d8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 20 Jun 2015 14:28:16 +0200 Subject: [PATCH 17/17] after combat, eject enemies only --- src/battle.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- src/battle.h | 1 + src/laws.c | 30 ++++-------------------------- src/laws.h | 2 +- src/laws.test.c | 11 ++++++----- 5 files changed, 59 insertions(+), 33 deletions(-) diff --git a/src/battle.c b/src/battle.c index e06d45979..73c0a74ec 100644 --- a/src/battle.c +++ b/src/battle.c @@ -4235,6 +4235,52 @@ static void battle_flee(battle * b) } } +static bool is_enemy(battle *b, unit *u1, unit *u2) { + if (u1->faction != u2->faction) { + if (b) { + side *es, *s1 = 0, *s2 = 0; + for (es = b->sides; es != b->sides + b->nsides; ++es) { + if (!s1 && es->faction == u1->faction) s1 = es; + else if (!s2 && es->faction == u2->faction) s2 = es; + if (s1 && s2) break; + } + return enemy(s1, s2); + } + else { + return !help_enter(u1, u2); + } + } + return false; +} + +void force_leave(region *r, battle *b) { + unit *u; + + for (u = r->units; u; u = u->next) { + unit *uo = NULL; + if (u->building) { + uo = building_owner(u->building); + } + if (u->ship && r->land) { + uo = ship_owner(u->ship); + } + if (uo && is_enemy(b, uo, u)) { + message *msg = NULL; + if (u->building) { + msg = msg_message("force_leave_building", "unit owner building", u, uo, u->building); + } + else { + msg = msg_message("force_leave_ship", "unit owner ship", u, uo, u->ship); + } + if (msg) { + ADDMSG(&u->faction->msgs, msg); + } + leave(u, false); + } + } +} + + void do_battle(region * r) { battle *b = NULL; @@ -4307,7 +4353,7 @@ void do_battle(region * r) /* Auswirkungen berechnen: */ aftermath(b); if (rule_force_leave(FORCE_LEAVE_POSTCOMBAT)) { - force_leave(b->region); + force_leave(b->region, b); } /* Hier ist das Gefecht beendet, und wir können die * Hilfsstrukturen * wieder löschen: */ diff --git a/src/battle.h b/src/battle.h index 075edf496..8d29d733a 100644 --- a/src/battle.h +++ b/src/battle.h @@ -270,6 +270,7 @@ extern "C" { const struct group * g, unsigned int flags, const struct faction * stealthfaction); int skilldiff(troop at, troop dt, int dist); + void force_leave(struct region *r, struct battle *b); #ifdef __cplusplus } diff --git a/src/laws.c b/src/laws.c index 46c471cd5..fb4daa76f 100755 --- a/src/laws.c +++ b/src/laws.c @@ -4307,34 +4307,12 @@ static void enter_2(region * r) do_enter(r, 1); } -static bool help_enter(unit *uo, unit *u) { +bool help_enter(unit *uo, unit *u) { return uo->faction == u->faction || alliedunit(uo, u->faction, HELP_GUARD); } -void force_leave(region *r) { - unit *u; - for (u = r->units; u; u = u->next) { - unit *uo = NULL; - if (u->building) { - uo = building_owner(u->building); - } - if (u->ship && r->land) { - uo = ship_owner(u->ship); - } - if (uo && !help_enter(uo, u)) { - message *msg = NULL; - if (u->building) { - msg = msg_message("force_leave_building", "unit owner building", u, uo, u->building); - } - else { - msg = msg_message("force_leave_ship", "unit owner ship", u, uo, u->ship); - } - if (msg) { - ADDMSG(&u->faction->msgs, msg); - } - leave(u, false); - } - } +static void do_force_leave(region *r) { + force_leave(r, NULL); } bool rule_force_leave(int flags) { @@ -4450,7 +4428,7 @@ void init_processor(void) p += 10; /* rest rng again before economics */ if (rule_force_leave(FORCE_LEAVE_ALL)) { - add_proc_region(p, force_leave, "kick non-allies out of buildings/ships"); + add_proc_region(p, do_force_leave, "kick non-allies out of buildings/ships"); } add_proc_region(p, economics, "Zerstoeren, Geben, Rekrutieren, Vergessen"); add_proc_order(p, K_PROMOTION, promotion_cmd, 0, "Heldenbefoerderung"); diff --git a/src/laws.h b/src/laws.h index 6da5ed5de..7eec612e3 100755 --- a/src/laws.h +++ b/src/laws.h @@ -110,7 +110,7 @@ extern "C" { #define FORCE_LEAVE_POSTCOMBAT 1 #define FORCE_LEAVE_ALL 2 bool rule_force_leave(int flag); - void force_leave(struct region *r); + bool help_enter(struct unit *uo, struct unit *u); #ifdef __cplusplus } diff --git a/src/laws.test.c b/src/laws.test.c index 4c9f43ba5..8a02d6ef4 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -1,5 +1,6 @@ #include #include "laws.h" +#include "battle.h" #include #include @@ -261,8 +262,8 @@ static void test_force_leave_buildings(CuTest *tc) { building_set_owner(u1); u_set_building(u2, b); u_set_building(u3, b); - force_leave(r); - CuAssertPtrEquals_Msg(tc, "owner should not be forecd to leave", b, u1->building); + force_leave(r, NULL); + CuAssertPtrEquals_Msg(tc, "owner should not be forced to leave", b, u1->building); CuAssertPtrEquals_Msg(tc, "same faction should not be forced to leave", b, u2->building); CuAssertPtrEquals_Msg(tc, "non-allies should be forced to leave", NULL, u3->building); msg = test_get_last_message(u3->faction->msgs); @@ -271,7 +272,7 @@ static void test_force_leave_buildings(CuTest *tc) { u_set_building(u3, b); al = ally_add(&u1->faction->allies, u3->faction); al->status = HELP_GUARD; - force_leave(r); + force_leave(r, NULL); CuAssertPtrEquals_Msg(tc, "allies should not be forced to leave", b, u3->building); test_cleanup(); } @@ -289,7 +290,7 @@ static void test_force_leave_ships(CuTest *tc) { u_set_ship(u1, sh); u_set_ship(u2, sh); ship_set_owner(u1); - force_leave(r); + force_leave(r, NULL); CuAssertPtrEquals_Msg(tc, "non-allies should be forced to leave", NULL, u2->ship); msg = test_get_last_message(u2->faction->msgs); CuAssertStrEquals(tc, "force_leave_ship", test_get_messagetype(msg)); @@ -308,7 +309,7 @@ static void test_force_leave_ships_on_ocean(CuTest *tc) { u_set_ship(u1, sh); u_set_ship(u2, sh); ship_set_owner(u1); - force_leave(r); + force_leave(r, NULL); CuAssertPtrEquals_Msg(tc, "no forcing out of ships on oceans", sh, u2->ship); test_cleanup(); }