From e5b60ae075e571a29868993a5f0d191d91f8d266 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Thu, 29 May 2025 00:04:19 -0300 Subject: impl `strings.cc` --- reference/game.c | 355 ------------------------------------------------------- 1 file changed, 355 deletions(-) (limited to 'reference/game.c') diff --git a/reference/game.c b/reference/game.c index dff762d..e8bb7cd 100644 --- a/reference/game.c +++ b/reference/game.c @@ -2667,339 +2667,6 @@ void __static_initialization_and_destruction_0(int __initialize_p,int __priority return; } - - -// WARNING: Variable defined which should be unmapped: p - -char * AddStaticString(char *String) - -{ - size_t sVar1; - char *__dest; - listnode<> *plVar2; - TStaticStringTableBlock *pTVar3; - listIterator<> iter; - TStaticStringTableBlock *local_18; - char *p; - - sVar1 = strlen(String); - if ((int)sVar1 < 0x10000) { - __dest = ""; - if (sVar1 != 0) { - for (plVar2 = StaticStringTable.firstNode; plVar2 != (listnode<> *)0x0; - plVar2 = plVar2->next) { - if ((int)(sVar1 + 1) < 0x10000 - (plVar2->data).TotalTextLength) { - if (plVar2 != (listnode<> *)0x0) goto LAB_0805197a; - break; - } - } - plVar2 = list<>::append(&StaticStringTable); - if (plVar2 == (listnode<> *)0x0) { - error("listIterator::operator*: Iterator ist NULL.\n"); - pTVar3 = (TStaticStringTableBlock *)0x0; - } - else { - pTVar3 = &plVar2->data; - } - pTVar3->TotalTextLength = 0; - if (plVar2 == (listnode<> *)0x0) { - error("listIterator::operator*: Iterator ist NULL.\n"); - local_18 = (TStaticStringTableBlock *)0x0; - } - else { -LAB_0805197a: - local_18 = &plVar2->data; - } - if (plVar2 == (listnode<> *)0x0) { - error("listIterator::operator*: Iterator ist NULL.\n"); - pTVar3 = (TStaticStringTableBlock *)0x0; - } - else { - pTVar3 = &plVar2->data; - } - __dest = local_18->Text + pTVar3->TotalTextLength; - memcpy(__dest,String,sVar1 + 1); - if (plVar2 == (listnode<> *)0x0) { - error("listIterator::operator*: Iterator ist NULL.\n"); - pTVar3 = (TStaticStringTableBlock *)0x0; - } - else { - pTVar3 = &plVar2->data; - } - pTVar3->TotalTextLength = sVar1 + pTVar3->TotalTextLength + 1; - } - } - else { - error("AddStaticString: String zu lang (%d).\n",sVar1); - __dest = (char *)0x0; - } - return __dest; -} - - - -// WARNING: Variable defined which should be unmapped: iter - -ulong AddDynamicString(char *String) - -{ - int iVar1; - int i_1; - size_t sVar2; - int i; - int iVar3; - TDynamicStringTableBlock *pTVar4; - int pos; - int iVar5; - int local_18; - int count; - listIterator<> iter; - - sVar2 = strlen(String); - if ((int)sVar2 < 0x8000) { - if (sVar2 == 0) { - return 0; - } - local_18 = 0; - count = (int)DynamicStringTable.firstNode; - while ((listnode<> *)count != (listnode<> *)0x0) { - if (0 < (((listnode<> *)count)->data).FreeEntries) { - if ((listnode<> *)count == (listnode<> *)0x0) { - error("listIterator::operator*: Iterator ist NULL.\n"); - pTVar4 = (TDynamicStringTableBlock *)0x0; - } - else { - pTVar4 = &((listnode<> *)count)->data; - } - if ((int)(sVar2 + 1) < 0x8000 - pTVar4->TotalTextLength) { - if ((listnode<> *)count != (listnode<> *)0x0) goto LAB_08051ae9; - break; - } - } - if ((listnode<> *)count == (listnode<> *)0x0) { - error("listIterator::operator++: Iterator ist NULL.\n"); - } - else { - count = (int)((listnode<> *)count)->next; - } - local_18 = local_18 + 1; - } - count = (int)list<>::append(&DynamicStringTable); - if ((listnode<> *)count == (listnode<> *)0x0) { - error("listIterator::operator*: Iterator ist NULL.\n"); - pTVar4 = (TDynamicStringTableBlock *)0x0; - } - else { - pTVar4 = &((listnode<> *)count)->data; - } - pTVar4->FreeEntries = 0x100; - iVar3 = 0; - pTVar4->TotalTextLength = 0; - pTVar4->Dirty = false; - do { - pTVar4->EntryType[iVar3] = '\0'; - iVar3 = iVar3 + 1; - } while (iVar3 < 0x100); - if ((listnode<> *)count == (listnode<> *)0x0) { - pTVar4 = (TDynamicStringTableBlock *)0x0; - error("listIterator::operator*: Iterator ist NULL.\n"); - } - else { -LAB_08051ae9: - pTVar4 = &((listnode<> *)count)->data; - } - iVar3 = 0; - do { - iVar5 = iVar3; - if (pTVar4->EntryType[iVar3] == '\0') break; - iVar3 = iVar3 + 1; - iVar5 = -1; - } while (iVar3 < 0x100); - if (iVar5 != -1) { - iVar1 = pTVar4->TotalTextLength; - pTVar4->EntryType[iVar5] = '\x01'; - iVar3 = pTVar4->TotalTextLength; - pTVar4->FreeEntries = pTVar4->FreeEntries + -1; - pTVar4->StringOffset[iVar5] = (ushort)iVar1; - memcpy(pTVar4->Text + iVar3,String,sVar2 + 1); - pTVar4->TotalTextLength = sVar2 + pTVar4->TotalTextLength + 1; - return iVar5 + 1 + local_18 * 0x100; - } - error("AddDynamicString: Keinen freien Platz gefunden.\n"); - } - else { - error("AddDynamicString: String zu lang (%d)\n",sVar2); - } - return 0; -} - - - -// WARNING: Variable defined which should be unmapped: iter - -char * GetDynamicString(ulong Number) - -{ - int count; - int iVar1; - int Block; - uint uVar2; - uint uVar3; - char *Text; - listnode<> *local_10; - listIterator<> iter; - - if (Number == 0) { - return (char *)0x0; - } - uVar2 = Number - 1 >> 8; - iVar1 = 0; - uVar3 = Number - 1 & 0xff; - local_10 = DynamicStringTable.firstNode; - if (uVar2 == 0) { -LAB_08051c50: - if (local_10 != (listnode<> *)0x0) { - if ((local_10->data).EntryType[uVar3] == '\x01') { - return (local_10->data).Text + (local_10->data).StringOffset[uVar3]; - } - Text = &DAT_080f0540; - goto LAB_08051c3a; - } - } - else if (DynamicStringTable.firstNode != (listnode<> *)0x0) { - do { - local_10 = local_10->next; - iVar1 = iVar1 + 1; - if ((int)uVar2 <= iVar1) goto LAB_08051c50; - } while (local_10 != (listnode<> *)0x0); - } - Text = &DAT_080f0500; -LAB_08051c3a: - error(Text,Number); - return (char *)0x0; -} - - - -// WARNING: Variable defined which should be unmapped: iter - -void DeleteDynamicString(ulong Number) - -{ - int count; - int iVar1; - int Block; - uint uVar2; - uint uVar3; - char *Text; - listnode<> *local_10; - listIterator<> iter; - - if (Number == 0) { - return; - } - uVar2 = Number - 1 >> 8; - iVar1 = 0; - uVar3 = Number - 1 & 0xff; - local_10 = DynamicStringTable.firstNode; - if (uVar2 == 0) { -LAB_08051ce0: - if (local_10 != (listnode<> *)0x0) { - if ((local_10->data).EntryType[uVar3] == '\x01') { - (local_10->data).EntryType[uVar3] = '\x02'; - (local_10->data).Dirty = true; - return; - } - Text = &DAT_080f05c0; - goto LAB_08051cca; - } - } - else if (DynamicStringTable.firstNode != (listnode<> *)0x0) { - do { - local_10 = local_10->next; - iVar1 = iVar1 + 1; - if ((int)uVar2 <= iVar1) goto LAB_08051ce0; - } while (local_10 != (listnode<> *)0x0); - } - Text = &DAT_080f0580; -LAB_08051cca: - error(Text,Number); - return; -} - - - -// WARNING: Variable defined which should be unmapped: iter -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void CleanupDynamicStrings(void) - -{ - int *piVar1; - int iVar2; - char *__s; - ushort uVar3; - int Help; - size_t sVar4; - int j; - int iVar5; - int Offset; - uint uVar6; - int Length; - int local_18; - int i; - listIterator<> iter; - - i = (int)DynamicStringTable.firstNode; - if (DynamicStringTable.firstNode != (listnode<> *)0x0) { - do { - piVar1 = (int *)(i + 8); - if (*(char *)(i + 0x10) != '\0') { - local_18 = 0; - do { - if (*(char *)(local_18 + 9 + (int)piVar1) == '\x02') { - uVar6 = (uint)*(ushort *)(i + 0x112 + local_18 * 2); - __s = (char *)(uVar6 + 0x30a + (int)piVar1); - sVar4 = strlen(__s); - iVar2 = sVar4 + 1; - *(int *)(i + 0xc) = *(int *)(i + 0xc) - iVar2; - *(undefined1 *)(local_18 + 9 + (int)piVar1) = 0; - if ((int)(iVar2 + uVar6) < 0x8001) { - sVar4 = (-iVar2 - uVar6) + 0x8000; - if (0 < (int)sVar4) { - memmove(__s,(void *)(iVar2 + uVar6 + 0x30a + (int)piVar1),sVar4); - } - *piVar1 = *piVar1 + 1; - iVar5 = 0; - do { - if ((*(char *)(iVar5 + 9 + (int)piVar1) != '\0') && - (uVar3 = *(ushort *)(i + 0x112 + iVar5 * 2), uVar6 < uVar3)) { - *(ushort *)(i + 0x112 + iVar5 * 2) = uVar3 - (short)iVar2; - } - iVar5 = iVar5 + 1; - } while (iVar5 < 0x100); - } - else { - error("CleanupDynamicStrings: Stringende fehlt\n"); - } - } - local_18 = local_18 + 1; - } while (local_18 < 0x100); - *(undefined1 *)(i + 0x10) = 0; - } - if (i == 0) { - error("listIterator::operator++: Iterator ist NULL.\n"); - } - else { - i = *(int *)i; - } - } while (i != 0); - } - return; -} - - - bool IsCountable(char *s) { @@ -3809,28 +3476,6 @@ char * Capitals(char *Text) return Text; } - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void InitStrings(void) - -{ - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void ExitStrings(void) - -{ - return; -} - - - void __tcf_0(void *param_1) { -- cgit v1.2.3