diff --git a/common/map/region_pager_api.hpp b/common/map/region_pager_api.hpp index bc40981..466af61 100644 --- a/common/map/region_pager_api.hpp +++ b/common/map/region_pager_api.hpp @@ -24,7 +24,7 @@ #include "lua/lua.hpp" -#define TORTUGA_REGION_PAGER_NAME "pager" +#define TORTUGA_REGION_PAGER_NAME "RegionPager" LUAMOD_API int openRegionPagerAPI(lua_State* L); #endif diff --git a/rsc/scripts/setup_server.lua b/rsc/scripts/setup_server.lua index bae4a74..3511fa9 100644 --- a/rsc/scripts/setup_server.lua +++ b/rsc/scripts/setup_server.lua @@ -1,20 +1 @@ print("Lua script check (./rsc)") - -------------------------- ---Map API overrides -------------------------- - -function region.create(r) - for i = 1, region.getwidth() do - for j = 1, region.getheight() do - if math.abs(region.getx(r) + i -1) == math.abs(region.gety(r) + j -1) then - region.settile(r, i, j, 1, 50) - else - region.settile(r, i, j, 1, 14) - end - end - end - - --signal - region.settile(r, 4, 5, 2, 86) -end diff --git a/server/rooms/room_manager.cpp b/server/rooms/room_manager.cpp index 53347be..46beb53 100644 --- a/server/rooms/room_manager.cpp +++ b/server/rooms/room_manager.cpp @@ -34,7 +34,7 @@ //public access methods //------------------------- -int RoomManager::CreateRoom(MapType mapType) { +RoomData* RoomManager::CreateRoom(MapType mapType) { //create the room RoomData* newRoom = new RoomData(); @@ -60,8 +60,6 @@ int RoomManager::CreateRoom(MapType mapType) { //register the room roomMap[counter++] = newRoom; - //TODO: pass the room's index to the lua hooks? - //API hook lua_getglobal(luaState, "Room"); lua_getfield(luaState, -1, "OnCreate"); @@ -72,14 +70,14 @@ int RoomManager::CreateRoom(MapType mapType) { lua_pop(luaState, 1); //finish the routine - return counter; + return newRoom; } -int RoomManager::UnloadRoom(int uid) { +void RoomManager::UnloadRoom(int uid) { //find the room RoomData* room = FindRoom(uid); if (!room) { - return -1; + return; } //API hook @@ -95,15 +93,12 @@ int RoomManager::UnloadRoom(int uid) { delete room->generator; delete room; roomMap.erase(uid); - - return 0; } RoomData* RoomManager::GetRoom(int uid) { RoomData* ptr = FindRoom(uid); if (ptr) return ptr; - int newIndex = CreateRoom(MapType::NONE); - return FindRoom(newIndex); + return CreateRoom(MapType::NONE); } RoomData* RoomManager::FindRoom(int uid) { diff --git a/server/rooms/room_manager.hpp b/server/rooms/room_manager.hpp index 5aad423..02c5b32 100644 --- a/server/rooms/room_manager.hpp +++ b/server/rooms/room_manager.hpp @@ -36,8 +36,8 @@ public: ~RoomManager() = default; //public access methods - int CreateRoom(MapType); - int UnloadRoom(int uid); + RoomData* CreateRoom(MapType); + void UnloadRoom(int uid); RoomData* GetRoom(int uid); RoomData* FindRoom(int uid); diff --git a/server/rooms/room_mgr_api.cpp b/server/rooms/room_mgr_api.cpp index aae40df..1d7825b 100644 --- a/server/rooms/room_mgr_api.cpp +++ b/server/rooms/room_mgr_api.cpp @@ -21,6 +21,7 @@ */ #include "room_mgr_api.hpp" +#include "room_api.hpp" #include "room_manager.hpp" #include "room_data.hpp" @@ -54,10 +55,10 @@ static int createRoom(lua_State* L) { }(); //create the room - int newIndex = roomMgr->CreateRoom(mapType); + RoomData* newRoom = roomMgr->CreateRoom(mapType); - //return the index - lua_pushinteger(L, newIndex); + //return the new room + lua_pushlightuserdata(L, newRoom); return 1; }