Merge branch 'rebuild' into develop, read more

This branch was mostly used for streamlining the code after not seeing it
for a week. It's quite surprising what you realize after taking a break
for a while.
This commit is contained in:
Kayne Ruse
2014-07-03 02:26:42 +10:00
63 changed files with 216 additions and 894 deletions
@@ -28,13 +28,9 @@ void CharacterData::Update(double delta) {
else if (motion != 0) { else if (motion != 0) {
origin += motion * delta; origin += motion * delta;
} }
#ifdef GRAPHICS
sprite.Update(delta); sprite.Update(delta);
#endif
} }
#ifdef GRAPHICS
void CharacterData::DrawTo(SDL_Surface* const dest, int camX, int camY) { void CharacterData::DrawTo(SDL_Surface* const dest, int camX, int camY) {
sprite.DrawTo(dest, origin.x - camX, origin.y - camY); sprite.DrawTo(dest, origin.x - camX, origin.y - camY);
} }
@@ -63,5 +59,3 @@ void CharacterData::CorrectSprite() {
sprite.SetXIndex(0); sprite.SetXIndex(0);
} }
} }
#endif
@@ -22,36 +22,33 @@
#ifndef CHARACTERDATA_HPP_ #ifndef CHARACTERDATA_HPP_
#define CHARACTERDATA_HPP_ #define CHARACTERDATA_HPP_
//components
#include "character_defines.hpp"
#include "vector2.hpp" #include "vector2.hpp"
#include "statistics.hpp" #include "statistics.hpp"
//graphics //graphics
#ifdef GRAPHICS #include "sprite_sheet.hpp"
#include "sprite_sheet.hpp"
#endif
//std namespace //std namespace
#include <string> #include <string>
#include <cmath> #include <cmath>
//the speeds that the characters move //TODO: encapsulate this and the server version
constexpr double CHARACTER_WALKING_SPEED = 140.0;
constexpr double CHARACTER_WALKING_MOD = 1.0/sqrt(2.0);
//the bounding boxes for the characters
constexpr double CHARACTER_BOUNDS_WIDTH = 32.0;
constexpr double CHARACTER_BOUNDS_HEIGHT = 32.0;
struct CharacterData { struct CharacterData {
//metadata //metadata
int owner; int owner;
std::string handle; std::string handle;
std::string avatar; std::string avatar;
//members
SpriteSheet sprite;
//world position //world position
int roomIndex = 0; int roomIndex = 0;
Vector2 origin = {0.0,0.0}; Vector2 origin = {0.0,0.0};
Vector2 motion = {0.0,0.0}; Vector2 motion = {0.0,0.0};
Vector2 bounds = {0.0,0.0};
//base statistics //base statistics
Statistics stats; Statistics stats;
@@ -60,17 +57,12 @@ struct CharacterData {
//methods //methods
void Update(double delta); void Update(double delta);
#ifdef GRAPHICS
void DrawTo(SDL_Surface* const, int camX, int camY); void DrawTo(SDL_Surface* const, int camX, int camY);
void CorrectSprite(); void CorrectSprite();
#endif
//active gameplay members //active gameplay members
//NOTE: these are lost when unloaded //NOTE: these are lost when unloaded
#ifdef GRAPHICS
Vector2 bounds = {0.0,0.0};
SpriteSheet sprite;
#endif
bool inCombat = false; bool inCombat = false;
int atbGauge = 0; int atbGauge = 0;
//TODO: stored command //TODO: stored command
+55 -5
View File
@@ -25,6 +25,7 @@
#include <stdexcept> #include <stdexcept>
#include <chrono> #include <chrono>
#include <iostream>
//------------------------- //-------------------------
//Scene headers //Scene headers
@@ -44,24 +45,71 @@
//------------------------- //-------------------------
void ClientApplication::Init(int argc, char** argv) { void ClientApplication::Init(int argc, char** argv) {
std::cout << "Beginning " << argv[0] << std::endl;
//load the prerequisites //load the prerequisites
config.Load("rsc\\config.cfg"); config.Load("rsc\\config.cfg");
//-------------------------
//Initialize the APIs
//-------------------------
//initialize SDL //initialize SDL
if (SDL_Init(SDL_INIT_VIDEO)) { if (SDL_Init(SDL_INIT_VIDEO)) {
throw(std::runtime_error("Failed to initialize SDL")); throw(std::runtime_error("Failed to initialize SDL"));
} }
int w = config.Int("client.screen.w"); std::cout << "Initialized SDL" << std::endl;
int h = config.Int("client.screen.h");
int f = config.Bool("client.screen.f") ? SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN : SDL_HWSURFACE|SDL_DOUBLEBUF;
BaseScene::SetScreen(w ? w : 800, h ? h : 600, 0, f);
//initialize SDL_net //initialize SDL_net
if (SDLNet_Init()) { if (SDLNet_Init()) {
throw(std::runtime_error("Failed to initialize SDL_net")); throw(std::runtime_error("Failed to initialize SDL_net"));
} }
network.Open(0); network.Open(0);
std::cout << "Initialized SDL_net" << std::endl;
//-------------------------
//Setup the screen
//-------------------------
int w = config.Int("client.screen.w");
int h = config.Int("client.screen.h");
int f = config.Bool("client.screen.f") ? SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN : SDL_HWSURFACE|SDL_DOUBLEBUF;
BaseScene::SetScreen(w ? w : 800, h ? h : 600, 0, f);
std::cout << "Initialized the screen" << std::endl;
//-------------------------
//debug output
//-------------------------
//TODO: enable/disable these with a switch
#define DEBUG_OUTPUT_VAR(x) std::cout << "\t" << #x << ": " << x << std::endl;
std::cout << "Internal sizes:" << std::endl;
DEBUG_OUTPUT_VAR(sizeof(Region::type_t));
DEBUG_OUTPUT_VAR(sizeof(Region));
DEBUG_OUTPUT_VAR(REGION_WIDTH);
DEBUG_OUTPUT_VAR(REGION_HEIGHT);
DEBUG_OUTPUT_VAR(REGION_DEPTH);
DEBUG_OUTPUT_VAR(REGION_SOLID_FOOTPRINT);
DEBUG_OUTPUT_VAR(REGION_FOOTPRINT);
DEBUG_OUTPUT_VAR(PACKET_BUFFER_SIZE);
DEBUG_OUTPUT_VAR(MAX_PACKET_SIZE);
#undef DEBUG_OUTPUT_VAR
//-------------------------
//finalize the startup
//-------------------------
std::cout << "Startup completed successfully" << std::endl;
//-------------------------
//debugging
//-------------------------
//...
} }
void ClientApplication::Proc() { void ClientApplication::Proc() {
@@ -100,9 +148,11 @@ void ClientApplication::Proc() {
} }
void ClientApplication::Quit() { void ClientApplication::Quit() {
std::cout << "Shutting down" << std::endl;
network.Close(); network.Close();
SDLNet_Quit(); SDLNet_Quit();
SDL_Quit(); SDL_Quit();
std::cout << "Clean exit" << std::endl;
} }
//------------------------- //-------------------------
@@ -23,31 +23,19 @@
#define COMBATDATA_HPP_ #define COMBATDATA_HPP_
#include "vector2.hpp" #include "vector2.hpp"
#include "combat_defines.hpp"
//gameplay members //gameplay members
#include "character_data.hpp" #include "character_data.hpp"
#include "enemy_data.hpp" #include "enemy_data.hpp"
//graphics
#ifdef GRAPHICS
#include "sprite_sheet.hpp"
#endif
//std namespace //std namespace
#include <chrono> #include <chrono>
#include <array> #include <array>
#include <utility> #include <utility>
#define COMBAT_MAX_CHARACTERS 12 //NOTE: This is a placeholder, since it'd break to client too much to remove it
#define COMBAT_MAX_ENEMIES 12
struct CombatData { struct CombatData {
enum class Terrain {
//TODO: types of combat terrains
NONE = 0,
GRASSLANDS,
};
typedef std::chrono::steady_clock Clock; typedef std::chrono::steady_clock Clock;
std::array<CharacterData, COMBAT_MAX_CHARACTERS> characterArray; std::array<CharacterData, COMBAT_MAX_CHARACTERS> characterArray;
@@ -60,11 +48,6 @@ struct CombatData {
//time interval //time interval
Clock::time_point lastTick = Clock::now(); Clock::time_point lastTick = Clock::now();
//graphics
#ifdef GRAPHICS
SpriteSheet sprite;
#endif
}; };
#endif #endif
@@ -25,14 +25,10 @@
#include "vector2.hpp" #include "vector2.hpp"
#include "statistics.hpp" #include "statistics.hpp"
//graphics
#ifdef GRAPHICS
#include "sprite_sheet.hpp"
#endif
//std namespace //std namespace
#include <string> #include <string>
//NOTE: This is a placeholder, since it'd break to client too much to remove it
struct EnemyData { struct EnemyData {
//metadata //metadata
std::string handle; std::string handle;
@@ -45,11 +41,6 @@ struct EnemyData {
//active gameplay members //active gameplay members
//NOTE: these are lost when unloaded //NOTE: these are lost when unloaded
#ifdef GRAPHICS
SpriteSheet sprite;
Vector2 origin = {0.0,0.0};
Vector2 bounds = {0.0,0.0};
#endif
int tableIndex; int tableIndex;
int atbGauge = 0; int atbGauge = 0;
}; };
-2
View File
@@ -27,7 +27,6 @@
using namespace std; using namespace std;
int main(int argc, char** argv) { int main(int argc, char** argv) {
cout << "Beginning client" << endl;
try { try {
ClientApplication app; ClientApplication app;
app.Init(argc, argv); app.Init(argc, argv);
@@ -38,6 +37,5 @@ int main(int argc, char** argv) {
cerr << "Fatal exception thrown: " << e.what() << endl; cerr << "Fatal exception thrown: " << e.what() << endl;
return 1; return 1;
} }
cout << "Clean exit" << endl;
return 0; return 0;
} }
+4 -3
View File
@@ -1,7 +1,7 @@
#config #config
INCLUDES+=. ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet ../common/network/serial ../common/ui ../common/utilities INCLUDES+=. scenes ../common/gameplay ../common/graphics ../common/map ../common/network ../common/network/packet ../common/network/serial ../common/ui ../common/utilities
LIBS+=../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua LIBS+=client.a ../libcommon.a -lSDL_net -lwsock32 -liphlpapi -lmingw32 -lSDLmain -lSDL -llua
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) -DGRAPHICS CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
#source #source
CXXSRC=$(wildcard *.cpp) CXXSRC=$(wildcard *.cpp)
@@ -16,6 +16,7 @@ OUT=$(addprefix $(OUTDIR)/,client)
#targets #targets
all: $(OBJ) $(OUT) all: $(OBJ) $(OUT)
$(MAKE) -C scenes
$(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS) $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
$(OBJ): | $(OBJDIR) $(OBJ): | $(OBJDIR)
@@ -1,5 +1,5 @@
#config #config
INCLUDES+=. generators INCLUDES+=. .. ../../common/gameplay ../../common/graphics ../../common/map ../../common/network ../../common/network/packet ../../common/network/serial ../../common/ui ../../common/utilities
LIBS+= LIBS+=
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
@@ -12,12 +12,11 @@ OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
#output #output
OUTDIR=.. OUTDIR=..
OUT=$(addprefix $(OUTDIR)/,server.a) OUT=$(addprefix $(OUTDIR)/,client.a)
#targets #targets
all: $(OBJ) $(OUT) all: $(OBJ) $(OUT)
ar -crs $(OUT) $(OBJ) ar -crs $(OUT) $(OBJ)
$(MAKE) -C generators
$(OBJ): | $(OBJDIR) $(OBJ): | $(OBJDIR)
@@ -19,18 +19,17 @@
* 3. This notice may not be removed or altered from any source * 3. This notice may not be removed or altered from any source
* distribution. * distribution.
*/ */
#ifndef OVERWORLDGENERATOR_HPP_ #ifndef CHARACTERDEFINES_HPP_
#define OVERWORLDGENERATOR_HPP_ #define CHARACTERDEFINES_HPP_
#include "base_generator.hpp" #include <cmath>
class OverworldGenerator : public BaseGenerator { //the speeds that the characters move
public: constexpr double CHARACTER_WALKING_SPEED = 140.0;
OverworldGenerator(); constexpr double CHARACTER_WALKING_MOD = 1.0/sqrt(2.0);
~OverworldGenerator();
private: //the bounding boxes for the characters
// constexpr double CHARACTER_BOUNDS_WIDTH = 32.0;
}; constexpr double CHARACTER_BOUNDS_HEIGHT = 32.0;
#endif #endif
@@ -19,22 +19,16 @@
* 3. This notice may not be removed or altered from any source * 3. This notice may not be removed or altered from any source
* distribution. * distribution.
*/ */
#ifndef TERRAINTYPE_HPP_ #ifndef COMBATDEFINES_HPP_
#define TERRAINTYPE_HPP_ #define COMBATDEFINES_HPP_
#define COMBAT_MAX_CHARACTERS 16
#define COMBAT_MAX_ENEMIES 16
enum class TerrainType { enum class TerrainType {
//default: something's wrong
NONE = 0, NONE = 0,
GRASSLANDS,
//standard overworld //etc.
PLAINS,
GRASS,
DIRT,
SAND,
WATER,
//not used
LAST,
}; };
#endif #endif
+2 -2
View File
@@ -1,7 +1,7 @@
#config #config
INCLUDES+=. ../utilities ../graphics INCLUDES+=.
LIBS+= LIBS+=
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) -DGRAPHICS CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
#source #source
CXXSRC=$(wildcard *.cpp) CXXSRC=$(wildcard *.cpp)
+2 -2
View File
@@ -24,13 +24,13 @@
#include "serial_packet_base.hpp" #include "serial_packet_base.hpp"
#include "combat_data.hpp" #include "combat_defines.hpp"
struct CombatPacket : SerialPacketBase { struct CombatPacket : SerialPacketBase {
//identify the combat instance //identify the combat instance
int combatIndex; int combatIndex;
int difficulty; int difficulty;
CombatData::Terrain terrainType; TerrainType terrainType;
//combatants //combatants
int characterArray[COMBAT_MAX_CHARACTERS]; int characterArray[COMBAT_MAX_CHARACTERS];
+2 -2
View File
@@ -29,7 +29,7 @@ void serializeCombat(CombatPacket* packet, void* buffer) {
//identify the combat instance //identify the combat instance
SERIALIZE(buffer, &packet->combatIndex, sizeof(int)); SERIALIZE(buffer, &packet->combatIndex, sizeof(int));
SERIALIZE(buffer, &packet->difficulty, sizeof(int)); SERIALIZE(buffer, &packet->difficulty, sizeof(int));
SERIALIZE(buffer, &packet->terrainType, sizeof(CombatData::Terrain)); SERIALIZE(buffer, &packet->terrainType, sizeof(TerrainType));
//combatants //combatants
SERIALIZE(buffer, &packet->characterArray, sizeof(int) * COMBAT_MAX_CHARACTERS); SERIALIZE(buffer, &packet->characterArray, sizeof(int) * COMBAT_MAX_CHARACTERS);
@@ -49,7 +49,7 @@ void deserializeCombat(CombatPacket* packet, void* buffer) {
//identify the combat instance //identify the combat instance
DESERIALIZE(buffer, &packet->combatIndex, sizeof(int)); DESERIALIZE(buffer, &packet->combatIndex, sizeof(int));
DESERIALIZE(buffer, &packet->difficulty, sizeof(int)); DESERIALIZE(buffer, &packet->difficulty, sizeof(int));
DESERIALIZE(buffer, &packet->terrainType, sizeof(CombatData::Terrain)); DESERIALIZE(buffer, &packet->terrainType, sizeof(TerrainType));
//combatants //combatants
DESERIALIZE(buffer, &packet->characterArray, sizeof(int) * COMBAT_MAX_CHARACTERS); DESERIALIZE(buffer, &packet->characterArray, sizeof(int) * COMBAT_MAX_CHARACTERS);
+1
View File
@@ -36,6 +36,7 @@
* This class needs a rewrite. * This class needs a rewrite.
*/ */
//TODO: This thing is fucking terrible, fix it and the button class
class MenuBar { class MenuBar {
public: public:
MenuBar() = default; MenuBar() = default;
+57
View File
@@ -0,0 +1,57 @@
/* 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.
*/
#ifndef CHARACTERDATA_HPP_
#define CHARACTERDATA_HPP_
//components
#include "character_defines.hpp"
#include "vector2.hpp"
#include "statistics.hpp"
//std namespace
#include <string>
#include <cmath>
struct CharacterData {
//metadata
int owner;
std::string handle;
std::string avatar;
//world position
int roomIndex = 0;
Vector2 origin = {0.0,0.0};
Vector2 motion = {0.0,0.0};
//base statistics
Statistics stats;
//TODO: gameplay components: equipment, items, buffs, debuffs
//active gameplay members
//NOTE: these are lost when unloaded
bool inCombat = false;
int atbGauge = 0;
//TODO: stored command
};
#endif
+1
View File
@@ -26,6 +26,7 @@
struct ClientData { struct ClientData {
IPaddress address = {0,0}; IPaddress address = {0,0};
//TODO: ping system?
}; };
#endif #endif
@@ -19,24 +19,34 @@
* 3. This notice may not be removed or altered from any source * 3. This notice may not be removed or altered from any source
* distribution. * distribution.
*/ */
#ifndef ENEMYFACTORYGENERIC_HPP_ #ifndef COMBATDATA_HPP_
#define ENEMYFACTORYGENERIC_HPP_ #define COMBATDATA_HPP_
#include "enemy_factory_interface.hpp" #include "vector2.hpp"
#include "combat_defines.hpp"
//gameplay members
#include "character_data.hpp"
#include "enemy_data.hpp" #include "enemy_data.hpp"
#include <list> //std namespace
#include <chrono>
#include <array>
#include <utility>
//DOCS: Not really intended for use, but rather for copying and tweaking struct CombatData {
class EnemyFactoryGeneric : public EnemyFactoryInterface { typedef std::chrono::steady_clock Clock;
public:
EnemyFactoryGeneric();
~EnemyFactoryGeneric() noexcept override;
void Generate(std::list<EnemyData>* container) override; std::array<CharacterData, COMBAT_MAX_CHARACTERS> characterArray;
private: std::array<EnemyData, COMBAT_MAX_ENEMIES> enemyArray;
//TODO: hold the parameters specified by the room
//world interaction
int mapIndex = 0;
Vector2 origin = {0.0,0.0};
Vector2 bounds = {0.0,0.0};
//time interval
Clock::time_point lastTick = Clock::now();
}; };
#endif #endif
+1 -1
View File
@@ -1,5 +1,5 @@
#config #config
INCLUDES+=. ../../common/gameplay ../../common/utilities INCLUDES+=. ../../common/gameplay ../../common/utilities ../characters ../enemies
LIBS+= LIBS+=
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES)) CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
@@ -19,13 +19,29 @@
* 3. This notice may not be removed or altered from any source * 3. This notice may not be removed or altered from any source
* distribution. * distribution.
*/ */
#include "character_data.hpp" #ifndef ENEMYDATA_HPP_
#include "combat_data.hpp" #define ENEMYDATA_HPP_
#include "enemy_data.hpp"
#include "vector2.hpp"
#include "statistics.hpp" #include "statistics.hpp"
/* DOCS: Sanity check, read more //std namespace
* Since most/all of the files in this directory are header files, I've created #include <string>
* this source file as a "sanity check", to ensure that the above header files
* are written correctly via make. struct EnemyData {
*/ //metadata
std::string handle;
std::string avatar;
//gameplay
Statistics stats;
//TODO: gameplay components: equipment, items, buffs, debuffs, rewards
//active gameplay members
//NOTE: these are lost when unloaded
int tableIndex;
int atbGauge = 0;
};
#endif
-34
View File
@@ -1,34 +0,0 @@
/* 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 "enemy_factory_generic.hpp"
EnemyFactoryGeneric::EnemyFactoryGeneric() : EnemyFactoryInterface() {
//EMPTY
}
EnemyFactoryGeneric::~EnemyFactoryGeneric() noexcept {
//EMPTY
}
void EnemyFactoryGeneric::Generate(std::list<EnemyData>* container) {
//TODO: fill this out
}
@@ -1,49 +0,0 @@
/* 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.
*/
#ifndef ENEMYFACTORYINTERFACE_HPP_
#define ENEMYFACTORYINTERFACE_HPP_
#include "enemy_data.hpp"
#include "map_type.hpp"
#include <list>
//NOTE: Based on biome, world difficulty, etc.
class EnemyFactoryInterface {
public:
EnemyFactoryInterface() = default;
virtual ~EnemyFactoryInterface() = default;
virtual void Generate(std::list<EnemyData>* container) = 0;
//control the difficulty of the room
MapType SetType(MapType t) { return type = t; }
MapType GetType() { return type; }
int SetDifficulty(int d) { return difficulty = d; }
int GetDifficulty() { return difficulty; }
protected:
MapType type;
int difficulty = 0;
};
#endif
-2
View File
@@ -40,7 +40,6 @@
#include "region_pager_api.hpp" #include "region_pager_api.hpp"
#include "room_api.hpp" #include "room_api.hpp"
#include "room_mgr_api.hpp" #include "room_mgr_api.hpp"
#include "generator_api.hpp"
//these libs are loaded by lua.c and are readily available to any Lua program //these libs are loaded by lua.c and are readily available to any Lua program
static const luaL_Reg loadedlibs[] = { static const luaL_Reg loadedlibs[] = {
@@ -61,7 +60,6 @@ static const luaL_Reg loadedlibs[] = {
{TORTUGA_REGION_PAGER_NAME, openRegionPagerAPI}, {TORTUGA_REGION_PAGER_NAME, openRegionPagerAPI},
{TORTUGA_ROOM_NAME, openRoomAPI}, {TORTUGA_ROOM_NAME, openRoomAPI},
{TORTUGA_ROOM_MGR_NAME, openRoomMgrAPI}, {TORTUGA_ROOM_MGR_NAME, openRoomMgrAPI},
{TORTUGA_GENRATOR_NAME, openGeneratorAPI},
{NULL, NULL} {NULL, NULL}
}; };
+1 -5
View File
@@ -21,15 +21,12 @@
*/ */
#include "server_application.hpp" #include "server_application.hpp"
#include "SDL/SDL.h"
#include <stdexcept> #include <stdexcept>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
int main(int argc, char** argv) { int main(int argc, char** argv) {
cout << "Beginning server" << endl;
try { try {
ServerApplication app; ServerApplication app;
app.Init(argc, argv); app.Init(argc, argv);
@@ -37,9 +34,8 @@ int main(int argc, char** argv) {
app.Quit(); app.Quit();
} }
catch(exception& e) { catch(exception& e) {
cerr << "Fatal error: " << e.what() << endl; cerr << "Fatal exception thrown: " << e.what() << endl;
return 1; return 1;
} }
cout << "Clean exit" << endl;
return 0; return 0;
} }
-1
View File
@@ -20,7 +20,6 @@ all: $(OBJ) $(OUT)
$(MAKE) -C characters $(MAKE) -C characters
$(MAKE) -C combat $(MAKE) -C combat
$(MAKE) -C enemies $(MAKE) -C enemies
$(MAKE) -C mapgen
$(MAKE) -C rooms $(MAKE) -C rooms
$(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS) $(CXX) $(CXXFLAGS) -o $(OUT) $(OBJ) $(LIBS)
-44
View File
@@ -1,44 +0,0 @@
/* 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.
*/
#ifndef CHUNKDATA_HPP_
#define CHUNKDATA_HPP_
#include "terrain_type.hpp"
#include <type_traits>
struct ChunkData {
enum class Moddable {
LOCKED, //do not change
HARD, //minor changes
SOFT, //major changes
CLEAR, //untouched
};
TerrainType type;
// int fountainCount;
Moddable mod;
};
static_assert(std::is_pod<ChunkData>::value, "ChunkData is not a POD");
#endif
-79
View File
@@ -1,79 +0,0 @@
/* 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 "generator_api.hpp"
#include "base_generator.hpp"
static int getMapType(lua_State* L) {
BaseGenerator* ptr = reinterpret_cast<BaseGenerator*>(lua_touserdata(L, 1));
switch(ptr->GetMapType()) {
case MapType::NONE:
lua_pushstring(L, "none");
break;
case MapType::OVERWORLD:
lua_pushstring(L, "overworld");
break;
case MapType::RUINS:
lua_pushstring(L, "ruins");
break;
case MapType::TOWERS:
lua_pushstring(L, "towers");
break;
case MapType::FORESTS:
lua_pushstring(L, "forests");
break;
case MapType::CAVES:
lua_pushstring(L, "caves");
break;
}
return 1;
}
static int getChunk(lua_State* L) {
BaseGenerator* ptr = reinterpret_cast<BaseGenerator*>(lua_touserdata(L, 1));
ChunkData* chunk = ptr->GetChunk(lua_tointeger(L, 2), lua_tointeger(L, 3));
lua_pushlightuserdata(L, reinterpret_cast<void*>(chunk));
return 1;
}
static int getMapWidth(lua_State* L) {
lua_pushinteger(L, MAP_WIDTH);
return 1;
}
static int getMapHeight(lua_State* L) {
lua_pushinteger(L, MAP_HEIGHT);
return 1;
}
static const luaL_Reg generatorLib[] = {
{"GetMapType", getMapType},
{"GetChunk", getChunk},
{"GetMapWidth", getMapWidth},
{"GetMapHeight", getMapHeight},
{nullptr, nullptr}
};
LUAMOD_API int openGeneratorAPI(lua_State* L) {
luaL_newlib(L, generatorLib);
return 1;
}
-30
View File
@@ -1,30 +0,0 @@
/* 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.
*/
#ifndef GENERATORAPI_HPP_
#define GENERATORAPI_HPP_
#include "lua/lua.hpp"
#define TORTUGA_GENRATOR_NAME "Generator"
LUAMOD_API int openGeneratorAPI(lua_State* L);
#endif
@@ -1,36 +0,0 @@
/* 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 "base_generator.hpp"
BaseGenerator::BaseGenerator(MapType t) {
mapType = t;
for (int i = 0; i < MAP_WIDTH; i++) {
for (int j = 0; j < MAP_HEIGHT; j++) {
chunks[i][j].type = TerrainType::NONE;
chunks[i][j].mod = ChunkData::Moddable::CLEAR;
}
}
}
BaseGenerator::~BaseGenerator() {
//
}
@@ -1,54 +0,0 @@
/* 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.
*/
#ifndef BASEGENERATOR_HPP_
#define BASEGENERATOR_HPP_
#include "map_type.hpp"
#include "chunk_data.hpp"
#include "lua/lua.hpp"
constexpr int MAP_WIDTH = 256;
constexpr int MAP_HEIGHT = 256;
class BaseGenerator {
public:
virtual ~BaseGenerator();
//accessors and mutators
virtual ChunkData* GetChunk(int x, int y) { return &chunks[x][y]; }
MapType GetMapType() { return mapType; }
lua_State* SetLuaState(lua_State* L) { return luaState = L; }
lua_State* GetLuaState() { return luaState; }
protected:
BaseGenerator() = delete;
BaseGenerator(MapType t);
ChunkData chunks[MAP_WIDTH][MAP_HEIGHT];
MapType mapType = MapType::NONE;
lua_State* luaState = nullptr;
};
#endif
@@ -1,30 +0,0 @@
/* 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 "caves_generator.hpp"
CavesGenerator::CavesGenerator() : BaseGenerator(MapType::CAVES) {
//
}
CavesGenerator::~CavesGenerator() {
//
}
@@ -1,36 +0,0 @@
/* 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.
*/
#ifndef CAVESGENERATOR_HPP_
#define CAVESGENERATOR_HPP_
#include "base_generator.hpp"
class CavesGenerator : public BaseGenerator {
public:
CavesGenerator();
~CavesGenerator();
private:
//
};
#endif
@@ -1,30 +0,0 @@
/* 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 "forests_generator.hpp"
ForestsGenerator::ForestsGenerator() : BaseGenerator(MapType::FORESTS) {
//
}
ForestsGenerator::~ForestsGenerator() {
//
}
@@ -1,36 +0,0 @@
/* 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.
*/
#ifndef FORESTSGENERATOR_HPP_
#define FORESTSGENERATOR_HPP_
#include "base_generator.hpp"
class ForestsGenerator : public BaseGenerator {
public:
ForestsGenerator();
~ForestsGenerator();
private:
//
};
#endif
-37
View File
@@ -1,37 +0,0 @@
#config
INCLUDES+=. ..
LIBS+=
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
#source
CXXSRC=$(wildcard *.cpp)
#objects
OBJDIR=obj
OBJ+=$(addprefix $(OBJDIR)/,$(CXXSRC:.cpp=.o))
#output
OUTDIR=../..
OUT=$(addprefix $(OUTDIR)/,server.a)
#targets
all: $(OBJ) $(OUT)
ar -crs $(OUT) $(OBJ)
$(OBJ): | $(OBJDIR)
$(OUT): | $(OUTDIR)
$(OBJDIR):
mkdir $(OBJDIR)
$(OUTDIR):
mkdir $(OUTDIR)
$(OBJDIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -c -o $@ $<
clean:
$(RM) *.o *.a *.exe
rebuild: clean all
@@ -1,30 +0,0 @@
/* 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 "overworld_generator.hpp"
OverworldGenerator::OverworldGenerator() : BaseGenerator(MapType::OVERWORLD) {
//
}
OverworldGenerator::~OverworldGenerator() {
//
}
@@ -1,30 +0,0 @@
/* 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 "ruins_generator.hpp"
RuinsGenerator::RuinsGenerator() : BaseGenerator(MapType::RUINS) {
//
}
RuinsGenerator::~RuinsGenerator() {
//
}
@@ -1,36 +0,0 @@
/* 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.
*/
#ifndef RUINSGENERATOR_HPP_
#define RUINSGENERATOR_HPP_
#include "base_generator.hpp"
class RuinsGenerator : public BaseGenerator {
public:
RuinsGenerator();
~RuinsGenerator();
private:
//
};
#endif
@@ -1,30 +0,0 @@
/* 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 "towers_generator.hpp"
TowersGenerator::TowersGenerator() : BaseGenerator(MapType::TOWERS) {
//
}
TowersGenerator::~TowersGenerator() {
//
}
@@ -1,36 +0,0 @@
/* 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.
*/
#ifndef TOWERSGENERATOR_HPP_
#define TOWERSGENERATOR_HPP_
#include "base_generator.hpp"
class TowersGenerator : public BaseGenerator {
public:
TowersGenerator();
~TowersGenerator();
private:
//
};
#endif
-34
View File
@@ -1,34 +0,0 @@
/* 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.
*/
#ifndef MAPTYPE_HPP_
#define MAPTYPE_HPP_
enum class MapType {
NONE,
OVERWORLD,
RUINS,
TOWERS,
FORESTS,
CAVES,
};
#endif
-7
View File
@@ -29,12 +29,6 @@ static int getPager(lua_State* L) {
return 1; return 1;
} }
static int getGenerator(lua_State* L) {
RoomData* room = reinterpret_cast<RoomData*>(lua_touserdata(L, 1));
lua_pushlightuserdata(L, reinterpret_cast<void*>(room->generator));
return 1;
}
static int onCreate(lua_State* L) { static int onCreate(lua_State* L) {
//TODO: onCreate() //TODO: onCreate()
return 0; return 0;
@@ -49,7 +43,6 @@ static int onUnload(lua_State* L) {
static const luaL_Reg roomLib[] = { static const luaL_Reg roomLib[] = {
{"GetPager",getPager}, {"GetPager",getPager},
{"GetGenerator",getGenerator},
{"OnCreate", onCreate}, {"OnCreate", onCreate},
{"OnUnload", onUnload}, {"OnUnload", onUnload},
{nullptr, nullptr} {nullptr, nullptr}
-3
View File
@@ -23,14 +23,11 @@
#define ROOMDATA_HPP_ #define ROOMDATA_HPP_
//map system //map system
#include "map_type.hpp"
#include "region_pager_lua.hpp" #include "region_pager_lua.hpp"
#include "base_generator.hpp"
struct RoomData { struct RoomData {
//members //members
RegionPagerLua pager; RegionPagerLua pager;
BaseGenerator* generator = nullptr;
//TODO: collision map //TODO: collision map
//TODO: NPCs? //TODO: NPCs?
+3 -27
View File
@@ -21,41 +21,19 @@
*/ */
#include "room_manager.hpp" #include "room_manager.hpp"
//the generator types
#include "overworld_generator.hpp"
#include "ruins_generator.hpp"
#include "towers_generator.hpp"
#include "forests_generator.hpp"
#include "caves_generator.hpp"
#include <stdexcept> #include <stdexcept>
//------------------------- //-------------------------
//public access methods //public access methods
//------------------------- //-------------------------
RoomData* RoomManager::CreateRoom(MapType mapType) { RoomData* RoomManager::CreateRoom() {
//create the room //create the room
RoomData* newRoom = new RoomData(); RoomData* newRoom = new RoomData();
//create the generator, use a lambda because I'm lazy
newRoom->generator = [mapType]() -> BaseGenerator* {
switch(mapType) {
//BUG: Not having a map type results in an overworld generator by default
case MapType::NONE:
case MapType::OVERWORLD: return new OverworldGenerator();
case MapType::RUINS: return new RuinsGenerator();
case MapType::TOWERS: return new TowersGenerator();
case MapType::FORESTS: return new ForestsGenerator();
case MapType::CAVES: return new CavesGenerator();
}
throw(std::runtime_error("Failed to set the room's generator"));
}();
//set the state //set the state
if (luaState) { if (luaState) {
newRoom->pager.SetLuaState(luaState); newRoom->pager.SetLuaState(luaState);
newRoom->generator->SetLuaState(luaState);
} }
//register the room //register the room
@@ -91,15 +69,13 @@ void RoomManager::UnloadRoom(int uid) {
lua_pop(luaState, 1); lua_pop(luaState, 1);
//free the memory //free the memory
delete room->generator;
delete room; delete room;
roomMap.erase(uid); roomMap.erase(uid);
} }
RoomData* RoomManager::GetRoom(int uid) { RoomData* RoomManager::GetRoom(int uid) {
RoomData* ptr = FindRoom(uid); return FindRoom(uid);
if (ptr) return ptr; //TODO: expand this to auto-create the room
return CreateRoom(MapType::NONE);
} }
RoomData* RoomManager::FindRoom(int uid) { RoomData* RoomManager::FindRoom(int uid) {
+1 -1
View File
@@ -36,7 +36,7 @@ public:
~RoomManager() = default; ~RoomManager() = default;
//public access methods //public access methods
RoomData* CreateRoom(MapType); RoomData* CreateRoom();
void UnloadRoom(int uid); void UnloadRoom(int uid);
RoomData* GetRoom(int uid); RoomData* GetRoom(int uid);
+1 -11
View File
@@ -46,18 +46,8 @@ static int createRoom(lua_State* L) {
lua_gettable(L, LUA_REGISTRYINDEX); lua_gettable(L, LUA_REGISTRYINDEX);
RoomManager* roomMgr = reinterpret_cast<RoomManager*>(lua_touserdata(L, -1)); RoomManager* roomMgr = reinterpret_cast<RoomManager*>(lua_touserdata(L, -1));
//determine the specified room type
MapType mapType = [L]() -> MapType {
if (std::string("overworld") == lua_tostring(L, -2)) return MapType::OVERWORLD;
if (std::string("ruins") == lua_tostring(L, -2)) return MapType::RUINS;
if (std::string("towers") == lua_tostring(L, -2)) return MapType::TOWERS;
if (std::string("forests") == lua_tostring(L, -2)) return MapType::FORESTS;
if (std::string("caves") == lua_tostring(L, -2)) return MapType::CAVES;
return MapType::NONE;
}();
//create the room //create the room
RoomData* newRoom = roomMgr->CreateRoom(mapType); RoomData* newRoom = roomMgr->CreateRoom();
//return the new room //return the new room
lua_pushlightuserdata(L, newRoom); lua_pushlightuserdata(L, newRoom);
+7 -19
View File
@@ -21,8 +21,11 @@
*/ */
#include "server_application.hpp" #include "server_application.hpp"
#include "sql_utility.hpp" //for PACKET_BUFFER_SIZE
#include "serial.hpp" #include "serial.hpp"
//utility functions
#include "sql_utility.hpp"
#include "utility.hpp" #include "utility.hpp"
#include <stdexcept> #include <stdexcept>
@@ -35,9 +38,9 @@
void ServerApplication::Init(int argc, char** argv) { void ServerApplication::Init(int argc, char** argv) {
//NOTE: I might need to rearrange the init process so that lua & SQL can interact with the map system as needed. //NOTE: I might need to rearrange the init process so that lua & SQL can interact with the map system as needed.
std::cout << "Beginning startup" << std::endl; std::cout << "Beginning " << argv[0] << std::endl;
//initial setup //load the prerequisites
config.Load("rsc\\config.cfg"); config.Load("rsc\\config.cfg");
//------------------------- //-------------------------
@@ -80,9 +83,7 @@ void ServerApplication::Init(int argc, char** argv) {
accountMgr.SetDatabase(database); accountMgr.SetDatabase(database);
characterMgr.SetDatabase(database); characterMgr.SetDatabase(database);
combatMgr.SetLuaState(luaState);
roomMgr.SetLuaState(luaState); roomMgr.SetLuaState(luaState);
enemyMgr.SetLuaState(luaState);
std::cout << "Internal managers set" << std::endl; std::cout << "Internal managers set" << std::endl;
@@ -113,7 +114,6 @@ void ServerApplication::Init(int argc, char** argv) {
//debug output //debug output
//------------------------- //-------------------------
//TODO: put these outputs into the client too
//TODO: enable/disable these with a switch //TODO: enable/disable these with a switch
#define DEBUG_OUTPUT_VAR(x) std::cout << "\t" << #x << ": " << x << std::endl; #define DEBUG_OUTPUT_VAR(x) std::cout << "\t" << #x << ": " << x << std::endl;
@@ -178,7 +178,7 @@ void ServerApplication::Quit() {
SDLNet_Quit(); SDLNet_Quit();
SDL_Quit(); SDL_Quit();
std::cout << "Shutdown finished" << std::endl; std::cout << "Clean exit" << std::endl;
} }
//------------------------- //-------------------------
@@ -355,12 +355,6 @@ void ServerApplication::HandleRegionRequest(RegionPacket* const argPacket) {
network.SendTo(&argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket)); network.SendTo(&argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));
} }
//-------------------------
//combat management
//-------------------------
//TODO: combat management
//------------------------- //-------------------------
//Character Management //Character Management
//------------------------- //-------------------------
@@ -439,12 +433,6 @@ void ServerApplication::HandleCharacterUpdate(CharacterPacket* const argPacket)
PumpPacket(argPacket); PumpPacket(argPacket);
} }
//-------------------------
//enemy management
//-------------------------
//TODO: enemy management
//------------------------- //-------------------------
//mismanagement //mismanagement
//------------------------- //-------------------------
+2 -12
View File
@@ -22,12 +22,10 @@
#ifndef SERVERAPPLICATION_HPP_ #ifndef SERVERAPPLICATION_HPP_
#define SERVERAPPLICATION_HPP_ #define SERVERAPPLICATION_HPP_
//server specific stuff //server specific stuff, mostly managers
#include "client_data.hpp"
#include "account_manager.hpp" #include "account_manager.hpp"
#include "character_manager.hpp" #include "character_manager.hpp"
#include "client_data.hpp"
#include "combat_manager.hpp"
#include "enemy_manager.hpp"
#include "room_manager.hpp" #include "room_manager.hpp"
//common utilities //common utilities
@@ -67,17 +65,11 @@ private:
//map management //map management
void HandleRegionRequest(RegionPacket* const); void HandleRegionRequest(RegionPacket* const);
//combat management
//TODO: combat management
//character management //character management
void HandleCharacterNew(CharacterPacket* const); void HandleCharacterNew(CharacterPacket* const);
void HandleCharacterDelete(CharacterPacket* const); void HandleCharacterDelete(CharacterPacket* const);
void HandleCharacterUpdate(CharacterPacket* const); void HandleCharacterUpdate(CharacterPacket* const);
//enemy management
//TODO: enemy management
//mismanagement //mismanagement
void HandleSynchronize(ClientPacket* const); void HandleSynchronize(ClientPacket* const);
@@ -99,8 +91,6 @@ private:
//managers //managers
AccountManager accountMgr; AccountManager accountMgr;
CharacterManager characterMgr; CharacterManager characterMgr;
CombatManager combatMgr;
EnemyManager enemyMgr;
RoomManager roomMgr; RoomManager roomMgr;
//misc //misc