draws a string
| 439 | #define GR_STR_LEN 128 |
| 440 | // draws a string |
| 441 | void grtext_Puts(int x, int y, const char *str) { |
| 442 | struct { |
| 443 | char op; |
| 444 | int16_t x, y; |
| 445 | } cmd; |
| 446 | |
| 447 | ASSERT((Grtext_ptr + sizeof(cmd) + strlen(str) + 1) < GRTEXT_BUFLEN); |
| 448 | |
| 449 | cmd.op = GRTEXTOP_PUTS; |
| 450 | cmd.x = (int16_t)x; |
| 451 | cmd.y = (int16_t)y; |
| 452 | |
| 453 | ASSERT((Grtext_ptr + sizeof(cmd) + strlen(str) + 1) < GRTEXT_BUFLEN); |
| 454 | |
| 455 | cmd.op = GRTEXTOP_PUTS; |
| 456 | cmd.x = (int16_t)x; |
| 457 | cmd.y = (int16_t)y; |
| 458 | memcpy(&Grtext_buffer[Grtext_ptr], &cmd, sizeof(cmd)); |
| 459 | Grtext_ptr += sizeof(cmd); |
| 460 | strcpy(&Grtext_buffer[Grtext_ptr], str); |
| 461 | |
| 462 | if (grtext_FilterProfanity) { |
| 463 | // DAJ changed to local to reduce memory thrashing |
| 464 | // DAJ char *lowerstr = (char *)mem_malloc(strlen(str)+1); |
| 465 | char lowerstr[GR_STR_LEN]; |
| 466 | |
| 467 | int slen = strlen(str); |
| 468 | if (slen >= GR_STR_LEN) |
| 469 | slen = GR_STR_LEN - 1; |
| 470 | |
| 471 | for (int a = 0; a < slen; a++) |
| 472 | lowerstr[a] = tolower(str[a]); |
| 473 | |
| 474 | lowerstr[slen] = '\0'; |
| 475 | |
| 476 | for (auto & bad_word : bad_words) { |
| 477 | char *p = strstr(lowerstr, (char *)bad_word); |
| 478 | while (p) { |
| 479 | int len = strlen((char *)bad_word); |
| 480 | char *realp = (char *)((int)(p - lowerstr) + &Grtext_buffer[Grtext_ptr]); |
| 481 | for (int a = 0; a < len; a++) { |
| 482 | ASSERT(p); |
| 483 | *realp = subst_chars[(*realp) % NUM_SUBST_CHARS]; |
| 484 | *p = *realp; |
| 485 | realp++; |
| 486 | } |
| 487 | p = strstr(lowerstr, (char *)bad_word); |
| 488 | }; |
| 489 | } |
| 490 | // DAJ mem_free(lowerstr); |
| 491 | } |
| 492 | |
| 493 | Grtext_ptr += (strlen(str) + 1); |
| 494 | } |
| 495 | |
| 496 | // puts a character down |
| 497 | void grtext_PutChar(int x, int y, int ch) { |
no outgoing calls
no test coverage detected