Breaks up the input message so that if we overflow it starts on the next line nicely Returns the number of characters in the next line
| 905 | // Breaks up the input message so that if we overflow it starts on the next line nicely |
| 906 | // Returns the number of characters in the next line |
| 907 | int BreakupHUDInputMessage(char *str) { |
| 908 | int cur = 0; |
| 909 | int last_space = -1; |
| 910 | int len = strlen(HudInputMessage); |
| 911 | |
| 912 | for (int i = 0; i < len; i++) { |
| 913 | if (HudInputMessage[i] == ' ') |
| 914 | last_space = i; |
| 915 | } |
| 916 | |
| 917 | if (last_space == -1) { |
| 918 | return 0; |
| 919 | } |
| 920 | |
| 921 | int leftover_len = len - last_space; |
| 922 | int leftover_size = leftover_len - 1; |
| 923 | if (leftover_len > 0) { |
| 924 | int to_who; |
| 925 | const char *colon_pos = GetMessageDestination(HudInputMessage, &to_who); |
| 926 | |
| 927 | if (to_who != MULTI_SEND_MESSAGE_ALL) { |
| 928 | char to_who_text[64]; |
| 929 | int to_who_size; |
| 930 | |
| 931 | to_who_size = colon_pos - HudInputMessage - 1; |
| 932 | strncpy(to_who_text, HudInputMessage, to_who_size); |
| 933 | to_who_text[to_who_size] = '\0'; |
| 934 | |
| 935 | sprintf(str, "%s:%s", to_who_text, &HudInputMessage[last_space + 1]); |
| 936 | leftover_size = strlen(str); |
| 937 | } else { |
| 938 | strcpy(str, &HudInputMessage[last_space + 1]); |
| 939 | } |
| 940 | } |
| 941 | |
| 942 | HudInputMessage[last_space] = 0; |
| 943 | |
| 944 | return leftover_size; |
| 945 | } |
| 946 | |
| 947 | // Handles all incoming keys for an inputted hud message |
| 948 | void DoHUDInputMessageKey(int key) { |
no test coverage detected