Added some structures to SerialPacket, and serial.cpp
I've also created the Statistics structure for simplicity.
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#include "serial.hpp"
|
#include "serial.hpp"
|
||||||
|
|
||||||
#include "map_allocator.hpp"
|
#include "map_allocator.hpp"
|
||||||
|
#include "statistics.hpp"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
@@ -59,6 +60,7 @@ void serializeClient(SerialPacket* packet, char* buffer) {
|
|||||||
|
|
||||||
//texts
|
//texts
|
||||||
SERIALIZE(buffer, packet->clientInfo.username, PACKET_STRING_SIZE);
|
SERIALIZE(buffer, packet->clientInfo.username, PACKET_STRING_SIZE);
|
||||||
|
//TODO: password
|
||||||
SERIALIZE(buffer, packet->clientInfo.handle, PACKET_STRING_SIZE);
|
SERIALIZE(buffer, packet->clientInfo.handle, PACKET_STRING_SIZE);
|
||||||
SERIALIZE(buffer, packet->clientInfo.avatar, PACKET_STRING_SIZE);
|
SERIALIZE(buffer, packet->clientInfo.avatar, PACKET_STRING_SIZE);
|
||||||
}
|
}
|
||||||
@@ -91,6 +93,35 @@ void serializeRegionContent(SerialPacket* packet, char* buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void serializeCombat(SerialPacket* packet, char* buffer) {
|
||||||
|
SERIALIZE(buffer, &packet->meta.type, sizeof(SerialPacket::Type));
|
||||||
|
|
||||||
|
//integers
|
||||||
|
SERIALIZE(buffer, &packet->combatInfo.combatIndex, sizeof(int));
|
||||||
|
SERIALIZE(buffer, &packet->combatInfo.difficulty, sizeof(int));
|
||||||
|
//TODO: more comabat info
|
||||||
|
}
|
||||||
|
|
||||||
|
void serializeStatistics(Statistics* stats, char* buffer) {
|
||||||
|
//integers
|
||||||
|
SERIALIZE(buffer, &stats->level, sizeof(int));
|
||||||
|
SERIALIZE(buffer, &stats->exp, sizeof(int));
|
||||||
|
SERIALIZE(buffer, &stats->maxHP, sizeof(int));
|
||||||
|
SERIALIZE(buffer, &stats->health, sizeof(int));
|
||||||
|
SERIALIZE(buffer, &stats->maxMP, sizeof(int));
|
||||||
|
SERIALIZE(buffer, &stats->mana, sizeof(int));
|
||||||
|
SERIALIZE(buffer, &stats->attack, sizeof(int));
|
||||||
|
SERIALIZE(buffer, &stats->defence, sizeof(int));
|
||||||
|
SERIALIZE(buffer, &stats->intelligence, sizeof(int));
|
||||||
|
SERIALIZE(buffer, &stats->resistance, sizeof(int));
|
||||||
|
SERIALIZE(buffer, &stats->speed, sizeof(int));
|
||||||
|
|
||||||
|
//floats
|
||||||
|
SERIALIZE(buffer, &stats->accuracy, sizeof(float));
|
||||||
|
SERIALIZE(buffer, &stats->evasion, sizeof(float));
|
||||||
|
SERIALIZE(buffer, &stats->luck, sizeof(float));
|
||||||
|
}
|
||||||
|
|
||||||
void serializeCharacter(SerialPacket* packet, char* buffer) {
|
void serializeCharacter(SerialPacket* packet, char* buffer) {
|
||||||
SERIALIZE(buffer, &packet->meta.type, sizeof(SerialPacket::Type));
|
SERIALIZE(buffer, &packet->meta.type, sizeof(SerialPacket::Type));
|
||||||
|
|
||||||
@@ -108,6 +139,22 @@ void serializeCharacter(SerialPacket* packet, char* buffer) {
|
|||||||
SERIALIZE(buffer, &packet->characterInfo.position.y, sizeof(double));
|
SERIALIZE(buffer, &packet->characterInfo.position.y, sizeof(double));
|
||||||
SERIALIZE(buffer, &packet->characterInfo.motion.x, sizeof(double));
|
SERIALIZE(buffer, &packet->characterInfo.motion.x, sizeof(double));
|
||||||
SERIALIZE(buffer, &packet->characterInfo.motion.y, sizeof(double));
|
SERIALIZE(buffer, &packet->characterInfo.motion.y, sizeof(double));
|
||||||
|
|
||||||
|
//stats structure
|
||||||
|
serializeStatistics(&packet->characterInfo.stats, buffer);
|
||||||
|
buffer += sizeof(Statistics);
|
||||||
|
}
|
||||||
|
|
||||||
|
void serializeEnemy(SerialPacket* packet, char* buffer) {
|
||||||
|
SERIALIZE(buffer, &packet->meta.type, sizeof(SerialPacket::Type));
|
||||||
|
|
||||||
|
//texts
|
||||||
|
SERIALIZE(buffer, packet->clientInfo.handle, PACKET_STRING_SIZE);
|
||||||
|
SERIALIZE(buffer, packet->clientInfo.avatar, PACKET_STRING_SIZE);
|
||||||
|
|
||||||
|
//stats structure
|
||||||
|
serializeStatistics(&packet->characterInfo.stats, buffer);
|
||||||
|
buffer += sizeof(Statistics);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
@@ -137,6 +184,7 @@ void deserializeClient(SerialPacket* packet, char* buffer) {
|
|||||||
|
|
||||||
//texts
|
//texts
|
||||||
DESERIALIZE(buffer, packet->clientInfo.username, PACKET_STRING_SIZE);
|
DESERIALIZE(buffer, packet->clientInfo.username, PACKET_STRING_SIZE);
|
||||||
|
//TODO: password
|
||||||
DESERIALIZE(buffer, packet->clientInfo.handle, PACKET_STRING_SIZE);
|
DESERIALIZE(buffer, packet->clientInfo.handle, PACKET_STRING_SIZE);
|
||||||
DESERIALIZE(buffer, packet->clientInfo.avatar, PACKET_STRING_SIZE);
|
DESERIALIZE(buffer, packet->clientInfo.avatar, PACKET_STRING_SIZE);
|
||||||
}
|
}
|
||||||
@@ -176,6 +224,37 @@ void deserializeRegionContent(SerialPacket* packet, char* buffer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void deserializeCombat(SerialPacket* packet, char* buffer) {
|
||||||
|
DESERIALIZE(buffer, &packet->meta.type, sizeof(SerialPacket::Type));
|
||||||
|
|
||||||
|
//integers
|
||||||
|
DESERIALIZE(buffer, &packet->combatInfo.combatIndex, sizeof(int));
|
||||||
|
DESERIALIZE(buffer, &packet->combatInfo.difficulty, sizeof(int));
|
||||||
|
//TODO: more comabat info
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void deserializeStatistics(Statistics* stats, char* buffer) {
|
||||||
|
//integers
|
||||||
|
DESERIALIZE(buffer, &stats->level, sizeof(int));
|
||||||
|
DESERIALIZE(buffer, &stats->exp, sizeof(int));
|
||||||
|
DESERIALIZE(buffer, &stats->maxHP, sizeof(int));
|
||||||
|
DESERIALIZE(buffer, &stats->health, sizeof(int));
|
||||||
|
DESERIALIZE(buffer, &stats->maxMP, sizeof(int));
|
||||||
|
DESERIALIZE(buffer, &stats->mana, sizeof(int));
|
||||||
|
DESERIALIZE(buffer, &stats->attack, sizeof(int));
|
||||||
|
DESERIALIZE(buffer, &stats->defence, sizeof(int));
|
||||||
|
DESERIALIZE(buffer, &stats->intelligence, sizeof(int));
|
||||||
|
DESERIALIZE(buffer, &stats->resistance, sizeof(int));
|
||||||
|
DESERIALIZE(buffer, &stats->speed, sizeof(int));
|
||||||
|
|
||||||
|
//floats
|
||||||
|
DESERIALIZE(buffer, &stats->accuracy, sizeof(float));
|
||||||
|
DESERIALIZE(buffer, &stats->evasion, sizeof(float));
|
||||||
|
DESERIALIZE(buffer, &stats->luck, sizeof(float));
|
||||||
|
}
|
||||||
|
|
||||||
void deserializeCharacter(SerialPacket* packet, char* buffer) {
|
void deserializeCharacter(SerialPacket* packet, char* buffer) {
|
||||||
DESERIALIZE(buffer, &packet->meta.type, sizeof(SerialPacket::Type));
|
DESERIALIZE(buffer, &packet->meta.type, sizeof(SerialPacket::Type));
|
||||||
|
|
||||||
@@ -193,6 +272,22 @@ void deserializeCharacter(SerialPacket* packet, char* buffer) {
|
|||||||
DESERIALIZE(buffer, &packet->characterInfo.position.y, sizeof(double));
|
DESERIALIZE(buffer, &packet->characterInfo.position.y, sizeof(double));
|
||||||
DESERIALIZE(buffer, &packet->characterInfo.motion.x, sizeof(double));
|
DESERIALIZE(buffer, &packet->characterInfo.motion.x, sizeof(double));
|
||||||
DESERIALIZE(buffer, &packet->characterInfo.motion.y, sizeof(double));
|
DESERIALIZE(buffer, &packet->characterInfo.motion.y, sizeof(double));
|
||||||
|
|
||||||
|
//stats structure
|
||||||
|
deserializeStatistics(&packet->characterInfo.stats, buffer);
|
||||||
|
buffer += sizeof(Statistics);
|
||||||
|
}
|
||||||
|
|
||||||
|
void deserializeEnemy(SerialPacket* packet, char* buffer) {
|
||||||
|
DESERIALIZE(buffer, &packet->meta.type, sizeof(SerialPacket::Type));
|
||||||
|
|
||||||
|
//texts
|
||||||
|
DESERIALIZE(buffer, packet->clientInfo.handle, PACKET_STRING_SIZE);
|
||||||
|
DESERIALIZE(buffer, packet->clientInfo.avatar, PACKET_STRING_SIZE);
|
||||||
|
|
||||||
|
//stats structure
|
||||||
|
deserializeStatistics(&packet->characterInfo.stats, buffer);
|
||||||
|
buffer += sizeof(Statistics);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|||||||
@@ -28,11 +28,11 @@
|
|||||||
* NOTE: REGION_CONTENT is currently the largest type of packet
|
* NOTE: REGION_CONTENT is currently the largest type of packet
|
||||||
* map content: REGION_WIDTH * REGION_HEIGHT * REGION_DEPTH * sizoeof(region::type_t)
|
* map content: REGION_WIDTH * REGION_HEIGHT * REGION_DEPTH * sizoeof(region::type_t)
|
||||||
* map format: sizeof(int) * 3
|
* map format: sizeof(int) * 3
|
||||||
* metadata: sizeof(metadata)
|
* metadata: sizeof(SerialPacket::Type)
|
||||||
*/
|
*/
|
||||||
#define PACKET_BUFFER_SIZE REGION_WIDTH * REGION_HEIGHT * REGION_DEPTH * sizeof(Region::type_t) + sizeof(int) * 3 + sizeof(SerialPacket::Metadata)
|
#define PACKET_BUFFER_SIZE REGION_WIDTH * REGION_HEIGHT * REGION_DEPTH * sizeof(Region::type_t) + sizeof(int) * 3 + sizeof(SerialPacket::Type)
|
||||||
|
|
||||||
void serialize(SerialPacket* const, void*);
|
void serialize(SerialPacket* const, void* dest);
|
||||||
void deserialize(SerialPacket* const, void*);
|
void deserialize(SerialPacket* const, void* src);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,53 +24,80 @@
|
|||||||
|
|
||||||
#include "vector2.hpp"
|
#include "vector2.hpp"
|
||||||
#include "region.hpp"
|
#include "region.hpp"
|
||||||
|
#include "statistics.hpp"
|
||||||
|
|
||||||
#include "SDL/SDL_net.h"
|
#include "SDL/SDL_net.h"
|
||||||
|
|
||||||
#define NETWORK_VERSION 20140512
|
#define NETWORK_VERSION 20140526
|
||||||
#define PACKET_STRING_SIZE 100
|
|
||||||
|
|
||||||
#pragma pack(push, 0)
|
//maximum string size; don't use std::string
|
||||||
|
#define PACKET_STRING_SIZE 100
|
||||||
|
|
||||||
union SerialPacket {
|
union SerialPacket {
|
||||||
//types of packets
|
//types of packets
|
||||||
|
//TODO: readd the value definitions
|
||||||
enum class Type {
|
enum class Type {
|
||||||
//default: there is something wrong
|
//default: there is something wrong
|
||||||
NONE = 0,
|
NONE = 0,
|
||||||
|
|
||||||
//not used
|
//keep alive
|
||||||
PING = 1,
|
PING,
|
||||||
PONG = 2,
|
PONG,
|
||||||
|
|
||||||
//TODO: rejection message
|
//searching for a server to join
|
||||||
|
BROADCAST_REQUEST,
|
||||||
//Searching for a server to join
|
BROADCAST_RESPONSE,
|
||||||
BROADCAST_REQUEST = 3,
|
BROADCAST_REJECTION,
|
||||||
BROADCAST_RESPONSE = 4,
|
|
||||||
|
|
||||||
//try to join the server
|
//try to join the server
|
||||||
JOIN_REQUEST = 5,
|
JOIN_REQUEST,
|
||||||
JOIN_RESPONSE = 6,
|
JOIN_RESPONSE,
|
||||||
|
JOIN_REJECTION,
|
||||||
|
|
||||||
//mass update
|
//mass update
|
||||||
SYNCHRONIZE = 7,
|
SYNCHRONIZE,
|
||||||
|
|
||||||
//disconnect from the server
|
//disconnect from the server
|
||||||
DISCONNECT = 8,
|
DISCONNECT,
|
||||||
|
|
||||||
//shut down the server
|
//shut down the server
|
||||||
SHUTDOWN = 9,
|
SHUTDOWN,
|
||||||
|
|
||||||
//map data
|
//map data
|
||||||
REGION_REQUEST = 10,
|
REGION_REQUEST,
|
||||||
REGION_CONTENT = 11,
|
REGION_CONTENT,
|
||||||
|
REGION_REJECTION,
|
||||||
|
|
||||||
//Character movement, etc.
|
//character data
|
||||||
CHARACTER_NEW = 12,
|
CHARACTER_NEW,
|
||||||
CHARACTER_DELETE = 13,
|
CHARACTER_DELETE,
|
||||||
CHARACTER_UPDATE = 14,
|
CHARACTER_UPDATE,
|
||||||
|
|
||||||
//TODO: combat packets
|
CHARACTER_STATS_REQUEST,
|
||||||
|
CHARACTER_STATS_RESPONSE,
|
||||||
|
|
||||||
|
CHARACTER_REJECTION,
|
||||||
|
|
||||||
|
//enemy data
|
||||||
|
ENEMY_NEW,
|
||||||
|
ENEMY_DELETE,
|
||||||
|
ENEMY_UPDATE,
|
||||||
|
|
||||||
|
ENEMY_STATS_REQUEST,
|
||||||
|
ENEMY_STATS_RESPONSE,
|
||||||
|
|
||||||
|
ENEMY_REJECTION,
|
||||||
|
|
||||||
|
//combat data
|
||||||
|
COMBAT_ENTER,
|
||||||
|
COMBAT_EXIT,
|
||||||
|
|
||||||
|
COMBAT_REJECTION,
|
||||||
|
|
||||||
|
//more packet types go here
|
||||||
|
|
||||||
|
//not used
|
||||||
|
LAST,
|
||||||
};
|
};
|
||||||
|
|
||||||
//metadata on the packet itself
|
//metadata on the packet itself
|
||||||
@@ -79,7 +106,7 @@ union SerialPacket {
|
|||||||
IPaddress srcAddress;
|
IPaddress srcAddress;
|
||||||
}meta;
|
}meta;
|
||||||
|
|
||||||
//information about the server
|
//info about the server
|
||||||
struct ServerInformation {
|
struct ServerInformation {
|
||||||
Metadata meta;
|
Metadata meta;
|
||||||
int networkVersion;
|
int networkVersion;
|
||||||
@@ -87,18 +114,19 @@ union SerialPacket {
|
|||||||
int playerCount;
|
int playerCount;
|
||||||
}serverInfo;
|
}serverInfo;
|
||||||
|
|
||||||
//information about the client
|
//info about the client
|
||||||
struct ClientInformation {
|
struct ClientInformation {
|
||||||
Metadata meta;
|
Metadata meta;
|
||||||
int clientIndex;
|
int clientIndex;
|
||||||
int accountIndex;
|
int accountIndex;
|
||||||
int characterIndex;
|
int characterIndex;
|
||||||
char username[PACKET_STRING_SIZE];
|
char username[PACKET_STRING_SIZE];
|
||||||
|
//TODO: password
|
||||||
char handle[PACKET_STRING_SIZE];
|
char handle[PACKET_STRING_SIZE];
|
||||||
char avatar[PACKET_STRING_SIZE];
|
char avatar[PACKET_STRING_SIZE];
|
||||||
}clientInfo;
|
}clientInfo;
|
||||||
|
|
||||||
//map data
|
//info about a region
|
||||||
struct RegionInformation {
|
struct RegionInformation {
|
||||||
Metadata meta;
|
Metadata meta;
|
||||||
int mapIndex;
|
int mapIndex;
|
||||||
@@ -106,7 +134,16 @@ union SerialPacket {
|
|||||||
Region* region;
|
Region* region;
|
||||||
}regionInfo;
|
}regionInfo;
|
||||||
|
|
||||||
//information about a character
|
//info about a combat scenario
|
||||||
|
struct CombatInformation {
|
||||||
|
Metadata meta;
|
||||||
|
int combatIndex;
|
||||||
|
int difficulty;
|
||||||
|
//TODO: background image, based on terrain type
|
||||||
|
//TODO: array of combatants
|
||||||
|
}combatInfo;
|
||||||
|
|
||||||
|
//info about a character
|
||||||
struct CharacterInformation {
|
struct CharacterInformation {
|
||||||
Metadata meta;
|
Metadata meta;
|
||||||
int clientIndex;
|
int clientIndex;
|
||||||
@@ -117,8 +154,17 @@ union SerialPacket {
|
|||||||
int mapIndex;
|
int mapIndex;
|
||||||
Vector2 position;
|
Vector2 position;
|
||||||
Vector2 motion;
|
Vector2 motion;
|
||||||
|
Statistics stats;
|
||||||
}characterInfo;
|
}characterInfo;
|
||||||
|
|
||||||
|
//info about an enemy
|
||||||
|
struct EnemyInformation {
|
||||||
|
Metadata meta;
|
||||||
|
char handle[PACKET_STRING_SIZE];
|
||||||
|
char avatar[PACKET_STRING_SIZE];
|
||||||
|
Statistics stats;
|
||||||
|
}enemyInfo;
|
||||||
|
|
||||||
//defaults
|
//defaults
|
||||||
SerialPacket() {
|
SerialPacket() {
|
||||||
meta.type = Type::NONE;
|
meta.type = Type::NONE;
|
||||||
@@ -126,6 +172,4 @@ union SerialPacket {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(pop)
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/* Copyright: (c) Kayne Ruse 2014
|
||||||
|
*
|
||||||
|
* This software is provided 'as-is', without any express or implied
|
||||||
|
* warranty. In no event will the authors be held liable for any damages
|
||||||
|
* arising from the use of this software.
|
||||||
|
*
|
||||||
|
* Permission is granted to anyone to use this software for any purpose,
|
||||||
|
* including commercial applications, and to alter it and redistribute it
|
||||||
|
* freely, subject to the following restrictions:
|
||||||
|
*
|
||||||
|
* 1. The origin of this software must not be misrepresented; you must not
|
||||||
|
* claim that you wrote the original software. If you use this software
|
||||||
|
* in a product, an acknowledgment in the product documentation would be
|
||||||
|
* appreciated but is not required.
|
||||||
|
*
|
||||||
|
* 2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
* misrepresented as being the original software.
|
||||||
|
*
|
||||||
|
* 3. This notice may not be removed or altered from any source
|
||||||
|
* distribution.
|
||||||
|
*/
|
||||||
|
#ifndef STATISTICS_HPP_
|
||||||
|
#define STATISTICS_HPP_
|
||||||
|
|
||||||
|
struct Statistics {
|
||||||
|
int level = 0;
|
||||||
|
int exp = 0;
|
||||||
|
int maxHP = 0;
|
||||||
|
int health = 0;
|
||||||
|
int maxMP = 0;
|
||||||
|
int mana = 0;
|
||||||
|
int attack = 0;
|
||||||
|
int defence = 0;
|
||||||
|
int intelligence = 0;
|
||||||
|
int resistance = 0;
|
||||||
|
int speed = 0;
|
||||||
|
float accuracy = 0.0;
|
||||||
|
float evasion = 0.0;
|
||||||
|
float luck = 0.0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
//POD members
|
//POD members
|
||||||
#include "bbox.hpp"
|
#include "bbox.hpp"
|
||||||
#include "vector2.hpp"
|
#include "vector2.hpp"
|
||||||
|
#include "statistics.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -40,20 +41,7 @@ struct CharacterData {
|
|||||||
Vector2 motion = {0.0,0.0};
|
Vector2 motion = {0.0,0.0};
|
||||||
|
|
||||||
//base statistics
|
//base statistics
|
||||||
int level = 0;
|
Statistics stats;
|
||||||
int exp = 0;
|
|
||||||
int maxHP = 0;
|
|
||||||
int health = 0;
|
|
||||||
int maxMP = 0;
|
|
||||||
int mana = 0;
|
|
||||||
int attack = 0;
|
|
||||||
int defence = 0;
|
|
||||||
int intelligence = 0;
|
|
||||||
int resistance = 0;
|
|
||||||
int speed = 0;
|
|
||||||
float accuracy = 0.0;
|
|
||||||
float evasion = 0.0;
|
|
||||||
float luck = 0.0;
|
|
||||||
|
|
||||||
//TODO: equipment
|
//TODO: equipment
|
||||||
//TODO: items
|
//TODO: items
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
//Define the queries
|
//Define the queries
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
|
//TODO: save and load the statistics
|
||||||
static const char* CREATE_CHARACTER = "INSERT INTO PlayerCharacters (owner, handle, avatar) VALUES (?, ?, ?);";
|
static const char* CREATE_CHARACTER = "INSERT INTO PlayerCharacters (owner, handle, avatar) VALUES (?, ?, ?);";
|
||||||
static const char* LOAD_CHARACTER = "SELECT * FROM PlayerCharacters WHERE handle = ?;";
|
static const char* LOAD_CHARACTER = "SELECT * FROM PlayerCharacters WHERE handle = ?;";
|
||||||
static const char* SAVE_CHARACTER = "UPDATE OR FAIL PlayerCharacters SET mapIndex = ?2, positionX = ?3, positionY = ?4 WHERE uid = ?1;";
|
static const char* SAVE_CHARACTER = "UPDATE OR FAIL PlayerCharacters SET mapIndex = ?2, positionX = ?3, positionY = ?4 WHERE uid = ?1;";
|
||||||
@@ -38,6 +39,7 @@ static const char* DELETE_CHARACTER = "DELETE FROM PlayerCharacters WHERE uid =
|
|||||||
//Define the methods
|
//Define the methods
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|
||||||
|
//TODO: default stats as a parameter
|
||||||
int ServerApplication::CreateCharacter(int owner, std::string handle, std::string avatar) {
|
int ServerApplication::CreateCharacter(int owner, std::string handle, std::string avatar) {
|
||||||
//Create the character, failing if it exists
|
//Create the character, failing if it exists
|
||||||
sqlite3_stmt* statement = nullptr;
|
sqlite3_stmt* statement = nullptr;
|
||||||
@@ -121,20 +123,20 @@ int ServerApplication::LoadCharacter(int owner, std::string handle, std::string
|
|||||||
newChar.position.y = (double)sqlite3_column_int(statement, 7);
|
newChar.position.y = (double)sqlite3_column_int(statement, 7);
|
||||||
|
|
||||||
//statistics
|
//statistics
|
||||||
newChar.level = sqlite3_column_int(statement, 8);
|
newChar.stats.level = sqlite3_column_int(statement, 8);
|
||||||
newChar.exp = sqlite3_column_int(statement, 9);
|
newChar.stats.exp = sqlite3_column_int(statement, 9);
|
||||||
newChar.maxHP = sqlite3_column_int(statement, 10);
|
newChar.stats.maxHP = sqlite3_column_int(statement, 10);
|
||||||
newChar.health = sqlite3_column_int(statement, 11);
|
newChar.stats.health = sqlite3_column_int(statement, 11);
|
||||||
newChar.maxMP = sqlite3_column_int(statement, 12);
|
newChar.stats.maxMP = sqlite3_column_int(statement, 12);
|
||||||
newChar.mana = sqlite3_column_int(statement, 13);
|
newChar.stats.mana = sqlite3_column_int(statement, 13);
|
||||||
newChar.attack = sqlite3_column_int(statement, 14);
|
newChar.stats.attack = sqlite3_column_int(statement, 14);
|
||||||
newChar.defence = sqlite3_column_int(statement, 15);
|
newChar.stats.defence = sqlite3_column_int(statement, 15);
|
||||||
newChar.intelligence = sqlite3_column_int(statement, 16);
|
newChar.stats.intelligence = sqlite3_column_int(statement, 16);
|
||||||
newChar.resistance = sqlite3_column_int(statement, 17);
|
newChar.stats.resistance = sqlite3_column_int(statement, 17);
|
||||||
newChar.speed = sqlite3_column_int(statement, 18);
|
newChar.stats.speed = sqlite3_column_int(statement, 18);
|
||||||
newChar.accuracy = sqlite3_column_double(statement, 19);
|
newChar.stats.accuracy = sqlite3_column_double(statement, 19);
|
||||||
newChar.evasion = sqlite3_column_double(statement, 20);
|
newChar.stats.evasion = sqlite3_column_double(statement, 20);
|
||||||
newChar.luck = sqlite3_column_double(statement, 21);
|
newChar.stats.luck = sqlite3_column_double(statement, 21);
|
||||||
|
|
||||||
//TODO: equipment
|
//TODO: equipment
|
||||||
|
|
||||||
|
|||||||
+4
-15
@@ -22,6 +22,8 @@
|
|||||||
#ifndef ENEMYDATA_HPP_
|
#ifndef ENEMYDATA_HPP_
|
||||||
#define ENEMYDATA_HPP_
|
#define ENEMYDATA_HPP_
|
||||||
|
|
||||||
|
#include "statistics.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct EnemyData {
|
struct EnemyData {
|
||||||
@@ -29,21 +31,8 @@ struct EnemyData {
|
|||||||
std::string handle;
|
std::string handle;
|
||||||
std::string avatar;
|
std::string avatar;
|
||||||
|
|
||||||
//statistics
|
//gameplay
|
||||||
int level = 0;
|
Statistics stats;
|
||||||
int exp = 0;
|
|
||||||
int maxHP = 0;
|
|
||||||
int health = 0;
|
|
||||||
int maxMP = 0;
|
|
||||||
int mana = 0;
|
|
||||||
int attack = 0;
|
|
||||||
int defence = 0;
|
|
||||||
int intelligence = 0;
|
|
||||||
int resistance = 0;
|
|
||||||
int speed = 0;
|
|
||||||
float accuracy = 0.0;
|
|
||||||
float evasion = 0.0;
|
|
||||||
float luck = 0.0;
|
|
||||||
|
|
||||||
//TODO: equipment
|
//TODO: equipment
|
||||||
//TODO: items
|
//TODO: items
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
* I need to keep the documentation up to date. Namely, the GDD is getting out of date.
|
TODO: I need to keep the documentation up to date. Namely, the GDD is getting out of date.
|
||||||
* How many lookups is the map system using?
|
TODO: How many lookups is the map system using?
|
||||||
* Hook the serial packet to the network utility
|
TODO: Hook the serial packet to the network utility
|
||||||
* I completely forgot about status ailments
|
TODO: I completely forgot about status ailments
|
||||||
|
TODO: Time delay for requesting region packets
|
||||||
|
TODO: command line parameters overriding config.cfg settings
|
||||||
|
TODO: inplementing SerialPacket in NetworkUtility
|
||||||
|
|
||||||
--Battle System--
|
--Battle System--
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user