Created '*_data.cpp' files, modified API files a bit
This commit is contained in:
@@ -26,8 +26,30 @@
|
||||
#include "region_pager_api.hpp"
|
||||
#include "tile_sheet.hpp"
|
||||
|
||||
/* This mimics linit.c to create a nested collection of all map modules.
|
||||
*/
|
||||
//useful "globals"
|
||||
static int getRegionWidth(lua_State* L) {
|
||||
lua_pushinteger(L, REGION_WIDTH);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int getRegionHeight(lua_State* L) {
|
||||
lua_pushinteger(L, REGION_HEIGHT);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int getRegionDepth(lua_State* L) {
|
||||
lua_pushinteger(L, REGION_DEPTH);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//This mimics linit.c to create a nested collection of all map modules.
|
||||
static const luaL_Reg mapfuncs[] = {
|
||||
//synonyms
|
||||
{"GetRegionWidth", getRegionWidth},
|
||||
{"GetRegionHeight", getRegionHeight},
|
||||
{"GetRegionDepth", getRegionDepth},
|
||||
{nullptr, nullptr}
|
||||
};
|
||||
|
||||
static const luaL_Reg maplibs[] = {
|
||||
{"Region", openRegionAPI},
|
||||
@@ -37,7 +59,13 @@ static const luaL_Reg maplibs[] = {
|
||||
};
|
||||
|
||||
int openMapSystemAPI(lua_State* L) {
|
||||
//create the table
|
||||
luaL_newlibtable(L, maplibs);
|
||||
|
||||
//push the "global" functions
|
||||
luaL_setfuncs(L, mapfuncs, 0);
|
||||
|
||||
//push the substable
|
||||
for (const luaL_Reg* lib = maplibs; lib->func; lib++) {
|
||||
lua_pushcfunction(L, lib->func);
|
||||
lua_setfield(L, -2, lib->name);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/* Copyright: (c) Kayne Ruse 2014
|
||||
*
|
||||
* 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 "account_data.hpp"
|
||||
|
||||
int AccountData::SetClientIndex(int i) {
|
||||
return clientIndex = i;
|
||||
}
|
||||
|
||||
int AccountData::GetClientIndex() {
|
||||
return clientIndex;
|
||||
}
|
||||
|
||||
std::string AccountData::SetUsername(std::string s) {
|
||||
return username = s;
|
||||
}
|
||||
|
||||
std::string AccountData::GetUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
bool AccountData::GetBlackListed() {
|
||||
return blackListed;
|
||||
}
|
||||
|
||||
bool AccountData::GetWhiteListed() {
|
||||
return whiteListed;
|
||||
}
|
||||
|
||||
bool AccountData::GetModerator() {
|
||||
return mod;
|
||||
}
|
||||
|
||||
bool AccountData::GetAdministrator() {
|
||||
return admin;
|
||||
}
|
||||
@@ -30,17 +30,17 @@ public:
|
||||
~AccountData() = default;
|
||||
|
||||
//accessors and mutators
|
||||
int SetClientIndex(int i) { return clientIndex = i; }
|
||||
int GetClientIndex() { return clientIndex; }
|
||||
int SetClientIndex(int i);
|
||||
int GetClientIndex();
|
||||
|
||||
std::string SetUsername(std::string s) { return username = s; }
|
||||
std::string GetUsername() { return username; }
|
||||
std::string SetUsername(std::string s);
|
||||
std::string GetUsername();
|
||||
|
||||
//database stuff
|
||||
bool GetBlackListed() { return blackListed; }
|
||||
bool GetWhiteListed() { return whiteListed; }
|
||||
bool GetModerator() { return mod; }
|
||||
bool GetAdministrator() { return admin; }
|
||||
bool GetBlackListed();
|
||||
bool GetWhiteListed();
|
||||
bool GetModerator();
|
||||
bool GetAdministrator();
|
||||
|
||||
private:
|
||||
friend class AccountManager;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/* Copyright: (c) Kayne Ruse 2014
|
||||
*
|
||||
* 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_data.hpp"
|
||||
|
||||
Statistics* CharacterData::GetBaseStats() {
|
||||
return &baseStats;
|
||||
}
|
||||
|
||||
int CharacterData::GetOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
std::string CharacterData::GetHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
std::string CharacterData::GetAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
@@ -37,12 +37,12 @@ public:
|
||||
~CharacterData() = default;
|
||||
|
||||
//accessors and mutators
|
||||
Statistics* GetBaseStats() { return &baseStats; }
|
||||
Statistics* GetBaseStats();
|
||||
|
||||
//database stuff
|
||||
int GetOwner() { return owner; }
|
||||
std::string GetHandle() { return handle; }
|
||||
std::string GetAvatar() { return avatar; }
|
||||
int GetOwner();
|
||||
std::string GetHandle();
|
||||
std::string GetAvatar();
|
||||
|
||||
private:
|
||||
friend class CharacterManager;
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/* Copyright: (c) Kayne Ruse 2014
|
||||
*
|
||||
* 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 "entity.hpp"
|
||||
|
||||
int Entity::SetEntityIndex(int i) {
|
||||
return entityIndex = i;
|
||||
}
|
||||
|
||||
int Entity::SetRoomIndex(int i) {
|
||||
return roomIndex = i;
|
||||
}
|
||||
|
||||
Vector2 Entity::SetOrigin(Vector2 v) {
|
||||
return origin = v;
|
||||
}
|
||||
|
||||
Vector2 Entity::SetMotion(Vector2 v) {
|
||||
return motion = v;
|
||||
}
|
||||
int Entity::GetEntityIndex() {
|
||||
return entityIndex;
|
||||
}
|
||||
|
||||
int Entity::GetRoomIndex() {
|
||||
return roomIndex;
|
||||
}
|
||||
|
||||
Vector2 Entity::GetOrigin() {
|
||||
return origin;
|
||||
}
|
||||
|
||||
Vector2 Entity::GetMotion() {
|
||||
return motion;
|
||||
}
|
||||
@@ -28,15 +28,15 @@
|
||||
class Entity {
|
||||
public:
|
||||
//accessors & mutators
|
||||
int SetEntityIndex(int i) { return entityIndex = i; }
|
||||
int SetRoomIndex(int i) { return roomIndex = i; }
|
||||
Vector2 SetOrigin(Vector2 v) { return origin = v; }
|
||||
Vector2 SetMotion(Vector2 v) { return motion = v; }
|
||||
int SetEntityIndex(int i);
|
||||
int SetRoomIndex(int i);
|
||||
Vector2 SetOrigin(Vector2 v);
|
||||
Vector2 SetMotion(Vector2 v);
|
||||
|
||||
int GetEntityIndex() { return entityIndex; }
|
||||
int GetRoomIndex() { return roomIndex; }
|
||||
Vector2 GetOrigin() { return origin; }
|
||||
Vector2 GetMotion() { return motion; }
|
||||
int GetEntityIndex();
|
||||
int GetRoomIndex();
|
||||
Vector2 GetOrigin();
|
||||
Vector2 GetMotion();
|
||||
|
||||
protected:
|
||||
Entity() = default;
|
||||
|
||||
@@ -27,6 +27,10 @@ OUT=$(addprefix $(OUTDIR)/,server)
|
||||
all: $(OUT)
|
||||
$(MAKE) -C accounts
|
||||
$(MAKE) -C characters
|
||||
$(MAKE) -C clients
|
||||
$(MAKE) -C doors
|
||||
$(MAKE) -C entities
|
||||
$(MAKE) -C monsters
|
||||
$(MAKE) -C rooms
|
||||
$(MAKE) -C server_utilities
|
||||
# $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
|
||||
|
||||
@@ -59,10 +59,10 @@ public:
|
||||
std::map<int, MonsterData>* GetContainer() override;
|
||||
|
||||
//hooks
|
||||
sqlite3* SetDatabase(sqlite3* db) override;
|
||||
sqlite3* GetDatabase() override;
|
||||
lua_State* SetLuaState(lua_State* L) override;
|
||||
lua_State* GetLuaState() override;
|
||||
sqlite3* SetDatabase(sqlite3* db);
|
||||
sqlite3* GetDatabase();
|
||||
lua_State* SetLuaState(lua_State* L);
|
||||
lua_State* GetLuaState();
|
||||
|
||||
private:
|
||||
friend Singleton<MonsterManager>;
|
||||
|
||||
@@ -23,12 +23,6 @@
|
||||
|
||||
#include "room_data.hpp"
|
||||
|
||||
static int getPager(lua_State* L) {
|
||||
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
||||
lua_pushlightuserdata(L, reinterpret_cast<void*>(room->GetPager()) );
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int setRoomName(lua_State* L) {
|
||||
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
||||
room->SetRoomName(lua_tostring(L, 2));
|
||||
@@ -53,6 +47,14 @@ static int getTilesetName(lua_State* L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int getPager(lua_State* L) {
|
||||
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
||||
lua_pushlightuserdata(L, reinterpret_cast<void*>(room->GetPager()) );
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const luaL_Reg roomLib[] = {
|
||||
{"GetPager",getPager},
|
||||
{"SetRoomName", setRoomName},
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "lua.hpp"
|
||||
#endif
|
||||
|
||||
#define TORTUGA_ROOM_NAME "Room"
|
||||
#define TORTUGA_ROOM_NAME "room"
|
||||
LUAMOD_API int openRoomAPI(lua_State* L);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -21,3 +21,42 @@
|
||||
*/
|
||||
#include "room_data.hpp"
|
||||
|
||||
std::string RoomData::SetRoomName(std::string s) {
|
||||
return roomName = s;
|
||||
}
|
||||
|
||||
std::string RoomData::GetRoomName() {
|
||||
return roomName;
|
||||
}
|
||||
|
||||
std::string RoomData::SetTilesetName(std::string s) {
|
||||
return tilesetName = s;
|
||||
}
|
||||
|
||||
std::string RoomData::GetTilesetName() {
|
||||
return tilesetName;
|
||||
}
|
||||
|
||||
RegionPagerLua* RoomData::GetPager() {
|
||||
return &pager;
|
||||
}
|
||||
|
||||
std::list<Entity*>* RoomData::GetEntityList() {
|
||||
return &entityList;
|
||||
}
|
||||
|
||||
int RoomData::SetLoadReference(int i) {
|
||||
return loadRef = i;
|
||||
}
|
||||
|
||||
int RoomData::GetLoadReference() {
|
||||
return loadRef;
|
||||
}
|
||||
|
||||
int RoomData::SetUnloadReference(int i) {
|
||||
return unloadRef = i;
|
||||
}
|
||||
|
||||
int RoomData::GetUnloadReference() {
|
||||
return unloadRef;
|
||||
}
|
||||
@@ -40,21 +40,29 @@ public:
|
||||
~RoomData() = default;
|
||||
|
||||
//accessors and mutators
|
||||
RegionPagerLua* GetPager() { return &pager; }
|
||||
std::string SetRoomName(std::string s);
|
||||
std::string GetRoomName();
|
||||
|
||||
std::string SetRoomName(std::string s) { return roomName = s; }
|
||||
std::string GetRoomName() { return roomName; }
|
||||
std::string SetTilesetName(std::string s);
|
||||
std::string GetTilesetName();
|
||||
|
||||
std::string SetTilesetName(std::string s) { return tilesetName = s; }
|
||||
std::string GetTilesetName() { return tilesetName; }
|
||||
RegionPagerLua* GetPager();
|
||||
std::list<Entity*>* GetEntityList();
|
||||
|
||||
//hooks
|
||||
int SetLoadReference(int);
|
||||
int GetLoadReference();
|
||||
int SetUnloadReference(int);
|
||||
int GetUnloadReference();
|
||||
|
||||
private:
|
||||
friend class RoomManager;
|
||||
|
||||
//members
|
||||
RegionPagerLua pager;
|
||||
std::string roomName;
|
||||
std::string tilesetName;
|
||||
|
||||
RegionPagerLua pager;
|
||||
std::list<Entity*> entityList;
|
||||
|
||||
//lua references
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "lua.hpp"
|
||||
#endif
|
||||
|
||||
#define TORTUGA_ROOM_MANAGER_NAME "RoomManager"
|
||||
#define TORTUGA_ROOM_MANAGER_NAME "room_manager"
|
||||
LUAMOD_API int openRoomManagerAPI(lua_State* L);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user