SEGS  0.4.2
Super Entity Game Server
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Character.h
Go to the documentation of this file.
1 /*
2  * SEGS - Super Entity Game Server
3  * http://www.segs.io/
4  * Copyright (c) 2006 - 2018 SEGS Team (see Authors.txt)
5  * This software is licensed! (See License.txt for details)
6  */
7 
8 #pragma once
9 #include "CommonNetStructures.h"
10 #include "BitStream.h"
11 #include "Powers.h"
18 
19 #include <QtCore/QString>
20 #include <QtCore/QVector>
21 #include <cassert>
22 #include <string>
23 
24 class CharacterCostume;
25 struct PlayerData;
26 struct Costume;
27 
29 {
31  int level = 0;
32  int num_combines = 0;
33 };
34 
36 {
38  int bought_at_level = 0;
39  float range = 1.0f;
40  std::vector<CharacterPowerBoost> boosts;
41 };
42 
43 enum NameFlag : bool
44 {
45  NoName = false,
46  HasName = true,
47 };
48 
49 enum ConditionalFlag : bool
50 {
51  Unconditional = false,
52  Conditional = true,
53 };
54 
55 class Character
56 {
57  friend class CharacterDatabase;
58 
59  using vPowerPool = std::vector<CharacterPower>;
60  using vCostume = std::vector<CharacterCostume>;
61 
62  vPowerPool m_powers;
63  PowerTrayGroup m_trays;
64  uint64_t m_owner_account_id;
65  uint8_t m_player_collisions=0;
66  friend bool toActualCharacter(const struct GameAccountResponseCharacterData &src, Character &tgt,PlayerData &player);
67  friend bool fromActualCharacter(const Character &src,const PlayerData &player, GameAccountResponseCharacterData &tgt);
68 public:
69  Character();
71 // Getters and setters
72 const QString & getName() const { return m_name; }
73  void setName(const QString &val);
74  uint8_t getIndex() const { return m_index; }
75  void setIndex(uint8_t val) { m_index = val; }
76  uint64_t getAccountId() const { return m_owner_account_id; }
77  void setAccountId(uint64_t val) { m_owner_account_id = val; }
78 
79 
80 //
82  void reset();
83  bool isEmpty();
84  void serializefrom(BitStream &buffer);
85  void serializeto(BitStream &buffer) const;
86  void serialize_costumes(BitStream &buffer, const ColorAndPartPacker *packer, bool all_costumes=true) const;
87  void serializetoCharsel(BitStream &bs);
88  void GetCharBuildInfo(BitStream &src); // serialize from char creation
89  void SendCharBuildInfo(BitStream &bs) const;
90  void recv_initial_costume(BitStream &src, const ColorAndPartPacker *packer);
91  const CharacterCostume *getCurrentCostume() const;
92  void DumpSidekickInfo();
93  void DumpPowerPoolInfo( const PowerPool_Info &pool_info );
94  void DumpBuildInfo();
95  void face_bits(uint32_t){}
96  void dump();
97  void sendFullStats(BitStream &bs) const;
98  void sendTray(BitStream &bs) const;
99  void sendDescription(BitStream &bs) const;
100  void sendTitles(BitStream &bs, NameFlag hasname, ConditionalFlag conditional) const;
101  void sendFriendList(BitStream &bs) const;
102 
107 
108  uint32_t m_account_id;
109  uint32_t m_db_id;
110 
111 protected:
113  uint8_t m_index;
114  QString m_name;
115  bool m_villain;
116  vCostume m_costumes;
120  uint32_t m_num_costumes;
121  bool m_multiple_costumes; // has more then 1 costume
123  {
130  };
131 };
132 
133 void serializeStats(const Character &src, BitStream &bs, bool sendAbsolute);
136 bool fromActualCharacter(const Character &src, const PlayerData &player, GameAccountResponseCharacterData &tgt);
The ColorAndPartPacker class is responsible for packing/unpacking colors and part names from BitStrea...
Definition: CommonNetStructures.h:34
int level
Definition: Character.h:31
int bought_at_level
Definition: Character.h:38
bool isEmpty()
Definition: Character.cpp:74
void GetCharBuildInfo(BitStream &src)
Definition: Character.cpp:93
Parse_CharAttrib m_max_attribs
Definition: Character.h:104
Definition: Costume.h:77
CharacterData m_char_data
Definition: Character.h:106
void recv_initial_costume(BitStream &src, const ColorAndPartPacker *packer)
Definition: Character.cpp:305
void setName(const QString &val)
Definition: Character.cpp:80
uint64_t getAccountId() const
Definition: Character.h:76
NameFlag
Definition: Character.h:43
void DumpBuildInfo()
Definition: Character.cpp:269
Definition: Character.h:55
Definition: Character.h:51
Definition: Character.h:52
void sendFriendList(BitStream &bs) const
Definition: Character.cpp:426
Definition: Powers.h:25
Definition: Character.h:28
Definition: Character.h:46
bool m_current_costume_set
Definition: Character.h:119
Definition: BitStream.h:30
Definition: playerdata_definitions.h:17
int num_combines
Definition: Character.h:32
void DumpSidekickInfo()
Definition: Character.cpp:246
void serializeStats(const Parse_CharAttrib &src, BitStream &bs, bool)
Definition: Character.cpp:313
void sendTray(BitStream &bs) const
Definition: Character.cpp:88
Costume * m_sg_costume
Definition: Character.h:117
void sendTitles(BitStream &bs, NameFlag hasname, ConditionalFlag conditional) const
Definition: Character.cpp:405
Definition: Character.h:127
std::vector< CharacterPowerBoost > boosts
Definition: Character.h:40
void reset()
Definition: Character.cpp:55
uint32_t m_num_costumes
Definition: Character.h:120
Parse_CharAttrib m_current_attribs
Definition: Character.h:103
Definition: other_definitions.h:22
uint32_t m_current_costume_idx
Definition: Character.h:118
const CharacterCostume * getCurrentCostume() const
Definition: Character.cpp:200
void sendFullStats(BitStream &bs) const
Definition: Character.cpp:388
void serializeto(BitStream &buffer) const
void setAccountId(uint64_t val)
Definition: Character.h:77
ConditionalFlag
Definition: Character.h:49
vCostume m_costumes
Definition: Character.h:116
bool m_villain
Definition: Character.h:115
friend class CharacterDatabase
Definition: Character.h:57
float range
Definition: Character.h:39
friend bool toActualCharacter(const struct GameAccountResponseCharacterData &src, Character &tgt, PlayerData &player)
Definition: Character.h:128
Definition: Powers.h:60
uint8_t m_index
Definition: Character.h:113
void DumpPowerPoolInfo(const PowerPool_Info &pool_info)
Definition: Character.cpp:256
Definition: GameDBSyncEvents.h:130
bool toActualCharacter(const GameAccountResponseCharacterData &src, Character &tgt, PlayerData &player)
Definition: Character.cpp:462
const QString & getName() const
Definition: Character.h:72
PowerPool_Info boost_id
Definition: Character.h:30
Definition: Character.h:125
LevelExpAndDebt m_other_attribs
Definition: Character.h:105
CharBodyType
Definition: Character.h:122
Definition: attrib_definitions.h:28
void setIndex(uint8_t val)
Definition: Character.h:75
Definition: Character.h:124
QString m_name
Definition: Character.h:114
Definition: Character.h:129
Character()
Definition: Character.cpp:36
void serialize_costumes(BitStream &buffer, const ColorAndPartPacker *packer, bool all_costumes=true) const
Definition: Character.cpp:209
bool fromActualCharacter(const Character &src, const PlayerData &player, GameAccountResponseCharacterData &tgt)
Definition: Character.cpp:486
uint8_t getIndex() const
Definition: Character.h:74
PowerPool_Info get_power_info(BitStream &src)
void sendDescription(BitStream &bs) const
Definition: Character.cpp:394
Definition: Character.h:126
uint32_t m_account_id
Definition: Character.h:108
bool m_multiple_costumes
Definition: Character.h:121
friend bool fromActualCharacter(const Character &src, const PlayerData &player, GameAccountResponseCharacterData &tgt)
Definition: Character.cpp:486
void serializefrom(BitStream &buffer)
Definition: Character.h:45
Definition: Character.h:35
PowerPool_Info power_id
Definition: Character.h:37
bool initializeCharacterFromCreator()
Definition: Costume.h:50
uint32_t m_db_id
Definition: Character.h:109
void dump()
Definition: Character.cpp:293
void face_bits(uint32_t)
Definition: Character.h:95
void SendCharBuildInfo(BitStream &bs) const
Definition: Character.cpp:107
Definition: chardata_definitions.h:29
void serializetoCharsel(BitStream &bs)
Definition: Character.cpp:182