Skip to content

Commit

Permalink
Clean up arena, vs, and newsroom stripping
Browse files Browse the repository at this point in the history
  • Loading branch information
Nopey committed Nov 5, 2024
1 parent e284afe commit 59a33b4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 31 deletions.
8 changes: 3 additions & 5 deletions src/game/scenes/arena.c
Original file line number Diff line number Diff line change
Expand Up @@ -1149,11 +1149,9 @@ void arena_render_overlay(scene *scene) {

if(player[1]->pilot) {
// when quitting, this can go null
int p2len = (strlen(player2_name) - 1) * font_small.w;
// XXX TODO: Magnus: Hardcoded - 1 for trailing newlines in localization strings
int h2len = (strlen(lang_get_offset(LangRobot, player[1]->pilot->har_id)) - 1) * font_small.w;
text_render(&tconf_players, TEXT_DEFAULT, 315 - p2len, 19, 100, 6, player2_name);
text_render(&tconf_players, TEXT_DEFAULT, 315 - h2len, 26, 100, 6,
tconf_players.halign = TEXT_RIGHT;
text_render(&tconf_players, TEXT_DEFAULT, 215, 19, 100, 6, player2_name);
text_render(&tconf_players, TEXT_DEFAULT, 215, 26, 100, 6,
lang_get_offset(LangRobot, player[1]->pilot->har_id));
}

Expand Down
30 changes: 9 additions & 21 deletions src/game/scenes/newsroom.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,6 @@ const char *subject_pronoun(int sex) {
return lang_get_offset(LangPronoun, 4 + sex);
}

char const *pronoun_strip(char const *pronoun, char *buf, size_t buf_size) {
size_t pronoun_len = strlen(pronoun);
while(pronoun_len && pronoun[pronoun_len - 1] == '\n') {
pronoun_len--;
}
if(pronoun_len >= buf_size)
pronoun_len = buf_size - 1;
memcpy(buf, pronoun, pronoun_len);
buf[pronoun_len] = '\0';
return buf;
}

static void newsroom_fixup_capitalization(str *tmp) {
// XXX non-const str_c variant?
char *it = (char *)str_c(tmp);
Expand Down Expand Up @@ -99,18 +87,17 @@ void newsroom_fixup_str(newsroom_local *local) {
raw_translation = lang_get_offset(LangNewsroomReport, local->news_id + min2(local->screen, 1));
}

char scratch[9];
str tmp;
str_from_c(&tmp, raw_translation);
str_replace(&tmp, "~11", pronoun_strip(subject_pronoun(local->sex2), scratch, sizeof scratch), -1);
str_replace(&tmp, "~10", pronoun_strip(object_pronoun(local->sex2), scratch, sizeof scratch), -1);
str_replace(&tmp, "~9", pronoun_strip(possessive_pronoun(local->sex2), scratch, sizeof scratch), -1);
str_replace(&tmp, "~8", pronoun_strip(subject_pronoun(local->sex1), scratch, sizeof scratch), -1);
str_replace(&tmp, "~7", pronoun_strip(object_pronoun(local->sex1), scratch, sizeof scratch), -1);
str_replace(&tmp, "~6", pronoun_strip(possessive_pronoun(local->sex1), scratch, sizeof scratch), -1);
str_replace(&tmp, "~11", subject_pronoun(local->sex2), -1);
str_replace(&tmp, "~10", object_pronoun(local->sex2), -1);
str_replace(&tmp, "~9", possessive_pronoun(local->sex2), -1);
str_replace(&tmp, "~8", subject_pronoun(local->sex1), -1);
str_replace(&tmp, "~7", object_pronoun(local->sex1), -1);
str_replace(&tmp, "~6", possessive_pronoun(local->sex1), -1);
str_replace(&tmp, "~5", "Stadium", -1);
str_replace(&tmp, "~4", pronoun_strip(lang_get_offset(LangRobot, local->har2), scratch, sizeof scratch), -1);
str_replace(&tmp, "~3", pronoun_strip(lang_get_offset(LangRobot, local->har1), scratch, sizeof scratch), -1);
str_replace(&tmp, "~4", lang_get_offset(LangRobot, local->har2), -1);
str_replace(&tmp, "~3", lang_get_offset(LangRobot, local->har1), -1);
str_replace(&tmp, "~2", str_c(&local->pilot2), -1);
str_replace(&tmp, "~1", str_c(&local->pilot1), -1);

Expand All @@ -123,6 +110,7 @@ void newsroom_fixup_str(newsroom_local *local) {
void newsroom_set_names(newsroom_local *local, const char *pilot1, const char *pilot2, int har1, int har2, int sex1,
int sex2) {

// XXX TODO: Magnus: put pilot names in title case
str_from_c(&local->pilot1, pilot1);
str_from_c(&local->pilot2, pilot2);
local->har1 = har1;
Expand Down
7 changes: 2 additions & 5 deletions src/game/scenes/vs.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,8 @@ int vs_create(scene *scene) {
} else {
const char *pilot1 = lang_get_offset(LangPilot, player1->pilot->pilot_id);
const char *pilot2 = lang_get_offset(LangPilot, player2->pilot->pilot_id);
// XXX TODO: Magnus: hardcoded -1's to compensate for OMF 2097 lang trailing newlines
snprintf(local->vs_str, 128, "%*.*s VS. %*.*s", (int)strlen(pilot1) - 1, (int)strlen(pilot1) - 1, pilot1,
(int)strlen(pilot2) - 1, (int)strlen(pilot2) - 1, pilot2);
snprintf(local->vs_str, 128, "%*.*s VS. %*.*s", (int)strlen(pilot1), (int)strlen(pilot1), pilot1,
(int)strlen(pilot2), (int)strlen(pilot2), pilot2);
}

// Set player palettes
Expand Down Expand Up @@ -649,8 +648,6 @@ int vs_create(scene *scene) {
str_from_c(&insult, lang_get(LangTooPatheticDialog));
str_replace(&insult, "%s", lang_get_offset(LangCpuDifficulty, VETERAN), 1);
str_replace(&insult, "%s", lang_get_offset(LangPilot, PILOT_KREISSACK), 1);
// XXX HACK: Remove newline after kreissack's name until we clean up our string tables
str_replace(&insult, "\n.", ".", -1);
dialog_create(&local->too_pathetic_dialog, DIALOG_STYLE_OK, str_c(&insult), 40, 40);
str_free(&insult);
local->too_pathetic_dialog.userdata = scene;
Expand Down

0 comments on commit 59a33b4

Please sign in to comment.