Created '*_data.cpp' files, modified API files a bit
This commit is contained in:
@@ -26,8 +26,30 @@
|
|||||||
#include "region_pager_api.hpp"
|
#include "region_pager_api.hpp"
|
||||||
#include "tile_sheet.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[] = {
|
static const luaL_Reg maplibs[] = {
|
||||||
{"Region", openRegionAPI},
|
{"Region", openRegionAPI},
|
||||||
@@ -37,7 +59,13 @@ static const luaL_Reg maplibs[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int openMapSystemAPI(lua_State* L) {
|
int openMapSystemAPI(lua_State* L) {
|
||||||
|
//create the table
|
||||||
luaL_newlibtable(L, maplibs);
|
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++) {
|
for (const luaL_Reg* lib = maplibs; lib->func; lib++) {
|
||||||
lua_pushcfunction(L, lib->func);
|
lua_pushcfunction(L, lib->func);
|
||||||
lua_setfield(L, -2, lib->name);
|
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;
|
~AccountData() = default;
|
||||||
|
|
||||||
//accessors and mutators
|
//accessors and mutators
|
||||||
int SetClientIndex(int i) { return clientIndex = i; }
|
int SetClientIndex(int i);
|
||||||
int GetClientIndex() { return clientIndex; }
|
int GetClientIndex();
|
||||||
|
|
||||||
std::string SetUsername(std::string s) { return username = s; }
|
std::string SetUsername(std::string s);
|
||||||
std::string GetUsername() { return username; }
|
std::string GetUsername();
|
||||||
|
|
||||||
//database stuff
|
//database stuff
|
||||||
bool GetBlackListed() { return blackListed; }
|
bool GetBlackListed();
|
||||||
bool GetWhiteListed() { return whiteListed; }
|
bool GetWhiteListed();
|
||||||
bool GetModerator() { return mod; }
|
bool GetModerator();
|
||||||
bool GetAdministrator() { return admin; }
|
bool GetAdministrator();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class AccountManager;
|
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;
|
~CharacterData() = default;
|
||||||
|
|
||||||
//accessors and mutators
|
//accessors and mutators
|
||||||
Statistics* GetBaseStats() { return &baseStats; }
|
Statistics* GetBaseStats();
|
||||||
|
|
||||||
//database stuff
|
//database stuff
|
||||||
int GetOwner() { return owner; }
|
int GetOwner();
|
||||||
std::string GetHandle() { return handle; }
|
std::string GetHandle();
|
||||||
std::string GetAvatar() { return avatar; }
|
std::string GetAvatar();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class CharacterManager;
|
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 {
|
class Entity {
|
||||||
public:
|
public:
|
||||||
//accessors & mutators
|
//accessors & mutators
|
||||||
int SetEntityIndex(int i) { return entityIndex = i; }
|
int SetEntityIndex(int i);
|
||||||
int SetRoomIndex(int i) { return roomIndex = i; }
|
int SetRoomIndex(int i);
|
||||||
Vector2 SetOrigin(Vector2 v) { return origin = v; }
|
Vector2 SetOrigin(Vector2 v);
|
||||||
Vector2 SetMotion(Vector2 v) { return motion = v; }
|
Vector2 SetMotion(Vector2 v);
|
||||||
|
|
||||||
int GetEntityIndex() { return entityIndex; }
|
int GetEntityIndex();
|
||||||
int GetRoomIndex() { return roomIndex; }
|
int GetRoomIndex();
|
||||||
Vector2 GetOrigin() { return origin; }
|
Vector2 GetOrigin();
|
||||||
Vector2 GetMotion() { return motion; }
|
Vector2 GetMotion();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Entity() = default;
|
Entity() = default;
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ OUT=$(addprefix $(OUTDIR)/,server)
|
|||||||
all: $(OUT)
|
all: $(OUT)
|
||||||
$(MAKE) -C accounts
|
$(MAKE) -C accounts
|
||||||
$(MAKE) -C characters
|
$(MAKE) -C characters
|
||||||
|
$(MAKE) -C clients
|
||||||
|
$(MAKE) -C doors
|
||||||
|
$(MAKE) -C entities
|
||||||
|
$(MAKE) -C monsters
|
||||||
$(MAKE) -C rooms
|
$(MAKE) -C rooms
|
||||||
$(MAKE) -C server_utilities
|
$(MAKE) -C server_utilities
|
||||||
# $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
|
# $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
|
||||||
|
|||||||
@@ -59,10 +59,10 @@ public:
|
|||||||
std::map<int, MonsterData>* GetContainer() override;
|
std::map<int, MonsterData>* GetContainer() override;
|
||||||
|
|
||||||
//hooks
|
//hooks
|
||||||
sqlite3* SetDatabase(sqlite3* db) override;
|
sqlite3* SetDatabase(sqlite3* db);
|
||||||
sqlite3* GetDatabase() override;
|
sqlite3* GetDatabase();
|
||||||
lua_State* SetLuaState(lua_State* L) override;
|
lua_State* SetLuaState(lua_State* L);
|
||||||
lua_State* GetLuaState() override;
|
lua_State* GetLuaState();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend Singleton<MonsterManager>;
|
friend Singleton<MonsterManager>;
|
||||||
|
|||||||
@@ -23,12 +23,6 @@
|
|||||||
|
|
||||||
#include "room_data.hpp"
|
#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) {
|
static int setRoomName(lua_State* L) {
|
||||||
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
|
||||||
room->SetRoomName(lua_tostring(L, 2));
|
room->SetRoomName(lua_tostring(L, 2));
|
||||||
@@ -53,6 +47,14 @@ static int getTilesetName(lua_State* L) {
|
|||||||
return 1;
|
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[] = {
|
static const luaL_Reg roomLib[] = {
|
||||||
{"GetPager",getPager},
|
{"GetPager",getPager},
|
||||||
{"SetRoomName", setRoomName},
|
{"SetRoomName", setRoomName},
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
#include "lua.hpp"
|
#include "lua.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TORTUGA_ROOM_NAME "Room"
|
#define TORTUGA_ROOM_NAME "room"
|
||||||
LUAMOD_API int openRoomAPI(lua_State* L);
|
LUAMOD_API int openRoomAPI(lua_State* L);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -21,3 +21,42 @@
|
|||||||
*/
|
*/
|
||||||
#include "room_data.hpp"
|
#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;
|
~RoomData() = default;
|
||||||
|
|
||||||
//accessors and mutators
|
//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 SetTilesetName(std::string s);
|
||||||
std::string GetRoomName() { return roomName; }
|
std::string GetTilesetName();
|
||||||
|
|
||||||
std::string SetTilesetName(std::string s) { return tilesetName = s; }
|
RegionPagerLua* GetPager();
|
||||||
std::string GetTilesetName() { return tilesetName; }
|
std::list<Entity*>* GetEntityList();
|
||||||
|
|
||||||
|
//hooks
|
||||||
|
int SetLoadReference(int);
|
||||||
|
int GetLoadReference();
|
||||||
|
int SetUnloadReference(int);
|
||||||
|
int GetUnloadReference();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class RoomManager;
|
friend class RoomManager;
|
||||||
|
|
||||||
//members
|
//members
|
||||||
RegionPagerLua pager;
|
|
||||||
std::string roomName;
|
std::string roomName;
|
||||||
std::string tilesetName;
|
std::string tilesetName;
|
||||||
|
|
||||||
|
RegionPagerLua pager;
|
||||||
std::list<Entity*> entityList;
|
std::list<Entity*> entityList;
|
||||||
|
|
||||||
//lua references
|
//lua references
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
#include "lua.hpp"
|
#include "lua.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TORTUGA_ROOM_MANAGER_NAME "RoomManager"
|
#define TORTUGA_ROOM_MANAGER_NAME "room_manager"
|
||||||
LUAMOD_API int openRoomManagerAPI(lua_State* L);
|
LUAMOD_API int openRoomManagerAPI(lua_State* L);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
TODO: client_manager.cpp
|
TODO: client_manager.cpp
|
||||||
TODO: door_manager.cpp
|
TODO: door_manager.cpp
|
||||||
TODO: monster_manager.cpp
|
TODO: monster_manager.cpp
|
||||||
|
TODO: *_data.cpp
|
||||||
|
TODO: reduce friendships
|
||||||
|
|
||||||
TODO: I need a better way to handle the statistics
|
TODO: I need a better way to handle the statistics
|
||||||
TODO: Fix shoddy movement
|
TODO: Fix shoddy movement
|
||||||
|
|||||||
Reference in New Issue
Block a user