Sends a string to the server (function encrypts it before sending)
| 449 | |
| 450 | // Sends a string to the server (function encrypts it before sending) |
| 451 | void 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 |
| 494 | void Remote_HandleServerPacket(uint8_t *data) { |
no test coverage detected