Atlas
0.7.0
Networking protocol for the Worldforge system.
|
8 #include <Atlas/Objects/Entity.h>
11 using Atlas::Message::MapType;
13 namespace Atlas {
namespace Objects {
namespace Entity {
15 Allocator<AdminEntityData> AdminEntityData::allocator;
33 return copyInstance<AdminEntityData>(*
this);
38 if(ADMIN_ENTITY_NO == classNo)
return true;
42 void AdminEntityData::fillDefaultObjectInstance(
AdminEntityData& data, std::map<std::string, uint32_t>& attr_data)
58 const std::string USERNAME_ATTR =
"username";
59 const std::string PASSWORD_ATTR =
"password";
60 const std::string CHARACTERS_ATTR =
"characters";
64 if (allocator.attr_flags_Data.find(name) != allocator.attr_flags_Data.end()) {
72 auto I = allocator.attr_flags_Data.find(name);
73 if (I != allocator.attr_flags_Data.end()) {
82 if (name == USERNAME_ATTR) { attr =
getUsername();
return 0; }
83 if (name == PASSWORD_ATTR) { attr =
getPassword();
return 0; }
98 if (name == USERNAME_ATTR)
99 { m_attrFlags &= ~USERNAME_FLAG;
return;}
100 if (name == PASSWORD_ATTR)
101 { m_attrFlags &= ~PASSWORD_FLAG;
return;}
102 if (name == CHARACTERS_ATTR)
103 { m_attrFlags &= ~CHARACTERS_FLAG;
return;}
109 if(m_attrFlags & USERNAME_FLAG) {
116 if(m_attrFlags & PASSWORD_FLAG) {
123 if(m_attrFlags & CHARACTERS_FLAG) {
124 b.mapListItem(CHARACTERS_ATTR);
126 b.listStringItem(item);
143 if(m_attrFlags & USERNAME_FLAG)
145 if(m_attrFlags & PASSWORD_FLAG)
147 if(m_attrFlags & CHARACTERS_FLAG)
157 allocator.free(
this);
169 return copyInstance<AccountData>(*
this);
174 if(ACCOUNT_NO == classNo)
return true;
178 void AccountData::fillDefaultObjectInstance(
AccountData& data, std::map<std::string, uint32_t>& attr_data)
192 attr_data[USERNAME_ATTR] = USERNAME_FLAG;
193 attr_data[PASSWORD_ATTR] = PASSWORD_FLAG;
194 attr_data[CHARACTERS_ATTR] = CHARACTERS_FLAG;
203 allocator.free(
this);
215 return copyInstance<PlayerData>(*
this);
220 if(PLAYER_NO == classNo)
return true;
224 void PlayerData::fillDefaultObjectInstance(
PlayerData& data, std::map<std::string, uint32_t>& attr_data)
246 allocator.free(
this);
258 return copyInstance<AdminData>(*
this);
263 if(ADMIN_NO == classNo)
return true;
267 void AdminData::fillDefaultObjectInstance(
AdminData& data, std::map<std::string, uint32_t>& attr_data)
289 allocator.free(
this);
301 return copyInstance<GameData>(*
this);
306 if(GAME_NO == classNo)
return true;
310 void GameData::fillDefaultObjectInstance(
GameData& data, std::map<std::string, uint32_t>& attr_data)
332 allocator.free(
this);
344 return copyInstance<GameEntityData>(*
this);
349 if(GAME_ENTITY_NO == classNo)
return true;
353 void GameEntityData::fillDefaultObjectInstance(
GameEntityData& data, std::map<std::string, uint32_t>& attr_data)
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
void sendPassword(Atlas::Bridge &) const
Send the "password" attribute to an Atlas::Bridge.
void addToMessage(Atlas::Message::MapType &) const override
Write this object to an existing Element.
void setCharactersAsList(const Atlas::Message::ListType &val)
Set the "characters" attribute AsList.
void reset() override
Resets the object as it's returned to the pool.
const std::string & getPassword() const
Retrieve the "password" attribute.
bool instanceOf(int classNo) const override
Is this instance of some class?
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
void setAttr(std::string name, Atlas::Message::Element attr, const Atlas::Objects::Factories *factories=nullptr) override
Set the attribute "name" to the value given by"attr".
double attr_stamp
Last time this object was modified.
void reset() override
Resets the object as it's returned to the pool.
std::vector< std::string > attr_characters
List of characters account can control.
GameEntityData * copy() const override
Copy this object.
std::string attr_password
Password for account usually.
void free() override
Free an instance of this class, returning it to the memory pool.
bool instanceOf(int classNo) const override
Is this instance of some class?
bool instanceOf(int classNo) const override
Is this instance of some class?
AccountData * copy() const override
Copy this object.
StringType && moveString()
GameData * copy() const override
Copy this object.
void reset() override
Resets the object as it's returned to the pool.
bool instanceOf(int classNo) const override
Is this instance of some class?
std::string attr_parent
The object this inherits attributes from.
void setPassword(std::string val)
Set the "password" attribute.
void setUsername(std::string val)
Set the "username" attribute.
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
AdminEntityData * copy() const override
Copy this object.
AdminData * copy() const override
Copy this object.
int copyAttr(const std::string &name, Atlas::Message::Element &attr) const override
double attr_stamp_contains
Last time any object that uses this as reference recursively has been modified.
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
void free() override
Free an instance of this class, returning it to the memory pool.
void reset() override
Resets the object as it's returned to the pool.
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
All In Game classes and objects.
std::vector< double > attr_pos
Position coordinates, usually world is 3D.
Atlas::Message::ListType getCharactersAsList() const
Retrieve the "characters" attribute AsList.
All classes and objects used for administrative purposes.
void free() override
Free an instance of this class, returning it to the memory pool.
void free() override
Free an instance of this class, returning it to the memory pool.
bool instanceOf(int classNo) const override
Is this instance of some class?
void reset() override
Resets the object as it's returned to the pool.
void sendCharacters(Atlas::Bridge &) const
Send the "characters" attribute to an Atlas::Bridge.
void sendContents(Atlas::Bridge &b) const override
Send the contents of this object to a Bridge.
std::string attr_username
Username for account usually.
std::vector< double > attr_velocity
Velocity object is moving, usually world is 3D.
PlayerData * copy() const override
Copy this object.
void free() override
Free an instance of this class, returning it to the memory pool.
void setAttr(std::string name, Atlas::Message::Element attr, const Atlas::Objects::Factories *factories=nullptr) override
Set the attribute "name" to the value given by"attr".
bool instanceOf(int classNo) const override
Is this instance of some class?
void sendUsername(Atlas::Bridge &) const
Send the "username" attribute to an Atlas::Bridge.
int getAttrClass(const std::string &name) const override
Find the class which contains the attribute "name".
bool getAttrFlag(const std::string &name, uint32_t &flag) const override
Find the flag for the attribute "name".
void reset() override
Resets the object as it's returned to the pool.
std::string attr_objtype
What kind of object this is.
void free() override
Free an instance of this class, returning it to the memory pool.
bool instanceOf(int classNo) const override
Is this instance of some class?
void reset() override
Resets the object as it's returned to the pool.
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.
const std::string & getUsername() const
Retrieve the "username" attribute.
void removeAttr(const std::string &name) override
Remove the attribute "name". This will not work for static attributes.