Expanded network protocol, read more

Not really doing much, just busywork with the server's handlers.

I've tweaked the TODO tags as well.
This commit is contained in:
Kayne Ruse
2015-02-13 02:05:10 +11:00
parent bad6cc2fab
commit ca2d4c9217
32 changed files with 196 additions and 184 deletions
+1 -1
View File
@@ -127,7 +127,7 @@ void BaseScene::HandleEvents() {
break; break;
#ifdef USE_EVENT_JOYSTICK #ifdef USE_EVENT_JOYSTICK
//TODO: joystick/gamepad support //EMPTY
#endif #endif
#ifdef USE_EVENT_UNKNOWN #ifdef USE_EVENT_UNKNOWN
+1 -1
View File
@@ -59,7 +59,7 @@ protected:
virtual void KeyUp(SDL_KeyboardEvent const&) {} virtual void KeyUp(SDL_KeyboardEvent const&) {}
#ifdef USE_EVENT_JOYSTICK #ifdef USE_EVENT_JOYSTICK
//TODO: joystick/gamepad support //EMPTY
#endif #endif
#ifdef USE_EVENT_UNKNOWN #ifdef USE_EVENT_UNKNOWN
-1
View File
@@ -83,7 +83,6 @@ void ClientApplication::Init(int argc, char* argv[]) {
//debug output //debug output
//------------------------- //-------------------------
//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;
std::cout << "Internal sizes:" << std::endl; std::cout << "Internal sizes:" << std::endl;
+1 -1
View File
@@ -24,7 +24,7 @@
#include "config_utility.hpp" #include "config_utility.hpp"
void BaseMonster::CorrectSprite() { void BaseMonster::CorrectSprite() {
//TODO: CorrectSprite //TODO: (1) CorrectSprite
} }
std::string BaseMonster::SetHandle(std::string s) { std::string BaseMonster::SetHandle(std::string s) {
+1 -1
View File
@@ -142,7 +142,7 @@ protected:
LocalCharacter* localCharacter = nullptr; LocalCharacter* localCharacter = nullptr;
//heartbeat //heartbeat
//TODO: Heartbeat needs it's own utility //TODO: (9) Heartbeat needs it's own utility
typedef std::chrono::steady_clock Clock; typedef std::chrono::steady_clock Clock;
Clock::time_point lastBeat = Clock::now(); Clock::time_point lastBeat = Clock::now();
int attemptedBeats = 0; int attemptedBeats = 0;
@@ -51,7 +51,7 @@ void InWorld::HandleCharacterCreate(CharacterPacket* const argPacket) {
//fill the character's info //fill the character's info
character->SetOrigin(argPacket->origin); character->SetOrigin(argPacket->origin);
character->SetMotion(argPacket->motion); character->SetMotion(argPacket->motion);
character->SetBounds({CHARACTER_BOUNDS_X, CHARACTER_BOUNDS_Y, CHARACTER_BOUNDS_WIDTH, CHARACTER_BOUNDS_HEIGHT}); //TODO: send the bounds from the server character->SetBounds({CHARACTER_BOUNDS_X, CHARACTER_BOUNDS_Y, CHARACTER_BOUNDS_WIDTH, CHARACTER_BOUNDS_HEIGHT}); //TODO: (1) send the bounds from the server
character->SetHandle(argPacket->handle); character->SetHandle(argPacket->handle);
character->SetAvatar(argPacket->avatar); character->SetAvatar(argPacket->avatar);
character->SetOwner(argPacket->accountIndex); character->SetOwner(argPacket->accountIndex);
@@ -128,7 +128,7 @@ void InWorld::HandleCharacterQueryExists(CharacterPacket* const argPacket) {
} }
void InWorld::HandleCharacterMovement(CharacterPacket* const argPacket) { void InWorld::HandleCharacterMovement(CharacterPacket* const argPacket) {
//TODO: Authentication //TODO: (1) Authentication
if (argPacket->characterIndex == characterIndex) { if (argPacket->characterIndex == characterIndex) {
return; return;
} }
@@ -144,7 +144,7 @@ void InWorld::HandleCharacterMovement(CharacterPacket* const argPacket) {
} }
void InWorld::HandleCharacterAttack(CharacterPacket* const argPacket) { void InWorld::HandleCharacterAttack(CharacterPacket* const argPacket) {
//TODO: attack animation //TODO: (1) attack animation
} }
//------------------------- //-------------------------
+1 -1
View File
@@ -110,5 +110,5 @@ void InWorld::HandleMonsterMovement(MonsterPacket* const argPacket) {
} }
void InWorld::HandleMonsterAttack(MonsterPacket* const argPacket) { void InWorld::HandleMonsterAttack(MonsterPacket* const argPacket) {
//TODO: HandleMonsterAttack //TODO: (1) HandleMonsterAttack
} }
+3 -6
View File
@@ -60,12 +60,10 @@ InWorld::InWorld(int* const argClientIndex, int* const argAccountIndex):
shutDownButton.SetText("Shut Down"); shutDownButton.SetText("Shut Down");
//load the tilesheet //load the tilesheet
//TODO: add the tilesheet to the map system //TODO: (9) Tile size and tile sheet should be loaded elsewhere
//TODO: Tile size and tile sheet should be loaded elsewhere
tileSheet.Load(config["dir.tilesets"] + "overworld.bmp", 32, 32); tileSheet.Load(config["dir.tilesets"] + "overworld.bmp", 32, 32);
//Send the character data //Send the character data
//TODO: login scene, prompt, etc.
CharacterPacket newPacket; CharacterPacket newPacket;
newPacket.type = SerialPacketType::CHARACTER_LOAD; newPacket.type = SerialPacketType::CHARACTER_LOAD;
strncpy(newPacket.handle, config["client.handle"].c_str(), PACKET_STRING_SIZE); strncpy(newPacket.handle, config["client.handle"].c_str(), PACKET_STRING_SIZE);
@@ -175,11 +173,10 @@ void InWorld::Render(SDL_Surface* const screen) {
//draw the entities //draw the entities
for (auto& it : characterMap) { for (auto& it : characterMap) {
//TODO: depth ordering //TODO: (1) depth ordering
it.second.DrawTo(screen, camera.x, camera.y); it.second.DrawTo(screen, camera.x, camera.y);
} }
for (auto& it : monsterMap) { for (auto& it : monsterMap) {
//TODO: depth ordering
it.second.DrawTo(screen, camera.x, camera.y); it.second.DrawTo(screen, camera.x, camera.y);
} }
@@ -224,7 +221,7 @@ void InWorld::KeyDown(SDL_KeyboardEvent const& key) {
//hotkeys //hotkeys
switch(key.keysym.sym) { switch(key.keysym.sym) {
case SDLK_ESCAPE: case SDLK_ESCAPE:
//TODO: the escape key should actually control menus and stuff //TODO: (9) the escape key should actually control menus and stuff
SendLogoutRequest(); SendLogoutRequest();
return; return;
} }
+4 -6
View File
@@ -100,14 +100,14 @@ void LobbyMenu::FrameEnd() {
} }
void LobbyMenu::Render(SDL_Surface* const screen) { void LobbyMenu::Render(SDL_Surface* const screen) {
//TODO: I need a proper UI system for the entire client and the editor //TODO: (9) I need a proper UI system for the entire client and the editor
//UI //UI
search.DrawTo(screen); search.DrawTo(screen);
join.DrawTo(screen); join.DrawTo(screen);
back.DrawTo(screen); back.DrawTo(screen);
//TODO: draw headers for the server list //TODO: (9) draw headers for the server list
for (int i = 0; i < serverInfo.size(); i++) { for (int i = 0; i < serverInfo.size(); i++) {
//draw the selected server's highlight //draw the selected server's highlight
if (selection == &serverInfo[i]) { if (selection == &serverInfo[i]) {
@@ -131,8 +131,6 @@ void LobbyMenu::Render(SDL_Surface* const screen) {
if (!serverInfo[i].compatible) { if (!serverInfo[i].compatible) {
font.DrawStringTo("?", screen, listBox.x - font.GetCharW(), listBox.y + i*listBox.h); font.DrawStringTo("?", screen, listBox.x - font.GetCharW(), listBox.y + i*listBox.h);
} }
//TODO: ping/delay?
} }
} }
@@ -254,11 +252,11 @@ void LobbyMenu::HandleLoginResponse(ClientPacket* const argPacket) {
} }
void LobbyMenu::HandleJoinRejection(TextPacket* const argPacket) { void LobbyMenu::HandleJoinRejection(TextPacket* const argPacket) {
//TODO: Better output for join rejection //TODO: (9) Better output for join rejection
} }
void LobbyMenu::HandleLoginRejection(TextPacket* const argPacket) { void LobbyMenu::HandleLoginRejection(TextPacket* const argPacket) {
//TODO: Better output for login rejection //TODO: (9) Better output for login rejection
} }
//------------------------- //-------------------------
+2 -3
View File
@@ -88,8 +88,7 @@ void MainMenu::Render(SDL_Surface* const screen) {
//text //text
font.DrawStringTo("Thanks for playing!", screen, 50, screen->h - 50 - image.GetClipH() * 2); font.DrawStringTo("Thanks for playing!", screen, 50, screen->h - 50 - image.GetClipH() * 2);
font.DrawStringTo("You can get the latest version at: ", screen, 50, screen->h - 50 - image.GetClipH() * 1); font.DrawStringTo("You can get the latest version at: ", screen, 50, screen->h - 50 - image.GetClipH() * 1);
font.DrawStringTo("https://github.com/Ratstail91/Tortuga", screen, 50, screen->h - 50 - image.GetClipH() * 0); font.DrawStringTo("krgamestudios.com", screen, 50, screen->h - 50 - image.GetClipH() * 0);
//TODO: replace this with a website address
} }
//------------------------- //-------------------------
@@ -109,7 +108,7 @@ void MainMenu::MouseButtonDown(SDL_MouseButtonEvent const& button) {
} }
void MainMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) { void MainMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) {
//TODO: Buttons should only register as "selected" when the left button is used //TODO: (9) Buttons should only register as "selected" when the left button is used
if (startButton.MouseButtonUp(button) == Button::State::HOVER) { if (startButton.MouseButtonUp(button) == Button::State::HOVER) {
SetNextScene(SceneList::LOBBYMENU); SetNextScene(SceneList::LOBBYMENU);
} }
+1 -1
View File
@@ -28,7 +28,7 @@
#include "raster_font.hpp" #include "raster_font.hpp"
#include "button.hpp" #include "button.hpp"
//TODO: The options screen needs to be USED //NOTE: The options screen needs to be USED
class OptionsMenu : public BaseScene { class OptionsMenu : public BaseScene {
public: public:
//Public access members //Public access members
@@ -34,14 +34,11 @@ struct CharacterPacket : SerialPacketBase {
//the owner //the owner
int accountIndex; int accountIndex;
//TODO: Authentication token?
//location //location
int roomIndex; int roomIndex;
Vector2 origin; Vector2 origin;
Vector2 motion; Vector2 motion;
//TODO: gameplay components: equipment, items, buffs, debuffs...
}; };
void serializeCharacter(void* buffer, CharacterPacket* packet); void serializeCharacter(void* buffer, CharacterPacket* packet);
@@ -28,6 +28,7 @@ struct ClientPacket : SerialPacketBase {
int clientIndex; int clientIndex;
int accountIndex; int accountIndex;
char username[PACKET_STRING_SIZE]; char username[PACKET_STRING_SIZE];
//TODO: (9) password, auth token
}; };
void serializeClient(void* buffer, ClientPacket* packet); void serializeClient(void* buffer, ClientPacket* packet);
@@ -44,8 +44,6 @@ void serializeMonster(void* buffer, MonsterPacket* packet) {
serialCopy(&buffer, &packet->origin.y, sizeof(double)); serialCopy(&buffer, &packet->origin.y, sizeof(double));
serialCopy(&buffer, &packet->motion.x, sizeof(double)); serialCopy(&buffer, &packet->motion.x, sizeof(double));
serialCopy(&buffer, &packet->motion.y, sizeof(double)); serialCopy(&buffer, &packet->motion.y, sizeof(double));
//TODO: attack data
} }
void deserializeMonster(void* buffer, MonsterPacket* packet) { void deserializeMonster(void* buffer, MonsterPacket* packet) {
@@ -69,6 +67,4 @@ void deserializeMonster(void* buffer, MonsterPacket* packet) {
deserialCopy(&buffer, &packet->origin.y, sizeof(double)); deserialCopy(&buffer, &packet->origin.y, sizeof(double));
deserialCopy(&buffer, &packet->motion.x, sizeof(double)); deserialCopy(&buffer, &packet->motion.x, sizeof(double));
deserialCopy(&buffer, &packet->motion.y, sizeof(double)); deserialCopy(&buffer, &packet->motion.y, sizeof(double));
//TODO: attack data
} }
@@ -38,8 +38,6 @@ struct MonsterPacket : SerialPacketBase {
int roomIndex; int roomIndex;
Vector2 origin; Vector2 origin;
Vector2 motion; Vector2 motion;
//TODO: attack data
}; };
void serializeMonster(void* buffer, MonsterPacket* packet); void serializeMonster(void* buffer, MonsterPacket* packet);
+1 -1
View File
@@ -34,7 +34,7 @@
typedef SerialPacketBase SerialPacket; typedef SerialPacketBase SerialPacket;
//DOCS: NETWORK_VERSION is used to discern compatible servers and clients //DOCS: NETWORK_VERSION is used to discern compatible servers and clients
constexpr int NETWORK_VERSION = 20150205; constexpr int NETWORK_VERSION = 20150213;
union MaxPacket { union MaxPacket {
CharacterPacket a; CharacterPacket a;
+46 -46
View File
@@ -27,10 +27,9 @@
* valid data, but it will still be carried in that packet's format. * valid data, but it will still be carried in that packet's format.
*/ */
//TODO: This needs to be smoothed out
enum class SerialPacketType { enum class SerialPacketType {
//default: there is something wrong //default: there is something wrong
NONE = 0, NONE,
//------------------------- //-------------------------
//ServerPacket //ServerPacket
@@ -38,12 +37,12 @@ enum class SerialPacketType {
//------------------------- //-------------------------
//heartbeat //heartbeat
PING = 1, PING,
PONG = 2, PONG,
//Used for finding available servers //Used for finding available servers
BROADCAST_REQUEST = 3, BROADCAST_REQUEST,
BROADCAST_RESPONSE = 4, BROADCAST_RESPONSE,
//------------------------- //-------------------------
//ClientPacket //ClientPacket
@@ -51,24 +50,24 @@ enum class SerialPacketType {
//------------------------- //-------------------------
//Connecting to a server as a client //Connecting to a server as a client
JOIN_REQUEST = 5, JOIN_REQUEST,
JOIN_RESPONSE = 6, JOIN_RESPONSE,
//disconnect from the server //disconnect from the server
DISCONNECT_REQUEST = 7, DISCONNECT_REQUEST,
DISCONNECT_RESPONSE = 8, DISCONNECT_RESPONSE,
DISCONNECT_FORCED = 9, ADMIN_DISCONNECT_FORCED,
//load the account //load the account
LOGIN_REQUEST = 10, LOGIN_REQUEST,
LOGIN_RESPONSE = 11, LOGIN_RESPONSE,
//unload the account //unload the account
LOGOUT_REQUEST = 12, LOGOUT_REQUEST,
LOGOUT_RESPONSE = 13, LOGOUT_RESPONSE,
//shut down the server //shut down the server
SHUTDOWN_REQUEST = 14, ADMIN_SHUTDOWN_REQUEST,
//------------------------- //-------------------------
//RegionPacket //RegionPacket
@@ -76,32 +75,32 @@ enum class SerialPacketType {
//------------------------- //-------------------------
//map data //map data
REGION_REQUEST = 15, //NOTE: technically a query REGION_REQUEST,
REGION_CONTENT = 16, REGION_CONTENT,
//------------------------- //-------------------------
//CharacterPacket //CharacterPacket
// character index, // character index,
// handle, avatar, // handle, avatar,
// account index (owner), // account index (owner),
// room index, origin, motion, // room index, origin, motion
// statistics
//------------------------- //-------------------------
//character management //character management
CHARACTER_CREATE = 17, CHARACTER_CREATE,
CHARACTER_DELETE = 18, CHARACTER_DELETE,
CHARACTER_LOAD = 19, CHARACTER_LOAD,
CHARACTER_UNLOAD = 20, CHARACTER_UNLOAD,
//find out info from the server //find out info from the server
QUERY_CHARACTER_EXISTS = 21, QUERY_CHARACTER_EXISTS,
QUERY_CHARACTER_STATS = 22, QUERY_CHARACTER_STATS,
QUERY_CHARACTER_LOCATION = 23, QUERY_CHARACTER_LOCATION,
//set the info in the server //set the info in the server
CHARACTER_MOVEMENT = 24, CHARACTER_MOVEMENT,
CHARACTER_ATTACK = 25, CHARACTER_ATTACK,
CHARACTER_DAMAGE,
//admin control //admin control
// ADMIN_SET_CHARACTER_ORIGIN, // ADMIN_SET_CHARACTER_ORIGIN,
@@ -109,20 +108,21 @@ enum class SerialPacketType {
//------------------------- //-------------------------
//MonsterPacket //MonsterPacket
// monster index, // monster index,
// handle, avatar, hitbox // handle, avatar
// bounds
// room index, origin, motion // room index, origin, motion
// TODO: attack data
//------------------------- //-------------------------
MONSTER_CREATE = 26, MONSTER_CREATE,
MONSTER_DELETE = 27, MONSTER_DELETE,
QUERY_MONSTER_EXISTS = 28, //a list of monsters in a room QUERY_MONSTER_EXISTS,
QUERY_MONSTER_STATS = 29, //statistics of a specific monster type or instance QUERY_MONSTER_STATS,
QUERY_MONSTER_LOCATION = 30, //umm... QUERY_MONSTER_LOCATION,
MONSTER_MOVEMENT = 31, //monster movement MONSTER_MOVEMENT,
MONSTER_ATTACK = 32, MONSTER_ATTACK,
MONSTER_DAMAGE,
//------------------------- //-------------------------
//TextPacket //TextPacket
@@ -130,21 +130,21 @@ enum class SerialPacketType {
//------------------------- //-------------------------
//general speech //general speech
TEXT_BROADCAST = 33, TEXT_BROADCAST,
//rejection/error messages //rejection/error messages
JOIN_REJECTION = 34, JOIN_REJECTION,
LOGIN_REJECTION = 35, LOGIN_REJECTION,
REGION_REJECTION = 36, REGION_REJECTION,
CHARACTER_REJECTION = 37, CHARACTER_REJECTION,
MONSTER_REJECTION = 38, MONSTER_REJECTION,
SHUTDOWN_REJECTION = 39, SHUTDOWN_REJECTION,
//------------------------- //-------------------------
//not used //not used
//------------------------- //-------------------------
LAST = 40 LAST
}; };
#endif #endif
+8 -4
View File
@@ -57,12 +57,12 @@ void serializePacket(void* buffer, SerialPacketBase* packet) {
case SerialPacketType::JOIN_RESPONSE: case SerialPacketType::JOIN_RESPONSE:
case SerialPacketType::DISCONNECT_REQUEST: case SerialPacketType::DISCONNECT_REQUEST:
case SerialPacketType::DISCONNECT_RESPONSE: case SerialPacketType::DISCONNECT_RESPONSE:
case SerialPacketType::DISCONNECT_FORCED: case SerialPacketType::ADMIN_DISCONNECT_FORCED:
case SerialPacketType::LOGIN_REQUEST: case SerialPacketType::LOGIN_REQUEST:
case SerialPacketType::LOGIN_RESPONSE: case SerialPacketType::LOGIN_RESPONSE:
case SerialPacketType::LOGOUT_REQUEST: case SerialPacketType::LOGOUT_REQUEST:
case SerialPacketType::LOGOUT_RESPONSE: case SerialPacketType::LOGOUT_RESPONSE:
case SerialPacketType::SHUTDOWN_REQUEST: case SerialPacketType::ADMIN_SHUTDOWN_REQUEST:
serializeClient(buffer, static_cast<ClientPacket*>(packet)); serializeClient(buffer, static_cast<ClientPacket*>(packet));
break; break;
case SerialPacketType::REGION_REQUEST: case SerialPacketType::REGION_REQUEST:
@@ -78,6 +78,7 @@ void serializePacket(void* buffer, SerialPacketBase* packet) {
case SerialPacketType::QUERY_CHARACTER_LOCATION: case SerialPacketType::QUERY_CHARACTER_LOCATION:
case SerialPacketType::CHARACTER_MOVEMENT: case SerialPacketType::CHARACTER_MOVEMENT:
case SerialPacketType::CHARACTER_ATTACK: case SerialPacketType::CHARACTER_ATTACK:
case SerialPacketType::CHARACTER_DAMAGE:
serializeCharacter(buffer, static_cast<CharacterPacket*>(packet)); serializeCharacter(buffer, static_cast<CharacterPacket*>(packet));
break; break;
case SerialPacketType::MONSTER_CREATE: case SerialPacketType::MONSTER_CREATE:
@@ -87,6 +88,7 @@ void serializePacket(void* buffer, SerialPacketBase* packet) {
case SerialPacketType::QUERY_MONSTER_LOCATION: case SerialPacketType::QUERY_MONSTER_LOCATION:
case SerialPacketType::MONSTER_MOVEMENT: case SerialPacketType::MONSTER_MOVEMENT:
case SerialPacketType::MONSTER_ATTACK: case SerialPacketType::MONSTER_ATTACK:
case SerialPacketType::MONSTER_DAMAGE:
serializeMonster(buffer, static_cast<MonsterPacket*>(packet)); serializeMonster(buffer, static_cast<MonsterPacket*>(packet));
break; break;
case SerialPacketType::TEXT_BROADCAST: case SerialPacketType::TEXT_BROADCAST:
@@ -117,12 +119,12 @@ void deserializePacket(void* buffer, SerialPacketBase* packet) {
case SerialPacketType::JOIN_RESPONSE: case SerialPacketType::JOIN_RESPONSE:
case SerialPacketType::DISCONNECT_REQUEST: case SerialPacketType::DISCONNECT_REQUEST:
case SerialPacketType::DISCONNECT_RESPONSE: case SerialPacketType::DISCONNECT_RESPONSE:
case SerialPacketType::DISCONNECT_FORCED: case SerialPacketType::ADMIN_DISCONNECT_FORCED:
case SerialPacketType::LOGIN_REQUEST: case SerialPacketType::LOGIN_REQUEST:
case SerialPacketType::LOGIN_RESPONSE: case SerialPacketType::LOGIN_RESPONSE:
case SerialPacketType::LOGOUT_REQUEST: case SerialPacketType::LOGOUT_REQUEST:
case SerialPacketType::LOGOUT_RESPONSE: case SerialPacketType::LOGOUT_RESPONSE:
case SerialPacketType::SHUTDOWN_REQUEST: case SerialPacketType::ADMIN_SHUTDOWN_REQUEST:
deserializeClient(buffer, static_cast<ClientPacket*>(packet)); deserializeClient(buffer, static_cast<ClientPacket*>(packet));
break; break;
case SerialPacketType::REGION_REQUEST: case SerialPacketType::REGION_REQUEST:
@@ -138,6 +140,7 @@ void deserializePacket(void* buffer, SerialPacketBase* packet) {
case SerialPacketType::QUERY_CHARACTER_LOCATION: case SerialPacketType::QUERY_CHARACTER_LOCATION:
case SerialPacketType::CHARACTER_MOVEMENT: case SerialPacketType::CHARACTER_MOVEMENT:
case SerialPacketType::CHARACTER_ATTACK: case SerialPacketType::CHARACTER_ATTACK:
case SerialPacketType::CHARACTER_DAMAGE:
deserializeCharacter(buffer, static_cast<CharacterPacket*>(packet)); deserializeCharacter(buffer, static_cast<CharacterPacket*>(packet));
break; break;
case SerialPacketType::MONSTER_CREATE: case SerialPacketType::MONSTER_CREATE:
@@ -147,6 +150,7 @@ void deserializePacket(void* buffer, SerialPacketBase* packet) {
case SerialPacketType::QUERY_MONSTER_LOCATION: case SerialPacketType::QUERY_MONSTER_LOCATION:
case SerialPacketType::MONSTER_MOVEMENT: case SerialPacketType::MONSTER_MOVEMENT:
case SerialPacketType::MONSTER_ATTACK: case SerialPacketType::MONSTER_ATTACK:
case SerialPacketType::MONSTER_DAMAGE:
deserializeMonster(buffer, static_cast<MonsterPacket*>(packet)); deserializeMonster(buffer, static_cast<MonsterPacket*>(packet));
break; break;
case SerialPacketType::TEXT_BROADCAST: case SerialPacketType::TEXT_BROADCAST:
-1
View File
@@ -140,7 +140,6 @@ int UDPNetworkUtility::SendToAllChannels(void* data, int len) {
return sent; return sent;
} }
//TODO: put a void* and int* parameter list here
int UDPNetworkUtility::Receive() { int UDPNetworkUtility::Receive() {
memset(packet->data, 0, packet->maxlen); memset(packet->data, 0, packet->maxlen);
int ret = SDLNet_UDP_Recv(socket, packet); int ret = SDLNet_UDP_Recv(socket, packet);
+1 -1
View File
@@ -11,5 +11,5 @@ function mapSaver.Save(r)
io.write("map_saver:Save(", Region.GetX(r), ", ", Region.GetY(r), ")\n") io.write("map_saver:Save(", Region.GetX(r), ", ", Region.GetY(r), ")\n")
end end
--TODO: create a flexible saving & loading system --TODO: (9) create a flexible saving & loading system
return mapSaver return mapSaver
+4 -4
View File
@@ -1,10 +1,10 @@
--TODO: An archive table of all dead characters --TODO: (9) An archive table of all dead characters
CREATE TABLE IF NOT EXISTS Accounts ( CREATE TABLE IF NOT EXISTS Accounts (
uid INTEGER PRIMARY KEY AUTOINCREMENT, uid INTEGER PRIMARY KEY AUTOINCREMENT,
username varchar(100) UNIQUE, --TODO: Swap username for email address username varchar(100) UNIQUE, --TODO: (9) Swap username for email address
--TODO: server-client security --server-client security
-- passhash varchar(100), -- passhash varchar(100),
-- passsalt varchar(100), -- passsalt varchar(100),
@@ -101,5 +101,5 @@ CREATE TABLE IF NOT EXISTS WornEquipment (
--unique information --unique information
durability INTEGER DEFAULT 0, durability INTEGER DEFAULT 0,
stats INTEGER REFERENCES StatisticSets(uid) stats INTEGER REFERENCES StatisticSets(uid)
--TODO: attached script? --attached script?
); );
+1 -1
View File
@@ -47,7 +47,7 @@ private:
int clientIndex; int clientIndex;
std::string username; std::string username;
//TODO: password //password/auth token
//bit fields? //bit fields?
bool blackListed = false; bool blackListed = false;
+11 -11
View File
@@ -30,45 +30,45 @@ MonsterManager::~MonsterManager() {
} }
int MonsterManager::Create(std::string) { int MonsterManager::Create(std::string) {
//TODO: Create //Create
} }
void MonsterManager::Unload(int uid) { void MonsterManager::Unload(int uid) {
//TODO: Unload //Unload
} }
void MonsterManager::UnloadAll() { void MonsterManager::UnloadAll() {
//TODO: UnloadAll //UnloadAll
} }
void MonsterManager::UnloadIf(std::function<bool(std::pair<const int, MonsterData const&>)> fn) { void MonsterManager::UnloadIf(std::function<bool(std::pair<const int, MonsterData const&>)> fn) {
//TODO: UnloadIf //UnloadIf
} }
MonsterData* MonsterManager::Get(int uid) { MonsterData* MonsterManager::Get(int uid) {
//TODO: Get //Get
} }
int MonsterManager::GetLoadedCount() { int MonsterManager::GetLoadedCount() {
//TODO: GetLoadedCount //GetLoadedCount
} }
std::map<int, MonsterData>* MonsterManager::GetContainer() { std::map<int, MonsterData>* MonsterManager::GetContainer() {
//TODO: GetContainer //GetContainer
} }
lua_State* MonsterManager::SetLuaState(lua_State* L) { lua_State* MonsterManager::SetLuaState(lua_State* L) {
//TODO: SetLuaState //SetLuaState
} }
lua_State* MonsterManager::GetLuaState() { lua_State* MonsterManager::GetLuaState() {
//TODO: GetLuaState //GetLuaState
} }
sqlite3* MonsterManager::SetDatabase(sqlite3* db) { sqlite3* MonsterManager::SetDatabase(sqlite3* db) {
//TODO: SetDatabase //SetDatabase
} }
sqlite3* MonsterManager::GetDatabase() { sqlite3* MonsterManager::GetDatabase() {
//TODO: GetDatabase //GetDatabase
} }
-1
View File
@@ -66,7 +66,6 @@ static int getWaypointMgr(lua_State* L) {
} }
static int initialize(lua_State* L) { static int initialize(lua_State* L) {
//TODO: This could fit into the room system's globals
RoomData* room = static_cast<RoomData*>(lua_touserdata(L, 1)); RoomData* room = static_cast<RoomData*>(lua_touserdata(L, 1));
//set the refs of these parameters (backwards, since it pops from the top of the stack) //set the refs of these parameters (backwards, since it pops from the top of the stack)
+1 -1
View File
@@ -71,7 +71,7 @@ int unloadRoom(lua_State* L) {
} }
int getRoom(lua_State* L) { int getRoom(lua_State* L) {
//TODO: integer vs name for getRoom() //integer vs name for getRoom()
RoomManager& roomMgr = RoomManager::GetSingleton(); RoomManager& roomMgr = RoomManager::GetSingleton();
RoomData* room = nullptr; RoomData* room = nullptr;
+34 -23
View File
@@ -65,46 +65,57 @@ private:
//handle incoming traffic //handle incoming traffic
void HandlePacket(SerialPacket* const); void HandlePacket(SerialPacket* const);
//heartbeat sustem //heartbeat system
void HandlePing(ServerPacket* const); void hPing(ServerPacket* const);
void HandlePong(ServerPacket* const); void hPong(ServerPacket* const);
//basic connections //basic connections
void HandleBroadcastRequest(ServerPacket* const); void hBroadcastRequest(ServerPacket* const);
void HandleJoinRequest(ClientPacket* const); void hJoinRequest(ClientPacket* const);
void HandleLoginRequest(ClientPacket* const); void hLoginRequest(ClientPacket* const);
//client disconnections //client disconnections
void HandleLogoutRequest(ClientPacket* const); void hLogoutRequest(ClientPacket* const);
void HandleDisconnectRequest(ClientPacket* const); void hDisconnectRequest(ClientPacket* const);
//server commands //server commands
void HandleDisconnectForced(ClientPacket* const); void hAdminDisconnectForced(ClientPacket* const);
void HandleShutdownRequest(ClientPacket* const); void hAdminShutdownRequest(ClientPacket* const);
//data management //data management
void HandleRegionRequest(RegionPacket* const); void hRegionRequest(RegionPacket* const);
void HandleCharacterExists(CharacterPacket* const); void hQueryCharacterExists(CharacterPacket* const);
void hQueryCharacterStats(CharacterPacket* const);
void SaveServerState(); void hQueryCharacterLocation(CharacterPacket* const);
void FullClientUnload(int index); void hQueryMonsterExists(MonsterPacket* const);
void FullAccountUnload(int index); void hQueryMonsterStats(MonsterPacket* const);
void FullCharacterUnload(int index); void hQueryMonsterLocation(MonsterPacket* const);
//character management //character management
void HandleCharacterCreate(CharacterPacket* const); void hCharacterCreate(CharacterPacket* const);
void HandleCharacterDelete(CharacterPacket* const); void hCharacterDelete(CharacterPacket* const);
void HandleCharacterLoad(CharacterPacket* const); void hCharacterLoad(CharacterPacket* const);
void HandleCharacterUnload(CharacterPacket* const); void hCharacterUnload(CharacterPacket* const);
//character movement //character movement
void HandleCharacterMovement(CharacterPacket* const); void hCharacterMovement(CharacterPacket* const);
void HandleCharacterAttack(CharacterPacket* const); void hCharacterAttack(CharacterPacket* const);
void hCharacterDamage(CharacterPacket* const);
//character management
void hMonsterDamage(MonsterPacket* const);
//chat
void hTextBroadcast(TextPacket* const);
//utility methods //utility methods
void PumpPacket(SerialPacket* const); void PumpPacket(SerialPacket* const);
void PumpPacketProximity(SerialPacket* const argPacket, int roomIndex, Vector2 position, int distance); void PumpPacketProximity(SerialPacket* const argPacket, int roomIndex, Vector2 position, int distance);
void CopyCharacterToPacket(CharacterPacket* const packet, int characterIndex); void CopyCharacterToPacket(CharacterPacket* const packet, int characterIndex);
void SaveServerState();
void FullClientUnload(int index);
void FullAccountUnload(int index);
void FullCharacterUnload(int index);
//APIs and utilities //APIs and utilities
sqlite3* database = nullptr; sqlite3* database = nullptr;
+5 -5
View File
@@ -144,12 +144,12 @@ void ServerApplication::HandleCharacterUnload(CharacterPacket* const argPacket)
AccountData* accountData = accountMgr.Get(characterData->GetOwner()); AccountData* accountData = accountMgr.Get(characterData->GetOwner());
if (!accountData) { if (!accountData) {
return; //TODO: logic_error return;
} }
ClientData* clientData = clientMgr.Get(accountData->GetClientIndex()); ClientData* clientData = clientMgr.Get(accountData->GetClientIndex());
if (!clientData) { if (!clientData) {
return; //TODO: logic_error return;
} }
//check for fraud //check for fraud
@@ -175,7 +175,7 @@ void ServerApplication::HandleCharacterUnload(CharacterPacket* const argPacket)
//character movement //character movement
//------------------------- //-------------------------
//TODO: Could replace this verbosity with a "verify" method, taking a client, account and character ptr as arguments //TODO: (9) Could replace this verbosity with a "verify" method, taking a client, account and character ptr as arguments
void ServerApplication::HandleCharacterMovement(CharacterPacket* const argPacket) { void ServerApplication::HandleCharacterMovement(CharacterPacket* const argPacket) {
//get the specified objects //get the specified objects
@@ -197,7 +197,7 @@ void ServerApplication::HandleCharacterMovement(CharacterPacket* const argPacket
//check if allowed //check if allowed
if (characterData->GetOwner() != argPacket->accountIndex && !accountData->GetModerator() && !accountData->GetAdministrator()) { if (characterData->GetOwner() != argPacket->accountIndex && !accountData->GetModerator() && !accountData->GetAdministrator()) {
//TODO: send to the client? //TODO: (9) send to the client?
std::cerr << "Failed to set character motion due to lack of permissions targeting uid(" << argPacket->characterIndex << ")" << std::endl; std::cerr << "Failed to set character motion due to lack of permissions targeting uid(" << argPacket->characterIndex << ")" << std::endl;
return; return;
} }
@@ -235,5 +235,5 @@ void ServerApplication::HandleCharacterMovement(CharacterPacket* const argPacket
} }
void ServerApplication::HandleCharacterAttack(CharacterPacket* const) { void ServerApplication::HandleCharacterAttack(CharacterPacket* const) {
//TODO: bounce graphical attack data //TODO: (9) bounce graphical attack data
} }
+1 -1
View File
@@ -172,5 +172,5 @@ void ServerApplication::HandleDisconnectRequest(ClientPacket* const argPacket) {
} }
void ServerApplication::HandleDisconnectForced(ClientPacket* const argPacket) { void ServerApplication::HandleDisconnectForced(ClientPacket* const argPacket) {
//TODO: HandleDisconnectForced //HandleDisconnectForced
} }
+2 -2
View File
@@ -28,10 +28,10 @@
//General data management //General data management
//------------------------- //-------------------------
//TODO: Queries //NOTE: Queries go here
void ServerApplication::SaveServerState() { void ServerApplication::SaveServerState() {
//TODO: SaveServerState //SaveServerState
} }
//------------------------- //-------------------------
+44 -33
View File
@@ -128,7 +128,6 @@ void ServerApplication::Init(int argc, char* argv[]) {
//debug output //debug output
//------------------------- //-------------------------
//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;
std::cout << "Internal sizes:" << std::endl; std::cout << "Internal sizes:" << std::endl;
@@ -195,7 +194,7 @@ void ServerApplication::Proc() {
void ServerApplication::Quit() { void ServerApplication::Quit() {
std::cout << "Shutting down" << std::endl; std::cout << "Shutting down" << std::endl;
//TODO: save the server state //TODO: (9) save the server state
//close the managers //close the managers
accountMgr.UnloadAll(); accountMgr.UnloadAll();
@@ -221,84 +220,96 @@ void ServerApplication::HandlePacket(SerialPacket* const argPacket) {
switch(argPacket->type) { switch(argPacket->type) {
//heartbeat system //heartbeat system
case SerialPacketType::PING: case SerialPacketType::PING:
HandlePing(static_cast<ServerPacket*>(argPacket)); hPing(static_cast<ServerPacket*>(argPacket));
break; break;
case SerialPacketType::PONG: case SerialPacketType::PONG:
HandlePong(static_cast<ServerPacket*>(argPacket)); hPong(static_cast<ServerPacket*>(argPacket));
break; break;
//client connections //client connections
case SerialPacketType::BROADCAST_REQUEST: case SerialPacketType::BROADCAST_REQUEST:
HandleBroadcastRequest(static_cast<ServerPacket*>(argPacket)); hBroadcastRequest(static_cast<ServerPacket*>(argPacket));
break; break;
case SerialPacketType::JOIN_REQUEST: case SerialPacketType::JOIN_REQUEST:
HandleJoinRequest(static_cast<ClientPacket*>(argPacket)); hJoinRequest(static_cast<ClientPacket*>(argPacket));
break; break;
case SerialPacketType::LOGIN_REQUEST: case SerialPacketType::LOGIN_REQUEST:
HandleLoginRequest(static_cast<ClientPacket*>(argPacket)); hLoginRequest(static_cast<ClientPacket*>(argPacket));
break; break;
//client disconnections //client disconnections
case SerialPacketType::LOGOUT_REQUEST: case SerialPacketType::LOGOUT_REQUEST:
HandleLogoutRequest(static_cast<ClientPacket*>(argPacket)); hLogoutRequest(static_cast<ClientPacket*>(argPacket));
break; break;
case SerialPacketType::DISCONNECT_REQUEST: case SerialPacketType::DISCONNECT_REQUEST:
HandleDisconnectRequest(static_cast<ClientPacket*>(argPacket)); hDisconnectRequest(static_cast<ClientPacket*>(argPacket));
break; break;
//server commands //server commands
// case SerialPacketType::DISCONNECT_FORCED: case SerialPacketType::ADMIN_DISCONNECT_FORCED:
// HandleDisconnectForced(static_cast<ClientPacket*>(argPacket)); hAdminDisconnectForced(static_cast<ClientPacket*>(argPacket));
// break; break;
case SerialPacketType::SHUTDOWN_REQUEST: case SerialPacketType::ADMIN_SHUTDOWN_REQUEST:
HandleShutdownRequest(static_cast<ClientPacket*>(argPacket)); hAdminShutdownRequest(static_cast<ClientPacket*>(argPacket));
break; break;
//data management & queries //data management & queries
case SerialPacketType::REGION_REQUEST: case SerialPacketType::REGION_REQUEST:
HandleRegionRequest(static_cast<RegionPacket*>(argPacket)); hRegionRequest(static_cast<RegionPacket*>(argPacket));
break; break;
case SerialPacketType::QUERY_CHARACTER_EXISTS: case SerialPacketType::QUERY_CHARACTER_EXISTS:
HandleCharacterExists(static_cast<CharacterPacket*>(argPacket)); hQueryCharacterExists(static_cast<CharacterPacket*>(argPacket));
break; break;
case SerialPacketType::QUERY_CHARACTER_STATS:
hQueryCharacterStats(static_cast<CharacterPacket*>(argPacket));
break;
case SerialPacketType::QUERY_CHARACTER_LOCATION:
hQueryCharacterLocation(static_cast<CharacterPacket*>(argPacket));
break;
case SerialPacketType::QUERY_MONSTER_EXISTS: case SerialPacketType::QUERY_MONSTER_EXISTS:
// HandleMonsterExists(static_cast<MonsterPacket*>(argPacket)); hQueryMonsterExists(static_cast<MonsterPacket*>(argPacket));
break;
case SerialPacketType::QUERY_MONSTER_STATS:
hQueryMonsterStats(static_cast<MonsterPacket*>(argPacket));
break;
case SerialPacketType::QUERY_MONSTER_LOCATION:
hQueryMonsterLocation(static_cast<MonsterPacket*>(argPacket));
break; break;
//character management //character management
case SerialPacketType::CHARACTER_CREATE: case SerialPacketType::CHARACTER_CREATE:
HandleCharacterCreate(static_cast<CharacterPacket*>(argPacket)); hCharacterCreate(static_cast<CharacterPacket*>(argPacket));
break; break;
case SerialPacketType::CHARACTER_DELETE: case SerialPacketType::CHARACTER_DELETE:
HandleCharacterDelete(static_cast<CharacterPacket*>(argPacket)); hCharacterDelete(static_cast<CharacterPacket*>(argPacket));
break; break;
case SerialPacketType::CHARACTER_LOAD: case SerialPacketType::CHARACTER_LOAD:
HandleCharacterLoad(static_cast<CharacterPacket*>(argPacket)); hCharacterLoad(static_cast<CharacterPacket*>(argPacket));
break; break;
case SerialPacketType::CHARACTER_UNLOAD: case SerialPacketType::CHARACTER_UNLOAD:
HandleCharacterUnload(static_cast<CharacterPacket*>(argPacket)); hCharacterUnload(static_cast<CharacterPacket*>(argPacket));
break; break;
//character movement //character movement
case SerialPacketType::CHARACTER_MOVEMENT: case SerialPacketType::CHARACTER_MOVEMENT:
HandleCharacterMovement(static_cast<CharacterPacket*>(argPacket)); hCharacterMovement(static_cast<CharacterPacket*>(argPacket));
break; break;
case SerialPacketType::CHARACTER_ATTACK: case SerialPacketType::CHARACTER_ATTACK:
HandleCharacterAttack(static_cast<CharacterPacket*>(argPacket)); hCharacterAttack(static_cast<CharacterPacket*>(argPacket));
break;
case SerialPacketType::CHARACTER_DAMAGE:
hCharacterDamage(static_cast<CharacterPacket*>(argPacket));
break; break;
//monster management //monster management
case SerialPacketType::MONSTER_CREATE: case SerialPacketType::MONSTER_DAMAGE:
// HandleMonsterCreate(static_cast<MonsterPacket*>(argPacket)); hMonsterDamage(static_cast<MonsterPacket*>(argPacket));
break; break;
case SerialPacketType::MONSTER_DELETE:
// HandleMonsterDelete(static_cast<MonsterPacket*>(argPacket)); //chat
break; case SerialPacketType::TEXT_BROADCAST:
case SerialPacketType::MONSTER_MOVEMENT: hTextBroadcast(static_cast<TextPacket*>(argPacket));
// HandleMonsterMovement(static_cast<MonsterPacket*>(argPacket));
break;
case SerialPacketType::MONSTER_ATTACK:
// HandleMonsterAttack(static_cast<MonsterPacket*>(argPacket));
break; break;
//handle errors //handle errors
@@ -27,12 +27,10 @@
static int create(lua_State* L) { static int create(lua_State* L) {
WaypointManager* mgr = static_cast<WaypointManager*>(lua_touserdata(L, 1)); WaypointManager* mgr = static_cast<WaypointManager*>(lua_touserdata(L, 1));
//TODO: create
} }
static int unload(lua_State* L) { static int unload(lua_State* L) {
WaypointManager* mgr = static_cast<WaypointManager*>(lua_touserdata(L, 1)); WaypointManager* mgr = static_cast<WaypointManager*>(lua_touserdata(L, 1));
//TODO: create
} }
static int getWaypoint(lua_State* L) { static int getWaypoint(lua_State* L) {
+18 -13
View File
@@ -7,16 +7,21 @@ TODO: Account passwords (list)
* ... * ...
* salts & hashes * salts & hashes
TODO: Make sure login errors are sent to the client TODO: Features
TODO: Split config.cfg in two, one for the server and the client * Make sure login errors are sent to the client
TODO: Add the "home" parameter to the server's config file * Split config.cfg in two, one for the server and the client
TODO: Waypoints, with positions and trigger zones (collision areas) for doors, monster spawns, etc. * Add the "home" parameter to the server's config file
TODO: Fix shoddy movement * Waypoints, with positions and trigger zones (collision areas) for doors, monster spawns, etc.
TODO: Periodic mass server saves * Fix shoddy movement
TODO: Remove the big "Shut Down" button (currently broken...) * Periodic mass server saves
TODO: Make a way for the server owner to control the server directly * Remove the big "Shut Down" button (currently broken...)
TODO: The TileSheet class should implement the surface itself * Make a way for the server owner to control the server directly
TODO: Time delay for requesting region packets * The TileSheet class should implement the surface itself
TODO: A proper logging system * Time delay for requesting region packets
TODO: Fix the const-ness of accessors * A proper logging system
TODO: Add a screenshot of the game to README.md * Fix the const-ness of accessors
* Add a screenshot of the game to README.md
* joystick/gamepad support
* add the tilesheet to the map system
* ping/delay displayed in the lobby
* login screen prompting for username & password