Removed the statistics structure from common/* and server/*

This commit is contained in:
Kayne Ruse
2014-11-16 22:34:12 +11:00
parent 97b7945191
commit cacd3dcd6d
10 changed files with 1 additions and 167 deletions
-42
View File
@@ -1,42 +0,0 @@
/* Copyright: (c) Kayne Ruse 2014
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*/
#ifndef 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
@@ -23,8 +23,6 @@
#include "serial_utility.hpp"
#include "serial_statistics.hpp"
void serializeCharacter(void* buffer, CharacterPacket* packet) {
serialCopy(&buffer, &packet->type, sizeof(SerialPacketType));
@@ -43,9 +41,6 @@ void serializeCharacter(void* buffer, CharacterPacket* packet) {
serialCopy(&buffer, &packet->motion.x, sizeof(double));
serialCopy(&buffer, &packet->motion.y, sizeof(double));
//stats structure
serializeStatistics(&buffer, &packet->stats);
//gameplay components: equipment, items, buffs, debuffs...
}
@@ -67,8 +62,5 @@ void deserializeCharacter(void* buffer, CharacterPacket* packet) {
deserialCopy(&buffer, &packet->motion.x, sizeof(double));
deserialCopy(&buffer, &packet->motion.y, sizeof(double));
//stats structure
deserializeStatistics(&buffer, &packet->stats);
//gameplay components: equipment, items, buffs, debuffs...
}
@@ -25,7 +25,6 @@
#include "serial_packet_base.hpp"
#include "vector2.hpp"
#include "statistics.hpp"
struct CharacterPacket : SerialPacketBase {
//identify the character
@@ -42,9 +41,6 @@ struct CharacterPacket : SerialPacketBase {
Vector2 origin;
Vector2 motion;
//gameplay
Statistics stats;
//gameplay components: equipment, items, buffs, debuffs...
};
@@ -1,64 +0,0 @@
/* Copyright: (c) Kayne Ruse 2014
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*/
#include "serial_statistics.hpp"
#include "serial_utility.hpp"
void serializeStatistics(void** buffer, Statistics* stats) {
//integers
serialCopy(buffer, &stats->level, sizeof(int));
serialCopy(buffer, &stats->exp, sizeof(int));
serialCopy(buffer, &stats->maxHP, sizeof(int));
serialCopy(buffer, &stats->health, sizeof(int));
serialCopy(buffer, &stats->maxMP, sizeof(int));
serialCopy(buffer, &stats->mana, sizeof(int));
serialCopy(buffer, &stats->attack, sizeof(int));
serialCopy(buffer, &stats->defence, sizeof(int));
serialCopy(buffer, &stats->intelligence, sizeof(int));
serialCopy(buffer, &stats->resistance, sizeof(int));
serialCopy(buffer, &stats->speed, sizeof(int));
//floats
serialCopy(buffer, &stats->accuracy, sizeof(float));
serialCopy(buffer, &stats->evasion, sizeof(float));
serialCopy(buffer, &stats->luck, sizeof(float));
}
void deserializeStatistics(void** buffer, Statistics* stats) {
//integers
deserialCopy(buffer, &stats->level, sizeof(int));
deserialCopy(buffer, &stats->exp, sizeof(int));
deserialCopy(buffer, &stats->maxHP, sizeof(int));
deserialCopy(buffer, &stats->health, sizeof(int));
deserialCopy(buffer, &stats->maxMP, sizeof(int));
deserialCopy(buffer, &stats->mana, sizeof(int));
deserialCopy(buffer, &stats->attack, sizeof(int));
deserialCopy(buffer, &stats->defence, sizeof(int));
deserialCopy(buffer, &stats->intelligence, sizeof(int));
deserialCopy(buffer, &stats->resistance, sizeof(int));
deserialCopy(buffer, &stats->speed, sizeof(int));
//floats
deserialCopy(buffer, &stats->accuracy, sizeof(float));
deserialCopy(buffer, &stats->evasion, sizeof(float));
deserialCopy(buffer, &stats->luck, sizeof(float));
}
@@ -1,30 +0,0 @@
/* Copyright: (c) Kayne Ruse 2014
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
*/
#ifndef SERIALSTATISTICS_HPP_
#define SERIALSTATISTICS_HPP_
#include "statistics.hpp"
void serializeStatistics(void** buffer, Statistics* stats);
void deserializeStatistics(void** buffer, Statistics* stats);
#endif
-4
View File
@@ -21,10 +21,6 @@
*/
#include "character_data.hpp"
Statistics* CharacterData::GetBaseStats() {
return &baseStats;
}
int CharacterData::GetOwner() {
return owner;
}
+1 -4
View File
@@ -25,7 +25,6 @@
//components
#include "character_defines.hpp"
#include "entity.hpp"
#include "statistics.hpp"
//std namespace
#include <string>
@@ -37,7 +36,7 @@ public:
~CharacterData() = default;
//accessors and mutators
Statistics* GetBaseStats();
//...
//database stuff
int GetOwner();
@@ -47,8 +46,6 @@ public:
private:
friend class CharacterManager;
Statistics baseStats;
int owner;
std::string handle;
std::string avatar;
-4
View File
@@ -21,10 +21,6 @@
*/
#include "monster_data.hpp"
Statistics* MonsterData::GetBaseStats() {
return &baseStats;
}
std::string MonsterData::SetAvatar(std::string s) {
return avatar = s;
}
-4
View File
@@ -23,7 +23,6 @@
#define MONSTERDATA_HPP_
#include "entity.hpp"
#include "statistics.hpp"
#include <string>
@@ -32,8 +31,6 @@ public:
MonsterData() = default;
~MonsterData() = default;
Statistics* GetBaseStats();
std::string SetAvatar(std::string);
int SetScriptReference(int);
@@ -43,7 +40,6 @@ public:
private:
friend class MonsterManager;
Statistics baseStats;
std::string avatar;
int scriptRef;
};
-3
View File
@@ -240,8 +240,6 @@ void ServerApplication::HandleCharacterUpdate(CharacterPacket* const argPacket)
character->SetOrigin(argPacket->origin);
character->SetMotion(argPacket->motion);
*character->GetBaseStats() = argPacket->stats;
//TODO: gameplay components: equipment, items, buffs, debuffs
PumpPacket(argPacket);
@@ -353,5 +351,4 @@ void ServerApplication::CopyCharacterToPacket(CharacterPacket* const packet, int
packet->roomIndex = character->GetRoomIndex();
packet->origin = character->GetOrigin();
packet->motion = character->GetMotion();
packet->stats = *character->GetBaseStats();
}