From 42be37f4ad99fc8580415fed89939e305d56193e Mon Sep 17 00:00:00 2001 From: fusion32 Date: Tue, 20 May 2025 16:41:03 -0300 Subject: implement `main.cc`, `shm.cc`, and `time.cc` + overall tweeks --- reference/enums.hh | 378 --- reference/game.c | 6789 +++++++++++++++++++--------------------------------- reference/types.hh | 377 +-- 3 files changed, 2522 insertions(+), 5022 deletions(-) (limited to 'reference') diff --git a/reference/enums.hh b/reference/enums.hh index 9e999c4..254781e 100644 --- a/reference/enums.hh +++ b/reference/enums.hh @@ -1,47 +1,4 @@ -enum CreatureType: int { - PLAYER=0, - MONSTER=1, - NPC=2 -}; - -enum CONNECTIONSTATE: int { - CONNECTION_FREE=0, - CONNECTION_ASSIGNED=1, - CONNECTION_CONNECTED=2, - CONNECTION_LOGIN=3, - CONNECTION_GAME=4, - CONNECTION_DEAD=5, - CONNECTION_LOGOUT=6, - CONNECTION_DISCONNECTED=7 -}; - -enum KNOWNCREATURESTATE: int { - KNOWNCREATURE_FREE=0, - KNOWNCREATURE_UPTODATE=1, - KNOWNCREATURE_OUTDATED=2 -}; - -enum ToDoType: int { - TDWait=0, - TDGo=1, - TDRotate=2, - TDMove=3, - TDTrade=4, - TDUse=5, - TDTurn=6, - TDAttack=7, - TDTalk=8, - TDChangeState=9 -}; - -enum GAMESTATE: int { - GAME_STARTING=0, - GAME_RUNNING=1, - GAME_CLOSING=2, - GAME_ENDING=3 -}; - enum STATE: int { SLEEPING=0, IDLE=1, @@ -52,90 +9,6 @@ enum STATE: int { PANIC=6 }; -enum SpellShapeType: int { - SHAPE_ACTOR=0, - SHAPE_VICTIM=1, - SHAPE_ORIGIN=2, - SHAPE_DESTINATION=3, - SHAPE_ANGLE=4 -}; - -enum SpellImpactType: int { - IMPACT_DAMAGE=0, - IMPACT_FIELD=1, - IMPACT_HEALING=2, - IMPACT_SPEED=3, - IMPACT_DRUNKEN=4, - IMPACT_STRENGTH=5, - IMPACT_OUTFIT=6, - IMPACT_SUMMON=7 -}; - -enum RESULT: int { - ERROR=-1, - NOERROR=0, - NOTACCESSIBLE=1, - NOTMOVABLE=2, - NOTTAKABLE=3, - NOROOM=4, - OUTOFRANGE=5, - OUTOFHOME=6, - CANNOTTHROW=7, - TOOHEAVY=8, - CROSSREFERENCE=9, - CONTAINERFULL=10, - WRONGPOSITION=11, - WRONGPOSITION2=12, - WRONGCLOTHES=13, - HANDSNOTFREE=14, - HANDBLOCKED=15, - ONEWEAPONONLY=16, - NOMATCH=17, - NOTCUMULABLE=18, - TOOMANYPARTS=19, - EMPTYCONTAINER=20, - SPLITOBJECT=21, - NOKEYMATCH=22, - UPSTAIRS=23, - DOWNSTAIRS=24, - CREATURENOTEXISTING=25, - PLAYERNOTEXISTING=26, - PLAYERNOTONLINE=27, - NAMEAMBIGUOUS=28, - NOTUSABLE=29, - FEDUP=30, - DESTROYED=31, - SPELLUNKNOWN=32, - LOWMAGICLEVEL=33, - MAGICITEM=34, - NOTENOUGHMANA=35, - NOSKILL=36, - TARGETLOST=37, - OUTOFAMMO=38, - NOCREATURE=39, - TOOLONG=40, - TARGETOUTOFRANGE=41, - TARGETHIDDEN=42, - ATTACKNOTALLOWED=43, - NOWAY=44, - LOGINERROR=45, - LOGINABORT=46, - PROTECTIONZONE=47, - ENTERPROTECTIONZONE=48, - EXHAUSTED=49, - NOTINVITED=50, - NOPREMIUMACCOUNT=51, - MOVENOTPOSSIBLE=52, - ALREADYTRADING=53, - PARTNERTRADING=54, - TOOMANYOBJECTS=55, - TOOMANYSLAVES=56, - NOTTURNABLE=57, - SECUREMODE=58, - NOTENOUGHSOULPOINTS=59, - LOWLEVEL=60 -}; - enum ActionType: int { ACTION_CREATEONMAP=0, ACTION_CREATE=1, @@ -233,140 +106,6 @@ enum INSTANCEATTRIBUTE: int { REMAININGUSES=17 }; -enum TYPEATTRIBUTE: int { - WAYPOINTS=0, - CAPACITY=1, - CHANGETARGET=2, - KEYDOORTARGET=3, - NAMEDOORTARGET=4, - LEVELDOORTARGET=5, - QUESTDOORTARGET=6, - NUTRITION=7, - INFORMATIONTYPE=8, - FONTSIZE=9, - MAXLENGTH=10, - MAXLENGTHONCE=11, - SOURCELIQUIDTYPE=12, - ABSTELEPORTEFFECT=13, - RELTELEPORTDISPLACEMENT=14, - RELTELEPORTEFFECT=15, - AVOIDDAMAGETYPES=16, - MINIMUMLEVEL=17, - PROFESSIONS=18, - WEIGHT=19, - ROTATETARGET=20, - DESTROYTARGET=21, - BODYPOSITION=22, - SKILLNUMBER=23, - SKILLMODIFICATION=24, - PROTECTIONDAMAGETYPES=25, - DAMAGEREDUCTION=26, - BRIGHTNESS=27, - LIGHTCOLOR=28, - CORPSETYPE=29, - TOTALEXPIRETIME=30, - EXPIRETARGET=31, - TOTALUSES=32, - WEAROUTTARGET=33, - WEAPONTYPE=34, - WEAPONATTACKVALUE=35, - WEAPONDEFENDVALUE=36, - SHIELDDEFENDVALUE=37, - BOWRANGE=38, - BOWAMMOTYPE=39, - THROWRANGE=40, - THROWATTACKVALUE=41, - THROWDEFENDVALUE=42, - THROWMISSILE=43, - THROWSPECIALEFFECT=44, - THROWEFFECTSTRENGTH=45, - THROWFRAGILITY=46, - WANDRANGE=47, - WANDMANACONSUMPTION=48, - WANDATTACKSTRENGTH=49, - WANDATTACKVARIATION=50, - WANDDAMAGETYPE=51, - WANDMISSILE=52, - AMMOTYPE=53, - AMMOATTACKVALUE=54, - AMMOMISSILE=55, - AMMOSPECIALEFFECT=56, - AMMOEFFECTSTRENGTH=57, - ARMORVALUE=58, - ELEVATION=59, - DISGUISETARGET=60, - MEANING=61 -}; - -enum FLAG: int { - BANK=0, - CLIP=1, - BOTTOM=2, - TOP=3, - CONTAINER=4, - CHEST=5, - CUMULATIVE=6, - USEEVENT=7, - CHANGEUSE=8, - FORCEUSE=9, - MULTIUSE=10, - DISTUSE=11, - MOVEMENTEVENT=12, - COLLISIONEVENT=13, - SEPARATIONEVENT=14, - KEY=15, - KEYDOOR=16, - NAMEDOOR=17, - LEVELDOOR=18, - QUESTDOOR=19, - BED=20, - FOOD=21, - RUNE=22, - INFORMATION=23, - TEXT=24, - WRITE=25, - WRITEONCE=26, - LIQUIDCONTAINER=27, - LIQUIDSOURCE=28, - LIQUIDPOOL=29, - TELEPORTABSOLUTE=30, - TELEPORTRELATIVE=31, - UNPASS=32, - UNMOVE=33, - UNTHROW=34, - UNLAY=35, - AVOID=36, - MAGICFIELD=37, - RESTRICTLEVEL=38, - RESTRICTPROFESSION=39, - TAKE=40, - HANG=41, - HOOKSOUTH=42, - HOOKEAST=43, - ROTATE=44, - DESTROY=45, - CLOTHES=46, - SKILLBOOST=47, - PROTECTION=48, - LIGHT=49, - ROPESPOT=50, - CORPSE=51, - EXPIRE=52, - EXPIRESTOP=53, - WEAROUT=54, - WEAPON=55, - SHIELD=56, - BOW=57, - THROW=58, - WAND=59, - AMMO=60, - ARMOR=61, - HEIGHT=62, - DISGUISE=63, - SHOWDETAIL=64, - SPECIALOBJECT=65 -}; - enum SPECIALMEANING: int { MONEY_ONE=1, MONEY_HUNDRED=2, @@ -397,91 +136,6 @@ enum SPECIALMEANING: int { MAGICFIELD_RUSHWOOD=48 }; -enum RIGHT: int { - PREMIUM_ACCOUNT=0, - NOTATION=1, - NAMELOCK=2, - STATEMENT_REPORT=3, - BANISHMENT=4, - FINAL_WARNING=5, - IP_BANISHMENT=6, - KICK=7, - HOME_TELEPORT=8, - GAMEMASTER_BROADCAST=9, - ANONYMOUS_BROADCAST=10, - NO_BANISHMENT=11, - ALLOW_MULTICLIENT=12, - LOG_COMMUNICATION=13, - READ_GAMEMASTER_CHANNEL=14, - READ_TUTOR_CHANNEL=15, - HIGHLIGHT_HELP_CHANNEL=16, - SEND_BUGREPORTS=17, - NAME_INSULTING=18, - NAME_SENTENCE=19, - NAME_NONSENSICAL_LETTERS=20, - NAME_BADLY_FORMATTED=21, - NAME_NO_PERSON=22, - NAME_CELEBRITY=23, - NAME_COUNTRY=24, - NAME_FAKE_IDENTITY=25, - NAME_FAKE_POSITION=26, - STATEMENT_INSULTING=27, - STATEMENT_SPAMMING=28, - STATEMENT_ADVERT_OFFTOPIC=29, - STATEMENT_ADVERT_MONEY=30, - STATEMENT_NON_ENGLISH=31, - STATEMENT_CHANNEL_OFFTOPIC=32, - STATEMENT_VIOLATION_INCITING=33, - CHEATING_BUG_ABUSE=34, - CHEATING_GAME_WEAKNESS=35, - CHEATING_MACRO_USE=36, - CHEATING_MODIFIED_CLIENT=37, - CHEATING_HACKING=38, - CHEATING_MULTI_CLIENT=39, - CHEATING_ACCOUNT_TRADING=40, - CHEATING_ACCOUNT_SHARING=41, - GAMEMASTER_THREATENING=42, - GAMEMASTER_PRETENDING=43, - GAMEMASTER_INFLUENCE=44, - GAMEMASTER_FALSE_REPORTS=45, - KILLING_EXCESSIVE_UNJUSTIFIED=46, - DESTRUCTIVE_BEHAVIOUR=47, - SPOILING_AUCTION=48, - INVALID_PAYMENT=49, - TELEPORT_TO_CHARACTER=50, - TELEPORT_TO_MARK=51, - TELEPORT_VERTICAL=52, - TELEPORT_TO_COORDINATE=53, - LEVITATE=54, - SPECIAL_MOVEUSE=55, - MODIFY_GOSTRENGTH=56, - SHOW_COORDINATE=57, - RETRIEVE=58, - ENTER_HOUSES=59, - OPEN_NAMEDOORS=60, - INVULNERABLE=61, - UNLIMITED_MANA=62, - KEEP_INVENTORY=63, - ALL_SPELLS=64, - UNLIMITED_CAPACITY=65, - ZERO_CAPACITY=66, - ATTACK_EVERYWHERE=67, - NO_ATTACK=68, - NO_RUNES=69, - NO_LOGOUT_BLOCK=70, - GAMEMASTER_OUTFIT=71, - ILLUMINATE=72, - CHANGE_PROFESSION=73, - IGNORED_BY_MONSTERS=74, - SHOW_KEYHOLE_NUMBERS=75, - CREATE_OBJECTS=76, - CREATE_MONEY=77, - CREATE_MONSTERS=78, - CHANGE_SKILLS=79, - CLEANUP_FIELDS=80, - NO_STATISTICS=81 -}; - enum TWriterThreadReplyType: int { REPLY_BROADCAST=0, REPLY_DIRECT=1, @@ -501,32 +155,6 @@ enum TWriterThreadOrderType: int { ORDER_SAVEPLAYERDATA=9 }; -enum TALK_MODE: int { - TALK_SAY=1, - TALK_WHISPER=2, - TALK_YELL=3, - TALK_PRIVATE_MESSAGE=4, - TALK_CHANNEL_CALL=5, - TALK_GAMEMASTER_REQUEST=6, - TALK_GAMEMASTER_ANSWER=7, - TALK_PLAYER_ANSWER=8, - TALK_GAMEMASTER_BROADCAST=9, - TALK_GAMEMASTER_CHANNELCALL=10, - TALK_GAMEMASTER_MESSAGE=11, - TALK_HIGHLIGHT_CHANNELCALL=12, - TALK_ANONYMOUS_BROADCAST=13, - TALK_ANONYMOUS_CHANNELCALL=14, - TALK_ANONYMOUS_MESSAGE=15, - TALK_ANIMAL_LOW=16, - TALK_ANIMAL_LOUD=17, - TALK_ADMIN_MESSAGE=18, - TALK_EVENT_MESSAGE=19, - TALK_LOGIN_MESSAGE=20, - TALK_STATUS_MESSAGE=21, - TALK_INFO_MESSAGE=22, - TALK_FAILURE_MESSAGE=23 -}; - enum CHANNEL: int { GUILD_CHANNEL=0, GAMEMASTER_CHANNEL=1, @@ -597,9 +225,3 @@ enum BloodType: int { BT_FIRE=3, BT_ENERGY=4 }; - -enum TWorldType: int { - NORMAL=0, - NON_PVP=1, - PVP_ENFORCED=2 -}; diff --git a/reference/game.c b/reference/game.c index a005445..07e6991 100644 --- a/reference/game.c +++ b/reference/game.c @@ -1946,352 +1946,226 @@ void __static_initialization_and_destruction_0(int __initialize_p,int __priority return; } +// WARNING: Unknown calling convention -- yet parameter storage is locked +void _GLOBAL__I_BeADaemon(void) -// WARNING: Unknown calling convention -- yet parameter storage is locked +{ + __static_initialization_and_destruction_0(1,0xffff); + return; +} -void ProcessCommand(void) +bool isSpace(int c) { - char *CommandBuffer; - int iVar1; - char *pcVar2; - int Command; + bool bVar1; - iVar1 = GetCommand(); - if (iVar1 != 0) { - pcVar2 = GetCommandBuffer(); - if (iVar1 == 1) { - if (pcVar2 == (char *)0x0) { - error(&DAT_080ee440); - } - else { - BroadcastMessage(0x12,"%s",pcVar2); - } - } - else { - error("ProcessCommand: Unbekanntes Kommando %d.\n",iVar1); - } - SetCommand(0,(char *)0x0); + bVar1 = false; + if ((((c == 0x20) || (c == 0xc)) || (c == 10)) || (((c == 0xd || (c == 9)) || (c == 0xb)))) { + bVar1 = true; } - return; + return bVar1; } -// WARNING: Variable defined which should be unmapped: Color - -void AdvanceGame(int Delay) +bool isAlpha(int c) { - int iVar1; - TConnection *Connection_00; - TConnection *Connection; - int Time; - char *pcVar2; - int local_20; - int Hour; - int Minute; - int Brightness; - int Color; + bool bVar1; - AdvanceGame::SkillTimeCounter = AdvanceGame::SkillTimeCounter + Delay; - AdvanceGame::OtherTimeCounter = AdvanceGame::OtherTimeCounter + Delay; - AdvanceGame::CreaturesTimeCounter = AdvanceGame::CreaturesTimeCounter + Delay; - AdvanceGame::CronTimeCounter = AdvanceGame::CronTimeCounter + Delay; - if (0x6d5 < AdvanceGame::CreaturesTimeCounter) { - AdvanceGame::CreaturesTimeCounter = AdvanceGame::CreaturesTimeCounter + -1000; - ProcessCreatures(); - } - if (0x5db < AdvanceGame::CronTimeCounter) { - AdvanceGame::CronTimeCounter = AdvanceGame::CronTimeCounter + -1000; - ProcessCronSystem(); - } - if (0x4e1 < AdvanceGame::SkillTimeCounter) { - AdvanceGame::SkillTimeCounter = AdvanceGame::SkillTimeCounter + -1000; - ProcessSkills(); - } - if (999 < AdvanceGame::OtherTimeCounter) { - AdvanceGame::OtherTimeCounter = AdvanceGame::OtherTimeCounter + -1000; - RoundNr = RoundNr + 1; - SetRoundNr(RoundNr); - ProcessConnections(); - ProcessMonsterhomes(); - ProcessMonsterRaids(); - ProcessCommunicationControl(); - ProcessReaderThreadReplies(RefreshSector,SendMails); - ProcessWriterThreadReplies(); - ProcessCommand(); - GetAmbiente(&Minute,&Brightness); - if (Minute != AdvanceGame::OldAmbiente) { - AdvanceGame::OldAmbiente = Minute; - Connection_00 = GetFirstConnection(); - while (Connection_00 != (TConnection *)0x0) { - if (Connection_00->State - CONNECTION_LOGIN < 4) { - SendAmbiente(Connection_00); - } - Connection_00 = GetNextConnection(); - } - } - if (RoundNr == (RoundNr / 10) * 10) { - NetLoadCheck(); - } - if (AdvanceGame::NextMinute <= RoundNr) { - GetRealTime(&local_20,&Hour); - RefreshCylinders(); - if (Hour == (Hour / 5) * 5) { - CreatePlayerList(true); - } - if (Hour == (Hour / 0xf) * 0xf) { - SavePlayerDataOrder(); - } - if (Hour == 0) { - NetLoadSummary(); - } - if (Hour == 0x37) { - WriteKillStatistics(); - } - iVar1 = Hour + local_20 * 0x3c; - if ((iVar1 + 5) % 0x5a0 == RebootTime) { - if (Reboot == false) { - pcVar2 = "Server is going down in 5 minutes.\nPlease log out."; - } - else { - pcVar2 = "Server is saving game in 5 minutes.\nPlease come back in 10 minutes."; - } - BroadcastMessage(0x12,pcVar2); - CloseGame(); - } - if ((iVar1 + 3) % 0x5a0 == RebootTime) { - if (Reboot == false) { - pcVar2 = "Server is going down in 3 minutes.\nPlease log out."; - } - else { - pcVar2 = "Server is saving game in 3 minutes.\nPlease come back in 10 minutes."; - } - BroadcastMessage(0x12,pcVar2); - } - if ((iVar1 + 1) % 0x5a0 == RebootTime) { - if (Reboot == false) { - pcVar2 = "Server is going down in one minute.\nPlease log out."; - } - else { - pcVar2 = "Server is saving game in one minute.\nPlease log out."; - } - BroadcastMessage(0x12,pcVar2); - } - if (iVar1 == RebootTime) { - CloseGame(); - LogoutAllPlayers(); - SendAll(); - if (Reboot != false) { - RefreshMap(); - } - SaveMap(); - SaveMapOn = false; - EndGame(); - } - AdvanceGame::NextMinute = GetRoundForNextMinute(); - } - CleanupDynamicStrings(); - } - if (Beat < Delay) { - Log("lag",&DAT_080ee9c7,Delay); - } - if (Delay < 1000) { - MoveCreatures(Delay); - AdvanceGame::Lag = false; - } - else { - if ((AdvanceGame::Lag == false) && (10 < RoundNr)) { - error(&DAT_080ee480,Delay); - } - AdvanceGame::Lag = true; + bVar1 = false; + if ((((((c - 0x61U < 0x1a) || (c - 0x41U < 0x1a)) || (c == -0x1c)) || ((c == -10 || (c == -4)))) + || ((c == -0x3c || ((c == -0x2a || (c == -0x24)))))) || (c == -0x21)) { + bVar1 = true; } - SendAll(); - return; + return bVar1; } -void HandlerSigAlarm(int param_1) +bool isEngAlpha(int c) { - undefined1 local_2c [4]; - itimerval ov; - itimerval v; + bool bVar1; - ov.it_value.tv_usec = 0; - SigAlarmCounter = SigAlarmCounter + 1; - setitimer(ITIMER_REAL,(itimerval *)&ov.it_value.tv_usec,(itimerval *)local_2c); - return; + bVar1 = false; + if ((c - 0x61U < 0x1a) || (c - 0x41U < 0x1a)) { + bVar1 = true; + } + return bVar1; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void TimeReset(void) +bool isDigit(int c) { - SigAlarmCounter = 0; - return; + return c - 0x30U < 10; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void InitTime(void) +int toLower(int c) { - undefined1 local_2c [4]; - itimerval ov; - itimerval v; - - SigAlarmCounter = 0; - handler(0xe,HandlerSigAlarm); - ov.it_value.tv_usec = 0; - SigAlarmCounter = SigAlarmCounter + 1; - setitimer(ITIMER_REAL,(itimerval *)&ov.it_value.tv_usec,(itimerval *)local_2c); - return; + if ((c - 0x41U < 0x1a) || ((byte)((char)(c - 0x41U) + 0x81U) < 0x1f)) { + c = c + 0x20; + } + return c; } -// WARNING: Unknown calling convention -- yet parameter storage is locked +int toUpper(int c) + +{ + if ((c - 0x61U < 0x1a) || ((byte)((char)(c - 0x61U) + 0x81U) < 0x1f)) { + c = c + -0x20; + } + return c; +} + -void ExitTime(void) + +char * strLower(char *s) { - undefined1 local_2c [4]; - itimerval ov; - itimerval v; + char cVar1; + int i; + int iVar2; - ov.it_value.tv_usec = 0; - setitimer(ITIMER_REAL,(itimerval *)&ov.it_value.tv_usec,(itimerval *)local_2c); - handler(0xe,(_func_void_int *)0x1); - return; + iVar2 = 0; + cVar1 = *s; + while (cVar1 != '\0') { + if (((int)cVar1 - 0x41U < 0x1a) || ((byte)((char)((int)cVar1 - 0x41U) + 0x81U) < 0x1f)) { + cVar1 = cVar1 + ' '; + } + s[iVar2] = cVar1; + iVar2 = iVar2 + 1; + cVar1 = s[iVar2]; + } + return s; } -void SigHupHandler(int param_1) +char * strUpper(char *s) { - return; + char cVar1; + int i; + int iVar2; + + iVar2 = 0; + cVar1 = *s; + while (cVar1 != '\0') { + if (((int)cVar1 - 0x61U < 0x1a) || ((byte)((char)((int)cVar1 - 0x61U) + 0x81U) < 0x1f)) { + cVar1 = cVar1 + -0x20; + } + s[iVar2] = cVar1; + iVar2 = iVar2 + 1; + cVar1 = s[iVar2]; + } + return s; } -void SigAbortHandler(int param_1) +int stricmp(char *s1,char *s2,int Pos) { - print(); - AbortWriter(); - return; + char cVar1; + int iVar2; + int iVar3; + int i; + int iVar4; + + iVar4 = 0; + while( true ) { + if (iVar4 == Pos) { + return 0; + } + cVar1 = s1[iVar4]; + iVar2 = (int)cVar1; + if ((iVar2 - 0x41U < 0x1a) || ((byte)((char)(iVar2 - 0x41U) + 0x81U) < 0x1f)) { + iVar2 = iVar2 + 0x20; + } + iVar3 = (int)s2[iVar4]; + if ((iVar3 - 0x41U < 0x1a) || ((byte)((char)(iVar3 - 0x41U) + 0x81U) < 0x1f)) { + iVar3 = iVar3 + 0x20; + } + if (iVar3 < iVar2) break; + iVar2 = (int)cVar1; + if ((iVar2 - 0x41U < 0x1a) || ((byte)((char)(iVar2 - 0x41U) + 0x81U) < 0x1f)) { + iVar2 = iVar2 + 0x20; + } + iVar3 = (int)s2[iVar4]; + if ((iVar3 - 0x41U < 0x1a) || ((byte)((char)(iVar3 - 0x41U) + 0x81U) < 0x1f)) { + iVar3 = iVar3 + 0x20; + } + if (iVar2 < iVar3) { + return -1; + } + if (cVar1 == '\0') { + return 0; + } + iVar4 = iVar4 + 1; + } + return 1; } -void HandlerSigUsr1(int param_1) +char * findFirst(char *s,char c) { - SigUsr1Counter = SigUsr1Counter + 1; - return; + char *pcVar1; + + pcVar1 = strchr(s,(int)c); + return pcVar1; } -// WARNING: Variable defined which should be unmapped: s - -void DefaultHandler(int signo) +char * findLast(char *s,char c) { - int local_94; - int Hour; - int Minute; - char s [128]; + char *pcVar1; + char *p; + char *pcVar2; - snprintf((char *)&Minute,0x80,"SigNr. %d: %s",signo,*(undefined4 *)(sys_siglist + signo * 4)); - print(); - handler(2,(_func_void_int *)0x1); - handler(3,(_func_void_int *)0x1); - handler(0xf,(_func_void_int *)0x1); - handler(0x18,(_func_void_int *)0x1); - handler(0x19,(_func_void_int *)0x1); - handler(0x1e,(_func_void_int *)0x1); - SaveMapOn = false; - if (((signo == 3) || (signo == 0xf)) || (signo == 0x1e)) { - SaveMapOn = true; - } - if (signo == 0xf) { - GetRealTime(&local_94,&Hour); - RebootTime = (Hour + 6 + local_94 * 0x3c) % 0x5a0; - CloseGame(); - } - else { - EndGame(); + pcVar2 = (char *)0x0; + while( true ) { + pcVar1 = strchr(s,(int)c); + if (pcVar1 == (char *)0x0) break; + s = pcVar1 + 1; + pcVar2 = pcVar1; } - Reboot = false; - return; + return pcVar2; } -void ErrorHandler(int signo) +void SetPrintFunction(TPrintFunction *Function) { - char local_8c [4]; - char s [128]; - - snprintf(local_8c,0x80,"SigNr. %d: %s",signo,*(undefined4 *)(sys_siglist + signo * 4)); - error("ErrorHandler: %s\n",local_8c); - EndGame(); - LogoutAllPlayers(); - // WARNING: Subroutine does not return - exit(1); + PrintFunction = Function; + return; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void InitSignalHandler(void) +void SetErrorFunction(TErrorFunction *Function) { - int count; - - handler(1,SigHupHandler); - handler(2,DefaultHandler); - handler(3,DefaultHandler); - handler(6,SigAbortHandler); - handler(10,(_func_void_int *)0x1); - handler(0xc,(_func_void_int *)0x1); - handler(0xd,(_func_void_int *)0x1); - handler(0xe,(_func_void_int *)0x1); - handler(0xf,DefaultHandler); - handler(0x10,(_func_void_int *)0x1); - handler(0x11,(_func_void_int *)0x1); - handler(0x14,(_func_void_int *)0x1); - handler(0x15,(_func_void_int *)0x1); - handler(0x16,(_func_void_int *)0x1); - handler(0x17,(_func_void_int *)0x1); - handler(0x18,DefaultHandler); - handler(0x19,DefaultHandler); - handler(0x1a,(_func_void_int *)0x1); - handler(0x1c,(_func_void_int *)0x1); - handler(0x1d,(_func_void_int *)0x1); - handler(0x1e,DefaultHandler); - print(); + ErrorFunction = Function; return; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void ExitSignalHandler(void) +void SilentHandler(int param_1,char *param_2) { return; @@ -2299,2659 +2173,1930 @@ void ExitSignalHandler(void) -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void UnlockGame(void) +void SilentHandler(char *param_1) { - int iVar1; - __pid_t _Var2; - int local_1140; - int Pid; - ifstream IF; - undefined4 local_1134 [3]; - uint auStack_1128 [23]; - __basic_file local_10cc [25]; - undefined1 local_10b3; - undefined *local_10ac; - ios_base local_10a8 [16]; - uint local_1098; - char local_101c [4]; - char FileName [4096]; - - std::ios_base::ios_base(local_10a8); - local_10ac = (undefined *)0x8128950; - // try { // try from 0804bd94 to 0804bd98 has its CatchHandler @ 0804bf54 - std::istream::istream((istream *)&Pid,(streambuf *)(std::ifstream::VTT + 4)); - Pid = (int)&DAT_08128994; - local_10ac = &DAT_081289a8; - // try { // try from 0804bdb8 to 0804bdbc has its CatchHandler @ 0804bf50 - std::filebuf::filebuf((filebuf *)local_1134); - // try { // try from 0804bdca to 0804bdce has its CatchHandler @ 0804bf14 - std::ios::init((EVP_PKEY_CTX *)&local_10ac); - strcpy(local_101c,SAVEPATH); - strcat(local_101c,"/game.pid"); - // try { // try from 0804be04 to 0804be36 has its CatchHandler @ 0804bf58 - iVar1 = std::filebuf::open((char *)local_1134,(int)local_101c,8); - if (iVar1 == 0) { - std::ios::clear((istream *)&Pid + *(int *)(Pid + -0xc), - *(uint *)((int)auStack_1128 + *(int *)(Pid + -0xc)) | 4); - } - if ((local_1098 & 5) == 0) { - std::istream::operator>>((istream *)&Pid,&local_1140); - iVar1 = std::filebuf::close((int)local_1134); - if (iVar1 == 0) { - // try { // try from 0804bee1 to 0804bf0e has its CatchHandler @ 0804bf58 - std::ios::clear((istream *)&Pid + *(int *)(Pid + -0xc), - *(uint *)((int)auStack_1128 + *(int *)(Pid + -0xc)) | 4); - } - _Var2 = getpid(); - if (local_1140 == _Var2) { - unlink(local_101c); - } - } - Pid = (int)&DAT_08128994; - local_10ac = &DAT_081289a8; - local_1134[0] = 0x8128ad0; - std::filebuf::close((int)local_1134); - local_10b3 = 0; - std::__basic_file::~__basic_file(local_10cc); - std::streambuf::~streambuf((streambuf *)local_1134); - std::istream::~istream((istream *)&Pid); - std::ios::~ios((ios *)&local_10ac); return; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void LockGame(void) +void LogfileHandler(int param_1,char *Text) { - uint uVar1; - int iVar2; - ulong uVar3; - undefined4 *puVar4; - int local_1260; - int Pid; - char FileName [4096]; - ofstream OF; - uint auStack_250 [24]; - __basic_file local_1f0 [25]; - undefined1 local_1d7; - undefined *local_1d0; - ios_base local_1cc [144]; - undefined *local_13c; - ifstream IF; - undefined4 local_134 [3]; - uint auStack_128 [23]; - __basic_file local_cc [25]; - undefined1 local_b3; - undefined *local_ac; - ios_base local_a8 [16]; - uint local_98; + FILE *__stream; + int iVar1; + FILE *f; - // try { // try from 0804bff1 to 0804bff5 has its CatchHandler @ 0804c550 - std::ios_base::ios_base(local_a8); - local_ac = (undefined *)0x8128950; - // try { // try from 0804c014 to 0804c018 has its CatchHandler @ 0804c3f0 - std::istream::istream((istream *)&local_13c,(streambuf *)(std::ifstream::VTT + 4)); - local_13c = &DAT_08128994; - local_ac = &DAT_081289a8; - // try { // try from 0804c038 to 0804c03c has its CatchHandler @ 0804c3e7 - std::filebuf::filebuf((filebuf *)local_134); - // try { // try from 0804c050 to 0804c054 has its CatchHandler @ 0804c3a0 - std::ios::init((EVP_PKEY_CTX *)&local_ac); - // try { // try from 0804c05e to 0804c062 has its CatchHandler @ 0804c546 - std::ios_base::ios_base(local_1cc); - local_1d0 = (undefined *)0x8128950; - // try { // try from 0804c087 to 0804c08b has its CatchHandler @ 0804c4be - std::ostream::ostream((ostream *)(FileName + 0xffc),(streambuf *)(std::ofstream::VTT + 4)); - FileName._4092_4_ = &DAT_08128a64; - local_1d0 = &DAT_08128a78; - // try { // try from 0804c0ab to 0804c0af has its CatchHandler @ 0804c4b5 - std::filebuf::filebuf((filebuf *)&OF); - // try { // try from 0804c0c3 to 0804c0c7 has its CatchHandler @ 0804c3f6 - std::ios::init((EVP_PKEY_CTX *)&local_1d0); - strcpy((char *)&Pid,SAVEPATH); - strcat((char *)&Pid,"/game.pid"); - // try { // try from 0804c103 to 0804c194 has its CatchHandler @ 0804c4c7 - iVar2 = std::filebuf::open((char *)local_134,(int)&Pid,8); - if (iVar2 == 0) { - std::ios::clear((istream *)&local_13c + *(int *)(local_13c + -0xc), - *(uint *)((int)auStack_128 + *(int *)(local_13c + -0xc)) | 4); - } - if ((local_98 & 5) == 0) { - std::istream::operator>>((istream *)&local_13c,&local_1260); - iVar2 = std::filebuf::close((int)local_134); - if (iVar2 == 0) { - std::ios::clear((istream *)&local_13c + *(int *)(local_13c + -0xc), - *(uint *)((int)auStack_128 + *(int *)(local_13c + -0xc)) | 4); - } - if (local_1260 != 0) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "Game-Server is already running, PID file exists."; - // WARNING: Subroutine does not return - __cxa_throw(puVar4,char_const*::typeinfo,0); + if (StandardLogfile[0] != '\0') { + __stream = fopen(StandardLogfile,"at"); + if (__stream != (FILE *)0x0) { + fprintf(__stream,"%s",Text); + iVar1 = fclose(__stream); + if (iVar1 != 0) { + __errno_location(); + error(&DAT_080eeb60); + return; + } } } - else { - iVar2 = std::filebuf::close((int)local_134); - if (iVar2 == 0) { - std::ios::clear((istream *)&local_13c + *(int *)(local_13c + -0xc), - *(uint *)((int)auStack_128 + *(int *)(local_13c + -0xc)) | 4); - } - iVar2 = std::filebuf::open((char *)&OF,(int)&Pid,0x30); - if (iVar2 == 0) { - std::ios::clear(FileName + *(int *)(FileName._4092_4_ + -0xc) + 0xffc, - *(uint *)((int)auStack_250 + *(int *)(FileName._4092_4_ + -0xc) + 8) | 4 - ); - } - uVar3 = getpid(); - uVar1 = *(uint *)((int)auStack_250 + *(int *)(FileName._4092_4_ + -0xc)); - if (((uVar1 & 0x40) == 0) && ((uVar1 & 8) == 0)) { - // try { // try from 0804c2a1 to 0804c397 has its CatchHandler @ 0804c4c7 - std::ostream::operator<<((ostream *)(FileName + 0xffc),uVar3); - } - else { - std::ostream::operator<<((ostream *)(FileName + 0xffc),uVar3); - } - atexit(UnlockGame); - } - FileName._4092_4_ = &DAT_08128a64; - local_1d0 = &DAT_08128a78; - _OF = 0x8128ad0; - // try { // try from 0804c1cb to 0804c216 has its CatchHandler @ 0804c546 - std::filebuf::close((int)&OF); - local_1d7 = 0; - std::__basic_file::~__basic_file(local_1f0); - std::streambuf::~streambuf((streambuf *)&OF); - std::ostream::~ostream((ostream *)(FileName + 0xffc)); - std::ios::~ios((ios *)&local_1d0); - local_13c = &DAT_08128994; - local_ac = &DAT_081289a8; - local_134[0] = 0x8128ad0; - // try { // try from 0804c241 to 0804c286 has its CatchHandler @ 0804c550 - std::filebuf::close((int)local_134); - local_b3 = 0; - std::__basic_file::~__basic_file(local_cc); - std::streambuf::~streambuf((streambuf *)local_134); - std::istream::~istream((istream *)&local_13c); - std::ios::~ios((ios *)&local_ac); return; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void LoadWorldConfig(void) +void LogfileHandler(char *Text) { - TQueryManagerConnection *this; + FILE *__stream; int iVar1; - undefined4 *puVar2; - TWorldType *pTVar3; - int *piVar4; - int *piVar5; - int *piVar6; - int *piVar7; - int *piVar8; - int *piVar9; - int *piVar10; - TWorldType local_60; - int HelpWorldType; - int HelpGameAddress [4]; - TQueryManagerConnection Connection; - - this = (TQueryManagerConnection *)(HelpGameAddress + 3); - // try { // try from 0804c590 to 0804c594 has its CatchHandler @ 0804c6b7 - TQueryManagerConnection::TQueryManagerConnection(this,0x4000); - if (Connection.WriteBuffer.Position < 0) { - error("LoadWorldConfig: Kann nicht zum Query-Manager verbinden.\n"); - puVar2 = (undefined4 *)__cxa_allocate_exception(4); - *puVar2 = "cannot connect to querymanager"; - } - else { - piVar10 = &PremiumNewbieBuffer; - piVar5 = &HelpWorldType; - pTVar3 = &local_60; - piVar9 = &MaxNewbies; - piVar8 = &PremiumPlayerBuffer; - piVar7 = &MaxPlayers; - piVar6 = &GamePort; - piVar4 = &RebootTime; - // try { // try from 0804c5e6 to 0804c5ea has its CatchHandler @ 0804c6a0 - iVar1 = TQueryManagerConnection::loadWorldConfig(this); - if (iVar1 == 0) { - iVar1 = 0x10; - WorldType = local_60; - snprintf(GameAddress,0x10,"%d.%d.%d.%d",HelpWorldType,HelpGameAddress[0], - HelpGameAddress[1],HelpGameAddress[2]); - // try { // try from 0804c632 to 0804c636 has its CatchHandler @ 0804c6b7 - TQueryManagerConnection::~TQueryManagerConnection(this,iVar1); - return; + int *piVar2; + FILE *f; + + if (StandardLogfile[0] != '\0') { + __stream = fopen(StandardLogfile,"at"); + if (__stream != (FILE *)0x0) { + fprintf(__stream,"%s",Text); + iVar1 = fclose(__stream); + if (iVar1 != 0) { + piVar2 = __errno_location(); + error(&DAT_080eeb60,*piVar2); + } } - // try { // try from 0804c64b to 0804c685 has its CatchHandler @ 0804c6a0 - error("LoadWorldConfig: Kann Konfigurationsdaten nicht holen.\n",pTVar3,piVar4,piVar5,piVar6 - ,piVar7,piVar8,piVar9,piVar10); - puVar2 = (undefined4 *)__cxa_allocate_exception(4); - *puVar2 = "cannot load world config"; } - // WARNING: Subroutine does not return - __cxa_throw(puVar2,char_const*::typeinfo,0); + return; } // WARNING: Unknown calling convention -- yet parameter storage is locked -void InitAll(void) +void print(void) { - uint __seed; - undefined1 local_2c [4]; - itimerval ov; - itimerval v; - - // try { // try from 0804c6d9 to 0804c7d4 has its CatchHandler @ 0804c7e0 - ReadConfig(); - SetQueryManagerLoginData(1,WorldName); - LoadWorldConfig(); - InitSHM((bool)(BeADaemon ^ 1)); - LockGame(); - InitLog("game"); - __seed = time((time_t *)0x0); - srand(__seed); - InitSignalHandler(); - InitConnections(); - InitCommunication(); - InitStrings(); - InitWriter(); - InitReader(); - InitObjects(); - InitMap(); - InitInfo(); - InitMoveUse(); - InitMagic(); - InitCr(); - InitHouses(); - SigAlarmCounter = 0; - handler(0xe,HandlerSigAlarm); - SigAlarmCounter = SigAlarmCounter + 1; - ov.it_value.tv_usec = 0; - setitimer(ITIMER_REAL,(itimerval *)&ov.it_value.tv_usec,(itimerval *)local_2c); - ApplyPatches(); + int in_stack_00000004; + char *in_stack_00000008; + char local_40c [4]; + char s [1024]; + + vsnprintf(local_40c,0x400,in_stack_00000008,&stack0x0000000c); + if (PrintFunction == (TPrintFunction *)0x0) { + printf("%s",local_40c); + } + else { + (*PrintFunction)(in_stack_00000004,local_40c); + } return; } +// DWARF original prototype: bool readFlag(TReadStream * this) -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void ExitAll(void) +bool __thiscall TReadStream::readFlag(TReadStream *this) { - undefined1 local_2c [4]; - itimerval ov; - itimerval v; + int iVar1; - EndGame(); - ov.it_value.tv_usec = 0; - setitimer(ITIMER_REAL,(itimerval *)&ov.it_value.tv_usec,(itimerval *)local_2c); - handler(0xe,(_func_void_int *)0x1); - ExitCr(); - ExitMagic(); - ExitMoveUse(); - ExitInfo(); - ExitHouses(); - ExitMap(SaveMapOn); - ExitObjects(); - ExitReader(); - ExitWriter(); - ExitStrings(); - ExitCommunication(); - ExitConnections(); - ExitSHM(); - return; + // try { // try from 0804d1ce to 0804d1d0 has its CatchHandler @ 0804d1e0 + iVar1 = (*this->_vptr_TReadStream[1])(this); + return (char)iVar1 != '\0'; } -// WARNING: Unknown calling convention -- yet parameter storage is locked +// WARNING: Variable defined which should be unmapped: Lo +// DWARF original prototype: ushort readWord(TReadStream * this) -void LaunchGame(void) +ushort __thiscall TReadStream::readWord(TReadStream *this) { + uchar Hi; int iVar1; - bool bVar2; + uint uVar2; + uchar Lo; - SigUsr1Counter = 0; - handler(10,HandlerSigUsr1); - StartGame(); - getpid(); - print(); - SaveMapOn = true; - SigAlarmCounter = 0; - while (bVar2 = GameRunning(), bVar2) { - sigblock(0x200); - while ((SigUsr1Counter == 0 && (SigAlarmCounter == 0))) { - __sigpause(0,0); - } - if (0 < SigUsr1Counter) { - SigUsr1Counter = 0; - ReceiveData(); - } - iVar1 = SigAlarmCounter; - if (0 < SigAlarmCounter) { - SigAlarmCounter = 0; - AdvanceGame(iVar1 * Beat); - } - } - LogoutAllPlayers(); - return; + // try { // try from 0804d211 to 0804d21e has its CatchHandler @ 0804d232 + iVar1 = (*this->_vptr_TReadStream[1])(this); + uVar2 = (*this->_vptr_TReadStream[1])(this); + return (ushort)(byte)iVar1 | (ushort)((uVar2 & 0xff) << 8); } -int DaemonInit(bool NoFork) +// WARNING: Variable defined which should be unmapped: hi +// DWARF original prototype: ulong readQuad(TReadStream * this) + +ulong __thiscall TReadStream::readQuad(TReadStream *this) { - pid_t Pid; - __pid_t _Var1; - long lVar2; - int i; - int __fd; + int iVar1; + int iVar2; int iVar3; - int openmax; + int iVar4; + uchar Hi; + uchar hi; + uchar lo; + uchar Lo; - if (!NoFork) { - _Var1 = fork(); - if (_Var1 < 0) { - return 1; + // try { // try from 0804d261 to 0804d284 has its CatchHandler @ 0804d2b0 + iVar1 = (*this->_vptr_TReadStream[1])(this); + iVar2 = (*this->_vptr_TReadStream[1])(this); + iVar3 = (*this->_vptr_TReadStream[1])(this); + iVar4 = (*this->_vptr_TReadStream[1])(this); + return (uint)CONCAT12((char)iVar3,CONCAT11((char)iVar2,(char)iVar1)) | iVar4 << 0x18; +} + + + +// DWARF original prototype: void readString(TReadStream * this, char * Buffer, int MaxLength) + +void __thiscall TReadStream::readString(TReadStream *this,char *Buffer,int MaxLength) + +{ + uint uVar1; + undefined4 *puVar2; + int Length; + + if (Buffer != (char *)0x0) { + // try { // try from 0804d2f2 to 0804d3a4 has its CatchHandler @ 0804d3a5 + uVar1 = (*this->_vptr_TReadStream[2])(this); + uVar1 = uVar1 & 0xffff; + if (uVar1 == 0xffff) { + uVar1 = (*this->_vptr_TReadStream[3])(this); } - if (_Var1 != 0) { - // WARNING: Subroutine does not return - exit(0); + *Buffer = '\0'; + if (uVar1 != 0) { + if ((MaxLength < 0) || ((int)uVar1 < MaxLength)) { + (*this->_vptr_TReadStream[5])(this,Buffer,uVar1); + Buffer[uVar1] = '\0'; + } + else { + (*this->_vptr_TReadStream[5])(this,Buffer,MaxLength + -1); + Buffer[MaxLength + -1] = '\0'; + (*this->_vptr_TReadStream[7])(this,(uVar1 - MaxLength) + 1); + } } - setsid(); - } - umask(0); - umask(0x7f); - chdir(SAVEPATH); - lVar2 = sysconf(4); - if (lVar2 < 0) { - lVar2 = 0x400; - } - __fd = 0; - if (0 < lVar2) { - do { - iVar3 = __fd + 1; - close(__fd); - __fd = iVar3; - } while (iVar3 < lVar2); + return; } - return 0; + error(&DAT_080eeba0); + puVar2 = (undefined4 *)__cxa_allocate_exception(4); + *puVar2 = "internal error"; + // WARNING: Subroutine does not return + __cxa_throw(puVar2,char_const*::typeinfo,0); } -int main(int argc,char **argv) +// DWARF original prototype: void readBytes(TReadStream * this, uchar * Buffer, int Count) + +void __thiscall TReadStream::readBytes(TReadStream *this,uchar *Buffer,int Count) { - RESULT r; int iVar1; - char *pcVar2; - char *pcVar3; - bool bVar4; - int local_1024; + undefined4 *puVar2; int i; - char local_101c [3]; - bool NoFork; - char FileName [4096]; + int iVar3; - local_1024 = 1; - bVar4 = argc == 1; - i._3_1_ = false; - BeADaemon = false; - Reboot = true; - if (1 < argc) { + if (Buffer == (uchar *)0x0) { + error(&DAT_080eebe0); + puVar2 = (undefined4 *)__cxa_allocate_exception(4); + *puVar2 = "internal error"; + // WARNING: Subroutine does not return + __cxa_throw(puVar2,char_const*::typeinfo,0); + } + iVar3 = 0; + if (0 < Count) { do { - iVar1 = 7; - pcVar2 = argv[local_1024]; - pcVar3 = "daemon"; - do { - if (iVar1 == 0) break; - iVar1 = iVar1 + -1; - bVar4 = *pcVar2 == *pcVar3; - pcVar2 = pcVar2 + 1; - pcVar3 = pcVar3 + 1; - } while (bVar4); - if (bVar4) { - BeADaemon = true; - } - iVar1 = 7; - pcVar2 = argv[local_1024]; - pcVar3 = "nofork"; - do { - if (iVar1 == 0) break; - iVar1 = iVar1 + -1; - bVar4 = *pcVar2 == *pcVar3; - pcVar2 = pcVar2 + 1; - pcVar3 = pcVar3 + 1; - } while (bVar4); - if (bVar4) { - i._3_1_ = true; - } - local_1024 = local_1024 + 1; - bVar4 = local_1024 == argc; - } while (local_1024 < argc); - } - if (((BeADaemon != false) || - (puts("Tibia Game-Server\n(c) by CIP Productions, 2003.\n"), BeADaemon != false)) && - (iVar1 = DaemonInit(i._3_1_), iVar1 != 0)) { - return 2; - } - InitAll(); - atexit(ExitAll); - // try { // try from 0804cb24 to 0804cb28 has its CatchHandler @ 0804cbb5 - LaunchGame(); - if (Reboot != false) { - UnlockGame(); - sprintf(local_101c,"%s/reboot-daily",BINPATH); - bVar4 = FileExists(local_101c); - if (bVar4) { - ExitAll(); - print(); - execv(local_101c,argv); - } + // try { // try from 0804d3f5 to 0804d43a has its CatchHandler @ 0804d440 + iVar1 = (*this->_vptr_TReadStream[1])(this); + Buffer[iVar3] = (uchar)iVar1; + iVar3 = iVar3 + 1; + } while (iVar3 < Count); } - print(); - return 0; + return; } -// WARNING: Unknown calling convention -- yet parameter storage is locked +// DWARF original prototype: void writeFlag(TWriteStream * this, bool f) -void _GLOBAL__I_BeADaemon(void) +void __thiscall TWriteStream::writeFlag(TWriteStream *this,bool f) { - __static_initialization_and_destruction_0(1,0xffff); + // try { // try from 0804d47b to 0804d47d has its CatchHandler @ 0804d482 + (*this->_vptr_TWriteStream[1])(this,(uint)f); return; } -_func_void_int * handler(int signr,_func_void_int *sighandler) +// DWARF original prototype: void writeWord(TWriteStream * this, ushort w) + +void __thiscall TWriteStream::writeWord(TWriteStream *this,ushort w) { - int iVar1; - _union_1051 _Var2; - _union_1051 local_12c; - sigaction alt_handler; - _union_1051 local_9c; - sigaction neu_handler; - - local_9c.sa_handler = (__sighandler_t)sighandler; - sigemptyset((sigset_t *)&neu_handler); - neu_handler.sa_mask.__val[0x1f] = 0x20000000; - if (signr != 0xe) { - neu_handler.sa_mask.__val[0x1f] = 0x10000000; - } - iVar1 = sigaction(signr,(sigaction *)&local_9c,(sigaction *)&local_12c); - _Var2 = (_union_1051)0xffffffff; - if (-1 < iVar1) { - _Var2 = local_12c; - } - return (_func_void_int *)_Var2.sa_handler; + // try { // try from 0804d4c1 to 0804d4d7 has its CatchHandler @ 0804d4e2 + (*this->_vptr_TWriteStream[1])(this,w & 0xff); + (*this->_vptr_TWriteStream[1])(this,w >> 8); + return; } -bool isSpace(int c) +// DWARF original prototype: void writeQuad(TWriteStream * this, ulong q) + +void __thiscall TWriteStream::writeQuad(TWriteStream *this,ulong q) { - bool bVar1; - - bVar1 = false; - if ((((c == 0x20) || (c == 0xc)) || (c == 10)) || (((c == 0xd || (c == 9)) || (c == 0xb)))) { - bVar1 = true; - } - return bVar1; + // try { // try from 0804d51e to 0804d553 has its CatchHandler @ 0804d560 + (*this->_vptr_TWriteStream[1])(this,q & 0xff); + (*this->_vptr_TWriteStream[1])(this,q >> 8 & 0xff); + (*this->_vptr_TWriteStream[1])(this,q >> 0x10 & 0xff); + (*this->_vptr_TWriteStream[1])(this,q >> 0x18); + return; } -bool isAlpha(int c) +// DWARF original prototype: void writeString(TWriteStream * this, char * s) + +void __thiscall TWriteStream::writeString(TWriteStream *this,char *s) { - bool bVar1; + size_t sVar1; - bVar1 = false; - if ((((((c - 0x61U < 0x1a) || (c - 0x41U < 0x1a)) || (c == -0x1c)) || ((c == -10 || (c == -4)))) - || ((c == -0x3c || ((c == -0x2a || (c == -0x24)))))) || (c == -0x21)) { - bVar1 = true; + if (s == (char *)0x0) { + (*this->_vptr_TWriteStream[2])(this,0); } - return bVar1; + else { + sVar1 = strlen(s); + if ((int)sVar1 < 0xffff) { + (*this->_vptr_TWriteStream[2])(this,sVar1 & 0xffff); + } + else { + // try { // try from 0804d5b7 to 0804d610 has its CatchHandler @ 0804d613 + (*this->_vptr_TWriteStream[2])(this,0xffff); + (*this->_vptr_TWriteStream[3])(this,sVar1); + } + if (sVar1 != 0) { + (*this->_vptr_TWriteStream[5])(this,s,sVar1); + } + } + return; } -bool isEngAlpha(int c) +// DWARF original prototype: void writeBytes(TWriteStream * this, uchar * Buffer, int Count) + +void __thiscall TWriteStream::writeBytes(TWriteStream *this,uchar *Buffer,int Count) { - bool bVar1; + undefined4 *puVar1; + int i; + int iVar2; - bVar1 = false; - if ((c - 0x61U < 0x1a) || (c - 0x41U < 0x1a)) { - bVar1 = true; + if (Buffer == (uchar *)0x0) { + error(&DAT_080eec20); + puVar1 = (undefined4 *)__cxa_allocate_exception(4); + *puVar1 = "internal error"; + // WARNING: Subroutine does not return + __cxa_throw(puVar1,char_const*::typeinfo,0); } - return bVar1; + iVar2 = 0; + if (0 < Count) { + do { + // try { // try from 0804d673 to 0804d6b2 has its CatchHandler @ 0804d6b3 + (*this->_vptr_TWriteStream[1])(this,(uint)Buffer[iVar2]); + iVar2 = iVar2 + 1; + } while (iVar2 < Count); + } + return; } -bool isDigit(int c) +// DWARF original prototype: void TReadBuffer(TReadBuffer * this, uchar * data, int size) + +void __thiscall TReadBuffer::TReadBuffer(TReadBuffer *this,uchar *data,int size) { - return c - 0x30U < 10; + (this->super_TReadStream)._vptr_TReadStream = (_func_int_varargs **)&PTR_readFlag_081267c8; + this->Data = data; + this->Size = size; + this->Position = 0; + if (data == (uchar *)0x0) { + error("TReadBuffer::TReadBuffer: data ist NULL.\n"); + } + else { + if (-1 < size) { + return; + } + error(&DAT_080eec60,size); + } + this->Size = 0; + return; } -int toLower(int c) +// DWARF original prototype: void TReadBuffer(TReadBuffer * this, uchar * data, int size) + +void __thiscall TReadBuffer::TReadBuffer(TReadBuffer *this,uchar *data,int size) { - if ((c - 0x41U < 0x1a) || ((byte)((char)(c - 0x41U) + 0x81U) < 0x1f)) { - c = c + 0x20; + (this->super_TReadStream)._vptr_TReadStream = (_func_int_varargs **)&PTR_readFlag_081267c8; + this->Data = data; + this->Size = size; + this->Position = 0; + if (data == (uchar *)0x0) { + error("TReadBuffer::TReadBuffer: data ist NULL.\n"); } - return c; + else { + if (-1 < size) { + return; + } + error(&DAT_080eec60,size); + } + this->Size = 0; + return; } -int toUpper(int c) +// DWARF original prototype: uchar readByte(TReadBuffer * this) + +uchar __thiscall TReadBuffer::readByte(TReadBuffer *this) { - if ((c - 0x61U < 0x1a) || ((byte)((char)(c - 0x61U) + 0x81U) < 0x1f)) { - c = c + -0x20; + uchar uVar1; + int iVar2; + undefined4 *puVar3; + uchar b; + + iVar2 = this->Position; + if (iVar2 <= this->Size + -1) { + uVar1 = this->Data[iVar2]; + this->Position = iVar2 + 1; + return uVar1; } - return c; + puVar3 = (undefined4 *)__cxa_allocate_exception(4); + *puVar3 = "buffer empty"; + // WARNING: Subroutine does not return + // try { // try from 0804d7e3 to 0804d7e7 has its CatchHandler @ 0804d7e8 + __cxa_throw(puVar3,char_const*::typeinfo,0); } -char * strLower(char *s) +// DWARF original prototype: ushort readWord(TReadBuffer * this) + +ushort __thiscall TReadBuffer::readWord(TReadBuffer *this) { - char cVar1; - int i; - int iVar2; + uchar uVar1; + uchar uVar2; + int iVar3; + ushort w; + undefined4 *puVar4; - iVar2 = 0; - cVar1 = *s; - while (cVar1 != '\0') { - if (((int)cVar1 - 0x41U < 0x1a) || ((byte)((char)((int)cVar1 - 0x41U) + 0x81U) < 0x1f)) { - cVar1 = cVar1 + ' '; - } - s[iVar2] = cVar1; - iVar2 = iVar2 + 1; - cVar1 = s[iVar2]; + iVar3 = this->Position; + if (iVar3 <= this->Size + -2) { + uVar1 = this->Data[iVar3]; + uVar2 = this->Data[iVar3 + 1]; + this->Position = iVar3 + 2; + return CONCAT11(uVar2,uVar1); } - return s; + puVar4 = (undefined4 *)__cxa_allocate_exception(4); + *puVar4 = "buffer empty"; + // WARNING: Subroutine does not return + // try { // try from 0804d860 to 0804d864 has its CatchHandler @ 0804d865 + __cxa_throw(puVar4,char_const*::typeinfo,0); } -char * strUpper(char *s) +// DWARF original prototype: ulong readQuad(TReadBuffer * this) + +ulong __thiscall TReadBuffer::readQuad(TReadBuffer *this) { - char cVar1; - int i; - int iVar2; + uchar uVar1; + uchar uVar2; + uchar uVar3; + uchar uVar4; + int iVar5; + uchar *puVar6; + ulong q; + undefined4 *puVar7; - iVar2 = 0; - cVar1 = *s; - while (cVar1 != '\0') { - if (((int)cVar1 - 0x61U < 0x1a) || ((byte)((char)((int)cVar1 - 0x61U) + 0x81U) < 0x1f)) { - cVar1 = cVar1 + -0x20; - } - s[iVar2] = cVar1; - iVar2 = iVar2 + 1; - cVar1 = s[iVar2]; + iVar5 = this->Position; + if (iVar5 <= this->Size + -4) { + puVar6 = this->Data; + uVar1 = puVar6[iVar5 + 3]; + uVar2 = puVar6[iVar5 + 2]; + uVar3 = puVar6[iVar5 + 1]; + uVar4 = puVar6[iVar5]; + this->Position = iVar5 + 4; + return CONCAT31(CONCAT21(CONCAT11(uVar1,uVar2),uVar3),uVar4); } - return s; + puVar7 = (undefined4 *)__cxa_allocate_exception(4); + *puVar7 = "buffer empty"; + // WARNING: Subroutine does not return + // try { // try from 0804d8f6 to 0804d8fa has its CatchHandler @ 0804d8fb + __cxa_throw(puVar7,char_const*::typeinfo,0); } -int stricmp(char *s1,char *s2,int Pos) +// DWARF original prototype: void readBytes(TReadBuffer * this, uchar * Buffer, int Count) + +void __thiscall TReadBuffer::readBytes(TReadBuffer *this,uchar *Buffer,int Count) { - char cVar1; - int iVar2; - int iVar3; - int i; - int iVar4; + undefined4 *puVar1; - iVar4 = 0; - while( true ) { - if (iVar4 == Pos) { - return 0; - } - cVar1 = s1[iVar4]; - iVar2 = (int)cVar1; - if ((iVar2 - 0x41U < 0x1a) || ((byte)((char)(iVar2 - 0x41U) + 0x81U) < 0x1f)) { - iVar2 = iVar2 + 0x20; - } - iVar3 = (int)s2[iVar4]; - if ((iVar3 - 0x41U < 0x1a) || ((byte)((char)(iVar3 - 0x41U) + 0x81U) < 0x1f)) { - iVar3 = iVar3 + 0x20; - } - if (iVar3 < iVar2) break; - iVar2 = (int)cVar1; - if ((iVar2 - 0x41U < 0x1a) || ((byte)((char)(iVar2 - 0x41U) + 0x81U) < 0x1f)) { - iVar2 = iVar2 + 0x20; - } - iVar3 = (int)s2[iVar4]; - if ((iVar3 - 0x41U < 0x1a) || ((byte)((char)(iVar3 - 0x41U) + 0x81U) < 0x1f)) { - iVar3 = iVar3 + 0x20; - } - if (iVar2 < iVar3) { - return -1; - } - if (cVar1 == '\0') { - return 0; + if (Buffer == (uchar *)0x0) { + error(&DAT_080eece0); + puVar1 = (undefined4 *)__cxa_allocate_exception(4); + *puVar1 = "buffer not existing"; + } + else { + if (this->Position <= this->Size - Count) { + memcpy(Buffer,this->Data + this->Position,Count); + this->Position = this->Position + Count; + return; } - iVar4 = iVar4 + 1; + puVar1 = (undefined4 *)__cxa_allocate_exception(4); + *puVar1 = "buffer empty"; } - return 1; + // WARNING: Subroutine does not return + // try { // try from 0804d97c to 0804d98c has its CatchHandler @ 0804d9a1 + __cxa_throw(puVar1,char_const*::typeinfo,0); } -char * findFirst(char *s,char c) +// DWARF original prototype: bool eof(TReadBuffer * this) + +bool __thiscall TReadBuffer::eof(TReadBuffer *this) { - char *pcVar1; - - pcVar1 = strchr(s,(int)c); - return pcVar1; + return this->Size <= this->Position; } -char * findLast(char *s,char c) +// DWARF original prototype: void skip(TReadBuffer * this, int Count) + +void __thiscall TReadBuffer::skip(TReadBuffer *this,int Count) { - char *pcVar1; - char *p; - char *pcVar2; + undefined4 *puVar1; - pcVar2 = (char *)0x0; - while( true ) { - pcVar1 = strchr(s,(int)c); - if (pcVar1 == (char *)0x0) break; - s = pcVar1 + 1; - pcVar2 = pcVar1; + if (this->Position <= this->Size - Count) { + this->Position = Count + this->Position; + return; } - return pcVar2; + puVar1 = (undefined4 *)__cxa_allocate_exception(4); + *puVar1 = "buffer empty"; + // WARNING: Subroutine does not return + // try { // try from 0804da2d to 0804da31 has its CatchHandler @ 0804da32 + __cxa_throw(puVar1,char_const*::typeinfo,0); } -void SetPrintFunction(TPrintFunction *Function) +// DWARF original prototype: void TWriteBuffer(TWriteBuffer * this, uchar * data, int size) + +void __thiscall TWriteBuffer::TWriteBuffer(TWriteBuffer *this,uchar *data,int size) { - PrintFunction = Function; + (this->super_TWriteStream)._vptr_TWriteStream = (_func_int_varargs **)&PTR_writeFlag_081267a8; + this->Data = data; + this->Size = size; + this->Position = 0; + if (data == (uchar *)0x0) { + error("TWriteBuffer::TWriteBuffer: data ist NULL.\n"); + this->Size = 0; + } + else if (size < 0) { + error(&DAT_080eed20); + return; + } return; } -void SetErrorFunction(TErrorFunction *Function) +// DWARF original prototype: void TWriteBuffer(TWriteBuffer * this, uchar * data, int size) + +void __thiscall TWriteBuffer::TWriteBuffer(TWriteBuffer *this,uchar *data,int size) { - ErrorFunction = Function; + (this->super_TWriteStream)._vptr_TWriteStream = (_func_int_varargs **)&PTR_writeFlag_081267a8; + this->Data = data; + this->Size = size; + this->Position = 0; + if (data == (uchar *)0x0) { + error("TWriteBuffer::TWriteBuffer: data ist NULL.\n"); + this->Size = 0; + } + else if (size < 0) { + error(&DAT_080eed20); + return; + } return; } -void SilentHandler(int param_1,char *param_2) +// DWARF original prototype: void writeByte(TWriteBuffer * this, uchar b) + +void __thiscall TWriteBuffer::writeByte(TWriteBuffer *this,uchar b) { - return; + undefined4 *puVar1; + + if (this->Position <= this->Size + -1) { + this->Data[this->Position] = b; + this->Position = this->Position + 1; + return; + } + puVar1 = (undefined4 *)__cxa_allocate_exception(4); + *puVar1 = "buffer full"; + // WARNING: Subroutine does not return + // try { // try from 0804db5f to 0804db63 has its CatchHandler @ 0804db64 + __cxa_throw(puVar1,char_const*::typeinfo,0); } -void SilentHandler(char *param_1) +// DWARF original prototype: void writeWord(TWriteBuffer * this, ushort w) + +void __thiscall TWriteBuffer::writeWord(TWriteBuffer *this,ushort w) { - return; + undefined4 *puVar1; + + if (this->Position <= this->Size + -2) { + this->Data[this->Position] = (uchar)w; + this->Data[this->Position + 1] = (uchar)(w >> 8); + this->Position = this->Position + 2; + return; + } + puVar1 = (undefined4 *)__cxa_allocate_exception(4); + *puVar1 = "buffer full"; + // WARNING: Subroutine does not return + // try { // try from 0804dbe0 to 0804dbe4 has its CatchHandler @ 0804dbe5 + __cxa_throw(puVar1,char_const*::typeinfo,0); } -void LogfileHandler(int param_1,char *Text) +// DWARF original prototype: void writeQuad(TWriteBuffer * this, ulong q) + +void __thiscall TWriteBuffer::writeQuad(TWriteBuffer *this,ulong q) { - FILE *__stream; - int iVar1; - FILE *f; + undefined4 *puVar1; - if (StandardLogfile[0] != '\0') { - __stream = fopen(StandardLogfile,"at"); - if (__stream != (FILE *)0x0) { - fprintf(__stream,"%s",Text); - iVar1 = fclose(__stream); - if (iVar1 != 0) { - __errno_location(); - error(&DAT_080eeb60); - return; - } - } + if (this->Position <= this->Size + -4) { + this->Data[this->Position] = (uchar)q; + this->Data[this->Position + 1] = (uchar)(q >> 8); + this->Data[this->Position + 2] = (uchar)(q >> 0x10); + this->Data[this->Position + 3] = (uchar)(q >> 0x18); + this->Position = this->Position + 4; + return; } - return; + puVar1 = (undefined4 *)__cxa_allocate_exception(4); + *puVar1 = "buffer full"; + // WARNING: Subroutine does not return + // try { // try from 0804dc79 to 0804dc7d has its CatchHandler @ 0804dc7e + __cxa_throw(puVar1,char_const*::typeinfo,0); } -void LogfileHandler(char *Text) +// DWARF original prototype: void writeBytes(TWriteBuffer * this, uchar * Buffer, int Count) + +void __thiscall TWriteBuffer::writeBytes(TWriteBuffer *this,uchar *Buffer,int Count) { - FILE *__stream; - int iVar1; - int *piVar2; - FILE *f; + undefined4 *puVar1; - if (StandardLogfile[0] != '\0') { - __stream = fopen(StandardLogfile,"at"); - if (__stream != (FILE *)0x0) { - fprintf(__stream,"%s",Text); - iVar1 = fclose(__stream); - if (iVar1 != 0) { - piVar2 = __errno_location(); - error(&DAT_080eeb60,*piVar2); - } - } + if (this->Position <= this->Size - Count) { + memcpy(this->Data + this->Position,Buffer,Count); + this->Position = this->Position + Count; + return; } - return; + puVar1 = (undefined4 *)__cxa_allocate_exception(4); + *puVar1 = "buffer full"; + // WARNING: Subroutine does not return + // try { // try from 0804dd08 to 0804dd0c has its CatchHandler @ 0804dd0d + __cxa_throw(puVar1,char_const*::typeinfo,0); } -// WARNING: Unknown calling convention -- yet parameter storage is locked +// DWARF original prototype: void TDynamicWriteBuffer(TDynamicWriteBuffer * this, int InitialSize) -void print(void) +void __thiscall TDynamicWriteBuffer::TDynamicWriteBuffer(TDynamicWriteBuffer *this,int InitialSize) { - int in_stack_00000004; - char *in_stack_00000008; - char local_40c [4]; - char s [1024]; + uchar *data; - vsnprintf(local_40c,0x400,in_stack_00000008,&stack0x0000000c); - if (PrintFunction == (TPrintFunction *)0x0) { - printf("%s",local_40c); - } - else { - (*PrintFunction)(in_stack_00000004,local_40c); - } + data = (uchar *)operator_new__(InitialSize); + TWriteBuffer::TWriteBuffer(&this->super_TWriteBuffer,data,InitialSize); + (this->super_TWriteBuffer).super_TWriteStream._vptr_TWriteStream = + (_func_int_varargs **)&PTR_writeFlag_08126768; return; } -// DWARF original prototype: bool readFlag(TReadStream * this) -bool __thiscall TReadStream::readFlag(TReadStream *this) +// DWARF original prototype: void TDynamicWriteBuffer(TDynamicWriteBuffer * this, int InitialSize) + +void __thiscall TDynamicWriteBuffer::TDynamicWriteBuffer(TDynamicWriteBuffer *this,int InitialSize) { - int iVar1; + uchar *data; - // try { // try from 0804d1ce to 0804d1d0 has its CatchHandler @ 0804d1e0 - iVar1 = (*this->_vptr_TReadStream[1])(this); - return (char)iVar1 != '\0'; + data = (uchar *)operator_new__(InitialSize); + TWriteBuffer::TWriteBuffer(&this->super_TWriteBuffer,data,InitialSize); + (this->super_TWriteBuffer).super_TWriteStream._vptr_TWriteStream = + (_func_int_varargs **)&PTR_writeFlag_08126768; + return; } -// WARNING: Variable defined which should be unmapped: Lo -// DWARF original prototype: ushort readWord(TReadStream * this) +// DWARF original prototype: void ~TDynamicWriteBuffer(TDynamicWriteBuffer * this, int __in_chrg) -ushort __thiscall TReadStream::readWord(TReadStream *this) +void __thiscall TDynamicWriteBuffer::~TDynamicWriteBuffer(TDynamicWriteBuffer *this,int __in_chrg) { - uchar Hi; - int iVar1; - uint uVar2; - uchar Lo; + uchar *puVar1; - // try { // try from 0804d211 to 0804d21e has its CatchHandler @ 0804d232 - iVar1 = (*this->_vptr_TReadStream[1])(this); - uVar2 = (*this->_vptr_TReadStream[1])(this); - return (ushort)(byte)iVar1 | (ushort)((uVar2 & 0xff) << 8); + (this->super_TWriteBuffer).super_TWriteStream._vptr_TWriteStream = + (_func_int_varargs **)&PTR_writeFlag_08126768; + puVar1 = (this->super_TWriteBuffer).Data; + if (puVar1 != (uchar *)0x0) { + operator_delete__(puVar1); + } + return; } -// WARNING: Variable defined which should be unmapped: hi -// DWARF original prototype: ulong readQuad(TReadStream * this) +// DWARF original prototype: void ~TDynamicWriteBuffer(TDynamicWriteBuffer * this, int __in_chrg) -ulong __thiscall TReadStream::readQuad(TReadStream *this) +void __thiscall TDynamicWriteBuffer::~TDynamicWriteBuffer(TDynamicWriteBuffer *this,int __in_chrg) { - int iVar1; - int iVar2; - int iVar3; - int iVar4; - uchar Hi; - uchar hi; - uchar lo; - uchar Lo; + uchar *puVar1; - // try { // try from 0804d261 to 0804d284 has its CatchHandler @ 0804d2b0 - iVar1 = (*this->_vptr_TReadStream[1])(this); - iVar2 = (*this->_vptr_TReadStream[1])(this); - iVar3 = (*this->_vptr_TReadStream[1])(this); - iVar4 = (*this->_vptr_TReadStream[1])(this); - return (uint)CONCAT12((char)iVar3,CONCAT11((char)iVar2,(char)iVar1)) | iVar4 << 0x18; + (this->super_TWriteBuffer).super_TWriteStream._vptr_TWriteStream = + (_func_int_varargs **)&PTR_writeFlag_08126768; + puVar1 = (this->super_TWriteBuffer).Data; + if (puVar1 != (uchar *)0x0) { + operator_delete__(puVar1); + } + return; } -// DWARF original prototype: void readString(TReadStream * this, char * Buffer, int MaxLength) +// DWARF original prototype: void ~TDynamicWriteBuffer(TDynamicWriteBuffer * this, int __in_chrg) -void __thiscall TReadStream::readString(TReadStream *this,char *Buffer,int MaxLength) +void __thiscall TDynamicWriteBuffer::~TDynamicWriteBuffer(TDynamicWriteBuffer *this,int __in_chrg) { - uint uVar1; - undefined4 *puVar2; - int Length; + uchar *puVar1; - if (Buffer != (char *)0x0) { - // try { // try from 0804d2f2 to 0804d3a4 has its CatchHandler @ 0804d3a5 - uVar1 = (*this->_vptr_TReadStream[2])(this); - uVar1 = uVar1 & 0xffff; - if (uVar1 == 0xffff) { - uVar1 = (*this->_vptr_TReadStream[3])(this); - } - *Buffer = '\0'; - if (uVar1 != 0) { - if ((MaxLength < 0) || ((int)uVar1 < MaxLength)) { - (*this->_vptr_TReadStream[5])(this,Buffer,uVar1); - Buffer[uVar1] = '\0'; - } - else { - (*this->_vptr_TReadStream[5])(this,Buffer,MaxLength + -1); - Buffer[MaxLength + -1] = '\0'; - (*this->_vptr_TReadStream[7])(this,(uVar1 - MaxLength) + 1); - } - } - return; + puVar1 = (this->super_TWriteBuffer).Data; + (this->super_TWriteBuffer).super_TWriteStream._vptr_TWriteStream = + (_func_int_varargs **)&PTR_writeFlag_08126768; + if (puVar1 != (uchar *)0x0) { + operator_delete__(puVar1); } - error(&DAT_080eeba0); - puVar2 = (undefined4 *)__cxa_allocate_exception(4); - *puVar2 = "internal error"; - // WARNING: Subroutine does not return - __cxa_throw(puVar2,char_const*::typeinfo,0); + operator_delete(this); + return; } -// DWARF original prototype: void readBytes(TReadStream * this, uchar * Buffer, int Count) +// DWARF original prototype: void resizeBuffer(TDynamicWriteBuffer * this) -void __thiscall TReadStream::readBytes(TReadStream *this,uchar *Buffer,int Count) +void __thiscall TDynamicWriteBuffer::resizeBuffer(TDynamicWriteBuffer *this) { - int iVar1; - undefined4 *puVar2; - int i; - int iVar3; + int *piVar1; + uchar *puVar2; + uchar *__dest; + uchar *Help; - if (Buffer == (uchar *)0x0) { - error(&DAT_080eebe0); - puVar2 = (undefined4 *)__cxa_allocate_exception(4); - *puVar2 = "internal error"; - // WARNING: Subroutine does not return - __cxa_throw(puVar2,char_const*::typeinfo,0); + __dest = (uchar *)operator_new__((this->super_TWriteBuffer).Size * 2); + memcpy(__dest,(this->super_TWriteBuffer).Data,(this->super_TWriteBuffer).Size); + puVar2 = (this->super_TWriteBuffer).Data; + if (puVar2 != (uchar *)0x0) { + operator_delete__(puVar2); } - iVar3 = 0; - if (0 < Count) { + piVar1 = &(this->super_TWriteBuffer).Size; + *piVar1 = *piVar1 << 1; + (this->super_TWriteBuffer).Data = __dest; + return; +} + + + +// WARNING: Variable defined which should be unmapped: b_local +// DWARF original prototype: void writeByte(TDynamicWriteBuffer * this, uchar b) + +void __thiscall TDynamicWriteBuffer::writeByte(TDynamicWriteBuffer *this,uchar b) + +{ + int *piVar1; + uchar *puVar2; + uchar *__dest; + int iVar3; + int iVar4; + uchar *Help; + uchar b_local; + + iVar3 = (this->super_TWriteBuffer).Size; + iVar4 = (this->super_TWriteBuffer).Position; + if (iVar3 + -1 < iVar4) { do { - // try { // try from 0804d3f5 to 0804d43a has its CatchHandler @ 0804d440 - iVar1 = (*this->_vptr_TReadStream[1])(this); - Buffer[iVar3] = (uchar)iVar1; - iVar3 = iVar3 + 1; - } while (iVar3 < Count); + // try { // try from 0804dee6 to 0804deea has its CatchHandler @ 0804df30 + __dest = (uchar *)operator_new__(iVar3 * 2); + memcpy(__dest,(this->super_TWriteBuffer).Data,(this->super_TWriteBuffer).Size); + puVar2 = (this->super_TWriteBuffer).Data; + if (puVar2 != (uchar *)0x0) { + operator_delete__(puVar2); + } + (this->super_TWriteBuffer).Data = __dest; + iVar4 = (this->super_TWriteBuffer).Position; + iVar3 = (this->super_TWriteBuffer).Size * 2; + (this->super_TWriteBuffer).Size = iVar3; + } while (iVar3 + -1 < iVar4); } + (this->super_TWriteBuffer).Data[iVar4] = b; + piVar1 = &(this->super_TWriteBuffer).Position; + *piVar1 = *piVar1 + 1; return; } -// DWARF original prototype: void writeFlag(TWriteStream * this, bool f) +// DWARF original prototype: void writeWord(TDynamicWriteBuffer * this, ushort w) -void __thiscall TWriteStream::writeFlag(TWriteStream *this,bool f) +void __thiscall TDynamicWriteBuffer::writeWord(TDynamicWriteBuffer *this,ushort w) { - // try { // try from 0804d47b to 0804d47d has its CatchHandler @ 0804d482 - (*this->_vptr_TWriteStream[1])(this,(uint)f); + int *piVar1; + uchar *puVar2; + uchar *__dest; + int iVar3; + int iVar4; + uchar *Help; + + iVar3 = (this->super_TWriteBuffer).Size; + iVar4 = (this->super_TWriteBuffer).Position; + if (iVar3 + -2 < iVar4) { + do { + // try { // try from 0804dfa6 to 0804dfaa has its CatchHandler @ 0804dff0 + __dest = (uchar *)operator_new__(iVar3 * 2); + memcpy(__dest,(this->super_TWriteBuffer).Data,(this->super_TWriteBuffer).Size); + puVar2 = (this->super_TWriteBuffer).Data; + if (puVar2 != (uchar *)0x0) { + operator_delete__(puVar2); + } + (this->super_TWriteBuffer).Data = __dest; + iVar4 = (this->super_TWriteBuffer).Position; + iVar3 = (this->super_TWriteBuffer).Size * 2; + (this->super_TWriteBuffer).Size = iVar3; + } while (iVar3 + -2 < iVar4); + } + (this->super_TWriteBuffer).Data[iVar4] = (uchar)w; + (this->super_TWriteBuffer).Data[(this->super_TWriteBuffer).Position + 1] = (uchar)(w >> 8); + piVar1 = &(this->super_TWriteBuffer).Position; + *piVar1 = *piVar1 + 2; return; } -// DWARF original prototype: void writeWord(TWriteStream * this, ushort w) +// DWARF original prototype: void writeQuad(TDynamicWriteBuffer * this, ulong q) -void __thiscall TWriteStream::writeWord(TWriteStream *this,ushort w) +void __thiscall TDynamicWriteBuffer::writeQuad(TDynamicWriteBuffer *this,ulong q) { - // try { // try from 0804d4c1 to 0804d4d7 has its CatchHandler @ 0804d4e2 - (*this->_vptr_TWriteStream[1])(this,w & 0xff); - (*this->_vptr_TWriteStream[1])(this,w >> 8); + int *piVar1; + uchar *puVar2; + uchar *__dest; + int iVar3; + int iVar4; + uchar *Help; + + iVar3 = (this->super_TWriteBuffer).Size; + iVar4 = (this->super_TWriteBuffer).Position; + if (iVar3 + -4 < iVar4) { + do { + // try { // try from 0804e076 to 0804e07a has its CatchHandler @ 0804e0c0 + __dest = (uchar *)operator_new__(iVar3 * 2); + memcpy(__dest,(this->super_TWriteBuffer).Data,(this->super_TWriteBuffer).Size); + puVar2 = (this->super_TWriteBuffer).Data; + if (puVar2 != (uchar *)0x0) { + operator_delete__(puVar2); + } + (this->super_TWriteBuffer).Data = __dest; + iVar4 = (this->super_TWriteBuffer).Position; + iVar3 = (this->super_TWriteBuffer).Size * 2; + (this->super_TWriteBuffer).Size = iVar3; + } while (iVar3 + -4 < iVar4); + } + (this->super_TWriteBuffer).Data[iVar4] = (uchar)q; + (this->super_TWriteBuffer).Data[(this->super_TWriteBuffer).Position + 1] = (uchar)(q >> 8); + (this->super_TWriteBuffer).Data[(this->super_TWriteBuffer).Position + 2] = (uchar)(q >> 0x10); + (this->super_TWriteBuffer).Data[(this->super_TWriteBuffer).Position + 3] = (uchar)(q >> 0x18); + piVar1 = &(this->super_TWriteBuffer).Position; + *piVar1 = *piVar1 + 4; return; } -// DWARF original prototype: void writeQuad(TWriteStream * this, ulong q) +// DWARF original prototype: void writeBytes(TDynamicWriteBuffer * this, uchar * Buffer, int Count) -void __thiscall TWriteStream::writeQuad(TWriteStream *this,ulong q) +void __thiscall TDynamicWriteBuffer::writeBytes(TDynamicWriteBuffer *this,uchar *Buffer,int Count) { - // try { // try from 0804d51e to 0804d553 has its CatchHandler @ 0804d560 - (*this->_vptr_TWriteStream[1])(this,q & 0xff); - (*this->_vptr_TWriteStream[1])(this,q >> 8 & 0xff); - (*this->_vptr_TWriteStream[1])(this,q >> 0x10 & 0xff); - (*this->_vptr_TWriteStream[1])(this,q >> 0x18); + int *piVar1; + uchar *puVar2; + uchar *__dest; + int iVar3; + int iVar4; + uchar *Help; + + iVar3 = (this->super_TWriteBuffer).Size; + iVar4 = (this->super_TWriteBuffer).Position; + if (iVar3 - Count < iVar4) { + do { + // try { // try from 0804e136 to 0804e13a has its CatchHandler @ 0804e180 + __dest = (uchar *)operator_new__(iVar3 * 2); + memcpy(__dest,(this->super_TWriteBuffer).Data,(this->super_TWriteBuffer).Size); + puVar2 = (this->super_TWriteBuffer).Data; + if (puVar2 != (uchar *)0x0) { + operator_delete__(puVar2); + } + (this->super_TWriteBuffer).Data = __dest; + iVar4 = (this->super_TWriteBuffer).Position; + iVar3 = (this->super_TWriteBuffer).Size * 2; + (this->super_TWriteBuffer).Size = iVar3; + } while (iVar3 - Count < iVar4); + } + memcpy((this->super_TWriteBuffer).Data + iVar4,Buffer,Count); + piVar1 = &(this->super_TWriteBuffer).Position; + *piVar1 = *piVar1 + Count; return; } -// DWARF original prototype: void writeString(TWriteStream * this, char * s) - -void __thiscall TWriteStream::writeString(TWriteStream *this,char *s) +int val(char c) { - size_t sVar1; + int iVar1; - if (s == (char *)0x0) { - (*this->_vptr_TWriteStream[2])(this,0); + if ((byte)(c - 0x30U) < 10) { + iVar1 = c + -0x30; + } + else if ((byte)(c + 0xbfU) < 6) { + iVar1 = c + -0x37; + } + else if ((byte)(c + 0x9fU) < 6) { + iVar1 = c + -0x57; } else { - sVar1 = strlen(s); - if ((int)sVar1 < 0xffff) { - (*this->_vptr_TWriteStream[2])(this,sVar1 & 0xffff); - } - else { - // try { // try from 0804d5b7 to 0804d610 has its CatchHandler @ 0804d613 - (*this->_vptr_TWriteStream[2])(this,0xffff); - (*this->_vptr_TWriteStream[3])(this,sVar1); - } - if (sVar1 != 0) { - (*this->_vptr_TWriteStream[5])(this,s,sVar1); - } + iVar1 = 0; } - return; + return iVar1; } -// DWARF original prototype: void writeBytes(TWriteStream * this, uchar * Buffer, int Count) +// WARNING: Unknown calling convention -- yet parameter storage is locked -void __thiscall TWriteStream::writeBytes(TWriteStream *this,uchar *Buffer,int Count) +long random(void) { - undefined4 *puVar1; - int i; + int iVar1; int iVar2; + int range; + int in_stack_00000004; + int in_stack_00000008; - if (Buffer == (uchar *)0x0) { - error(&DAT_080eec20); - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "internal error"; - // WARNING: Subroutine does not return - __cxa_throw(puVar1,char_const*::typeinfo,0); - } - iVar2 = 0; - if (0 < Count) { - do { - // try { // try from 0804d673 to 0804d6b2 has its CatchHandler @ 0804d6b3 - (*this->_vptr_TWriteStream[1])(this,(uint)Buffer[iVar2]); - iVar2 = iVar2 + 1; - } while (iVar2 < Count); + iVar1 = (in_stack_00000008 - in_stack_00000004) + 1; + if (0 < iVar1) { + iVar2 = rand(); + in_stack_00000004 = iVar2 % iVar1 + in_stack_00000004; } - return; + return in_stack_00000004; } -// DWARF original prototype: void TReadBuffer(TReadBuffer * this, uchar * data, int size) - -void __thiscall TReadBuffer::TReadBuffer(TReadBuffer *this,uchar *data,int size) +bool FileExists(char *FileName) { - (this->super_TReadStream)._vptr_TReadStream = (_func_int_varargs **)&PTR_readFlag_081267c8; - this->Data = data; - this->Size = size; - this->Position = 0; - if (data == (uchar *)0x0) { - error("TReadBuffer::TReadBuffer: data ist NULL.\n"); - } - else { - if (-1 < size) { - return; + int *piVar1; + int iVar2; + bool bVar3; + undefined1 local_6c [4]; + stat Buffer; + + piVar1 = __errno_location(); + *piVar1 = 0; + iVar2 = __xstat(3,FileName,(stat *)local_6c); + bVar3 = true; + if (iVar2 != 0) { + if (*piVar1 != 2) { + error("FileExists: Unerwarteter Fehlercode %d.\n",*piVar1); } - error(&DAT_080eec60,size); + bVar3 = false; } - this->Size = 0; - return; + return bVar3; } -// DWARF original prototype: void TReadBuffer(TReadBuffer * this, uchar * data, int size) - -void __thiscall TReadBuffer::TReadBuffer(TReadBuffer *this,uchar *data,int size) +void TreatAllFiles(char *Directory,char *Extension,TFileHandlerFunction *Function) { - (this->super_TReadStream)._vptr_TReadStream = (_func_int_varargs **)&PTR_readFlag_081267c8; - this->Data = data; - this->Size = size; - this->Position = 0; - if (data == (uchar *)0x0) { - error("TReadBuffer::TReadBuffer: data ist NULL.\n"); - } - else { - if (-1 < size) { - return; + uint *__dest; + dirent *DirectoryEntry; + DIR *__dirp; + dirent *pdVar1; + char *pcVar2; + size_t sVar3; + int iVar4; + uint uVar5; + uint uVar6; + uint *puVar7; + uint *puVar8; + DIR *WorkingDirectory; + bool bVar9; + char local_105c [4]; + char Name [64]; + char FileName [4096]; + + __dirp = opendir(Directory); + if (__dirp != (DIR *)0x0) { + while (pdVar1 = readdir(__dirp), pdVar1 != (dirent *)0x0) { + __dest = (uint *)(Name + 0x3c); + strcpy((char *)__dest,pdVar1->d_name); + puVar8 = __dest; + do { + puVar7 = puVar8; + uVar5 = *puVar7 + 0xfefefeff & ~*puVar7; + uVar6 = uVar5 & 0x80808080; + puVar8 = puVar7 + 1; + } while (uVar6 == 0); + bVar9 = (uVar5 & 0x8080) == 0; + if (bVar9) { + uVar6 = uVar6 >> 0x10; + } + if (bVar9) { + puVar8 = (uint *)((int)puVar7 + 6); + } + pcVar2 = (char *)strlen(Extension); + puVar7 = __dest; + if (pcVar2 < (char *)((int)puVar8 + + ((-3 - (uint)CARRY1((byte)uVar6,(byte)uVar6)) - (int)__dest))) { + do { + puVar8 = puVar7; + uVar5 = *puVar8 + 0xfefefeff & ~*puVar8; + uVar6 = uVar5 & 0x80808080; + puVar7 = puVar8 + 1; + } while (uVar6 == 0); + bVar9 = (uVar5 & 0x8080) == 0; + if (bVar9) { + uVar6 = uVar6 >> 0x10; + } + puVar7 = (uint *)((int)puVar8 + 6); + if (!bVar9) { + puVar7 = puVar8 + 1; + } + sVar3 = strlen(Extension); + iVar4 = strcmp((char *)((int)puVar7 + + ((-3 - (uint)CARRY1((byte)uVar6,(byte)uVar6)) - sVar3)), + Extension); + if (iVar4 == 0) { + local_105c[0] = '\0'; + local_105c[1] = '\0'; + local_105c[2] = '\0'; + local_105c[3] = '\0'; + Name[0] = '\0'; + Name[1] = '\0'; + Name[2] = '\0'; + Name[3] = '\0'; + Name[4] = '\0'; + Name[5] = '\0'; + Name[6] = '\0'; + Name[7] = '\0'; + Name[0xc] = '\0'; + Name[0xd] = '\0'; + Name[0xe] = '\0'; + Name[0xf] = '\0'; + Name[0x10] = '\0'; + Name[0x11] = '\0'; + Name[0x12] = '\0'; + Name[0x13] = '\0'; + Name[0x14] = '\0'; + Name[0x15] = '\0'; + Name[0x16] = '\0'; + Name[0x17] = '\0'; + Name[0x18] = '\0'; + Name[0x19] = '\0'; + Name[0x1a] = '\0'; + Name[0x1b] = '\0'; + Name[0x1c] = '\0'; + Name[0x1d] = '\0'; + Name[0x1e] = '\0'; + Name[0x1f] = '\0'; + Name[8] = '\0'; + Name[9] = '\0'; + Name[10] = '\0'; + Name[0xb] = '\0'; + Name[0x20] = '\0'; + Name[0x21] = '\0'; + Name[0x22] = '\0'; + Name[0x23] = '\0'; + Name[0x24] = '\0'; + Name[0x25] = '\0'; + Name[0x26] = '\0'; + Name[0x27] = '\0'; + Name[0x28] = '\0'; + Name[0x29] = '\0'; + Name[0x2a] = '\0'; + Name[0x2b] = '\0'; + Name[0x30] = '\0'; + Name[0x31] = '\0'; + Name[0x32] = '\0'; + Name[0x33] = '\0'; + Name[0x34] = '\0'; + Name[0x35] = '\0'; + Name[0x36] = '\0'; + Name[0x37] = '\0'; + Name[0x2c] = '\0'; + Name[0x2d] = '\0'; + Name[0x2e] = '\0'; + Name[0x2f] = '\0'; + Name[0x38] = '\0'; + Name[0x39] = '\0'; + Name[0x3a] = '\0'; + Name[0x3b] = '\0'; + puVar8 = __dest; + do { + puVar7 = puVar8; + uVar5 = *puVar7 + 0xfefefeff & ~*puVar7; + uVar6 = uVar5 & 0x80808080; + puVar8 = puVar7 + 1; + } while (uVar6 == 0); + bVar9 = (uVar5 & 0x8080) == 0; + if (bVar9) { + uVar6 = uVar6 >> 0x10; + } + if (bVar9) { + puVar8 = (uint *)((int)puVar7 + 6); + } + sVar3 = strlen(Extension); + strncpy(local_105c,(char *)__dest, + (size_t)((int)puVar8 + + (((-3 - (uint)CARRY1((byte)uVar6,(byte)uVar6)) - (int)__dest) - + sVar3))); + (*Function)(Directory,local_105c,Extension); + } + } } - error(&DAT_080eec60,size); + closedir(__dirp); } - this->Size = 0; return; } -// DWARF original prototype: uchar readByte(TReadBuffer * this) - -uchar __thiscall TReadBuffer::readByte(TReadBuffer *this) +void SendMail(char *Address,char *Subject,char *Text) { - uchar uVar1; + uint *puVar1; int iVar2; - undefined4 *puVar3; - uchar b; + size_t sVar3; + int iVar4; + __pid_t _Var5; + int *piVar6; + uint *puVar7; + uint *puVar8; + uint uVar9; + uint uVar10; + char_0_ *Content; + bool bVar11; + int iStack_b0; + uint auStack_94 [4]; + undefined4 local_84; + int inode [2]; + stat StatBuffer; - iVar2 = this->Position; - if (iVar2 <= this->Size + -1) { - uVar1 = this->Data[iVar2]; - this->Position = iVar2 + 1; - return uVar1; + iStack_b0 = 0x804e4b9; + sVar3 = strlen(Text); + iVar2 = -(sVar3 + 0x7df & 0xfffffff0); + *(undefined1 *)((int)auStack_94 + iVar2) = 0; + puVar1 = (uint *)((int)auStack_94 + iVar2); + puVar8 = puVar1; + do { + puVar7 = puVar8; + uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; + uVar10 = uVar9 & 0x80808080; + puVar8 = puVar7 + 1; + } while (uVar10 == 0); + bVar11 = (uVar9 & 0x8080) == 0; + if (bVar11) { + uVar10 = uVar10 >> 0x10; } - puVar3 = (undefined4 *)__cxa_allocate_exception(4); - *puVar3 = "buffer empty"; - // WARNING: Subroutine does not return - // try { // try from 0804d7e3 to 0804d7e7 has its CatchHandler @ 0804d7e8 - __cxa_throw(puVar3,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: ushort readWord(TReadBuffer * this) - -ushort __thiscall TReadBuffer::readWord(TReadBuffer *this) - -{ - uchar uVar1; - uchar uVar2; - int iVar3; - ushort w; - undefined4 *puVar4; - - iVar3 = this->Position; - if (iVar3 <= this->Size + -2) { - uVar1 = this->Data[iVar3]; - uVar2 = this->Data[iVar3 + 1]; - this->Position = iVar3 + 2; - return CONCAT11(uVar2,uVar1); + if (bVar11) { + puVar8 = (uint *)((int)puVar7 + 6); } - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "buffer empty"; - // WARNING: Subroutine does not return - // try { // try from 0804d860 to 0804d864 has its CatchHandler @ 0804d865 - __cxa_throw(puVar4,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: ulong readQuad(TReadBuffer * this) - -ulong __thiscall TReadBuffer::readQuad(TReadBuffer *this) - -{ - uchar uVar1; - uchar uVar2; - uchar uVar3; - uchar uVar4; - int iVar5; - uchar *puVar6; - ulong q; - undefined4 *puVar7; - - iVar5 = this->Position; - if (iVar5 <= this->Size + -4) { - puVar6 = this->Data; - uVar1 = puVar6[iVar5 + 3]; - uVar2 = puVar6[iVar5 + 2]; - uVar3 = puVar6[iVar5 + 1]; - uVar4 = puVar6[iVar5]; - this->Position = iVar5 + 4; - return CONCAT31(CONCAT21(CONCAT11(uVar1,uVar2),uVar3),uVar4); + *(char **)(&stack0xffffff58 + iVar2) = "From: %s\n"; + *(uint *)((int)auStack_94 + iVar2 + -0x18) = + (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); + *(char **)(&stack0xffffff5c + iVar2) = SendMail::sender; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e519; + sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); + puVar8 = puVar1; + do { + puVar7 = puVar8; + uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; + uVar10 = uVar9 & 0x80808080; + puVar8 = puVar7 + 1; + } while (uVar10 == 0); + bVar11 = (uVar9 & 0x8080) == 0; + if (bVar11) { + uVar10 = uVar10 >> 0x10; } - puVar7 = (undefined4 *)__cxa_allocate_exception(4); - *puVar7 = "buffer empty"; - // WARNING: Subroutine does not return - // try { // try from 0804d8f6 to 0804d8fa has its CatchHandler @ 0804d8fb - __cxa_throw(puVar7,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: void readBytes(TReadBuffer * this, uchar * Buffer, int Count) - -void __thiscall TReadBuffer::readBytes(TReadBuffer *this,uchar *Buffer,int Count) - -{ - undefined4 *puVar1; - - if (Buffer == (uchar *)0x0) { - error(&DAT_080eece0); - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "buffer not existing"; + if (bVar11) { + puVar8 = (uint *)((int)puVar7 + 6); } - else { - if (this->Position <= this->Size - Count) { - memcpy(Buffer,this->Data + this->Position,Count); - this->Position = this->Position + Count; - return; - } - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "buffer empty"; + *(char **)(&stack0xffffff58 + iVar2) = "To: %s\n"; + *(uint *)((int)auStack_94 + iVar2 + -0x18) = + (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); + *(char **)(&stack0xffffff5c + iVar2) = Address; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e567; + sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); + puVar8 = puVar1; + do { + puVar7 = puVar8; + uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; + uVar10 = uVar9 & 0x80808080; + puVar8 = puVar7 + 1; + } while (uVar10 == 0); + bVar11 = (uVar9 & 0x8080) == 0; + if (bVar11) { + uVar10 = uVar10 >> 0x10; } - // WARNING: Subroutine does not return - // try { // try from 0804d97c to 0804d98c has its CatchHandler @ 0804d9a1 - __cxa_throw(puVar1,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: bool eof(TReadBuffer * this) - -bool __thiscall TReadBuffer::eof(TReadBuffer *this) - -{ - return this->Size <= this->Position; -} - - - -// DWARF original prototype: void skip(TReadBuffer * this, int Count) - -void __thiscall TReadBuffer::skip(TReadBuffer *this,int Count) - -{ - undefined4 *puVar1; - - if (this->Position <= this->Size - Count) { - this->Position = Count + this->Position; - return; + if (bVar11) { + puVar8 = (uint *)((int)puVar7 + 6); } - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "buffer empty"; - // WARNING: Subroutine does not return - // try { // try from 0804da2d to 0804da31 has its CatchHandler @ 0804da32 - __cxa_throw(puVar1,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: void TWriteBuffer(TWriteBuffer * this, uchar * data, int size) - -void __thiscall TWriteBuffer::TWriteBuffer(TWriteBuffer *this,uchar *data,int size) - -{ - (this->super_TWriteStream)._vptr_TWriteStream = (_func_int_varargs **)&PTR_writeFlag_081267a8; - this->Data = data; - this->Size = size; - this->Position = 0; - if (data == (uchar *)0x0) { - error("TWriteBuffer::TWriteBuffer: data ist NULL.\n"); - this->Size = 0; + *(char **)(&stack0xffffff58 + iVar2) = "Subject: %s\n"; + *(uint *)((int)auStack_94 + iVar2 + -0x18) = + (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); + *(char **)(&stack0xffffff5c + iVar2) = Subject; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e5b7; + sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); + puVar8 = puVar1; + do { + puVar7 = puVar8; + uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; + uVar10 = uVar9 & 0x80808080; + puVar8 = puVar7 + 1; + } while (uVar10 == 0); + bVar11 = (uVar9 & 0x8080) == 0; + if (bVar11) { + uVar10 = uVar10 >> 0x10; } - else if (size < 0) { - error(&DAT_080eed20); - return; + if (bVar11) { + puVar8 = (uint *)((int)puVar7 + 6); } - return; -} - - - -// DWARF original prototype: void TWriteBuffer(TWriteBuffer * this, uchar * data, int size) - -void __thiscall TWriteBuffer::TWriteBuffer(TWriteBuffer *this,uchar *data,int size) - -{ - (this->super_TWriteStream)._vptr_TWriteStream = (_func_int_varargs **)&PTR_writeFlag_081267a8; - this->Data = data; - this->Size = size; - this->Position = 0; - if (data == (uchar *)0x0) { - error("TWriteBuffer::TWriteBuffer: data ist NULL.\n"); - this->Size = 0; + *(char **)(&stack0xffffff58 + iVar2) = "Reply-To: %s\n"; + *(uint *)((int)auStack_94 + iVar2 + -0x18) = + (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); + *(char **)(&stack0xffffff5c + iVar2) = SendMail::replyto; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e609; + sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); + puVar8 = puVar1; + do { + puVar7 = puVar8; + uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; + uVar10 = uVar9 & 0x80808080; + puVar8 = puVar7 + 1; + } while (uVar10 == 0); + bVar11 = (uVar9 & 0x8080) == 0; + if (bVar11) { + uVar10 = uVar10 >> 0x10; } - else if (size < 0) { - error(&DAT_080eed20); - return; + if (bVar11) { + puVar8 = (uint *)((int)puVar7 + 6); } - return; -} - - - -// DWARF original prototype: void writeByte(TWriteBuffer * this, uchar b) - -void __thiscall TWriteBuffer::writeByte(TWriteBuffer *this,uchar b) - -{ - undefined4 *puVar1; - - if (this->Position <= this->Size + -1) { - this->Data[this->Position] = b; - this->Position = this->Position + 1; - return; + *(char **)(&stack0xffffff58 + iVar2) = "X-Mailer: %s\n"; + *(uint *)((int)auStack_94 + iVar2 + -0x18) = + (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); + *(char **)(&stack0xffffff5c + iVar2) = SendMail::xmailer; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e659; + sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); + puVar8 = puVar1; + do { + puVar7 = puVar8; + uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; + uVar10 = uVar9 & 0x80808080; + puVar8 = puVar7 + 1; + } while (uVar10 == 0); + *(char **)(&stack0xffffff58 + iVar2) = "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; + bVar11 = (uVar9 & 0x8080) == 0; + if (bVar11) { + uVar10 = uVar10 >> 0x10; } - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "buffer full"; - // WARNING: Subroutine does not return - // try { // try from 0804db5f to 0804db63 has its CatchHandler @ 0804db64 - __cxa_throw(puVar1,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: void writeWord(TWriteBuffer * this, ushort w) - -void __thiscall TWriteBuffer::writeWord(TWriteBuffer *this,ushort w) - -{ - undefined4 *puVar1; - - if (this->Position <= this->Size + -2) { - this->Data[this->Position] = (uchar)w; - this->Data[this->Position + 1] = (uchar)(w >> 8); - this->Position = this->Position + 2; - return; + if (bVar11) { + puVar8 = (uint *)((int)puVar7 + 6); } - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "buffer full"; + *(uint *)((int)auStack_94 + iVar2 + -0x18) = + (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e6a0; + sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); + puVar8 = puVar1; + do { + puVar7 = puVar8; + uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; + uVar10 = uVar9 & 0x80808080; + puVar8 = puVar7 + 1; + } while (uVar10 == 0); + *(char **)(&stack0xffffff58 + iVar2) = "\n"; + bVar11 = (uVar9 & 0x8080) == 0; + if (bVar11) { + uVar10 = uVar10 >> 0x10; + } + if (bVar11) { + puVar8 = (uint *)((int)puVar7 + 6); + } + *(uint *)((int)auStack_94 + iVar2 + -0x18) = + (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e6f0; + sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); + puVar8 = puVar1; + do { + puVar7 = puVar8; + uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; + uVar10 = uVar9 & 0x80808080; + puVar8 = puVar7 + 1; + } while (uVar10 == 0); + *(char **)(&stack0xffffff5c + iVar2) = Text; + *(char **)(&stack0xffffff58 + iVar2) = "%s\n"; + bVar11 = (uVar9 & 0x8080) == 0; + if (bVar11) { + uVar10 = uVar10 >> 0x10; + } + if (bVar11) { + puVar8 = (uint *)((int)puVar7 + 6); + } + *(uint *)((int)auStack_94 + iVar2 + -0x18) = + (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e744; + sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); + *(undefined4 *)((int)auStack_94 + iVar2 + -0x18) = 3; + *(int **)(&stack0xffffff5c + iVar2) = inode + 1; + *(char **)(&stack0xffffff58 + iVar2) = SendMail::mailer; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e761; + iVar4 = __xstat(*(int *)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2), + *(stat **)(&stack0xffffff5c + iVar2)); + if (iVar4 == 0) { + *(undefined4 **)((int)auStack_94 + iVar2 + -0x18) = &local_84; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e78f; + iVar4 = pipe(*(int **)((int)auStack_94 + iVar2 + -0x18)); + if (iVar4 == 0) { + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e7a6; + _Var5 = fork(); + if (-1 < _Var5) { + puVar8 = puVar1; + if (_Var5 == 0) { + *(undefined4 *)(&stack0xffffff58 + iVar2) = 0; + *(undefined4 *)((int)auStack_94 + iVar2 + -0x18) = local_84; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e86a; + dup2(*(int *)((int)auStack_94 + iVar2 + -0x18), + *(int *)(&stack0xffffff58 + iVar2)); + *(undefined4 *)((int)auStack_94 + iVar2 + -0x18) = local_84; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e875; + iVar4 = close(*(int *)((int)auStack_94 + iVar2 + -0x18)); + if (iVar4 < 0) { + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e8e8; + piVar6 = __errno_location(); + iVar4 = *piVar6; + *(undefined **)((int)auStack_94 + iVar2 + -0x18) = &DAT_080eefa0; + *(int *)(&stack0xffffff58 + iVar2) = iVar4; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e8fa; + error(*(char **)((int)auStack_94 + iVar2 + -0x18)); + } + *(int *)((int)auStack_94 + iVar2 + -0x18) = inode[0]; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e884; + iVar4 = close(*(int *)((int)auStack_94 + iVar2 + -0x18)); + if (iVar4 < 0) { + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e8cf; + piVar6 = __errno_location(); + iVar4 = *piVar6; + *(undefined **)((int)auStack_94 + iVar2 + -0x18) = &DAT_080eef60; + *(int *)(&stack0xffffff58 + iVar2) = iVar4; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e8e1; + error(*(char **)((int)auStack_94 + iVar2 + -0x18)); + } + *(undefined4 *)(&stack0xffffff68 + iVar2) = 0; + *(char **)(&stack0xffffff64 + iVar2) = Address; + *(undefined **)(&stack0xffffff5c + iVar2) = &DAT_080eeb56; + *(char **)(&stack0xffffff60 + iVar2) = SendMail::envelope; + *(char **)(&stack0xffffff58 + iVar2) = SendMail::mailer; + *(char **)((int)auStack_94 + iVar2 + -0x18) = SendMail::mailer; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e8be; + execlp(*(char **)((int)auStack_94 + iVar2 + -0x18), + *(char **)(&stack0xffffff58 + iVar2)); + *(undefined4 *)((int)auStack_94 + iVar2 + -0x18) = 0; // WARNING: Subroutine does not return - // try { // try from 0804dbe0 to 0804dbe4 has its CatchHandler @ 0804dbe5 - __cxa_throw(puVar1,char_const*::typeinfo,0); + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e8ca; + exit(*(int *)((int)auStack_94 + iVar2 + -0x18)); + } + do { + puVar7 = puVar8; + uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; + uVar10 = uVar9 & 0x80808080; + puVar8 = puVar7 + 1; + } while (uVar10 == 0); + *(uint **)(&stack0xffffff58 + iVar2) = puVar1; + bVar11 = (uVar9 & 0x8080) == 0; + if (bVar11) { + uVar10 = uVar10 >> 0x10; + } + if (bVar11) { + puVar8 = (uint *)((int)puVar7 + 6); + } + *(uint *)(&stack0xffffff5c + iVar2) = + (int)puVar8 + ((-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)) - (int)puVar1); + *(int *)((int)auStack_94 + iVar2 + -0x18) = inode[0]; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e805; + write(*(int *)((int)auStack_94 + iVar2 + -0x18),*(void **)(&stack0xffffff58 + iVar2) + ,*(size_t *)(&stack0xffffff5c + iVar2)); + *(undefined4 *)((int)auStack_94 + iVar2 + -0x18) = local_84; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e810; + iVar4 = close(*(int *)((int)auStack_94 + iVar2 + -0x18)); + if (iVar4 < 0) { + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e843; + piVar6 = __errno_location(); + iVar4 = *piVar6; + *(undefined **)((int)auStack_94 + iVar2 + -0x18) = &DAT_080eef20; + *(int *)(&stack0xffffff58 + iVar2) = iVar4; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e855; + error(*(char **)((int)auStack_94 + iVar2 + -0x18)); + } + *(int *)((int)auStack_94 + iVar2 + -0x18) = inode[0]; + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e81f; + iVar4 = close(*(int *)((int)auStack_94 + iVar2 + -0x18)); + if (-1 < iVar4) { + return; + } + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e82c; + piVar6 = __errno_location(); + iVar4 = *piVar6; + *(undefined **)((int)auStack_94 + iVar2 + -0x18) = &DAT_080eeee0; + *(int *)(&stack0xffffff58 + iVar2) = iVar4; + goto LAB_0804e775; + } + *(undefined **)((int)auStack_94 + iVar2 + -0x18) = &DAT_080eefe0; + } + else { + *(char **)((int)auStack_94 + iVar2 + -0x18) = "SendMail: Kann Pipe nicht anlegen.\n"; + } + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e79f; + error(*(char **)((int)auStack_94 + iVar2 + -0x18)); + } + else { + *(undefined **)((int)auStack_94 + iVar2 + -0x18) = &DAT_080eee60; + *(char **)(&stack0xffffff58 + iVar2) = SendMail::mailer; +LAB_0804e775: + *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e77a; + error(*(char **)((int)auStack_94 + iVar2 + -0x18)); + } + return; } -// DWARF original prototype: void writeQuad(TWriteBuffer * this, ulong q) +// WARNING: Variable defined which should be unmapped: status +// WARNING: Unknown calling convention -- yet parameter storage is locked -void __thiscall TWriteBuffer::writeQuad(TWriteBuffer *this,ulong q) +void RemoveZombie(void) { - undefined4 *puVar1; + int local_8; + int status; - if (this->Position <= this->Size + -4) { - this->Data[this->Position] = (uchar)q; - this->Data[this->Position + 1] = (uchar)(q >> 8); - this->Data[this->Position + 2] = (uchar)(q >> 0x10); - this->Data[this->Position + 3] = (uchar)(q >> 0x18); - this->Position = this->Position + 4; - return; - } - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "buffer full"; - // WARNING: Subroutine does not return - // try { // try from 0804dc79 to 0804dc7d has its CatchHandler @ 0804dc7e - __cxa_throw(puVar1,char_const*::typeinfo,0); + waitpid(-1,&local_8,3); + return; } -// DWARF original prototype: void writeBytes(TWriteBuffer * this, uchar * Buffer, int Count) +ulong PackAbsoluteCoordinate(int x,int y,int z) -void __thiscall TWriteBuffer::writeBytes(TWriteBuffer *this,uchar *Buffer,int Count) +{ + return (x + -0x6000) * 0x40000 + (y + -0x6000) * 0x10 + z; +} + + + +ulong PackRelativeCoordinate(int dx,int dy,int dz) { - undefined4 *puVar1; - - if (this->Position <= this->Size - Count) { - memcpy(this->Data + this->Position,Buffer,Count); - this->Position = this->Position + Count; - return; - } - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "buffer full"; - // WARNING: Subroutine does not return - // try { // try from 0804dd08 to 0804dd0c has its CatchHandler @ 0804dd0d - __cxa_throw(puVar1,char_const*::typeinfo,0); + return (dx + 0x2000) * 0x40000 + (dy + 0x2000) * 0x10 + dz + 8; } -// DWARF original prototype: void TDynamicWriteBuffer(TDynamicWriteBuffer * this, int InitialSize) +// WARNING: Unknown calling convention -- yet parameter storage is locked -void __thiscall TDynamicWriteBuffer::TDynamicWriteBuffer(TDynamicWriteBuffer *this,int InitialSize) +void UnpackAbsoluteCoordinate(void) { - uchar *data; + uint in_stack_00000004; + int *in_stack_00000008; + int *in_stack_0000000c; + uint *in_stack_00000010; - data = (uchar *)operator_new__(InitialSize); - TWriteBuffer::TWriteBuffer(&this->super_TWriteBuffer,data,InitialSize); - (this->super_TWriteBuffer).super_TWriteStream._vptr_TWriteStream = - (_func_int_varargs **)&PTR_writeFlag_08126768; + *in_stack_00000008 = (in_stack_00000004 >> 0x12) + 0x6000; + *in_stack_0000000c = (in_stack_00000004 >> 4 & 0x3fff) + 0x6000; + *in_stack_00000010 = in_stack_00000004 & 0xf; return; } -// DWARF original prototype: void TDynamicWriteBuffer(TDynamicWriteBuffer * this, int InitialSize) +// WARNING: Unknown calling convention -- yet parameter storage is locked -void __thiscall TDynamicWriteBuffer::TDynamicWriteBuffer(TDynamicWriteBuffer *this,int InitialSize) +void UnpackRelativeCoordinate(void) { - uchar *data; + uint in_stack_00000004; + int *in_stack_00000008; + int *in_stack_0000000c; + int *in_stack_00000010; - data = (uchar *)operator_new__(InitialSize); - TWriteBuffer::TWriteBuffer(&this->super_TWriteBuffer,data,InitialSize); - (this->super_TWriteBuffer).super_TWriteStream._vptr_TWriteStream = - (_func_int_varargs **)&PTR_writeFlag_08126768; + *in_stack_00000008 = (in_stack_00000004 >> 0x12) - 0x2000; + *in_stack_0000000c = (in_stack_00000004 >> 4 & 0x3fff) - 0x2000; + *in_stack_00000010 = (in_stack_00000004 & 0xf) - 8; return; } -// DWARF original prototype: void ~TDynamicWriteBuffer(TDynamicWriteBuffer * this, int __in_chrg) - -void __thiscall TDynamicWriteBuffer::~TDynamicWriteBuffer(TDynamicWriteBuffer *this,int __in_chrg) +void SaveFile(char *Filename) { - uchar *puVar1; + int iVar1; + FILE *pFVar2; + FILE *__stream; + size_t sVar3; + size_t sVar4; + int iVar5; + int *piVar6; + size_t Size; + FILE *Source; + undefined4 uStack_1040; + char *pcVar7; + undefined4 uStack_1030; + undefined1 auStack_102c [4]; + undefined1 *local_1028; + uchar_0_ *Buffer; + FILE *local_1020; + FILE *Dest; + char BackupFilename [4096]; - (this->super_TWriteBuffer).super_TWriteStream._vptr_TWriteStream = - (_func_int_varargs **)&PTR_writeFlag_08126768; - puVar1 = (this->super_TWriteBuffer).Data; - if (puVar1 != (uchar *)0x0) { - operator_delete__(puVar1); + Buffer = &stack0xffffefc4; + if (Filename == (char *)0x0) { + uStack_1040 = 0x804ec01; + error("SaveFile: Filename ist NULL.\n"); + return; + } + uStack_1040 = 0x804ea52; + Buffer = &stack0xffffefc4; + strcpy((char *)&Dest,Filename); + uStack_1040 = 0x804ea62; + strcat((char *)&Dest,"#"); + uStack_1040 = 0x804ea75; + __stream = fopen(Filename,"rb"); + if (__stream == (FILE *)0x0) { + pcVar7 = "SaveFile: Quelldatei %s existiert nicht.\n"; +LAB_0804ebdb: + uStack_1040 = 0x804ebe0; + error(pcVar7); + return; + } + uStack_1040 = 0x804ea8f; + local_1020 = fopen((char *)&Dest,"wb"); + if (local_1020 == (FILE *)0x0) { + pcVar7 = "SaveFile: Kann Zieldatei %s nicht anlegen.\n"; + local_1020 = (FILE *)0x0; + goto LAB_0804ebdb; + } + uStack_1040 = 0x804eab5; + fseek(__stream,0,2); + uStack_1040 = 0x804eabd; + sVar3 = ftell(__stream); + uStack_1040 = 0x804ead7; + fseek(__stream,0,0); + iVar1 = -(sVar3 + 0xf & 0xfffffff0); + local_1028 = auStack_102c + iVar1; + *(FILE **)((int)&uStack_1030 + iVar1) = __stream; + *(size_t *)(BackupFilename + iVar1 + -0x1c) = sVar3; + pcVar7 = BackupFilename + iVar1 + -0x20; + pcVar7[0] = '\x01'; + pcVar7[1] = '\0'; + pcVar7[2] = '\0'; + pcVar7[3] = '\0'; + *(undefined1 **)(&stack0xffffefc4 + iVar1) = auStack_102c + iVar1; + *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb01; + sVar4 = fread(*(void **)(&stack0xffffefc4 + iVar1),*(size_t *)(BackupFilename + iVar1 + -0x20), + *(size_t *)(BackupFilename + iVar1 + -0x1c),*(FILE **)((int)&uStack_1030 + iVar1)) + ; + pFVar2 = local_1020; + if (sVar4 == sVar3) { + pcVar7 = BackupFilename + iVar1 + -0x20; + pcVar7[0] = '\x01'; + pcVar7[1] = '\0'; + pcVar7[2] = '\0'; + pcVar7[3] = '\0'; + *(size_t *)(BackupFilename + iVar1 + -0x1c) = sVar4; + *(FILE **)((int)&uStack_1030 + iVar1) = pFVar2; + *(undefined1 **)(&stack0xffffefc4 + iVar1) = local_1028; + *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804ebb4; + sVar3 = fwrite(*(void **)(&stack0xffffefc4 + iVar1), + *(size_t *)(BackupFilename + iVar1 + -0x20), + *(size_t *)(BackupFilename + iVar1 + -0x1c), + *(FILE **)((int)&uStack_1030 + iVar1)); + if (sVar3 == sVar4) goto LAB_0804eb1e; + *(char **)(&stack0xffffefc4 + iVar1) = "SaveFile: Fehler beim Schreiben der Zieldatei %s.\n" + ; + *(char **)(BackupFilename + iVar1 + -0x20) = Filename; + } + else { + *(char **)(&stack0xffffefc4 + iVar1) = "SaveFile: Fehler beim Lesen der Quelldatei %s.\n"; + *(char **)(BackupFilename + iVar1 + -0x20) = Filename; } + *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb1e; + error(*(char **)(&stack0xffffefc4 + iVar1)); +LAB_0804eb1e: + *(FILE **)(&stack0xffffefc4 + iVar1) = __stream; + *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb26; + iVar5 = fclose(*(FILE **)(&stack0xffffefc4 + iVar1)); + if (iVar5 != 0) { + *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb75; + piVar6 = __errno_location(); + iVar5 = *piVar6; + *(undefined **)(&stack0xffffefc4 + iVar1) = &DAT_080ef3a0; + *(int *)(BackupFilename + iVar1 + -0x20) = iVar5; + *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb87; + error(*(char **)(&stack0xffffefc4 + iVar1)); + } + *(FILE **)(&stack0xffffefc4 + iVar1) = local_1020; + *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb38; + iVar5 = fclose(*(FILE **)(&stack0xffffefc4 + iVar1)); + if (iVar5 == 0) { + return; + } + *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb55; + piVar6 = __errno_location(); + iVar5 = *piVar6; + *(undefined **)(&stack0xffffefc4 + iVar1) = &DAT_080ef360; + *(int *)(BackupFilename + iVar1 + -0x20) = iVar5; + *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb67; + error(*(char **)(&stack0xffffefc4 + iVar1)); return; } -// DWARF original prototype: void ~TDynamicWriteBuffer(TDynamicWriteBuffer * this, int __in_chrg) +// DWARF original prototype: void TReadScriptFile(TReadScriptFile * this) -void __thiscall TDynamicWriteBuffer::~TDynamicWriteBuffer(TDynamicWriteBuffer *this,int __in_chrg) +void __thiscall TReadScriptFile::TReadScriptFile(TReadScriptFile *this) { - uchar *puVar1; - - (this->super_TWriteBuffer).super_TWriteStream._vptr_TWriteStream = - (_func_int_varargs **)&PTR_writeFlag_08126768; - puVar1 = (this->super_TWriteBuffer).Data; - if (puVar1 != (uchar *)0x0) { - operator_delete__(puVar1); - } + this->RecursionDepth = -1; + this->Bytes = (uchar *)this->String; return; } -// DWARF original prototype: void ~TDynamicWriteBuffer(TDynamicWriteBuffer * this, int __in_chrg) +// DWARF original prototype: void TReadScriptFile(TReadScriptFile * this) -void __thiscall TDynamicWriteBuffer::~TDynamicWriteBuffer(TDynamicWriteBuffer *this,int __in_chrg) +void __thiscall TReadScriptFile::TReadScriptFile(TReadScriptFile *this) { - uchar *puVar1; - - puVar1 = (this->super_TWriteBuffer).Data; - (this->super_TWriteBuffer).super_TWriteStream._vptr_TWriteStream = - (_func_int_varargs **)&PTR_writeFlag_08126768; - if (puVar1 != (uchar *)0x0) { - operator_delete__(puVar1); - } - operator_delete(this); + this->RecursionDepth = -1; + this->Bytes = (uchar *)this->String; return; } -// DWARF original prototype: void resizeBuffer(TDynamicWriteBuffer * this) +// DWARF original prototype: void ~TReadScriptFile(TReadScriptFile * this, int __in_chrg) -void __thiscall TDynamicWriteBuffer::resizeBuffer(TDynamicWriteBuffer *this) +void __thiscall TReadScriptFile::~TReadScriptFile(TReadScriptFile *this,int __in_chrg) { - int *piVar1; - uchar *puVar2; - uchar *__dest; - uchar *Help; + int iVar1; + int *piVar2; - __dest = (uchar *)operator_new__((this->super_TWriteBuffer).Size * 2); - memcpy(__dest,(this->super_TWriteBuffer).Data,(this->super_TWriteBuffer).Size); - puVar2 = (this->super_TWriteBuffer).Data; - if (puVar2 != (uchar *)0x0) { - operator_delete__(puVar2); + if (this->RecursionDepth != -1) { + ::error("TReadScriptFile::~TReadScriptFile: Datei ist noch offen.\n"); + iVar1 = this->RecursionDepth; + while (iVar1 != -1) { + iVar1 = fclose((FILE *)this->File[iVar1]); + if (iVar1 != 0) { + piVar2 = __errno_location(); + ::error(&DAT_080ef4e0,*piVar2); + } + this->RecursionDepth = this->RecursionDepth + -1; + iVar1 = this->RecursionDepth; + } } - piVar1 = &(this->super_TWriteBuffer).Size; - *piVar1 = *piVar1 << 1; - (this->super_TWriteBuffer).Data = __dest; return; } -// WARNING: Variable defined which should be unmapped: b_local -// DWARF original prototype: void writeByte(TDynamicWriteBuffer * this, uchar b) +// DWARF original prototype: void ~TReadScriptFile(TReadScriptFile * this, int __in_chrg) -void __thiscall TDynamicWriteBuffer::writeByte(TDynamicWriteBuffer *this,uchar b) +void __thiscall TReadScriptFile::~TReadScriptFile(TReadScriptFile *this,int __in_chrg) { - int *piVar1; - uchar *puVar2; - uchar *__dest; - int iVar3; - int iVar4; - uchar *Help; - uchar b_local; + int iVar1; + int *piVar2; - iVar3 = (this->super_TWriteBuffer).Size; - iVar4 = (this->super_TWriteBuffer).Position; - if (iVar3 + -1 < iVar4) { - do { - // try { // try from 0804dee6 to 0804deea has its CatchHandler @ 0804df30 - __dest = (uchar *)operator_new__(iVar3 * 2); - memcpy(__dest,(this->super_TWriteBuffer).Data,(this->super_TWriteBuffer).Size); - puVar2 = (this->super_TWriteBuffer).Data; - if (puVar2 != (uchar *)0x0) { - operator_delete__(puVar2); + if (this->RecursionDepth != -1) { + ::error("TReadScriptFile::~TReadScriptFile: Datei ist noch offen.\n"); + iVar1 = this->RecursionDepth; + while (iVar1 != -1) { + iVar1 = fclose((FILE *)this->File[iVar1]); + if (iVar1 != 0) { + piVar2 = __errno_location(); + ::error(&DAT_080ef4e0,*piVar2); } - (this->super_TWriteBuffer).Data = __dest; - iVar4 = (this->super_TWriteBuffer).Position; - iVar3 = (this->super_TWriteBuffer).Size * 2; - (this->super_TWriteBuffer).Size = iVar3; - } while (iVar3 + -1 < iVar4); + this->RecursionDepth = this->RecursionDepth + -1; + iVar1 = this->RecursionDepth; + } } - (this->super_TWriteBuffer).Data[iVar4] = b; - piVar1 = &(this->super_TWriteBuffer).Position; - *piVar1 = *piVar1 + 1; return; } -// DWARF original prototype: void writeWord(TDynamicWriteBuffer * this, ushort w) +// DWARF original prototype: void open(TReadScriptFile * this, char * FileName) -void __thiscall TDynamicWriteBuffer::writeWord(TDynamicWriteBuffer *this,ushort w) +int __thiscall TReadScriptFile::open(TReadScriptFile *this,char *__file,int __oflag,...) { - int *piVar1; - uchar *puVar2; - uchar *__dest; - int iVar3; - int iVar4; - uchar *Help; + int iVar1; + char *p; + int iVar2; + char *pcVar3; + char (*__dest) [4096]; + FILE *pFVar4; + int *piVar5; + undefined4 *puVar6; + int ErrorCode; - iVar3 = (this->super_TWriteBuffer).Size; - iVar4 = (this->super_TWriteBuffer).Position; - if (iVar3 + -2 < iVar4) { - do { - // try { // try from 0804dfa6 to 0804dfaa has its CatchHandler @ 0804dff0 - __dest = (uchar *)operator_new__(iVar3 * 2); - memcpy(__dest,(this->super_TWriteBuffer).Data,(this->super_TWriteBuffer).Size); - puVar2 = (this->super_TWriteBuffer).Data; - if (puVar2 != (uchar *)0x0) { - operator_delete__(puVar2); - } - (this->super_TWriteBuffer).Data = __dest; - iVar4 = (this->super_TWriteBuffer).Position; - iVar3 = (this->super_TWriteBuffer).Size * 2; - (this->super_TWriteBuffer).Size = iVar3; - } while (iVar3 + -2 < iVar4); + iVar1 = this->RecursionDepth; + iVar2 = iVar1 + 1; + this->RecursionDepth = iVar2; + if (iVar2 == 3) { + ::error(&DAT_080ef560); + puVar6 = (undefined4 *)__cxa_allocate_exception(4); + *puVar6 = "Recursion depth too high"; + goto LAB_0804ee56; } - (this->super_TWriteBuffer).Data[iVar4] = (uchar)w; - (this->super_TWriteBuffer).Data[(this->super_TWriteBuffer).Position + 1] = (uchar)(w >> 8); - piVar1 = &(this->super_TWriteBuffer).Position; - *piVar1 = *piVar1 + 2; - return; -} - - - -// DWARF original prototype: void writeQuad(TDynamicWriteBuffer * this, ulong q) - -void __thiscall TDynamicWriteBuffer::writeQuad(TDynamicWriteBuffer *this,ulong q) - -{ - int *piVar1; - uchar *puVar2; - uchar *__dest; - int iVar3; - int iVar4; - uchar *Help; - - iVar3 = (this->super_TWriteBuffer).Size; - iVar4 = (this->super_TWriteBuffer).Position; - if (iVar3 + -4 < iVar4) { - do { - // try { // try from 0804e076 to 0804e07a has its CatchHandler @ 0804e0c0 - __dest = (uchar *)operator_new__(iVar3 * 2); - memcpy(__dest,(this->super_TWriteBuffer).Data,(this->super_TWriteBuffer).Size); - puVar2 = (this->super_TWriteBuffer).Data; - if (puVar2 != (uchar *)0x0) { - operator_delete__(puVar2); - } - (this->super_TWriteBuffer).Data = __dest; - iVar4 = (this->super_TWriteBuffer).Position; - iVar3 = (this->super_TWriteBuffer).Size * 2; - (this->super_TWriteBuffer).Size = iVar3; - } while (iVar3 + -4 < iVar4); + if ((iVar2 < 1) || (*__file == '/')) { +LAB_0804ee70: + __dest = this->Filename + this->RecursionDepth; } - (this->super_TWriteBuffer).Data[iVar4] = (uchar)q; - (this->super_TWriteBuffer).Data[(this->super_TWriteBuffer).Position + 1] = (uchar)(q >> 8); - (this->super_TWriteBuffer).Data[(this->super_TWriteBuffer).Position + 2] = (uchar)(q >> 0x10); - (this->super_TWriteBuffer).Data[(this->super_TWriteBuffer).Position + 3] = (uchar)(q >> 0x18); - piVar1 = &(this->super_TWriteBuffer).Position; - *piVar1 = *piVar1 + 4; - return; -} - - - -// DWARF original prototype: void writeBytes(TDynamicWriteBuffer * this, uchar * Buffer, int Count) - -void __thiscall TDynamicWriteBuffer::writeBytes(TDynamicWriteBuffer *this,uchar *Buffer,int Count) - -{ - int *piVar1; - uchar *puVar2; - uchar *__dest; - int iVar3; - int iVar4; - uchar *Help; - - iVar3 = (this->super_TWriteBuffer).Size; - iVar4 = (this->super_TWriteBuffer).Position; - if (iVar3 - Count < iVar4) { - do { - // try { // try from 0804e136 to 0804e13a has its CatchHandler @ 0804e180 - __dest = (uchar *)operator_new__(iVar3 * 2); - memcpy(__dest,(this->super_TWriteBuffer).Data,(this->super_TWriteBuffer).Size); - puVar2 = (this->super_TWriteBuffer).Data; - if (puVar2 != (uchar *)0x0) { - operator_delete__(puVar2); - } - (this->super_TWriteBuffer).Data = __dest; - iVar4 = (this->super_TWriteBuffer).Position; - iVar3 = (this->super_TWriteBuffer).Size * 2; - (this->super_TWriteBuffer).Size = iVar3; - } while (iVar3 - Count < iVar4); + else { + strcpy(this->Filename[this->RecursionDepth],this->Filename[iVar1]); + // try { // try from 0804eda1 to 0804ee91 has its CatchHandler @ 0804eea6 + pcVar3 = findLast(this->Filename[this->RecursionDepth],'/'); + if (pcVar3 == (char *)0x0) goto LAB_0804ee70; + __dest = (char (*) [4096])(pcVar3 + 1); } - memcpy((this->super_TWriteBuffer).Data + iVar4,Buffer,Count); - piVar1 = &(this->super_TWriteBuffer).Position; - *piVar1 = *piVar1 + Count; - return; + strcpy(*__dest,__file); + iVar1 = this->RecursionDepth; + pFVar4 = fopen(this->Filename[this->RecursionDepth],"rb"); + iVar2 = this->RecursionDepth; + this->File[iVar1] = (FILE *)pFVar4; + if (this->File[iVar2] != (FILE *)0x0) { + this->Line[iVar2] = 1; + return 1; + } + piVar5 = __errno_location(); + iVar1 = *piVar5; + ::error(&DAT_080ef520,this->Filename + iVar2); + pcVar3 = strerror(iVar1); + ::error("Fehler %d: %s.\n",iVar1,pcVar3); + this->RecursionDepth = this->RecursionDepth + -1; + puVar6 = (undefined4 *)__cxa_allocate_exception(4); + *puVar6 = "Cannot open script-file"; +LAB_0804ee56: + // WARNING: Subroutine does not return + __cxa_throw(puVar6,char_const*::typeinfo,0); } -int val(char c) +// DWARF original prototype: void close(TReadScriptFile * this) + +int __thiscall TReadScriptFile::close(TReadScriptFile *this,int __fd) { int iVar1; + int *piVar2; - if ((byte)(c - 0x30U) < 10) { - iVar1 = c + -0x30; - } - else if ((byte)(c + 0xbfU) < 6) { - iVar1 = c + -0x37; - } - else if ((byte)(c + 0x9fU) < 6) { - iVar1 = c + -0x57; - } - else { - iVar1 = 0; + iVar1 = this->RecursionDepth; + if (iVar1 != -1) { + iVar1 = fclose((FILE *)this->File[iVar1]); + if (iVar1 != 0) { + piVar2 = __errno_location(); + iVar1 = *piVar2; + ::error(&DAT_080ef4e0,iVar1); + } + this->RecursionDepth = this->RecursionDepth + -1; + return iVar1; } + ::error("TReadScriptFile::close: Keine Datei offen.\n"); return iVar1; } -// WARNING: Unknown calling convention -- yet parameter storage is locked +// DWARF original prototype: void error(TReadScriptFile * this, char * Text) -long random(void) +void __thiscall TReadScriptFile::error(TReadScriptFile *this,char *Text) { - int iVar1; + char *pcVar1; int iVar2; - int range; - int in_stack_00000004; - int in_stack_00000008; + int *piVar3; + undefined4 *puVar4; + char *p; + char (*pacVar5) [4096]; - iVar1 = (in_stack_00000008 - in_stack_00000004) + 1; - if (0 < iVar1) { - iVar2 = rand(); - in_stack_00000004 = iVar2 % iVar1 + in_stack_00000004; + // try { // try from 0804ef52 to 0804f008 has its CatchHandler @ 0804f020 + pcVar1 = findLast(this->Filename[this->RecursionDepth],'/'); + if (pcVar1 == (char *)0x0) { + iVar2 = this->RecursionDepth; + pacVar5 = this->Filename + iVar2; } - return in_stack_00000004; -} - - - -bool FileExists(char *FileName) - -{ - int *piVar1; - int iVar2; - bool bVar3; - undefined1 local_6c [4]; - stat Buffer; - - piVar1 = __errno_location(); - *piVar1 = 0; - iVar2 = __xstat(3,FileName,(stat *)local_6c); - bVar3 = true; - if (iVar2 != 0) { - if (*piVar1 != 2) { - error("FileExists: Unerwarteter Fehlercode %d.\n",*piVar1); + else { + iVar2 = this->RecursionDepth; + pacVar5 = (char (*) [4096])(pcVar1 + 1); + } + snprintf(ErrorString,100,"error in script-file \"%s\", line %d: %s",pacVar5,this->Line[iVar2], + Text); + iVar2 = this->RecursionDepth; + while (iVar2 != -1) { + iVar2 = fclose((FILE *)this->File[iVar2]); + if (iVar2 != 0) { + piVar3 = __errno_location(); + ::error(&DAT_080ef4e0,*piVar3); } - bVar3 = false; + this->RecursionDepth = this->RecursionDepth + -1; + iVar2 = this->RecursionDepth; } - return bVar3; + puVar4 = (undefined4 *)__cxa_allocate_exception(4); + *puVar4 = ErrorString; + // WARNING: Subroutine does not return + __cxa_throw(puVar4,char*::typeinfo,0); } -void TreatAllFiles(char *Directory,char *Extension,TFileHandlerFunction *Function) +// WARNING: Variable defined which should be unmapped: pos +// DWARF original prototype: void nextToken(TReadScriptFile * this) + +void __thiscall TReadScriptFile::nextToken(TReadScriptFile *this) { - uint *__dest; - dirent *DirectoryEntry; - DIR *__dirp; - dirent *pdVar1; - char *pcVar2; - size_t sVar3; - int iVar4; - uint uVar5; - uint uVar6; - uint *puVar7; - uint *puVar8; - DIR *WorkingDirectory; - bool bVar9; - char local_105c [4]; - char Name [64]; - char FileName [4096]; + char *__file; + FILE *__stream; + bool bVar1; + uint uVar2; + int iVar3; + int *piVar4; + int State; + undefined4 uVar5; + int c; + char *pcVar6; + int in_stack_ffffffcc; + int local_1c; + int Sign; + FILE *f; + int pos; - __dirp = opendir(Directory); - if (__dirp != (DIR *)0x0) { - while (pdVar1 = readdir(__dirp), pdVar1 != (dirent *)0x0) { - __dest = (uint *)(Name + 0x3c); - strcpy((char *)__dest,pdVar1->d_name); - puVar8 = __dest; - do { - puVar7 = puVar8; - uVar5 = *puVar7 + 0xfefefeff & ~*puVar7; - uVar6 = uVar5 & 0x80808080; - puVar8 = puVar7 + 1; - } while (uVar6 == 0); - bVar9 = (uVar5 & 0x8080) == 0; - if (bVar9) { - uVar6 = uVar6 >> 0x10; - } - if (bVar9) { - puVar8 = (uint *)((int)puVar7 + 6); + if (this->RecursionDepth == -1) { + ::error(&DAT_080ef660); +LAB_0804f216: + this->Token = ENDOFFILE; + return; + } + __file = this->String; +LAB_0804f062: + f = (FILE *)0x0; + uVar5 = 0; + uVar2 = 4000; + pcVar6 = __file; + if (((uint)__file & 4) != 0) { + pcVar6 = this->String + 4; + uVar2 = 0xf9c; + this->String[0] = '\0'; + this->String[1] = '\0'; + this->String[2] = '\0'; + this->String[3] = '\0'; + } + for (uVar2 = uVar2 >> 2; uVar2 != 0; uVar2 = uVar2 - 1) { + pcVar6[0] = '\0'; + pcVar6[1] = '\0'; + pcVar6[2] = '\0'; + pcVar6[3] = '\0'; + pcVar6 = pcVar6 + 4; + } + this->Number = 0; + __stream = (FILE *)this->File[this->RecursionDepth]; + local_1c = 1; +LAB_0804f0b6: + if (f == (FILE *)0xf9f) { + error(this,"string too long"); + } + switch(uVar5) { + case 0: + iVar3 = getc(__stream); + if (iVar3 != -1) { + if (iVar3 == 10) { + this->Line[this->RecursionDepth] = this->Line[this->RecursionDepth] + 1; } - pcVar2 = (char *)strlen(Extension); - puVar7 = __dest; - if (pcVar2 < (char *)((int)puVar8 + - ((-3 - (uint)CARRY1((byte)uVar6,(byte)uVar6)) - (int)__dest))) { - do { - puVar8 = puVar7; - uVar5 = *puVar8 + 0xfefefeff & ~*puVar8; - uVar6 = uVar5 & 0x80808080; - puVar7 = puVar8 + 1; - } while (uVar6 == 0); - bVar9 = (uVar5 & 0x8080) == 0; - if (bVar9) { - uVar6 = uVar6 >> 0x10; - } - puVar7 = (uint *)((int)puVar8 + 6); - if (!bVar9) { - puVar7 = puVar8 + 1; - } - sVar3 = strlen(Extension); - iVar4 = strcmp((char *)((int)puVar7 + - ((-3 - (uint)CARRY1((byte)uVar6,(byte)uVar6)) - sVar3)), - Extension); - if (iVar4 == 0) { - local_105c[0] = '\0'; - local_105c[1] = '\0'; - local_105c[2] = '\0'; - local_105c[3] = '\0'; - Name[0] = '\0'; - Name[1] = '\0'; - Name[2] = '\0'; - Name[3] = '\0'; - Name[4] = '\0'; - Name[5] = '\0'; - Name[6] = '\0'; - Name[7] = '\0'; - Name[0xc] = '\0'; - Name[0xd] = '\0'; - Name[0xe] = '\0'; - Name[0xf] = '\0'; - Name[0x10] = '\0'; - Name[0x11] = '\0'; - Name[0x12] = '\0'; - Name[0x13] = '\0'; - Name[0x14] = '\0'; - Name[0x15] = '\0'; - Name[0x16] = '\0'; - Name[0x17] = '\0'; - Name[0x18] = '\0'; - Name[0x19] = '\0'; - Name[0x1a] = '\0'; - Name[0x1b] = '\0'; - Name[0x1c] = '\0'; - Name[0x1d] = '\0'; - Name[0x1e] = '\0'; - Name[0x1f] = '\0'; - Name[8] = '\0'; - Name[9] = '\0'; - Name[10] = '\0'; - Name[0xb] = '\0'; - Name[0x20] = '\0'; - Name[0x21] = '\0'; - Name[0x22] = '\0'; - Name[0x23] = '\0'; - Name[0x24] = '\0'; - Name[0x25] = '\0'; - Name[0x26] = '\0'; - Name[0x27] = '\0'; - Name[0x28] = '\0'; - Name[0x29] = '\0'; - Name[0x2a] = '\0'; - Name[0x2b] = '\0'; - Name[0x30] = '\0'; - Name[0x31] = '\0'; - Name[0x32] = '\0'; - Name[0x33] = '\0'; - Name[0x34] = '\0'; - Name[0x35] = '\0'; - Name[0x36] = '\0'; - Name[0x37] = '\0'; - Name[0x2c] = '\0'; - Name[0x2d] = '\0'; - Name[0x2e] = '\0'; - Name[0x2f] = '\0'; - Name[0x38] = '\0'; - Name[0x39] = '\0'; - Name[0x3a] = '\0'; - Name[0x3b] = '\0'; - puVar8 = __dest; - do { - puVar7 = puVar8; - uVar5 = *puVar7 + 0xfefefeff & ~*puVar7; - uVar6 = uVar5 & 0x80808080; - puVar8 = puVar7 + 1; - } while (uVar6 == 0); - bVar9 = (uVar5 & 0x8080) == 0; - if (bVar9) { - uVar6 = uVar6 >> 0x10; + else { + // try { // try from 0804f0f5 to 0804f92b has its CatchHandler @ 0804f931 + bVar1 = isSpace(iVar3); + if (((!bVar1) && (uVar5 = 1, iVar3 != 0x23)) && (uVar5 = 0x1e, iVar3 != 0x40)) { + bVar1 = isAlpha(iVar3); + if (bVar1) { + uVar5 = 2; + this->String[(int)f] = (char)iVar3; + f = (FILE *)((int)&f->_flags + 1); } - if (bVar9) { - puVar8 = (uint *)((int)puVar7 + 6); + else { + bVar1 = isDigit(iVar3); + if (bVar1) { + this->Number = iVar3 + -0x30; + uVar5 = 3; + } + else { + uVar5 = 6; + if (((iVar3 != 0x22) && (uVar5 = 0xb, iVar3 != 0x5b)) && + ((uVar5 = 0x16, iVar3 != 0x3c && + ((uVar5 = 0x19, iVar3 != 0x3e && (uVar5 = 0x1b, iVar3 != 0x2d)))))) + { + uVar5 = 10; + this->Special = (char)iVar3; + } + } } - sVar3 = strlen(Extension); - strncpy(local_105c,(char *)__dest, - (size_t)((int)puVar8 + - (((-3 - (uint)CARRY1((byte)uVar6,(byte)uVar6)) - (int)__dest) - - sVar3))); - (*Function)(Directory,local_105c,Extension); } } + goto LAB_0804f0b6; } - closedir(__dirp); - } - return; -} - - - -void SendMail(char *Address,char *Subject,char *Text) - -{ - uint *puVar1; - int iVar2; - size_t sVar3; - int iVar4; - __pid_t _Var5; - int *piVar6; - uint *puVar7; - uint *puVar8; - uint uVar9; - uint uVar10; - char_0_ *Content; - bool bVar11; - int iStack_b0; - uint auStack_94 [4]; - undefined4 local_84; - int inode [2]; - stat StatBuffer; - - iStack_b0 = 0x804e4b9; - sVar3 = strlen(Text); - iVar2 = -(sVar3 + 0x7df & 0xfffffff0); - *(undefined1 *)((int)auStack_94 + iVar2) = 0; - puVar1 = (uint *)((int)auStack_94 + iVar2); - puVar8 = puVar1; - do { - puVar7 = puVar8; - uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; - uVar10 = uVar9 & 0x80808080; - puVar8 = puVar7 + 1; - } while (uVar10 == 0); - bVar11 = (uVar9 & 0x8080) == 0; - if (bVar11) { - uVar10 = uVar10 >> 0x10; - } - if (bVar11) { - puVar8 = (uint *)((int)puVar7 + 6); - } - *(char **)(&stack0xffffff58 + iVar2) = "From: %s\n"; - *(uint *)((int)auStack_94 + iVar2 + -0x18) = - (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); - *(char **)(&stack0xffffff5c + iVar2) = SendMail::sender; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e519; - sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); - puVar8 = puVar1; - do { - puVar7 = puVar8; - uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; - uVar10 = uVar9 & 0x80808080; - puVar8 = puVar7 + 1; - } while (uVar10 == 0); - bVar11 = (uVar9 & 0x8080) == 0; - if (bVar11) { - uVar10 = uVar10 >> 0x10; - } - if (bVar11) { - puVar8 = (uint *)((int)puVar7 + 6); - } - *(char **)(&stack0xffffff58 + iVar2) = "To: %s\n"; - *(uint *)((int)auStack_94 + iVar2 + -0x18) = - (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); - *(char **)(&stack0xffffff5c + iVar2) = Address; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e567; - sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); - puVar8 = puVar1; - do { - puVar7 = puVar8; - uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; - uVar10 = uVar9 & 0x80808080; - puVar8 = puVar7 + 1; - } while (uVar10 == 0); - bVar11 = (uVar9 & 0x8080) == 0; - if (bVar11) { - uVar10 = uVar10 >> 0x10; - } - if (bVar11) { - puVar8 = (uint *)((int)puVar7 + 6); - } - *(char **)(&stack0xffffff58 + iVar2) = "Subject: %s\n"; - *(uint *)((int)auStack_94 + iVar2 + -0x18) = - (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); - *(char **)(&stack0xffffff5c + iVar2) = Subject; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e5b7; - sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); - puVar8 = puVar1; - do { - puVar7 = puVar8; - uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; - uVar10 = uVar9 & 0x80808080; - puVar8 = puVar7 + 1; - } while (uVar10 == 0); - bVar11 = (uVar9 & 0x8080) == 0; - if (bVar11) { - uVar10 = uVar10 >> 0x10; - } - if (bVar11) { - puVar8 = (uint *)((int)puVar7 + 6); - } - *(char **)(&stack0xffffff58 + iVar2) = "Reply-To: %s\n"; - *(uint *)((int)auStack_94 + iVar2 + -0x18) = - (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); - *(char **)(&stack0xffffff5c + iVar2) = SendMail::replyto; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e609; - sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); - puVar8 = puVar1; - do { - puVar7 = puVar8; - uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; - uVar10 = uVar9 & 0x80808080; - puVar8 = puVar7 + 1; - } while (uVar10 == 0); - bVar11 = (uVar9 & 0x8080) == 0; - if (bVar11) { - uVar10 = uVar10 >> 0x10; - } - if (bVar11) { - puVar8 = (uint *)((int)puVar7 + 6); - } - *(char **)(&stack0xffffff58 + iVar2) = "X-Mailer: %s\n"; - *(uint *)((int)auStack_94 + iVar2 + -0x18) = - (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); - *(char **)(&stack0xffffff5c + iVar2) = SendMail::xmailer; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e659; - sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); - puVar8 = puVar1; - do { - puVar7 = puVar8; - uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; - uVar10 = uVar9 & 0x80808080; - puVar8 = puVar7 + 1; - } while (uVar10 == 0); - *(char **)(&stack0xffffff58 + iVar2) = "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; - bVar11 = (uVar9 & 0x8080) == 0; - if (bVar11) { - uVar10 = uVar10 >> 0x10; - } - if (bVar11) { - puVar8 = (uint *)((int)puVar7 + 6); - } - *(uint *)((int)auStack_94 + iVar2 + -0x18) = - (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e6a0; - sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); - puVar8 = puVar1; - do { - puVar7 = puVar8; - uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; - uVar10 = uVar9 & 0x80808080; - puVar8 = puVar7 + 1; - } while (uVar10 == 0); - *(char **)(&stack0xffffff58 + iVar2) = "\n"; - bVar11 = (uVar9 & 0x8080) == 0; - if (bVar11) { - uVar10 = uVar10 >> 0x10; - } - if (bVar11) { - puVar8 = (uint *)((int)puVar7 + 6); - } - *(uint *)((int)auStack_94 + iVar2 + -0x18) = - (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e6f0; - sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); - puVar8 = puVar1; - do { - puVar7 = puVar8; - uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; - uVar10 = uVar9 & 0x80808080; - puVar8 = puVar7 + 1; - } while (uVar10 == 0); - *(char **)(&stack0xffffff5c + iVar2) = Text; - *(char **)(&stack0xffffff58 + iVar2) = "%s\n"; - bVar11 = (uVar9 & 0x8080) == 0; - if (bVar11) { - uVar10 = uVar10 >> 0x10; - } - if (bVar11) { - puVar8 = (uint *)((int)puVar7 + 6); - } - *(uint *)((int)auStack_94 + iVar2 + -0x18) = - (int)puVar8 + (-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)); - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e744; - sprintf(*(char **)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2)); - *(undefined4 *)((int)auStack_94 + iVar2 + -0x18) = 3; - *(int **)(&stack0xffffff5c + iVar2) = inode + 1; - *(char **)(&stack0xffffff58 + iVar2) = SendMail::mailer; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e761; - iVar4 = __xstat(*(int *)((int)auStack_94 + iVar2 + -0x18),*(char **)(&stack0xffffff58 + iVar2), - *(stat **)(&stack0xffffff5c + iVar2)); - if (iVar4 == 0) { - *(undefined4 **)((int)auStack_94 + iVar2 + -0x18) = &local_84; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e78f; - iVar4 = pipe(*(int **)((int)auStack_94 + iVar2 + -0x18)); - if (iVar4 == 0) { - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e7a6; - _Var5 = fork(); - if (-1 < _Var5) { - puVar8 = puVar1; - if (_Var5 == 0) { - *(undefined4 *)(&stack0xffffff58 + iVar2) = 0; - *(undefined4 *)((int)auStack_94 + iVar2 + -0x18) = local_84; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e86a; - dup2(*(int *)((int)auStack_94 + iVar2 + -0x18), - *(int *)(&stack0xffffff58 + iVar2)); - *(undefined4 *)((int)auStack_94 + iVar2 + -0x18) = local_84; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e875; - iVar4 = close(*(int *)((int)auStack_94 + iVar2 + -0x18)); - if (iVar4 < 0) { - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e8e8; - piVar6 = __errno_location(); - iVar4 = *piVar6; - *(undefined **)((int)auStack_94 + iVar2 + -0x18) = &DAT_080eefa0; - *(int *)(&stack0xffffff58 + iVar2) = iVar4; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e8fa; - error(*(char **)((int)auStack_94 + iVar2 + -0x18)); - } - *(int *)((int)auStack_94 + iVar2 + -0x18) = inode[0]; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e884; - iVar4 = close(*(int *)((int)auStack_94 + iVar2 + -0x18)); - if (iVar4 < 0) { - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e8cf; - piVar6 = __errno_location(); - iVar4 = *piVar6; - *(undefined **)((int)auStack_94 + iVar2 + -0x18) = &DAT_080eef60; - *(int *)(&stack0xffffff58 + iVar2) = iVar4; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e8e1; - error(*(char **)((int)auStack_94 + iVar2 + -0x18)); - } - *(undefined4 *)(&stack0xffffff68 + iVar2) = 0; - *(char **)(&stack0xffffff64 + iVar2) = Address; - *(undefined **)(&stack0xffffff5c + iVar2) = &DAT_080eeb56; - *(char **)(&stack0xffffff60 + iVar2) = SendMail::envelope; - *(char **)(&stack0xffffff58 + iVar2) = SendMail::mailer; - *(char **)((int)auStack_94 + iVar2 + -0x18) = SendMail::mailer; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e8be; - execlp(*(char **)((int)auStack_94 + iVar2 + -0x18), - *(char **)(&stack0xffffff58 + iVar2)); - *(undefined4 *)((int)auStack_94 + iVar2 + -0x18) = 0; - // WARNING: Subroutine does not return - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e8ca; - exit(*(int *)((int)auStack_94 + iVar2 + -0x18)); - } - do { - puVar7 = puVar8; - uVar9 = *puVar7 + 0xfefefeff & ~*puVar7; - uVar10 = uVar9 & 0x80808080; - puVar8 = puVar7 + 1; - } while (uVar10 == 0); - *(uint **)(&stack0xffffff58 + iVar2) = puVar1; - bVar11 = (uVar9 & 0x8080) == 0; - if (bVar11) { - uVar10 = uVar10 >> 0x10; - } - if (bVar11) { - puVar8 = (uint *)((int)puVar7 + 6); - } - *(uint *)(&stack0xffffff5c + iVar2) = - (int)puVar8 + ((-3 - (uint)CARRY1((byte)uVar10,(byte)uVar10)) - (int)puVar1); - *(int *)((int)auStack_94 + iVar2 + -0x18) = inode[0]; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e805; - write(*(int *)((int)auStack_94 + iVar2 + -0x18),*(void **)(&stack0xffffff58 + iVar2) - ,*(size_t *)(&stack0xffffff5c + iVar2)); - *(undefined4 *)((int)auStack_94 + iVar2 + -0x18) = local_84; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e810; - iVar4 = close(*(int *)((int)auStack_94 + iVar2 + -0x18)); - if (iVar4 < 0) { - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e843; - piVar6 = __errno_location(); - iVar4 = *piVar6; - *(undefined **)((int)auStack_94 + iVar2 + -0x18) = &DAT_080eef20; - *(int *)(&stack0xffffff58 + iVar2) = iVar4; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e855; - error(*(char **)((int)auStack_94 + iVar2 + -0x18)); - } - *(int *)((int)auStack_94 + iVar2 + -0x18) = inode[0]; - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e81f; - iVar4 = close(*(int *)((int)auStack_94 + iVar2 + -0x18)); - if (-1 < iVar4) { - return; - } - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e82c; - piVar6 = __errno_location(); - iVar4 = *piVar6; - *(undefined **)((int)auStack_94 + iVar2 + -0x18) = &DAT_080eeee0; - *(int *)(&stack0xffffff58 + iVar2) = iVar4; - goto LAB_0804e775; - } - *(undefined **)((int)auStack_94 + iVar2 + -0x18) = &DAT_080eefe0; +LAB_0804f1c2: + iVar3 = this->RecursionDepth; + if (iVar3 < 1) goto LAB_0804f216; + if (iVar3 == -1) { + ::error("TReadScriptFile::close: Keine Datei offen.\n"); } else { - *(char **)((int)auStack_94 + iVar2 + -0x18) = "SendMail: Kann Pipe nicht anlegen.\n"; - } - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e79f; - error(*(char **)((int)auStack_94 + iVar2 + -0x18)); - } - else { - *(undefined **)((int)auStack_94 + iVar2 + -0x18) = &DAT_080eee60; - *(char **)(&stack0xffffff58 + iVar2) = SendMail::mailer; -LAB_0804e775: - *(undefined4 *)((int)&iStack_b0 + iVar2) = 0x804e77a; - error(*(char **)((int)auStack_94 + iVar2 + -0x18)); - } - return; -} - - - -// WARNING: Variable defined which should be unmapped: status -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void RemoveZombie(void) - -{ - int local_8; - int status; - - waitpid(-1,&local_8,3); - return; -} - - - -ulong PackAbsoluteCoordinate(int x,int y,int z) - -{ - return (x + -0x6000) * 0x40000 + (y + -0x6000) * 0x10 + z; -} - - - -ulong PackRelativeCoordinate(int dx,int dy,int dz) - -{ - return (dx + 0x2000) * 0x40000 + (dy + 0x2000) * 0x10 + dz + 8; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void UnpackAbsoluteCoordinate(void) - -{ - uint in_stack_00000004; - int *in_stack_00000008; - int *in_stack_0000000c; - uint *in_stack_00000010; - - *in_stack_00000008 = (in_stack_00000004 >> 0x12) + 0x6000; - *in_stack_0000000c = (in_stack_00000004 >> 4 & 0x3fff) + 0x6000; - *in_stack_00000010 = in_stack_00000004 & 0xf; - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void UnpackRelativeCoordinate(void) - -{ - uint in_stack_00000004; - int *in_stack_00000008; - int *in_stack_0000000c; - int *in_stack_00000010; - - *in_stack_00000008 = (in_stack_00000004 >> 0x12) - 0x2000; - *in_stack_0000000c = (in_stack_00000004 >> 4 & 0x3fff) - 0x2000; - *in_stack_00000010 = (in_stack_00000004 & 0xf) - 8; - return; -} - - - -void SaveFile(char *Filename) - -{ - int iVar1; - FILE *pFVar2; - FILE *__stream; - size_t sVar3; - size_t sVar4; - int iVar5; - int *piVar6; - size_t Size; - FILE *Source; - undefined4 uStack_1040; - char *pcVar7; - undefined4 uStack_1030; - undefined1 auStack_102c [4]; - undefined1 *local_1028; - uchar_0_ *Buffer; - FILE *local_1020; - FILE *Dest; - char BackupFilename [4096]; - - Buffer = &stack0xffffefc4; - if (Filename == (char *)0x0) { - uStack_1040 = 0x804ec01; - error("SaveFile: Filename ist NULL.\n"); - return; - } - uStack_1040 = 0x804ea52; - Buffer = &stack0xffffefc4; - strcpy((char *)&Dest,Filename); - uStack_1040 = 0x804ea62; - strcat((char *)&Dest,"#"); - uStack_1040 = 0x804ea75; - __stream = fopen(Filename,"rb"); - if (__stream == (FILE *)0x0) { - pcVar7 = "SaveFile: Quelldatei %s existiert nicht.\n"; -LAB_0804ebdb: - uStack_1040 = 0x804ebe0; - error(pcVar7); - return; - } - uStack_1040 = 0x804ea8f; - local_1020 = fopen((char *)&Dest,"wb"); - if (local_1020 == (FILE *)0x0) { - pcVar7 = "SaveFile: Kann Zieldatei %s nicht anlegen.\n"; - local_1020 = (FILE *)0x0; - goto LAB_0804ebdb; - } - uStack_1040 = 0x804eab5; - fseek(__stream,0,2); - uStack_1040 = 0x804eabd; - sVar3 = ftell(__stream); - uStack_1040 = 0x804ead7; - fseek(__stream,0,0); - iVar1 = -(sVar3 + 0xf & 0xfffffff0); - local_1028 = auStack_102c + iVar1; - *(FILE **)((int)&uStack_1030 + iVar1) = __stream; - *(size_t *)(BackupFilename + iVar1 + -0x1c) = sVar3; - pcVar7 = BackupFilename + iVar1 + -0x20; - pcVar7[0] = '\x01'; - pcVar7[1] = '\0'; - pcVar7[2] = '\0'; - pcVar7[3] = '\0'; - *(undefined1 **)(&stack0xffffefc4 + iVar1) = auStack_102c + iVar1; - *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb01; - sVar4 = fread(*(void **)(&stack0xffffefc4 + iVar1),*(size_t *)(BackupFilename + iVar1 + -0x20), - *(size_t *)(BackupFilename + iVar1 + -0x1c),*(FILE **)((int)&uStack_1030 + iVar1)) - ; - pFVar2 = local_1020; - if (sVar4 == sVar3) { - pcVar7 = BackupFilename + iVar1 + -0x20; - pcVar7[0] = '\x01'; - pcVar7[1] = '\0'; - pcVar7[2] = '\0'; - pcVar7[3] = '\0'; - *(size_t *)(BackupFilename + iVar1 + -0x1c) = sVar4; - *(FILE **)((int)&uStack_1030 + iVar1) = pFVar2; - *(undefined1 **)(&stack0xffffefc4 + iVar1) = local_1028; - *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804ebb4; - sVar3 = fwrite(*(void **)(&stack0xffffefc4 + iVar1), - *(size_t *)(BackupFilename + iVar1 + -0x20), - *(size_t *)(BackupFilename + iVar1 + -0x1c), - *(FILE **)((int)&uStack_1030 + iVar1)); - if (sVar3 == sVar4) goto LAB_0804eb1e; - *(char **)(&stack0xffffefc4 + iVar1) = "SaveFile: Fehler beim Schreiben der Zieldatei %s.\n" - ; - *(char **)(BackupFilename + iVar1 + -0x20) = Filename; - } - else { - *(char **)(&stack0xffffefc4 + iVar1) = "SaveFile: Fehler beim Lesen der Quelldatei %s.\n"; - *(char **)(BackupFilename + iVar1 + -0x20) = Filename; - } - *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb1e; - error(*(char **)(&stack0xffffefc4 + iVar1)); -LAB_0804eb1e: - *(FILE **)(&stack0xffffefc4 + iVar1) = __stream; - *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb26; - iVar5 = fclose(*(FILE **)(&stack0xffffefc4 + iVar1)); - if (iVar5 != 0) { - *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb75; - piVar6 = __errno_location(); - iVar5 = *piVar6; - *(undefined **)(&stack0xffffefc4 + iVar1) = &DAT_080ef3a0; - *(int *)(BackupFilename + iVar1 + -0x20) = iVar5; - *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb87; - error(*(char **)(&stack0xffffefc4 + iVar1)); - } - *(FILE **)(&stack0xffffefc4 + iVar1) = local_1020; - *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb38; - iVar5 = fclose(*(FILE **)(&stack0xffffefc4 + iVar1)); - if (iVar5 == 0) { - return; - } - *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb55; - piVar6 = __errno_location(); - iVar5 = *piVar6; - *(undefined **)(&stack0xffffefc4 + iVar1) = &DAT_080ef360; - *(int *)(BackupFilename + iVar1 + -0x20) = iVar5; - *(undefined4 *)((int)&uStack_1040 + iVar1) = 0x804eb67; - error(*(char **)(&stack0xffffefc4 + iVar1)); - return; -} - - - -// DWARF original prototype: void TReadScriptFile(TReadScriptFile * this) - -void __thiscall TReadScriptFile::TReadScriptFile(TReadScriptFile *this) - -{ - this->RecursionDepth = -1; - this->Bytes = (uchar *)this->String; - return; -} - - - -// DWARF original prototype: void TReadScriptFile(TReadScriptFile * this) - -void __thiscall TReadScriptFile::TReadScriptFile(TReadScriptFile *this) - -{ - this->RecursionDepth = -1; - this->Bytes = (uchar *)this->String; - return; -} - - - -// DWARF original prototype: void ~TReadScriptFile(TReadScriptFile * this, int __in_chrg) - -void __thiscall TReadScriptFile::~TReadScriptFile(TReadScriptFile *this,int __in_chrg) - -{ - int iVar1; - int *piVar2; - - if (this->RecursionDepth != -1) { - ::error("TReadScriptFile::~TReadScriptFile: Datei ist noch offen.\n"); - iVar1 = this->RecursionDepth; - while (iVar1 != -1) { - iVar1 = fclose((FILE *)this->File[iVar1]); - if (iVar1 != 0) { - piVar2 = __errno_location(); - ::error(&DAT_080ef4e0,*piVar2); - } - this->RecursionDepth = this->RecursionDepth + -1; - iVar1 = this->RecursionDepth; - } - } - return; -} - - - -// DWARF original prototype: void ~TReadScriptFile(TReadScriptFile * this, int __in_chrg) - -void __thiscall TReadScriptFile::~TReadScriptFile(TReadScriptFile *this,int __in_chrg) - -{ - int iVar1; - int *piVar2; - - if (this->RecursionDepth != -1) { - ::error("TReadScriptFile::~TReadScriptFile: Datei ist noch offen.\n"); - iVar1 = this->RecursionDepth; - while (iVar1 != -1) { - iVar1 = fclose((FILE *)this->File[iVar1]); - if (iVar1 != 0) { - piVar2 = __errno_location(); - ::error(&DAT_080ef4e0,*piVar2); - } - this->RecursionDepth = this->RecursionDepth + -1; - iVar1 = this->RecursionDepth; - } - } - return; -} - - - -// DWARF original prototype: void open(TReadScriptFile * this, char * FileName) - -int __thiscall TReadScriptFile::open(TReadScriptFile *this,char *__file,int __oflag,...) - -{ - int iVar1; - char *p; - int iVar2; - char *pcVar3; - char (*__dest) [4096]; - FILE *pFVar4; - int *piVar5; - undefined4 *puVar6; - int ErrorCode; - - iVar1 = this->RecursionDepth; - iVar2 = iVar1 + 1; - this->RecursionDepth = iVar2; - if (iVar2 == 3) { - ::error(&DAT_080ef560); - puVar6 = (undefined4 *)__cxa_allocate_exception(4); - *puVar6 = "Recursion depth too high"; - goto LAB_0804ee56; - } - if ((iVar2 < 1) || (*__file == '/')) { -LAB_0804ee70: - __dest = this->Filename + this->RecursionDepth; - } - else { - strcpy(this->Filename[this->RecursionDepth],this->Filename[iVar1]); - // try { // try from 0804eda1 to 0804ee91 has its CatchHandler @ 0804eea6 - pcVar3 = findLast(this->Filename[this->RecursionDepth],'/'); - if (pcVar3 == (char *)0x0) goto LAB_0804ee70; - __dest = (char (*) [4096])(pcVar3 + 1); - } - strcpy(*__dest,__file); - iVar1 = this->RecursionDepth; - pFVar4 = fopen(this->Filename[this->RecursionDepth],"rb"); - iVar2 = this->RecursionDepth; - this->File[iVar1] = (FILE *)pFVar4; - if (this->File[iVar2] != (FILE *)0x0) { - this->Line[iVar2] = 1; - return 1; - } - piVar5 = __errno_location(); - iVar1 = *piVar5; - ::error(&DAT_080ef520,this->Filename + iVar2); - pcVar3 = strerror(iVar1); - ::error("Fehler %d: %s.\n",iVar1,pcVar3); - this->RecursionDepth = this->RecursionDepth + -1; - puVar6 = (undefined4 *)__cxa_allocate_exception(4); - *puVar6 = "Cannot open script-file"; -LAB_0804ee56: - // WARNING: Subroutine does not return - __cxa_throw(puVar6,char_const*::typeinfo,0); -} - - - -// DWARF original prototype: void close(TReadScriptFile * this) - -int __thiscall TReadScriptFile::close(TReadScriptFile *this,int __fd) - -{ - int iVar1; - int *piVar2; - - iVar1 = this->RecursionDepth; - if (iVar1 != -1) { - iVar1 = fclose((FILE *)this->File[iVar1]); - if (iVar1 != 0) { - piVar2 = __errno_location(); - iVar1 = *piVar2; - ::error(&DAT_080ef4e0,iVar1); - } - this->RecursionDepth = this->RecursionDepth + -1; - return iVar1; - } - ::error("TReadScriptFile::close: Keine Datei offen.\n"); - return iVar1; -} - - - -// DWARF original prototype: void error(TReadScriptFile * this, char * Text) - -void __thiscall TReadScriptFile::error(TReadScriptFile *this,char *Text) - -{ - char *pcVar1; - int iVar2; - int *piVar3; - undefined4 *puVar4; - char *p; - char (*pacVar5) [4096]; - - // try { // try from 0804ef52 to 0804f008 has its CatchHandler @ 0804f020 - pcVar1 = findLast(this->Filename[this->RecursionDepth],'/'); - if (pcVar1 == (char *)0x0) { - iVar2 = this->RecursionDepth; - pacVar5 = this->Filename + iVar2; - } - else { - iVar2 = this->RecursionDepth; - pacVar5 = (char (*) [4096])(pcVar1 + 1); - } - snprintf(ErrorString,100,"error in script-file \"%s\", line %d: %s",pacVar5,this->Line[iVar2], - Text); - iVar2 = this->RecursionDepth; - while (iVar2 != -1) { - iVar2 = fclose((FILE *)this->File[iVar2]); - if (iVar2 != 0) { - piVar3 = __errno_location(); - ::error(&DAT_080ef4e0,*piVar3); - } - this->RecursionDepth = this->RecursionDepth + -1; - iVar2 = this->RecursionDepth; - } - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = ErrorString; - // WARNING: Subroutine does not return - __cxa_throw(puVar4,char*::typeinfo,0); -} - - - -// WARNING: Variable defined which should be unmapped: pos -// DWARF original prototype: void nextToken(TReadScriptFile * this) - -void __thiscall TReadScriptFile::nextToken(TReadScriptFile *this) - -{ - char *__file; - FILE *__stream; - bool bVar1; - uint uVar2; - int iVar3; - int *piVar4; - int State; - undefined4 uVar5; - int c; - char *pcVar6; - int in_stack_ffffffcc; - int local_1c; - int Sign; - FILE *f; - int pos; - - if (this->RecursionDepth == -1) { - ::error(&DAT_080ef660); -LAB_0804f216: - this->Token = ENDOFFILE; - return; - } - __file = this->String; -LAB_0804f062: - f = (FILE *)0x0; - uVar5 = 0; - uVar2 = 4000; - pcVar6 = __file; - if (((uint)__file & 4) != 0) { - pcVar6 = this->String + 4; - uVar2 = 0xf9c; - this->String[0] = '\0'; - this->String[1] = '\0'; - this->String[2] = '\0'; - this->String[3] = '\0'; - } - for (uVar2 = uVar2 >> 2; uVar2 != 0; uVar2 = uVar2 - 1) { - pcVar6[0] = '\0'; - pcVar6[1] = '\0'; - pcVar6[2] = '\0'; - pcVar6[3] = '\0'; - pcVar6 = pcVar6 + 4; - } - this->Number = 0; - __stream = (FILE *)this->File[this->RecursionDepth]; - local_1c = 1; -LAB_0804f0b6: - if (f == (FILE *)0xf9f) { - error(this,"string too long"); - } - switch(uVar5) { - case 0: - iVar3 = getc(__stream); - if (iVar3 != -1) { - if (iVar3 == 10) { - this->Line[this->RecursionDepth] = this->Line[this->RecursionDepth] + 1; - } - else { - // try { // try from 0804f0f5 to 0804f92b has its CatchHandler @ 0804f931 - bVar1 = isSpace(iVar3); - if (((!bVar1) && (uVar5 = 1, iVar3 != 0x23)) && (uVar5 = 0x1e, iVar3 != 0x40)) { - bVar1 = isAlpha(iVar3); - if (bVar1) { - uVar5 = 2; - this->String[(int)f] = (char)iVar3; - f = (FILE *)((int)&f->_flags + 1); - } - else { - bVar1 = isDigit(iVar3); - if (bVar1) { - this->Number = iVar3 + -0x30; - uVar5 = 3; - } - else { - uVar5 = 6; - if (((iVar3 != 0x22) && (uVar5 = 0xb, iVar3 != 0x5b)) && - ((uVar5 = 0x16, iVar3 != 0x3c && - ((uVar5 = 0x19, iVar3 != 0x3e && (uVar5 = 0x1b, iVar3 != 0x2d)))))) - { - uVar5 = 10; - this->Special = (char)iVar3; - } - } - } - } - } - goto LAB_0804f0b6; - } -LAB_0804f1c2: - iVar3 = this->RecursionDepth; - if (iVar3 < 1) goto LAB_0804f216; - if (iVar3 == -1) { - ::error("TReadScriptFile::close: Keine Datei offen.\n"); - } - else { - iVar3 = fclose((FILE *)this->File[iVar3]); - if (iVar3 != 0) { - piVar4 = __errno_location(); - ::error(&DAT_080ef4e0,*piVar4); - } - this->RecursionDepth = this->RecursionDepth + -1; + iVar3 = fclose((FILE *)this->File[iVar3]); + if (iVar3 != 0) { + piVar4 = __errno_location(); + ::error(&DAT_080ef4e0,*piVar4); + } + this->RecursionDepth = this->RecursionDepth + -1; } goto LAB_0804f062; case 1: @@ -8623,188 +7768,14 @@ void ReadConfig(void) strcpy(QUERY_MANAGER[NumberOfQueryManagers].Password,pcVar5); DisguisePassword(QUERY_MANAGER[NumberOfQueryManagers].Password,"Pm-,o%yD"); pcVar5 = (char *)0x29; - TReadScriptFile::readSymbol(pTVar1,')'); - NumberOfQueryManagers = NumberOfQueryManagers + 1; - cVar3 = TReadScriptFile::readSpecial(pTVar1); - } while (cVar3 != '}'); - } - } while( true ); -} - - - -// WARNING: Variable defined which should be unmapped: t - -void GetAmbiente(int *Brightness,int *Color) - -{ - int iVar1; - int Time; - tm *ptVar2; - time_t local_14; - time_t t; - - local_14 = time((time_t *)0x0); - ptVar2 = localtime(&local_14); - iVar1 = ptVar2->tm_sec + ptVar2->tm_min * 0x3c; - iVar1 = ((iVar1 % 0x96) * 2) / 5 + (iVar1 / 0x96) * 0x3c; - if (iVar1 < 0x3c) { -LAB_08053cb0: - *Brightness = 0x33; - } - else { - if (0x77 < iVar1) { - if (iVar1 < 0xb4) { - *Brightness = 0x99; -LAB_08053c88: - *Color = 0xad; - return; - } - if (iVar1 < 0xf0) { - *Brightness = 0xcc; - goto LAB_08053c88; - } - if (0x564 < iVar1) goto LAB_08053cb0; - if (iVar1 < 0x529) { - if (0x4ec < iVar1) { - *Brightness = 0x99; -LAB_08053ce5: - *Color = 0xd0; - return; - } - if (0x4b0 < iVar1) { - *Brightness = 0xcc; - goto LAB_08053ce5; - } - *Brightness = 0xff; - goto LAB_08053cb6; - } - } - *Brightness = 0x66; - } -LAB_08053cb6: - *Color = 0xd7; - return; -} - - - -// WARNING: Variable defined which should be unmapped: t - -void GetDate(int *Year,int *Cycle,int *Day) - -{ - tm *ptVar1; - tm *Time; - int local_10; - time_t t; - - local_10 = time((time_t *)0x0); - ptVar1 = localtime(&local_10); - *Year = (local_10 / 0x15180 + 4) / 7; - *Cycle = ptVar1->tm_wday; - *Day = ptVar1->tm_hour; - return; -} - - - -// WARNING: Variable defined which should be unmapped: t - -void GetTime(int *Hour,int *Minute) - -{ - tm *ptVar1; - tm *Time; - time_t local_14; - time_t t; - - local_14 = time((time_t *)0x0); - ptVar1 = localtime(&local_14); - *Hour = (ptVar1->tm_sec + ptVar1->tm_min * 0x3c) / 0x96; - *Minute = (((ptVar1->tm_sec + ptVar1->tm_min * 0x3c) % 0x96) * 2) / 5; - return; -} - - - -// WARNING: Variable defined which should be unmapped: t - -void GetRealTime(int *Hour,int *Minute) - -{ - tm *ptVar1; - time_t local_8; - time_t t; - - local_8 = time((time_t *)0x0); - ptVar1 = localtime(&local_8); - *Hour = ptVar1->tm_hour; - *Minute = ptVar1->tm_min; - return; -} - - - -// WARNING: Variable defined which should be unmapped: t - -ulong GetRoundAtTime(int Hour,int Minute) - -{ - int Delta; - tm *ptVar1; - uint uVar2; - tm *Time; - time_t local_c; - time_t t; - - local_c = time((time_t *)0x0); - ptVar1 = localtime(&local_c); - uVar2 = ((Hour - ptVar1->tm_hour) * 0xe10 + (Minute - ptVar1->tm_min) * 0x3c) - ptVar1->tm_sec; - if (0x7fffffff < uVar2) { - uVar2 = uVar2 + 0x15180; - } - return uVar2 + RoundNr; -} - - - -// WARNING: Variable defined which should be unmapped: t -// WARNING: Unknown calling convention -- yet parameter storage is locked - -ulong GetRoundForNextMinute(void) - -{ - int iVar1; - int iVar2; - ulong NewRound; - tm *ptVar3; - int Delta; - uint uVar4; - time_t local_14; - time_t t_1; - time_t t; - - t_1 = time((time_t *)0x0); - ptVar3 = localtime(&t_1); - iVar1 = ptVar3->tm_hour; - iVar2 = ptVar3->tm_min; - local_14 = time((time_t *)0x0); - ptVar3 = localtime(&local_14); - uVar4 = ((iVar1 - ptVar3->tm_hour) * 0xe10 + ((iVar2 + 1) - ptVar3->tm_min) * 0x3c) - - ptVar3->tm_sec; - if (0x7fffffff < uVar4) { - uVar4 = uVar4 + 0x15180; - } - for (uVar4 = uVar4 + 0x1e + RoundNr; uVar4 < RoundNr + 0x1e; uVar4 = uVar4 + 0x3c) { - } - for (; RoundNr + 0x5a < uVar4; uVar4 = uVar4 - 0x3c) { - } - return uVar4; + TReadScriptFile::readSymbol(pTVar1,')'); + NumberOfQueryManagers = NumberOfQueryManagers + 1; + cVar3 = TReadScriptFile::readSpecial(pTVar1); + } while (cVar3 != '}'); + } + } while( true ); } - - void __static_initialization_and_destruction_0(int __initialize_p,int __priority) { @@ -8890,296 +7861,48 @@ void __static_initialization_and_destruction_0(int __initialize_p,int __priority if (!bVar1) { error(&DAT_080f0a80,0); } - SpecialObjects[8].TypeID = 0; - bVar1 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[9].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - SpecialObjects[10].TypeID = 0; - bVar1 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0xb].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - SpecialObjects[0xc].TypeID = 0; - bVar1 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0xd].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0xe].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0xf].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - SpecialObjects[0x10].TypeID = 0; - bVar1 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x11].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - SpecialObjects[0x12].TypeID = 0; - bVar1 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x13].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - SpecialObjects[0x14].TypeID = 0; - bVar1 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x15].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x16].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x17].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - SpecialObjects[0x18].TypeID = 0; - bVar1 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x19].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - SpecialObjects[0x1a].TypeID = 0; - bVar1 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x1b].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - SpecialObjects[0x1c].TypeID = 0; - bVar1 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x1d].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x1e].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x1f].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - SpecialObjects[0x20].TypeID = 0; - bVar1 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x21].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - SpecialObjects[0x22].TypeID = 0; - bVar1 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x23].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - SpecialObjects[0x24].TypeID = 0; - bVar1 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x25].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } - bVar1 = false; - SpecialObjects[0x26].TypeID = 0; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,0); - } + SpecialObjects[8].TypeID = 0; bVar1 = false; - SpecialObjects[0x27].TypeID = 0; if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { bVar1 = true; } if (!bVar1) { error(&DAT_080f0a80,0); } - SpecialObjects[0x28].TypeID = 0; bVar1 = false; + SpecialObjects[9].TypeID = 0; if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { bVar1 = true; } if (!bVar1) { error(&DAT_080f0a80,0); } + SpecialObjects[10].TypeID = 0; bVar1 = false; - SpecialObjects[0x29].TypeID = 0; if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { bVar1 = true; } if (!bVar1) { error(&DAT_080f0a80,0); } - SpecialObjects[0x2a].TypeID = 0; bVar1 = false; + SpecialObjects[0xb].TypeID = 0; if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { bVar1 = true; } if (!bVar1) { error(&DAT_080f0a80,0); } + SpecialObjects[0xc].TypeID = 0; bVar1 = false; - SpecialObjects[0x2b].TypeID = 0; if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { bVar1 = true; } if (!bVar1) { error(&DAT_080f0a80,0); } - SpecialObjects[0x2c].TypeID = 0; bVar1 = false; + SpecialObjects[0xd].TypeID = 0; if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { bVar1 = true; } @@ -9187,1641 +7910,1171 @@ void __static_initialization_and_destruction_0(int __initialize_p,int __priority error(&DAT_080f0a80,0); } bVar1 = false; - SpecialObjects[0x2d].TypeID = 0; + SpecialObjects[0xe].TypeID = 0; if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { bVar1 = true; } if (!bVar1) { error(&DAT_080f0a80,0); } - SpecialObjects[0x2e].TypeID = 0; bVar1 = false; + SpecialObjects[0xf].TypeID = 0; if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { bVar1 = true; } if (!bVar1) { error(&DAT_080f0a80,0); } + SpecialObjects[0x10].TypeID = 0; bVar1 = false; - SpecialObjects[0x2f].TypeID = 0; - if ((ObjectTypes.min < 1) && (bVar1 = true, ObjectTypes.max < 0)) { - bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; } if (!bVar1) { error(&DAT_080f0a80,0); } - SpecialObjects[0x30].TypeID = 0; - } - return; -} - - - -int GetFlagByName(char *Name) - -{ - int iVar1; - int i; - int iVar2; - char (*s1) [20]; - - iVar2 = 0; - s1 = FlagNames; - do { - iVar1 = stricmp(*s1,Name,-1); - if (iVar1 == 0) { - return iVar2; - } - iVar2 = iVar2 + 1; - s1 = s1 + 1; - } while (iVar2 < 0x42); - return -1; -} - - - -int GetTypeAttributeByName(char *Name) - -{ - int iVar1; - int i; - int iVar2; - char (*s1) [30]; - - iVar2 = 0; - s1 = TypeAttributeNames; - do { - iVar1 = stricmp(*s1,Name,-1); - if (iVar1 == 0) { - return iVar2; - } - iVar2 = iVar2 + 1; - s1 = s1 + 1; - } while (iVar2 < 0x3e); - return -1; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void LoadObjects(void) - -{ - FLAG FVar1; - bool bVar2; - bool bVar3; - char cVar4; - char *pcVar5; - TObjectType *pTVar6; - ulong uVar7; - int iVar8; - uint uVar9; - int iVar10; - int TypeID; - int i; - FLAG FVar11; - char *pcVar12; - undefined1 uVar13; - char *pcVar14; - char (*local_5084) [20]; - char (*local_5080) [30]; - int local_5074; - uchar b; - char *local_5050; - int local_5048; - int i_2; - int Offset; - char local_501c [4]; - char Ident [30]; - TReadScriptFile Script; - char local_101c [4]; - char FileName [4096]; - - local_5050 = local_101c; - pcVar14 = DATAPATH; - sprintf(local_5050,"%s/objects.srv"); - // try { // try from 08054e09 to 08054e0d has its CatchHandler @ 08055640 - TReadScriptFile::TReadScriptFile((TReadScriptFile *)(Ident + 0x1c)); - // try { // try from 08054e1b to 080555fd has its CatchHandler @ 08055620 - TReadScriptFile::open((TReadScriptFile *)(Ident + 0x1c),local_5050,(int)pcVar14); - pcVar14 = (char *)0xffffffff; -LAB_08054e25: - TReadScriptFile::nextToken((TReadScriptFile *)(Ident + 0x1c)); - if (stack0xffffb004 == 0) { - TReadScriptFile::close((TReadScriptFile *)(Ident + 0x1c),(int)local_5050); - // try { // try from 08055607 to 0805560b has its CatchHandler @ 08055640 - TReadScriptFile::~TReadScriptFile((TReadScriptFile *)(Ident + 0x1c),(int)local_5050); - return; - } - uVar13 = stack0xffffb004 == 1; - if (!(bool)uVar13) { - TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"Identifier expected"); - } - pcVar5 = TReadScriptFile::getIdentifier((TReadScriptFile *)(Ident + 0x1c)); - strcpy(local_501c,pcVar5); - local_5050 = (char *)0x3d; - TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'='); - iVar10 = 7; - pcVar5 = local_501c; - pcVar12 = "typeid"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar5 == *pcVar12; - pcVar5 = pcVar5 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - pcVar14 = (char *)TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); - pTVar6->Name = (char *)0x0; - pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); - pTVar6->Description = (char *)0x0; - pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); - pTVar6->Flags[0] = '\0'; - pTVar6->Flags[1] = '\0'; - pTVar6->Flags[2] = '\0'; - pTVar6->Flags[3] = '\0'; - iVar10 = 0; - pTVar6->Flags[4] = '\0'; - pTVar6->Flags[5] = '\0'; - pTVar6->Flags[6] = '\0'; - pTVar6->Flags[7] = '\0'; - pTVar6->Flags[8] = '\0'; - do { - pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); - pTVar6->Attributes[iVar10] = 0; - iVar10 = iVar10 + 1; - } while (iVar10 < 0x3e); - iVar10 = 0; - do { - local_5050 = pcVar14; - pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); - pTVar6->AttributeOffsets[iVar10] = -1; - iVar10 = iVar10 + 1; - } while (iVar10 < 0x12); - } - uVar13 = pcVar14 == (char *)0x0; - if ((int)pcVar14 < 0) { - local_5050 = "Invalid type id"; - TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"Invalid type id"); - } - iVar10 = 5; - pcVar5 = local_501c; - pcVar12 = "name"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar5 == *pcVar12; - pcVar5 = pcVar5 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_5050 = pcVar14; - pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); - pcVar5 = TReadScriptFile::readString((TReadScriptFile *)(Ident + 0x1c)); - pcVar5 = AddStaticString(pcVar5); - pTVar6->Name = pcVar5; - } - iVar10 = 0xc; - pcVar5 = local_501c; - pcVar12 = "description"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar5 == *pcVar12; - pcVar5 = pcVar5 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_5050 = pcVar14; - pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); - pcVar5 = TReadScriptFile::readString((TReadScriptFile *)(Ident + 0x1c)); - pcVar5 = AddStaticString(pcVar5); - pTVar6->Description = pcVar5; - } - iVar10 = 6; - pcVar5 = local_501c; - pcVar12 = "flags"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar5 == *pcVar12; - pcVar5 = pcVar5 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'{'); -LAB_08055258: - TReadScriptFile::nextToken((TReadScriptFile *)(Ident + 0x1c)); - if (stack0xffffb004 != 6) goto LAB_080552b0; - cVar4 = TReadScriptFile::getSpecial((TReadScriptFile *)(Ident + 0x1c)); - i_2 = 0; - local_5048 = 0; - if (cVar4 != '}') goto code_r0x08055295; - goto LAB_08055365; - } - goto LAB_08054f04; -code_r0x08055295: - if ((stack0xffffb004 != 6) || - (cVar4 = TReadScriptFile::getSpecial((TReadScriptFile *)(Ident + 0x1c)), cVar4 != ',')) { -LAB_080552b0: - pcVar5 = TReadScriptFile::getIdentifier((TReadScriptFile *)(Ident + 0x1c)); - iVar10 = 0; - local_5084 = FlagNames; - do { - iVar8 = stricmp(*local_5084,pcVar5,-1); - if (iVar8 == 0) goto LAB_08055307; - local_5084 = local_5084 + 1; - iVar10 = iVar10 + 1; - } while (iVar10 < 0x42); - iVar10 = -1; -LAB_08055307: - if (iVar10 == -1) { - TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"Unknown flag"); + bVar1 = false; + SpecialObjects[0x11].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; } - pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); - iVar8 = iVar10 + 7; - if (-1 < iVar10) { - iVar8 = iVar10; + if (!bVar1) { + error(&DAT_080f0a80,0); } - pTVar6->Flags[iVar8 >> 3] = - pTVar6->Flags[iVar8 >> 3] | - (byte)(1 << ((char)iVar10 - (char)((iVar8 >> 3) << 3) & 0x1fU)); - } - goto LAB_08055258; -LAB_08055365: - do { - bVar3 = false; - bVar2 = false; - if ((ObjectTypes.min <= (int)pcVar14) && ((int)pcVar14 <= ObjectTypes.max)) { - bVar2 = true; + SpecialObjects[0x12].TypeID = 0; + bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; } - local_5050 = pcVar14; - if (!bVar2) { - error(&DAT_080f0a80,pcVar14); - local_5050 = (char *)0x0; + if (!bVar1) { + error(&DAT_080f0a80,0); } - FVar1 = InstanceAttributeFlags[local_5048]; - FVar11 = FVar1; - if (0x7fffffff < FVar1) { - FVar11 = FVar1 + USEEVENT; + bVar1 = false; + SpecialObjects[0x13].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; } - uVar9 = 1 << ((char)FVar1 + (char)((int)FVar11 >> 3) * -8 & 0x1fU); - pTVar6 = vector<>::operator()(&ObjectTypes,(int)local_5050); - if ((uint)(pTVar6->Flags[(int)FVar11 >> 3] & (byte)uVar9) == (uVar9 & 0xff)) { -LAB_08055442: - bVar3 = true; + if (!bVar1) { + error(&DAT_080f0a80,0); } - else if (local_5048 == 0) { - bVar2 = false; - if ((ObjectTypes.min <= (int)pcVar14) && (bVar2 = true, ObjectTypes.max < (int)pcVar14)) - { - bVar2 = false; - } - local_5050 = pcVar14; - if (!bVar2) { - error(&DAT_080f0a80,pcVar14); - local_5050 = (char *)0x0; - } - pTVar6 = vector<>::operator()(&ObjectTypes,(int)local_5050); - if ((pTVar6->Flags[0] & 0x20) != 0) goto LAB_08055442; + SpecialObjects[0x14].TypeID = 0; + bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; } - if (bVar3) { - local_5050 = pcVar14; - pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); - pTVar6->AttributeOffsets[local_5048] = i_2; - i_2 = i_2 + 1; + if (!bVar1) { + error(&DAT_080f0a80,0); } - local_5048 = local_5048 + 1; - uVar13 = local_5048 == 0x11; - } while (local_5048 < 0x12); -LAB_08054f04: - iVar10 = 0xb; - pcVar5 = local_501c; - pcVar12 = "attributes"; - do { - if (iVar10 == 0) break; - iVar10 = iVar10 + -1; - uVar13 = *pcVar5 == *pcVar12; - pcVar5 = pcVar5 + 1; - pcVar12 = pcVar12 + 1; - } while ((bool)uVar13); - if ((bool)uVar13) { - local_5050 = (char *)0x7b; - TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'{'); -LAB_08054f35: - TReadScriptFile::nextToken((TReadScriptFile *)(Ident + 0x1c)); - if (stack0xffffb004 != 6) goto LAB_08054f7d; - cVar4 = TReadScriptFile::getSpecial((TReadScriptFile *)(Ident + 0x1c)); - if (cVar4 != '}') goto code_r0x08054f62; - } - goto LAB_08054e25; -code_r0x08054f62: - if ((stack0xffffb004 != 6) || - (cVar4 = TReadScriptFile::getSpecial((TReadScriptFile *)(Ident + 0x1c)), cVar4 != ',')) { -LAB_08054f7d: - pcVar5 = TReadScriptFile::getIdentifier((TReadScriptFile *)(Ident + 0x1c)); - local_5074 = 0; - local_5080 = TypeAttributeNames; - do { - iVar10 = stricmp(*local_5080,pcVar5,-1); - if (iVar10 == 0) goto LAB_08054fde; - local_5080 = local_5080 + 1; - local_5074 = local_5074 + 1; - } while (local_5074 < 0x3e); - local_5074 = -1; -LAB_08054fde: - if (local_5074 == -1) { - TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"Unknown attribute"); + bVar1 = false; + SpecialObjects[0x15].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; } - TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'='); - local_5050 = pcVar14; - pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); - uVar7 = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - pTVar6->Attributes[local_5074] = uVar7; - if (local_5074 == 0x3d) { - local_5050 = pcVar14; - pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); - uVar7 = pTVar6->Attributes[0x3d]; - bVar2 = false; - if ((0 < (int)uVar7) && ((int)uVar7 < 0x32)) { - bVar2 = true; - } - if (!bVar2) { - local_5050 = "Unknown meaning"; - TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"Unknown meaning"); - } - bVar2 = false; - if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { - bVar2 = true; - } - if (!bVar2) { - local_5050 = (char *)0x0; - error(&DAT_080f0a80); - } - bVar2 = false; - if ((ObjectTypes.min < 1) && (bVar2 = true, ObjectTypes.max < 0)) { - bVar2 = false; - } - if (!bVar2) { - local_5050 = (char *)0x0; - error(&DAT_080f0a80); - } - if (SpecialObjects[uVar7].TypeID != 0) { - local_5050 = "Special object already defined"; - TReadScriptFile::error - ((TReadScriptFile *)(Ident + 0x1c),"Special object already defined"); - } - bVar2 = false; - if ((ObjectTypes.min <= (int)pcVar14) && ((int)pcVar14 <= ObjectTypes.max)) { - bVar2 = true; - } - pcVar5 = pcVar14; - if (!bVar2) { - local_5050 = pcVar14; - error(&DAT_080f0a80); - pcVar5 = (char *)0x0; - } - bVar2 = false; - if ((ObjectTypes.min <= (int)pcVar5) && ((int)pcVar5 <= ObjectTypes.max)) { - bVar2 = true; - } - if (!bVar2) { - local_5050 = pcVar5; - error(&DAT_080f0a80); - pcVar5 = (char *)0x0; - } - iVar8 = ObjectTypes.max; - iVar10 = ObjectTypes.min; - SpecialObjects[uVar7].TypeID = (int)pcVar5; - if ((int)pcVar5 < iVar10 || iVar8 < (int)pcVar5) { - error(&DAT_080f0a80); - local_5050 = pcVar5; - } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x16].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x17].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + SpecialObjects[0x18].TypeID = 0; + bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x19].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + SpecialObjects[0x1a].TypeID = 0; + bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x1b].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + SpecialObjects[0x1c].TypeID = 0; + bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x1d].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x1e].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x1f].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); } - } - goto LAB_08054f35; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void LoadConversionList(void) - -{ - istream *this; - int i; - int iVar1; - undefined4 *puVar2; - int local_1148; - int Type; - int Number; - int Group; - char FileName [4096]; - ifstream IN; - undefined4 local_134 [3]; - uint auStack_128 [23]; - __basic_file local_cc [25]; - undefined1 local_b3; - undefined *local_ac; - ios_base local_a8 [16]; - uint local_98; - - this = (istream *)(FileName + 0xffc); - // try { // try from 0805566b to 0805566f has its CatchHandler @ 08055a21 - std::ios_base::ios_base(local_a8); - local_ac = (undefined *)0x8128950; - // try { // try from 0805568e to 08055692 has its CatchHandler @ 080559a2 - std::istream::istream(this,(streambuf *)(std::ifstream::VTT + 4)); - FileName._4092_4_ = &DAT_08128994; - local_ac = &DAT_081289a8; - // try { // try from 080556b2 to 080556b6 has its CatchHandler @ 0805599c - std::filebuf::filebuf((filebuf *)local_134); - // try { // try from 080556ca to 080556ce has its CatchHandler @ 08055955 - std::ios::init((EVP_PKEY_CTX *)&local_ac); - iVar1 = 0; - do { - OldGroup[iVar1] = '\0'; - OldNumber[iVar1] = '\0'; - iVar1 = iVar1 + 1; - } while (iVar1 < 0x2000); - iVar1 = 0; - do { - NewType[iVar1] = -1; - iVar1 = iVar1 + 1; - } while (iVar1 < 0x10000); - sprintf((char *)&Group,"%s/conversion.lst",DATAPATH); - // try { // try from 08055742 to 08055831 has its CatchHandler @ 080559a8 - iVar1 = std::filebuf::open((char *)local_134,(int)&Group,8); - if (iVar1 == 0) { - std::ios::clear(this + *(int *)(FileName._4092_4_ + -0xc), - *(uint *)((int)auStack_128 + *(int *)(FileName._4092_4_ + -0xc)) | 4); - } - if ((local_98 & 5) == 0) { - while( true ) { - std::istream::operator>>(this,&Number); - if ((local_98 & 2) != 0) { - iVar1 = std::filebuf::close((int)local_134); - if (iVar1 == 0) { - // try { // try from 08055904 to 0805594f has its CatchHandler @ 080559a8 - std::ios::clear(this + *(int *)(FileName._4092_4_ + -0xc), - *(uint *)((int)auStack_128 + *(int *)(FileName._4092_4_ + -0xc)) - | 4); - } - iVar1 = 0; - do { - OldGroup[iVar1] = '\0'; - OldNumber[iVar1] = (uchar)iVar1; - NewType[iVar1] = iVar1; - iVar1 = iVar1 + 1; - } while (iVar1 < 0xb); - OldGroup[99] = 0xfa; - NewType[64000] = 99; - OldNumber[99] = '\0'; - FileName._4092_4_ = &DAT_08128994; - local_ac = &DAT_081289a8; - local_134[0] = 0x8128ad0; - // try { // try from 08055899 to 080558de has its CatchHandler @ 08055a21 - std::filebuf::close((int)local_134); - local_b3 = 0; - std::__basic_file::~__basic_file(local_cc); - std::streambuf::~streambuf((streambuf *)local_134); - std::istream::~istream(this); - std::ios::~ios((ios *)&local_ac); - return; - } - std::istream::operator>>(this,&Type); - std::istream::operator>>(this,&local_1148); - if (0x1ffe < local_1148 - 1U) break; - OldGroup[local_1148] = (uchar)Number; - OldNumber[local_1148] = (uchar)Type; - NewType[Number * 0x100 + Type] = local_1148; + SpecialObjects[0x20].TypeID = 0; + bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); } - error(&DAT_080f0ae0,local_1148); - puVar2 = (undefined4 *)__cxa_allocate_exception(4); - *puVar2 = "Error while loading conversion.lst"; - } - else { - error(&DAT_080f0b60); - puVar2 = (undefined4 *)__cxa_allocate_exception(4); - *puVar2 = "Cannot open conversion.lst"; - } - // WARNING: Subroutine does not return - __cxa_throw(puVar2,char_const*::typeinfo,0); -} - - - -ObjectType GetNewObjectType(uchar Group,uchar Number) - -{ - bool bVar1; - int Type; - uint uVar2; - int iVar3; - undefined3 in_stack_00000005; - byte in_stack_0000000c; - - uVar2 = (uint)in_stack_0000000c; - iVar3 = NewType[CONCAT11(Number,in_stack_0000000c)]; - if (iVar3 == -1) { - error("GetNewObjectType: Objekttyp %d/%d existiert nicht.\n",(uint)Number,uVar2); bVar1 = false; + SpecialObjects[0x21].TypeID = 0; if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { bVar1 = true; } if (!bVar1) { - error(&DAT_080f0a80,0,uVar2); + error(&DAT_080f0a80,0); } - *_Group = 0; - } - else { + SpecialObjects[0x22].TypeID = 0; bVar1 = false; - if ((ObjectTypes.min <= iVar3) && (iVar3 <= ObjectTypes.max)) { + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { bVar1 = true; } if (!bVar1) { - error(&DAT_080f0a80,iVar3); - iVar3 = 0; + error(&DAT_080f0a80,0); } - *_Group = iVar3; - } - return (ObjectType)(int)_Group; -} - - - -void GetOldObjectType(ObjectType *Type,uchar *Group,uchar *Number) - -{ - int iVar1; - bool bVar2; - - bVar2 = false; - iVar1 = Type->TypeID; - if ((ObjectTypes.min <= iVar1) && (iVar1 <= ObjectTypes.max)) { - bVar2 = true; - } - if (bVar2) { - *Group = OldGroup[iVar1]; - *Number = OldNumber[Type->TypeID]; - return; - } - error(&DAT_080f0be0); - return; -} - - - -bool ObjectTypeExists(uchar Group,uchar Number) - -{ - return (bool)((byte)~(byte)((uint)NewType[CONCAT11(Group,Number)] >> 0x18) >> 7); -} - - - -// DWARF original prototype: void setTypeID(ObjectType * this, int _TypeID) - -void __thiscall ObjectType::setTypeID(ObjectType *this,int _TypeID) - -{ - bool bVar1; - - bVar1 = false; - if ((ObjectTypes.min <= _TypeID) && (_TypeID <= ObjectTypes.max)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,_TypeID); - _TypeID = 0; - } - this->TypeID = _TypeID; - return; -} - - - -// DWARF original prototype: char * getName(ObjectType * this, int Count) - -char * __thiscall ObjectType::getName(ObjectType *this) - -{ - char *pcVar1; - TObjectType *pTVar2; - int in_stack_00000008; - char local_4c [4]; - char ObjectName [50]; - - local_4c[0] = '\0'; - if (this->TypeID == 99) { - error("ObjectType::getName: Der Kreaturtyp hat keinen Namen.\n"); - pcVar1 = (char *)0x0; - } - else { - pTVar2 = vector<>::operator()(&ObjectTypes,this->TypeID); - if (pTVar2->Name != (char *)0x0) { - strcpy(local_4c,pTVar2->Name); + bVar1 = false; + SpecialObjects[0x23].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + SpecialObjects[0x24].TypeID = 0; + bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x25].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x26].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); } - pcVar1 = Plural(local_4c,in_stack_00000008); - } - return pcVar1; -} - - - -// DWARF original prototype: char * getDescription(ObjectType * this) - -char * __thiscall ObjectType::getDescription(ObjectType *this) - -{ - TObjectType *pTVar1; - - pTVar1 = vector<>::operator()(&ObjectTypes,this->TypeID); - return pTVar1->Description; -} - - - -// DWARF original prototype: bool getFlag(ObjectType * this, FLAG Flag) - -bool __thiscall ObjectType::getFlag(ObjectType *this,FLAG Flag) - -{ - uint uVar1; - TObjectType *pTVar2; - FLAG FVar3; - uchar b; - - FVar3 = Flag + USEEVENT; - if (-1 < (int)Flag) { - FVar3 = Flag; - } - uVar1 = 1 << ((char)Flag + (char)((int)FVar3 >> 3) * -8 & 0x1fU); - pTVar2 = vector<>::operator()(&ObjectTypes,this->TypeID); - return (uint)(pTVar2->Flags[(int)FVar3 >> 3] & (byte)uVar1) == (uVar1 & 0xff); -} - - - -// DWARF original prototype: ulong getAttribute(ObjectType * this, TYPEATTRIBUTE Attribute) - -ulong __thiscall ObjectType::getAttribute(ObjectType *this,TYPEATTRIBUTE Attribute) - -{ - FLAG FVar1; - uint uVar2; - TObjectType *pTVar3; - ulong uVar4; - FLAG FVar5; - uchar b; - - FVar1 = TypeAttributeFlags[Attribute]; - FVar5 = FVar1 + USEEVENT; - if (-1 < (int)FVar1) { - FVar5 = FVar1; - } - uVar2 = 1 << ((char)FVar1 + (char)((int)FVar5 >> 3) * -8 & 0x1fU); - pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); - if ((uint)(pTVar3->Flags[(int)FVar5 >> 3] & (byte)uVar2) == (uVar2 & 0xff)) { - pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); - uVar4 = pTVar3->Attributes[Attribute]; - } - else { - error(&DAT_080f0c60,this->TypeID,TypeAttributeFlags[Attribute],Attribute); - uVar4 = 0; - } - return uVar4; -} - - - -// DWARF original prototype: int getAttributeOffset(ObjectType * this, INSTANCEATTRIBUTE Attribute) - -int __thiscall ObjectType::getAttributeOffset(ObjectType *this,INSTANCEATTRIBUTE Attribute) - -{ - FLAG FVar1; - uint uVar2; - TObjectType *pTVar3; - int iVar4; - FLAG FVar5; - uchar b; - - FVar1 = InstanceAttributeFlags[Attribute]; - FVar5 = FVar1 + USEEVENT; - if (-1 < (int)FVar1) { - FVar5 = FVar1; - } - uVar2 = 1 << ((char)FVar1 + (char)((int)FVar5 >> 3) * -8 & 0x1fU); - pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); - if ((uint)(pTVar3->Flags[(int)FVar5 >> 3] & (byte)uVar2) == (uVar2 & 0xff)) { -LAB_08055e2a: - pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); - iVar4 = pTVar3->AttributeOffsets[Attribute]; - } - else { - if (Attribute == CONTENT) { - pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); - if ((pTVar3->Flags[0] & 0x20) != 0) goto LAB_08055e2a; + bVar1 = false; + SpecialObjects[0x27].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; } - iVar4 = -1; - } - return iVar4; -} - - - -bool ObjectTypeExists(int TypeID) - -{ - bool bVar1; - - bVar1 = false; - if ((ObjectTypes.min <= TypeID) && (TypeID <= ObjectTypes.max)) { - bVar1 = true; - } - return bVar1; -} - - - -ObjectType GetSpecialObject(SPECIALMEANING Meaning) - -{ - bool bVar1; - int in_stack_00000008; - char *Text; - int _TypeID; - ObjectType local_2c [7]; - - bVar1 = false; - if ((0 < in_stack_00000008) && (in_stack_00000008 < 0x32)) { - bVar1 = true; - } - if (bVar1) { - ObjectType::setTypeID(local_2c,0); - _TypeID = SpecialObjects[in_stack_00000008].TypeID; - if (_TypeID != local_2c[0].TypeID) goto LAB_08055ec3; - Text = "GetSpecialObject: Kein Objekttyp mit Bedeutung %d definiert.\n"; - } - else { - Text = &DAT_080f0cc0; - } - error(Text); - _TypeID = 0; -LAB_08055ec3: - ObjectType::setTypeID((ObjectType *)Meaning,_TypeID); - return (ObjectType)Meaning; -} - - - -ObjectType GetObjectTypeByName(char *SearchName,bool Movable) - -{ - TObjectType *pTVar1; - char *pcVar2; - int iVar3; - char *ObjectName; - int TypeID; - int _TypeID; - undefined3 in_stack_00000009; - char in_stack_0000000c; - ObjectType _TypeID_00; - char local_dc [3]; - bool Movable_local; - char Help [50]; - ObjectType local_9c [4]; - ObjectType local_8c [4]; - ObjectType local_7c; - ObjectType Type; - ObjectType local_6c; - ObjectType BestType; - char local_5c [4]; - char Pattern [50]; - - if (_Movable == (char *)0x0) { - error("GetObjectTypeByName: SearchName ist NULL.\n"); - _TypeID_00.TypeID = 0; - } - else { - snprintf(local_5c,0x32," %s ",_Movable); - ObjectType::setTypeID(&local_6c,0); - ObjectType::setTypeID(&local_7c,99); - _TypeID = local_7c.TypeID + 1; - _TypeID_00.TypeID = local_6c.TypeID; - if (_TypeID <= ObjectTypes.max) { - do { - ObjectType::setTypeID(&local_7c,_TypeID); - if ((((in_stack_0000000c == '\0') || - (pTVar1 = vector<>::operator()(&ObjectTypes,local_7c.TypeID), - (pTVar1->Flags[4] & 2) == 0)) && - (pcVar2 = ObjectType::getName(&local_7c), pcVar2 != (char *)0x0)) && - (*pcVar2 != '\0')) { - iVar3 = stricmp(pcVar2,_Movable,-1); - _TypeID_00.TypeID = local_7c.TypeID; - if (iVar3 == 0) break; - ObjectType::setTypeID(local_8c,0); - ObjectType::setTypeID(local_9c,local_8c[0].TypeID); - if (local_6c.TypeID == local_9c[0].TypeID) { - snprintf(local_dc,0x32," %s ",pcVar2); - pcVar2 = strstr(local_dc,local_5c); - if (pcVar2 != (char *)0x0) { - ObjectType::setTypeID(local_8c,local_7c.TypeID); - ObjectType::setTypeID(&local_6c,local_8c[0].TypeID); - ObjectType::setTypeID(local_9c,local_6c.TypeID); - } - } - } - _TypeID = _TypeID + 1; - _TypeID_00.TypeID = local_6c.TypeID; - } while (_TypeID <= ObjectTypes.max); + if (!bVar1) { + error(&DAT_080f0a80,0); + } + SpecialObjects[0x28].TypeID = 0; + bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x29].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + SpecialObjects[0x2a].TypeID = 0; + bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x2b].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + SpecialObjects[0x2c].TypeID = 0; + bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; } - } - ObjectType::setTypeID((ObjectType *)SearchName,_TypeID_00.TypeID); - return (ObjectType)(int)SearchName; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void InitObjects(void) - -{ - // try { // try from 08056126 to 0805612f has its CatchHandler @ 08056134 - LoadObjects(); - LoadConversionList(); - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void ExitObjects(void) - -{ - return; -} - - - -void __tcf_0(void *param_1) - -{ - if (ObjectTypes.entry == (TObjectType *)0x0) { - return; - } - operator_delete__(ObjectTypes.entry); - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void _GLOBAL__I_FlagNames(void) - -{ - __static_initialization_and_destruction_0(1,0xffff); - return; -} - - -void __static_initialization_and_destruction_0(int __initialize_p,int __priority) - -{ - if ((__priority == 0xffff) && (__initialize_p == 1)) { - NONE.ObjectID = 0; - Semaphore::Semaphore(&LogfileMutex,1); - __cxa_atexit(__tcf_0,0,&__dso_handle); - } - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void StartGame(void) - -{ - if (SHM == (TSharedMemory *)0x0) { - error("StartGame: SharedMemory existiert nicht.\n"); - } - else if (SHM->GameState == GAME_STARTING) { - SHM->GameState = GAME_RUNNING; - } - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void CloseGame(void) - -{ - if (SHM == (TSharedMemory *)0x0) { - error("CloseGame: SharedMemory existiert nicht.\n"); - } - else if (SHM->GameState == GAME_RUNNING) { - SHM->GameState = GAME_CLOSING; + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x2d].TypeID = 0; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + SpecialObjects[0x2e].TypeID = 0; + bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + bVar1 = false; + SpecialObjects[0x2f].TypeID = 0; + if ((ObjectTypes.min < 1) && (bVar1 = true, ObjectTypes.max < 0)) { + bVar1 = false; + } + if (!bVar1) { + error(&DAT_080f0a80,0); + } + SpecialObjects[0x30].TypeID = 0; } return; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void EndGame(void) +int GetFlagByName(char *Name) { - if (SHM == (TSharedMemory *)0x0) { - error("EndGame: SharedMemory existiert nicht.\n"); - } - else { - SHM->GameState = GAME_ENDING; - } - return; + int iVar1; + int i; + int iVar2; + char (*s1) [20]; + + iVar2 = 0; + s1 = FlagNames; + do { + iVar1 = stricmp(*s1,Name,-1); + if (iVar1 == 0) { + return iVar2; + } + iVar2 = iVar2 + 1; + s1 = s1 + 1; + } while (iVar2 < 0x42); + return -1; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -bool LoginAllowed(void) +int GetTypeAttributeByName(char *Name) { - bool bVar1; + int iVar1; + int i; + int iVar2; + char (*s1) [30]; - if (SHM == (TSharedMemory *)0x0) { - error("IsLoginAllowed: SharedMemory existiert nicht.\n"); - bVar1 = false; - } - else { - bVar1 = SHM->GameState == GAME_RUNNING; - } - return bVar1; + iVar2 = 0; + s1 = TypeAttributeNames; + do { + iVar1 = stricmp(*s1,Name,-1); + if (iVar1 == 0) { + return iVar2; + } + iVar2 = iVar2 + 1; + s1 = s1 + 1; + } while (iVar2 < 0x3e); + return -1; } // WARNING: Unknown calling convention -- yet parameter storage is locked -bool GameRunning(void) +void LoadObjects(void) { - bool bVar1; + FLAG FVar1; + bool bVar2; + bool bVar3; + char cVar4; + char *pcVar5; + TObjectType *pTVar6; + ulong uVar7; + int iVar8; + uint uVar9; + int iVar10; + int TypeID; + int i; + FLAG FVar11; + char *pcVar12; + undefined1 uVar13; + char *pcVar14; + char (*local_5084) [20]; + char (*local_5080) [30]; + int local_5074; + uchar b; + char *local_5050; + int local_5048; + int i_2; + int Offset; + char local_501c [4]; + char Ident [30]; + TReadScriptFile Script; + char local_101c [4]; + char FileName [4096]; - if (SHM == (TSharedMemory *)0x0) { - error("GameRunning: SharedMemory existiert nicht.\n"); - bVar1 = false; + local_5050 = local_101c; + pcVar14 = DATAPATH; + sprintf(local_5050,"%s/objects.srv"); + // try { // try from 08054e09 to 08054e0d has its CatchHandler @ 08055640 + TReadScriptFile::TReadScriptFile((TReadScriptFile *)(Ident + 0x1c)); + // try { // try from 08054e1b to 080555fd has its CatchHandler @ 08055620 + TReadScriptFile::open((TReadScriptFile *)(Ident + 0x1c),local_5050,(int)pcVar14); + pcVar14 = (char *)0xffffffff; +LAB_08054e25: + TReadScriptFile::nextToken((TReadScriptFile *)(Ident + 0x1c)); + if (stack0xffffb004 == 0) { + TReadScriptFile::close((TReadScriptFile *)(Ident + 0x1c),(int)local_5050); + // try { // try from 08055607 to 0805560b has its CatchHandler @ 08055640 + TReadScriptFile::~TReadScriptFile((TReadScriptFile *)(Ident + 0x1c),(int)local_5050); + return; } - else { - bVar1 = SHM->GameState < GAME_ENDING; + uVar13 = stack0xffffb004 == 1; + if (!(bool)uVar13) { + TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"Identifier expected"); } - return bVar1; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -bool GameStarting(void) - -{ - bool bVar1; - - if (SHM == (TSharedMemory *)0x0) { - error("GameStarting: SharedMemory existiert nicht.\n"); - bVar1 = false; + pcVar5 = TReadScriptFile::getIdentifier((TReadScriptFile *)(Ident + 0x1c)); + strcpy(local_501c,pcVar5); + local_5050 = (char *)0x3d; + TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'='); + iVar10 = 7; + pcVar5 = local_501c; + pcVar12 = "typeid"; + do { + if (iVar10 == 0) break; + iVar10 = iVar10 + -1; + uVar13 = *pcVar5 == *pcVar12; + pcVar5 = pcVar5 + 1; + pcVar12 = pcVar12 + 1; + } while ((bool)uVar13); + if ((bool)uVar13) { + pcVar14 = (char *)TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); + pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); + pTVar6->Name = (char *)0x0; + pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); + pTVar6->Description = (char *)0x0; + pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); + pTVar6->Flags[0] = '\0'; + pTVar6->Flags[1] = '\0'; + pTVar6->Flags[2] = '\0'; + pTVar6->Flags[3] = '\0'; + iVar10 = 0; + pTVar6->Flags[4] = '\0'; + pTVar6->Flags[5] = '\0'; + pTVar6->Flags[6] = '\0'; + pTVar6->Flags[7] = '\0'; + pTVar6->Flags[8] = '\0'; + do { + pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); + pTVar6->Attributes[iVar10] = 0; + iVar10 = iVar10 + 1; + } while (iVar10 < 0x3e); + iVar10 = 0; + do { + local_5050 = pcVar14; + pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); + pTVar6->AttributeOffsets[iVar10] = -1; + iVar10 = iVar10 + 1; + } while (iVar10 < 0x12); } - else { - bVar1 = SHM->GameState == GAME_STARTING; + uVar13 = pcVar14 == (char *)0x0; + if ((int)pcVar14 < 0) { + local_5050 = "Invalid type id"; + TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"Invalid type id"); } - return bVar1; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -bool GameEnding(void) - -{ - bool bVar1; - - if (SHM == (TSharedMemory *)0x0) { - error("GameEnding: SharedMemory existiert nicht.\n"); - bVar1 = false; + iVar10 = 5; + pcVar5 = local_501c; + pcVar12 = "name"; + do { + if (iVar10 == 0) break; + iVar10 = iVar10 + -1; + uVar13 = *pcVar5 == *pcVar12; + pcVar5 = pcVar5 + 1; + pcVar12 = pcVar12 + 1; + } while ((bool)uVar13); + if ((bool)uVar13) { + local_5050 = pcVar14; + pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); + pcVar5 = TReadScriptFile::readString((TReadScriptFile *)(Ident + 0x1c)); + pcVar5 = AddStaticString(pcVar5); + pTVar6->Name = pcVar5; } - else { - bVar1 = SHM->GameState - GAME_CLOSING < 2; + iVar10 = 0xc; + pcVar5 = local_501c; + pcVar12 = "description"; + do { + if (iVar10 == 0) break; + iVar10 = iVar10 + -1; + uVar13 = *pcVar5 == *pcVar12; + pcVar5 = pcVar5 + 1; + pcVar12 = pcVar12 + 1; + } while ((bool)uVar13); + if ((bool)uVar13) { + local_5050 = pcVar14; + pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); + pcVar5 = TReadScriptFile::readString((TReadScriptFile *)(Ident + 0x1c)); + pcVar5 = AddStaticString(pcVar5); + pTVar6->Description = pcVar5; } - return bVar1; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -pid_t GetGameThreadPID(void) - -{ - pid_t pVar1; - - pVar1 = 0; - if (SHM != (TSharedMemory *)0x0) { - pVar1 = SHM->GameThreadPID; + iVar10 = 6; + pcVar5 = local_501c; + pcVar12 = "flags"; + do { + if (iVar10 == 0) break; + iVar10 = iVar10 + -1; + uVar13 = *pcVar5 == *pcVar12; + pcVar5 = pcVar5 + 1; + pcVar12 = pcVar12 + 1; + } while ((bool)uVar13); + if ((bool)uVar13) { + TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'{'); +LAB_08055258: + TReadScriptFile::nextToken((TReadScriptFile *)(Ident + 0x1c)); + if (stack0xffffb004 != 6) goto LAB_080552b0; + cVar4 = TReadScriptFile::getSpecial((TReadScriptFile *)(Ident + 0x1c)); + i_2 = 0; + local_5048 = 0; + if (cVar4 != '}') goto code_r0x08055295; + goto LAB_08055365; } - return pVar1; -} - - - -void ErrorHandler(char *Text) - -{ - ulong uVar1; - - if (VerboseOutput) { - printf("%s",Text); + goto LAB_08054f04; +code_r0x08055295: + if ((stack0xffffb004 != 6) || + (cVar4 = TReadScriptFile::getSpecial((TReadScriptFile *)(Ident + 0x1c)), cVar4 != ',')) { +LAB_080552b0: + pcVar5 = TReadScriptFile::getIdentifier((TReadScriptFile *)(Ident + 0x1c)); + iVar10 = 0; + local_5084 = FlagNames; + do { + iVar8 = stricmp(*local_5084,pcVar5,-1); + if (iVar8 == 0) goto LAB_08055307; + local_5084 = local_5084 + 1; + iVar10 = iVar10 + 1; + } while (iVar10 < 0x42); + iVar10 = -1; +LAB_08055307: + if (iVar10 == -1) { + TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"Unknown flag"); + } + pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); + iVar8 = iVar10 + 7; + if (-1 < iVar10) { + iVar8 = iVar10; + } + pTVar6->Flags[iVar8 >> 3] = + pTVar6->Flags[iVar8 >> 3] | + (byte)(1 << ((char)iVar10 - (char)((iVar8 >> 3) << 3) & 0x1fU)); } - if (SHM != (TSharedMemory *)0x0) { - if (SHM->Errors < 0x8000) { - Log("error",Text); + goto LAB_08055258; +LAB_08055365: + do { + bVar3 = false; + bVar2 = false; + if ((ObjectTypes.min <= (int)pcVar14) && ((int)pcVar14 <= ObjectTypes.max)) { + bVar2 = true; + } + local_5050 = pcVar14; + if (!bVar2) { + error(&DAT_080f0a80,pcVar14); + local_5050 = (char *)0x0; + } + FVar1 = InstanceAttributeFlags[local_5048]; + FVar11 = FVar1; + if (0x7fffffff < FVar1) { + FVar11 = FVar1 + USEEVENT; + } + uVar9 = 1 << ((char)FVar1 + (char)((int)FVar11 >> 3) * -8 & 0x1fU); + pTVar6 = vector<>::operator()(&ObjectTypes,(int)local_5050); + if ((uint)(pTVar6->Flags[(int)FVar11 >> 3] & (byte)uVar9) == (uVar9 & 0xff)) { +LAB_08055442: + bVar3 = true; + } + else if (local_5048 == 0) { + bVar2 = false; + if ((ObjectTypes.min <= (int)pcVar14) && (bVar2 = true, ObjectTypes.max < (int)pcVar14)) + { + bVar2 = false; + } + local_5050 = pcVar14; + if (!bVar2) { + error(&DAT_080f0a80,pcVar14); + local_5050 = (char *)0x0; + } + pTVar6 = vector<>::operator()(&ObjectTypes,(int)local_5050); + if ((pTVar6->Flags[0] & 0x20) != 0) goto LAB_08055442; } - uVar1 = SHM->Errors + 1; - SHM->Errors = uVar1; - if (uVar1 == 0x8000) { - Log("error","Zu viele Fehler. Keine weitere Protokollierung.\n"); + if (bVar3) { + local_5050 = pcVar14; + pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); + pTVar6->AttributeOffsets[local_5048] = i_2; + i_2 = i_2 + 1; } + local_5048 = local_5048 + 1; + uVar13 = local_5048 == 0x11; + } while (local_5048 < 0x12); +LAB_08054f04: + iVar10 = 0xb; + pcVar5 = local_501c; + pcVar12 = "attributes"; + do { + if (iVar10 == 0) break; + iVar10 = iVar10 + -1; + uVar13 = *pcVar5 == *pcVar12; + pcVar5 = pcVar5 + 1; + pcVar12 = pcVar12 + 1; + } while ((bool)uVar13); + if ((bool)uVar13) { + local_5050 = (char *)0x7b; + TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'{'); +LAB_08054f35: + TReadScriptFile::nextToken((TReadScriptFile *)(Ident + 0x1c)); + if (stack0xffffb004 != 6) goto LAB_08054f7d; + cVar4 = TReadScriptFile::getSpecial((TReadScriptFile *)(Ident + 0x1c)); + if (cVar4 != '}') goto code_r0x08054f62; } - return; -} - - - -void PrintHandler(int Level,char *Text) - -{ - size_t sVar1; - int iVar2; - int iVar3; - TSharedMemory *pTVar4; - - if (Level <= DebugLevel) { - if (VerboseOutput) { - printf("%s",Text); - } - if (SHM != (TSharedMemory *)0x0) { - Semaphore::down(&LogfileMutex); - strncpy(SHM->PrintBuffer[SHM->PrintBufferPosition],Text,0x7f); - SHM->PrintBuffer[SHM->PrintBufferPosition][0x7e] = '\0'; - pTVar4 = SHM; - iVar3 = SHM->PrintBufferPosition; - if (SHM->PrintBuffer[iVar3][0] != '\0') { - sVar1 = strlen(SHM->PrintBuffer[iVar3]); - if (pTVar4->PrintBuffer[iVar3 + -1][sVar1 + 0x7f] != '\n') { - strcat(pTVar4->PrintBuffer[pTVar4->PrintBufferPosition],"\n"); - pTVar4 = SHM; - } - } - iVar2 = pTVar4->PrintBufferPosition + 1; - iVar3 = 0; - if (iVar2 < 200) { - iVar3 = iVar2; + goto LAB_08054e25; +code_r0x08054f62: + if ((stack0xffffb004 != 6) || + (cVar4 = TReadScriptFile::getSpecial((TReadScriptFile *)(Ident + 0x1c)), cVar4 != ',')) { +LAB_08054f7d: + pcVar5 = TReadScriptFile::getIdentifier((TReadScriptFile *)(Ident + 0x1c)); + local_5074 = 0; + local_5080 = TypeAttributeNames; + do { + iVar10 = stricmp(*local_5080,pcVar5,-1); + if (iVar10 == 0) goto LAB_08054fde; + local_5080 = local_5080 + 1; + local_5074 = local_5074 + 1; + } while (local_5074 < 0x3e); + local_5074 = -1; +LAB_08054fde: + if (local_5074 == -1) { + TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"Unknown attribute"); + } + TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'='); + local_5050 = pcVar14; + pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); + uVar7 = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); + pTVar6->Attributes[local_5074] = uVar7; + if (local_5074 == 0x3d) { + local_5050 = pcVar14; + pTVar6 = vector<>::operator()(&ObjectTypes,(int)pcVar14); + uVar7 = pTVar6->Attributes[0x3d]; + bVar2 = false; + if ((0 < (int)uVar7) && ((int)uVar7 < 0x32)) { + bVar2 = true; + } + if (!bVar2) { + local_5050 = "Unknown meaning"; + TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"Unknown meaning"); + } + bVar2 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar2 = true; + } + if (!bVar2) { + local_5050 = (char *)0x0; + error(&DAT_080f0a80); + } + bVar2 = false; + if ((ObjectTypes.min < 1) && (bVar2 = true, ObjectTypes.max < 0)) { + bVar2 = false; + } + if (!bVar2) { + local_5050 = (char *)0x0; + error(&DAT_080f0a80); + } + if (SpecialObjects[uVar7].TypeID != 0) { + local_5050 = "Special object already defined"; + TReadScriptFile::error + ((TReadScriptFile *)(Ident + 0x1c),"Special object already defined"); + } + bVar2 = false; + if ((ObjectTypes.min <= (int)pcVar14) && ((int)pcVar14 <= ObjectTypes.max)) { + bVar2 = true; + } + pcVar5 = pcVar14; + if (!bVar2) { + local_5050 = pcVar14; + error(&DAT_080f0a80); + pcVar5 = (char *)0x0; + } + bVar2 = false; + if ((ObjectTypes.min <= (int)pcVar5) && ((int)pcVar5 <= ObjectTypes.max)) { + bVar2 = true; + } + if (!bVar2) { + local_5050 = pcVar5; + error(&DAT_080f0a80); + pcVar5 = (char *)0x0; + } + iVar8 = ObjectTypes.max; + iVar10 = ObjectTypes.min; + SpecialObjects[uVar7].TypeID = (int)pcVar5; + if ((int)pcVar5 < iVar10 || iVar8 < (int)pcVar5) { + error(&DAT_080f0a80); + local_5050 = pcVar5; } - pTVar4->PrintBufferPosition = iVar3; - Semaphore::up(&LogfileMutex); - return; } } - return; + goto LAB_08054f35; } // WARNING: Unknown calling convention -- yet parameter storage is locked -int GetPrintlogPosition(void) +void LoadConversionList(void) { + istream *this; + int i; int iVar1; + undefined4 *puVar2; + int local_1148; + int Type; + int Number; + int Group; + char FileName [4096]; + ifstream IN; + undefined4 local_134 [3]; + uint auStack_128 [23]; + __basic_file local_cc [25]; + undefined1 local_b3; + undefined *local_ac; + ios_base local_a8 [16]; + uint local_98; + this = (istream *)(FileName + 0xffc); + // try { // try from 0805566b to 0805566f has its CatchHandler @ 08055a21 + std::ios_base::ios_base(local_a8); + local_ac = (undefined *)0x8128950; + // try { // try from 0805568e to 08055692 has its CatchHandler @ 080559a2 + std::istream::istream(this,(streambuf *)(std::ifstream::VTT + 4)); + FileName._4092_4_ = &DAT_08128994; + local_ac = &DAT_081289a8; + // try { // try from 080556b2 to 080556b6 has its CatchHandler @ 0805599c + std::filebuf::filebuf((filebuf *)local_134); + // try { // try from 080556ca to 080556ce has its CatchHandler @ 08055955 + std::ios::init((EVP_PKEY_CTX *)&local_ac); iVar1 = 0; - if (SHM != (TSharedMemory *)0x0) { - iVar1 = SHM->PrintBufferPosition; + do { + OldGroup[iVar1] = '\0'; + OldNumber[iVar1] = '\0'; + iVar1 = iVar1 + 1; + } while (iVar1 < 0x2000); + iVar1 = 0; + do { + NewType[iVar1] = -1; + iVar1 = iVar1 + 1; + } while (iVar1 < 0x10000); + sprintf((char *)&Group,"%s/conversion.lst",DATAPATH); + // try { // try from 08055742 to 08055831 has its CatchHandler @ 080559a8 + iVar1 = std::filebuf::open((char *)local_134,(int)&Group,8); + if (iVar1 == 0) { + std::ios::clear(this + *(int *)(FileName._4092_4_ + -0xc), + *(uint *)((int)auStack_128 + *(int *)(FileName._4092_4_ + -0xc)) | 4); } - return iVar1; -} - - - -char * GetPrintlogLine(int Line) - -{ - char (*pacVar1) [128]; - - if ((SHM == (TSharedMemory *)0x0) || (199 < Line)) { - pacVar1 = (char (*) [128])0x0; + if ((local_98 & 5) == 0) { + while( true ) { + std::istream::operator>>(this,&Number); + if ((local_98 & 2) != 0) { + iVar1 = std::filebuf::close((int)local_134); + if (iVar1 == 0) { + // try { // try from 08055904 to 0805594f has its CatchHandler @ 080559a8 + std::ios::clear(this + *(int *)(FileName._4092_4_ + -0xc), + *(uint *)((int)auStack_128 + *(int *)(FileName._4092_4_ + -0xc)) + | 4); + } + iVar1 = 0; + do { + OldGroup[iVar1] = '\0'; + OldNumber[iVar1] = (uchar)iVar1; + NewType[iVar1] = iVar1; + iVar1 = iVar1 + 1; + } while (iVar1 < 0xb); + OldGroup[99] = 0xfa; + NewType[64000] = 99; + OldNumber[99] = '\0'; + FileName._4092_4_ = &DAT_08128994; + local_ac = &DAT_081289a8; + local_134[0] = 0x8128ad0; + // try { // try from 08055899 to 080558de has its CatchHandler @ 08055a21 + std::filebuf::close((int)local_134); + local_b3 = 0; + std::__basic_file::~__basic_file(local_cc); + std::streambuf::~streambuf((streambuf *)local_134); + std::istream::~istream(this); + std::ios::~ios((ios *)&local_ac); + return; + } + std::istream::operator>>(this,&Type); + std::istream::operator>>(this,&local_1148); + if (0x1ffe < local_1148 - 1U) break; + OldGroup[local_1148] = (uchar)Number; + OldNumber[local_1148] = (uchar)Type; + NewType[Number * 0x100 + Type] = local_1148; + } + error(&DAT_080f0ae0,local_1148); + puVar2 = (undefined4 *)__cxa_allocate_exception(4); + *puVar2 = "Error while loading conversion.lst"; } else { - pacVar1 = SHM->PrintBuffer + Line; + error(&DAT_080f0b60); + puVar2 = (undefined4 *)__cxa_allocate_exception(4); + *puVar2 = "Cannot open conversion.lst"; } - return *pacVar1; + // WARNING: Subroutine does not return + __cxa_throw(puVar2,char_const*::typeinfo,0); } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void IncrementObjectCounter(void) +ObjectType GetNewObjectType(uchar Group,uchar Number) { - if (SHM != (TSharedMemory *)0x0) { - SHM->ObjectCounter = SHM->ObjectCounter + 1; + bool bVar1; + int Type; + uint uVar2; + int iVar3; + undefined3 in_stack_00000005; + byte in_stack_0000000c; + + uVar2 = (uint)in_stack_0000000c; + iVar3 = NewType[CONCAT11(Number,in_stack_0000000c)]; + if (iVar3 == -1) { + error("GetNewObjectType: Objekttyp %d/%d existiert nicht.\n",(uint)Number,uVar2); + bVar1 = false; + if ((ObjectTypes.min < 1) && ((uint)ObjectTypes.max < 0x80000000)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,0,uVar2); + } + *_Group = 0; } - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void DecrementObjectCounter(void) - -{ - if (SHM != (TSharedMemory *)0x0) { - SHM->ObjectCounter = SHM->ObjectCounter - 1; + else { + bVar1 = false; + if ((ObjectTypes.min <= iVar3) && (iVar3 <= ObjectTypes.max)) { + bVar1 = true; + } + if (!bVar1) { + error(&DAT_080f0a80,iVar3); + iVar3 = 0; + } + *_Group = iVar3; } - return; + return (ObjectType)(int)_Group; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -ulong GetObjectCounter(void) +void GetOldObjectType(ObjectType *Type,uchar *Group,uchar *Number) { - ulong uVar1; + int iVar1; + bool bVar2; - uVar1 = 0; - if (SHM != (TSharedMemory *)0x0) { - uVar1 = SHM->ObjectCounter; + bVar2 = false; + iVar1 = Type->TypeID; + if ((ObjectTypes.min <= iVar1) && (iVar1 <= ObjectTypes.max)) { + bVar2 = true; } - return uVar1; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void IncrementPlayersOnline(void) - -{ - if (SHM != (TSharedMemory *)0x0) { - SHM->PlayersOnline = SHM->PlayersOnline + 1; + if (bVar2) { + *Group = OldGroup[iVar1]; + *Number = OldNumber[Type->TypeID]; + return; } + error(&DAT_080f0be0); return; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void DecrementPlayersOnline(void) +bool ObjectTypeExists(uchar Group,uchar Number) { - if (SHM != (TSharedMemory *)0x0) { - SHM->PlayersOnline = SHM->PlayersOnline + -1; - } - return; + return (bool)((byte)~(byte)((uint)NewType[CONCAT11(Group,Number)] >> 0x18) >> 7); } -// WARNING: Unknown calling convention -- yet parameter storage is locked +// DWARF original prototype: void setTypeID(ObjectType * this, int _TypeID) -int GetPlayersOnline(void) +void __thiscall ObjectType::setTypeID(ObjectType *this,int _TypeID) { - int iVar1; + bool bVar1; - iVar1 = 0; - if (SHM != (TSharedMemory *)0x0) { - iVar1 = SHM->PlayersOnline; - } - return iVar1; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void IncrementNewbiesOnline(void) - -{ - if (SHM != (TSharedMemory *)0x0) { - SHM->NewbiesOnline = SHM->NewbiesOnline + 1; + bVar1 = false; + if ((ObjectTypes.min <= _TypeID) && (_TypeID <= ObjectTypes.max)) { + bVar1 = true; } - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void DecrementNewbiesOnline(void) - -{ - if (SHM != (TSharedMemory *)0x0) { - SHM->NewbiesOnline = SHM->NewbiesOnline + -1; + if (!bVar1) { + error(&DAT_080f0a80,_TypeID); + _TypeID = 0; } + this->TypeID = _TypeID; return; } -// WARNING: Unknown calling convention -- yet parameter storage is locked +// DWARF original prototype: char * getName(ObjectType * this, int Count) -int GetNewbiesOnline(void) +char * __thiscall ObjectType::getName(ObjectType *this) { - int iVar1; + char *pcVar1; + TObjectType *pTVar2; + int in_stack_00000008; + char local_4c [4]; + char ObjectName [50]; - iVar1 = 0; - if (SHM != (TSharedMemory *)0x0) { - iVar1 = SHM->NewbiesOnline; + local_4c[0] = '\0'; + if (this->TypeID == 99) { + error("ObjectType::getName: Der Kreaturtyp hat keinen Namen.\n"); + pcVar1 = (char *)0x0; } - return iVar1; -} - - - -void SetRoundNr(ulong RoundNr) - -{ - if (SHM != (TSharedMemory *)0x0) { - SHM->RoundNr = RoundNr; + else { + pTVar2 = vector<>::operator()(&ObjectTypes,this->TypeID); + if (pTVar2->Name != (char *)0x0) { + strcpy(local_4c,pTVar2->Name); + } + pcVar1 = Plural(local_4c,in_stack_00000008); } - return; + return pcVar1; } -// WARNING: Unknown calling convention -- yet parameter storage is locked +// DWARF original prototype: char * getDescription(ObjectType * this) -ulong GetRoundNr(void) +char * __thiscall ObjectType::getDescription(ObjectType *this) { - ulong uVar1; + TObjectType *pTVar1; - uVar1 = 0; - if (SHM != (TSharedMemory *)0x0) { - uVar1 = SHM->RoundNr; - } - return uVar1; + pTVar1 = vector<>::operator()(&ObjectTypes,this->TypeID); + return pTVar1->Description; } -void SetCommand(int Command,char *Text) +// DWARF original prototype: bool getFlag(ObjectType * this, FLAG Flag) + +bool __thiscall ObjectType::getFlag(ObjectType *this,FLAG Flag) { - TSharedMemory *pTVar1; + uint uVar1; + TObjectType *pTVar2; + FLAG FVar3; + uchar b; - pTVar1 = SHM; - if (SHM != (TSharedMemory *)0x0) { - SHM->Command = Command; - if (Text == (char *)0x0) { - pTVar1->CommandBuffer[0] = '\0'; - } - else { - strncpy(pTVar1->CommandBuffer,Text,0x100); - SHM->CommandBuffer[0xff] = '\0'; - } + FVar3 = Flag + USEEVENT; + if (-1 < (int)Flag) { + FVar3 = Flag; } - return; + uVar1 = 1 << ((char)Flag + (char)((int)FVar3 >> 3) * -8 & 0x1fU); + pTVar2 = vector<>::operator()(&ObjectTypes,this->TypeID); + return (uint)(pTVar2->Flags[(int)FVar3 >> 3] & (byte)uVar1) == (uVar1 & 0xff); } -// WARNING: Unknown calling convention -- yet parameter storage is locked +// DWARF original prototype: ulong getAttribute(ObjectType * this, TYPEATTRIBUTE Attribute) -int GetCommand(void) +ulong __thiscall ObjectType::getAttribute(ObjectType *this,TYPEATTRIBUTE Attribute) { - int iVar1; + FLAG FVar1; + uint uVar2; + TObjectType *pTVar3; + ulong uVar4; + FLAG FVar5; + uchar b; - iVar1 = 0; - if (SHM != (TSharedMemory *)0x0) { - iVar1 = SHM->Command; + FVar1 = TypeAttributeFlags[Attribute]; + FVar5 = FVar1 + USEEVENT; + if (-1 < (int)FVar1) { + FVar5 = FVar1; } - return iVar1; + uVar2 = 1 << ((char)FVar1 + (char)((int)FVar5 >> 3) * -8 & 0x1fU); + pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); + if ((uint)(pTVar3->Flags[(int)FVar5 >> 3] & (byte)uVar2) == (uVar2 & 0xff)) { + pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); + uVar4 = pTVar3->Attributes[Attribute]; + } + else { + error(&DAT_080f0c60,this->TypeID,TypeAttributeFlags[Attribute],Attribute); + uVar4 = 0; + } + return uVar4; } -// WARNING: Unknown calling convention -- yet parameter storage is locked +// DWARF original prototype: int getAttributeOffset(ObjectType * this, INSTANCEATTRIBUTE Attribute) -char * GetCommandBuffer(void) +int __thiscall ObjectType::getAttributeOffset(ObjectType *this,INSTANCEATTRIBUTE Attribute) { - char *pcVar1; + FLAG FVar1; + uint uVar2; + TObjectType *pTVar3; + int iVar4; + FLAG FVar5; + uchar b; - pcVar1 = (char *)0x0; - if (SHM != (TSharedMemory *)0x0) { - if (SHM->Command == 0) { - pcVar1 = (char *)0x0; - } - else { - pcVar1 = SHM->CommandBuffer; + FVar1 = InstanceAttributeFlags[Attribute]; + FVar5 = FVar1 + USEEVENT; + if (-1 < (int)FVar1) { + FVar5 = FVar1; + } + uVar2 = 1 << ((char)FVar1 + (char)((int)FVar5 >> 3) * -8 & 0x1fU); + pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); + if ((uint)(pTVar3->Flags[(int)FVar5 >> 3] & (byte)uVar2) == (uVar2 & 0xff)) { +LAB_08055e2a: + pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); + iVar4 = pTVar3->AttributeOffsets[Attribute]; + } + else { + if (Attribute == CONTENT) { + pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); + if ((pTVar3->Flags[0] & 0x20) != 0) goto LAB_08055e2a; } + iVar4 = -1; } - return pcVar1; + return iVar4; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -bool DeleteSHM(void) +bool ObjectTypeExists(int TypeID) { - int SHMID; - int iVar1; - bool bVar2; + bool bVar1; - iVar1 = shmget(SHMKey,0,0); - if (iVar1 == -1) { - if (VerboseOutput != false) { - puts("DeleteSHM: SharedMemory existiert nicht."); - } - bVar2 = true; - } - else { - iVar1 = shmctl(iVar1,0,(shmid_ds *)0x0); - bVar2 = true; - if (iVar1 == -1) { - if (VerboseOutput != false) { - puts(&DAT_080f1020); - } - bVar2 = false; - } + bVar1 = false; + if ((ObjectTypes.min <= TypeID) && (TypeID <= ObjectTypes.max)) { + bVar1 = true; } - return bVar2; + return bVar1; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void CreateSHM(void) +ObjectType GetSpecialObject(SPECIALMEANING Meaning) { bool bVar1; - int SHMID; - int iVar2; - int *piVar3; - undefined4 *puVar4; - int iter; + int in_stack_00000008; + char *Text; + int _TypeID; + ObjectType local_2c [7]; bVar1 = false; - while( true ) { - iVar2 = shmget(SHMKey,0x6524,0x7ff); - if (iVar2 != -1) { - return; - } - piVar3 = __errno_location(); - if ((*piVar3 != 0x11) || (bVar1)) break; - bVar1 = DeleteSHM(); - if (!bVar1) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "Cannot delete SharedMemory"; - goto LAB_08056d20; - } + if ((0 < in_stack_00000008) && (in_stack_00000008 < 0x32)) { bVar1 = true; } - if (VerboseOutput != false) { - piVar3 = __errno_location(); - printf("CreateSHM: Kann SharedMemory nicht anlegen (Fehler %d).\n",*piVar3); + if (bVar1) { + ObjectType::setTypeID(local_2c,0); + _TypeID = SpecialObjects[in_stack_00000008].TypeID; + if (_TypeID != local_2c[0].TypeID) goto LAB_08055ec3; + Text = "GetSpecialObject: Kein Objekttyp mit Bedeutung %d definiert.\n"; } - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "Cannot create SharedMemory"; -LAB_08056d20: - // WARNING: Subroutine does not return - // try { // try from 08056d33 to 08056d37 has its CatchHandler @ 08056d72 - __cxa_throw(puVar4,char_const*::typeinfo,0); + else { + Text = &DAT_080f0cc0; + } + error(Text); + _TypeID = 0; +LAB_08055ec3: + ObjectType::setTypeID((ObjectType *)Meaning,_TypeID); + return (ObjectType)Meaning; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void AttachSHM(void) +ObjectType GetObjectTypeByName(char *SearchName,bool Movable) { - int SHMID; - int __shmid; - undefined4 *puVar1; + TObjectType *pTVar1; + char *pcVar2; + int iVar3; + char *ObjectName; + int TypeID; + int _TypeID; + undefined3 in_stack_00000009; + char in_stack_0000000c; + ObjectType _TypeID_00; + char local_dc [3]; + bool Movable_local; + char Help [50]; + ObjectType local_9c [4]; + ObjectType local_8c [4]; + ObjectType local_7c; + ObjectType Type; + ObjectType local_6c; + ObjectType BestType; + char local_5c [4]; + char Pattern [50]; - __shmid = shmget(SHMKey,0x6524,0); - if (__shmid == -1) { - if (VerboseOutput != false) { - puts("AttachSHM: Kann SharedMemory nicht fassen."); - } - SHM = (TSharedMemory *)0x0; - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "Cannot get SharedMemory"; + if (_Movable == (char *)0x0) { + error("GetObjectTypeByName: SearchName ist NULL.\n"); + _TypeID_00.TypeID = 0; } else { - SHM = (TSharedMemory *)shmat(__shmid,(void *)0x0,0); - if (SHM != (TSharedMemory *)0xffffffff) { - return; - } - if (VerboseOutput != false) { - puts("AttachSHM: Kann SharedMemory nicht anbinden."); + snprintf(local_5c,0x32," %s ",_Movable); + ObjectType::setTypeID(&local_6c,0); + ObjectType::setTypeID(&local_7c,99); + _TypeID = local_7c.TypeID + 1; + _TypeID_00.TypeID = local_6c.TypeID; + if (_TypeID <= ObjectTypes.max) { + do { + ObjectType::setTypeID(&local_7c,_TypeID); + if ((((in_stack_0000000c == '\0') || + (pTVar1 = vector<>::operator()(&ObjectTypes,local_7c.TypeID), + (pTVar1->Flags[4] & 2) == 0)) && + (pcVar2 = ObjectType::getName(&local_7c), pcVar2 != (char *)0x0)) && + (*pcVar2 != '\0')) { + iVar3 = stricmp(pcVar2,_Movable,-1); + _TypeID_00.TypeID = local_7c.TypeID; + if (iVar3 == 0) break; + ObjectType::setTypeID(local_8c,0); + ObjectType::setTypeID(local_9c,local_8c[0].TypeID); + if (local_6c.TypeID == local_9c[0].TypeID) { + snprintf(local_dc,0x32," %s ",pcVar2); + pcVar2 = strstr(local_dc,local_5c); + if (pcVar2 != (char *)0x0) { + ObjectType::setTypeID(local_8c,local_7c.TypeID); + ObjectType::setTypeID(&local_6c,local_8c[0].TypeID); + ObjectType::setTypeID(local_9c,local_6c.TypeID); + } + } + } + _TypeID = _TypeID + 1; + _TypeID_00.TypeID = local_6c.TypeID; + } while (_TypeID <= ObjectTypes.max); } - SHM = (TSharedMemory *)0x0; - puVar1 = (undefined4 *)__cxa_allocate_exception(4); - *puVar1 = "Cannot attach SharedMemory"; } - // WARNING: Subroutine does not return - // try { // try from 08056e1e to 08056e22 has its CatchHandler @ 08056e54 - __cxa_throw(puVar1,char_const*::typeinfo,0); + ObjectType::setTypeID((ObjectType *)SearchName,_TypeID_00.TypeID); + return (ObjectType)(int)SearchName; } // WARNING: Unknown calling convention -- yet parameter storage is locked -void DetachSHM(void) +void InitObjects(void) { - int result; - int iVar1; - - if (SHM != (TSharedMemory *)0x0) { - iVar1 = shmdt(SHM); - if ((iVar1 == -1) && (VerboseOutput != false)) { - puts(&DAT_080f1160); - } - SHM = (TSharedMemory *)0x0; - } + // try { // try from 08056126 to 0805612f has its CatchHandler @ 08056134 + LoadObjects(); + LoadConversionList(); return; } -void InitSHM(bool Verbose) +// WARNING: Unknown calling convention -- yet parameter storage is locked + +void ExitObjects(void) { - TSharedMemory *pTVar1; - uint uVar2; - __pid_t _Var3; - TSharedMemory *pTVar4; - - IsGameServer = true; - VerboseOutput = Verbose; - // try { // try from 08056ecb to 08056eec has its CatchHandler @ 08056fe8 - CreateSHM(); - AttachSHM(); - SetErrorFunction(ErrorHandler); - SetPrintFunction(PrintHandler); - pTVar4 = SHM; - uVar2 = 0x6524; - if (((uint)SHM & 4) != 0) { - SHM->Command = 0; - uVar2 = 0x6520; - pTVar4 = (TSharedMemory *)pTVar4->CommandBuffer; - } - for (uVar2 = uVar2 >> 2; uVar2 != 0; uVar2 = uVar2 - 1) { - pTVar4->Command = 0; - pTVar4 = (TSharedMemory *)pTVar4->CommandBuffer; - } - pTVar4 = SHM; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0) = 'S'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 1) = 'H'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 2) = 'M'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 3) = ' '; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 4) = 'i'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 5) = 'n'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 6) = 'i'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 7) = 't'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 8) = 'i'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 9) = 'a'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 10) = 'l'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0xb) = 'i'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0xc) = 'z'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0xd) = 'e'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0xe) = 'd'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0xf) = '.'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x10) = ' '; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x11) = 'S'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x12) = 'y'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x13) = 's'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x14) = 't'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x15) = 'e'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x16) = 'm'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x17) = ' '; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x18) = 'p'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x19) = 'r'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x1a) = 'i'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x1b) = 'n'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x1c) = 't'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x1d) = 'i'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x1e) = 'n'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x1f) = 'g'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x20) = ' '; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x21) = 'i'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x22) = 's'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x23) = ' '; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x24) = 'w'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x25) = 'o'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x26) = 'r'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x27) = 'k'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x28) = 'i'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x29) = 'n'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x2a) = 'g'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x2b) = '!'; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x2c) = '\n'; - pTVar1 = SHM; - *(char *)((int)(pTVar4->PrintBuffer + 0) + 0x2d) = '\0'; - SHM->Errors = 0; - pTVar1->RoundNr = 0; - pTVar1->PrintBufferPosition = 1; - pTVar1->ObjectCounter = 0; - pTVar1->GameState = GAME_STARTING; - _Var3 = getpid(); - pTVar1->GameThreadPID = _Var3; return; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void ExitSHM(void) +void __tcf_0(void *param_1) { - int result; - int iVar1; - - SetErrorFunction((TErrorFunction *)0x0); - SetPrintFunction((TPrintFunction *)0x0); - if (SHM != (TSharedMemory *)0x0) { - iVar1 = shmdt(SHM); - if ((iVar1 == -1) && (VerboseOutput != false)) { - puts(&DAT_080f1160); - } - SHM = (TSharedMemory *)0x0; + if (ObjectTypes.entry == (TObjectType *)0x0) { + return; } - DeleteSHM(); + operator_delete__(ObjectTypes.entry); return; } -void InitSHMExtern(bool Verbose) +// WARNING: Unknown calling convention -- yet parameter storage is locked + +void _GLOBAL__I_FlagNames(void) { - VerboseOutput = Verbose; - // try { // try from 0805706e to 08057072 has its CatchHandler @ 08057077 - AttachSHM(); + __static_initialization_and_destruction_0(1,0xffff); return; } - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void ExitSHMExtern(void) +void __static_initialization_and_destruction_0(int __initialize_p,int __priority) { - int result; - int iVar1; - - if (SHM != (TSharedMemory *)0x0) { - iVar1 = shmdt(SHM); - if ((iVar1 == -1) && (VerboseOutput != false)) { - puts(&DAT_080f1160); - } - SHM = (TSharedMemory *)0x0; + if ((__priority == 0xffff) && (__initialize_p == 1)) { + NONE.ObjectID = 0; + Semaphore::Semaphore(&LogfileMutex,1); + __cxa_atexit(__tcf_0,0,&__dso_handle); } return; } - - void __tcf_0(void *param_1) { diff --git a/reference/types.hh b/reference/types.hh index d79cf0c..e66ea72 100644 --- a/reference/types.hh +++ b/reference/types.hh @@ -1,89 +1,4 @@ -struct Object { - uint32 ObjectID; -}; - -struct TSkill { - int (**_vptr.TSkill)(...); // VTABLE? - int DAct; - int MDAct; - uint16 SkNr; - TCreature *Master; - int Act; - int Max; - int Min; - int FactorPercent; - int LastLevel; - int NextLevel; - int Delta; - int Exp; - int Cycle; - int MaxCycle; - int Count; - int MaxCount; - int AddLevel; -}; - -struct TSkillAdd { - TSkill super_TSkill; // INHERITANCE? -}; -struct TSkillHitpoints { - TSkillAdd super_TSkillAdd; // INHERITANCE? -}; - -struct TSkillSoulpoints { - TSkillAdd super_TSkillAdd; // INHERITANCE? -}; - -struct TSkillProbe { - TSkill super_TSkill; // INHERITANCE? -}; - -struct TSkillMana { - TSkillAdd super_TSkillAdd; // INHERITANCE? -}; - -struct TSkillGoStrength { - TSkillAdd super_TSkillAdd; // INHERITANCE? -}; - -struct TSkillLight { - TSkill super_TSkill; // INHERITANCE? -}; - -struct TSkillEnergy { - TSkill super_TSkill; // INHERITANCE? -}; - -struct TSkillCarryStrength { - TSkillAdd super_TSkillAdd; // INHERITANCE? -}; - -struct TSkillPoison { - TSkill super_TSkill; // INHERITANCE? -}; - -struct TSkillBurning { - TSkill super_TSkill; // INHERITANCE? -}; - -struct TSkillFed { - TSkill super_TSkill; // INHERITANCE? -}; - -struct TSkillIllusion { - TSkill super_TSkill; // INHERITANCE? -}; - -struct TSkillLevel { - TSkill super_TSkill; // INHERITANCE? -}; - -struct TSkillBase { - TSkill *Skills[25]; - TSkill *TimerList[25]; - uint16 FirstFreeTimer; -}; struct TImpact { int (**_vptr.TImpact)(...); // VTABLE? @@ -145,142 +60,6 @@ struct TDamageImpact { bool AllowDefense; }; -struct TCombatEntry { - uint32 ID; - uint32 Damage; - int TimeStamp; -}; - -struct TCombat { - TCreature *Master; - uint32 EarliestAttackTime; - uint32 EarliestDefendTime; - uint32 LastDefendTime; - uint32 LatestAttackTime; - uint32 AttackMode; - uint32 ChaseMode; - uint32 SecureMode; - uint32 AttackDest; - bool Following; - Object Shield; - Object Close; - Object Missile; - Object Throw; - Object Wand; - Object Ammo; - bool Fist; - uint32 CombatDamage; - int ActCombatEntry; - TCombatEntry CombatList[20]; - int LearningPoints; -}; - -struct TOutfit { - int OutfitID; - union{ - uint16 ObjectType; - uint8 Colors[4]; - }; -}; - -struct TCreature { - int (**_vptr.TCreature)(...); // CREATURE VTABLE? - TSkillBase super_TSkillBase; // INHERITANCE? - TCombat Combat; - uint32 ID; - TCreature *NextHashEntry; - uint32 NextChainCreature; - char Name[31]; - char Murderer[31]; - TOutfit OrgOutfit; - TOutfit Outfit; - int startx; - int starty; - int startz; - int posx; - int posy; - int posz; - int Sex; - int Race; - int Direction; - int Radius; - CreatureType Type; - bool IsDead; - int LoseInventory; - bool LoggingOut; - bool LogoutAllowed; - uint32 EarliestLogoutRound; - uint32 EarliestProtectionZoneRound; - uint32 EarliestYellRound; - uint32 EarliestTradeChannelRound; - uint32 EarliestSpellTime; - uint32 EarliestMultiuseTime; - uint32 EarliestWalkTime; - uint32 LifeEndRound; - TKnownCreature *FirstKnowingConnection; - int SummonedCreatures; - uint32 FireDamageOrigin; - uint32 PoisonDamageOrigin; - uint32 EnergyDamageOrigin; - Object CrObject; - vector ToDoList; - int ActToDo; - int NrToDo; - uint32 NextWakeup; - bool Stop; - bool LockToDo; - uint8 Profession; - TConnection *Connection; -}; - - -struct TKnownCreature { - KNOWNCREATURESTATE State; - uint32 CreatureID; - TKnownCreature *Next; - TConnection *Connection; -}; - -struct TConnection { - uint8 InData[2048]; - int InDataSize; - bool SigIOPending; - bool WaitingForACK; - uint8 OutData[16384]; - uint8 field5_0x4806; - uint8 field6_0x4807; - int NextToSend; - int NextToCommit; - int NextToWrite; - bool Overflow; - bool WillingToSend; - uint8 field12_0x4816; - uint8 field13_0x4817; - TConnection *NextSendingConnection; - uint32 RandomSeed; - CONNECTIONSTATE State; - pid_t PID; - int Socket; - char IPAddress[16]; - TXTEASymmetricKey SymmetricKey; - bool ConnectionIsOk; - bool ClosingIsDelayed; - uint8 field23_0x4852; - uint8 field24_0x4853; - uint32 TimeStamp; - uint32 TimeStampAction; - int TerminalType; - int TerminalVersion; - int TerminalOffsetX; - int TerminalOffsetY; - int TerminalWidth; - int TerminalHeight; - uint32 CharacterID; - char Name[31]; - uint8 field35_0x4897; - TKnownCreature KnownCreatureTable[150]; -}; - struct TCircle { int x[32]; int y[32]; @@ -300,59 +79,6 @@ struct TSpellList { int Amount; }; -struct TToDoEntry { - ToDoType Code; - union{ - struct{ - uint32 Time; - } Wait; - - struct{ - int x; - int y; - int z; - } Go; - - struct{ - int Direction; - } Rotate; - - struct{ - uint32 Obj; - int x; - int y; - int z; - int Count; - } Move; - - struct{ - uint32 Obj; - uint32 Partner; - } Trade; - - struct{ - uint32 Obj1; - uint32 Obj2; - int Dummy; - } Use; - - struct{ - uint32 Obj; - } Turn; - - struct{ - uint32 Text; // POINTER? - int Mode; - uint32 Addressee; - bool CheckSpamming; - } Talk; - - struct{ - int NewState; - } ChangeState; - }; -}; - struct TXTEASymmetricKey { int (**_vptr.TXTEASymmetricKey)(...); // VTABLE? uint8 m_SymmetricKey[16]; @@ -405,20 +131,6 @@ struct TPreparedQuery { char *Name; }; -struct TSharedMemory { - int Command; - char CommandBuffer[256]; - ulong RoundNr; - ulong ObjectCounter; - ulong Errors; - int PlayersOnline; - int NewbiesOnline; - int PrintBufferPosition; - char PrintBuffer[200][128]; - enum GAMESTATE GameState; - pid_t GameThreadPID; -}; - struct TPlayerIndexNode { bool InternalNode; }; @@ -539,16 +251,6 @@ struct listnode_> { // Original name: listnode struct storeunit data; }; -struct ObjectType { - int TypeID; -}; - -struct TItemData { - struct ObjectType Type; - int Maximum; - int Probability; -}; - struct TAttackWave { int x; int y; @@ -564,16 +266,6 @@ struct TAttackWave { struct vector ExtraItem; }; -struct TSkillData { - int Nr; - int Actual; - int Minimum; - int Maximum; - int NextLevel; - int FactorPercent; - int AddLevel; -}; - struct store { struct list_> *Units; union storeitem *firstFreeItem; @@ -656,19 +348,7 @@ struct listIterator_> { // Original name: list struct listnode_> *actNode; }; -struct TSpellData { - enum SpellShapeType Shape; - int ShapeParam1; - int ShapeParam2; - int ShapeParam3; - int ShapeParam4; - enum SpellImpactType Impact; - int ImpactParam1; - int ImpactParam2; - int ImpactParam3; - int ImpactParam4; - int Delay; -}; + struct storeunit { union storeitem item[256]; @@ -734,14 +414,6 @@ struct list_> { // Original name: list_> *lastNode; }; -struct TObjectType { - char *Name; - char *Description; - uchar Flags[9]; - ulong Attributes[62]; - int AttributeOffsets[18]; -}; - struct TCondition { int Type; ulong Text; @@ -1207,53 +879,6 @@ struct TBehaviourDatabase { int Behaviours; }; -struct TMonster { - struct TNonplayer super_TNonplayer; - int Home; - ulong Master; - ulong Target; -}; - -struct TRaceData { - char Name[30]; - char Article[3]; - struct TOutfit Outfit; - struct ObjectType MaleCorpse; - struct ObjectType FemaleCorpse; - enum BloodType Blood; - int ExperiencePoints; - int FleeThreshold; - int Attack; - int Defend; - int Armor; - int Poison; - int SummonCost; - int LoseTarget; - int Strategy[4]; - bool KickBoxes; - bool KickCreatures; - bool SeeInvisible; - bool Unpushable; - bool DistanceFighting; - bool NoSummon; - bool NoIllusion; - bool NoConvince; - bool NoBurning; - bool NoPoison; - bool NoEnergy; - bool NoHit; - bool NoLifeDrain; - bool NoParalyze; - int Skills; - struct vector Skill; - int Talks; - struct vector Talk; - int Items; - struct vector Item; - int Spells; - struct vector Spell; -}; - struct TQueryManagerConnection { int BufferSize; uchar *Buffer; -- cgit v1.2.3