Login Flow & Authentication
Complete sequence from ENet connect to world entry
Sequence Diagram
Client Server
| |
+- ENet Connect ---------------->| CONNECT event
| | allocate Player*
|<- Welcome (type 1) ------------| send_(peer, 1, ...)
| |
+- Login Packet (type 2) ------->| tankIDName|user
| protocol|225 | tankIDPass|pass
| game_version|5.53 | requestedName|
| fz|... | f|1
| klv|... | protocol|225
| hash|... | game_version|5.53
| mac|... | fz|23314424
| rid|... | klv|037fbb...
| | hash|466084983
| | mac|9c:12:21:08:xx:xx:xx
| | country|us
| | RTENDMARKERBS1001
| |
|<- OnSuperMainStart (OSM) ------| Type 4 binary
| (world list, user data, | NetID, userID,
| items, currency, etc.) | skin, clothes,
| | currency, etc.
| |
+- Join Request (type 3) ------->| action|join_request
| action|join_request|WORLD | WORLD_NAME
| |
|<- World Data ------------------| Type 4 packets
| - World blocks | - World header
| - Player spawn | - Tile data
| - Other players | - Player spawns
| |
|<- OnConsoleMessage ------------| "Welcome to WORLD"
| |
+- Gameplay begins ------------->| Type 4 binary packetsLogin Packet Fields
| Field | Example | Description |
|---|---|---|
| tankIDName | MyUsername | Account username |
| tankIDPass | MyPassword | Account password (plaintext) |
| requestedName | "" | Name change request (usually empty) |
| f | 1 | Platform flag |
| protocol | 225 | Protocol version (must match server) |
| game_version | 5.53 | Client game version |
| fz | 23314424 | Fingerprint/hash |
| klv | 037fbb624f... | Key lineage value (64-char hex) |
| hash | 466084983 | Account hash |
| mac | 9c:12:21:08:xx:xx:xx | MAC address |
| rid | 026F4146... | Device RID (32-char hex) |
| country | us | Country code |
| platformID | 0,1,1 | Platform identifiers |
OnSuperMainStart (OSM) Response
The OSM is the critical response packet sent after successful authentication. It contains all data needed for the client to begin gameplay:
- Player identity: NetID, userID, skin, clothes, colors
- Currency: Gems, World Locks, Diamond Locks, Blue Gem Locks
- Inventory: Full item list with counts
- World list: Available worlds, last world
- Social: Friends list, ignored players
- Flags: VIP, moderator, supporter, roles
- Playmods: Active effects with timers
- Settings: Audio, graphics, privacy
The OSM is a type 4 binary packet built via gamepacket_t with structured serialization.
Server-Side Processing
Rate Limiting
// Reset counters every 6.5 seconds
if (Server_Security.login_time + 6500 < now_ms()) {
Server_Security.login_count = 0;
Server_Security.update_item_data = 0;
Server_Security.login_time = now_ms();
}
// Limit concurrent logins per IP
int logged = count_peers_with_same_ip(peer->ip);
if (logged >= 3 || Server_Security.login_count > 40) {
failed_login(peer, "Too many people logging in");
return;
}
Server_Security.login_count++;Authentication
- Parse login packet fields
- Check RID bans (
Server_Security.ridbans) - Load player JSON from
players/{name}_.json - Verify password hash
- Load inventory, clothes, currency, flags
- Apply playmods, check expirations
- Build and send OSM response
- Set
pInfo(peer)->bypass = truefor type 3 packets
Join Request & World Entry
// Client sends (type 3):
action|join_request|WORLD_NAME
// Server processes:
1. Load world (get_world) - creates or loads from JSON
2. Send world header (size, weather, locks, etc.)
3. Send tile data (PackBlockType for each tile)
4. Send player spawn (OnSpawn with NetID, position, clothes)
5. Send other players in world (OnSpawn for each)
6. Send OnConsoleMessage "Welcome to WORLD_NAME"Load Testing Tool
A bundled test tool simulates 60 concurrent clients:
- Generates unique names:
faker{id}_{timestamp} - Sends login packet with all required fields
- Waits for
OnSuperMainStartdetection - Sends
action|join_request|START - Logs connection metrics (connected, login sent, OSM received, join sent)
Useful for load testing and protocol debugging.