From 501b1e9814206635dc697f904636618aa8e7bec5 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sun, 8 Mar 2015 20:08:12 +1100 Subject: [PATCH] Reduced script verbosity to a degree --- common/map/map_system_api.cpp | 55 ----------- common/map/map_system_api.hpp | 30 ------ common/map/region_api.hpp | 2 +- common/map/region_pager_api.cpp | 1 + common/map/region_pager_api.hpp | 2 +- rsc/scripts/map_maker.lua | 50 +++++----- rsc/scripts/map_saver.lua | 6 +- rsc/scripts/setup_server.lua | 110 ++++++++------------- server/characters/character_system_api.cpp | 55 ----------- server/characters/character_system_api.hpp | 30 ------ server/linit.cpp | 30 ++++-- server/monsters/monster_system_api.cpp | 55 ----------- server/monsters/monster_system_api.hpp | 30 ------ server/rooms/room_system_api.cpp | 55 ----------- server/rooms/room_system_api.hpp | 30 ------ server/triggers/trigger_system_api.cpp | 55 ----------- server/triggers/trigger_system_api.hpp | 30 ------ 17 files changed, 90 insertions(+), 536 deletions(-) delete mode 100644 common/map/map_system_api.cpp delete mode 100644 common/map/map_system_api.hpp delete mode 100644 server/characters/character_system_api.cpp delete mode 100644 server/characters/character_system_api.hpp delete mode 100644 server/monsters/monster_system_api.cpp delete mode 100644 server/monsters/monster_system_api.hpp delete mode 100644 server/rooms/room_system_api.cpp delete mode 100644 server/rooms/room_system_api.hpp delete mode 100644 server/triggers/trigger_system_api.cpp delete mode 100644 server/triggers/trigger_system_api.hpp diff --git a/common/map/map_system_api.cpp b/common/map/map_system_api.cpp deleted file mode 100644 index 7a980c7..0000000 --- a/common/map/map_system_api.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013-2015 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#include "map_system_api.hpp" - -//all map API headers -#include "region_api.hpp" -#include "region_pager_api.hpp" - -//useful "globals" -//... - -//This mimics linit.c to create a nested collection of all map modules. -static const luaL_Reg funcs[] = { - {nullptr, nullptr} -}; - -static const luaL_Reg libs[] = { - {"Region", openRegionAPI}, - {"RegionPager", openRegionPagerAPI}, - {nullptr, nullptr} -}; - -int openMapSystemAPI(lua_State* L) { - //create the table - luaL_newlibtable(L, libs); - - //push the "global" functions - luaL_setfuncs(L, funcs, 0); - - //push the substable - for (const luaL_Reg* lib = libs; lib->func; lib++) { - lib->func(L); - lua_setfield(L, -2, lib->name); - } - return 1; -} \ No newline at end of file diff --git a/common/map/map_system_api.hpp b/common/map/map_system_api.hpp deleted file mode 100644 index c188e18..0000000 --- a/common/map/map_system_api.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013-2015 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#ifndef MAPSYSTEMAPI_HPP_ -#define MAPSYSTEMAPI_APP_ - -#include "lua.hpp" - -#define TORTUGA_MAP_SYSTEM_API "map_system" -LUAMOD_API int openMapSystemAPI(lua_State* L); - -#endif \ No newline at end of file diff --git a/common/map/region_api.hpp b/common/map/region_api.hpp index cf3ef0e..4529f6e 100644 --- a/common/map/region_api.hpp +++ b/common/map/region_api.hpp @@ -24,7 +24,7 @@ #include "lua.hpp" -#define TORTUGA_REGION_NAME "region" +#define TORTUGA_REGION_API "region" LUAMOD_API int openRegionAPI(lua_State* L); #endif diff --git a/common/map/region_pager_api.cpp b/common/map/region_pager_api.cpp index 73ad6e9..fd366db 100644 --- a/common/map/region_pager_api.cpp +++ b/common/map/region_pager_api.cpp @@ -25,6 +25,7 @@ #include "region.hpp" //DOCS: These glue functions simply wrap RegionPagerLua's methods +//NOTE: zero indexing is used here, but not in the region API static int setTile(lua_State* L) { RegionPagerLua* pager = reinterpret_cast(lua_touserdata(L, 1)); diff --git a/common/map/region_pager_api.hpp b/common/map/region_pager_api.hpp index 01b01e8..ed36740 100644 --- a/common/map/region_pager_api.hpp +++ b/common/map/region_pager_api.hpp @@ -24,7 +24,7 @@ #include "lua.hpp" -#define TORTUGA_REGION_PAGER_NAME "region_pager" +#define TORTUGA_REGION_PAGER_API "region_pager" LUAMOD_API int openRegionPagerAPI(lua_State* L); #endif diff --git a/rsc/scripts/map_maker.lua b/rsc/scripts/map_maker.lua index 62e4e06..d24f056 100644 --- a/rsc/scripts/map_maker.lua +++ b/rsc/scripts/map_maker.lua @@ -1,4 +1,4 @@ -local Region = require("map_system").Region +local regionAPI = require("region") local mapMaker = {} @@ -25,38 +25,38 @@ mapMaker.edges.west = -1 function mapMaker.SmoothEdgesSimple(r) --make and pad an array to use local shiftArray = {} - for i = 1, Region.GetWidth(r) do + for i = 1, regionAPI.GetWidth(r) do shiftArray[i] = {} - for j = 1, Region.GetHeight(r) do + for j = 1, regionAPI.GetHeight(r) do shiftArray[i][j] = 0 end end --build the array - for i = 1, Region.GetWidth(r) do - for j = 1, Region.GetHeight(r) do - --if (not region edge) and (west tile < this tile), etc. - if i > 1 and Region.GetTile(r, i - 1, j, 1) < Region.GetTile(r, i, j, 1) then + for i = 1, regionAPI.GetWidth(r) do + for j = 1, regionAPI.GetHeight(r) do + --if (not regionAPI edge) and (west tile < this tile), etc. + if i > 1 and regionAPI.GetTile(r, i - 1, j, 1) < regionAPI.GetTile(r, i, j, 1) then shiftArray[i][j] = shiftArray[i][j] + mapMaker.edges.west end - if j > 1 and Region.GetTile(r, i, j - 1, 1) < Region.GetTile(r, i, j, 1) then + if j > 1 and regionAPI.GetTile(r, i, j - 1, 1) < regionAPI.GetTile(r, i, j, 1) then shiftArray[i][j] = shiftArray[i][j] + mapMaker.edges.north end - if i < Region.GetWidth(r) and Region.GetTile(r, i + 1, j, 1) < Region.GetTile(r, i, j, 1) then + if i < regionAPI.GetWidth(r) and regionAPI.GetTile(r, i + 1, j, 1) < regionAPI.GetTile(r, i, j, 1) then shiftArray[i][j] = shiftArray[i][j] + mapMaker.edges.east end - if j < Region.GetHeight(r) and Region.GetTile(r, i, j + 1, 1) < Region.GetTile(r, i, j, 1) then + if j < regionAPI.GetHeight(r) and regionAPI.GetTile(r, i, j + 1, 1) < regionAPI.GetTile(r, i, j, 1) then shiftArray[i][j] = shiftArray[i][j] + mapMaker.edges.south end end end --finally apply this - for i = 1, Region.GetWidth(r) do - for j = 1, Region.GetHeight(r) do + for i = 1, regionAPI.GetWidth(r) do + for j = 1, regionAPI.GetHeight(r) do if shiftArray[i][j] ~= 0 then - Region.SetTile(r, i, j, 2, Region.GetTile(r, i, j, 1) + shiftArray[i][j]) - Region.SetTile(r, i, j, 1, Region.GetTile(r, i, j, 1) - 3) + regionAPI.SetTile(r, i, j, 2, regionAPI.GetTile(r, i, j, 1) + shiftArray[i][j]) + regionAPI.SetTile(r, i, j, 1, regionAPI.GetTile(r, i, j, 1) - 3) end end end @@ -65,27 +65,27 @@ end --custom generation systems here function mapMaker.DebugIsland(r) --basic distance check for each tile, placing an island around the world origin - for i = 1, Region.GetWidth(r) do - for j = 1, Region.GetHeight(r) do - local dist = mapMaker.Dist(0, 0, i + Region.GetX(r) -1, j + Region.GetY(r) -1) + for i = 1, regionAPI.GetWidth(r) do + for j = 1, regionAPI.GetHeight(r) do + local dist = mapMaker.Dist(0, 0, i + regionAPI.GetX(r) -1, j + regionAPI.GetY(r) -1) if dist < 10 then - Region.SetTile(r, i, j, 1, mapMaker.plains) + regionAPI.SetTile(r, i, j, 1, mapMaker.plains) elseif dist < 12 then - Region.SetTile(r, i, j, 1, mapMaker.sand) + regionAPI.SetTile(r, i, j, 1, mapMaker.sand) else - Region.SetTile(r, i, j, 1, mapMaker.water) - Region.SetSolid(r, i, j, true) + regionAPI.SetTile(r, i, j, 1, mapMaker.water) + regionAPI.SetSolid(r, i, j, true) end end end --examples of the smoothing function NOT working correctly --[[ - for j = 1, Region.GetHeight(r) do - Region.SetTile(r, 3, j, 1, mapMaker.dirt) - Region.SetTile(r, 4, j, 1, mapMaker.dirt) + for j = 1, regionAPI.GetHeight(r) do + regionAPI.SetTile(r, 3, j, 1, mapMaker.dirt) + regionAPI.SetTile(r, 4, j, 1, mapMaker.dirt) - Region.SetTile(r, 10, j, 1, mapMaker.dirt) + regionAPI.SetTile(r, 10, j, 1, mapMaker.dirt) end --]] diff --git a/rsc/scripts/map_saver.lua b/rsc/scripts/map_saver.lua index c5b528b..b28d1bd 100644 --- a/rsc/scripts/map_saver.lua +++ b/rsc/scripts/map_saver.lua @@ -1,14 +1,14 @@ -local Region = require("map_system").Region +local region = require("region") local mapSaver = {} function mapSaver.Load(r) --empty - io.write("map_saver:Load(", Region.GetX(r), ", ", Region.GetY(r), ")\n") + io.write("map_saver:Load(", region.GetX(r), ", ", region.GetY(r), ")\n") end function mapSaver.Save(r) --empty - io.write("map_saver:Save(", Region.GetX(r), ", ", Region.GetY(r), ")\n") + io.write("map_saver:Save(", region.GetX(r), ", ", region.GetY(r), ")\n") end --TODO: (3) create a flexible saving & loading system diff --git a/rsc/scripts/setup_server.lua b/rsc/scripts/setup_server.lua index b69b3b4..b056fa4 100644 --- a/rsc/scripts/setup_server.lua +++ b/rsc/scripts/setup_server.lua @@ -1,87 +1,55 @@ print("Lua script check") +--requirements +roomManagerAPI = require("room_manager") +roomAPI = require("room") + mapMaker = require("map_maker") mapSaver = require("map_saver") -mapSystem = require("map_system") -roomSystem = require("room_system") -characterSystem = require("character_system") -networkSystem = require("network") -triggerSystem = require("trigger_system") - -local function dumpTable(t) - print(t) - for k, v in pairs(t) do - print("",k,v) - end -end --test the room hooks -roomSystem.RoomManager.SetOnCreate(function(room, index) - print("", "Creating room: ", roomSystem.Room.GetName(room), index) - - --called ~60 times per second --- roomSystem.Room.SetOnTick(room, function(room) --- roomSystem.Room.ForEachCharacter(room, function(character) --- print(characterSystem.Character.GetHandle(character)) --- end) - --[[ - local character = characterSystem.CharacterManager.GetCharacter("handle") - if character ~= nil then - --debugging - local originX, originY = characterSystem.Character.GetOrigin(character) - local motionX, motionY = characterSystem.Character.GetMotion(character) - if motionY < 0 then - characterSystem.Character.SetMotion(character, motionX, 0) - networkSystem.PumpCharacterUpdate(character) - print("Sending: ", motionX, motionY) - end - end - --]] --- end) +roomManagerAPI.SetOnCreate(function(room, index) + print("", "Creating room: ", roomAPI.GetName(room), index) end) -roomSystem.RoomManager.SetOnUnload(function(room, index) - print("", "Unloading room: ", roomSystem.Room.GetName(room), index) +roomManagerAPI.SetOnUnload(function(room, index) + print("", "Unloading room: ", roomAPI.GetName(room), index) end) --NOTE: room 0 is the first that the client asks for, therefore it must exist -local overworld, uid = roomSystem.RoomManager.CreateRoom("overworld", "overworld.bmp") -roomSystem.Room.Initialize(overworld, mapSaver.Load, mapSaver.Save, mapMaker.DebugIsland, mapSaver.Save) +local overworld, uid = roomManagerAPI.CreateRoom("overworld", "overworld.bmp") +roomAPI.Initialize(overworld, mapSaver.Load, mapSaver.Save, mapMaker.DebugIsland, mapSaver.Save) --debug: test the trigger system -local pager = roomSystem.Room.GetPager(overworld) -mapSystem.RegionPager.SetTile(pager, 0, 0, 0, mapMaker.dirt) -local triggerMgr = roomSystem.Room.GetTriggerMgr(overworld) ---TODO: (1) What does the trigger script take as a parameter? -triggerSystem.TriggerManager.Create(triggerMgr, "dirt", 0, 0, 0, 0, 32, 32, function(character) - local x, y = characterSystem.Character.GetOrigin(character) - characterSystem.Character.SetOrigin(character, x, y + 128) - networkSystem.PumpCharacterUpdate(character) +--TODO: (0) What userdata type does the trigger script take as a parameter? + +regionPagerAPI = require("region_pager") +triggerManagerAPI = require("trigger_manager") + +function createTrigger(handle, room, x, y, script) + local pager = roomAPI.GetPager(room) + + --place the indicator tile + regionPagerAPI.SetTile(pager, x, y, 0, mapMaker.dirt) + regionPagerAPI.SetTile(pager, x, y, 1, mapMaker.blank) + regionPagerAPI.SetTile(pager, x, y, 2, mapMaker.blank) + + --create the trigger object + triggerManagerAPI.Create( + roomAPI.GetTriggerMgr(room), handle, x, y, + 0, 0, 32, 32, --size of the tiles + script + ) +end + +characterAPI = require("character") +networkAPI = require("network") + +--simple teleporter +createTrigger("trigger 1", overworld, 0, 0, function(character) + local x, y = characterAPI.GetOrigin(character) + characterAPI.SetOrigin(character, x, y + 128) + networkAPI.PumpCharacterUpdate(character) end) ---debugging -function dumpTrigger(t) - local originX, originY = triggerSystem.Trigger.GetOrigin(t) - local bx, by, bw, bh = triggerSystem.Trigger.GetBounds(t) - local s = triggerSystem.Trigger.GetScript(t) - print(triggerSystem.Trigger.GetHandle(t), originX, originY, bx, by, bw, bh, s) -end - -function dumpTable(t) - for k, v in pairs(t) do - print("", k, v) - end -end - ---[[ -triggerMgr = roomSystem.Room.GetTriggerMgr(overworld) -trigger1, uid1 = triggerSystem.TriggerManager.Create(triggerMgr, "handle1") -trigger2, uid2 = triggerSystem.TriggerManager.Create(triggerMgr, "handle2", 30.2, 40.2) -trigger3, uid3 = triggerSystem.TriggerManager.Create(triggerMgr, "handle3", 30.2, 40.2, 0, 16, 32, 32, function() end) - -dumpTrigger(trigger1) -dumpTrigger(trigger2) -dumpTrigger(trigger3) ---]] - print("Finished the lua script") diff --git a/server/characters/character_system_api.cpp b/server/characters/character_system_api.cpp deleted file mode 100644 index bac7893..0000000 --- a/server/characters/character_system_api.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013-2015 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#include "character_system_api.hpp" - -//all character API headers -#include "character_api.hpp" -#include "character_manager_api.hpp" - -//useful "globals" -//... - -//This mimics linit.c to create a nested collection of all character modules. -static const luaL_Reg funcs[] = { - {nullptr, nullptr} -}; - -static const luaL_Reg libs[] = { - {"Character", openCharacterAPI}, - {"CharacterManager", openCharacterManagerAPI}, - {nullptr, nullptr} -}; - -int openCharacterSystemAPI(lua_State* L) { - //create the table - luaL_newlibtable(L, libs); - - //push the "global" functions - luaL_setfuncs(L, funcs, 0); - - //push the substable - for (const luaL_Reg* lib = libs; lib->func; lib++) { - lib->func(L); - lua_setfield(L, -2, lib->name); - } - return 1; -} diff --git a/server/characters/character_system_api.hpp b/server/characters/character_system_api.hpp deleted file mode 100644 index 67b47a7..0000000 --- a/server/characters/character_system_api.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013-2015 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#ifndef CHARACTERSYSTEMAPI_HPP_ -#define CHARACTERSYSTEMAPI_HPP_ - -#include "lua.hpp" - -#define TORTUGA_CHARACTER_SYSTEM_API "character_system" -LUAMOD_API int openCharacterSystemAPI(lua_State* L); - -#endif \ No newline at end of file diff --git a/server/linit.cpp b/server/linit.cpp index 7a83db7..c0552ea 100644 --- a/server/linit.cpp +++ b/server/linit.cpp @@ -37,12 +37,17 @@ #include "lua.hpp" #include "entity_api.hpp" -#include "character_system_api.hpp" -#include "map_system_api.hpp" -#include "monster_system_api.hpp" +#include "character_api.hpp" +#include "character_manager_api.hpp" +#include "region_api.hpp" +#include "region_pager_api.hpp" +#include "monster_api.hpp" +#include "monster_manager_api.hpp" #include "network_api.hpp" -#include "room_system_api.hpp" -#include "trigger_system_api.hpp" +#include "room_api.hpp" +#include "room_manager_api.hpp" +#include "trigger_api.hpp" +#include "trigger_manager_api.hpp" //these libs are loaded by lua.c and are readily available to any Lua program static const luaL_Reg loadedlibs[] = { @@ -63,12 +68,17 @@ static const luaL_Reg loadedlibs[] = { //these libs are preloaded and must be required before used static const luaL_Reg preloadedlibs[] = { {TORTUGA_ENTITY_API, openEntityAPI}, //required by derived classes - {TORTUGA_CHARACTER_SYSTEM_API, openCharacterSystemAPI}, - {TORTUGA_MAP_SYSTEM_API, openMapSystemAPI}, - {TORTUGA_MONSTER_SYSTEM_API, openMonsterSystemAPI}, + {TORTUGA_CHARACTER_API, openCharacterAPI}, + {TORTUGA_CHARACTER_MANAGER_API, openCharacterManagerAPI}, + {TORTUGA_MONSTER_API, openMonsterAPI}, + {TORTUGA_MONSTER_MANAGER_API, openMonsterManagerAPI}, {TORTUGA_NETWORK_API, openNetworkAPI}, - {TORTUGA_ROOM_SYSTEM_API, openRoomSystemAPI}, - {TORTUGA_TRIGGER_SYSTEM_API, openTriggerSystemAPI}, + {TORTUGA_REGION_API, openRegionAPI}, + {TORTUGA_REGION_PAGER_API, openRegionPagerAPI}, + {TORTUGA_ROOM_API, openRoomAPI}, + {TORTUGA_ROOM_MANAGER_API, openRoomManagerAPI}, + {TORTUGA_TRIGGER_API, openTriggerAPI}, + {TORTUGA_TRIGGER_MANAGER_API, openTriggerManagerAPI}, {NULL, NULL} }; diff --git a/server/monsters/monster_system_api.cpp b/server/monsters/monster_system_api.cpp deleted file mode 100644 index 2ecbf71..0000000 --- a/server/monsters/monster_system_api.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013-2015 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#include "monster_system_api.hpp" - -//all monster API headers -#include "monster_api.hpp" -#include "monster_manager_api.hpp" - -//useful "globals" -//... - -//This mimics linit.c to create a nested collection of all monster modules. -static const luaL_Reg funcs[] = { - {nullptr, nullptr} -}; - -static const luaL_Reg libs[] = { - {"Monster", openMonsterAPI}, - {"MonsterManager", openMonsterManagerAPI}, - {nullptr, nullptr} -}; - -int openMonsterSystemAPI(lua_State* L) { - //create the table - luaL_newlibtable(L, libs); - - //push the "global" functions - luaL_setfuncs(L, funcs, 0); - - //push the substable - for (const luaL_Reg* lib = libs; lib->func; lib++) { - lib->func(L); - lua_setfield(L, -2, lib->name); - } - return 1; -} diff --git a/server/monsters/monster_system_api.hpp b/server/monsters/monster_system_api.hpp deleted file mode 100644 index 843a5e7..0000000 --- a/server/monsters/monster_system_api.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013-2015 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#ifndef MONSTERSYSTEMAPI_HPP_ -#define MONSTERSYSTEMAPI_HPP_ - -#include "lua.hpp" - -#define TORTUGA_MONSTER_SYSTEM_API "monster_system" -LUAMOD_API int openMonsterSystemAPI(lua_State* L); - -#endif \ No newline at end of file diff --git a/server/rooms/room_system_api.cpp b/server/rooms/room_system_api.cpp deleted file mode 100644 index 0d6fa1a..0000000 --- a/server/rooms/room_system_api.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013-2015 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#include "room_system_api.hpp" - -//all room API headers -#include "room_api.hpp" -#include "room_manager_api.hpp" - -//useful "globals" -//... - -//This mimics linit.c to create a nested collection of all room modules. -static const luaL_Reg funcs[] = { - {nullptr, nullptr} -}; - -static const luaL_Reg libs[] = { - {"Room", openRoomAPI}, - {"RoomManager", openRoomManagerAPI}, - {nullptr, nullptr} -}; - -int openRoomSystemAPI(lua_State* L) { - //create the table - luaL_newlibtable(L, libs); - - //push the "global" functions - luaL_setfuncs(L, funcs, 0); - - //push the substable - for (const luaL_Reg* lib = libs; lib->func; lib++) { - lib->func(L); - lua_setfield(L, -2, lib->name); - } - return 1; -} diff --git a/server/rooms/room_system_api.hpp b/server/rooms/room_system_api.hpp deleted file mode 100644 index 29ec4d7..0000000 --- a/server/rooms/room_system_api.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013-2015 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#ifndef ROOMSYSTEMAPI_HPP_ -#define ROOMSYSTEMAPI_HPP_ - -#include "lua.hpp" - -#define TORTUGA_ROOM_SYSTEM_API "room_system" -LUAMOD_API int openRoomSystemAPI(lua_State* L); - -#endif \ No newline at end of file diff --git a/server/triggers/trigger_system_api.cpp b/server/triggers/trigger_system_api.cpp deleted file mode 100644 index 2c7a231..0000000 --- a/server/triggers/trigger_system_api.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013-2015 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#include "trigger_system_api.hpp" - -//all trigger API headers -#include "trigger_api.hpp" -#include "trigger_manager_api.hpp" - -//useful "globals" -//... - -//This mimics linit.c to create a nested collection of all trigger modules. -static const luaL_Reg funcs[] = { - {nullptr, nullptr} -}; - -static const luaL_Reg libs[] = { - {"Trigger", openTriggerAPI}, - {"TriggerManager", openTriggerManagerAPI}, - {nullptr, nullptr} -}; - -int openTriggerSystemAPI(lua_State* L) { - //create the table - luaL_newlibtable(L, libs); - - //push the "global" functions - luaL_setfuncs(L, funcs, 0); - - //push the substable - for (const luaL_Reg* lib = libs; lib->func; lib++) { - lib->func(L); - lua_setfield(L, -2, lib->name); - } - return 1; -} diff --git a/server/triggers/trigger_system_api.hpp b/server/triggers/trigger_system_api.hpp deleted file mode 100644 index d917c9d..0000000 --- a/server/triggers/trigger_system_api.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013-2015 - * - * This software is provided 'as-is', without any express or implied - * warranty. In no event will the authors be held liable for any damages - * arising from the use of this software. - * - * Permission is granted to anyone to use this software for any purpose, - * including commercial applications, and to alter it and redistribute it - * freely, subject to the following restrictions: - * - * 1. The origin of this software must not be misrepresented; you must not - * claim that you wrote the original software. If you use this software - * in a product, an acknowledgment in the product documentation would be - * appreciated but is not required. - * - * 2. Altered source versions must be plainly marked as such, and must not be - * misrepresented as being the original software. - * - * 3. This notice may not be removed or altered from any source - * distribution. -*/ -#ifndef TRIGGERSYSTEMAPI_HPP_ -#define TRIGGERSYSTEMAPI_HPP_ - -#include "lua.hpp" - -#define TORTUGA_TRIGGER_SYSTEM_API "trigger_system" -LUAMOD_API int openTriggerSystemAPI(lua_State* L); - -#endif \ No newline at end of file