Removed a lot of rubbish from the server
This commit is contained in:
@@ -22,11 +22,14 @@
|
|||||||
#ifndef NETWORKPACKET_HPP_
|
#ifndef NETWORKPACKET_HPP_
|
||||||
#define NETWORKPACKET_HPP_
|
#define NETWORKPACKET_HPP_
|
||||||
|
|
||||||
//#define PACKET_STRING_SIZE 100
|
#include "SDL/SDL_net.h"
|
||||||
|
|
||||||
|
#define PACKET_STRING_SIZE 100
|
||||||
|
|
||||||
#pragma pack(push, 0)
|
#pragma pack(push, 0)
|
||||||
|
|
||||||
union NetworkPacket {
|
union NetworkPacket {
|
||||||
|
//types of packets
|
||||||
enum class Type {
|
enum class Type {
|
||||||
//default: there is something wrong
|
//default: there is something wrong
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
@@ -35,7 +38,7 @@ union NetworkPacket {
|
|||||||
PING = 1,
|
PING = 1,
|
||||||
PONG = 2,
|
PONG = 2,
|
||||||
|
|
||||||
//bounce information between the client & server
|
//Searching for a server to join
|
||||||
BROADCAST_REQUEST = 3,
|
BROADCAST_REQUEST = 3,
|
||||||
BROADCAST_RESPONSE = 4,
|
BROADCAST_RESPONSE = 4,
|
||||||
|
|
||||||
@@ -48,11 +51,23 @@ union NetworkPacket {
|
|||||||
|
|
||||||
//mass update
|
//mass update
|
||||||
SYNCHRONIZE = 8,
|
SYNCHRONIZE = 8,
|
||||||
|
|
||||||
|
//Player movement, etc.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//metadata on the packet itself
|
||||||
struct Metadata {
|
struct Metadata {
|
||||||
Type type;
|
Type type;
|
||||||
|
IPaddress srcAddress;
|
||||||
}meta;
|
}meta;
|
||||||
|
|
||||||
|
//information about the server
|
||||||
|
struct ServerInformation {
|
||||||
|
Metadata meta;
|
||||||
|
//TODO: version info
|
||||||
|
char name[PACKET_STRING_SIZE];
|
||||||
|
//TODO: player count
|
||||||
|
}serverInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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_manager.hpp"
|
|
||||||
|
|
||||||
AccountManager AccountManager::instance;
|
|
||||||
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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 ACCOUNTMANAGER_HPP_
|
|
||||||
#define ACCOUNTMANAGER_HPP_
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
class AccountManager {
|
|
||||||
private:
|
|
||||||
AccountManager() = default;
|
|
||||||
~AccountManager() = default;
|
|
||||||
static AccountManager instance;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static AccountManager* GetInstance() { return &instance; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct AccountEntry {
|
|
||||||
int index;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::list<AccountEntry> list;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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 BASEROOM_HPP_
|
|
||||||
#define BASEROOM_HPP_
|
|
||||||
|
|
||||||
#include "mail_box.hpp"
|
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
//The abstract base class for all rooms
|
|
||||||
class BaseRoom {
|
|
||||||
public:
|
|
||||||
BaseRoom() = default;
|
|
||||||
~BaseRoom() = default;
|
|
||||||
|
|
||||||
virtual void Init() = 0;
|
|
||||||
virtual void Loop() = 0;
|
|
||||||
virtual void Quit() = 0;
|
|
||||||
|
|
||||||
bool SetRunning(bool b) { return running = b; }
|
|
||||||
bool GetRunning() const { return running; }
|
|
||||||
|
|
||||||
MailBox* GetMailBox() { return& mailBox; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
MailBox mailBox;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool running = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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 "combat_room.hpp"
|
|
||||||
|
|
||||||
CombatRoom::CombatRoom() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
CombatRoom::~CombatRoom() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
void CombatRoom::Init() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
void CombatRoom::Loop() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
void CombatRoom::Quit() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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 COMBATROOM_HPP_
|
|
||||||
#define COMBATROOM_HPP_
|
|
||||||
|
|
||||||
#include "base_room.hpp"
|
|
||||||
|
|
||||||
class CombatRoom : public BaseRoom {
|
|
||||||
public:
|
|
||||||
CombatRoom();
|
|
||||||
~CombatRoom();
|
|
||||||
|
|
||||||
void Init();
|
|
||||||
void Loop();
|
|
||||||
void Quit();
|
|
||||||
|
|
||||||
private:
|
|
||||||
//parent room index
|
|
||||||
//combatants
|
|
||||||
//monsters
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,114 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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 "mail_box.hpp"
|
|
||||||
|
|
||||||
#include <sstream>
|
|
||||||
#include <stdexcept>
|
|
||||||
|
|
||||||
MailBox::MailBox() {
|
|
||||||
if (!(inLock = SDL_CreateMutex())) {
|
|
||||||
std::ostringstream os;
|
|
||||||
os << "Failed to create a MailBox mutex; ";
|
|
||||||
os << SDL_GetError();
|
|
||||||
throw(std::runtime_error(os.str()));
|
|
||||||
}
|
|
||||||
if (!(outLock = SDL_CreateMutex())) {
|
|
||||||
SDL_DestroyMutex(inLock);
|
|
||||||
std::ostringstream os;
|
|
||||||
os << "Failed to create a MailBox mutex; ";
|
|
||||||
os << SDL_GetError();
|
|
||||||
throw(std::runtime_error(os.str()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MailBox::~MailBox() {
|
|
||||||
SDL_DestroyMutex(inLock);
|
|
||||||
SDL_DestroyMutex(outLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string MailBox::PushIn(std::string msg) {
|
|
||||||
SDL_LockMutex(inLock);
|
|
||||||
input.push_back(msg);
|
|
||||||
SDL_UnlockMutex(inLock);
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string MailBox::PeekIn() {
|
|
||||||
std::string ret;
|
|
||||||
SDL_LockMutex(inLock);
|
|
||||||
if (input.size()) {
|
|
||||||
ret = input[0];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ret = "";
|
|
||||||
}
|
|
||||||
SDL_UnlockMutex(inLock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string MailBox::PopIn() {
|
|
||||||
std::string ret;
|
|
||||||
SDL_LockMutex(inLock);
|
|
||||||
if (input.size()) {
|
|
||||||
ret = input[0];
|
|
||||||
input.pop_front();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ret = "";
|
|
||||||
}
|
|
||||||
SDL_UnlockMutex(inLock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string MailBox::PushOut(std::string msg) {
|
|
||||||
SDL_LockMutex(outLock);
|
|
||||||
output.push_back(msg);
|
|
||||||
SDL_UnlockMutex(outLock);
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string MailBox::PeekOut() {
|
|
||||||
std::string ret;
|
|
||||||
SDL_LockMutex(outLock);
|
|
||||||
if (output.size()) {
|
|
||||||
ret = output[0];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ret = "";
|
|
||||||
}
|
|
||||||
SDL_UnlockMutex(outLock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string MailBox::PopOut() {
|
|
||||||
std::string ret;
|
|
||||||
SDL_LockMutex(outLock);
|
|
||||||
if (output.size()) {
|
|
||||||
ret = output[0];
|
|
||||||
output.pop_front();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ret = "";
|
|
||||||
}
|
|
||||||
SDL_UnlockMutex(outLock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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 MAILBOX_HPP_
|
|
||||||
#define MAILBOX_HPP_
|
|
||||||
|
|
||||||
#include "SDL/SDL_thread.h"
|
|
||||||
|
|
||||||
#include <deque>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
//Thread safe messaging system
|
|
||||||
class MailBox {
|
|
||||||
public:
|
|
||||||
MailBox();
|
|
||||||
~MailBox();
|
|
||||||
|
|
||||||
std::string PushIn(std::string);
|
|
||||||
std::string PeekIn();
|
|
||||||
std::string PopIn();
|
|
||||||
std::string PushOut(std::string);
|
|
||||||
std::string PeekOut();
|
|
||||||
std::string PopOut();
|
|
||||||
private:
|
|
||||||
std::deque<std::string> input;
|
|
||||||
std::deque<std::string> output;
|
|
||||||
SDL_mutex* inLock = nullptr;
|
|
||||||
SDL_mutex* outLock = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
+4
-3
@@ -31,9 +31,10 @@ using namespace std;
|
|||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
cout << "Beginning server" << endl;
|
cout << "Beginning server" << endl;
|
||||||
try {
|
try {
|
||||||
ServerApplication::GetInstance()->Init(argc, argv);
|
ServerApplication app;
|
||||||
ServerApplication::GetInstance()->Loop();
|
app.Init(argc, argv);
|
||||||
ServerApplication::GetInstance()->Quit();
|
app.Loop();
|
||||||
|
app.Quit();
|
||||||
}
|
}
|
||||||
catch(exception& e) {
|
catch(exception& e) {
|
||||||
cerr << "Fatal error: " << e.what() << endl;
|
cerr << "Fatal error: " << e.what() << endl;
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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 "player_manager.hpp"
|
|
||||||
|
|
||||||
PlayerManager PlayerManager::instance;
|
|
||||||
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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 PLAYERMANAGER_HPP_
|
|
||||||
#define PLAYERMANAGER_HPP_
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
class PlayerManager {
|
|
||||||
private:
|
|
||||||
PlayerManager() = default;
|
|
||||||
~PlayerManager() = default;
|
|
||||||
static PlayerManager instance;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static PlayerManager* GetInstance() { return &instance; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct PlayerEntry {
|
|
||||||
int index;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::list<PlayerEntry> list;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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_manager.hpp"
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
RoomManager RoomManager::instance;
|
|
||||||
|
|
||||||
int roomThread(void* ptr) {
|
|
||||||
std::cout << "Opening room" << std::endl;
|
|
||||||
try {
|
|
||||||
reinterpret_cast<BaseRoom*>(ptr)->Init();
|
|
||||||
reinterpret_cast<BaseRoom*>(ptr)->Loop();
|
|
||||||
reinterpret_cast<BaseRoom*>(ptr)->Quit();
|
|
||||||
}
|
|
||||||
catch(std::exception& e) {
|
|
||||||
std::cerr << "Fatal room error: " << e.what() << std::endl;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
std::cout << "Closing room" << std::endl;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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 ROOMMANAGER_HPP_
|
|
||||||
#define ROOMMANAGER_HPP_
|
|
||||||
|
|
||||||
#include "base_room.hpp"
|
|
||||||
|
|
||||||
#include "SDL/SDL_thread.h"
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
class RoomManager {
|
|
||||||
private:
|
|
||||||
RoomManager() = default;
|
|
||||||
~RoomManager() = default;
|
|
||||||
static RoomManager instance;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static RoomManager* GetInstance() { return &instance; }
|
|
||||||
|
|
||||||
//open room
|
|
||||||
//close room
|
|
||||||
|
|
||||||
//get room
|
|
||||||
//set?
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct RoomHandle {
|
|
||||||
SDL_Thread* thread = nullptr;
|
|
||||||
BaseRoom* room = nullptr;
|
|
||||||
};
|
|
||||||
std::list<RoomHandle> rooms;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -29,14 +29,13 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
int ClientEntry::indexCounter = 0;
|
int ClientEntry::indexCounter = 0;
|
||||||
ServerApplication ServerApplication::instance;
|
|
||||||
|
|
||||||
ServerApplication::ServerApplication() {
|
ServerApplication::ServerApplication() {
|
||||||
//TODO
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerApplication::~ServerApplication() {
|
ServerApplication::~ServerApplication() {
|
||||||
//TODO
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::Init(int argc, char** argv) {
|
void ServerApplication::Init(int argc, char** argv) {
|
||||||
@@ -65,7 +64,7 @@ void ServerApplication::Init(int argc, char** argv) {
|
|||||||
else {
|
else {
|
||||||
std::cout << "SDL_net initialized" << std::endl;
|
std::cout << "SDL_net initialized" << std::endl;
|
||||||
}
|
}
|
||||||
networkUtil.Open(8895, 1024);
|
networkUtil.Open(21795, 1024);
|
||||||
|
|
||||||
//Init SQL
|
//Init SQL
|
||||||
std::string dbname = (argc > 1) ? argv[1] : argv[0];
|
std::string dbname = (argc > 1) ? argv[1] : argv[0];
|
||||||
|
|||||||
@@ -38,13 +38,9 @@ struct ClientEntry {
|
|||||||
|
|
||||||
//The main application class
|
//The main application class
|
||||||
class ServerApplication {
|
class ServerApplication {
|
||||||
private:
|
public:
|
||||||
ServerApplication();
|
ServerApplication();
|
||||||
~ServerApplication();
|
~ServerApplication();
|
||||||
static ServerApplication instance;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static ServerApplication* GetInstance() { return &instance; }
|
|
||||||
|
|
||||||
void Init(int argc, char** argv);
|
void Init(int argc, char** argv);
|
||||||
void Loop();
|
void Loop();
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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 "world_room.hpp"
|
|
||||||
|
|
||||||
WorldRoom::WorldRoom() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
WorldRoom::~WorldRoom() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
void WorldRoom::Init() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
void WorldRoom::Loop() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
void WorldRoom::Quit() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/* Copyright: (c) Kayne Ruse 2013
|
|
||||||
*
|
|
||||||
* 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 WORLDROOM_HPP_
|
|
||||||
#define WORLDROOM_HPP_
|
|
||||||
|
|
||||||
#include "base_room.hpp"
|
|
||||||
|
|
||||||
class WorldRoom : public BaseRoom {
|
|
||||||
public:
|
|
||||||
WorldRoom();
|
|
||||||
~WorldRoom();
|
|
||||||
|
|
||||||
void Init();
|
|
||||||
void Loop();
|
|
||||||
void Quit();
|
|
||||||
|
|
||||||
private:
|
|
||||||
//collision map
|
|
||||||
//map metadata
|
|
||||||
//player list
|
|
||||||
//combat portals
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user