mirror of
https://github.com/dhewm/dhewm3-sdk.git
synced 2025-02-16 17:11:24 +00:00
Mirroring the idLangDict changes made to the Engine for this mod
I don't think this code is really used (the string table seems to be parsed in the engine), but better safe than sorry etc
This commit is contained in:
parent
4dd8a97f73
commit
6cd666e1a3
1 changed files with 18 additions and 3 deletions
|
@ -100,8 +100,11 @@ bool idLangDict::Load( const char *fileName, bool clear /* _D3XP */ ) {
|
|||
idLangKeyValue kv;
|
||||
kv.key = tok;
|
||||
kv.value = tok2;
|
||||
assert( kv.key.Cmpn( STRTABLE_ID, STRTABLE_ID_LENGTH ) == 0 );
|
||||
hash.Add( GetHashKey( kv.key ), args.Append( kv ) );
|
||||
// DG: D3LE has #font_ entries in english.lang, maybe from D3BFG? not supported here, just skip them
|
||||
if(kv.key.Cmpn("#font_", 6) != 0) {
|
||||
assert( kv.key.Cmpn( STRTABLE_ID, STRTABLE_ID_LENGTH ) == 0 );
|
||||
hash.Add( GetHashKey( kv.key ), args.Append( kv ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
idLib::common->Printf( "%i strings read from %s\n", args.Num(), fileName );
|
||||
|
@ -303,8 +306,20 @@ idLangDict::GetHashKey
|
|||
*/
|
||||
int idLangDict::GetHashKey( const char *str ) const {
|
||||
int hashKey = 0;
|
||||
// DG: Replace assertion for invalid entries with a warning that's shown only once
|
||||
// (for D3LE mod that seems to have lots of entries like #str_adil_exis_pda_01_audio_info)
|
||||
const char* strbk = str;
|
||||
static bool warnedAboutInvalidKey = false;
|
||||
for ( str += STRTABLE_ID_LENGTH; str[0] != '\0'; str++ ) {
|
||||
assert( str[0] >= '0' && str[0] <= '9' );
|
||||
// assert( str[0] >= '0' && str[0] <= '9' );
|
||||
if(!warnedAboutInvalidKey && (str[0] < '0' || str[0] > '9')) {
|
||||
// The "hash" code here very obviously expects numbers, but apparently it still somehow works,
|
||||
// so just warn about it and otherwise accept those entries, seems to work for D3LE?
|
||||
idLib::common->Warning( "We have at least one invalid key in a language dict: %s\n"
|
||||
" (might still work, but Doom3 really wants #str_01234, i.e. only a number after '#str_')\n", strbk );
|
||||
warnedAboutInvalidKey = true;
|
||||
}
|
||||
// DG end
|
||||
hashKey = hashKey * 10 + str[0] - '0';
|
||||
}
|
||||
return hashKey;
|
||||
|
|
Loading…
Reference in a new issue