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

Function Remote_SendStringToServer

netgames/dmfc/dmfcremote.cpp:451–491  ·  view source on GitHub ↗

Sends a string to the server (function encrypts it before sending)

Source from the content-addressed store, hash-verified

449
450// Sends a string to the server (function encrypts it before sending)
451void Remote_SendStringToServer(const char *string) {
452 if (basethis->GetLocalRole() == LR_SERVER) {
453 Int3();
454 return;
455 }
456
457 int slen;
458 int new_strlen;
459 uint8_t *packet_data;
460
461 slen = strlen(string);
462 player_record *pr;
463 pr = PRec_GetPRecordByPnum(basethis->GetPlayerNum());
464 int prec = translate_precptr_to_index(pr);
465 if (prec == -1) {
466 mprintf(0, "INVALID PREC!\n");
467 Int3();
468 return;
469 }
470
471 Remote_encrypt(Authorized_players[prec].curr_key, slen, (uint8_t *)string, &new_strlen, &packet_data);
472
473 if (new_strlen == 0) {
474 mprintf(0, "COULDN'T ENCRYPT\n");
475 Int3();
476 return;
477 }
478
479 // now we can send off the packet
480 int count = 0;
481 uint8_t data[MAX_GAME_DATA_SIZE];
482 basethis->StartPacket(data, SPID_REMOTETOSERVER, &count);
483
484 MultiAddByte(prec, data, &count);
485 MultiAddInt(new_strlen, data, &count);
486 memcpy(&data[count], packet_data, new_strlen);
487 count += new_strlen;
488
489 basethis->SendPacket(data, count, SP_SERVER);
490 free(packet_data);
491}
492
493// Handles remote admin packets from a client
494void Remote_HandleServerPacket(uint8_t *data) {

Callers 1

Remote_ClientProcessFunction · 0.85

Calls 9

PRec_GetPRecordByPnumFunction · 0.85
Remote_encryptFunction · 0.85
MultiAddByteFunction · 0.85
MultiAddIntFunction · 0.85
GetLocalRoleMethod · 0.80
GetPlayerNumMethod · 0.80
StartPacketMethod · 0.80
SendPacketMethod · 0.80

Tested by

no test coverage detected