Development:Network:Packet format
Contents
- 1 Packet format
- 1.1 acctserver.cpp
- 1.1.1 CMD_LOGIN: C->S, CMD_LOGIN (S to A)
- 1.1.2 LOGIN_NEW (A to S)
- 1.1.3 LOGIN_ACCEPT (A to S)
- 1.1.4 LOGIN_ALREADY, LOGIN_UNAVAIL (A to S), LOGIN_ERROR (A to S)
- 1.1.5 CMD_LOGOUT (C to S)
- 1.1.6 CMD_LOGOUT (S to A)
- 1.1.7 CMD_NEWCHAR (S to A)
- 1.1.8 CMD_NEWSUBSCRIBE (S to A)
- 1.1.9 (Cmd)0 (A to S)
- 1.1.10 CMD_RESYNCACCOUNTS (S to A)
- 1.1.11 CMD_SAVEACCOUNTS (S to A)
- 1.1.12 LOGIN_DATA (C to A)
- 1.2 netserver.cpp
- 1.2.1 CMD_ADDCLIENT (C to S)
- 1.2.2 CMD_POSUPDATE (C to S)
- 1.2.3 CMD_LETSGO (C to S)
- 1.2.4 CMD_PING (C to S)
- 1.2.5 CMD_SERVERTIME (C to S)
- 1.2.6 CMD_ACK (C to S)
- 1.2.7 CMD_ASKFILE (C to S)
- 1.2.8 CMD_DOWNLOAD (C to S)
- 1.2.9 CMD_FIREREQUEST (C to S)
- 1.2.10 CMD_UNFIREREQUEST (C to S)
- 1.2.11 CMD_JUMP (C to S)
- 1.2.12 CMD_SCAN (C to S)
- 1.2.13 CMD_TARGET (C to S)
- 1.2.14 CMD_STARTNETCOMM, CMD_STOPNETCOMM, CMD_SOUNDAMPLE, CMD_TXTMESSAGE (C to S)
- 1.2.15 CMD_DOCK (C to S)
- 1.2.16 CMD_UNDOCK (C to S)
- 1.3 netclient.cpp
- 1.3.1 LOGIN_ACCEPT (S to C)
- 1.3.2 CMD_ASKFILE (S to C)
- 1.3.3 CMD_DOWNLOAD (S to C)
- 1.3.4 LOGIN_ERROR,LOGIN_UNAVAIL (S to C)
- 1.3.5 CMD_CREATECHAR (S to C)
- 1.3.6 CMD_LOCATIONS (S to C)
- 1.3.7 CMD_SNAPSHOT (S to C)
- 1.3.8 CMD_ENTERCLIENT (S to C)
- 1.3.9 CMD_EXITCLIENT (S to C)
- 1.3.10 CMD_ADDEDYOU (S to C)
- 1.3.11 CMD_DISCONNECT (S to C)
- 1.3.12 CMD_ACK (S to C)
- 1.3.13 CMD_FIREREQUEST (S to C)
- 1.3.14 CMD_UNFIREREQUEST (S to C)
- 1.3.15 CMD_SCAN (S to C)
- 1.3.16 CMD_TARGET (S to C)
- 1.3.17 CMD_SNAPDAMAGE (S to C)
- 1.3.18 CMD_DAMAGE (S to C)
- 1.3.19 CMD_DAMAGE1 (S to C)
- 1.3.20 CMD_KILL (S to C)
- 1.3.21 CMD_JUMP (S to C)
- 1.3.22 CMD_STARTNETCOMM, CMD_STOPNETCOMM, CMD_SOUNDSAMPLE, CMD_SECSNDSAMPLE, CMD_TXTMESSAGE, CMD_SECMESSAGE (S to C)
- 1.3.23 CMD_DOCK (S to C)
- 1.3.24 CMD_UNDOCK (S to C)
- 1.3.25 CMD_POSUPDATE (S to C)
- 1.3.26 CMD_CREATE{UNIT|NEBULA|PLANET|ASTER|MISSILE} (S to C)
- 1.3.27 CMD_SERVERTIME (S to C)
- 1.1 acctserver.cpp
Packet format
acctserver.cpp
CMD_LOGIN: C->S, CMD_LOGIN (S to A)
- Function sent:
- Handler function:
- Data:
- char flags; // Don't seem to be used.
- string callsign; // The username should be restricted to a reasonable subset of ASCII
- string passwd; // Not encrypted -- Should be encrypted with a token (or timestamp).
LOGIN_NEW (A to S)
- Function sent:
- Handler function:
- Data:
- No Data
Sent the first time someone logs into an account -- asks for faction, ship, etc.
LOGIN_ACCEPT (A to S)
- Function sent:
- Handler function:
- Data:
- No Data
LOGIN_ALREADY, LOGIN_UNAVAIL (A to S), LOGIN_ERROR (A to S)
- Function sent: CMD_NEWSUBSCRIBE, CMD_LOGIN
- Handler function:
- Data:
- No Data
CMD_LOGOUT (C to S)
- Function sent:
- Handler function: references logoutList...
- Data:
- FIXME WRITEME
CMD_LOGOUT (S to A)
- Function sent:
- Handler function:
- Data:
- string callsign;
- string passwd; // Why send the password to logout?
CMD_NEWCHAR (S to A)
UNIMPLEMENTED!!!
// Should receive the result of the creation of a new char/ship
CMD_NEWSUBSCRIBE (S to A)
- Function sent:
- Handler function:
- Data:
- string callsign;
- string passwd;
Subscribes an account.
(Cmd)0 (A to S)
- Function sent: CMD_NEWLOGIN
- Handler function: The input checking that the server most certainly uses.
Unable to open account file?
CMD_RESYNCACCOUNTS (S to A)
- Function sent:
- Handler function:
- Data:
- ObjSerial nbclients; // Number of clients?
- Array [nbclients]
- short sertmp;
Calls setConnected(true) on all included Client serials.
CMD_SAVEACCOUNTS (S to A)
- Function sent:
- Handler function: AccountServer::writeSave(data, dataLen);
- Data:
- SaveString savestr;
- XmlString xmlstr; // Actually, the CSV ship data.
FileUtil::WriteSaveFiles(savestr, xmlstr, callsign);
CltSerial serial; vector<string> saves = FileUtil::GetSaveFromBuffer( netbuf );
LOGIN_DATA (C to A)
- Function sent:
- Handler function: AccountServer::sendServerData(sock, elem);
- Data:
- string callsign;
- string passwd;
Responds with IP address to connect to.
netserver.cpp
CMD_ADDCLIENT (C to S)
- Function sent:
- Handler function: NetServer::addClient(clt);
- Data:
- CltSerial ser;
CMD_POSUPDATE (C to S)
- Function sent:
- Handler function: NetServer::posUpdate(clt);
- Data:
- CltSerial ser;
Client tells server its actual position. Server accepts client's position with no validation.
CMD_LETSGO (C to S)
UNIMPLENTED!
CMD_PING (C to S)
- Function sent:
- Handler function:
- Data:
// Nothing to do here, just receiving the packet is enough
Source code comments are usually right.
CMD_SERVERTIME (C to S)
- Function sent:
- Handler function: serverTimeInitUDP(clt, netbuf);
- Data:
CMD_ACK (C to S)
// Commented out.
CMD_ASKFILE (C to S)
UNIMPLENTED!
CMD_DOWNLOAD (C to S)
- Function sent:
- Handler function: _downloadManagerServer->addCmdDownload( clt->tcp_sock, netbuf );
- Data:
- FIXME WRITEME
CMD_FIREREQUEST (C to S)
- Function sent: Unit::Fire -> NetClient::fireRequest
- Handler function:
- Data:
- ObjSerial target_serial;
- char mis; // Is this a missile? (Note: Missile FIREREQUESTS must be sent separately.
- int num_mount;
- Array[num_mount]
- int mount_to_fire
This seems to be sent *constantly* while firing! A waste of bandwidth and console buffer.
CMD_UNFIREREQUEST (C to S)
- Function sent: Unit::UnFire -> NetClient::unfireRequest
- Handler function:
- Data:
- ObjSerial target_serial;
- int num_mount;
- Array[num_mount]
- int mount_to_unfire
Not being sent very well. Firing has a tendency currently to get stuck.
CMD_JUMP (C to S)
- Function sent:
- Handler function:
- Data:
- string newsystem;
- ObjSerial jumpserial;
- ushort zonenum;
No idea how this is supposed to work... transfer to another server?
CMD_SCAN (C to S)
- Function sent: NetClient::scanRequest
- Handler function:
- Data:
- ObjSerial target_serial;
- ushort zone;
CMD_TARGET (C to S)
- Function sent: firekeyboard.cpp -> NetClient::targetRequest
- Handler function:
- Data:
- ObjSerial target_serial;
CMD_STARTNETCOMM, CMD_STOPNETCOMM, CMD_SOUNDAMPLE, CMD_TXTMESSAGE (C to S)
FIXME netcomm
CMD_DOCK (C to S)
- Function sent:
- Handler function:
- Data:
- ObjSerial utdwserial; // Unit to dock with.
- ushort zonenum;
CMD_UNDOCK (C to S)
- Function sent:
- Handler function:
- Data:
- ObjSerial utdwserial; // Unit to dock with.
- ushort zonenum;
netclient.cpp
LOGIN_ACCEPT (S to C)
- Function sent: Account server forwarded through netserver?????
- Handler function: NetClient::loginAccept(packet);
- Data:
- FIXME WRITEME
CMD_ASKFILE (S to C)
- Function sent:
- Handler function:
- Data:
- string filename;
- string file;
CMD_DOWNLOAD (S to C)
- Function sent:
- Handler function: _downloadManagerClient->processCmdDownload( clt_tcp_sock, netbuf );
- Data:
- FIXME WRITEME
LOGIN_ERROR,LOGIN_UNAVAIL (S to C)
- Function sent:
- Handler function: NetClient::disconnect();
- Data:
- No data.
CMD_CREATECHAR (S to C)
// Commented out.
- Function sent:
- Handler function: NetClient::createChar();
- Data:
- FIXME WRITEME
CMD_LOCATIONS (S to C)
- Function sent:
- Handler function: NetClient::receiveLocations(Packet);
- Data:
- FIXME WRITEME
// Should receive possible starting locations list
I assume this means that the client can choose where to start within a system?
IMO, the in-system starting point may just as well be determined randomly in the server.
CMD_SNAPSHOT (S to C)
- Function sent:
- Handler function: NetClient::receivePositions(numUnits, timestamp, netbuffer);
- Data:
- uint numUnits;
- uint timestamp;
- double deltatime; // NETFIXME: Uses netbuf.getFloat???
This is the packet that updates a client on *every* position!
Perhaps the server should optimize based on the distance from the client?
CMD_ENTERCLIENT (S to C)
- Function sent:
- Handler function: NetClient::AddClientObject(NetBuffer, ObjSerial);
- Data:
- FIXME WRITEME
CMD_EXITCLIENT (S to C)
- Function sent:
- Handler function: NetClient::removeClient(Packet);
- Data:
- FIXME WRITEME
CMD_ADDEDYOU (S to C)
- Function sent:
- Handler function: this->game_unit.GetUnit()->curr_physical_state = netbuf.getTransformation();
- Data:
- Transformation curr_physical_state;
CMD_DISCONNECT (S to C)
- Function sent:
- Handler function: VSExit(1);
- Data:
- No data.
In my opinion, this could have a slightly more graceful exit.
It doesn't even seem to close the socket...
As the code says, /*** TO REDO IN A CLEAN WAY ***/
CMD_ACK (S to C)
// Commented out.
CMD_FIREREQUEST (S to C)
- Function sent: NetServer::BroadcastFire
- Handler function: netclient.cpp:574 (case)
- Data:
- ObjSerial unSerial = p1.getSerial(); // Not sure how Packet and NetBuffer are different?
- ObjSerial mis;
- int num_mount;
- Array[num_mount]
- int mount_to_fire
CMD_UNFIREREQUEST (S to C)
- Function sent: NetServer::BroadcastUnfire
- Handler function: netclient.cpp:618 (case)
- Data:
- ObjSerial unSerial = p1.getSerial();
- int num_mount;
- Array[num_mount]
- int mount_to_unfire
CMD_SCAN (S to C)
- Function sent:
- Handler function: Cockpit::ReceivedTargetInfo();
- Data:
- No data.
CMD_TARGET (S to C)
- Function sent: NetServer::BroadcastTarget
- Handler function: Cockpit::ReceivedTargetInfo();
- Data:
- No data.
CMD_SNAPDAMAGE (S to C)
- Function sent:
- Handler function: ALL 85 lines in netclient.cpp:673-759
- Data:
- int nbupdates = packet_serial;
- ObjSerial serial;
- Array[nbupdates]
- short damages [mask];
- ObjSerial serial;
- More data based on mask:
- See netclient.cpp:673 for more detail.
CMD_DAMAGE (S to C)
- Function sent:
- Handler function: Unit::ApplyNetDamage(pnt, normal, amt, ppercentage, spercentage, col);
- Data:
- float amt;
- float ppercentage;
- float spercentage;
- Vector pnt;
- Vector normal;
- GFXColor col; // Unused.
- ObjSerial target;
- Shield sh;
- Armor ar;
Seems to be in an #ifdef NET_SHIELD_SYSTEM_1
CMD_DAMAGE1 (S to C)
// Commented out.
CMD_KILL (S to C)
- Function sent:
- Handler function: netclient.cpp:800 (case), Unit::Destroy()
- Data:
- ObjSerial clt = p1.getSerial();
CMD_JUMP (S to C)
- Function sent:
- Handler function: netclient.cpp:830
- Data:
- string newsystem;
- ObjSerial unserial;
- ObjSerial jumpserial;
- ushort zoneid;
CMD_STARTNETCOMM, CMD_STOPNETCOMM, CMD_SOUNDSAMPLE, CMD_SECSNDSAMPLE, CMD_TXTMESSAGE, CMD_SECMESSAGE (S to C)
FIXME Netcomm stuff...
CMD_DOCK (S to C)
- Function sent:
- Handler function: netclient.cpp:960
- Data:
- ObjSerial utdw_serial;
- int dockport;
- p1.getSerial();
CMD_UNDOCK (S to C)
- Function sent:
- Handler function: netclient.cpp:970
- Data:
- ObjSerial utdw_serial;
- p1.getSerial();
CMD_POSUPDATE (S to C)
- Function sent:
- Handler function: netclient.cpp:970
- Data:
- QVector serverpos;
// If a client receives that it means the server want to force the client position to be updated // with server data
Forces your position to be updated.
Normally, since SNAPSHOTs are old, they is ignored on CMD_SNAPSHOT. I assume, that after this, the client will relay its position, velocity, etc. back to the server to be broadcast?
The server should never have to manually update a client's position.
CMD_CREATE{UNIT|NEBULA|PLANET|ASTER|MISSILE} (S to C)
- Function sent:
- Handler function: netclient.cpp:1000-1125
- Data:
- FIXME WRITEME
Loads a lot of stuff from the packet, and then calls UnitFactory::create{Unit|...} (...);
CMD_SERVERTIME (S to C)
// No action... apparently receiving this is enough.
How is this different from CMD_PING?