Dbserver-protocols
dbserver listens on several ports, each one providing a different service. Most services correspond to another server which will connect. All of these services use the common Network protocol, in TCP-only mode.
account
arena
auction
AuctionServer connects to this service. It can receive the following commands:
AUCTION_SVR_CONNECT (2)
The message has no parameters. dbserver will accept only a single connection, and while it has one, it will respond to all further AUCTION_SVR_CONNECT messages by closing the connection.
dbserver responds with AUCTION_CLIENT_CONNECT (2):
packint(1) protocol_version string shard_name bits(1) have_inactive_players something....
AUCTION_SVR_SEND_INV (3)
autobits entity_id string inventory
dbserver finds the mapserver for entity_id, and proxies the message there as DBSERVER_AUCTION_SEND_INV
inventory is eventually decoded by AuctionInventory_FromStr in the mapserver, but dbserver proxies it without inspecting its value.
AUCTION_SVR_SEND_HISTORYINFO (4)
autobits entity_id string identifier autobits buying_count autobits selling_count autobits history_count repeated history_count times: autobits date autobits price
dbserver finds the mapserver for entity_id, and proxies the message there as DBSERVER_AUCTION_SEND_HIST.
AUCTION_SVR_BATCH_SEND_ITEMINFO (5)
autobits entity_id zipped data
dbserver finds the mapserver for entity_id, and proxies the message there as DBSERVER_AUCTION_BATCH_INFO. The zipped data is not inspected by dbserver.
After this output packet has been queued, dbserver sends AUCTION_CLIENT_DATAOK to the AuctioServer, with no both. This is a primitive form of flow control. It does not wait for the message to be sent to the mapserver before doing this.
AUCTION_SVR_XACT_CMD (7)
autobits entity_id autobits type XactCmd cmd
dbserver finds the mapserver for entity_id. If there is one, it proxies the message there as DBSERVER_AUCTION_XACT_CMD. If there is no mapserver, then dbserver responds to AuctionServer with AUCTION_CLIENT_XACT_UPDATE, sending:
autobits xid autobits subid autobits result
Where xid and subid are taken from cmd, and the result is set to kXactCmdRes_No.
AUCTION_SVR_RELAY_CMD_BYENT (9)
packint(1) entity_id packint(1) force string msg
dbserver finds the mapserver for entity_id. If there is one, it sends DBSERVER_RELAY_CMD there with msg as the body. If there is no mapserver, and force is set to 1, then the message is queued for relaying when the entity is available, and dbserver begins attempting to load the entity into a mapserver.
AUCTION_SVR_THROTTLE_ON (10)
This message has no parameters, and dbserver sends no response. It enables throttling, which prevents some (???) messages from being sent to the AuctionServer.
AUCTION_SVR_THROTTLE_OFF (11)
This message has no parameters, and dbserver sends no response. It disables throttling.
AUCTION_SVR_ACCOUNT_SHARDXFER (12)
OrderId order_id autobits dbid
dbid is interpreted as an Ent id. dbserver will offline (???) and delete (???) the player, and then send AccountServer an ACCOUNT_CLIENT_SHARDXFER with:
OrderId order_id autobits SHARDXFER_FULFILL_COMMIT_SRC
beacon
client
This service is used for the game client to communicate with dbserver.
It is documented on Client-to-dbserver
db
This service is used to communicate with MapServer and RaidServer.
Every NetLink for the db server has a unique lock_id, starting from 0. They are used to identify current connections to MapServer in order to send messages.
DBCLIENT_INITIAL_CONNECT
optional packint(1) map_protocol
If map_protocol is not present (the body is empty), it is 0. If map_protocol is not equal to DBSERVER_PROTOCOL_VERSION (currently 20110503) then dbserver will respond with DBSERVER_CLIENT_CMD_FAILED and close the NetLink.
Otherwise, dbserver sends these commands back to the MapServer:
DBSERVER_TIMEOFFSET:
bits(32) seconds_since_2000 float32 time_zone_delta
These values are set based on the system clock. time_zone_delta is the difference between UTC and local time, in hours.
DBSERVER_OVERRIDDEN_AUTHBITS
bits(128) overridden_auth_bits
The value of overridden_auth_bits is set based on OverrideAuthBit lines in servers.cfg.
If any DisabledZoneEvents entries are present in servers.cfg, dbserver sends a DBSERVER_DISABLED_ZONE_EVENTS command:
repeated string event
One entry for each DisabledZoneEvents line in servers.cfg
If user reactivation is active, dbserver sends a DBSERVER_NOTIFY_REACTIVATION message, with no body.
DBSERVER_UPDATE_LOG_LEVELS:
repeated LOG_LEVELS times: packint(1) log_level
These are the log levels, as managed by log.h, for all logging types in order from 0 to LOG_LEVELS. They are set in servers.cfg with SetLogLevel lines.
DBSERVER_ACCOUNTSERVER_CATALOG:
autobits catalog_timestamp autobits auth_timeout string mtx_environment string play_span_domain string play_span_url_home string play_span_url_categoryview string play_span_url_itemview string play_span_url_showcart string play_span_url_addtocart string play_span_url_manageaccount string play_span_url_supportpage string play_span_url_supportpage_de string play_span_url_supportpage_fr string play_span_url_updatetovip string coh_url_newfeatures string coh_url_newfeaturesupdate autobits play_span_store_flags
These appear to be values set in account_server.cfg. Most of them are URLs.
DBCLIENT_READY
This message is understood by dbserver, but does not appear to be sent by mapserver; it is suspected to be historical debris.
DBCLIENT_REGISTER
packint(1) map_id packint(1) local_ip packint(1) remote_ip packint(1) udp_port packint(1) tcp_port packint(1) static_link packint(1) cookie string patch_version optional string map_name
A MapServer sends this message when it starts up, immediately after DBCLIENT_INITIAL_CONNECT.
static_link is set based on the command line of the MapServer
map_id is a signed int, set on the command line of the MapServer. Negative values mean that a map_name field will be sent and edit mode will be used.
If map_id is non-negative, then dbserver selects the container for this mapserver based on map_id, and closes the link if the map_id is not known. Otherwise, dbserver selects the container based on map_name, and enables edit mode on this container. If static_link is set, then dbserver searches for a map with this name. If static_link is not set, or no map of this name is found, then a new map container is created and populated with the data in the map_name field.
udp_port and tcp_port are the ports on which the MapServer will listen for game clients, and are set on the command line.
cookie is set on the command line of the MapServer, and sent as-is. If the cookie is non-zero, then dbserver will validate that it matches the cookie matches the container referenced by map_id, and will close the link if it does not match. This is used to ensure the MapServer is the one this dbserver wanted to spawn, and not from a previous instance of dbserver.
local_ip and remote_ip are sent by the mapserver, based on the result of gethostbyname(NULL). They will use the first two results from this function. If one of those results is an rfc1918 address, or 127.0.0.1 (none of the other loopback addresses are recognised as "local"), then it will be local_ip; otherwise local_ip will be the first result from gethostbyname() and remote_ip will be the second.
The map container in the dbserver will have its link set to the link which sent this message, and will be marked starting and active. dbserver will respond to the MapServer with DBSERVER_CONTAINERS, sending the container for map_id followed by the containers for all static maps.
DBCLIENT_REGISTER_CONTAINER_SERVER
packint(1) list_id
The client attempts to claim ownership of the DbList identified by list_id. This is used by RaidServer to register itself with dbserver. Only one link may own a DbList at a time. If another link has claimed the DbList, then this one is marked as waiting for it. If the owner of the DbList is disconnected, then a link which is waiting for it will become the owner.
When a link becomes the owner of a DbList, then dbserver sends it a DBSERVER_CONTAINER_SERVER_ACK:
packint(1) list_id packint(1) max_session_id
Owning a DbList affects the handling of DBCLIENT_CONTAINER_RELAY and DBCLIENT_REGISTER_CONTAINER_SERVER_NOTIFY messages.
DBCLIENT_REGISTER_CONTAINER_SERVER_NOTIFY
packint(1) notify_mask
All DbLists owned by this link have their notify mask set to notify_mask.
notify_mask is a bitmask, where each bit corresponds to a ContainerType value. For each bit set, when a notification for that DbList is available, a DBSERVER_CONTAINER_SERVER_NOTIFY will be sent:
packint(1) list_id packint(1) container_id packint(1) member_id bits(1) is_added
Notifications are only sent for the addition of Ents (player characters loading onto a map), deletion of containers, and for adding and removing group members. When an Ent is added, an add notification is sent for all groups that Ent is currently a member of.
is_added is 1 if a thing is being added, and 0 if a thing is being removed.
container_id is the id of the container being updated - either the group where members are being added or removed, or the container being deleted.
member_id is 0 if the operation is the removal of a group (supergroup deletion, etc), or the member ID if the operation is adding or removing a member from a group.
DBCLIENT_READY_FOR_PLAYERS
packint(1) map_id
This message is sent by MapServer when it has finished settup in the map. It marks the MapCon as not starting. If the MapCon has been marked for shutdown in the dbserver, then the dbserver will respond with an empty DBSERVER_TEAM_LEFT_MISSION message.
DBCLIENT_CONTAINER_INFO
This message has no body. dbserver will respond with DBSERVER_CONTAINER_INFO:
packint(1) count string dbserver_status repeated count-1 times: string container_status
dbserver_status will be a string like "DbServer started on %s, Up %d hours, %d minutes"
container_status will be a string like "0040 Ent (1)", giving the number of allocated containers in the each DbList, and its name and ContainerType value.
DBCLIENT_REQ_CONTAINERS
packint(1) user_data packint(1) list_id packint(1) cmd packint(1) count repeated count times: packint(1) container_id
dbserver will respond to this message with DBSERVER_CONTAINERS, with some containers selected from DbList list_id. user_data is returned in the DBSERVER_CONTAINERS response.
If cmd is CONTAINER_CMD_LOAD_ALL, count is ignored and all containers in the list are selected. Otherwise, container_id values are sent in the message, and those containers are selected.
Depending on the command selected, three other operations might be performed on this list:
- With CONTAINER_CMD_LOCK_AND_LOAD, CONTAINER_CMD_LOAD_ALL, CONTAINER_CMD_TEMPLOAD, or CONTAINER_CMD_TEMPLOAD_OFFLINE the containers will be loaded if necessary. Otherwise, containers that are not loaded will return an error code of CONTAINER_ERR_DOESNT_EXIST for that container.
- With CONTAINER_CMD_LOCK or CONTAINER_CMD_LOCK_AND_LOAD the containers will be locked to this link. Any container which is already locked by another link will return an error code of CONTAINER_ERR_ALREADY_LOCKED for that container.
- With CONTAINER_CMD_TEMPLOAD or CONTAINER_CMD_TEMPLOAD_OFFLINE any containers that have to be loaded for this message will be unloaded after it is finished.
- With CONTAINER_CMD_TEMPLOAD_OFFLINE the special handling for offline players (???) is used.
DBCLIENT_SET_CONTAINERS
packint(1) list_id packint(1) cmd packint(1) callback_id packint(1) count repeated count times: packint(1) container_id packint(1) notdiff packint(1) debugdiff string str optional string debugdiff_str
debugdiff_str is only sent when debugdiff is not 0, otherwise it is skipped
dbserver stores the containers, and responds with DBSERVER_CONTAINER_ACK to most messages:
packint(1) list_id packint(1) callback_id packint(1) count repeated count times: packint(1) ack_id
The ack_id values will be the container_id values that were updated.
One DBSERVER_CONTAINER_ACK response is sent after every update is applied, containing all acks so far (this appears to be a bug, and not used for anything). Acks are used by MapServer to return the container_id when creating containers, and otherwise ignored.
The exception to this are:
- when list_id is the AutoCommands list, in which case dbserver will instead respond by broadcasting a DBSERVER_CONTAINERS message to all active MapServers with the new container value
- when the container is a GroupCon type, and cmd is not CONTAINER_CMD_UNLOCK_NOMODIFY, in which case dbserver will instead respond by broadcasting a DBSERVER_CONTAINERS message to all interested links:
- MapServers that are running members of a MapGroup
- MapServers that have connected Ents for other groups
- the MapServer for a supergroup base
- the statserver for a statserver group
- the link that sent the DBCLIENT_SET_CONTAINERS message)
In these cases, no DBSERVER_CONTAINER_ACK messages are sent.
Possible values for cmd are:
- CONTAINER_CMD_CREATE, in which case id must be -1 and the container will be created.
- CONTAINER_CMD_CREATE_MODIFY, in which case id may be -1 and the container will be created if no container with this id exists.
- CONTAINER_CMD_DELETE, which will mark the container for deletion. str is ignored.
- CONTAINER_CMD_UNLOCK, which will apply updates and then unlock the container if this link has it locked.
- CONTAINER_CMD_UNLOCK_NOMODIFY, which will unlocked the container if this link has it locked, and not attempt to update the container. str is ignored
- CONTAINER_CMD_TEMPLOAD, which will load the container before updating it, and unload it after updating it, regardless of whether it was already loaded.
All other values of cmd will apply the update to an existing container.
If an error occurs, dbserver will abandon processing of the rest of the message, and respond with DBSERVER_CLIENT_CMD_FAILED:
packint(1) fail_code string str
This occurs in the following scenarios:
- id is -1 for commands other than CREATE and CREATE_MODIFY, or id being any value other than -1 for CREATE, will return CONTAINER_ERR_DOESNT_EXIST
- Parse errors for the container in str will return CONTAINER_ERR_CANT_COMPLETE_SERIOUS
- An attempt to create an Ent on an account without free character slots will return CONTAINER_ERR_CANT_COMPLETE
- An attempt to create an Ent where the character name cannot be parsed will return CONTAINER_ERR_CANT_COMPLETE
- For DbList other than maps, a container that exists must not be locked to a link other than this one, or it will return CONTAINER_ERR_ALREADY_LOCKED
- For DbList other than maps, and commands other than CREATE_MODIFY, the container must be locked or it will return CONTAINER_ERR_NOT_LOCKED
- If the container does not exist for whatever reason (after processing creation), it will return CONTAINER_ERR_DOESNT_EXIST
Applying container updates
str will be treated as a diff if notdiff is 0, or as a full copy of the container if notdiff is 1.
If the container does not have a template, then the string supplied always treated as a complete replacement, and the content of the container is simply set to this value, then special column processing is run.
If the container has a template, and notdiff is 1, then a diff will be computed from the current value of the template to the string supplied, and then processing will continue as if a diff had been sent.
If the container has a template, then the string will be parsed into a line list, and then merged into the current line list. Next, special column processing is run. The computed updates are then added to the queue of sql writes, and if the container has an update callback, it is called (this is probably a bug: it will be called twice).
Special columns processing begins by calling the update callback. It then runs through a list of commands, which identify fields in the line list by name. The values of these fields will be written into some address inside the DbContainer struct, as identified by the command. In the particular case of CMD_MEMBER, special tracking is done of memberships, which may result in sending notifications to servers that requested them with DBCLIENT_REGISTER_CONTAINER_SERVER_NOTIFY.
Special hackery
If the command is CREATE and the DbList is Ents (creating a player), then the player name will be uniquified (by appending or incrementing a number).
If the DbList is maps, and there is a map name in str, and a container with that name exists, then id is ignored and the container with that name is updated instead.
If the DbList is Ents and the container exists, and str contains a MapId field, then it must be equal to the map_id in the Ent or the server will assert (!!!).
If debugdiff is set, then the debugdiff_str field must be precisely equal to the observed diff to the container after the operation, or the server will assert (!!!).
If the command is CREATE and the DbList is Teamups, Supergroups, Taskforces, or Leagues, and the DbList is being stored in sql, then an sql barrier will be generated (all workers will synchronise).
If the DbList is maps, and the container is not being deleted, then dbserver will ask a launcher to start a MapServer if it does not have a link from a MapServer on this container.
DBCLIENT_CONTAINER_RELAY
packint(1) cmd packint(1) list_id packint(1) cid packint(1) user_cmd packint(1) user_data
If list_id is not recognised, or no server has that DbList locked, then dbserver will respond with DBSERVER_CONTAINER_RECEIPT:
packint(1) cmd packint(1) list_id packint(1) cid packint(1) user_cmd packint(1) user_data packint(1) error_code string error_msg
where error_code will be CONTAINER_ERR_CANT_COMPLETE.
Otherwise, dbserver will forward the message to the server which has locked that DbList, as DBSERVER_CONTAINER_RELAY:
packint(1) cmd packint(1) list_id packint(1) cid packint(1) user_cmd packint(1) user_data packint(1) lock_id ... everything else from the DBCLIENT_CONTAINER_RELAY is copied here
This is used for MapServer to send messages to RaidServer.
DBCLIENT_CONTAINER_RECEIPT
DBCLIENT_CONTAINER_REFLECT
DBCLIENT_REQ_CONTAINER_STATUS
DBCLIENT_REQUEST_MAP_XFER
DBCLIENT_MAP_XFER
DBCLIENT_CONTAINER_ACK
DBCLIENT_TEST_MAP_XFER
DBCLIENT_SEND_DOORS
DBCLIENT_SAVELISTS
DBCLIENT_ADDDEL_MEMBERS
DBCLIENT_PLAYER_DISCONNECT
DBCLIENT_SEND_MSG
DBCLIENT_REQ_GROUP_NAMES
DBCLIENT_REQ_ENT_NAMES
DBCLIENT_CONTAINER_FIND_BY_ELEMENT
DBCLIENT_SHUTDOWN
DBCLIENT_WHO
DBCLIENT_SERVER_STATS_UPDATE
DBCLIENT_RELAY_CMD
DBCLIENT_RELAY_CMD_BYENT
DBCLIENT_RELAY_CMD_TOGROUP
DBCLIENT_REQ_ONLINE_ENTS
DBCLIENT_REQ_ONLINE_ENT_COMMENTS
DBCLIENT_PLAYER_KICKED
DBCLIENT_REQ_CUSTOM_DATA
DBCLIENT_EXECUTE_SQL
DBCLIENT_DISCONNECT_MAPSERVER
DBCLIENT_PLAYER_RENAME
DBCLIENT_PLAYER_CHANGETYPE
DBCLIENT_PLAYER_CHANGESUBTYPE
DBCLIENT_PLAYER_CHANGEPRAETORIANPROGRESS
DBCLIENT_PLAYER_CHANGEINFLUENCETYPE
DBCLIENT_DEPRECATED
DBCLIENT_REQ_ARENA_ADDRESS
DBCLIENT_REQ_SG_ELDEST_ON
DBCLIENT_REQ_SG_CHANNEL_INVITE
DBCLIENT_SGRP_STATSADJ
DBCLIENT_DESTROY_BASE
DBCLIENT_MISSION_PLAYER_COUNT
DBCLIENT_SEND_STATSERVER_CMD
DBCLIENT_REQUEST_SHUTDOWN
DBCLIENT_EMERGENCY_SHUTDOWN
DBCLIENT_OFFLINE_CHAR
DBCLIENT_RESTORE_DELETED_CHAR
DBCLIENT_LIST_DELETED_CHARS
DBCLIENT_BACKUP
DBCLIENT_BACKUP_SEARCH
DBCLIENT_BACKUP_APPLY
DBCLIENT_BACKUP_VIEW
DBCLIENT_REQ_SOME_ONLINE_ENTS
DBCLIENT_OVERRIDE_START_ZONE
DBCLIENT_AUCTION_REQ_INV
DBCLIENT_AUCTION_REQ_HISTINFO
DBCLIENT_AUCTION_XACT_REQ
DBCLIENT_AUCTION_XACT_UPDATE
DBCLIENT_AUCTION_PURGE_FAKE
DBCLIENT_AUCTION_XACT_MULTI_REQ
DBCLIENT_MININGDATA_RELAY
DBCLIENT_SEND_AUCTIONSERVER_CMD
DBCLIENT_ACCOUNTSERVER_CMD
DBCLIENT_ACCOUNTSERVER_SHARDXFER
DBCLIENT_ACCOUNTSERVER_ORDERRENAME
DBCLIENT_GET_PLAYNC_AUTH_KEY
DBCLIENT_ACCOUNTSERVER_CHARCOUNT
DBCLIENT_RENAME_RESPONSE
DBCLIENT_CHECK_NAME_RESPONSE
DBCLIENT_ACCOUNTSERVER_GET_INVENTORY
DBCLIENT_ACCOUNTSERVER_CHANGE_INV
DBCLIENT_ACCOUNTSERVER_UPDATE_EMAIL_STATS
DBCLIENT_ACCOUNTSERVER_CERTIFICATION_TEST
DBCLIENT_ACCOUNTSERVER_CERTIFICATION_GRANT
DBCLIENT_ACCOUNTSERVER_CERTIFICATION_CLAIM
DBCLIENT_ACCOUNTSERVER_CERTIFICATION_REFUND
DBCLIENT_ACCOUNTSERVER_MULTI_GAME_TRANSACTION
DBCLIENT_ACCOUNTSERVER_TRANSACTION_FINISH
DBCLIENT_ACCOUNTSERVER_RECOVER_UNSAVED
DBCLIENT_ACCOUNTSERVER_LOYALTY_CHANGE
DBCLIENT_ACCOUNTSERVER_LOYALTY_EARNED_CHANGE
DBCLIENT_ACCOUNTSERVER_LOYALTY_RESET
DBCLIENT_MISSIONSERVER_COMMAND
DBCLIENT_MISSIONSERVER_PUBLISHARC
DBCLIENT_MISSIONSERVER_SEARCHPAGE
DBCLIENT_MISSIONSERVER_ARCINFO
DBCLIENT_MISSIONSERVER_BANSTATUS
DBCLIENT_MISSIONSERVER_ALLARCS
DBCLIENT_MISSIONSERVER_ARCDATA
DBCLIENT_MISSIONSERVER_ARCDATA_OTHERUSER
DBCLIENT_MISSIONSERVER_INVENTORY
DBCLIENT_MISSIONSERVER_CLAIM_TICKETS
DBCLIENT_MISSIONSERVER_BUY_ITEM
DBCLIENT_ACCOUNTSERVER_ORDERRESPEC
DBCLIENT_DELETE_PLAYER
DBCLIENT_QUEUE_FOR_EVENTS
DBCLIENT_REMOVE_FROM_QUEUE
DBCLIENT_EVENT_READY_ACK
DBCLIENT_EVENT_RESPONSE
DBCLIENT_MAP_ID
DBCLIENT_TURNSTILE_PING
DBCLIENT_DEBUG_SHARD_XFER_OUT
DBCLIENT_DEBUG_SHARD_XFER_BACK
DBCLIENT_GROUP_UPDATE
DBCLIENT_EVENTHISTORY_FIND
DBCLIENT_CLOSE_INSTANCE
DBCLIENT_REJOIN_INSTANCE
DBCLIENT_PLAYER_LEAVE
DBCLIENT_MAP_WEEKLY_TF_ADD_TOKEN
DBCLIENT_MAP_WEEKLY_TF_REMOVE_TOKEN
DBCLIENT_MAP_WEEKLY_TF_SET_EPOCH_TIME
DBCLIENT_TEST_LOGGING
DBCLIENT_INCARNATETRIAL_COMPLETE
DBCLIENT_QUEUE_FOR_SPECIFIC_MISSION_INSTANCE
DBCLIENT_TS_ADD_BAN_DBID
DBCLIENT_MAP_SET_MARTY_STATUS
DBCLIENT_GRANT_CHARSLOT
DBCLIENT_PLAYER_UNLOCK
DBCLIENT_ACCOUNT_ADJUST_SERVER_SLOTS
DBCLIENT_UNLOCK_CHARACTER_RESPONSE
DBCLIENT_DEBUG_SET_VIP
DBSERVER_CONTAINERS
packint(1) user_data packint(1) list_id packint(1) count repeated count times: packint(1) id packint(1) has_error packint(1) is_map_xfer packint(1) is_static_map packint(1) locked packint(1) is_deleting packint(1) demand_loaded packint(1) member_count repeated member_count times: packint(1) member_id string text
If has_error is 1, then the block for this container is replaced by:
packint(1) map_id packint(1) has_error packint(1) error_code
The error_code will be CONTAINER_ERR_DOESNT_EXIST if the container was not found or not loaded, and CONTAINER_ERR_ALREADY_LOCKED if this was an attempt to lock the container and another link already has this container locked. In all cases, errors are on a per-container basis, and the rest of the request will be processed.
This message is used to send containers to the MapServer. The contents of the container is represented in the text string.
user_data will either be 0, or a value sent by the client that requested these containers. It is used by clients to identify responses.
locked will be 1 if the container has now been locked to this link, and 0 if the locking state is unchanged.
If the container is a group, then a member_id list will be sent. Otherwise, member_count will be 0.
is_map_xfer will be 0 unless the container is an Ent.
is_static_map will be 0 unless the container is a Map.