fixed CText to be 64 bit compatible

This commit is contained in:
aap 2020-05-16 12:51:54 +02:00
parent 81e711517d
commit 9558baa353
2 changed files with 24 additions and 0 deletions

View File

@ -97,7 +97,11 @@ CText::Unload(void)
wchar* wchar*
CText::Get(const char *key) CText::Get(const char *key)
{ {
#ifdef FIX_BUGS
return keyArray.Search(key, data.chars);
#else
return keyArray.Search(key); return keyArray.Search(key);
#endif
} }
wchar UpperCaseTable[128] = { wchar UpperCaseTable[128] = {
@ -196,9 +200,11 @@ CKeyArray::Unload(void)
void void
CKeyArray::Update(wchar *chars) CKeyArray::Update(wchar *chars)
{ {
#ifndef FIX_BUGS
int i; int i;
for(i = 0; i < numEntries; i++) for(i = 0; i < numEntries; i++)
entries[i].value = (wchar*)((uint8*)chars + (uintptr)entries[i].value); entries[i].value = (wchar*)((uint8*)chars + (uintptr)entries[i].value);
#endif
} }
CKeyEntry* CKeyEntry*
@ -222,15 +228,25 @@ CKeyArray::BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 hi
} }
wchar* wchar*
#ifdef FIX_BUGS
CKeyArray::Search(const char *key, wchar *data)
#else
CKeyArray::Search(const char *key) CKeyArray::Search(const char *key)
#endif
{ {
CKeyEntry *found; CKeyEntry *found;
char errstr[25]; char errstr[25];
int i; int i;
#ifdef FIX_BUGS
found = BinarySearch(key, entries, 0, numEntries-1);
if(found)
return (wchar*)((uint8*)data + found->valueOffset);
#else
found = BinarySearch(key, entries, 0, numEntries-1); found = BinarySearch(key, entries, 0, numEntries-1);
if(found) if(found)
return found->value; return found->value;
#endif
sprintf(errstr, "%s missing", key); sprintf(errstr, "%s missing", key);
for(i = 0; i < 25; i++) for(i = 0; i < 25; i++)
WideErrorString[i] = errstr[i]; WideErrorString[i] = errstr[i];

View File

@ -9,7 +9,11 @@ void TextCopy(wchar *dst, const wchar *src);
struct CKeyEntry struct CKeyEntry
{ {
#ifdef FIX_BUGS
uint32 valueOffset;
#else
wchar *value; wchar *value;
#endif
char key[8]; char key[8];
}; };
@ -28,7 +32,11 @@ public:
void Unload(void); void Unload(void);
void Update(wchar *chars); void Update(wchar *chars);
CKeyEntry *BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 high); CKeyEntry *BinarySearch(const char *key, CKeyEntry *entries, int16 low, int16 high);
#ifdef FIX_BUGS
wchar *Search(const char *key, wchar *data);
#else
wchar *Search(const char *key); wchar *Search(const char *key);
#endif
}; };
class CData class CData