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

Function grtext_Puts

grtext/grtext.cpp:441–494  ·  view source on GitHub ↗

draws a string

Source from the content-addressed store, hash-verified

439#define GR_STR_LEN 128
440// draws a string
441void 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
497void grtext_PutChar(int x, int y, int ch) {

Callers 14

FontKernFunction · 0.85
FontCreateFunction · 0.85
FontViewFunction · 0.85
ui_DrawStringFunction · 0.85
RenderHUDTextFlagsFunction · 0.85
InitMessageFunction · 0.85
DoWaitMessageFunction · 0.85
RenderSmallWindowFunction · 0.85
RenderHUDInputMessageFunction · 0.85
DrawMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected