From 297e8450d80411d81f0aaeee642053354125bd6d Mon Sep 17 00:00:00 2001 From: fusion32 Date: Thu, 22 May 2025 11:40:04 -0300 Subject: implement TWriteScriptFile --- reference/game.c | 385 ------------------------------------------------------- 1 file changed, 385 deletions(-) (limited to 'reference/game.c') diff --git a/reference/game.c b/reference/game.c index 1affc5c..975bc84 100644 --- a/reference/game.c +++ b/reference/game.c @@ -3594,391 +3594,6 @@ LAB_0804eb1e: return; } -// DWARF original prototype: void TWriteScriptFile(TWriteScriptFile * this) - -void __thiscall TWriteScriptFile::TWriteScriptFile(TWriteScriptFile *this) - -{ - this->File = (FILE *)0x0; - return; -} - - - -// DWARF original prototype: void TWriteScriptFile(TWriteScriptFile * this) - -void __thiscall TWriteScriptFile::TWriteScriptFile(TWriteScriptFile *this) - -{ - this->File = (FILE *)0x0; - return; -} - - - -// DWARF original prototype: void ~TWriteScriptFile(TWriteScriptFile * this, int __in_chrg) - -void __thiscall TWriteScriptFile::~TWriteScriptFile(TWriteScriptFile *this,int __in_chrg) - -{ - char *pcVar1; - int iVar2; - int *piVar3; - - if (this->File != (FILE *)0x0) { - pcVar1 = ""; - if (this != (TWriteScriptFile *)0xfffffffc) { - pcVar1 = this->Filename; - } - ::error("TWriteScriptFile::~TWriteScriptFile: Datei %s ist noch offen.\n",pcVar1); - iVar2 = fclose((FILE *)this->File); - if (iVar2 != 0) { - piVar3 = __errno_location(); - ::error(&DAT_080ef6e0,*piVar3); - } - } - return; -} - - - -// DWARF original prototype: void ~TWriteScriptFile(TWriteScriptFile * this, int __in_chrg) - -void __thiscall TWriteScriptFile::~TWriteScriptFile(TWriteScriptFile *this,int __in_chrg) - -{ - char *pcVar1; - int iVar2; - int *piVar3; - - if (this->File != (FILE *)0x0) { - pcVar1 = ""; - if (this != (TWriteScriptFile *)0xfffffffc) { - pcVar1 = this->Filename; - } - ::error("TWriteScriptFile::~TWriteScriptFile: Datei %s ist noch offen.\n",pcVar1); - iVar2 = fclose((FILE *)this->File); - if (iVar2 != 0) { - piVar3 = __errno_location(); - ::error(&DAT_080ef6e0,*piVar3); - } - } - return; -} - - - -// DWARF original prototype: void open(TWriteScriptFile * this, char * FileName) - -int __thiscall TWriteScriptFile::open(TWriteScriptFile *this,char *__file,int __oflag,...) - -{ - FILE *pFVar1; - char *pcVar2; - int *piVar3; - undefined4 *puVar4; - int iVar5; - - if (this->File != (FILE *)0x0) { - ::error("TWriteScriptFile::open: Altes Skript ist noch offen.\n"); - iVar5 = fclose((FILE *)this->File); - if (iVar5 != 0) { - piVar3 = __errno_location(); - ::error(&DAT_080ef7c0,*piVar3); - } - this->File = (FILE *)0x0; - } - pFVar1 = fopen(__file,"wb"); - this->File = (FILE *)pFVar1; - if (pFVar1 != (FILE *)0x0) { - this->Line = 0; - pcVar2 = strcpy(this->Filename,__file); - return (int)pcVar2; - } - piVar3 = __errno_location(); - iVar5 = *piVar3; - // try { // try from 08050063 to 080500eb has its CatchHandler @ 080500f0 - ::error("TWriteScriptFile: Kann Datei %s nicht anlegen.\n",__file); - pcVar2 = strerror(iVar5); - ::error("Fehler %d: %s.\n",iVar5,pcVar2); - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "Cannot create script-file"; - // WARNING: Subroutine does not return - __cxa_throw(puVar4,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: void close(TWriteScriptFile * this) - -int __thiscall TWriteScriptFile::close(TWriteScriptFile *this,int __fd) - -{ - int iVar1; - int *piVar2; - FILE *__stream; - - __stream = (FILE *)this->File; - if (__stream != (FILE *)0x0) { - iVar1 = fclose(__stream); - if (iVar1 != 0) { - piVar2 = __errno_location(); - iVar1 = *piVar2; - ::error(&DAT_080ef800,iVar1); - } - this->File = (FILE *)0x0; - return iVar1; - } - ::error("TWriteScriptFile::close: Kein Skript offen.\n"); - return (int)__stream; -} - - - -// DWARF original prototype: void error(TWriteScriptFile * this, char * Text) - -void __thiscall TWriteScriptFile::error(TWriteScriptFile *this,char *Text) - -{ - int iVar1; - int *piVar2; - undefined4 *puVar3; - - if ((FILE *)this->File != (FILE *)0x0) { - iVar1 = fclose((FILE *)this->File); - if (iVar1 != 0) { - piVar2 = __errno_location(); - // try { // try from 080501b0 to 08050223 has its CatchHandler @ 08050224 - ::error(&DAT_080ef880,*piVar2); - } - } - this->File = (FILE *)0x0; - snprintf(ErrorString,100,"error in script-file \"%s\", line %d: %s",this->Filename,this->Line, - Text); - puVar3 = (undefined4 *)__cxa_allocate_exception(4); - *puVar3 = ErrorString; - // WARNING: Subroutine does not return - __cxa_throw(puVar3,char*::typeinfo,0); -} - - - -// DWARF original prototype: void writeLn(TWriteScriptFile * this) - -void __thiscall TWriteScriptFile::writeLn(TWriteScriptFile *this) - -{ - undefined4 *puVar1; - - if ((FILE *)this->File != (FILE *)0x0) { - putc(10,(FILE *)this->File); - return; - } - // try { // try from 0805026a to 08050298 has its CatchHandler @ 08050299 - ::error(&DAT_080ef8c0); - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "Cannot write linefeed"; - // WARNING: Subroutine does not return - __cxa_throw(puVar1,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: void writeText(TWriteScriptFile * this, char * Text) - -void __thiscall TWriteScriptFile::writeText(TWriteScriptFile *this,char *Text) - -{ - char cVar1; - undefined4 *puVar2; - FILE *__stream; - char *Text_00; - - __stream = (FILE *)this->File; - if (__stream == (FILE *)0x0) { - Text_00 = &DAT_080ef940; - } - else { - if (Text != (char *)0x0) { - cVar1 = *Text; - if (cVar1 != '\0') { - while( true ) { - Text = Text + 1; - putc((int)cVar1,__stream); - cVar1 = *Text; - if (cVar1 == '\0') break; - __stream = (FILE *)this->File; - } - } - return; - } - Text_00 = "TWriteScriptFile::writeText: Text ist NULL.\n"; - } - // try { // try from 080502fe to 0805032c has its CatchHandler @ 08050336 - ::error(Text_00); - puVar2 = (undefined4 *)__cxa_allocate_exception(4); - *puVar2 = "Cannot write text"; - // WARNING: Subroutine does not return - __cxa_throw(puVar2,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: void writeString(TWriteScriptFile * this, char * Text) - -void __thiscall TWriteScriptFile::writeString(TWriteScriptFile *this,char *Text) - -{ - undefined4 *puVar1; - char cVar2; - char *Text_00; - - if ((FILE *)this->File == (FILE *)0x0) { - Text_00 = &DAT_080ef9e0; - } - else { - if (Text != (char *)0x0) { - putc(0x22,(FILE *)this->File); - cVar2 = *Text; - while (cVar2 != '\0') { - if ((cVar2 == '\"') || (cVar2 == '\\')) { - putc(0x5c,(FILE *)this->File); - cVar2 = *Text; - } - if (cVar2 == '\n') { - putc(0x5c,(FILE *)this->File); - putc(0x6e,(FILE *)this->File); - } - else { - putc((int)cVar2,(FILE *)this->File); - } - Text = Text + 1; - cVar2 = *Text; - } - putc(0x22,(FILE *)this->File); - return; - } - Text_00 = "TWriteScriptFile::writeString: Text ist NULL.\n"; - } - // try { // try from 08050416 to 08050444 has its CatchHandler @ 0805044e - ::error(Text_00); - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "Cannot write string"; - // WARNING: Subroutine does not return - __cxa_throw(puVar1,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: void writeNumber(TWriteScriptFile * this, int Number) - -void __thiscall TWriteScriptFile::writeNumber(TWriteScriptFile *this,int Number) - -{ - undefined4 *puVar1; - char local_2c [4]; - char s [20]; - - if (this->File != (FILE *)0x0) { - sprintf(local_2c,"%d",Number); - // try { // try from 080504a6 to 080504ea has its CatchHandler @ 080504f0 - writeText(this,local_2c); - return; - } - ::error(&DAT_080efa40); - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "Cannot write number"; - // WARNING: Subroutine does not return - __cxa_throw(puVar1,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: void writeBytesequence(TWriteScriptFile * this, uchar * Sequence, int -// Length) - -void __thiscall -TWriteScriptFile::writeBytesequence(TWriteScriptFile *this,uchar *Sequence,int Length) - -{ - undefined4 *puVar1; - int i; - int iVar2; - char *Text; - char local_3c [4]; - char s [20]; - - if (this->File == (FILE *)0x0) { - Text = &DAT_080efb20; - } - else if (Sequence == (uchar *)0x0) { - Text = "TWriteScriptFile::writeBytesequence: Sequence ist NULL.\n"; - } - else { - if (0 < Length) { - iVar2 = 0; - if (0 < Length) { - do { - if (iVar2 != 0) { - // try { // try from 080505de to 0805061d has its CatchHandler @ 08050648 - writeText(this,"-"); - } - if (this->File == (FILE *)0x0) { - ::error(&DAT_080efa40); - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "Cannot write number"; - // WARNING: Subroutine does not return - __cxa_throw(puVar1,char_const*::typeinfo,0); - } - sprintf(local_3c,"%d",(uint)Sequence[iVar2]); - // try { // try from 0805057c to 080505d2 has its CatchHandler @ 08050630 - writeText(this,local_3c); - iVar2 = iVar2 + 1; - } while (iVar2 < Length); - } - return; - } - Text = &DAT_080efaa0; - } - ::error(Text); - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "Cannot write bytesequence"; - // WARNING: Subroutine does not return - __cxa_throw(puVar1,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: void writeCoordinate(TWriteScriptFile * this, int x, int y, int z) - -void __thiscall TWriteScriptFile::writeCoordinate(TWriteScriptFile *this,int x,int y,int z) - -{ - undefined4 *puVar1; - char local_2c [4]; - char s [20]; - - if (this->File == (FILE *)0x0) { - ::error(&DAT_080efbe0); - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "Cannot write coordinate"; - } - else { - if (((-1 < x) && (-1 < y)) && (-1 < z)) { - sprintf(local_2c,"[%u,%u,%u]",x,y,z); - // try { // try from 080506b4 to 08050710 has its CatchHandler @ 08050725 - writeText(this,local_2c); - return; - } - ::error(&DAT_080efb80,x,y,z); - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "Invalid coordinates"; - } - // WARNING: Subroutine does not return - __cxa_throw(puVar1,char_const*::typeinfo,0); -} - - // DWARF original prototype: void TReadBinaryFile(TReadBinaryFile * this) -- cgit v1.2.3