From da60fa8f944d88fb44db347459a0f0d07af4476e Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Wed, 4 Jun 2014 20:46:05 +1000 Subject: [PATCH] Began reworking the network code This commit devides SerialPacket into a series of different structures, all decended from a common base class. Using a union was not a good idea. --- common/gameplay/combat_data.hpp | 11 +- common/gameplay/room_data.hpp | 6 + common/gameplay/sanity_check.cpp | 3 - common/network/packet/character_packet.hpp | 53 ++++++ common/network/packet/client_packet.hpp | 34 ++++ common/network/packet/combat_packet.hpp | 46 +++++ common/network/packet/enemy_packet.hpp | 39 ++++ common/network/packet/makefile | 37 ++++ common/network/packet/region_packet.hpp | 38 ++++ common/network/packet/sanity_check.cpp | 28 +++ common/network/packet/serial_packet.hpp | 34 ++++ common/network/packet/serial_packet_base.hpp | 46 +++++ common/network/packet/serial_packet_type.hpp | 98 ++++++++++ common/network/packet/server_packet.hpp | 34 ++++ common/network/serial.cpp | 8 +- common/network/serial_packet.hpp | 188 ------------------- todo.txt | 3 + 17 files changed, 505 insertions(+), 201 deletions(-) create mode 100644 common/network/packet/character_packet.hpp create mode 100644 common/network/packet/client_packet.hpp create mode 100644 common/network/packet/combat_packet.hpp create mode 100644 common/network/packet/enemy_packet.hpp create mode 100644 common/network/packet/makefile create mode 100644 common/network/packet/region_packet.hpp create mode 100644 common/network/packet/sanity_check.cpp create mode 100644 common/network/packet/serial_packet.hpp create mode 100644 common/network/packet/serial_packet_base.hpp create mode 100644 common/network/packet/serial_packet_type.hpp create mode 100644 common/network/packet/server_packet.hpp delete mode 100644 common/network/serial_packet.hpp diff --git a/common/gameplay/combat_data.hpp b/common/gameplay/combat_data.hpp index db87851..3c45b78 100644 --- a/common/gameplay/combat_data.hpp +++ b/common/gameplay/combat_data.hpp @@ -35,11 +35,11 @@ //std namespace #include -#include +#include #include -#define COMBAT_MAX_CHARACTER_COUNT 12 -#define COMBAT_MAX_ENEMY_COUNT 12 +#define COMBAT_MAX_CHARACTERS 12 +#define COMBAT_MAX_ENEMIES 12 struct CombatData { enum class Terrain { @@ -50,9 +50,8 @@ struct CombatData { typedef std::chrono::steady_clock Clock; - //combatants, point to the std::map's internal pairs - std::list*> characterList; - std::list*> enemyList; + std::array characterArray; + std::array enemyArray; //world interaction int mapIndex = 0; diff --git a/common/gameplay/room_data.hpp b/common/gameplay/room_data.hpp index ae49465..6826314 100644 --- a/common/gameplay/room_data.hpp +++ b/common/gameplay/room_data.hpp @@ -30,6 +30,12 @@ struct RoomData { FORESTS, CAVES, }; + + /* TODO: more + * "multiple rooms system" using this structure + * Pager + * collision map + */ }; #endif diff --git a/common/gameplay/sanity_check.cpp b/common/gameplay/sanity_check.cpp index 1e20ccf..719db9f 100644 --- a/common/gameplay/sanity_check.cpp +++ b/common/gameplay/sanity_check.cpp @@ -31,7 +31,4 @@ * Since most/all of the files in this directory are header files, I've created * this source file as a "sanity check", to ensure that the above header files * are written correctly via make. - * - * Oddly enough, I'm pretty sure this is the first directory compiled in a - * clean build. */ \ No newline at end of file diff --git a/common/network/packet/character_packet.hpp b/common/network/packet/character_packet.hpp new file mode 100644 index 0000000..3b44d9b --- /dev/null +++ b/common/network/packet/character_packet.hpp @@ -0,0 +1,53 @@ +/* Copyright: (c) Kayne Ruse 2013, 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 CHARACTERPACKET_HPP_ +#define CHARACTERPACKET_HPP_ + +#include "serial_packet_base.hpp" + +#include "vector2.hpp" +#include "statistics.hpp" + +struct CharacterPacket : SerialPacketBase { + //identify the character + int characterIndex; + char handle[PACKET_STRING_SIZE]; + char avatar[PACKET_STRING_SIZE]; + + //the owner + int accountIndex; + + //location + int roomIndex; + Vector2 origin; + Vector2 motion; + + //gameplay + Statistics stats; + + //TODO: equipment + //TODO: items + //TODO: buffs + //TODO: debuffs +}; + +#endif \ No newline at end of file diff --git a/common/network/packet/client_packet.hpp b/common/network/packet/client_packet.hpp new file mode 100644 index 0000000..995bc4a --- /dev/null +++ b/common/network/packet/client_packet.hpp @@ -0,0 +1,34 @@ +/* Copyright: (c) Kayne Ruse 2013, 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 CLIENTPACKET_HPP_ +#define CLIENTPACKET_HPP_ + +#include "serial_packet_base.hpp" + +struct ClientPacket : SerialPacketBase { + int clientIndex; + int accountIndex; + char username[PACKET_STRING_SIZE]; + char password[PACKET_STRING_SIZE]; //hashed, not currently used +}; + +#endif \ No newline at end of file diff --git a/common/network/packet/combat_packet.hpp b/common/network/packet/combat_packet.hpp new file mode 100644 index 0000000..a95ca25 --- /dev/null +++ b/common/network/packet/combat_packet.hpp @@ -0,0 +1,46 @@ +/* Copyright: (c) Kayne Ruse 2013, 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 COMBATPACKET_HPP_ +#define COMBATPACKET_HPP_ + +#include "serial_packet_base.hpp" + +#include "combat_data.hpp" + +struct CombatPacket : SerialPacketBase { + //identify the combat instance + int combatIndex; + int difficulty; + CombatData::Terrain terrainType; + + //combatants + int characterArray[COMBAT_MAX_CHARACTERS]; + int enemyArray[COMBAT_MAX_ENEMIES]; + + //location + int mapIndex; + Vector2 origin; + + //TODO: rewards +}; + +#endif \ No newline at end of file diff --git a/common/network/packet/enemy_packet.hpp b/common/network/packet/enemy_packet.hpp new file mode 100644 index 0000000..bbe68c9 --- /dev/null +++ b/common/network/packet/enemy_packet.hpp @@ -0,0 +1,39 @@ +/* Copyright: (c) Kayne Ruse 2013, 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 ENEMYPACKET_HPP_ +#define ENEMYPACKET_HPP_ + +#include "serial_packet_base.hpp" + +struct EnemyPacket : SerialPacketBase { + //identify the enemy + int enemyIndex; + char handle[PACKET_STRING_SIZE]; + char avatar[PACKET_STRING_SIZE]; + + //gameplay + Statistics stats; + + //TODO: rewards +}; + +#endif \ No newline at end of file diff --git a/common/network/packet/makefile b/common/network/packet/makefile new file mode 100644 index 0000000..f993f8b --- /dev/null +++ b/common/network/packet/makefile @@ -0,0 +1,37 @@ +#config +INCLUDES+=. ../../gameplay ../../map ../../utilities +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)/,libcommon.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 diff --git a/common/network/packet/region_packet.hpp b/common/network/packet/region_packet.hpp new file mode 100644 index 0000000..8a9085e --- /dev/null +++ b/common/network/packet/region_packet.hpp @@ -0,0 +1,38 @@ +/* Copyright: (c) Kayne Ruse 2013, 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 REGIONPACKET_HPP_ +#define REGIONPACKET_HPP_ + +#include "serial_packet_base.hpp" + +#include "region.hpp" + +struct RegionPacket : SerialPacketBase { + //location/identify the region + int roomIndex; + int x, y; + + //the data + Region* region; +}; + +#endif \ No newline at end of file diff --git a/common/network/packet/sanity_check.cpp b/common/network/packet/sanity_check.cpp new file mode 100644 index 0000000..f250d69 --- /dev/null +++ b/common/network/packet/sanity_check.cpp @@ -0,0 +1,28 @@ +/* Copyright: (c) Kayne Ruse 2013, 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 "serial_packet.hpp" + +/* DOCS: Sanity check, read more + * Since most/all of the files in this directory are header files, I've created + * this source file as a "sanity check", to ensure that the above header files + * are written correctly via make. +*/ diff --git a/common/network/packet/serial_packet.hpp b/common/network/packet/serial_packet.hpp new file mode 100644 index 0000000..7b7137f --- /dev/null +++ b/common/network/packet/serial_packet.hpp @@ -0,0 +1,34 @@ +/* Copyright: (c) Kayne Ruse 2013, 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 SERIALPACKET_HPP_ +#define SERIALPACKET_HPP_ + +#include "character_packet.hpp" +#include "client_packet.hpp" +#include "combat_packet.hpp" +#include "enemy_packet.hpp" +#include "region_packet.hpp" +#include "server_packet.hpp" + +//NOTE: SerialPacket is defined in serial_packet_base.hpp + +#endif diff --git a/common/network/packet/serial_packet_base.hpp b/common/network/packet/serial_packet_base.hpp new file mode 100644 index 0000000..742c4db --- /dev/null +++ b/common/network/packet/serial_packet_base.hpp @@ -0,0 +1,46 @@ +/* Copyright: (c) Kayne Ruse 2013, 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 SERIALPACKETBASE_HPP_ +#define SERIALPACKETBASE_HPP_ + +#ifndef SERIALPACKET_HPP_ + #error Cannot include this file without 'serial_packet.hpp' +#endif + +#include "serial_packet_type.hpp" + +#include "SDL/SDL_net.h" + +#define PACKET_STRING_SIZE 100 + +struct SerialPacketBase { + //members + SerialPacketType type; + IPaddress srcAddress; + + typedef SerialPacketType Type; +}; + +typedef SerialPacketBase* SerialPacket; +typedef SerialPacketType PacketType; + +#endif diff --git a/common/network/packet/serial_packet_type.hpp b/common/network/packet/serial_packet_type.hpp new file mode 100644 index 0000000..8fbcd17 --- /dev/null +++ b/common/network/packet/serial_packet_type.hpp @@ -0,0 +1,98 @@ +/* Copyright: (c) Kayne Ruse 2013, 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 SERIALPACKETTYPE_HPP_ +#define SERIALPACKETTYPE_HPP_ + +enum class SerialPacketType { + //default: there is something wrong + NONE = 0, + + //keep alive + PING, + PONG, + + //searching for a server to join + BROADCAST_REQUEST, + BROADCAST_RESPONSE, + BROADCAST_REJECTION, + + //try to join the server + JOIN_REQUEST, + JOIN_RESPONSE, + JOIN_REJECTION, + + //mass update + SYNCHRONIZE, + + //disconnect from the server + DISCONNECT, + + //shut down the server + SHUTDOWN, + + //map data + REGION_REQUEST, + REGION_CONTENT, + REGION_REJECTION, + + //combat data + COMBAT_NEW, + COMBAT_DELETE, + COMBAT_UPDATE, + + COMBAT_ENTER_REQUEST, + COMBAT_ENTER_RESPONSE, + + COMBAT_EXIT_REQUEST, + COMBAT_EXIT_RESPONSE, + + //TODO: COMBAT info + + COMBAT_REJECTION, + + //character data + CHARACTER_NEW, + CHARACTER_DELETE, + CHARACTER_UPDATE, + + CHARACTER_STATS_REQUEST, + CHARACTER_STATS_RESPONSE, + + CHARACTER_REJECTION, + + //enemy data + ENEMY_NEW, + ENEMY_DELETE, + ENEMY_UPDATE, + + ENEMY_STATS_REQUEST, + ENEMY_STATS_RESPONSE, + + ENEMY_REJECTION, + + //more packet types go here + + //not used + LAST, +}; + +#endif \ No newline at end of file diff --git a/common/network/packet/server_packet.hpp b/common/network/packet/server_packet.hpp new file mode 100644 index 0000000..fcd4a49 --- /dev/null +++ b/common/network/packet/server_packet.hpp @@ -0,0 +1,34 @@ +/* Copyright: (c) Kayne Ruse 2013, 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 SERVERPACKET_HPP_ +#define SERVERPACKET_HPP_ + +#include "serial_packet_base.hpp" + +struct ServerPacket : SerialPacketBase { + //identify the server + char name[PACKET_STRING_SIZE]; + int playerCount; + int version; +}; + +#endif \ No newline at end of file diff --git a/common/network/serial.cpp b/common/network/serial.cpp index 961afd4..6e75c5a 100644 --- a/common/network/serial.cpp +++ b/common/network/serial.cpp @@ -103,8 +103,8 @@ void serializeCombat(SerialPacket* packet, char* buffer) { SERIALIZE(buffer, &packet->combatInfo.terrainType, sizeof(CombatData::Terrain)); //arrays - SERIALIZE(buffer, &packet->combatInfo.characterArray, COMBAT_MAX_CHARACTER_COUNT); - SERIALIZE(buffer, &packet->combatInfo.enemyArray, COMBAT_MAX_ENEMY_COUNT); + SERIALIZE(buffer, &packet->combatInfo.characterArray, COMBAT_MAX_CHARACTERS); + SERIALIZE(buffer, &packet->combatInfo.enemyArray, COMBAT_MAX_ENEMIES); //position SERIALIZE(buffer, &packet->combatInfo.mapIndex, sizeof(int)); @@ -247,8 +247,8 @@ void deserializeCombat(SerialPacket* packet, char* buffer) { DESERIALIZE(buffer, &packet->combatInfo.terrainType, sizeof(CombatData::Terrain)); //arrays - DESERIALIZE(buffer, &packet->combatInfo.characterArray, COMBAT_MAX_CHARACTER_COUNT); - DESERIALIZE(buffer, &packet->combatInfo.enemyArray, COMBAT_MAX_ENEMY_COUNT); + DESERIALIZE(buffer, &packet->combatInfo.characterArray, COMBAT_MAX_CHARACTERS); + DESERIALIZE(buffer, &packet->combatInfo.enemyArray, COMBAT_MAX_ENEMIES); //position DESERIALIZE(buffer, &packet->combatInfo.mapIndex, sizeof(int)); diff --git a/common/network/serial_packet.hpp b/common/network/serial_packet.hpp deleted file mode 100644 index d378fde..0000000 --- a/common/network/serial_packet.hpp +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright: (c) Kayne Ruse 2013, 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 SERIALPACKET_HPP_ -#define SERIALPACKET_HPP_ - -#include "vector2.hpp" -#include "region.hpp" -#include "statistics.hpp" -#include "combat_data.hpp" - -#include "SDL/SDL_net.h" - -#define NETWORK_VERSION 20140601 -#define PACKET_STRING_SIZE 100 - -//TODO: would it be possible to serialize structures directly? -union SerialPacket { - //types of packets - enum class Type { - //default: there is something wrong - NONE = 0, - - //keep alive - PING, - PONG, - - //searching for a server to join - BROADCAST_REQUEST, - BROADCAST_RESPONSE, - BROADCAST_REJECTION, - - //try to join the server - JOIN_REQUEST, - JOIN_RESPONSE, - JOIN_REJECTION, - - //mass update - SYNCHRONIZE, - - //disconnect from the server - DISCONNECT, - - //shut down the server - SHUTDOWN, - - //map data - REGION_REQUEST, - REGION_CONTENT, - REGION_REJECTION, - - //combat data - COMBAT_NEW, - COMBAT_DELETE, - COMBAT_UPDATE, - - COMBAT_ENTER_REQUEST, - COMBAT_ENTER_RESPONSE, - - COMBAT_EXIT_REQUEST, - COMBAT_EXIT_RESPONSE, - - //TODO: COMBAT info - - COMBAT_REJECTION, - - //character data - CHARACTER_NEW, - CHARACTER_DELETE, - CHARACTER_UPDATE, - - CHARACTER_STATS_REQUEST, - CHARACTER_STATS_RESPONSE, - - CHARACTER_REJECTION, - - //enemy data - ENEMY_NEW, - ENEMY_DELETE, - ENEMY_UPDATE, - - ENEMY_STATS_REQUEST, - ENEMY_STATS_RESPONSE, - - ENEMY_REJECTION, - - //more packet types go here - - //not used - LAST, - }; - - //metadata on the packet itself - struct Metadata { - Type type; - IPaddress srcAddress; - }meta; - - //info about the server - struct ServerInformation { - Metadata meta; - int networkVersion; - char name[PACKET_STRING_SIZE]; - int playerCount; - }serverInfo; - - //info about the client - struct ClientInformation { - Metadata meta; - int clientIndex; - int accountIndex; - int characterIndex; - char username[PACKET_STRING_SIZE]; - //TODO: password - char handle[PACKET_STRING_SIZE]; - char avatar[PACKET_STRING_SIZE]; - }clientInfo; - - //info about a region - struct RegionInformation { - Metadata meta; - int mapIndex; - int x, y; - Region* region; - }regionInfo; - - //info about a combat scenario - struct CombatInformation { - Metadata meta; - int combatIndex; - int difficulty; - CombatData::Terrain terrainType; - int characterArray[COMBAT_MAX_CHARACTER_COUNT]; - int enemyArray[COMBAT_MAX_ENEMY_COUNT]; - int mapIndex; - Vector2 origin; - //TODO: rewards - }combatInfo; - - //info about a character - struct CharacterInformation { - Metadata meta; - int clientIndex; - int accountIndex; - int characterIndex; - char handle[PACKET_STRING_SIZE]; - char avatar[PACKET_STRING_SIZE]; - int mapIndex; - Vector2 origin; - Vector2 motion; - Statistics stats; - }characterInfo; - - //info about an enemy - struct EnemyInformation { - Metadata meta; - char handle[PACKET_STRING_SIZE]; - char avatar[PACKET_STRING_SIZE]; - Statistics stats; - //TODO: rewards - }enemyInfo; - - //defaults - SerialPacket() { - meta.type = Type::NONE; - meta.srcAddress = {0,0}; - } -}; - -#endif diff --git a/todo.txt b/todo.txt index f03386a..fa7d60d 100644 --- a/todo.txt +++ b/todo.txt @@ -1,3 +1,6 @@ +TODO: Modulate this god class +TODO: Segment SerialPacket? +TODO: Not all structures in common/gameplay are needed by the client TODO: I need to keep the documentation up to date. Namely, the GDD is getting out of date. TODO: I completely forgot about status ailments TODO: Time delay for requesting region packets