From ed242b32dfa74fea511a49d69bddfa0503ecf4af Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 7 Jan 2008 22:07:25 +0000 Subject: [PATCH] - Fixed: translationtables cannot use a TAutoGrowArray because it doesn't initialize newly added fields when growing. SVN r675 (trunk) --- docs/rh-log.txt | 2 ++ src/g_level.cpp | 6 ++++-- src/p_acs.cpp | 6 ++++-- src/r_translate.cpp | 4 ++-- src/r_translate.h | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 14d5bb6961..f84da4e1f4 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,6 @@ January 7, 2008 (Changes by Graf Zahl) +- Fixed: translationtables cannot use a TAutoGrowArray because it doesn't + initialize newly added fields when growing. - Added fix for Heretic IDKFA cheat by Karate Chris. - Added fix for Strife's AlienSpectre obituary by Karate Chris. diff --git a/src/g_level.cpp b/src/g_level.cpp index e30590d436..623847d861 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -2719,17 +2719,19 @@ void G_SerializeLevel (FArchive &arc, bool hubLoad) } else { + TArray &tt = translationtables[TRANSLATION_LevelScripted]; while (arc << w, w != 0xffff) { if (w >= MAX_ACS_TRANSLATIONS) { // hack hack to avoid crashing w = 0; } - trans = translationtables[TRANSLATION_LevelScripted].GetVal(w); + while (tt.Size() <= w) tt.Push(NULL); + trans = tt[w]; if (trans == NULL) { trans = new FRemapTable; - translationtables[TRANSLATION_LevelScripted].SetVal(t, trans); + tt[w] = trans; } trans->Serialize(arc); } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 40ed4629a3..513199782b 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4675,11 +4675,13 @@ int DLevelScript::RunScript () sp--; if (i >= 1 && i <= MAX_ACS_TRANSLATIONS) { - translation = translationtables[TRANSLATION_LevelScripted].GetVal(i - 1); + TArray &tt = translationtables[TRANSLATION_LevelScripted]; + while (tt.Size() < i) tt.Push(NULL); + translation = tt[i-1]; if (translation == NULL) { translation = new FRemapTable; - translationtables[TRANSLATION_LevelScripted].SetVal(i - 1, translation); + tt[i-1] = translation; } translation->MakeIdentity(); } diff --git a/src/r_translate.cpp b/src/r_translate.cpp index e3db077219..fd0bc659f1 100644 --- a/src/r_translate.cpp +++ b/src/r_translate.cpp @@ -44,7 +44,7 @@ #include "gi.h" #include "stats.h" -TAutoGrowArray translationtables[NUM_TRANSLATION_TABLES]; +TArray translationtables[NUM_TRANSLATION_TABLES]; /****************************************************/ /****************************************************/ @@ -281,7 +281,7 @@ FRemapTable *TranslationToTable(int translation) { unsigned int type = GetTranslationType(translation); unsigned int index = GetTranslationIndex(translation); - TAutoGrowArray *slots; + TArray *slots; if (type <= 0 || type >= NUM_TRANSLATION_TABLES) { diff --git a/src/r_translate.h b/src/r_translate.h index 1368aec500..a621d7ace2 100644 --- a/src/r_translate.h +++ b/src/r_translate.h @@ -49,7 +49,7 @@ private: void Alloc(int count); }; -extern TAutoGrowArray translationtables[NUM_TRANSLATION_TABLES]; +extern TArray translationtables[NUM_TRANSLATION_TABLES]; #define TRANSLATION_SHIFT 16 #define TRANSLATION_MASK ((1<