Skip to content

Commit

Permalink
Consitent JSON map save/load functions (#4882)
Browse files Browse the repository at this point in the history
  • Loading branch information
vadi2 committed Feb 26, 2021
1 parent 2a2894d commit e50200b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/TLuaInterpreter.cpp
Expand Up @@ -13712,8 +13712,8 @@ void TLuaInterpreter::initLuaGlobals()
lua_register(pGlobalLua, "getMapRoomExitsColor", TLuaInterpreter::getMapRoomExitsColor);
lua_register(pGlobalLua, "setMapRoomExitsColor", TLuaInterpreter::setMapRoomExitsColor);
lua_register(pGlobalLua, "showNotification", TLuaInterpreter::showNotification);
lua_register(pGlobalLua, "exportJsonMap", TLuaInterpreter::exportJsonMap);
lua_register(pGlobalLua, "importJsonMap", TLuaInterpreter::importJsonMap);
lua_register(pGlobalLua, "saveJsonMap", TLuaInterpreter::saveJsonMap);
lua_register(pGlobalLua, "loadJsonMap", TLuaInterpreter::loadJsonMap);
lua_register(pGlobalLua, "registerMapInfo", TLuaInterpreter::registerMapInfo);
lua_register(pGlobalLua, "killMapInfo", TLuaInterpreter::killMapInfo);
lua_register(pGlobalLua, "enableMapInfo", TLuaInterpreter::enableMapInfo);
Expand Down Expand Up @@ -15328,8 +15328,8 @@ int TLuaInterpreter::showNotification(lua_State* L)
return 0;
}

// Documentation: https://wiki.mudlet.org/w/Manual:Lua_Functions#exportJsonMap
int TLuaInterpreter::exportJsonMap(lua_State* L)
// Documentation: https://wiki.mudlet.org/w/Manual:Lua_Functions#saveJsonMap
int TLuaInterpreter::saveJsonMap(lua_State* L)
{
Host* pHost = &getHostFromLua(L);
if (!pHost || !pHost->mpMap || !pHost->mpMap->mpMapper || !pHost->mpMap->mpMapper->mp2dMap) {
Expand All @@ -15341,6 +15341,7 @@ int TLuaInterpreter::exportJsonMap(lua_State* L)
return warnArgumentValue(L, __func__, "a non-empty path and file name to write to must be provided");
}


if (auto [result, message] = pHost->mpMap->writeJsonMapFile(dest); !result) {
return warnArgumentValue(L, __func__, message);
}
Expand All @@ -15349,8 +15350,8 @@ int TLuaInterpreter::exportJsonMap(lua_State* L)
return 1;
}

// Documentation: https://wiki.mudlet.org/w/Manual:Lua_Functions#importJsonMap
int TLuaInterpreter::importJsonMap(lua_State* L)
// Documentation: https://wiki.mudlet.org/w/Manual:Lua_Functions#loadJsonMap
int TLuaInterpreter::loadJsonMap(lua_State* L)
{
Host* pHost = &getHostFromLua(L);
if (!pHost || !pHost->mpMap || !pHost->mpMap->mpMapper || !pHost->mpMap->mpMapper->mp2dMap) {
Expand Down
4 changes: 2 additions & 2 deletions src/TLuaInterpreter.h
Expand Up @@ -592,8 +592,8 @@ class TLuaInterpreter : public QThread
static int getMapRoomExitsColor(lua_State*);
static int setMapRoomExitsColor(lua_State*);
static int showNotification(lua_State*);
static int exportJsonMap(lua_State*);
static int importJsonMap(lua_State*);
static int saveJsonMap(lua_State*);
static int loadJsonMap(lua_State*);
static int registerMapInfo(lua_State*);
static int killMapInfo(lua_State*);
static int enableMapInfo(lua_State*);
Expand Down

0 comments on commit e50200b

Please sign in to comment.