MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / MultiDoMyInfo

Function MultiDoMyInfo

Descent3/multi.cpp:2288–2407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2286extern int Buddy_handle[MAX_PLAYERS];
2287bool AINotify(object *obj, uint8_t notify_type, void *info);
2288void MultiDoMyInfo(uint8_t *data) {
2289 int count = 0;
2290 char ship_name[PAGENAME_LEN];
2291 int length;
2292
2293 // Skip header stuff
2294 SKIP_HEADER(data, &count);
2295
2296 uint8_t slot = MultiGetByte(data, &count);
2297 if (!(NetPlayers[slot].flags & NPF_CONNECTED)) {
2298 mprintf(1, "ERROR! We got a MY_INFO packet from a disconnected player!\n");
2299 Int3(); // Get Jason
2300 return;
2301 }
2302
2303 // Copy the name out
2304 uint8_t len = MultiGetByte(data, &count);
2305 if (len > CALLSIGN_LEN)
2306 length = CALLSIGN_LEN;
2307 else
2308 length = len;
2309
2310 memcpy(Players[slot].callsign, &data[count], length);
2311 count += len;
2312
2313 // Copy the ship name out
2314 len = MultiGetByte(data, &count);
2315 memcpy(ship_name, &data[count], len);
2316 count += len;
2317
2318 int ship_index = FindShipName(ship_name);
2319 if (ship_index < 0)
2320 ship_index = 0;
2321
2322 if (!PlayerIsShipAllowed(slot, ship_name)) {
2323 bool found_one = false;
2324 int i;
2325
2326 // Loop through ships, looking for one that's allowed
2327 for (i = 0; i < MAX_SHIPS && !found_one; i++) {
2328 if (Ships[i].used && PlayerIsShipAllowed(Player_num, i)) {
2329 Players[Player_num].ship_index = i;
2330 MultiBashPlayerShip(slot, Ships[i].name);
2331 found_one = true;
2332 }
2333 }
2334
2335 // We should have found one
2336 ASSERT(found_one == true);
2337 }
2338
2339 PlayerChangeShip(slot, ship_index);
2340
2341 Players[slot].time_in_game = timer_GetTime();
2342 if (Game_is_master_tracker_game) {
2343 uint32_t mt_sig;
2344
2345 Players[slot].kills = 0;

Callers 1

MultiProcessDataFunction · 0.85

Calls 11

SKIP_HEADERFunction · 0.85
MultiGetByteFunction · 0.85
FindShipNameFunction · 0.85
PlayerIsShipAllowedFunction · 0.85
MultiBashPlayerShipFunction · 0.85
PlayerChangeShipFunction · 0.85
MultiGetUintFunction · 0.85
MultiGetIntFunction · 0.85
MultiGetUshortFunction · 0.85
ObjGetFunction · 0.85
AINotifyFunction · 0.85

Tested by

no test coverage detected