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

Function Remote_SendStringToClient

netgames/dmfc/dmfcremote.cpp:545–590  ·  view source on GitHub ↗

Sends a string to a client (function encrypts it before sending)

Source from the content-addressed store, hash-verified

543
544// Sends a string to a client (function encrypts it before sending)
545void Remote_SendStringToClient(int client, const char *string) {
546 if (basethis->GetLocalRole() != LR_SERVER) {
547 Int3();
548 return;
549 }
550
551 int slen;
552 int new_strlen;
553 uint8_t *packet_data;
554
555 slen = strlen(string);
556 player_record *pr;
557 pr = PRec_GetPRecordByPnum(client);
558 int prec = translate_precptr_to_index(pr);
559 if (prec == -1) {
560 mprintf(0, "INVALID PREC!\n");
561 Int3();
562 return;
563 }
564
565 // check to make sure the player is authorized before sending
566 if (!Authorized_players[prec].authorized) {
567 Int3();
568 return;
569 }
570
571 Remote_encrypt(Authorized_players[prec].curr_key, slen, (uint8_t *)string, &new_strlen, &packet_data);
572
573 if (new_strlen == 0) {
574 mprintf(0, "COULDN'T ENCRYPT\n");
575 Int3();
576 return;
577 }
578
579 // now we can send off the packet
580 int count = 0;
581 uint8_t data[MAX_GAME_DATA_SIZE];
582 basethis->StartPacket(data, SPID_REMOTETOCLIENT, &count);
583
584 MultiAddInt(new_strlen, data, &count);
585 memcpy(&data[count], packet_data, new_strlen);
586 count += new_strlen;
587
588 basethis->SendPacket(data, count, client);
589 free(packet_data);
590}
591
592// Handles remote admin packets from a client
593void Remote_HandleClientPacket(uint8_t *data) {

Callers 2

Remote_LogoutFunction · 0.85
Remote_ServerProcessFunction · 0.85

Calls 7

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

Tested by

no test coverage detected