From 03cb2be1e63e7ad582a50e1046c3c03f998d9a5d Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Tue, 5 Nov 2024 23:34:01 +0200 Subject: [PATCH] game: add 'g_language' localization cvar --- README.md | 2 +- doc/040_cvarlist.md | 4 ++++ src/game/g_main.c | 1 + src/game/g_translate.c | 4 +++- src/game/header/local.h | 1 + src/game/savegame/savegame.c | 1 + 6 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6519bf2e..d2fdc3b8 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ Maps support: Note: -* Non Quake 2 maps are limmited mostly view only, and could have issues +* Non Quake 2 maps are limited mostly view only, and could have issues with tranparency or some animations flags and properties. * If you like support some other maps type, create pull request for Mod_Load2QBSP function and provide a link to demo maps. diff --git a/doc/040_cvarlist.md b/doc/040_cvarlist.md index d70c5c2e..4fb735c5 100644 --- a/doc/040_cvarlist.md +++ b/doc/040_cvarlist.md @@ -249,6 +249,10 @@ it's `+set busywait 0` (setting the `busywait` cvar) and `-portable` By default this cvar is set to `1`, and will only work if the game.dll implements this behaviour. +* **g_language**: Default language for ReRelease game, requires `Q2Game.kpf` + or other source of `localization/loc_english.txt` like file. + Defaults to `english`. + * **g_swap_speed**: Sets the speed of the "changing weapon" animation. Default is `1`. If set to `2`, it will be double the speed, `3` is the triple... up until the max of `8`, since there are at least 2 diff --git a/src/game/g_main.c b/src/game/g_main.c index 8ed7c994..d3cab5ce 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -102,6 +102,7 @@ cvar_t *aimfix; cvar_t *g_machinegun_norecoil; cvar_t *g_quick_weap; cvar_t *g_swap_speed; +cvar_t *g_language; static void G_RunFrame(void); diff --git a/src/game/g_translate.c b/src/game/g_translate.c index 37d2a8a2..f06a87ed 100644 --- a/src/game/g_translate.c +++ b/src/game/g_translate.c @@ -53,12 +53,14 @@ LocalizationInit(void) byte *raw = NULL; char *buf_local = NULL, *buf_level = NULL; int len_local, len_level, curr_pos; + char loc_name[MAX_QPATH]; localmessages = NULL; nlocalmessages = 0; + snprintf(loc_name, sizeof(loc_name) - 1, "localization/loc_%s.txt", g_language->string); /* load the localization file */ - len_local = gi.FS_LoadFile("localization/loc_english.txt", (void **)&raw); + len_local = gi.FS_LoadFile(loc_name, (void **)&raw); if (len_local > 1) { buf_local = malloc(len_local + 1); diff --git a/src/game/header/local.h b/src/game/header/local.h index b0134bb3..acdedb0f 100644 --- a/src/game/header/local.h +++ b/src/game/header/local.h @@ -679,6 +679,7 @@ extern cvar_t *aimfix; extern cvar_t *g_machinegun_norecoil; extern cvar_t *g_quick_weap; extern cvar_t *g_swap_speed; +extern cvar_t *g_language; /* this is for the count of monsters */ #define ENT_SLOTS_LEFT \ diff --git a/src/game/savegame/savegame.c b/src/game/savegame/savegame.c index e4208c5c..ab295732 100644 --- a/src/game/savegame/savegame.c +++ b/src/game/savegame/savegame.c @@ -263,6 +263,7 @@ InitGame(void) g_machinegun_norecoil = gi.cvar("g_machinegun_norecoil", "0", CVAR_ARCHIVE); g_quick_weap = gi.cvar("g_quick_weap", "1", CVAR_ARCHIVE); g_swap_speed = gi.cvar("g_swap_speed", "1", CVAR_ARCHIVE); + g_language = gi.cvar("g_language", "english", CVAR_ARCHIVE); /* initilize localization */ LocalizationInit();