Entity (container)

From OuroDev

Entities are the container which represents a player character.

Storage and ownership

They are persisted in the dbserver database, but depending on the state of login sessions, might be owned by dbserver or a MapServer. When an entity is loaded onto a MapServer, dbserver sends the current copy of the entity to the MapServer, and locks it to that MapServer connection. The entity is then owned by the MapServer until it is unlocked (when the character leaves the map) or the connection is lost. While an entity is owned by a MapServer, the only up-to-date copy of the entity is in ram of the MapServer, which will send updates back to dbserver for persistance to the database, but does not wait for responses.

If a MapServer connection is lost without sending back entities, data will be lost, and users will experience a rollback to the last point where a copy of the entity was successfully persisted.

Entities can be "offlined", which means dbserver removes them from the sql database and writes them to a local file instead. Deleted entities are handled by offlining them, to make it possible to restore them later.

Loading and saving

Entities are loaded into MapServer from dbserver when dbserver sends a DBSERVER_CONTAINERS message to MapServer. The Entity container is unpacked into an Entity struct by the unpackEnt function.

Containers are sent back to dbserver by running this process in reverse. The packageEnt function converts an Entity struct into an Entity container. This can be used in a few different ways:

  • The shardjump command will cause DBCLIENT_AUCTION_XACT_REQ to be sent to dbserver with the container modified to remove the map ID, friends, and group memberships.
  • The shardxfer_init command will cause DBCLIENT_ACCOUNTSERVER_SHARDXFER to be sent to dbserver, modifying the container as above, but also inserting or applying the home and remote shard annotations if appropriate.
  • The packageent command will pack the entity and send it to the requesting client in a SERVER_SEND_PACKAGEDENT message
  • The svrSendEntListToDb function will send DBCLIENT_SET_CONTAINERS to dbserver for persistent storage in the database, using CONTAINER_CMD_DONT_LOCK. This happens when:
    • A player disconnects from this mapserver, for whatever reason, and the Entity was loaded via DBSERVER_CONTAINERS
    • The entsave command will cause all entities to be immediatley saved
    • When MapServer receives DBSERVER_SHUTDOWN from dbserver it will save all entities
    • Once a second, MapServer saves 1/1024 of the Entities that it has loaded; this will save all Entities once every 7.05 minutes
    • Any of the following commands will cause the relevant Entity to be saved: team_accept, coalition_accept, league_accept, hideset, raid_accept
    • When a trade between two characters completes, both Entites are saved
    • When a character gains a level, adds a power, or adds a boost slot
    • When a character respec is applied
    • When a supergroup is created, its creator is saved
    • When a map transfer is ready and DBCLIENT_MAP_XFER is about to be sent, the Entity being transferred is saved
    • When a corrupted Entity is repaired after being loaded, it is immediately saved
    • When a player joins a team or changes their LFG status, their Entity is saved

unpackEnt

This function runs the relatively elaborate parsing of the Entity container, as some different tables within it have slightly different parsing rules. It also applies a series of sanity checks and fixes to potentially corrupted data.

packageEnt

This function packs the various bits of data in an Entity struct into an Entity container.

Contents

Fields are using the names from serialised containers, as sent over the network or dumped by dbquery.

TeamupsId Identifys which 8-player team the character is on. This is the container ID in the Teamups DbList. Teamups are not persisted in the database, so are wiped when dbserver restarts.
SupergroupsId Identifys which supergroup the character is in. This is the container ID in the Supergroup DbList.
TaskforcesId Identifys which task force group the character is in. This is the container ID in the Taskforce DbList.
AuthId Account id (from the auth server) for the owner of the character. This is the container ID in the ShardAccount DbList.
AuthName Account name (from the auth server) for the owner of the character.
Name Character name. Character names are maintained in an in-ram model in dbserver, so can only be modified via dbserver.
StaticMapId Map id - The last static map the player was on (usually a city zone). When they exit a mission, they will be sent to this zone. This is the container ID in the maps DbList.
MapId Map id - The ID of the map they are currently on. This is the container ID in the maps DbList.
PosX, PosY, PosZ Current location of the character in their current map.
OrientP, OrientY, OrientR Current orientation of the character.
TotalTime The number of seconds the character has been online. Only updated on map moves and log out.
LoginCount The number of times the character has been logged in.
LastActive The date and time of the last log in.
AccessLevel The command access level. Normal players are always 0. GMs have higher values.
ChatBanExpire The date and time when the character will be allowed to send chat again.
DbFlags Bitfield. Positions are:
0 DBFLAG_TELEPORT_XFER Door flag. Teleport the entity to the location described by its SpawnTarget field.
1 DBFLAG_UNTARGETABLE Sets the untargetable and admin fields on the entity.
2 DBFLAG_INVINCIBLE Sets the invincible field on the entity.
3 DBFLAG_DOOR_XFER Door flag. Find the door described by its SpawnTarget field and place the entity there.
4 DBFLAG_MISSION_ENTER Door flag. Place the entity at the MissionStart location.
5 DBFLAG_MISSION_EXIT Door flag. Place the entity at the first location in its MapHistory field, with orientation rotated 180 degrees.
6 DBFLAG_INVISIBLE Sets the hide field on the entity to 2, which makes the entity persistently invisible.
7 DBFLAG_INTRO_TELEPORT Door flag. Place the entity at the NewPlayer, NewPlayerHero, or NewPlayerVillain location, reset story arcs, and send the new player welcome message.
8 DBFLAG_MAPMOVE Door flag. Place the entity at a random door on the map.
9 DBFLAG_CLEARATTRIBS All "abusive" buffs will be cleared when this entity is loaded. This is set when the entity is on an arena map, in a raid, an architect task force, or on a pvp map.
10 DBFLAG_NOCOLL Sets the nocoll field on the entity to 2 (what does this do???).
11 DBFLAG_BASE_ENTER Door flag. Find the spawn location based on its SpawnTarget field, handling base raids appropriately.
12 DBFLAG_RENAMEABLE Set when the entity has a rename token applied, making it possible for the client to rename them.
13 DBFLAG_BASE_EXIT Door flag. If the last location in its MapHistory field is a mission, go to BaseTeleportSpawn. Otherwise, like DBFLAG_MISSION_EXIT.
14 DBFLAG_ALT_CONTACT Indicates that the entity's initial contact is Burke instead of Kalinda.
15 DBFLAG_ARCHITECT_EXIT Unused.
16 DBFLAG_PRAET_SG_JOIN Set when an ex-Praetorian character joins a supergroup, to award their join bonus to only their first supergroup.
17 DBFLAG_HALF_MAX_HEALTH Halves the max health of the character, until removed by a special reward. Comments indicate this was used during the Praetorian tutorial, but now appears to be obsolete.
18 DBFLAG_UNLOCK_HERO_EPICS Unlocks Kheldian characters, if any character on the account is at least level 20 and has this flag set. Will be set for Primal Hero characters.
19 DBFLAG_UNLOCK_VILLAIN_EPICS Unlocks Arachnos characters, if any character on the account is at least level 20 and has this flag set. Will be set for Primal Villain characters.

Door flags are used when an entity is loaded onto a MapServer after a map transfer, to determine their initial position on the new map. They are cleared immediately after loading.

Locale Sets the language and other locale defaults
GurneyMapId Map id - The ID of the most recently visited static map which contains a hospital. If the character is defeated, they will get sent to this hospital.
TitleCommon The common title of the character, chosen at level 15
TitleOrigin The origin title of the character, chosen at level 20
MouseSpeed A multiplier for mouse speed (sensitivity). This is set in the options screen.
TurnSpeed A multiplier for mouse turning speed (sensitivity). This is set in the options screen.
TopChatFilter Bitfield - designates which types of chat appear in the top pane of the chat window.
BotChatFilter Bitfield - designates which types of chat appear in the bottom pane of the chat window.
ChatSendChannel The id of the output channel in the chat window
KeyProfile The name of the keybind profile the player has chosen on the options screen.
KeybindCount The number of keybinds currently in use
FriendCount The number of local friends
Rank The character's supergroup rank. 0 is member, 1 is lieutenant, 2 is captain, 3 is commander, 4 is leader.
TimePlayed The number of seconds the character has been in supergroup mode.
MemberSince The date and time when the character joined their supergroup
TaskForceMode If 1, the player is on a task force and in task force mode. If 0, they are not. 2 if its an architect taskforce
BodyType Gender and body type. 0 is male, 1 is female, 4 is huge.
BodyScale Overall body scale.
BoneScale Overall bone scale.
ColorSkin Color - skin color
Motto The character's battle cry (motto), entered on the ID screen
Description The character's description, entered on the ID screen
CurrentTray The index of the main tray
CurrentAltTray The index of the alternate (2nd) tray
ChatDivider The location of the chat divider in the chat window.
SpawnTarget The name of a beacon where the character will be spawned.
Class The Archetype (class) of the character
Origin The Origin of the character
Level The 0-based security level of the character. (If this value is 4, then the character's level is 5)
ExperiencePoints The number of experience points earned
ExperienceDebt The amount of debt accrued to be worked off
InfluencePoints The amount of influence the character currently has
HitPoints The character's current hit points
Endurance The character's current endurance
ChatFontSize The size of the chat font (set in options)
UniqueTaskIssued Bitfield - Tracks which unique tasks have been given to the character

The bits in this bitfield are assigned incrementally based on entries in server/db/templates/vars.attribute, which begin with the string xUNIQUETASK1_. The first such line in the file is bit 0, the second is bit 1, etc.

TitleSpecial The special title given to the character (given by GMs)
TitlesChosen Tracks which which titles (common and origin) the character has chosen.
TitleSpecialExpires The number of seconds which the character keeps the special title.
AuthUserData A copy of the auth user data from the Auth server.

This field is no longer used. It has been replaced by a larger version in Ents2. dbserver will convert this to the new type when it finds it, and then remove this field from the container.

UiSettings Bitfield - Misc UI settings (set in the options screen)
ShowSettings Bitfield - UI settings for showing reticles, health bars, names, etc. (set in the options screen)
NPCCostume If the character has been shape-changed, the index of the NPC Costume to use.
Banned If 1, the character cannot be logged in. (Set and unset by GMs.)
NumCostumeSlots The number of costume slots this character has earned
SuperPrimary Bitfield - For the Supergroup costume, determines if primary color is original or one of the supergroup colors
SuperSecondary Bitfield - For the Supergroup costume, determines if secondary color is original or one of the supergroup colors
CurrentCostume Index of the costume the character is currently wearing.
SuperPrimary2 Bitfield - For the Supergroup costume, SuperPrimary was not large enough for all parts
SuperSecondary2 Bitfield - For the Supergroup costume, SuperSecondary was not large enough for all parts
SuperTertiary Bitfield - For the Supergroup costume, some parts have 4 colors, determines which color is used for supergorup mode
SuperQuaternary Bitfield - For the Supergroup costume, some parts have 4 colors, determines which color is used for supergorup mode
FxSpecial
FxSpecialExpires
CsrModified If non-zero, then a GM has modified this character in some way. (Used to exclude the character in data mining.)
DateCreated The date that the character was created.
Gender The gender of the character (used to match gender in gendered languages).
0 Undefined
1 Neuter
2 Male
3 Female
NameGender The gender of the name of the character (used to match gender in gendered languages). Same values as Gender.
PlayerType
0 Hero
1 Villain
Prestige How much prestige the character has earned while a member of their current supergroup.
IsSlotLocked Current lock state of this character. 0 is unlocked, 1 is locked, 2 is supposed to be offlined (and locked), but offlined characters are now removed from Entities entirely.
Ents2 More single-value fields that are part of the Entity.
Tray
Friends
Windows
KeyBinds
SuperCostumeParts
VisitedMaps Array of values.
FameStrings
ChatWindows
ChatTabs
ChatChannels
DefeatRecord
RewardTokens Array of values.
RewardTokensActive Array of values.
Contacts
StoryArcs
Tasks
SouvenirClues
NewspaperHistory
PetNames Array of values.
MapHistory Array of values.
InvBaseDetail Array of values.
CombatMonitorStat
RecentBadge
BadgeMonitor
Ignore
GmailClaims
GmailPending
QueuedRewardTables
MARTYTracks
CertificationHistory Array of values.
CompletedOrders Array of values.
PendingOrders Array of values.
Powers
Boosts
Inspirations
AttribMods
Stats
CostumeParts
Appearance
PowerCustomizations
Badges
InvSalvage
InvConcept
InvRecipe
InvBaseDetail No longer used?
InvStoredSalvage

Ents2

This structure is represented in the Ents2 subfield of an Entity. In serialised containers it will appear like Ents2[0].RespecTokens, but is not an array.

RespecTokens Bitfield - the set of respec tokens the player has earned.

Each respec token is represented by two bits, with the lower one indicating that the respec has been granted, and the upper one indicating that the respec has been used. For example, setting bit 8 indicates that the first veteran respec has been granted, and bit 9 indicates that it has been used. The following positions are used:

0 Respec trial 1
2 Respec trial 2
4 Respec trial 3
6 Free respec, granted by csr
8 Veteran respec 1
10 Veteran respec 2
12 Veteran respec 3
14 Patron respec
24..31 Respec counter

The top 8 bits (0xff000000) are an 8-bit counter of respecs, instead of a bitfield. This is incremented or decremented as respecs are added or removed.

When a respec is consumed, it will pick in this sequence:

  1. free
  2. counter
  3. patron
  4. trials 1..3
  5. veteran 1..3
PendingReward The name of the reward table to apply to the character (used when character is offline and is granted a reward)
PendingRewardVillian The villain group for the pending reward (used when character is offline and is granted a reward)
PendingRewardLevel The level for the pending reward (used when character is offline and is granted a reward)
TitleBadge The character's current chosen Badge title
ChatSettings Bitfield - Chat settings
PrimaryChatMinimized Bitfield - Chat settings
MousePitch Camera following behaviour. 0 is free, 1 is spring, 2 is fixed.
UiSettings2 Bitfield - Misc UI settings
UserSendChannel The default chat channel the character is chatting to
FreeTailorSessions
MapOptions
Notoriety The character's notoriety (difficulty) level
0 Heroic/Villainous
1 Tenacious/Malicious
2 Rugged/Vicious
3 Unyielding/Ruthless
4 Invincible/Relentless
ChatBubbleTextColor Color of text in character's chat bubble
ChatBubbleBackColor Color of backgroudn bubble for character's chat bubble
TitleTheText If the character has a title leading with a definite article, this is the text to use for it.
DividerSuperName Width of UI column in window
DividerSuperMap Width of UI column in window
DividerSuperTitle Width of UI column in window
DividerEmailFrom Width of UI column in window
DividerEmailSubject Width of UI column in window
DividerFriendName Width of UI column in window
DividerLfgName Width of UI column in window
DividerLfgMap Width of UI column in window
LfgFlags Bitfield - What kind of groups the character is looking to join
0 Any
1 Hunt
2 Missions
3 Task Force
4 Trial
5 Arena
6 None
Comment The comment displayed for this character in the search window
TooltipDelay
UltraTailor
ArenaPaid
ArenaPaidAmount
ArenaPrizeAmount
Insight
CurrentAlt2Tray
MaxHitPoints
WisdomPoints
WisdomLevel
PvPSwitch
Reputation
VillainGurneyMapId
SkillsUnlocked
Rage
ExitMissionContext Specifies the information about the task that was just completed for displaying the exit mission text
ExitMissionSubHandle Specifies the information about the task that was just completed for displaying the exit mission text
ExitMissionCompoundPos Specifies the information about the task that was just completed for displaying the exit mission text
ExitMissionOwnerId Specifies the information about the task that was just completed for displaying the exit mission text
ExitMissionSuccess Specifies the information about the task that was just completed for displaying the exit mission text
TeamCompleteOption Specifies if the character wants credit for shared missions. 0 is prompt, 1 is always, 2 is never.
TimeInSGMode
UpdateTeamTask
BuffSettings
RecipeInvBonus
RecipeInvTotal
SalvageInvBonus
SalvageInvTotal
AuctionInvBonus
AuctionInvTotal
UiSettings3
StoredSalvageInvBonus
StoredSalvageInvTotal
AccSvrLock Used to lock entities while multi-step transactions are being run by AccountServer. Notably this is used during shard transfer, to prevent characters from being logged in while the transfer process is running.
TrayIndexes
HideField
originalPrimary
originalSecondary
MouseScrollSpeed
ExperienceRest
CurBuild The 0-based build number currently in use
LevelBuild0 Level of a build
LevelBuild1 Level of a build
LevelBuild2 Level of a build
LevelBuild3 Level of a build
LevelBuild4 Level of a build
LevelBuild5 Level of a build
LevelBuild6 Level of a build
LevelBuild7 Level of a build
RaidsId
LevelingPactsId
PendingArchitectTickets
BuildChangeTime Seconds since 2000 at which we can next change builds
BuildName0 Name of a build
BuildName1 Name of a build
BuildName2 Name of a build
BuildName3 Name of a build
BuildName4 Name of a build
BuildName5 Name of a build
BuildName6 Name of a build
BuildName7 Name of a build
ExitMissionPlayerCreated
LastDayJobsStart
ArchitectMissionsCompleted
PlayerSubType The character's current alignment within their faction:
0 Hero / Villain (normal)
1 Paragon / Tyrant
2 Vigilante / Rogue (able to switch sides)
InfluenceType Current type, for non-praetorians:
0 Influence
1 Infamy
InfluenceEscrow Total Influence (not Infamy or Information) available. Copied to Influence if InfluenceType is 0
AutoAcceptAbove The how far above their current level will be auto accepted by the player
AutoAcceptBelow The how far below their current level will be auto accepted by the player
LevelAdjust Level adustment of enemies ( -1 to +4 )
TeamSize Team size this player is treated as ( 1 to 8 )
UpgradeAV If true, don't downgrade AV to EB, otherwise always do
DowngradeBoss No bosses while solo
PraetorianProgress Whether the character is from Primal Earth or Praetorian and if so what progress they've made
0 Primal Earth-born
1 Praetorian, still in the tutorial
2 Praetorian, in Praetoria
3 Praetorian, on Primal Earth
4 Praetorian transferring to Paragon City
5 Praetorian transferring to the Rogue Isles
6 Primal Earth character in tutorial, before choosing a side
SpecialMapReturnData
IncarnateTimer0 The time when this incarnate slot will be slottable again
IncarnateTimer1 The time when this incarnate slot will be slottable again
IncarnateTimer2 The time when this incarnate slot will be slottable again
IncarnateTimer3 The time when this incarnate slot will be slottable again
IncarnateTimer4 The time when this incarnate slot will be slottable again
IncarnateTimer5 The time when this incarnate slot will be slottable again
IncarnateTimer6 The time when this incarnate slot will be slottable again
IncarnateTimer7 The time when this incarnate slot will be slottable again
IncarnateTimer8 The time when this incarnate slot will be slottable again
IncarnateTimer9 The time when this incarnate slot will be slottable again
PopHelpLatest0 The latest pop helps to have been received, in order
PopHelpLatest1 The latest pop helps to have been received, in order
PopHelpLatest2 The latest pop helps to have been received, in order
PopHelpLatest3 The latest pop helps to have been received, in order
PopHelpLatest4 The latest pop helps to have been received, in order
PopHelpStatus The state of each pop help, untriggered, unread, unseen, or dissmissed.
TitleColor1
TitleColor2
AuthUserDataEx A copy of the auth user data from the Auth server. UserData_Bits explains the contents.
LeaguesId Container ID for the league this entity is a member of.
SpecialReturnInProgress Is a specialMapReturnData transfer in progress? Used to solve race condition problems.
CurrentRazerTray The index of the Razer tray
HomeDBID Container ID of this entity on its home shard. Only used when visiting another shard.
HomeShard Shard number of this entity's home shard.
RemoteDBID Remote container ID of this entity when it is visiting another shard. This field is stored on the home shard, to indicate that the entity is currently visiting another shard.
VisitStartTime secondsSince2000 at which the character started the visit. Used to ensure they go back home eventually
HomeSGID Supergroup ID on home shard, only relevant when visiting
HomeLPID Leveling Pact ID on home shard, only relevant when visiting
ShardVisitorData Data used during shard visitor transfer. Includes such things as league identifier, target map, target location
RemoteShard Remote shard when visiting.
DisplayAlignmentStatsToOthers Flag to denote whether this player's alignment stats (in the Alignment tab in the Player Info window) are visible to other players.
DesiredTeamNumber Team number I want to be on in end game raid league
LastAutoCommandRunTime The time that the Auto Command system last ran commands against this Entity.
IsTeamLeader Promote me to team leader when turnstile starts
LastTurnstileEventID ID of the last turnstile event I was in
LastTurnstileMission ID of the last turnstile mission I was in
TurnstileTeamLock Turnstile team lock
PendingCertification0 Certification order we have not heard back from yet
PendingCertification1 Certification order we have not heard back from yet
PendingCertification2 Certification order we have not heard back from yet
PendingCertification3 Certification order we have not heard back from yet
HelperStatus flag that determines whether the player is a newbie or a vet for help system purposes.
UiSettings4 Bitfield - Misc UI settings
MapOptionRevision Used to initialize the MapOptions and MapOptions2 values to handle new defaults we want to set.
MapOptions2 Bitfield - Map display options
SelectedContactOnZoneEnter This contact (stored by handle #) will be selected as soon as the player next ticks, which may be after a mapmove. Currently used by the Contact Finder.
TeamupTimer_ActivePlayer Moment in time when teamup_activePlayer is set to point to teamup (internal)
ValidateCostume If set, the primary costume should be validated on receipt of account inventory
NumCostumeStored The number of costume slots stored on this character
DoNotKick if set, the character will not be kicked for invalid cosutmes, ATs and Powersets
LastTurnstileStartTime Time that turnstile started
HideOpenSalvageWarning Option to hide the open salvage warning dialog.
hideStorePiecesState State of Hide Store Pieces in Tailor
cursorScale Scale of the cursor
NewFeaturesVersion Last version that New Features window was shown

Tray

Friends

Windows

KeyBinds

SuperCostumeParts

VisitedMaps

FameStrings

ChatWindows

ChatTabs

ChatChannels

DefeatRecord

RewardTokens

RewardTokensActive

Contacts

StoryArcs

Tasks

SouvenirClues

NewspaperHistory

PetNames

MapHistory

InvBaseDetail

CombatMonitorStat

RecentBadge

BadgeMonitor

Ignore

GmailClaims

GmailPending

QueuedRewardTables

MARTYTracks

CertificationHistory

CompletedOrders

PendingOrders

Powers

Boosts

Inspiration

AttribMods

Stats

CostumeParts

Appearance

PowerCustomizations

Badges

Badges is not in the regular format.

The field .Owned is a bitfield of owned badges. Indexes into this (large) bitfield correspond to IDs in server/db/templates/badges.attribute

All other fields are of the form .c100, where the number after the c is a badge ID from badges.attribute, and the value is the current stat recorded for this badge, whatever that might mean.

InvSalvage

InvConcept

InvRecipe

InvBaseDetail

InvStoredSalvage