diff --git a/CMakeLists.txt b/CMakeLists.txt index ec339b037..291fab324 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -117,8 +117,8 @@ if (NOT EXISTS ${dfhack_SOURCE_DIR}/library/xml/codegen.pl OR NOT EXISTS ${dfhac endif() # set up versioning. -set(DF_VERSION "0.43.03") -SET(DFHACK_RELEASE "r1") +set(DF_VERSION "0.43.05") +SET(DFHACK_RELEASE "alpha0") SET(DFHACK_PRERELEASE FALSE) set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") diff --git a/library/Core.cpp b/library/Core.cpp index fb1dd80bb..975290e52 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -2107,7 +2107,7 @@ void Core::handleLoadAndUnloadScripts(color_ostream& out, state_change_event eve if (!df::global::world) return; - std::string rawFolder = "data/save/" + (df::global::world->cur_savegame.save_dir) + "/raw/"; + std::string rawFolder = "data/save/" + (df::global::world->save_dir) + "/raw/"; auto i = table.find(event); if ( i != table.end() ) { @@ -2167,9 +2167,9 @@ void Core::onStateChange(color_ostream &out, state_change_event event) case SC_WORLD_UNLOADED: case SC_MAP_LOADED: case SC_MAP_UNLOADED: - if (world && world->cur_savegame.save_dir.size()) + if (world && world->save_dir.size()) { - std::string save_dir = "data/save/" + world->cur_savegame.save_dir; + std::string save_dir = "data/save/" + world->save_dir; std::string evtlogpath = save_dir + "/events-dfhack.log"; std::ofstream evtlog; evtlog.open(evtlogpath, std::ios_base::app); // append @@ -2187,7 +2187,7 @@ void Core::onStateChange(color_ostream &out, state_change_event event) evtlog << timebuf; evtlog << "DFHack " << Version::git_description() << " on " << ostype << "; "; evtlog << "cwd md5: " << md5w.getHashFromString(getHackPath()).substr(0, 10) << "; "; - evtlog << "save: " << world->cur_savegame.save_dir << "; "; + evtlog << "save: " << world->save_dir << "; "; evtlog << sc_event_name(event) << "; "; if (gametype) evtlog << "game type " << ENUM_KEY_STR(game_type, *gametype) << " (" << *gametype << ")"; diff --git a/library/LuaTools.cpp b/library/LuaTools.cpp index 008cb00c2..b44f309c3 100644 --- a/library/LuaTools.cpp +++ b/library/LuaTools.cpp @@ -319,7 +319,7 @@ static int yield_helper(lua_State *S) } namespace { - int dfhack_lineedit_cont(lua_State *L, int status, int) + int dfhack_lineedit_cont(lua_State *L, int status, lua_KContext) { if (Lua::IsSuccess(status)) return lua_gettop(L) - 2; @@ -636,7 +636,7 @@ static bool do_finish_pcall(lua_State *L, bool success, int base = 1, int space } namespace { - int safecall_cont(lua_State *L, int status, int) + int safecall_cont(lua_State *L, int status, lua_KContext) { bool success = do_finish_pcall(L, Lua::IsSuccess(status)); @@ -1138,7 +1138,7 @@ static bool do_invoke_cleanup(lua_State *L, int nargs, int errorfun, bool succes return success; } -int dfhack_cleanup_cont(lua_State *L, int status, int) +int dfhack_cleanup_cont(lua_State *L, int status, lua_KContext) { bool success = Lua::IsSuccess(status); @@ -1246,6 +1246,11 @@ static int dfhack_open_plugin(lua_State *L) return 0; } +static int gettop_wrapper(lua_State *L, int, lua_KContext) +{ + return lua_gettop(L); +} + static int dfhack_curry_wrap(lua_State *L) { int nargs = lua_gettop(L); @@ -1261,7 +1266,7 @@ static int dfhack_curry_wrap(lua_State *L) for (int i = 1; i <= ncurry; i++) lua_copy(L, lua_upvalueindex(i+1), i); - lua_callk(L, scount-1, LUA_MULTRET, 0, lua_gettop); + lua_callk(L, scount-1, LUA_MULTRET, 0, gettop_wrapper); return lua_gettop(L); } diff --git a/library/LuaTypes.cpp b/library/LuaTypes.cpp index fa9445a81..e8d07dc2f 100644 --- a/library/LuaTypes.cpp +++ b/library/LuaTypes.cpp @@ -305,7 +305,7 @@ void container_identity::lua_item_write(lua_State *state, int fname_idx, void *p id->lua_write(state, fname_idx, pitem, val_index); } -bool container_identity::lua_insert(lua_State *state, int fname_idx, void *ptr, int idx, int val_index) +bool container_identity::lua_insert2(lua_State *state, int fname_idx, void *ptr, int idx, int val_index) { auto id = (type_identity*)lua_touserdata(state, UPVAL_ITEM_ID); @@ -351,7 +351,7 @@ void ptr_container_identity::lua_item_write(lua_State *state, int fname_idx, voi df::pointer_identity::lua_write(state, fname_idx, pitem, id, val_index); } -bool ptr_container_identity::lua_insert(lua_State *state, int fname_idx, void *ptr, int idx, int val_index) +bool ptr_container_identity::lua_insert2(lua_State *state, int fname_idx, void *ptr, int idx, int val_index) { auto id = (type_identity*)lua_touserdata(state, UPVAL_ITEM_ID); @@ -887,7 +887,7 @@ static int method_container_insert(lua_State *state) int len = id->lua_item_count(state, ptr, container_identity::COUNT_LEN); int idx = check_container_index(state, len, UPVAL_METHOD_NAME, 2, "call", true); - if (!id->lua_insert(state, UPVAL_METHOD_NAME, ptr, idx, 3)) + if (!id->lua_insert2(state, UPVAL_METHOD_NAME, ptr, idx, 3)) field_error(state, UPVAL_METHOD_NAME, "not supported", "call"); return 0; } diff --git a/library/RemoteTools.cpp b/library/RemoteTools.cpp index 77374ea0c..909ad9133 100644 --- a/library/RemoteTools.cpp +++ b/library/RemoteTools.cpp @@ -386,7 +386,7 @@ static command_result GetWorldInfo(color_ostream &stream, if (df::global::gametype) gt = *df::global::gametype; - out->set_save_dir(world->cur_savegame.save_dir); + out->set_save_dir(world->save_dir); if (world->world_data->name.has_name) describeName(out->mutable_world_name(), &world->world_data->name); diff --git a/library/include/DataIdentity.h b/library/include/DataIdentity.h index c94129f9b..10c905df3 100644 --- a/library/include/DataIdentity.h +++ b/library/include/DataIdentity.h @@ -132,7 +132,7 @@ namespace DFHack virtual bool erase(void *ptr, int index) { return false; } virtual bool insert(void *ptr, int index, void *pitem) { return false; } - virtual bool lua_insert(lua_State *state, int fname_idx, void *ptr, int idx, int val_index); + virtual bool lua_insert2(lua_State *state, int fname_idx, void *ptr, int idx, int val_index); protected: virtual int item_count(void *ptr, CountMode cnt) = 0; @@ -153,7 +153,7 @@ namespace DFHack virtual void lua_item_read(lua_State *state, int fname_idx, void *ptr, int idx); virtual void lua_item_write(lua_State *state, int fname_idx, void *ptr, int idx, int val_index); - virtual bool lua_insert(lua_State *state, int fname_idx, void *ptr, int idx, int val_index); + virtual bool lua_insert2(lua_State *state, int fname_idx, void *ptr, int idx, int val_index); }; class DFHACK_EXPORT bit_container_identity : public container_identity { diff --git a/library/include/LuaTools.h b/library/include/LuaTools.h index a36459d68..ae35cb52b 100644 --- a/library/include/LuaTools.h +++ b/library/include/LuaTools.h @@ -182,11 +182,9 @@ namespace DFHack {namespace Lua { } // Internal helper - template - int TailPCallK_Thunk(lua_State *state) { - int tmp; - int rv = lua_getctx(state, &tmp); - return cb(state, rv, tmp); + template + int TailPCallK_Thunk(lua_State *state, int rv, lua_KContext ctx) { + return cb(state, rv, ctx); } /** @@ -194,9 +192,9 @@ namespace DFHack {namespace Lua { * specifically, the callback is called with the same kind of arguments * in both yield and non-yield case. */ - template + template int TailPCallK(lua_State *state, int narg, int nret, int errfun, int ctx) { - int rv = lua_pcallk(state, narg, nret, errfun, ctx, &TailPCallK_Thunk); + int rv = lua_pcallk(state, narg, nret, errfun, ctx, cb); return cb(state, rv, ctx); } diff --git a/library/lua/dfhack.lua b/library/lua/dfhack.lua index 900607c08..f535d25ad 100644 --- a/library/lua/dfhack.lua +++ b/library/lua/dfhack.lua @@ -606,7 +606,7 @@ end function dfhack.getSavePath() if dfhack.isWorldLoaded() then - return dfhack.getDFPath() .. '/data/save/' .. df.global.world.cur_savegame.save_dir + return dfhack.getDFPath() .. '/data/save/' .. df.global.world.save_dir end end diff --git a/library/lua/memscan.lua b/library/lua/memscan.lua index afee78aee..87e2ad58c 100644 --- a/library/lua/memscan.lua +++ b/library/lua/memscan.lua @@ -155,6 +155,8 @@ function MemoryArea.new(astart, aend) uint16_t = CheckedArray.new('uint16_t',astart,aend), int32_t = CheckedArray.new('int32_t',astart,aend), uint32_t = CheckedArray.new('uint32_t',astart,aend), + int64_t = CheckedArray.new('int64_t',astart,aend), + uint64_t = CheckedArray.new('uint64_t',astart,aend), float = CheckedArray.new('float',astart,aend) } setmetatable(obj, MemoryArea) @@ -321,7 +323,7 @@ end -- Validation function is_valid_vector(ref,size) - local ints = df.reinterpret_cast('uint32_t', ref) + local ints = df.reinterpret_cast('uint64_t', ref) return ints[0] <= ints[1] and ints[1] <= ints[2] and (size == nil or (ints[1] - ints[0]) % size == 0) end diff --git a/library/modules/World.cpp b/library/modules/World.cpp index 3be400515..fcf516f4e 100644 --- a/library/modules/World.cpp +++ b/library/modules/World.cpp @@ -151,7 +151,7 @@ void World::SetCurrentWeather(uint8_t weather) string World::ReadWorldFolder() { - return world->cur_savegame.save_dir; + return world->save_dir; } bool World::isFortressMode(df::game_type t) diff --git a/library/xml b/library/xml index 7d312334c..369dfdd86 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit 7d312334c320022cd6275cddcdb8a64d4ed8d722 +Subproject commit 369dfdd862da961c74d35174cb55fed3d96a29c0 diff --git a/plugins/eventful.cpp b/plugins/eventful.cpp index 45b94510c..14f1ec26e 100644 --- a/plugins/eventful.cpp +++ b/plugins/eventful.cpp @@ -158,12 +158,12 @@ void ev_mng_jobCompleted(color_ostream& out, void* job) } void ev_mng_unitDeath(color_ostream& out, void* ptr) { - int32_t myId=int32_t(ptr); + int32_t myId=*(int32_t*)&ptr; onUnitDeath(out,myId); } void ev_mng_itemCreate(color_ostream& out, void* ptr) { - int32_t myId=int32_t(ptr); + int32_t myId=*(int32_t*)&ptr; onItemCreated(out,myId); } void ev_mng_construction(color_ostream& out, void* ptr) @@ -178,12 +178,12 @@ void ev_mng_syndrome(color_ostream& out, void* ptr) } void ev_mng_invasion(color_ostream& out, void* ptr) { - int32_t myId=int32_t(ptr); + int32_t myId=*(int32_t*)&ptr; onInvasion(out,myId); } static void ev_mng_building(color_ostream& out, void* ptr) { - int32_t myId=int32_t(ptr); + int32_t myId=*(int32_t*)&ptr; onBuildingCreatedDestroyed(out,myId); } static void ev_mng_inventory(color_ostream& out, void* ptr) @@ -204,7 +204,7 @@ static void ev_mng_inventory(color_ostream& out, void* ptr) onInventoryChange(out,unitId,itemId,item_old,item_new); } static void ev_mng_report(color_ostream& out, void* ptr) { - onReport(out,(int32_t)ptr); + onReport(out,*(int32_t*)&ptr); } static void ev_mng_unitAttack(color_ostream& out, void* ptr) { EventManager::UnitAttackData* data = (EventManager::UnitAttackData*)ptr; diff --git a/plugins/isoworldremote.cpp b/plugins/isoworldremote.cpp index 017fb45f6..bd3433b27 100644 --- a/plugins/isoworldremote.cpp +++ b/plugins/isoworldremote.cpp @@ -198,7 +198,7 @@ static command_result GetEmbarkInfo(color_ostream &stream, const MapRequest *in, return CR_OK; } if (in->has_save_folder()) { //If no save folder is given, it means we don't care. - if (!(in->save_folder() == world->cur_savegame.save_dir || in->save_folder() == "ANY")) { //isoworld has a different map loaded, don't bother trying to load tiles for it, we don't have them. + if (!(in->save_folder() == world->save_dir || in->save_folder() == "ANY")) { //isoworld has a different map loaded, don't bother trying to load tiles for it, we don't have them. out->set_available(false); return CR_OK; } @@ -345,7 +345,7 @@ static command_result GetRawNames(color_ostream &stream, const MapRequest *in, R return CR_OK; } if (in->has_save_folder()) { //If no save folder is given, it means we don't care. - if (!(in->save_folder() == world->cur_savegame.save_dir || in->save_folder() == "ANY")) { //isoworld has a different map loaded, don't bother trying to load tiles for it, we don't have them. + if (!(in->save_folder() == world->save_dir || in->save_folder() == "ANY")) { //isoworld has a different map loaded, don't bother trying to load tiles for it, we don't have them. out->set_available(false); return CR_OK; } diff --git a/plugins/remotefortressreader.cpp b/plugins/remotefortressreader.cpp index 7a853db82..e210b7d50 100644 --- a/plugins/remotefortressreader.cpp +++ b/plugins/remotefortressreader.cpp @@ -1576,7 +1576,7 @@ static command_result GetMapInfo(color_ostream &stream, const EmptyMessage *in, out->set_block_pos_z(pos_z); out->set_world_name(DF2UTF(Translation::TranslateName(&df::global::world->world_data->name, false))); out->set_world_name_english(DF2UTF(Translation::TranslateName(&df::global::world->world_data->name, true))); - out->set_save_name(df::global::world->cur_savegame.save_dir); + out->set_save_name(df::global::world->save_dir); return CR_OK; } diff --git a/plugins/rendermax/renderer_light.cpp b/plugins/rendermax/renderer_light.cpp index 5e6f2e2de..716f3d0b6 100644 --- a/plugins/rendermax/renderer_light.cpp +++ b/plugins/rendermax/renderer_light.cpp @@ -1172,9 +1172,9 @@ void lightingEngineViewscreen::defaultSettings() void lightingEngineViewscreen::loadSettings() { std::string rawFolder; - if(df::global::world->cur_savegame.save_dir!="") + if(df::global::world->save_dir!="") { - rawFolder= "data/save/" + (df::global::world->cur_savegame.save_dir) + "/raw/"; + rawFolder= "data/save/" + (df::global::world->save_dir) + "/raw/"; } else {