From 8e7919f206ab7cb3aeee034814b5d47c22a67687 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 30 Apr 2020 19:46:23 +0200 Subject: [PATCH 1/3] clibs submodule update --- clibs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clibs b/clibs index abe774f70..484fbf23e 160000 --- a/clibs +++ b/clibs @@ -1 +1 @@ -Subproject commit abe774f70265de14ea7f5e530518ca130562a9c9 +Subproject commit 484fbf23e34f6844f1c4e3f685bb6c53cadf5bfe From 2529a781d81e5dc7fe443b879adc72697ad13cdd Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 30 Apr 2020 20:01:02 +0200 Subject: [PATCH 2/3] fix lunit --- scripts/run-tests-e2.lua | 2 +- scripts/run-tests-e3.lua | 2 +- scripts/run-tests.lua | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/run-tests-e2.lua b/scripts/run-tests-e2.lua index b5f18c7f7..64a090108 100644 --- a/scripts/run-tests-e2.lua +++ b/scripts/run-tests-e2.lua @@ -11,11 +11,11 @@ package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua' config.rules = 'e2' +lunit = require 'lunit' require 'eressea' require 'eressea.xmlconf' require 'eressea.path' require 'tests.e2' -require 'lunit' rng.inject(0) eressea.settings.set("rules.food.flags", "4") diff --git a/scripts/run-tests-e3.lua b/scripts/run-tests-e3.lua index 3332df306..43d42635e 100644 --- a/scripts/run-tests-e3.lua +++ b/scripts/run-tests-e3.lua @@ -11,11 +11,11 @@ package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua' config.rules = 'e3' +lunit = require 'lunit' require 'eressea' require 'eressea.path' require 'eressea.xmlconf' require 'tests.e3' -require 'lunit' rng.inject(0) eressea.settings.set("rules.alliances", "0") diff --git a/scripts/run-tests.lua b/scripts/run-tests.lua index d1306ddcd..c41c29f01 100644 --- a/scripts/run-tests.lua +++ b/scripts/run-tests.lua @@ -9,9 +9,9 @@ if config.install then end package.path = package.path .. ';' .. path .. '/?.lua;' .. path .. '/?/init.lua' +lunit = require 'lunit' require 'eressea' require 'eressea.path' require 'tests' -require 'lunit' result = lunit.main() return result.errors + result.failed From 1a63e41929f4c855ece6f31d60a31fa8cc3567bc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 9 May 2020 21:06:25 +0200 Subject: [PATCH 3/3] Bug 2659: units inside building AND ship --- src/give.c | 3 +++ src/kernel/save.c | 18 +++++++++--------- src/kernel/unit.c | 4 ++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/give.c b/src/give.c index ac792da9a..8f8e72230 100644 --- a/src/give.c +++ b/src/give.c @@ -385,6 +385,9 @@ message * give_ship(unit *u1, unit *u2, int n, order *ord) } } else { + if (u2->building) { + leave_building(u2); + } if (n < u1->ship->number) { ship * sh = new_ship(u1->ship->type, u1->region, u1->faction->locale); scale_ship(sh, 0); diff --git a/src/kernel/save.c b/src/kernel/save.c index a65dda7e1..66eb22471 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -376,7 +376,7 @@ unit *read_unit(gamedata *data) { unit *u; const race *rc; - int number, n, p; + int number, n, p, bn, sn; order **orderp; char obuf[DISPLAYSIZE]; faction *f; @@ -443,9 +443,10 @@ unit *read_unit(gamedata *data) else u->irace = NULL; - READ_INT(data->store, &n); - if (n > 0) { - building * b = findbuilding(n); + READ_INT(data->store, &bn); + READ_INT(data->store, &sn); + if (sn <= 0 && bn > 0) { + building * b = findbuilding(bn); if (b) { u_set_building(u, b); if (fval(u, UFL_OWNER)) { @@ -453,13 +454,12 @@ unit *read_unit(gamedata *data) } } else { - log_error("read_unit: unit in unkown building '%s'", itoa36(n)); + log_error("read_unit: unit in unkown building '%s'", itoa36(bn)); } } - READ_INT(data->store, &n); - if (n > 0) { - ship * sh = findship(n); + if (sn > 0) { + ship * sh = findship(sn); if (sh) { u_set_ship(u, sh); if (fval(u, UFL_OWNER)) { @@ -467,7 +467,7 @@ unit *read_unit(gamedata *data) } } else { - log_error("read_unit: unit in unkown ship '%s'", itoa36(n)); + log_error("read_unit: unit in unkown ship '%s'", itoa36(sn)); } } diff --git a/src/kernel/unit.c b/src/kernel/unit.c index e9ec8e657..6b4cbe2b0 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -635,7 +635,7 @@ void leave_ship(unit * u) { struct ship *sh = u->ship; - u->ship = 0; + u->ship = NULL; if (sh->_owner == u) { ship_update_owner(sh); sh->_owner = ship_owner(sh); @@ -647,7 +647,7 @@ void leave_building(unit * u) { building * b = u->building; - u->building = 0; + u->building = NULL; if (b->_owner == u) { building_update_owner(b); assert(b->_owner != u);