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

Function SendD3PilotData

netcon/mtclient/mtpilottracker.cpp:267–328  ·  view source on GitHub ↗

Call with NULL to poll Call with valid pointer to a vmt_descent3_struct to initiate send

Source from the content-addressed store, hash-verified

265// Call with NULL to poll
266// Call with valid pointer to a vmt_descent3_struct to initiate send
267int SendD3PilotData(vmt_descent3_struct *d3_pilot) {
268 // First check the network
269 PollPTrackNet();
270
271 if (d3_pilot == nullptr) {
272 if (D3WriteState == STATE_IDLE) {
273 return -3;
274 }
275 if (D3WriteState == STATE_SENDING_PILOT) {
276 return 0;
277 }
278 if (D3WriteState == STATE_WROTE_PILOT) {
279 // We wrote this pilot, and now we are about to inform the app, so back to idle
280 D3WriteState = STATE_IDLE;
281 return 1;
282 }
283 if (D3WriteState == STATE_TIMED_OUT) {
284 // We gave up on sending this pilot, and now we are about to inform the app, so back to idle
285 D3WriteState = STATE_IDLE;
286
287 return -1;
288 }
289 if (D3WriteState == STATE_WRITE_PILOT_FAILED) {
290 // The tracker said this dude couldn't be written
291 D3WriteState = STATE_IDLE;
292
293 return 3;
294 }
295 } else if (D3WriteState == STATE_IDLE) {
296 // New request, send out the req, and go for it.
297
298 D3WriteState = STATE_SENDING_PILOT;
299
300 D3LastSentWrite = DLLtimer_GetTime();
301 D3FirstSentWrite = DLLtimer_GetTime();
302
303 d3_pilot_write.len = INTEL_SHORT(PACKED_HEADER_ONLY_SIZE + DESCENT3_BLOCK_SIZE);
304 d3_pilot_write.type = UNT_PILOT_DATA_WRITE;
305 d3_pilot_write.code = INTEL_INT(CMD_GAME_DESCENT3);
306 d3_pilot_write.security = d3_pilot->security;
307
308 d3_pilot->deaths = INTEL_INT(d3_pilot->deaths);
309 d3_pilot->kills = INTEL_INT(d3_pilot->kills);
310 d3_pilot->online_time = INTEL_INT(d3_pilot->online_time);
311 d3_pilot->games_played = INTEL_INT(d3_pilot->games_played);
312 d3_pilot->lateral_thrust = INTEL_INT(d3_pilot->lateral_thrust);
313 d3_pilot->rank = INTEL_INT(d3_pilot->rank);
314 d3_pilot->rotational_thrust = INTEL_INT(d3_pilot->rotational_thrust);
315 d3_pilot->sliding_pct = INTEL_INT(d3_pilot->sliding_pct);
316 d3_pilot->suicides = INTEL_INT(d3_pilot->suicides);
317
318#if (!(defined(OEM) || defined(DEMO)))
319 // This is the secret number we will use to determine if it's
320 // a game where we want to update the player's rank or not.
321 d3_pilot->lateral_thrust = INTEL_INT(0x142);
322#endif
323 memcpy(&d3_pilot_write.data, d3_pilot, DESCENT3_BLOCK_SIZE);
324

Callers 2

DoMTFrameFunction · 0.85
DoMTGameOverFunction · 0.85

Calls 1

PollPTrackNetFunction · 0.85

Tested by

no test coverage detected