Given a hud message, it will determine who should get this message. "name: message" = the player with the callsign name should get the message "team: message" = the Player_num's team should get the message "0-32: message" = the player with player num of 0-32 should get the message all other messages are for everyone else returns the starting position of the real message (past the :) destination w
| 741 | // MULTI_SEND_MESSAGE_YELLOW_TEAM = only yellow team (3) should get this message |
| 742 | // 0-32 = player num of the player to get the message |
| 743 | const char *GetMessageDestination(const char *message, int *destination) { |
| 744 | int to_who = MULTI_SEND_MESSAGE_ALL; |
| 745 | const char *ret = message; |
| 746 | |
| 747 | // see if there is a colon in the string, and match that up with a name |
| 748 | const char *colon_pos = NULL; |
| 749 | colon_pos = strchr(message, ':'); |
| 750 | if (colon_pos > message) { |
| 751 | // this message might be for one person in particular |
| 752 | char buffer[256]; |
| 753 | memcpy(buffer, message, (colon_pos - message)); |
| 754 | buffer[colon_pos - message] = '\0'; |
| 755 | |
| 756 | // see if buffer is a number, in which case just send to that pnum |
| 757 | char *p = buffer; |
| 758 | bool is_num = true; |
| 759 | while (*p) { |
| 760 | if (!isdigit(*p)) { |
| 761 | is_num = false; |
| 762 | break; |
| 763 | } |
| 764 | p++; |
| 765 | } |
| 766 | |
| 767 | if (is_num) { |
| 768 | to_who = atoi(buffer); |
| 769 | if (to_who < 0 || to_who >= MAX_PLAYERS) |
| 770 | to_who = MULTI_SEND_MESSAGE_ALL; |
| 771 | } else { |
| 772 | int possible_match = -1; |
| 773 | int name_len = strlen(buffer); |
| 774 | int call_len; |
| 775 | |
| 776 | // it's not a number, see if it matches any of the player names |
| 777 | for (int pn = 0; pn < MAX_PLAYERS; pn++) { |
| 778 | if (NetPlayers[pn].flags & NPF_CONNECTED && NetPlayers[pn].sequence == NETSEQ_PLAYING) { |
| 779 | |
| 780 | call_len = strlen(Players[pn].callsign); |
| 781 | |
| 782 | if (call_len > name_len) { |
| 783 | // try to match a partial name |
| 784 | if (!strnicmp(Players[pn].callsign, buffer, name_len)) { |
| 785 | // possible match |
| 786 | possible_match = pn; |
| 787 | } |
| 788 | } else if (call_len == name_len) { |
| 789 | if (!stricmp(Players[pn].callsign, buffer)) { |
| 790 | // match! |
| 791 | to_who = pn; |
| 792 | break; |
| 793 | } |
| 794 | } |
| 795 | } // end if |
| 796 | } // end for |
| 797 | |
| 798 | if (to_who < 0 && possible_match != -1) { |
| 799 | to_who = possible_match; |
| 800 | } |
no outgoing calls
no test coverage detected