From 76f6ecb7c809c6e93447efb91bdf50f2a9d50d6b Mon Sep 17 00:00:00 2001 From: fusion32 Date: Fri, 6 Jun 2025 19:36:18 -0300 Subject: some work on `crmain.cc` and `cract.cc` + merge creature headers --- reference/game.c | 5925 ++++++++++++------------------------------------------ 1 file changed, 1241 insertions(+), 4684 deletions(-) (limited to 'reference/game.c') diff --git a/reference/game.c b/reference/game.c index 9fbabaf..65f96be 100644 --- a/reference/game.c +++ b/reference/game.c @@ -29623,370 +29623,6 @@ void __static_initialization_and_destruction_0(int __initialize_p,int __priority return; } - - -TCreature * GetCreature(ulong id) - -{ - TCreature *pTVar1; - ulong m; - - if ((id != 0) && (pTVar1 = HashList[id % 1000], pTVar1 != (TCreature *)0x0)) { - if (pTVar1->ID == id) { - return pTVar1; - } - for (pTVar1 = pTVar1->NextHashEntry; pTVar1 != (TCreature *)0x0; - pTVar1 = pTVar1->NextHashEntry) { - if (pTVar1->ID == id) { - return pTVar1; - } - } - } - return (TCreature *)0x0; -} - - - -TCreature * GetCreature(Object *Obj) - -{ - ulong id; - TCreature *pTVar1; - - id = Object::getCreatureID(Obj); - pTVar1 = GetCreature(id); - return pTVar1; -} - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void ProcessSkills(void) - -{ - TCreature *pTVar1; - TCreature *cr; - TCreature **ppTVar2; - int i; - int i_00; - - i_00 = 0; - if (0 < FirstFreeCreature) { - do { - ppTVar2 = vector::operator()(&CreatureList,i_00); - pTVar1 = *ppTVar2; - if (pTVar1 == (TCreature *)0x0) { - error("ProcessSkills: Kreatur %d existiert nicht.\n",i_00); - } - else if ((pTVar1->super_TSkillBase).FirstFreeTimer != 0) { - TSkillBase::ProcessSkills(&pTVar1->super_TSkillBase); - } - i_00 = i_00 + 1; - } while (i_00 < FirstFreeCreature); - } - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void ProcessCreatures(void) - -{ - TPlayer *this; - bool bVar1; - TCreature **ppTVar2; - int iVar3; - uint uVar4; - CreatureType CVar5; - TCreature *cr; - int i; - int i_00; - - i_00 = 0; - if (0 < FirstFreeCreature) { - do { - ppTVar2 = vector::operator()(&CreatureList,i_00); - this = (TPlayer *)*ppTVar2; - if (this == (TPlayer *)0x0) { - error("ProcessCreatures: Kreatur %d existiert nicht.\n",i_00); - } - else { - iVar3 = TSkill::Get((this->super_TCreature).super_TSkillBase.Skills[0xe]); - if ((((iVar3 < 1) || - (uVar4 = TSkill::Get((this->super_TCreature).super_TSkillBase.Skills[0xe]), - RoundNr % uVar4 != 0)) || ((this->super_TCreature).IsDead != false)) || - (bVar1 = IsProtectionZone(), bVar1)) { -LAB_0809e093: - if ((this->super_TCreature).Type == PLAYER) { - CVar5 = PLAYER; - if ((this->super_TCreature).Connection != (TConnection *)0x0) { - TPlayer::CheckState(this); - CVar5 = (this->super_TCreature).Type; - } - if (((CVar5 == PLAYER) && - (uVar4 = (this->super_TCreature).EarliestLogoutRound, uVar4 != 0)) && - (uVar4 <= RoundNr)) { - TPlayer::ClearPlayerkillingMarks(this); - (this->super_TCreature).EarliestLogoutRound = 0; - } - } - } - else { - TSkill::Change((this->super_TCreature).super_TSkillBase.Skills[2],1); - TSkill::Change((this->super_TCreature).super_TSkillBase.Skills[3],4); - if ((this->super_TCreature).Type == PLAYER) { - SendPlayerData((this->super_TCreature).Connection); - goto LAB_0809e093; - } - } - if (((this->super_TCreature).IsDead == false) && - (iVar3 = TSkill::Get((this->super_TCreature).super_TSkillBase.Skills[2]), - iVar3 < 1)) { - error("ProcessCreatures: Kreatur %s ist nicht tot, obwohl sie keine HP mehr hat.\n" - ,(this->super_TCreature).Name); - (*(this->super_TCreature)._vptr_TCreature[2])(this); - } - if (((this->super_TCreature).LoggingOut != false) && - (iVar3 = TCreature::LogoutPossible((TCreature *)this), iVar3 == 0)) { - if (((this->super_TCreature).IsDead != false) && - (iVar3 = TSkill::Get((this->super_TCreature).super_TSkillBase.Skills[2]), - 0 < iVar3)) { - error("ProcessCreatures: Kreatur %s hat HP, obwohl sie tot ist.\n", - (this->super_TCreature).Name); - (*(this->super_TCreature).super_TSkillBase.Skills[2]->_vptr_TSkill[2]) - ((this->super_TCreature).super_TSkillBase.Skills[2],0); - } - if (this != (TPlayer *)0x0) { - (*(this->super_TCreature)._vptr_TCreature[1])(this); - } - i_00 = i_00 + -1; - } - } - i_00 = i_00 + 1; - } while (i_00 < FirstFreeCreature); - } - return; -} - - - -void MoveCreatures(int Delay) - -{ - uint uVar1; - ulong id; - bool Found; - TCreature *this; - priority_queue_entry<> *ppVar2; - ulong CreatureID; - ulong ExecutionTime; - - ServerMilliseconds = ServerMilliseconds + Delay; - while( true ) { - if (ToDoQueue.Entries == 0) { - return; - } - ppVar2 = vector<>::operator()(ToDoQueue.Entry,1); - uVar1 = ppVar2->Key; - ppVar2 = vector<>::operator()(ToDoQueue.Entry,1); - id = ppVar2->Data; - if (ServerMilliseconds < uVar1) break; - priority_queue<>::deleteMin(&ToDoQueue); - this = GetCreature(id); - if (this != (TCreature *)0x0) { - TCreature::Execute(this); - } - } - return; -} - - - -// WARNING: Variable defined which should be unmapped: blockx - -void DeleteChainCreature(TCreature *cr) - -{ - ulong id; - matrix<> *pmVar1; - ulong ID; - uint uVar2; - uint uVar3; - int iVar4; - ulong *puVar5; - TCreature *pTVar6; - TCreature *Help; - int iVar7; - int blocky; - int blockx; - - pmVar1 = FirstChainCreature; - if (cr == (TCreature *)0x0) { - cr = (TCreature *)&DAT_08101a00; -LAB_0809e38b: - error((char *)cr); - return; - } - uVar2 = cr->posx; - if (0x7fffffff < uVar2) { - uVar2 = uVar2 + 0xf; - } - uVar3 = cr->posy; - if (0x7fffffff < uVar3) { - uVar3 = uVar3 + 0xf; - } - iVar4 = ((int)uVar3 >> 4) - FirstChainCreature->ymin; - iVar7 = ((int)uVar2 >> 4) - FirstChainCreature->xmin; - if ((((iVar7 < 0) || (FirstChainCreature->dx <= iVar7)) || (iVar4 < 0)) || - (FirstChainCreature->dy <= iVar4)) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar7 + FirstChainCreature->xmin, - iVar4 + FirstChainCreature->ymin); - puVar5 = pmVar1->entry; - } - else { - puVar5 = FirstChainCreature->entry + iVar7 + iVar4 * FirstChainCreature->dx; - } - pmVar1 = FirstChainCreature; - id = *puVar5; - if (id == cr->ID) { - iVar4 = ((int)uVar3 >> 4) - FirstChainCreature->ymin; - iVar7 = ((int)uVar2 >> 4) - FirstChainCreature->xmin; - if (((iVar7 < 0) || (FirstChainCreature->dx <= iVar7)) || - ((iVar4 < 0 || (FirstChainCreature->dy <= iVar4)))) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar7 + FirstChainCreature->xmin, - iVar4 + FirstChainCreature->ymin); - puVar5 = pmVar1->entry; - } - else { - puVar5 = FirstChainCreature->entry + iVar7 + iVar4 * FirstChainCreature->dx; - } - *puVar5 = cr->NextChainCreature; - } - else { - do { - if (id == 0) { - cr = (TCreature *)s_DeleteChainCreature__Kreatur_nic_08101980; - goto LAB_0809e38b; - } - pTVar6 = GetCreature(id); - if (pTVar6 == (TCreature *)0x0) { - cr = (TCreature *)s_DeleteChainCreature__Kreatur_exi_081019c0; - goto LAB_0809e38b; - } - id = pTVar6->NextChainCreature; - } while (id != cr->ID); - pTVar6->NextChainCreature = cr->NextChainCreature; - } - return; -} - - - -// WARNING: Variable defined which should be unmapped: cr_local - -void InsertChainCreature(TCreature *cr,int newx,int newy) - -{ - matrix<> *pmVar1; - int iVar2; - ulong *puVar3; - int iVar4; - int blocky; - int blockx; - TCreature *cr_local; - - pmVar1 = FirstChainCreature; - if (cr == (TCreature *)0x0) { - error(&DAT_08101a00); - return; - } - if (newx == 0) { - newx = cr->posx; - if (0x7fffffff < (uint)newx) { - newx = newx + 0xf; - } - } - else if (0x7fffffff < (uint)newx) { - newx = newx + 0xf; - } - if (newy == 0) { - newy = cr->posy; - if (0x7fffffff < (uint)newy) { - newy = newy + 0xf; - } - } - else if (0x7fffffff < (uint)newy) { - newy = newy + 0xf; - } - iVar2 = (newy >> 4) - FirstChainCreature->ymin; - iVar4 = (newx >> 4) - FirstChainCreature->xmin; - if ((((iVar4 < 0) || (FirstChainCreature->dx <= iVar4)) || (iVar2 < 0)) || - (FirstChainCreature->dy <= iVar2)) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar4 + FirstChainCreature->xmin, - iVar2 + FirstChainCreature->ymin); - puVar3 = pmVar1->entry; - } - else { - puVar3 = FirstChainCreature->entry + iVar4 + iVar2 * FirstChainCreature->dx; - } - cr->NextChainCreature = *puVar3; - pmVar1 = FirstChainCreature; - iVar2 = (newy >> 4) - FirstChainCreature->ymin; - iVar4 = (newx >> 4) - FirstChainCreature->xmin; - if (((iVar4 < 0) || (FirstChainCreature->dx <= iVar4)) || - ((iVar2 < 0 || (FirstChainCreature->dy <= iVar2)))) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar4 + FirstChainCreature->xmin, - iVar2 + FirstChainCreature->ymin); - puVar3 = pmVar1->entry; - } - else { - puVar3 = FirstChainCreature->entry + iVar4 + iVar2 * FirstChainCreature->dx; - } - *puVar3 = cr->ID; - return; -} - - - -void MoveChainCreature(TCreature *cr,int newx,int newy) - -{ - uint uVar1; - int iVar2; - - if (cr == (TCreature *)0x0) { - error(&DAT_08101a00); - return; - } - uVar1 = cr->posx; - if (0x7fffffff < uVar1) { - uVar1 = uVar1 + 0xf; - } - iVar2 = newx + 0xf; - if (-1 < newx) { - iVar2 = newx; - } - if ((int)uVar1 >> 4 == iVar2 >> 4) { - uVar1 = cr->posy; - if (0x7fffffff < uVar1) { - uVar1 = uVar1 + 0xf; - } - iVar2 = newy + 0xf; - if (-1 < newy) { - iVar2 = newy; - } - if ((int)uVar1 >> 4 == iVar2 >> 4) { - return; - } - } - DeleteChainCreature(cr); - InsertChainCreature(cr,newx,newy); - return; -} - - - // DWARF original prototype: void TFindCreatures(TFindCreatures * this, int radx, int rady, int x, // int y, int Mask) @@ -30459,1251 +30095,169 @@ void ExitKillStatistics(void) return; } -// DWARF original prototype: void ~TCreature(TCreature * this, int __in_chrg) - -void __thiscall TCreature::~TCreature(TCreature *this,int __in_chrg) +char * GetRaceName(int Race) { - TKnownCreature *pTVar1; - TToDoEntry *pTVar2; - bool bVar3; - bool bVar4; - RESULT r_2; - ObjectType *pOVar5; - TCreature **ppTVar6; - TCreature **ppTVar7; - long lVar8; - ulong Value; - RESULT r; - TKnownCreature *KnownCreature; - int iVar9; - int i_1; - Object *pOVar10; - char *in_stack_fffffef8; - char *__src; - Object local_ec; - char s [128]; - Object Corpse; - Object local_5c; - Object Obj; - ObjectType local_4c; - ObjectType CorpseType; - Object local_3c; - Object Obj_1; - Object local_2c [7]; + TRaceData *pTVar1; - this->_vptr_TCreature = (_func_int_varargs **)&PTR__TCreature_08127be8; - if (this->IsDead != false) { - iVar9 = this->Race; - if (RaceData[iVar9].Blood == BT_BLOOD) { - GetSpecialObject((SPECIALMEANING)local_2c); - local_4c.TypeID = (this->CrObject).ObjectID; - GetMapContainer(&local_3c); - CreatePool(); - iVar9 = this->Race; - } - if (RaceData[iVar9].Blood == BT_SLIME) { - // try { // try from 0809f7ce to 0809f85d has its CatchHandler @ 0809f869 - GetSpecialObject((SPECIALMEANING)&local_4c); - local_2c[0].ObjectID = (this->CrObject).ObjectID; - GetMapContainer(&local_3c); - CreatePool(); - iVar9 = this->Race; - } - if (this->Sex == 1) { - pOVar5 = &RaceData[iVar9].MaleCorpse; - } - else { - pOVar5 = &RaceData[iVar9].FemaleCorpse; - } - // try { // try from 0809f31c to 0809f4ab has its CatchHandler @ 0809f957 - ObjectType::setTypeID(&local_4c,pOVar5->TypeID); - bVar3 = ObjectType::getFlag(&local_4c,MAGICFIELD); - if (bVar3) { - GetFirstObject(); - local_5c = (Object)::NONE.ObjectID; - local_2c[0].ObjectID = local_5c.ObjectID; - if (local_3c.ObjectID != ::NONE.ObjectID) { - do { - local_5c.ObjectID = local_3c.ObjectID; - local_2c[0].ObjectID = ::NONE.ObjectID; - Object::getNextObject((Object *)(s + 0x7c)); - local_3c.ObjectID._0_1_ = s[0x7c]; - local_3c.ObjectID._1_1_ = s[0x7d]; - local_3c.ObjectID._2_1_ = s[0x7e]; - local_3c.ObjectID._3_1_ = s[0x7f]; - local_2c[0].ObjectID._0_1_ = s[0x7c]; - local_2c[0].ObjectID._1_1_ = s[0x7d]; - local_2c[0].ObjectID._2_1_ = s[0x7e]; - local_2c[0].ObjectID._3_1_ = s[0x7f]; - Object::getObjectType((Object *)(s + 0x7c)); - bVar3 = ObjectType::getFlag((ObjectType *)(s + 0x7c),MAGICFIELD); - if (bVar3) { - s[0x7c] = (undefined1)local_5c.ObjectID; - s[0x7d] = local_5c.ObjectID._1_1_; - s[0x7e] = local_5c.ObjectID._2_1_; - s[0x7f] = local_5c.ObjectID._3_1_; - // try { // try from 0809f7a4 to 0809f7a8 has its CatchHandler @ 0809f8d4 - Delete((Object *)(s + 0x7c),-1); - } - local_2c[0].ObjectID = ::NONE.ObjectID; - local_5c.ObjectID = ::NONE.ObjectID; - } while (local_3c.ObjectID != ::NONE.ObjectID); - } - } - ObjectType::setTypeID((ObjectType *)&local_5c,local_4c.TypeID); - GetMapContainer((int)&local_3c,this->posx,this->posy); - Create((Object *)(s + 0x7c),(ObjectType *)&local_3c,(ulong)&local_5c); - in_stack_fffffef8 = "Tod von %s: LoseInventory=%d.\n"; - Log("game","Tod von %s: LoseInventory=%d.\n",this->Name,this->LoseInventory); - if (this->Type == PLAYER) { - sprintf((char *)&local_ec,"You recognize %s",this->Name); - if (this->Murderer[0] != '\0') { - if (this->Sex == 1) { - __src = ". He "; - } - else { - __src = ". She "; - } - strcat((char *)&local_ec,__src); - strcat((char *)&local_ec,"was killed by "); - strcat((char *)&local_ec,this->Murderer); - } - Value = AddDynamicString((char *)&local_ec); - in_stack_fffffef8 = (char *)0x9; - local_5c.ObjectID._0_1_ = s[0x7c]; - local_5c.ObjectID._1_1_ = s[0x7d]; - local_5c.ObjectID._2_1_ = s[0x7e]; - local_5c.ObjectID._3_1_ = s[0x7f]; - Change(&local_5c,TEXTSTRING,Value); - } - if (this->LoseInventory != 0) { - iVar9 = 1; - do { - in_stack_fffffef8 = (char *)this->ID; - GetBodyObject((ulong)&local_5c,(int)in_stack_fffffef8); - local_3c.ObjectID = ::NONE.ObjectID; - if (local_5c.ObjectID != ::NONE.ObjectID) { - if (this->LoseInventory != 2) { - Object::getObjectType(&local_3c); - bVar3 = ObjectType::getFlag((ObjectType *)&local_3c,CONTAINER); - if (!bVar3) { - in_stack_fffffef8 = (char *)0x9; - // try { // try from 0809f63b to 0809f76e has its CatchHandler @ 0809f957 - lVar8 = random(); - if (lVar8 != 0) goto LAB_0809f487; - } - } - local_3c.ObjectID = ::NONE.ObjectID; - local_ec.ObjectID = local_5c.ObjectID; - in_stack_fffffef8 = (char *)&local_ec; - local_2c[0].ObjectID._0_1_ = s[0x7c]; - local_2c[0].ObjectID._1_1_ = s[0x7d]; - local_2c[0].ObjectID._2_1_ = s[0x7e]; - local_2c[0].ObjectID._3_1_ = s[0x7f]; - ::Move(0,(Object *)in_stack_fffffef8,local_2c,-1,false,&local_3c); - } -LAB_0809f487: - iVar9 = iVar9 + 1; - } while (iVar9 < 0xb); - } - if ((this->Type == PLAYER) && (this->LoseInventory != 2)) { - TPlayer::SaveInventory((TPlayer *)this); - } - } - bVar3 = false; - local_ec.ObjectID = ::NONE.ObjectID; - s[0x7c] = (undefined1)::NONE.ObjectID; - s[0x7d] = ::NONE.ObjectID._1_1_; - s[0x7e] = ::NONE.ObjectID._2_1_; - s[0x7f] = ::NONE.ObjectID._3_1_; - if (((this->CrObject).ObjectID != ::NONE.ObjectID) && - (bVar4 = Object::exists(&this->CrObject), bVar4)) { - bVar3 = true; - } - if (bVar3) { - DelOnMap(this); - } - ToDoClear(this); - if ((this->Type == PLAYER) && (this->Connection != (TConnection *)0x0)) { - in_stack_fffffef8 = (char *)0x1e; - TConnection::Logout(this->Connection,0x1e,true); + if (Race - 1U < 0x1ff) { + pTVar1 = RaceData + Race; } - pOVar10 = (Object *)0x0; - if (0 < FirstFreeCreature) { - do { - in_stack_fffffef8 = (char *)pOVar10; - ppTVar6 = vector::operator()(&CreatureList,(int)pOVar10); - if (*ppTVar6 == this) { - ppTVar6 = vector::operator()(&CreatureList,(int)pOVar10); - ppTVar7 = vector::operator()(&CreatureList,FirstFreeCreature + -1); - *ppTVar6 = *ppTVar7; - in_stack_fffffef8 = (char *)(FirstFreeCreature + -1); - ppTVar6 = vector::operator()(&CreatureList,(int)in_stack_fffffef8); - *ppTVar6 = (TCreature *)0x0; - FirstFreeCreature = FirstFreeCreature + -1; - } - pOVar10 = (Object *)((int)&pOVar10->ObjectID + 1); - } while ((int)pOVar10 < FirstFreeCreature); - } - if (this->ID != 0) { - DelID(this); - } - for (pTVar1 = this->FirstKnowingConnection; pTVar1 != (TKnownCreature *)0x0; - pTVar1 = pTVar1->Next) { - pOVar10 = (Object *)this->ID; - if ((Object *)pTVar1->CreatureID != pOVar10) { - error("TCreature::~TCreature: Verkettungsfehler bei Kreatur %lu.\n"); - in_stack_fffffef8 = (char *)pOVar10; - } - pTVar1->State = KNOWNCREATURE_FREE; - } - pTVar2 = (this->ToDoList).entry; - if (pTVar2 != (TToDoEntry *)0x0) { - operator_delete__(pTVar2); + else { + error(&DAT_08102100,Race); + pTVar1 = (TRaceData *)0x0; } - TSkillBase::~TSkillBase(&this->super_TSkillBase,(int)in_stack_fffffef8); - return; + return pTVar1->Name; } -// DWARF original prototype: void ~TCreature(TCreature * this, int __in_chrg) - -void __thiscall TCreature::~TCreature(TCreature *this,int __in_chrg) +TOutfit GetRaceOutfit(int Race) { - TKnownCreature *pTVar1; - TToDoEntry *pTVar2; - bool bVar3; - bool bVar4; - RESULT r_2; - ObjectType *pOVar5; - TCreature **ppTVar6; - TCreature **ppTVar7; - long lVar8; - ulong Value; - RESULT r; - TKnownCreature *KnownCreature; - int iVar9; - int i_1; - Object *pOVar10; - char *in_stack_fffffef8; - char *__src; - Object local_ec; - char s [128]; - Object Corpse; - Object local_5c; - Object Obj; - ObjectType local_4c; - ObjectType CorpseType; - Object local_3c; - Object Obj_1; - Object local_2c [7]; + int iVar1; + anon_union_4_2_730cd3ca_for_TOutfit_2 aVar2; + TOutfit TVar3; + int in_stack_00000008; - this->_vptr_TCreature = (_func_int_varargs **)&PTR__TCreature_08127be8; - if (this->IsDead != false) { - iVar9 = this->Race; - if (RaceData[iVar9].Blood == BT_BLOOD) { - GetSpecialObject((SPECIALMEANING)local_2c); - local_4c.TypeID = (this->CrObject).ObjectID; - GetMapContainer(&local_3c); - CreatePool(); - iVar9 = this->Race; - } - if (RaceData[iVar9].Blood == BT_SLIME) { - // try { // try from 0809fe8e to 0809ff1d has its CatchHandler @ 0809ff29 - GetSpecialObject((SPECIALMEANING)&local_4c); - local_2c[0].ObjectID = (this->CrObject).ObjectID; - GetMapContainer(&local_3c); - CreatePool(); - iVar9 = this->Race; - } - if (this->Sex == 1) { - pOVar5 = &RaceData[iVar9].MaleCorpse; - } - else { - pOVar5 = &RaceData[iVar9].FemaleCorpse; - } - // try { // try from 0809f9dc to 0809fb6b has its CatchHandler @ 080a0017 - ObjectType::setTypeID(&local_4c,pOVar5->TypeID); - bVar3 = ObjectType::getFlag(&local_4c,MAGICFIELD); - if (bVar3) { - GetFirstObject(); - local_5c = (Object)::NONE.ObjectID; - local_2c[0].ObjectID = local_5c.ObjectID; - if (local_3c.ObjectID != ::NONE.ObjectID) { - do { - local_5c.ObjectID = local_3c.ObjectID; - local_2c[0].ObjectID = ::NONE.ObjectID; - Object::getNextObject((Object *)(s + 0x7c)); - local_3c.ObjectID._0_1_ = s[0x7c]; - local_3c.ObjectID._1_1_ = s[0x7d]; - local_3c.ObjectID._2_1_ = s[0x7e]; - local_3c.ObjectID._3_1_ = s[0x7f]; - local_2c[0].ObjectID._0_1_ = s[0x7c]; - local_2c[0].ObjectID._1_1_ = s[0x7d]; - local_2c[0].ObjectID._2_1_ = s[0x7e]; - local_2c[0].ObjectID._3_1_ = s[0x7f]; - Object::getObjectType((Object *)(s + 0x7c)); - bVar3 = ObjectType::getFlag((ObjectType *)(s + 0x7c),MAGICFIELD); - if (bVar3) { - s[0x7c] = (undefined1)local_5c.ObjectID; - s[0x7d] = local_5c.ObjectID._1_1_; - s[0x7e] = local_5c.ObjectID._2_1_; - s[0x7f] = local_5c.ObjectID._3_1_; - // try { // try from 0809fe64 to 0809fe68 has its CatchHandler @ 0809ff94 - Delete((Object *)(s + 0x7c),-1); - } - local_2c[0].ObjectID = ::NONE.ObjectID; - local_5c.ObjectID = ::NONE.ObjectID; - } while (local_3c.ObjectID != ::NONE.ObjectID); - } - } - ObjectType::setTypeID((ObjectType *)&local_5c,local_4c.TypeID); - GetMapContainer((int)&local_3c,this->posx,this->posy); - Create((Object *)(s + 0x7c),(ObjectType *)&local_3c,(ulong)&local_5c); - in_stack_fffffef8 = "Tod von %s: LoseInventory=%d.\n"; - Log("game","Tod von %s: LoseInventory=%d.\n",this->Name,this->LoseInventory); - if (this->Type == PLAYER) { - sprintf((char *)&local_ec,"You recognize %s",this->Name); - if (this->Murderer[0] != '\0') { - if (this->Sex == 1) { - __src = ". He "; - } - else { - __src = ". She "; - } - strcat((char *)&local_ec,__src); - strcat((char *)&local_ec,"was killed by "); - strcat((char *)&local_ec,this->Murderer); - } - Value = AddDynamicString((char *)&local_ec); - in_stack_fffffef8 = (char *)0x9; - local_5c.ObjectID._0_1_ = s[0x7c]; - local_5c.ObjectID._1_1_ = s[0x7d]; - local_5c.ObjectID._2_1_ = s[0x7e]; - local_5c.ObjectID._3_1_ = s[0x7f]; - Change(&local_5c,TEXTSTRING,Value); - } - if (this->LoseInventory != 0) { - iVar9 = 1; - do { - in_stack_fffffef8 = (char *)this->ID; - GetBodyObject((ulong)&local_5c,(int)in_stack_fffffef8); - local_3c.ObjectID = ::NONE.ObjectID; - if (local_5c.ObjectID != ::NONE.ObjectID) { - if (this->LoseInventory != 2) { - Object::getObjectType(&local_3c); - bVar3 = ObjectType::getFlag((ObjectType *)&local_3c,CONTAINER); - if (!bVar3) { - in_stack_fffffef8 = (char *)0x9; - // try { // try from 0809fcfb to 0809fe2e has its CatchHandler @ 080a0017 - lVar8 = random(); - if (lVar8 != 0) goto LAB_0809fb47; - } - } - local_3c.ObjectID = ::NONE.ObjectID; - local_ec.ObjectID = local_5c.ObjectID; - in_stack_fffffef8 = (char *)&local_ec; - local_2c[0].ObjectID._0_1_ = s[0x7c]; - local_2c[0].ObjectID._1_1_ = s[0x7d]; - local_2c[0].ObjectID._2_1_ = s[0x7e]; - local_2c[0].ObjectID._3_1_ = s[0x7f]; - ::Move(0,(Object *)in_stack_fffffef8,local_2c,-1,false,&local_3c); - } -LAB_0809fb47: - iVar9 = iVar9 + 1; - } while (iVar9 < 0xb); - } - if ((this->Type == PLAYER) && (this->LoseInventory != 2)) { - TPlayer::SaveInventory((TPlayer *)this); - } - } - bVar3 = false; - local_ec.ObjectID = ::NONE.ObjectID; - s[0x7c] = (undefined1)::NONE.ObjectID; - s[0x7d] = ::NONE.ObjectID._1_1_; - s[0x7e] = ::NONE.ObjectID._2_1_; - s[0x7f] = ::NONE.ObjectID._3_1_; - if (((this->CrObject).ObjectID != ::NONE.ObjectID) && - (bVar4 = Object::exists(&this->CrObject), bVar4)) { - bVar3 = true; - } - if (bVar3) { - DelOnMap(this); - } - ToDoClear(this); - if ((this->Type == PLAYER) && (this->Connection != (TConnection *)0x0)) { - in_stack_fffffef8 = (char *)0x1e; - TConnection::Logout(this->Connection,0x1e,true); + if (in_stack_00000008 - 1U < 0x1ff) { + iVar1 = RaceData[in_stack_00000008].Outfit.OutfitID; + aVar2 = RaceData[in_stack_00000008].Outfit.field_1; } - pOVar10 = (Object *)0x0; - if (0 < FirstFreeCreature) { - do { - in_stack_fffffef8 = (char *)pOVar10; - ppTVar6 = vector::operator()(&CreatureList,(int)pOVar10); - if (*ppTVar6 == this) { - ppTVar6 = vector::operator()(&CreatureList,(int)pOVar10); - ppTVar7 = vector::operator()(&CreatureList,FirstFreeCreature + -1); - *ppTVar6 = *ppTVar7; - in_stack_fffffef8 = (char *)(FirstFreeCreature + -1); - ppTVar6 = vector::operator()(&CreatureList,(int)in_stack_fffffef8); - *ppTVar6 = (TCreature *)0x0; - FirstFreeCreature = FirstFreeCreature + -1; - } - pOVar10 = (Object *)((int)&pOVar10->ObjectID + 1); - } while ((int)pOVar10 < FirstFreeCreature); - } - if (this->ID != 0) { - DelID(this); - } - for (pTVar1 = this->FirstKnowingConnection; pTVar1 != (TKnownCreature *)0x0; - pTVar1 = pTVar1->Next) { - pOVar10 = (Object *)this->ID; - if ((Object *)pTVar1->CreatureID != pOVar10) { - error("TCreature::~TCreature: Verkettungsfehler bei Kreatur %lu.\n"); - in_stack_fffffef8 = (char *)pOVar10; - } - pTVar1->State = KNOWNCREATURE_FREE; - } - pTVar2 = (this->ToDoList).entry; - if (pTVar2 != (TToDoEntry *)0x0) { - operator_delete__(pTVar2); + else { + error(&DAT_08102140); + iVar1 = RaceData[1].Outfit.OutfitID; + aVar2 = RaceData[1].Outfit.field_1; } - TSkillBase::~TSkillBase(&this->super_TSkillBase,(int)in_stack_fffffef8); - return; + *(int *)Race = iVar1; + *(anon_union_4_2_730cd3ca_for_TOutfit_2 *)(Race + 4) = aVar2; + TVar3.field_1 = aVar2; + TVar3.OutfitID = Race; + return TVar3; } -// DWARF original prototype: void ~TCreature(TCreature * this, int __in_chrg) - -void __thiscall TCreature::~TCreature(TCreature *this,int __in_chrg) +bool GetRaceNoSummon(int Race) { - TKnownCreature *pTVar1; - TToDoEntry *pTVar2; - bool bVar3; - bool bVar4; - RESULT r_2; - ObjectType *pOVar5; - TCreature **ppTVar6; - TCreature **ppTVar7; - long lVar8; - ulong Value; - RESULT r; - TKnownCreature *KnownCreature; - int iVar9; - int i_1; - Object *pOVar10; - char *in_stack_fffffef8; - char *__src; - Object local_ec; - char s [128]; - Object Corpse; - Object local_5c; - Object Obj; - ObjectType local_4c; - ObjectType CorpseType; - Object local_3c; - Object Obj_1; - Object local_2c [7]; + undefined1 uVar1; - this->_vptr_TCreature = (_func_int_varargs **)&PTR__TCreature_08127be8; - if (this->IsDead != false) { - iVar9 = this->Race; - if (RaceData[iVar9].Blood == BT_BLOOD) { - GetSpecialObject((SPECIALMEANING)local_2c); - local_4c.TypeID = (this->CrObject).ObjectID; - GetMapContainer(&local_3c); - CreatePool(); - iVar9 = this->Race; - } - if (RaceData[iVar9].Blood == BT_SLIME) { - // try { // try from 080a054e to 080a05dd has its CatchHandler @ 080a05e9 - GetSpecialObject((SPECIALMEANING)&local_4c); - local_2c[0].ObjectID = (this->CrObject).ObjectID; - GetMapContainer(&local_3c); - CreatePool(); - iVar9 = this->Race; - } - if (this->Sex == 1) { - pOVar5 = &RaceData[iVar9].MaleCorpse; - } - else { - pOVar5 = &RaceData[iVar9].FemaleCorpse; - } - // try { // try from 080a009c to 080a022b has its CatchHandler @ 080a06d7 - ObjectType::setTypeID(&local_4c,pOVar5->TypeID); - bVar3 = ObjectType::getFlag(&local_4c,MAGICFIELD); - if (bVar3) { - GetFirstObject(); - local_5c = (Object)::NONE.ObjectID; - local_2c[0].ObjectID = local_5c.ObjectID; - if (local_3c.ObjectID != ::NONE.ObjectID) { - do { - local_5c.ObjectID = local_3c.ObjectID; - local_2c[0].ObjectID = ::NONE.ObjectID; - Object::getNextObject((Object *)(s + 0x7c)); - local_3c.ObjectID._0_1_ = s[0x7c]; - local_3c.ObjectID._1_1_ = s[0x7d]; - local_3c.ObjectID._2_1_ = s[0x7e]; - local_3c.ObjectID._3_1_ = s[0x7f]; - local_2c[0].ObjectID._0_1_ = s[0x7c]; - local_2c[0].ObjectID._1_1_ = s[0x7d]; - local_2c[0].ObjectID._2_1_ = s[0x7e]; - local_2c[0].ObjectID._3_1_ = s[0x7f]; - Object::getObjectType((Object *)(s + 0x7c)); - bVar3 = ObjectType::getFlag((ObjectType *)(s + 0x7c),MAGICFIELD); - if (bVar3) { - s[0x7c] = (undefined1)local_5c.ObjectID; - s[0x7d] = local_5c.ObjectID._1_1_; - s[0x7e] = local_5c.ObjectID._2_1_; - s[0x7f] = local_5c.ObjectID._3_1_; - // try { // try from 080a0524 to 080a0528 has its CatchHandler @ 080a0654 - Delete((Object *)(s + 0x7c),-1); - } - local_2c[0].ObjectID = ::NONE.ObjectID; - local_5c.ObjectID = ::NONE.ObjectID; - } while (local_3c.ObjectID != ::NONE.ObjectID); - } - } - ObjectType::setTypeID((ObjectType *)&local_5c,local_4c.TypeID); - GetMapContainer((int)&local_3c,this->posx,this->posy); - Create((Object *)(s + 0x7c),(ObjectType *)&local_3c,(ulong)&local_5c); - in_stack_fffffef8 = "Tod von %s: LoseInventory=%d.\n"; - Log("game","Tod von %s: LoseInventory=%d.\n",this->Name,this->LoseInventory); - if (this->Type == PLAYER) { - sprintf((char *)&local_ec,"You recognize %s",this->Name); - if (this->Murderer[0] != '\0') { - if (this->Sex == 1) { - __src = ". He "; - } - else { - __src = ". She "; - } - strcat((char *)&local_ec,__src); - strcat((char *)&local_ec,"was killed by "); - strcat((char *)&local_ec,this->Murderer); - } - Value = AddDynamicString((char *)&local_ec); - in_stack_fffffef8 = (char *)0x9; - local_5c.ObjectID._0_1_ = s[0x7c]; - local_5c.ObjectID._1_1_ = s[0x7d]; - local_5c.ObjectID._2_1_ = s[0x7e]; - local_5c.ObjectID._3_1_ = s[0x7f]; - Change(&local_5c,TEXTSTRING,Value); - } - if (this->LoseInventory != 0) { - iVar9 = 1; - do { - in_stack_fffffef8 = (char *)this->ID; - GetBodyObject((ulong)&local_5c,(int)in_stack_fffffef8); - local_3c.ObjectID = ::NONE.ObjectID; - if (local_5c.ObjectID != ::NONE.ObjectID) { - if (this->LoseInventory != 2) { - Object::getObjectType(&local_3c); - bVar3 = ObjectType::getFlag((ObjectType *)&local_3c,CONTAINER); - if (!bVar3) { - in_stack_fffffef8 = (char *)0x9; - // try { // try from 080a03bc to 080a04ee has its CatchHandler @ 080a06d7 - lVar8 = random(); - if (lVar8 != 0) goto LAB_080a0207; - } - } - local_3c.ObjectID = ::NONE.ObjectID; - local_ec.ObjectID = local_5c.ObjectID; - in_stack_fffffef8 = (char *)&local_ec; - local_2c[0].ObjectID._0_1_ = s[0x7c]; - local_2c[0].ObjectID._1_1_ = s[0x7d]; - local_2c[0].ObjectID._2_1_ = s[0x7e]; - local_2c[0].ObjectID._3_1_ = s[0x7f]; - ::Move(0,(Object *)in_stack_fffffef8,local_2c,-1,false,&local_3c); - } -LAB_080a0207: - iVar9 = iVar9 + 1; - } while (iVar9 < 0xb); - } - if ((this->Type == PLAYER) && (this->LoseInventory != 2)) { - TPlayer::SaveInventory((TPlayer *)this); - } - } - bVar3 = false; - local_ec.ObjectID = ::NONE.ObjectID; - s[0x7c] = (undefined1)::NONE.ObjectID; - s[0x7d] = ::NONE.ObjectID._1_1_; - s[0x7e] = ::NONE.ObjectID._2_1_; - s[0x7f] = ::NONE.ObjectID._3_1_; - if (((this->CrObject).ObjectID != ::NONE.ObjectID) && - (bVar4 = Object::exists(&this->CrObject), bVar4)) { - bVar3 = true; - } - if (bVar3) { - DelOnMap(this); - } - ToDoClear(this); - if ((this->Type == PLAYER) && (this->Connection != (TConnection *)0x0)) { - in_stack_fffffef8 = (char *)0x1e; - TConnection::Logout(this->Connection,0x1e,true); + if (Race - 1U < 0x1ff) { + uVar1 = RaceData[Race].NoSummon; } - pOVar10 = (Object *)0x0; - if (0 < FirstFreeCreature) { - do { - in_stack_fffffef8 = (char *)pOVar10; - ppTVar6 = vector::operator()(&CreatureList,(int)pOVar10); - if (*ppTVar6 == this) { - ppTVar6 = vector::operator()(&CreatureList,(int)pOVar10); - ppTVar7 = vector::operator()(&CreatureList,FirstFreeCreature + -1); - *ppTVar6 = *ppTVar7; - in_stack_fffffef8 = (char *)(FirstFreeCreature + -1); - ppTVar6 = vector::operator()(&CreatureList,(int)in_stack_fffffef8); - *ppTVar6 = (TCreature *)0x0; - FirstFreeCreature = FirstFreeCreature + -1; - } - pOVar10 = (Object *)((int)&pOVar10->ObjectID + 1); - } while ((int)pOVar10 < FirstFreeCreature); - } - if (this->ID != 0) { - DelID(this); - } - for (pTVar1 = this->FirstKnowingConnection; pTVar1 != (TKnownCreature *)0x0; - pTVar1 = pTVar1->Next) { - pOVar10 = (Object *)this->ID; - if ((Object *)pTVar1->CreatureID != pOVar10) { - error("TCreature::~TCreature: Verkettungsfehler bei Kreatur %lu.\n"); - in_stack_fffffef8 = (char *)pOVar10; - } - pTVar1->State = KNOWNCREATURE_FREE; - } - pTVar2 = (this->ToDoList).entry; - if (pTVar2 != (TToDoEntry *)0x0) { - operator_delete__(pTVar2); + else { + error(&DAT_08102180,Race); + uVar1 = 1; } - TSkillBase::~TSkillBase(&this->super_TSkillBase,(int)in_stack_fffffef8); - operator_delete(this); - return; + return (bool)uVar1; } -// DWARF original prototype: void SetID(TCreature * this, ulong CharacterID) - -void __thiscall TCreature::SetID(TCreature *this,ulong CharacterID) +bool GetRaceNoConvince(int Race) { - TCreature *pTVar1; - ulong m; - uint uVar2; - int iVar3; - char *Text; - ulong uVar4; + undefined1 uVar1; - if (this->ID != 0) { - error("TCreature::SetID: ID ist schon gesetzt.\n"); - } - if (CharacterID == 0) { - iVar3 = 0; - this->ID = NextCreatureID; - NextCreatureID = NextCreatureID + 1; - do { - pTVar1 = GetCreature(this->ID); - if (pTVar1 == (TCreature *)0x0) goto LAB_080a0775; - iVar3 = iVar3 + 1; - error("TCreature::SetID: Doppelte Nonplayer-ID %d gefunden.\n",this->ID); - this->ID = NextCreatureID; - NextCreatureID = NextCreatureID + 1; - } while (iVar3 < 0x11); - uVar4 = this->ID; - Text = "TCreature::SetID: 16x hintereinander doppelte ID. Verwende nun doppelte ID %d\n"; + if (Race - 1U < 0x1ff) { + uVar1 = RaceData[Race].NoConvince; } else { - this->ID = CharacterID; - pTVar1 = GetCreature(CharacterID); - if (pTVar1 == (TCreature *)0x0) goto LAB_080a0775; - uVar4 = this->ID; - Text = "TCreature::SetID: Doppelte Character-ID %d gefunden.\n"; + error(&DAT_081021c0,Race); + uVar1 = 1; } - error(Text,uVar4); -LAB_080a0775: - uVar2 = this->ID % 1000; - this->NextHashEntry = HashList[uVar2]; - HashList[uVar2] = this; - return; + return (bool)uVar1; } -// DWARF original prototype: void DelID(TCreature * this) - -void __thiscall TCreature::DelID(TCreature *this) +bool GetRaceNoIllusion(int Race) { - uint uVar1; - TCreature *pTVar2; - uint uVar3; - TCreature *pTVar4; - TCreature *pTVar5; - ulong m; - TCreature *ocr; - TCreature *pTVar6; - char *Text; + undefined1 uVar1; - uVar1 = this->ID; - pTVar2 = HashList[uVar1 % 1000]; - if (pTVar2 == (TCreature *)0x0) { - Text = "TCreature::DelID: Hasheintrag nicht gefunden id = %d\n"; + if (Race - 1U < 0x1ff) { + uVar1 = RaceData[Race].NoIllusion; } else { - uVar3 = pTVar2->ID; - if (uVar3 == uVar1) { - HashList[uVar1 % 1000] = pTVar2->NextHashEntry; - return; - } - pTVar4 = pTVar2->NextHashEntry; - pTVar6 = (TCreature *)0x0; - while (pTVar4 != (TCreature *)0x0) { - pTVar5 = pTVar2->NextHashEntry; - uVar3 = pTVar5->ID; - pTVar6 = pTVar2; - if (uVar3 == uVar1) goto LAB_080a0867; - pTVar2 = pTVar5; - pTVar4 = pTVar5->NextHashEntry; - } - pTVar5 = pTVar2; - if (uVar3 == uVar1) { -LAB_080a0867: - pTVar6->NextHashEntry = pTVar5->NextHashEntry; - return; - } - Text = "TCreature::DelID: id=%d nicht gefunden.\n"; + error(&DAT_08102200,Race); + uVar1 = 1; } - error(Text,uVar1); - return; -} - - - -// DWARF original prototype: void SetInCrList(TCreature * this) - -void __thiscall TCreature::SetInCrList(TCreature *this) - -{ - TCreature **ppTVar1; - - ppTVar1 = vector::operator()(&CreatureList,FirstFreeCreature); - FirstFreeCreature = FirstFreeCreature + 1; - *ppTVar1 = this; - return; + return (bool)uVar1; } -// DWARF original prototype: void DelInCrList(TCreature * this) - -void __thiscall TCreature::DelInCrList(TCreature *this) +bool GetRaceNoParalyze(int Race) { - TCreature **ppTVar1; - TCreature **ppTVar2; - int i; - int i_00; + undefined1 uVar1; - i_00 = 0; - if (0 < FirstFreeCreature) { - do { - ppTVar1 = vector::operator()(&CreatureList,i_00); - if (*ppTVar1 == this) { - ppTVar1 = vector::operator()(&CreatureList,i_00); - ppTVar2 = vector::operator()(&CreatureList,FirstFreeCreature + -1); - *ppTVar1 = *ppTVar2; - ppTVar1 = vector::operator()(&CreatureList,FirstFreeCreature + -1); - *ppTVar1 = (TCreature *)0x0; - FirstFreeCreature = FirstFreeCreature + -1; - } - i_00 = i_00 + 1; - } while (i_00 < FirstFreeCreature); + if (Race - 1U < 0x1ff) { + uVar1 = RaceData[Race].NoParalyze; } - return; + else { + error(&DAT_08102240,Race); + uVar1 = 1; + } + return (bool)uVar1; } -// WARNING: Variable defined which should be unmapped: StopFight_local -// DWARF original prototype: void StartLogout(TCreature * this, bool Force, bool StopFight) - -void __thiscall TCreature::StartLogout(TCreature *this,bool Force,bool StopFight) +int GetRaceSummonCost(int Race) { - bool bVar1; - int Delay; - bool StopFight_local; + int iVar1; - this->LoggingOut = true; - if ((Force) || (bVar1 = LagDetected(), bVar1)) { - this->LogoutAllowed = true; - } - if ((this->Type == PLAYER) && (this->Connection != (TConnection *)0x0)) { - TConnection::Logout(this->Connection,0,true); + if (Race - 1U < 0x1ff) { + iVar1 = RaceData[Race].SummonCost; } - Delay = 0; - if (!StopFight) { - Delay = 0x3c; + else { + error(&DAT_08102280,Race); + iVar1 = 0; } - TCombat::StopAttack(&this->Combat,Delay); - return; + return iVar1; } -// DWARF original prototype: int LogoutPossible(TCreature * this) - -int __thiscall TCreature::LogoutPossible(TCreature *this) +int GetRacePoison(int Race) { - bool bVar1; + int iVar1; - if (((this->LogoutAllowed == false) && (bVar1 = GameEnding(), !bVar1)) && - (this->IsDead == false)) { - if ((RoundNr < this->EarliestLogoutRound) && (bVar1 = LagDetected(), !bVar1)) { - return 1; - } - bVar1 = IsNoLogoutField(); - if (bVar1) { - return 2; - } - this->LogoutAllowed = true; + if (Race - 1U < 0x1ff) { + iVar1 = RaceData[Race].Poison; } - return 0; -} - - - -// WARNING: Variable defined which should be unmapped: BlockProtectionZone_local -// DWARF original prototype: void BlockLogout(TCreature * this, int Delay, bool BlockProtectionZone) - -void __thiscall TCreature::BlockLogout(TCreature *this,int Delay,bool BlockProtectionZone) - -{ - uint uVar1; - bool bVar2; - ulong Round; - uint uVar3; - char local_d; - bool BlockProtectionZone_local; - - local_d = BlockProtectionZone; - if (WorldType == NON_PVP) { - local_d = '\0'; - } - if ((this->Type == PLAYER) && (bVar2 = CheckRight(this->ID,NO_LOGOUT_BLOCK), !bVar2)) { - if (local_d == '\0') { - uVar3 = this->EarliestProtectionZoneRound; - if (((uVar3 < RoundNr) && (this->Type == PLAYER)) && - (this->Connection == (TConnection *)0x0)) { - return; - } - } - else { - uVar3 = this->EarliestProtectionZoneRound; - } - uVar1 = Delay + RoundNr; - if (((local_d != '\0') || (RoundNr < uVar3)) && (uVar3 < uVar1)) { - this->EarliestProtectionZoneRound = uVar1; - } - if (this->EarliestLogoutRound < uVar1) { - this->EarliestLogoutRound = uVar1; - } - TPlayer::CheckState((TPlayer *)this); - return; + else { + error(&DAT_081022c0,Race); + iVar1 = 0; } - return; + return iVar1; } -// DWARF original prototype: int GetHealth(TCreature * this) - -int __thiscall TCreature::GetHealth(TCreature *this) +bool GetRaceUnpushable(int Race) { - TSkill *this_00; - int iVar1; - uint uVar2; - int iVar3; - int MaxHitpoints; - TSkill *sk; + undefined1 uVar1; - this_00 = (this->super_TSkillBase).Skills[2]; - iVar3 = this_00->Max; - if (iVar3 < 1) { - if (this->IsDead == false) { - error("TCreature::GetHealth: MaxHitpoints von %s ist %d, obwohl sie nicht tot ist.\n", - this->Name,iVar3); - } - uVar2 = 0; + if (Race - 1U < 0x1ff) { + uVar1 = RaceData[Race].Unpushable; } else { - iVar1 = TSkill::Get(this_00); - uVar2 = (iVar1 * 100) / iVar3; - if ((int)uVar2 < 1) { - iVar3 = TSkill::Get(this_00); - uVar2 = (uint)(iVar3 != 0); - } + error(&DAT_08102300,Race); + uVar1 = 1; } - return uVar2; + return (bool)uVar1; } -// DWARF original prototype: int GetSpeed(TCreature * this) - -int __thiscall TCreature::GetSpeed(TCreature *this) - -{ - TSkill *this_00; - int iVar1; - - this_00 = (this->super_TSkillBase).Skills[4]; - if (this_00 == (TSkill *)0x0) { - error("TCreature::GetSpeed: Kein Skill GOSTRENGTH vorhanden.\n"); - iVar1 = 0; - } - else { - iVar1 = TSkill::Get(this_00); - iVar1 = iVar1 * 2 + 0x50; - } - return iVar1; -} - - - -// DWARF original prototype: void Death(TCreature * this) - -void __thiscall TCreature::Death(TCreature *this) - -{ - this->IsDead = true; - this->LoggingOut = true; - return; -} - -// WARNING: Variable defined which should be unmapped: Execute_local -// DWARF original prototype: bool MovePossible(TCreature * this, int x, int y, int z, bool Execute, -// bool Jump) - -bool __thiscall TCreature::MovePossible(TCreature *this,int x,int y,int z,bool Execute,bool Jump) - -{ - bool bVar1; - bool local_18; - bool Execute_local; - - if (Jump) { - local_18 = JumpPossible(x,y,z,false); - } - else { - local_18 = false; - // try { // try from 080a2053 to 080a20dd has its CatchHandler @ 080a20e7 - bVar1 = CoordinateFlag(); - if (bVar1) { - local_18 = CoordinateFlag(); - local_18 = !local_18; - } - } - bVar1 = false; - if (local_18 != false) { - if ((!Execute) && (bVar1 = CoordinateFlag(), bVar1)) { - return false; - } - bVar1 = true; - } - return bVar1; -} - - - -// DWARF original prototype: void TRaceData(TRaceData * this) - -void __thiscall TRaceData::TRaceData(TRaceData *this) - -{ - int i; - int iVar1; - - ObjectType::setTypeID(&this->MaleCorpse,0); - ObjectType::setTypeID(&this->FemaleCorpse,0); - vector::vector(&this->Skill,1,5,5); - // try { // try from 080a2181 to 080a2185 has its CatchHandler @ 080a22e4 - vector<>::vector(&this->Talk,1,5,5,0); - // try { // try from 080a21a7 to 080a21ab has its CatchHandler @ 080a22e0 - vector::vector(&this->Item,1,5,5); - // try { // try from 080a21cd to 080a21d1 has its CatchHandler @ 080a22a0 - vector::vector(&this->Spell,1,5,5); - this->Name[0] = '\0'; - iVar1 = 1; - this->Article[0] = '\0'; - (this->Outfit).OutfitID = 0; - (this->Outfit).field_1 = (anon_union_4_2_730cd3ca_for_TOutfit_2)0x0; - this->Blood = BT_BLOOD; - this->ExperiencePoints = 0; - this->FleeThreshold = 0; - this->Attack = 0; - this->Defend = 0; - this->Armor = 0; - this->Poison = 0; - this->SummonCost = 0; - this->LoseTarget = 0; - this->Strategy[0] = 100; - do { - this->Strategy[iVar1] = 0; - iVar1 = iVar1 + 1; - } while (iVar1 < 4); - this->KickBoxes = false; - this->KickCreatures = false; - this->SeeInvisible = false; - this->Unpushable = false; - this->DistanceFighting = false; - this->NoSummon = false; - this->NoIllusion = false; - this->NoConvince = false; - this->NoBurning = false; - this->NoPoison = false; - this->NoEnergy = false; - this->NoHit = false; - this->NoLifeDrain = false; - this->NoParalyze = false; - this->Skills = 0; - this->Talks = 0; - this->Items = 0; - this->Spells = 0; - return; -} - - - -// DWARF original prototype: void TRaceData(TRaceData * this) - -void __thiscall TRaceData::TRaceData(TRaceData *this) - -{ - int i; - int iVar1; - - ObjectType::setTypeID(&this->MaleCorpse,0); - ObjectType::setTypeID(&this->FemaleCorpse,0); - vector::vector(&this->Skill,1,5,5); - // try { // try from 080a2371 to 080a2375 has its CatchHandler @ 080a24d4 - vector<>::vector(&this->Talk,1,5,5,0); - // try { // try from 080a2397 to 080a239b has its CatchHandler @ 080a24d0 - vector::vector(&this->Item,1,5,5); - // try { // try from 080a23bd to 080a23c1 has its CatchHandler @ 080a2490 - vector::vector(&this->Spell,1,5,5); - this->Name[0] = '\0'; - iVar1 = 1; - this->Article[0] = '\0'; - (this->Outfit).OutfitID = 0; - (this->Outfit).field_1 = (anon_union_4_2_730cd3ca_for_TOutfit_2)0x0; - this->Blood = BT_BLOOD; - this->ExperiencePoints = 0; - this->FleeThreshold = 0; - this->Attack = 0; - this->Defend = 0; - this->Armor = 0; - this->Poison = 0; - this->SummonCost = 0; - this->LoseTarget = 0; - this->Strategy[0] = 100; - do { - this->Strategy[iVar1] = 0; - iVar1 = iVar1 + 1; - } while (iVar1 < 4); - this->KickBoxes = false; - this->KickCreatures = false; - this->SeeInvisible = false; - this->Unpushable = false; - this->DistanceFighting = false; - this->NoSummon = false; - this->NoIllusion = false; - this->NoConvince = false; - this->NoBurning = false; - this->NoPoison = false; - this->NoEnergy = false; - this->NoHit = false; - this->NoLifeDrain = false; - this->NoParalyze = false; - this->Skills = 0; - this->Talks = 0; - this->Items = 0; - this->Spells = 0; - return; -} - - - -char * GetRaceName(int Race) - -{ - TRaceData *pTVar1; - - if (Race - 1U < 0x1ff) { - pTVar1 = RaceData + Race; - } - else { - error(&DAT_08102100,Race); - pTVar1 = (TRaceData *)0x0; - } - return pTVar1->Name; -} - - - -TOutfit GetRaceOutfit(int Race) - -{ - int iVar1; - anon_union_4_2_730cd3ca_for_TOutfit_2 aVar2; - TOutfit TVar3; - int in_stack_00000008; - - if (in_stack_00000008 - 1U < 0x1ff) { - iVar1 = RaceData[in_stack_00000008].Outfit.OutfitID; - aVar2 = RaceData[in_stack_00000008].Outfit.field_1; - } - else { - error(&DAT_08102140); - iVar1 = RaceData[1].Outfit.OutfitID; - aVar2 = RaceData[1].Outfit.field_1; - } - *(int *)Race = iVar1; - *(anon_union_4_2_730cd3ca_for_TOutfit_2 *)(Race + 4) = aVar2; - TVar3.field_1 = aVar2; - TVar3.OutfitID = Race; - return TVar3; -} - - - -bool GetRaceNoSummon(int Race) - -{ - undefined1 uVar1; - - if (Race - 1U < 0x1ff) { - uVar1 = RaceData[Race].NoSummon; - } - else { - error(&DAT_08102180,Race); - uVar1 = 1; - } - return (bool)uVar1; -} - - - -bool GetRaceNoConvince(int Race) - -{ - undefined1 uVar1; - - if (Race - 1U < 0x1ff) { - uVar1 = RaceData[Race].NoConvince; - } - else { - error(&DAT_081021c0,Race); - uVar1 = 1; - } - return (bool)uVar1; -} - - - -bool GetRaceNoIllusion(int Race) - -{ - undefined1 uVar1; - - if (Race - 1U < 0x1ff) { - uVar1 = RaceData[Race].NoIllusion; - } - else { - error(&DAT_08102200,Race); - uVar1 = 1; - } - return (bool)uVar1; -} - - - -bool GetRaceNoParalyze(int Race) - -{ - undefined1 uVar1; - - if (Race - 1U < 0x1ff) { - uVar1 = RaceData[Race].NoParalyze; - } - else { - error(&DAT_08102240,Race); - uVar1 = 1; - } - return (bool)uVar1; -} - - - -int GetRaceSummonCost(int Race) - -{ - int iVar1; - - if (Race - 1U < 0x1ff) { - iVar1 = RaceData[Race].SummonCost; - } - else { - error(&DAT_08102280,Race); - iVar1 = 0; - } - return iVar1; -} - - - -int GetRacePoison(int Race) - -{ - int iVar1; - - if (Race - 1U < 0x1ff) { - iVar1 = RaceData[Race].Poison; - } - else { - error(&DAT_081022c0,Race); - iVar1 = 0; - } - return iVar1; -} - - - -bool GetRaceUnpushable(int Race) - -{ - undefined1 uVar1; - - if (Race - 1U < 0x1ff) { - uVar1 = RaceData[Race].Unpushable; - } - else { - error(&DAT_08102300,Race); - uVar1 = 1; - } - return (bool)uVar1; -} - - - -void LoadRace(char *FileName) +void LoadRace(char *FileName) { TReadScriptFile *pTVar1; @@ -33734,77 +32288,19 @@ LAB_080a4d67: } while( true ); } - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void InitCr(void) +void __tcf_0(void *param_1) { - int i; - matrix<> *this; - int iVar1; - - // try { // try from 080a5106 to 080a510a has its CatchHandler @ 080a51e0 - this = (matrix<> *)operator_new(0x14); - // try { // try from 080a5148 to 080a514c has its CatchHandler @ 080a51b0 - matrix<>::matrix(this,SectorXMin * 2,SectorXMax * 2 + 1,SectorYMin * 2,SectorYMax * 2 + 1,0); - NextCreatureID = 0x40000000; - FirstChainCreature = this; - // try { // try from 080a515d to 080a517c has its CatchHandler @ 080a51e0 - LoadRaces(); - LoadMonsterRaids(); - FirstFreeCreature = 0; - InitPlayer(); - InitCrskill(); - InitNonplayer(); - iVar1 = 0; - do { - KilledCreatures[iVar1] = 0; - KilledPlayers[iVar1] = 0; - iVar1 = iVar1 + 1; - } while (iVar1 < 0x200); + if (CreatureList.entry == (TCreature **)0x0) { + return; + } + operator_delete__(CreatureList.entry); return; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void ExitCr(void) - -{ - matrix<> *pmVar1; - - WriteKillStatistics(); - ExitPlayer(); - ExitNonplayer(); - ExitCrskill(); - pmVar1 = FirstChainCreature; - if (FirstChainCreature != (matrix<> *)0x0) { - if (FirstChainCreature->entry != (ulong *)0x0) { - operator_delete__(FirstChainCreature->entry); - } - operator_delete(pmVar1); - } - return; -} - - - -void __tcf_0(void *param_1) - -{ - if (CreatureList.entry == (TCreature **)0x0) { - return; - } - operator_delete__(CreatureList.entry); - return; -} - - - -void __tcf_1(void *param_1) +void __tcf_1(void *param_1) { int *piVar1; @@ -33880,67 +32376,6 @@ void _GLOBAL__I_HashList(void) return; } - - -// DWARF original prototype: bool IsPeaceful(TCreature * this) - -bool __thiscall TCreature::IsPeaceful(TCreature *this) - -{ - return true; -} - - - -// DWARF original prototype: ulong GetMaster(TCreature * this) - -ulong __thiscall TCreature::GetMaster(TCreature *this) - -{ - return 0; -} - - - -// DWARF original prototype: void TalkStimulus(TCreature * this, ulong param_1, char * param_2) - -void __thiscall TCreature::TalkStimulus(TCreature *this,ulong param_1,char *param_2) - -{ - return; -} - - - -// DWARF original prototype: void DamageStimulus(TCreature * this, ulong param_1, int param_2, int -// param_3) - -void __thiscall TCreature::DamageStimulus(TCreature *this,ulong param_1,int param_2,int param_3) - -{ - return; -} - - - -// DWARF original prototype: void IdleStimulus(TCreature * this) - -void __thiscall TCreature::IdleStimulus(TCreature *this) - -{ - return; -} - - - -// DWARF original prototype: void AttackStimulus(TCreature * this, ulong param_1) - -void __thiscall TCreature::AttackStimulus(TCreature *this,ulong param_1) - -{ - return; -} - void __static_initialization_and_destruction_0(int __initialize_p,int __priority) { @@ -47534,3221 +45969,1343 @@ void __static_initialization_and_destruction_0(int __initialize_p,int __priority return; } +// DWARF original prototype: void Go(TCreature * this, int x, int y, int z) - -// DWARF original prototype: void TShortway(TShortway * this, TCreature * cr, int VisibleX, int -// VisibleY) - -void __thiscall TShortway::TShortway(TShortway *this,TCreature *cr,int VisibleX,int VisibleY) +void __thiscall TCreature::Go(TCreature *this,int x,int y,int z) { - matrix<> *this_00; + TSkill *pTVar1; + bool bVar2; + uint uVar3; + int iVar4; + CreatureType CVar5; + undefined4 *puVar6; + int iVar7; + int iVar8; + int iVar9; + int *piVar10; + int iVar11; + int Delay; + int dy; + int local_54; + int local_50; + Object local_4c [4]; + Object local_3c [4]; + Object local_2c [7]; - this->Map = (matrix<> *)0x0; - if (cr == (TCreature *)0x0) { - error(&DAT_08106b80); - return; - } - if ((((0 < VisibleX) && (0 < VisibleY)) && (VisibleX < 0x65)) && (VisibleY < 0x65)) { - this->cr = cr; - this->VisibleX = VisibleX; - this->VisibleY = VisibleY; - this->StartX = cr->posx; - this->StartY = cr->posy; - this->StartZ = cr->posz; - this_00 = (matrix<> *)operator_new(0x14); - // try { // try from 080bdfe3 to 080bdfe7 has its CatchHandler @ 080be019 - matrix<>::matrix(this_00,~VisibleX,VisibleX + 1,~VisibleY,VisibleY + 1); - this->Map = this_00; - FillMap(this); - return; + if (z == this->posz) { + uVar3 = x - this->posx; + if (0x7fffffff < uVar3) { + uVar3 = -uVar3; + } + if ((int)uVar3 < 2) { + uVar3 = y - this->posy; + if (0x7fffffff < uVar3) { + uVar3 = -uVar3; + } + if ((int)uVar3 < 2) { + pTVar1 = (this->super_TSkillBase).Skills[0x14]; + if (((pTVar1 != (TSkill *)0x0) && + (iVar8 = (*pTVar1->_vptr_TSkill[0xd])(pTVar1), 0 < iVar8)) && + (iVar8 = TSkill::Get((this->super_TSkillBase).Skills[0x14]), iVar8 == 0)) { + iVar8 = rand(); + pTVar1 = (this->super_TSkillBase).Skills[0x14]; + iVar9 = (*pTVar1->_vptr_TSkill[0xd])(pTVar1); + if (iVar8 % (7 - iVar9) == 0) { + Delay = 0; + iVar9 = 0; + iVar8 = rand(); + iVar8 = iVar8 % 4; + if (iVar8 == 1) { + iVar9 = -1; + } + else if (iVar8 < 2) { + if (iVar8 == 0) { + iVar9 = 1; + } + } + else if (iVar8 == 2) { + Delay = 1; + iVar9 = 0; + } + else if (iVar8 == 3) { + Delay = -1; + iVar9 = 0; + } + x = iVar9 + this->posx; + y = Delay + this->posy; + bVar2 = ToDoClear(this); + if ((bVar2) && (this->Type == PLAYER)) { + SendSnapback(this->Connection); + } + ToDoTalk(this); + if (this->NrToDo != 0) { + this->LockToDo = true; + this->ActToDo = 0; + local_50 = CalculateDelay(this); + local_54 = 1; + piVar10 = &local_54; + if (0 < local_50) { + piVar10 = &local_50; + } + iVar8 = *piVar10; + priority_queue<>::insert(&ToDoQueue); + this->NextWakeup = iVar8 + ServerMilliseconds; + } + } + } + // try { // try from 080bf247 to 080bf65d has its CatchHandler @ 080bf6b8 + iVar9 = x; + iVar8 = y; + iVar11 = z; + iVar4 = (*this->_vptr_TCreature[3])(this,x,y,z,1,0); + if ((char)iVar4 != '\0') goto LAB_080bf2f7; + if (this->Type == PLAYER) { + CVar5 = PLAYER; + if (0 < z) { + iVar8 = this->posz; + iVar9 = this->posy; + iVar4 = GetHeight(); + if (0x17 < iVar4) { + if (this->posx == x) { + iVar4 = this->posy; + } + else { + iVar4 = this->posy; + if (iVar4 != y) goto LAB_080bf2a4; + } + iVar11 = 0; + iVar7 = z + -1; + iVar8 = iVar7; + bVar2 = CoordinateFlag(); + iVar9 = iVar4; + if (!bVar2) { + iVar11 = 0x20; + iVar9 = this->posy; + iVar8 = iVar7; + bVar2 = CoordinateFlag(); + if ((!bVar2) && + (iVar9 = x, iVar8 = y, iVar11 = iVar7, + iVar4 = (*this->_vptr_TCreature[3])(this,x,y,iVar7,1,1), + (char)iVar4 != '\0')) { + z = iVar7; + } + } + } +LAB_080bf2a4: + CVar5 = this->Type; + } + if ((CVar5 == PLAYER) && (z < 0xf)) { + iVar4 = z + 1; + iVar9 = y; + iVar8 = iVar4; + iVar7 = GetHeight(); + if ((0x17 < iVar7) && ((this->posx == x || (this->posy == y)))) { + iVar11 = 0; + iVar9 = y; + iVar8 = z; + bVar2 = CoordinateFlag(); + if (!bVar2) { + iVar11 = 0x20; + iVar9 = y; + iVar8 = z; + bVar2 = CoordinateFlag(); + if ((!bVar2) && + (iVar9 = x, iVar8 = y, iVar11 = iVar4, + iVar7 = (*this->_vptr_TCreature[3])(this,x,y,iVar4,1,1), + (char)iVar7 != '\0')) { + z = iVar4; + } + } + } + } + } + if ((z != this->posz) && + (iVar9 = x, iVar8 = y, iVar4 = (*this->_vptr_TCreature[3])(this,x,y,z,1,1), + iVar11 = z, (char)iVar4 != '\0')) { +LAB_080bf2f7: + local_2c[0].ObjectID = ::NONE.ObjectID; + GetMapContainer((int)local_3c,x,y); + local_4c[0].ObjectID = (this->CrObject).ObjectID; + ::Move(this->ID,local_4c,local_3c,-1,false,local_2c); + return; + } + puVar6 = (undefined4 *)__cxa_allocate_exception(4,iVar9,iVar8,iVar11); + *puVar6 = 0x34; + goto LAB_080bf372; + } + } } - error(&DAT_08106b40); - return; + puVar6 = (undefined4 *)__cxa_allocate_exception(4); + *puVar6 = 1; +LAB_080bf372: + // WARNING: Subroutine does not return + __cxa_throw(puVar6,&RESULT::typeinfo,0); } -// DWARF original prototype: void TShortway(TShortway * this, TCreature * cr, int VisibleX, int -// VisibleY) +// DWARF original prototype: void Rotate(TCreature * this, uchar Dir) -void __thiscall TShortway::TShortway(TShortway *this,TCreature *cr,int VisibleX,int VisibleY) +void __thiscall TCreature::Rotate(TCreature *this,uchar Dir) { - matrix<> *this_00; + Object local_1c [6]; - this->Map = (matrix<> *)0x0; - if (cr == (TCreature *)0x0) { - error(&DAT_08106b80); - return; - } - if ((((0 < VisibleX) && (0 < VisibleY)) && (VisibleX < 0x65)) && (VisibleY < 0x65)) { - this->cr = cr; - this->VisibleX = VisibleX; - this->VisibleY = VisibleY; - this->StartX = cr->posx; - this->StartY = cr->posy; - this->StartZ = cr->posz; - this_00 = (matrix<> *)operator_new(0x14); - // try { // try from 080be0f3 to 080be0f7 has its CatchHandler @ 080be129 - matrix<>::matrix(this_00,~VisibleX,VisibleX + 1,~VisibleY,VisibleY + 1); - this->Map = this_00; - FillMap(this); - return; - } - error(&DAT_08106b40); + local_1c[0].ObjectID = (this->CrObject).ObjectID; + this->Direction = (uint)Dir; + AnnounceChangedObject(local_1c,2); return; } -// DWARF original prototype: void ~TShortway(TShortway * this, int __in_chrg) +// DWARF original prototype: void Rotate(TCreature * this, TCreature * Target) -void __thiscall TShortway::~TShortway(TShortway *this,int __in_chrg) +void __thiscall TCreature::Rotate(TCreature *this,TCreature *Target) { - matrix<> *pmVar1; + uint uVar1; + int dy; + uint uVar2; + int iVar3; + int dx; + int iVar4; + Object local_1c [4]; - pmVar1 = this->Map; - if (pmVar1 != (matrix<> *)0x0) { - if (pmVar1->entry != (TShortwayPoint *)0x0) { - operator_delete__(pmVar1->entry); - } - operator_delete(pmVar1); - return; + if (Target == (TCreature *)0x0) { + error("TCreature::Rotate: Target ist NULL.\n"); } - return; -} - - - -// DWARF original prototype: void ~TShortway(TShortway * this, int __in_chrg) - -void __thiscall TShortway::~TShortway(TShortway *this,int __in_chrg) - -{ - matrix<> *pmVar1; - - pmVar1 = this->Map; - if (pmVar1 != (matrix<> *)0x0) { - if (pmVar1->entry != (TShortwayPoint *)0x0) { - operator_delete__(pmVar1->entry); + else { + iVar4 = Target->posx - this->posx; + uVar2 = Target->posy - this->posy; + iVar3 = -iVar4; + if (-1 < iVar4) { + iVar3 = iVar4; } - operator_delete(pmVar1); - return; + uVar1 = -uVar2; + if (-1 < (int)uVar2) { + uVar1 = uVar2; + } + if (iVar3 < (int)uVar1) { + uVar2 = ((int)~uVar2 >> 0x1f) * -2; + } + else { + uVar2 = (iVar4 >> 0x1f) * -2 + 1; + } + local_1c[0].ObjectID = (this->CrObject).ObjectID; + this->Direction = uVar2 & 0xff; + AnnounceChangedObject(local_1c,2); } return; } -// DWARF original prototype: void FillMap(TShortway * this) +// DWARF original prototype: void Move(TCreature * this, Object * Obj, int zx, int zy, int zz, uchar +// Count) -void __thiscall TShortway::FillMap(TShortway *this) +void __thiscall TCreature::Move(TCreature *this,Object *Obj,int zx,int zy,int zz,uchar Count) { - matrix<> *pmVar1; + bool bVar1; bool bVar2; - int iVar3; - int iVar4; - TShortwayPoint *pTVar5; - ulong uVar6; - uint uVar7; - int iVar8; - uint uVar9; - int x_1; - uint uVar10; - int y; - int iVar11; - ulong local_44; - int Waypoints; - int x; + ulong uVar3; + undefined4 *puVar4; + int *piVar5; + int Delay; + uint Count_00; + Object *Obj_00; + Object *pOVar6; + int iVar7; + int local_a0; + int b_1; + int b; + int iStack_94; + uchar Count_local; + int local_90; + Object local_8c [4]; + Object local_7c [4]; + Object local_6c; + Object DestCon; + Object local_5c; + Object DestObj; + Object local_4c [4]; + Object local_3c [4]; Object local_2c; - Object Obj; + Object Dest; - this->MinWaypoints = 1000; - uVar7 = this->VisibleX; - Waypoints = -uVar7; - if (-uVar7 == uVar7 || SBORROW4(Waypoints,uVar7) != (int)(uVar7 * -2) < 0) { - uVar9 = this->VisibleY; - do { - iVar11 = -uVar9; - if (-uVar9 == uVar9 || iVar11 < (int)uVar9) { + b._3_1_ = Count; + // try { // try from 080bf7d5 to 080bfb3a has its CatchHandler @ 080c01e0 + bVar1 = Object::exists(Obj); + if (bVar1) { + local_2c.ObjectID = (this->CrObject).ObjectID; + if (Obj->ObjectID == local_2c.ObjectID) { + Go(this,zx,zy,zz); + return; + } + Object::getObjectType(&local_2c); + if (local_2c.ObjectID == 99) { + TCombat::DelayAttack(&this->Combat,2000); + } + Object::getObjectType(&local_2c); + bVar1 = ObjectType::getFlag((ObjectType *)&local_2c,CUMULATIVE); + // try { // try from 080bfff5 to 080c0037 has its CatchHandler @ 080c01e0 + if ((bVar1) && (uVar3 = Object::getAttribute(Obj,AMOUNT), uVar3 < Count)) { + uVar3 = Object::getAttribute(Obj,AMOUNT); + b._3_1_ = (byte)uVar3; + } + if (zx == 0xffff) { + if (zy == 0) { + b_1 = 1; + iVar7 = b_1; do { - local_44 = 0xffffffff; - iVar4 = this->StartZ; - GetFirstObject(); - bVar2 = Object::exists(&local_2c); - if (bVar2) { - Object::getObjectType((Object *)&x); - bVar2 = ObjectType::getFlag((ObjectType *)&x,BANK); - if (bVar2) { - Object::getObjectType((Object *)&x); - bVar2 = ObjectType::getFlag((ObjectType *)&x,UNPASS); - if (!bVar2) { - Object::getObjectType((Object *)&x); - local_44 = ObjectType::getAttribute((ObjectType *)&x,WAYPOINTS); - if (local_44 == 0) { - Object::getObjectType((Object *)&x); - error(&DAT_08106bc0,0,x); - local_44 = 0xffffffff; - } - iVar4 = this->StartZ; - iVar3 = (*this->cr->_vptr_TCreature[3]) - (this->cr,Waypoints + this->StartX, - this->StartY + iVar11,iVar4,0,0); - uVar6 = 0xffffffff; - if ((char)iVar3 != '\0') { - uVar6 = local_44; - } - local_44 = uVar6; - if ((0 < (int)uVar6) && ((int)uVar6 < this->MinWaypoints)) { - this->MinWaypoints = uVar6; - } + b_1 = iVar7; + local_6c = (Object)Obj->ObjectID; + // try { // try from 080bfb73 to 080bfb94 has its CatchHandler @ 080c003d + GetBodyContainer((ulong)&local_5c,this->ID); + CheckInventoryDestination(&local_6c,&local_5c,false); + if ((1 < b_1 - 5U) && (b_1 != 10)) break; + iVar7 = b_1 + 1; + } while (b_1 + 1 < 0xb); + zy = b_1; + if (b_1 == 0) { + local_a0 = 1; + do { + pOVar6 = (Object *)this->ID; + iVar7 = local_a0; + // try { // try from 080bfbe3 to 080bfc4b has its CatchHandler @ 080c01e0 + GetBodyObject((ulong)&local_6c,(int)pOVar6); + local_5c.ObjectID = ::NONE.ObjectID; + if (local_6c.ObjectID != ::NONE.ObjectID) { + Object::getObjectType(&local_5c); + pOVar6 = (Object *)0x4; + bVar1 = ObjectType::getFlag((ObjectType *)&local_5c,CONTAINER); + if (bVar1) { + pOVar6 = &local_5c; + local_5c.ObjectID = local_6c.ObjectID; + local_4c[0] = (Object)Obj->ObjectID; + // try { // try from 080bffcb to 080bffcf has its CatchHandler @ 080c0067 + CheckContainerDestination(local_4c,pOVar6); + b_1 = local_a0; } } + local_a0 = local_a0 + 1; + } while (local_a0 < 0xb); + zy = b_1; + if (b_1 == 0) { + puVar4 = (undefined4 *)__cxa_allocate_exception(4,pOVar6,iVar7); + *puVar4 = 4; + goto LAB_080bfb23; } - pmVar1 = this->Map; - iVar3 = iVar11 - pmVar1->ymin; - iVar8 = Waypoints - pmVar1->xmin; - if ((((iVar8 < 0) || (pmVar1->dx <= iVar8)) || (iVar3 < 0)) || - (pmVar1->dy <= iVar3)) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar8 + pmVar1->xmin, - iVar3 + pmVar1->ymin,iVar4); - pTVar5 = pmVar1->entry; + } + } + if (((0 < zy) && (0x34 < zy - 0xbU)) && (zy < 0x50)) { + pOVar6 = &local_6c; + Obj_00 = (Object *)this->ID; + GetBodyContainer((ulong)pOVar6,(int)Obj_00); + local_5c.ObjectID = ::NONE.ObjectID; + if (zy < 0x40) { + Obj_00 = (Object *)this->ID; + GetBodyObject((ulong)local_3c,(int)Obj_00); + local_5c.ObjectID = local_3c[0].ObjectID; + } + else { + if (zz < 0xfe) { + ObjectType::setTypeID((ObjectType *)&local_2c,0); + Obj_00 = (Object *)this->ID; + GetObject((ulong)local_3c,(int)Obj_00,0xffff,zy,zz,(ObjectType *)zz); + local_5c.ObjectID = local_3c[0].ObjectID; } - else { - pTVar5 = pmVar1->entry + iVar3 * pmVar1->dx + iVar8; - } - pTVar5->Waypoints = local_44; - pmVar1 = this->Map; - iVar3 = iVar11 - pmVar1->ymin; - iVar8 = Waypoints - pmVar1->xmin; - if (((iVar8 < 0) || (pmVar1->dx <= iVar8)) || - ((iVar3 < 0 || (pmVar1->dy <= iVar3)))) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar8 + pmVar1->xmin, - iVar3 + pmVar1->ymin,iVar4); - pTVar5 = pmVar1->entry; + if (zz == 0xfe) { + local_4c[0].ObjectID = ::NONE.ObjectID; + if (local_6c.ObjectID == ::NONE.ObjectID) goto LAB_080bfeb5; + Object::getContainer(local_3c); + local_6c.ObjectID = local_3c[0].ObjectID; + Obj_00 = pOVar6; } - else { - pTVar5 = pmVar1->entry + iVar3 * pmVar1->dx + iVar8; - } - pTVar5->x = Waypoints; - pmVar1 = this->Map; - iVar4 = iVar11 - pmVar1->ymin; - iVar3 = Waypoints - pmVar1->xmin; - if (((iVar3 < 0) || (pmVar1->dx <= iVar3)) || - ((iVar4 < 0 || (pmVar1->dy <= iVar4)))) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar3 + pmVar1->xmin, - iVar4 + pmVar1->ymin); - pTVar5 = pmVar1->entry; + } + bVar1 = false; + if (local_5c.ObjectID != ::NONE.ObjectID) { + local_4c[0].ObjectID = ::NONE.ObjectID; + local_3c[0].ObjectID = ::NONE.ObjectID; + Object::getObjectType(local_3c); + Obj_00 = (Object *)0x4; + bVar1 = ObjectType::getFlag((ObjectType *)local_3c,CONTAINER); + } + if (bVar1) { + local_6c.ObjectID = local_5c.ObjectID; + local_5c.ObjectID = ::NONE.ObjectID; + local_2c.ObjectID = ::NONE.ObjectID; + } + bVar1 = false; + local_4c[0].ObjectID = ::NONE.ObjectID; + local_3c[0].ObjectID = ::NONE.ObjectID; + if (local_5c.ObjectID != ::NONE.ObjectID) { + Object::getObjectType(local_3c); + Obj_00 = (Object *)0x6; + bVar2 = ObjectType::getFlag((ObjectType *)local_3c,CUMULATIVE); + if (bVar2) { + Object::getObjectType(local_3c); + Obj_00 = &local_5c; + Object::getObjectType(&local_2c); + if (local_3c[0].ObjectID == local_2c.ObjectID) { + bVar1 = true; + } } - else { - pTVar5 = pmVar1->entry + iVar4 * pmVar1->dx + iVar3; + } + if (bVar1) { + Count_00 = (uint)b._3_1_; + Obj_00 = (Object *)0x2; + // try { // try from 080bfd46 to 080bfd4a has its CatchHandler @ 080c01e0 + uVar3 = Object::getAttribute(&local_5c,AMOUNT); + if (100 < uVar3 + Count_00) { + Obj_00 = (Object *)0x2; + // try { // try from 080bfdd1 to 080bffa7 has its CatchHandler @ 080c01e0 + uVar3 = Object::getAttribute(&local_5c,AMOUNT); + Count_00 = 100 - uVar3; } - pTVar5->y = iVar11; - iVar11 = iVar11 + 1; - uVar9 = this->VisibleY; - } while (iVar11 <= (int)uVar9); - uVar7 = this->VisibleX; - } - Waypoints = Waypoints + 1; - } while (Waypoints <= (int)uVar7); - } - else { - uVar9 = this->VisibleY; - } - uVar10 = ~uVar7; - if ((int)uVar10 <= (int)(uVar7 + 1)) { - while( true ) { - pmVar1 = this->Map; - iVar11 = ~uVar9 - pmVar1->ymin; - iVar4 = uVar10 - pmVar1->xmin; - if ((((iVar4 < 0) || (pmVar1->dx <= iVar4)) || (iVar11 < 0)) || (pmVar1->dy <= iVar11)) - { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar4 + pmVar1->xmin, - iVar11 + pmVar1->ymin); - pTVar5 = pmVar1->entry; - } - else { - pTVar5 = pmVar1->entry + iVar11 * pmVar1->dx + iVar4; - } - pTVar5->Waypoints = -1; - pmVar1 = this->Map; - iVar11 = (this->VisibleY + 1) - pmVar1->ymin; - iVar4 = uVar10 - pmVar1->xmin; - if (((iVar4 < 0) || (pmVar1->dx <= iVar4)) || ((iVar11 < 0 || (pmVar1->dy <= iVar11)))) - { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar4 + pmVar1->xmin, - iVar11 + pmVar1->ymin); - pTVar5 = pmVar1->entry; - } - else { - pTVar5 = pmVar1->entry + iVar11 * pmVar1->dx + iVar4; + if (0 < (int)Count_00) { + Obj_00 = local_8c; + local_2c.ObjectID = ::NONE.ObjectID; + local_7c[0].ObjectID = local_5c.ObjectID; + local_8c[0] = (Object)Obj->ObjectID; + // try { // try from 080bfd98 to 080bfd9c has its CatchHandler @ 080c0082 + Merge(this->ID,Obj_00,local_7c,Count_00,&local_2c); + b._3_1_ = b._3_1_ - (char)Count_00; + if (b._3_1_ == 0) { + return; + } + } + local_7c[0] = (Object)::NONE.ObjectID; + local_5c.ObjectID = local_7c[0].ObjectID; + } + local_8c[0].ObjectID = ::NONE.ObjectID; + if (local_6c.ObjectID != ::NONE.ObjectID) { + local_7c[0].ObjectID = local_6c.ObjectID; + local_8c[0].ObjectID = local_5c.ObjectID; + local_4c[0] = (Object)Obj->ObjectID; + // try { // try from 080bfd13 to 080bfd17 has its CatchHandler @ 080c00b2 + ::Move(this->ID,local_4c,local_7c,(uint)b._3_1_,false,local_8c); + return; + } + puVar4 = (undefined4 *)__cxa_allocate_exception(4,Obj_00); + *puVar4 = 5; + goto LAB_080bfb23; } - pTVar5->Waypoints = -1; - uVar10 = uVar10 + 1; - uVar7 = this->VisibleX; - if ((int)(uVar7 + 1) < (int)uVar10) break; - uVar9 = this->VisibleY; + error(&DAT_08106e00,zy); } - uVar9 = this->VisibleY; - } - iVar11 = -uVar9; - if (-uVar9 == uVar9 || iVar11 < (int)uVar9) { - while( true ) { - pmVar1 = this->Map; - iVar4 = iVar11 - pmVar1->ymin; - iVar3 = ~uVar7 - pmVar1->xmin; - if (((iVar3 < 0) || (pmVar1->dx <= iVar3)) || ((iVar4 < 0 || (pmVar1->dy <= iVar4)))) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar3 + pmVar1->xmin, - iVar4 + pmVar1->ymin); - pTVar5 = pmVar1->entry; - } - else { - pTVar5 = pmVar1->entry + iVar4 * pmVar1->dx + iVar3; - } - pTVar5->Waypoints = -1; - pmVar1 = this->Map; - iVar4 = iVar11 - pmVar1->ymin; - iVar3 = (this->VisibleX + 1) - pmVar1->xmin; - if ((((iVar3 < 0) || (pmVar1->dx <= iVar3)) || (iVar4 < 0)) || (pmVar1->dy <= iVar4)) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar3 + pmVar1->xmin, - iVar4 + pmVar1->ymin); - pTVar5 = pmVar1->entry; - } - else { - pTVar5 = pmVar1->entry + iVar4 * pmVar1->dx + iVar3; - } - pTVar5->Waypoints = -1; - iVar11 = iVar11 + 1; - if (this->VisibleY < iVar11) break; - uVar7 = this->VisibleX; - } - } - return; -} - - - -// WARNING: Variable defined which should be unmapped: x -// DWARF original prototype: void ClearMap(TShortway * this) - -void __thiscall TShortway::ClearMap(TShortway *this) - -{ - matrix<> *pmVar1; - int iVar2; - TShortwayPoint *pTVar3; - int iVar4; - int y; - int iVar5; - int local_14; - int x; - - iVar2 = this->VisibleX; - local_14 = -iVar2; - if (-iVar2 == iVar2 || SBORROW4(local_14,iVar2) != iVar2 * -2 < 0) { - iVar4 = this->VisibleY; - do { - iVar5 = -iVar4; - if (-iVar4 == iVar4 || iVar5 < iVar4) { - do { - pmVar1 = this->Map; - iVar2 = iVar5 - pmVar1->ymin; - iVar4 = local_14 - pmVar1->xmin; - if ((((iVar4 < 0) || (pmVar1->dx <= iVar4)) || (iVar2 < 0)) || - (pmVar1->dy <= iVar2)) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar4 + pmVar1->xmin, - iVar2 + pmVar1->ymin); - pTVar3 = pmVar1->entry; - } - else { - pTVar3 = pmVar1->entry + iVar2 * pmVar1->dx + iVar4; - } - pTVar3->Predecessor = (TShortwayPoint *)0x0; - pmVar1 = this->Map; - iVar2 = iVar5 - pmVar1->ymin; - iVar4 = local_14 - pmVar1->xmin; - if (((iVar4 < 0) || (pmVar1->dx <= iVar4)) || - ((iVar2 < 0 || (pmVar1->dy <= iVar2)))) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar4 + pmVar1->xmin, - iVar2 + pmVar1->ymin); - pTVar3 = pmVar1->entry; - } - else { - pTVar3 = pmVar1->entry + iVar2 * pmVar1->dx + iVar4; - } - pTVar3->NextToExpand = (TShortwayPoint *)0x0; - pmVar1 = this->Map; - iVar2 = iVar5 - pmVar1->ymin; - iVar4 = local_14 - pmVar1->xmin; - if (((iVar4 < 0) || (pmVar1->dx <= iVar4)) || - ((iVar2 < 0 || (pmVar1->dy <= iVar2)))) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar4 + pmVar1->xmin, - iVar2 + pmVar1->ymin); - pTVar3 = pmVar1->entry; - } - else { - pTVar3 = pmVar1->entry + iVar2 * pmVar1->dx + iVar4; - } - pTVar3->Waylength = 0x7fffffff; - pmVar1 = this->Map; - iVar2 = iVar5 - pmVar1->ymin; - iVar4 = local_14 - pmVar1->xmin; - if ((((iVar4 < 0) || (pmVar1->dx <= iVar4)) || (iVar2 < 0)) || - (pmVar1->dy <= iVar2)) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar4 + pmVar1->xmin, - iVar2 + pmVar1->ymin); - pTVar3 = pmVar1->entry; + else { + GetMapContainer((int)&local_2c,zx,zy); + bVar1 = Object::exists(&local_2c); + if (bVar1) { + Object::getObjectType(local_3c); + bVar1 = ObjectType::getFlag((ObjectType *)local_3c,HANG); + if (bVar1) { + bVar1 = false; + bVar2 = CoordinateFlag(); + if ((bVar2) || (bVar2 = CoordinateFlag(), bVar2)) { + bVar1 = true; } - else { - pTVar3 = pmVar1->entry + iVar2 * pmVar1->dx + iVar4; + if (bVar1) { + local_3c[0].ObjectID = local_2c.ObjectID; + bVar1 = ObjectInRange(this->ID,local_3c,1); + if (!bVar1) { + bVar1 = ToDoClear(this); + if ((bVar1) && (this->Type == PLAYER)) { + SendSnapback(this->Connection); + } + local_4c[0] = (Object)Obj->ObjectID; + uVar3 = GetObjectCreatureID(local_4c); + if (uVar3 != this->ID) { + local_5c = (Object)Obj->ObjectID; + ToDoMove(this,&local_5c,0xffff,0,0,'\x01'); + } + ToDoGo(this,zx,zy,zz,false,0x7fffffff); + local_5c = (Object)Obj->ObjectID; + ToDoMove(this,&local_5c,zx,zy,zz,'\x01'); + if (this->NrToDo == 0) { + return; + } + this->LockToDo = true; + this->ActToDo = 0; + local_90 = CalculateDelay(this); + iStack_94 = 1; + piVar5 = &stack0xffffff6c; + if (0 < local_90) { + piVar5 = &local_90; + } + iVar7 = *piVar5; + priority_queue<>::insert(&ToDoQueue); + this->NextWakeup = iVar7 + ServerMilliseconds; + return; + } } - pTVar3->Heuristic = 0x7fffffff; - iVar5 = iVar5 + 1; - iVar4 = this->VisibleY; - } while (iVar5 <= iVar4); - iVar2 = this->VisibleX; + } + local_5c.ObjectID = ::NONE.ObjectID; + local_4c[0].ObjectID = local_2c.ObjectID; + local_6c = (Object)Obj->ObjectID; + ::Move(this->ID,&local_6c,local_4c,(uint)b._3_1_,false,&local_5c); + return; } - local_14 = local_14 + 1; - } while (local_14 <= iVar2); + } + puVar4 = (undefined4 *)__cxa_allocate_exception(4); + *puVar4 = 0xffffffff; } - this->FirstToExpand = (TShortwayPoint *)0x0; - return; + else { +LAB_080bfeb5: + puVar4 = (undefined4 *)__cxa_allocate_exception(4); + *puVar4 = 1; + } +LAB_080bfb23: + // WARNING: Subroutine does not return + __cxa_throw(puVar4,&RESULT::typeinfo,0); } -// DWARF original prototype: bool Calculate(TShortway * this, int DestX, int DestY, bool MustReach, -// int MaxSteps) +// DWARF original prototype: void Trade(TCreature * this, Object * Obj, ulong PartnerID) -bool __thiscall -TShortway::Calculate(TShortway *this,int DestX,int DestY,bool MustReach,int MaxSteps) +void __thiscall TCreature::Trade(TCreature *this,Object *Obj,ulong PartnerID) { - matrix<> *pmVar1; - int iVar2; - int iVar3; + Object OVar1; + bool bVar2; + TPlayer *pTVar3; int iVar4; - TCreature *this_00; - bool bVar5; - int iVar6; - int iVar7; - int iVar8; - TShortwayPoint *pTVar9; - TToDoEntry *pTVar10; - int iVar11; - TShortwayPoint *pTVar12; - TShortwayPoint *local_4c; - TShortwayPoint *Search; - int dy; - int dx; - bool MustReach_local; - TToDoEntry TD; + undefined4 *puVar5; + TPlayer *Partner; + TConnection *Connection; + char *Name; + Object local_5c; + Object Help_1; + Object local_4c [4]; + Object local_3c [4]; + Object local_2c; + Object Help; - if (this->Map == (matrix<> *)0x0) { - error("TShortway::Calculate: Karte existiert nicht.\n"); - } - else { - iVar6 = DestX - this->StartX; - iVar7 = DestY - this->StartY; - iVar8 = -iVar6; - if (-1 < iVar6) { - iVar8 = iVar6; - } - if (iVar8 <= this->VisibleX) { - iVar8 = -iVar7; - if (-1 < iVar7) { - iVar8 = iVar7; - } - if (iVar8 <= this->VisibleY) { - if ((iVar6 == 0) && (iVar7 == 0)) { - return true; - } - ClearMap(this); - pmVar1 = this->Map; - iVar8 = iVar7 - pmVar1->ymin; - iVar11 = iVar6 - pmVar1->xmin; - if ((((iVar11 < 0) || (pmVar1->dx <= iVar11)) || (iVar8 < 0)) || - (pmVar1->dy <= iVar8)) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar11 + pmVar1->xmin, - iVar8 + pmVar1->ymin); - pTVar9 = pmVar1->entry; - } - else { - pTVar9 = pmVar1->entry + iVar8 * pmVar1->dx + iVar11; - } - pTVar9->Waylength = 0; - pmVar1 = this->Map; - iVar8 = iVar7 - pmVar1->ymin; - iVar11 = iVar6 - pmVar1->xmin; - if (((iVar11 < 0) || (pmVar1->dx <= iVar11)) || - ((iVar8 < 0 || (pmVar1->dy <= iVar8)))) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar11 + pmVar1->xmin, - iVar8 + pmVar1->ymin); - pTVar9 = pmVar1->entry; - } - else { - pTVar9 = pmVar1->entry + iVar8 * pmVar1->dx + iVar11; - } - this->FirstToExpand = pTVar9; - while (pTVar9 != (TShortwayPoint *)0x0) { - Expand(this,pTVar9); - pTVar9 = this->FirstToExpand; - } - pmVar1 = this->Map; - iVar11 = -pmVar1->xmin; - iVar8 = -pmVar1->ymin; - if (((pmVar1->xmin < 1) && (iVar11 < pmVar1->dx)) && - ((pmVar1->ymin < 1 && (iVar8 < pmVar1->dy)))) { - pTVar9 = pmVar1->entry + iVar8 * pmVar1->dx + iVar11; + if (this->Type == PLAYER) { + // try { // try from 080c0226 to 080c05fa has its CatchHandler @ 080c0612 + bVar2 = Object::exists(Obj); + if (bVar2) { + local_2c = (Object)Obj->ObjectID; + bVar2 = ObjectAccessible(this->ID,&local_2c,1); + if (bVar2) { + if (this->ID == PartnerID) { + puVar5 = (undefined4 *)__cxa_allocate_exception(4); + *puVar5 = 9; } else { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar11 + pmVar1->xmin,0); - pTVar9 = pmVar1->entry; - } - if (pTVar9->Waylength != 0x7fffffff) { - pmVar1 = this->Map; - iVar11 = -pmVar1->xmin; - iVar8 = -pmVar1->ymin; - if ((((pmVar1->xmin < 1) && (iVar11 < pmVar1->dx)) && (pmVar1->ymin < 1)) && - (iVar8 < pmVar1->dy)) { - local_4c = pmVar1->entry + iVar8 * pmVar1->dx + iVar11; + pTVar3 = GetPlayer(PartnerID); + if ((pTVar3 == (TPlayer *)0x0) || ((pTVar3->super_TCreature).Type != PLAYER)) { + puVar5 = (undefined4 *)__cxa_allocate_exception(4); + *puVar5 = 0x1b; } else { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar11 + pmVar1->xmin - ,0); - local_4c = pmVar1->entry; - } - if ((local_4c->Predecessor != (TShortwayPoint *)0x0) && - (pTVar9 = local_4c->Predecessor, 0 < MaxSteps)) { - while ((pTVar12 = pTVar9, MustReach || - ((2 < (local_4c->x - iVar6) + 1U || (2 < (local_4c->y - iVar7) + 1U)) - ))) { - iVar8 = pTVar12->x; - iVar11 = this->StartX; - iVar2 = this->StartY; - iVar3 = pTVar12->y; - iVar4 = this->StartZ; - this_00 = this->cr; - if ((this_00->LockToDo != false) && - ((bVar5 = TCreature::ToDoClear(this_00), bVar5 && - (this_00->Type == PLAYER)))) { - SendSnapback(this_00->Connection); - } - pTVar10 = vector::operator() - (&this_00->ToDoList,this_00->NrToDo); - pTVar10->Code = TDGo; - (pTVar10->field_1).Go.x = iVar8 + iVar11; - (pTVar10->field_1).Go.y = iVar3 + iVar2; - (pTVar10->field_1).Go.z = iVar4; - (pTVar10->field_1).Move.z = TD.field_1.Go.z; - (pTVar10->field_1).Move.Count = TD.field_1.Move.z; - this_00->NrToDo = this_00->NrToDo + 1; - MaxSteps = MaxSteps + -1; - if (pTVar12->Predecessor == (TShortwayPoint *)0x0) { - return true; + local_2c.ObjectID = ::NONE.ObjectID; + local_3c[0].ObjectID = ::NONE.ObjectID; + if (this[1].super_TSkillBase.TimerList[0xb] == (TSkill *)::NONE.ObjectID) { + local_3c[0] = (Object)Obj->ObjectID; + iVar4 = CountObjects(local_3c); + if (iVar4 < 0x65) { + local_3c[0].ObjectID = (pTVar3->super_TCreature).CrObject.ObjectID; + local_2c.ObjectID = (this->CrObject).ObjectID; + iVar4 = ObjectDistance(&local_2c,local_3c); + if (iVar4 < 3) { + bVar2 = ThrowPossible(this->posx,this->posy,this->posz, + (pTVar3->super_TCreature).posx, + (pTVar3->super_TCreature).posy, + (pTVar3->super_TCreature).posz,0); + if (bVar2) { + bVar2 = false; + local_3c[0].ObjectID = ::NONE.ObjectID; + local_2c.ObjectID = ::NONE.ObjectID; + if (((pTVar3->TradeObject).ObjectID != ::NONE.ObjectID) && + (pTVar3->TradePartner != this->ID)) { + bVar2 = true; + } + if (!bVar2) { + OVar1.ObjectID = (pTVar3->TradeObject).ObjectID; + if (OVar1.ObjectID != ::NONE.ObjectID) { + while (local_2c.ObjectID = OVar1.ObjectID, + Object::getObjectType(local_4c), + local_4c[0].ObjectID != 0) { + local_4c[0] = (Object)Obj->ObjectID; + if (local_2c.ObjectID == local_4c[0].ObjectID) + goto LAB_080c03c7; + Object::getContainer(&local_5c); + local_4c[0].ObjectID = local_5c.ObjectID; + local_2c.ObjectID = local_5c.ObjectID; + OVar1.ObjectID = local_2c.ObjectID; + } + local_5c = (Object)Obj->ObjectID; + while (Object::getObjectType(local_4c), + local_4c[0].ObjectID != 0) { + local_4c[0].ObjectID = local_5c.ObjectID; + if ((pTVar3->TradeObject).ObjectID == + local_5c.ObjectID) goto LAB_080c03c7; + Object::getContainer(&local_2c); + local_4c[0].ObjectID = local_2c.ObjectID; + local_5c.ObjectID = local_2c.ObjectID; + } + } + local_4c[0] = (Object)Obj->ObjectID; + this[1].super_TSkillBase.TimerList[0xb] = + (TSkill *)local_4c[0].ObjectID; + this[1].super_TSkillBase.TimerList[0xc] = + (TSkill *)PartnerID; + *(undefined1 *) + (this[1].super_TSkillBase.TimerList + 0xd) = 0; + local_5c.ObjectID = ::NONE.ObjectID; + bVar2 = (pTVar3->TradeObject).ObjectID != + ::NONE.ObjectID; + if (bVar2) { + SendTradeOffer((pTVar3->super_TCreature).Connection, + this->Name,false,local_4c); + local_4c[0].ObjectID = + (ulong)this[1].super_TSkillBase.TimerList[0xb]; + SendTradeOffer(this->Connection,this->Name,true, + local_4c); + local_4c[0].ObjectID = + (pTVar3->TradeObject).ObjectID; + Name = (pTVar3->super_TCreature).Name; + Connection = this->Connection; + } + else { + Name = this->Name; + SendMessage((pTVar3->super_TCreature).Connection, + 0x16,"%s wants to trade with you.",Name) + ; + local_4c[0].ObjectID = + (ulong)this[1].super_TSkillBase.TimerList[0xb]; + Connection = this->Connection; + } + SendTradeOffer(Connection,Name,!bVar2,local_4c); + return; + } + puVar5 = (undefined4 *)__cxa_allocate_exception(4); + *puVar5 = 0x36; + } + else { + puVar5 = (undefined4 *)__cxa_allocate_exception(4); + *puVar5 = 7; + } + } + else { + puVar5 = (undefined4 *)__cxa_allocate_exception(4); + *puVar5 = 5; + } } - pTVar9 = pTVar12->Predecessor; - local_4c = pTVar12; - if (MaxSteps < 1) { - return true; + else { + puVar5 = (undefined4 *)__cxa_allocate_exception(4); + *puVar5 = 0x37; } } + else { + puVar5 = (undefined4 *)__cxa_allocate_exception(4); + *puVar5 = 0x35; + } } - return true; } + goto LAB_080c03d9; } } - } - return false; -} - - - -// WARNING: Variable defined which should be unmapped: this_local -// DWARF original prototype: void Expand(TShortway * this, TShortwayPoint * Node) - -void __thiscall TShortway::Expand(TShortway *this,TShortwayPoint *Node) - -{ - matrix<> *pmVar1; - int iVar2; - TShortwayPoint *pTVar3; - uint uVar4; - TShortwayPoint *Search_1; - TShortwayPoint *pTVar5; - TShortwayPoint *Search; - int iVar6; - int iVar7; - TShortwayPoint *pTVar8; - uint uVar9; - int Waylength; - int iVar10; - int local_24; - int y; - int x; - int BasicWaylength; - TShortwayPoint *Node_local; - TShortway *this_local; - - if (Node == (TShortwayPoint *)0x0) { - error(&DAT_08106c80); - return; - } - this->FirstToExpand = Node->NextToExpand; - iVar6 = Node->Waypoints + Node->Waylength; - pmVar1 = this->Map; - iVar7 = -pmVar1->xmin; - iVar2 = -pmVar1->ymin; - if ((((pmVar1->xmin < 1) && (iVar7 < pmVar1->dx)) && (pmVar1->ymin < 1)) && (iVar2 < pmVar1->dy) - ) { - pTVar3 = pmVar1->entry + iVar2 * pmVar1->dx + iVar7; - } - else { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar7 + pmVar1->xmin,0); - pTVar3 = pmVar1->entry; - } - if (iVar6 < pTVar3->Waylength) { - y = -1; - do { - local_24 = -1; - do { - if ((y != 0) || (local_24 != 0)) { - pmVar1 = this->Map; - iVar2 = (local_24 + Node->y) - pmVar1->ymin; - iVar7 = (y + Node->x) - pmVar1->xmin; - if (((iVar7 < 0) || ((pmVar1->dx <= iVar7 || (iVar2 < 0)))) || - (pmVar1->dy <= iVar2)) { - error("matrix::operator(): Ungueltiger Index %d/%d.\n",iVar7 + pmVar1->xmin, - iVar2 + pmVar1->ymin); - pTVar3 = pmVar1->entry; - } - else { - pTVar3 = pmVar1->entry + iVar2 * pmVar1->dx + iVar7; - } - iVar2 = -y; - if (-1 < y) { - iVar2 = y; - } - iVar7 = -local_24; - if (-1 < local_24) { - iVar7 = local_24; - } - iVar10 = iVar6; - if (iVar2 + iVar7 != 1) { - iVar10 = iVar6 + Node->Waypoints * 2; - } - if (iVar10 < pTVar3->Waylength) { - pTVar3->Waylength = iVar10; - uVar9 = pTVar3->x; - pTVar3->Predecessor = Node; - if (((uVar9 != 0) || (pTVar3->y != 0)) && - (iVar2 = pTVar3->Waypoints, iVar2 != -1)) { - if (pTVar3->Heuristic != 0x7fffffff) { - pTVar5 = this->FirstToExpand; - if (pTVar5 == pTVar3) { - this->FirstToExpand = pTVar3->NextToExpand; - } - else { - for (pTVar8 = pTVar5->NextToExpand; - pTVar8 != (TShortwayPoint *)0x0; - pTVar8 = pTVar8->NextToExpand) { - if (pTVar8 == pTVar3) { - if (pTVar8 != (TShortwayPoint *)0x0) { - pTVar5->NextToExpand = pTVar3->NextToExpand; - goto LAB_080bedc6; - } - break; - } - pTVar5 = pTVar8; - } - error( - "TShortway::Expand: Knoten steht nicht in der ExpandList.\n" - ); - } - uVar9 = pTVar3->x; - iVar2 = pTVar3->Waypoints; - } -LAB_080bedc6: - uVar4 = pTVar3->y; - if (0x7fffffff < uVar9) { - uVar9 = -uVar9; - } - if (0x7fffffff < uVar4) { - uVar4 = -uVar4; - } - iVar2 = ((uVar4 - 1) + uVar9) * this->MinWaypoints + iVar2 + iVar10; - pTVar3->Heuristic = iVar2; - pTVar5 = this->FirstToExpand; - if ((pTVar5 == (TShortwayPoint *)0x0) || (iVar2 <= pTVar5->Heuristic)) { - pTVar3->NextToExpand = pTVar5; - this->FirstToExpand = pTVar3; - } - else { - pTVar8 = pTVar5->NextToExpand; - if ((pTVar8 != (TShortwayPoint *)0x0) && (pTVar8->Heuristic < iVar2) - ) { - do { - pTVar5 = pTVar8; - pTVar8 = pTVar5->NextToExpand; - if (pTVar8 == (TShortwayPoint *)0x0) break; - } while (pTVar8->Heuristic < pTVar3->Heuristic); - } - pTVar3->NextToExpand = pTVar8; - pTVar5->NextToExpand = pTVar3; - } - } - } - } - local_24 = local_24 + 1; - } while (local_24 < 2); - y = y + 1; - } while (y < 2); - } - return; -} - - - -// DWARF original prototype: bool SetOnMap(TCreature * this) - -bool __thiscall TCreature::SetOnMap(TCreature *this) - -{ - int *z; - int *y; - int *x; - bool bVar1; - bool bVar2; - ushort HouseID; - ushort HouseID_00; - bool NoRoom; - ObjectType local_5c [4]; - ObjectType local_4c [4]; - Object local_3c [4]; - ulong local_2c; - Object Obj; - - z = &this->posz; - y = &this->posy; - x = &this->posx; - bVar1 = SearchLoginField(x,y,z,1,this->Type == PLAYER); - bVar1 = !bVar1; - if (bVar1) { - bVar2 = IsHouse(this->posx,this->posy,this->posz); - if (bVar2) { - HouseID_00 = GetHouseID(this->posx,this->posy,this->posz); - GetExitPosition(HouseID_00,x,y,z); - bVar1 = SearchLoginField(x,y,z,1,this->Type == PLAYER); - bVar1 = !bVar1; - } - if (bVar1) { - this->posx = this->startx; - this->posy = this->starty; - this->posz = this->startz; - } - } - GetMapContainer((int)&local_2c,this->posx,this->posy); - bVar1 = local_2c != ::NONE.ObjectID; - local_3c[0].ObjectID = ::NONE.ObjectID; - if (bVar1) { - // try { // try from 080befa5 to 080befcc has its CatchHandler @ 080bf0a5 - ObjectType::setTypeID(local_4c,99); - local_5c[0].TypeID = local_2c; - Create(local_3c,local_5c,(ulong)local_4c); +LAB_080c03c7: + puVar5 = (undefined4 *)__cxa_allocate_exception(4); + *puVar5 = 1; } else { - error(&DAT_08106cc0,this->posx,this->posy,this->posz); - } - return bVar1; -} - - - -// DWARF original prototype: bool DelOnMap(TCreature * this) - -bool __thiscall TCreature::DelOnMap(TCreature *this) - -{ - RESULT r; - Object local_4c [4]; - ulong local_3c; - ulong local_2c; - Object Help; - - local_3c = ::NONE.ObjectID; - local_4c[0].ObjectID = (this->CrObject).ObjectID; - if (local_4c[0].ObjectID != ::NONE.ObjectID) { - (this->CrObject).ObjectID = ::NONE.ObjectID; - local_2c = local_4c[0].ObjectID; - // try { // try from 080bf180 to 080bf184 has its CatchHandler @ 080bf187 - Delete(local_4c,-1); + error(&DAT_08106e40); + puVar5 = (undefined4 *)__cxa_allocate_exception(4); + *puVar5 = 0xffffffff; } - return true; +LAB_080c03d9: + // WARNING: Subroutine does not return + __cxa_throw(puVar5,&RESULT::typeinfo,0); } -// DWARF original prototype: void Go(TCreature * this, int x, int y, int z) +// DWARF original prototype: void Use(TCreature * this, Object * Obj1, Object * Obj2, uchar Dummy) -void __thiscall TCreature::Go(TCreature *this,int x,int y,int z) +void __thiscall TCreature::Use(TCreature *this,Object *Obj1,Object *Obj2,uchar Dummy) { - TSkill *pTVar1; + int iVar1; bool bVar2; - uint uVar3; - int iVar4; - CreatureType CVar5; - undefined4 *puVar6; - int iVar7; - int iVar8; - int iVar9; - int *piVar10; - int iVar11; + undefined4 *puVar3; + ulong uVar4; + int *piVar5; int Delay; - int dy; - int local_54; - int local_50; + bool bVar6; + int iStack_70; + uchar Dummy_local; + int local_6c; + int local_68; + int x; + int y; + int z; Object local_4c [4]; - Object local_3c [4]; + ulong local_3c; Object local_2c [7]; - if (z == this->posz) { - uVar3 = x - this->posx; - if (0x7fffffff < uVar3) { - uVar3 = -uVar3; + // try { // try from 080c0652 to 080c098c has its CatchHandler @ 080c09a0 + bVar2 = Object::exists(Obj1); + if (bVar2) { + bVar2 = false; + local_2c[0].ObjectID = ::NONE.ObjectID; + local_3c = ::NONE.ObjectID; + if ((Obj2->ObjectID != ::NONE.ObjectID) && (bVar6 = Object::exists(Obj2), !bVar6)) { + bVar2 = true; } - if ((int)uVar3 < 2) { - uVar3 = y - this->posy; - if (0x7fffffff < uVar3) { - uVar3 = -uVar3; + if (!bVar2) { + bVar2 = false; + local_3c = ::NONE.ObjectID; + local_2c[0].ObjectID = ::NONE.ObjectID; + local_4c[0] = (Object)Obj2->ObjectID; + if (local_4c[0].ObjectID != ::NONE.ObjectID) { + Object::getObjectType(local_2c); + bVar6 = ObjectType::getFlag((ObjectType *)local_2c,DISTUSE); + if (!bVar6) { + local_2c[0] = (Object)Obj2->ObjectID; + bVar6 = ObjectInRange(this->ID,local_2c,1); + if (!bVar6) { + bVar2 = true; + } + } + local_4c[0] = (Object)Obj2->ObjectID; } - if ((int)uVar3 < 2) { - pTVar1 = (this->super_TSkillBase).Skills[0x14]; - if (((pTVar1 != (TSkill *)0x0) && - (iVar8 = (*pTVar1->_vptr_TSkill[0xd])(pTVar1), 0 < iVar8)) && - (iVar8 = TSkill::Get((this->super_TSkillBase).Skills[0x14]), iVar8 == 0)) { - iVar8 = rand(); - pTVar1 = (this->super_TSkillBase).Skills[0x14]; - iVar9 = (*pTVar1->_vptr_TSkill[0xd])(pTVar1); - if (iVar8 % (7 - iVar9) == 0) { - Delay = 0; - iVar9 = 0; - iVar8 = rand(); - iVar8 = iVar8 % 4; - if (iVar8 == 1) { - iVar9 = -1; - } - else if (iVar8 < 2) { - if (iVar8 == 0) { - iVar9 = 1; - } - } - else if (iVar8 == 2) { - Delay = 1; - iVar9 = 0; - } - else if (iVar8 == 3) { - Delay = -1; - iVar9 = 0; - } - x = iVar9 + this->posx; - y = Delay + this->posy; - bVar2 = ToDoClear(this); - if ((bVar2) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); - } - ToDoTalk(this); - if (this->NrToDo != 0) { - this->LockToDo = true; - this->ActToDo = 0; - local_50 = CalculateDelay(this); - local_54 = 1; - piVar10 = &local_54; - if (0 < local_50) { - piVar10 = &local_50; - } - iVar8 = *piVar10; - priority_queue<>::insert(&ToDoQueue); - this->NextWakeup = iVar8 + ServerMilliseconds; - } + if (bVar2) { + GetObjectCoordinates(local_4c,&local_68,&x,&y); + bVar2 = ToDoClear(this); + if ((bVar2) && (this->Type == PLAYER)) { + SendSnapback(this->Connection); + } + local_4c[0] = (Object)Obj1->ObjectID; + uVar4 = GetObjectCreatureID(local_4c); + if (uVar4 != this->ID) { + z = Obj1->ObjectID; + ToDoMove(this,(Object *)&z,0xffff,0,0,'\x01'); + } + ToDoGo(this,local_68,x,y,false,0x7fffffff); + z = Obj2->ObjectID; + local_4c[0] = (Object)Obj1->ObjectID; + ToDoUse(this,'\x02',local_4c,(Object *)&z); + if (this->NrToDo != 0) { + this->LockToDo = true; + this->ActToDo = 0; + local_6c = CalculateDelay(this); + iStack_70 = 1; + piVar5 = &stack0xffffff90; + if (0 < local_6c) { + piVar5 = &local_6c; } + iVar1 = *piVar5; + priority_queue<>::insert(&ToDoQueue); + this->NextWakeup = iVar1 + ServerMilliseconds; } - // try { // try from 080bf247 to 080bf65d has its CatchHandler @ 080bf6b8 - iVar9 = x; - iVar8 = y; - iVar11 = z; - iVar4 = (*this->_vptr_TCreature[3])(this,x,y,z,1,0); - if ((char)iVar4 != '\0') goto LAB_080bf2f7; - if (this->Type == PLAYER) { - CVar5 = PLAYER; - if (0 < z) { - iVar8 = this->posz; - iVar9 = this->posy; - iVar4 = GetHeight(); - if (0x17 < iVar4) { - if (this->posx == x) { - iVar4 = this->posy; - } - else { - iVar4 = this->posy; - if (iVar4 != y) goto LAB_080bf2a4; - } - iVar11 = 0; - iVar7 = z + -1; - iVar8 = iVar7; - bVar2 = CoordinateFlag(); - iVar9 = iVar4; - if (!bVar2) { - iVar11 = 0x20; - iVar9 = this->posy; - iVar8 = iVar7; - bVar2 = CoordinateFlag(); - if ((!bVar2) && - (iVar9 = x, iVar8 = y, iVar11 = iVar7, - iVar4 = (*this->_vptr_TCreature[3])(this,x,y,iVar7,1,1), - (char)iVar4 != '\0')) { - z = iVar7; - } - } - } -LAB_080bf2a4: - CVar5 = this->Type; - } - if ((CVar5 == PLAYER) && (z < 0xf)) { - iVar4 = z + 1; - iVar9 = y; - iVar8 = iVar4; - iVar7 = GetHeight(); - if ((0x17 < iVar7) && ((this->posx == x || (this->posy == y)))) { - iVar11 = 0; - iVar9 = y; - iVar8 = z; - bVar2 = CoordinateFlag(); - if (!bVar2) { - iVar11 = 0x20; - iVar9 = y; - iVar8 = z; - bVar2 = CoordinateFlag(); - if ((!bVar2) && - (iVar9 = x, iVar8 = y, iVar11 = iVar4, - iVar7 = (*this->_vptr_TCreature[3])(this,x,y,iVar4,1,1), - (char)iVar7 != '\0')) { - z = iVar4; - } - } - } - } - } - if ((z != this->posz) && - (iVar9 = x, iVar8 = y, iVar4 = (*this->_vptr_TCreature[3])(this,x,y,z,1,1), - iVar11 = z, (char)iVar4 != '\0')) { -LAB_080bf2f7: - local_2c[0].ObjectID = ::NONE.ObjectID; - GetMapContainer((int)local_3c,x,y); - local_4c[0].ObjectID = (this->CrObject).ObjectID; - ::Move(this->ID,local_4c,local_3c,-1,false,local_2c); - return; - } - puVar6 = (undefined4 *)__cxa_allocate_exception(4,iVar9,iVar8,iVar11); - *puVar6 = 0x34; - goto LAB_080bf372; - } - } - } - puVar6 = (undefined4 *)__cxa_allocate_exception(4); - *puVar6 = 1; -LAB_080bf372: - // WARNING: Subroutine does not return - __cxa_throw(puVar6,&RESULT::typeinfo,0); -} - - - -// DWARF original prototype: void Rotate(TCreature * this, uchar Dir) - -void __thiscall TCreature::Rotate(TCreature *this,uchar Dir) - -{ - Object local_1c [6]; - - local_1c[0].ObjectID = (this->CrObject).ObjectID; - this->Direction = (uint)Dir; - AnnounceChangedObject(local_1c,2); - return; -} - - - -// DWARF original prototype: void Rotate(TCreature * this, TCreature * Target) - -void __thiscall TCreature::Rotate(TCreature *this,TCreature *Target) - -{ - uint uVar1; - int dy; - uint uVar2; - int iVar3; - int dx; - int iVar4; - Object local_1c [4]; - - if (Target == (TCreature *)0x0) { - error("TCreature::Rotate: Target ist NULL.\n"); - } - else { - iVar4 = Target->posx - this->posx; - uVar2 = Target->posy - this->posy; - iVar3 = -iVar4; - if (-1 < iVar4) { - iVar3 = iVar4; - } - uVar1 = -uVar2; - if (-1 < (int)uVar2) { - uVar1 = uVar2; - } - if (iVar3 < (int)uVar1) { - uVar2 = ((int)~uVar2 >> 0x1f) * -2; - } - else { - uVar2 = (iVar4 >> 0x1f) * -2 + 1; - } - local_1c[0].ObjectID = (this->CrObject).ObjectID; - this->Direction = uVar2 & 0xff; - AnnounceChangedObject(local_1c,2); - } - return; -} - - - -// DWARF original prototype: void Move(TCreature * this, Object * Obj, int zx, int zy, int zz, uchar -// Count) - -void __thiscall TCreature::Move(TCreature *this,Object *Obj,int zx,int zy,int zz,uchar Count) - -{ - bool bVar1; - bool bVar2; - ulong uVar3; - undefined4 *puVar4; - int *piVar5; - int Delay; - uint Count_00; - Object *Obj_00; - Object *pOVar6; - int iVar7; - int local_a0; - int b_1; - int b; - int iStack_94; - uchar Count_local; - int local_90; - Object local_8c [4]; - Object local_7c [4]; - Object local_6c; - Object DestCon; - Object local_5c; - Object DestObj; - Object local_4c [4]; - Object local_3c [4]; - Object local_2c; - Object Dest; - - b._3_1_ = Count; - // try { // try from 080bf7d5 to 080bfb3a has its CatchHandler @ 080c01e0 - bVar1 = Object::exists(Obj); - if (bVar1) { - local_2c.ObjectID = (this->CrObject).ObjectID; - if (Obj->ObjectID == local_2c.ObjectID) { - Go(this,zx,zy,zz); - return; - } - Object::getObjectType(&local_2c); - if (local_2c.ObjectID == 99) { - TCombat::DelayAttack(&this->Combat,2000); - } - Object::getObjectType(&local_2c); - bVar1 = ObjectType::getFlag((ObjectType *)&local_2c,CUMULATIVE); - // try { // try from 080bfff5 to 080c0037 has its CatchHandler @ 080c01e0 - if ((bVar1) && (uVar3 = Object::getAttribute(Obj,AMOUNT), uVar3 < Count)) { - uVar3 = Object::getAttribute(Obj,AMOUNT); - b._3_1_ = (byte)uVar3; - } - if (zx == 0xffff) { - if (zy == 0) { - b_1 = 1; - iVar7 = b_1; - do { - b_1 = iVar7; - local_6c = (Object)Obj->ObjectID; - // try { // try from 080bfb73 to 080bfb94 has its CatchHandler @ 080c003d - GetBodyContainer((ulong)&local_5c,this->ID); - CheckInventoryDestination(&local_6c,&local_5c,false); - if ((1 < b_1 - 5U) && (b_1 != 10)) break; - iVar7 = b_1 + 1; - } while (b_1 + 1 < 0xb); - zy = b_1; - if (b_1 == 0) { - local_a0 = 1; - do { - pOVar6 = (Object *)this->ID; - iVar7 = local_a0; - // try { // try from 080bfbe3 to 080bfc4b has its CatchHandler @ 080c01e0 - GetBodyObject((ulong)&local_6c,(int)pOVar6); - local_5c.ObjectID = ::NONE.ObjectID; - if (local_6c.ObjectID != ::NONE.ObjectID) { - Object::getObjectType(&local_5c); - pOVar6 = (Object *)0x4; - bVar1 = ObjectType::getFlag((ObjectType *)&local_5c,CONTAINER); - if (bVar1) { - pOVar6 = &local_5c; - local_5c.ObjectID = local_6c.ObjectID; - local_4c[0] = (Object)Obj->ObjectID; - // try { // try from 080bffcb to 080bffcf has its CatchHandler @ 080c0067 - CheckContainerDestination(local_4c,pOVar6); - b_1 = local_a0; - } - } - local_a0 = local_a0 + 1; - } while (local_a0 < 0xb); - zy = b_1; - if (b_1 == 0) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4,pOVar6,iVar7); - *puVar4 = 4; - goto LAB_080bfb23; - } - } - } - if (((0 < zy) && (0x34 < zy - 0xbU)) && (zy < 0x50)) { - pOVar6 = &local_6c; - Obj_00 = (Object *)this->ID; - GetBodyContainer((ulong)pOVar6,(int)Obj_00); - local_5c.ObjectID = ::NONE.ObjectID; - if (zy < 0x40) { - Obj_00 = (Object *)this->ID; - GetBodyObject((ulong)local_3c,(int)Obj_00); - local_5c.ObjectID = local_3c[0].ObjectID; - } - else { - if (zz < 0xfe) { - ObjectType::setTypeID((ObjectType *)&local_2c,0); - Obj_00 = (Object *)this->ID; - GetObject((ulong)local_3c,(int)Obj_00,0xffff,zy,zz,(ObjectType *)zz); - local_5c.ObjectID = local_3c[0].ObjectID; - } - if (zz == 0xfe) { - local_4c[0].ObjectID = ::NONE.ObjectID; - if (local_6c.ObjectID == ::NONE.ObjectID) goto LAB_080bfeb5; - Object::getContainer(local_3c); - local_6c.ObjectID = local_3c[0].ObjectID; - Obj_00 = pOVar6; - } - } - bVar1 = false; - if (local_5c.ObjectID != ::NONE.ObjectID) { - local_4c[0].ObjectID = ::NONE.ObjectID; - local_3c[0].ObjectID = ::NONE.ObjectID; - Object::getObjectType(local_3c); - Obj_00 = (Object *)0x4; - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,CONTAINER); - } - if (bVar1) { - local_6c.ObjectID = local_5c.ObjectID; - local_5c.ObjectID = ::NONE.ObjectID; - local_2c.ObjectID = ::NONE.ObjectID; - } - bVar1 = false; - local_4c[0].ObjectID = ::NONE.ObjectID; - local_3c[0].ObjectID = ::NONE.ObjectID; - if (local_5c.ObjectID != ::NONE.ObjectID) { - Object::getObjectType(local_3c); - Obj_00 = (Object *)0x6; - bVar2 = ObjectType::getFlag((ObjectType *)local_3c,CUMULATIVE); - if (bVar2) { - Object::getObjectType(local_3c); - Obj_00 = &local_5c; - Object::getObjectType(&local_2c); - if (local_3c[0].ObjectID == local_2c.ObjectID) { - bVar1 = true; - } - } - } - if (bVar1) { - Count_00 = (uint)b._3_1_; - Obj_00 = (Object *)0x2; - // try { // try from 080bfd46 to 080bfd4a has its CatchHandler @ 080c01e0 - uVar3 = Object::getAttribute(&local_5c,AMOUNT); - if (100 < uVar3 + Count_00) { - Obj_00 = (Object *)0x2; - // try { // try from 080bfdd1 to 080bffa7 has its CatchHandler @ 080c01e0 - uVar3 = Object::getAttribute(&local_5c,AMOUNT); - Count_00 = 100 - uVar3; - } - if (0 < (int)Count_00) { - Obj_00 = local_8c; - local_2c.ObjectID = ::NONE.ObjectID; - local_7c[0].ObjectID = local_5c.ObjectID; - local_8c[0] = (Object)Obj->ObjectID; - // try { // try from 080bfd98 to 080bfd9c has its CatchHandler @ 080c0082 - Merge(this->ID,Obj_00,local_7c,Count_00,&local_2c); - b._3_1_ = b._3_1_ - (char)Count_00; - if (b._3_1_ == 0) { - return; - } - } - local_7c[0] = (Object)::NONE.ObjectID; - local_5c.ObjectID = local_7c[0].ObjectID; - } - local_8c[0].ObjectID = ::NONE.ObjectID; - if (local_6c.ObjectID != ::NONE.ObjectID) { - local_7c[0].ObjectID = local_6c.ObjectID; - local_8c[0].ObjectID = local_5c.ObjectID; - local_4c[0] = (Object)Obj->ObjectID; - // try { // try from 080bfd13 to 080bfd17 has its CatchHandler @ 080c00b2 - ::Move(this->ID,local_4c,local_7c,(uint)b._3_1_,false,local_8c); - return; - } - puVar4 = (undefined4 *)__cxa_allocate_exception(4,Obj_00); - *puVar4 = 5; - goto LAB_080bfb23; - } - error(&DAT_08106e00,zy); - } - else { - GetMapContainer((int)&local_2c,zx,zy); - bVar1 = Object::exists(&local_2c); - if (bVar1) { - Object::getObjectType(local_3c); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,HANG); - if (bVar1) { - bVar1 = false; - bVar2 = CoordinateFlag(); - if ((bVar2) || (bVar2 = CoordinateFlag(), bVar2)) { - bVar1 = true; - } - if (bVar1) { - local_3c[0].ObjectID = local_2c.ObjectID; - bVar1 = ObjectInRange(this->ID,local_3c,1); - if (!bVar1) { - bVar1 = ToDoClear(this); - if ((bVar1) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); - } - local_4c[0] = (Object)Obj->ObjectID; - uVar3 = GetObjectCreatureID(local_4c); - if (uVar3 != this->ID) { - local_5c = (Object)Obj->ObjectID; - ToDoMove(this,&local_5c,0xffff,0,0,'\x01'); - } - ToDoGo(this,zx,zy,zz,false,0x7fffffff); - local_5c = (Object)Obj->ObjectID; - ToDoMove(this,&local_5c,zx,zy,zz,'\x01'); - if (this->NrToDo == 0) { - return; - } - this->LockToDo = true; - this->ActToDo = 0; - local_90 = CalculateDelay(this); - iStack_94 = 1; - piVar5 = &stack0xffffff6c; - if (0 < local_90) { - piVar5 = &local_90; - } - iVar7 = *piVar5; - priority_queue<>::insert(&ToDoQueue); - this->NextWakeup = iVar7 + ServerMilliseconds; - return; - } - } - } - local_5c.ObjectID = ::NONE.ObjectID; - local_4c[0].ObjectID = local_2c.ObjectID; - local_6c = (Object)Obj->ObjectID; - ::Move(this->ID,&local_6c,local_4c,(uint)b._3_1_,false,&local_5c); - return; - } - } - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = 0xffffffff; - } - else { -LAB_080bfeb5: - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = 1; - } -LAB_080bfb23: - // WARNING: Subroutine does not return - __cxa_throw(puVar4,&RESULT::typeinfo,0); -} - - - -// DWARF original prototype: void Trade(TCreature * this, Object * Obj, ulong PartnerID) - -void __thiscall TCreature::Trade(TCreature *this,Object *Obj,ulong PartnerID) - -{ - Object OVar1; - bool bVar2; - TPlayer *pTVar3; - int iVar4; - undefined4 *puVar5; - TPlayer *Partner; - TConnection *Connection; - char *Name; - Object local_5c; - Object Help_1; - Object local_4c [4]; - Object local_3c [4]; - Object local_2c; - Object Help; - - if (this->Type == PLAYER) { - // try { // try from 080c0226 to 080c05fa has its CatchHandler @ 080c0612 - bVar2 = Object::exists(Obj); - if (bVar2) { - local_2c = (Object)Obj->ObjectID; - bVar2 = ObjectAccessible(this->ID,&local_2c,1); - if (bVar2) { - if (this->ID == PartnerID) { - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 9; - } - else { - pTVar3 = GetPlayer(PartnerID); - if ((pTVar3 == (TPlayer *)0x0) || ((pTVar3->super_TCreature).Type != PLAYER)) { - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 0x1b; - } - else { - local_2c.ObjectID = ::NONE.ObjectID; - local_3c[0].ObjectID = ::NONE.ObjectID; - if (this[1].super_TSkillBase.TimerList[0xb] == (TSkill *)::NONE.ObjectID) { - local_3c[0] = (Object)Obj->ObjectID; - iVar4 = CountObjects(local_3c); - if (iVar4 < 0x65) { - local_3c[0].ObjectID = (pTVar3->super_TCreature).CrObject.ObjectID; - local_2c.ObjectID = (this->CrObject).ObjectID; - iVar4 = ObjectDistance(&local_2c,local_3c); - if (iVar4 < 3) { - bVar2 = ThrowPossible(this->posx,this->posy,this->posz, - (pTVar3->super_TCreature).posx, - (pTVar3->super_TCreature).posy, - (pTVar3->super_TCreature).posz,0); - if (bVar2) { - bVar2 = false; - local_3c[0].ObjectID = ::NONE.ObjectID; - local_2c.ObjectID = ::NONE.ObjectID; - if (((pTVar3->TradeObject).ObjectID != ::NONE.ObjectID) && - (pTVar3->TradePartner != this->ID)) { - bVar2 = true; - } - if (!bVar2) { - OVar1.ObjectID = (pTVar3->TradeObject).ObjectID; - if (OVar1.ObjectID != ::NONE.ObjectID) { - while (local_2c.ObjectID = OVar1.ObjectID, - Object::getObjectType(local_4c), - local_4c[0].ObjectID != 0) { - local_4c[0] = (Object)Obj->ObjectID; - if (local_2c.ObjectID == local_4c[0].ObjectID) - goto LAB_080c03c7; - Object::getContainer(&local_5c); - local_4c[0].ObjectID = local_5c.ObjectID; - local_2c.ObjectID = local_5c.ObjectID; - OVar1.ObjectID = local_2c.ObjectID; - } - local_5c = (Object)Obj->ObjectID; - while (Object::getObjectType(local_4c), - local_4c[0].ObjectID != 0) { - local_4c[0].ObjectID = local_5c.ObjectID; - if ((pTVar3->TradeObject).ObjectID == - local_5c.ObjectID) goto LAB_080c03c7; - Object::getContainer(&local_2c); - local_4c[0].ObjectID = local_2c.ObjectID; - local_5c.ObjectID = local_2c.ObjectID; - } - } - local_4c[0] = (Object)Obj->ObjectID; - this[1].super_TSkillBase.TimerList[0xb] = - (TSkill *)local_4c[0].ObjectID; - this[1].super_TSkillBase.TimerList[0xc] = - (TSkill *)PartnerID; - *(undefined1 *) - (this[1].super_TSkillBase.TimerList + 0xd) = 0; - local_5c.ObjectID = ::NONE.ObjectID; - bVar2 = (pTVar3->TradeObject).ObjectID != - ::NONE.ObjectID; - if (bVar2) { - SendTradeOffer((pTVar3->super_TCreature).Connection, - this->Name,false,local_4c); - local_4c[0].ObjectID = - (ulong)this[1].super_TSkillBase.TimerList[0xb]; - SendTradeOffer(this->Connection,this->Name,true, - local_4c); - local_4c[0].ObjectID = - (pTVar3->TradeObject).ObjectID; - Name = (pTVar3->super_TCreature).Name; - Connection = this->Connection; - } - else { - Name = this->Name; - SendMessage((pTVar3->super_TCreature).Connection, - 0x16,"%s wants to trade with you.",Name) - ; - local_4c[0].ObjectID = - (ulong)this[1].super_TSkillBase.TimerList[0xb]; - Connection = this->Connection; - } - SendTradeOffer(Connection,Name,!bVar2,local_4c); - return; - } - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 0x36; - } - else { - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 7; - } - } - else { - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 5; - } - } - else { - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 0x37; - } - } - else { - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 0x35; - } - } - } - goto LAB_080c03d9; - } - } -LAB_080c03c7: - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 1; - } - else { - error(&DAT_08106e40); - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 0xffffffff; - } -LAB_080c03d9: - // WARNING: Subroutine does not return - __cxa_throw(puVar5,&RESULT::typeinfo,0); -} - - - -// DWARF original prototype: void Use(TCreature * this, Object * Obj1, Object * Obj2, uchar Dummy) - -void __thiscall TCreature::Use(TCreature *this,Object *Obj1,Object *Obj2,uchar Dummy) - -{ - int iVar1; - bool bVar2; - undefined4 *puVar3; - ulong uVar4; - int *piVar5; - int Delay; - bool bVar6; - int iStack_70; - uchar Dummy_local; - int local_6c; - int local_68; - int x; - int y; - int z; - Object local_4c [4]; - ulong local_3c; - Object local_2c [7]; - - // try { // try from 080c0652 to 080c098c has its CatchHandler @ 080c09a0 - bVar2 = Object::exists(Obj1); - if (bVar2) { - bVar2 = false; - local_2c[0].ObjectID = ::NONE.ObjectID; - local_3c = ::NONE.ObjectID; - if ((Obj2->ObjectID != ::NONE.ObjectID) && (bVar6 = Object::exists(Obj2), !bVar6)) { - bVar2 = true; - } - if (!bVar2) { - bVar2 = false; - local_3c = ::NONE.ObjectID; - local_2c[0].ObjectID = ::NONE.ObjectID; - local_4c[0] = (Object)Obj2->ObjectID; - if (local_4c[0].ObjectID != ::NONE.ObjectID) { - Object::getObjectType(local_2c); - bVar6 = ObjectType::getFlag((ObjectType *)local_2c,DISTUSE); - if (!bVar6) { - local_2c[0] = (Object)Obj2->ObjectID; - bVar6 = ObjectInRange(this->ID,local_2c,1); - if (!bVar6) { - bVar2 = true; - } - } - local_4c[0] = (Object)Obj2->ObjectID; - } - if (bVar2) { - GetObjectCoordinates(local_4c,&local_68,&x,&y); - bVar2 = ToDoClear(this); - if ((bVar2) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); - } - local_4c[0] = (Object)Obj1->ObjectID; - uVar4 = GetObjectCreatureID(local_4c); - if (uVar4 != this->ID) { - z = Obj1->ObjectID; - ToDoMove(this,(Object *)&z,0xffff,0,0,'\x01'); - } - ToDoGo(this,local_68,x,y,false,0x7fffffff); - z = Obj2->ObjectID; - local_4c[0] = (Object)Obj1->ObjectID; - ToDoUse(this,'\x02',local_4c,(Object *)&z); - if (this->NrToDo != 0) { - this->LockToDo = true; - this->ActToDo = 0; - local_6c = CalculateDelay(this); - iStack_70 = 1; - piVar5 = &stack0xffffff90; - if (0 < local_6c) { - piVar5 = &local_6c; - } - iVar1 = *piVar5; - priority_queue<>::insert(&ToDoQueue); - this->NextWakeup = iVar1 + ServerMilliseconds; - } - return; - } - bVar2 = false; - z = ::NONE.ObjectID; - bVar6 = local_4c[0].ObjectID != ::NONE.ObjectID; - local_4c[0].ObjectID = ::NONE.ObjectID; - if (bVar6) { - Object::getObjectType(local_4c); - bVar6 = ObjectType::getFlag((ObjectType *)local_4c,DISTUSE); - if (bVar6) { - local_4c[0] = (Object)Obj2->ObjectID; - bVar6 = ObjectInRange(this->ID,local_4c,7); - if (!bVar6) { - bVar2 = true; - } - } - } - if (!bVar2) { - z = Obj2->ObjectID; - if (z != ::NONE.ObjectID) { - this->EarliestMultiuseTime = ServerMilliseconds + 1000; - z = Obj2->ObjectID; - } - local_4c[0] = (Object)Obj1->ObjectID; - ::Use(this->ID,local_4c,(Object *)&z,Dummy); - return; - } - puVar3 = (undefined4 *)__cxa_allocate_exception(4); - *puVar3 = 5; - goto LAB_080c0733; - } - } - puVar3 = (undefined4 *)__cxa_allocate_exception(4); - *puVar3 = 0x1f; -LAB_080c0733: - // WARNING: Subroutine does not return - __cxa_throw(puVar3,&RESULT::typeinfo,0); -} - - - -// DWARF original prototype: void Turn(TCreature * this, Object * Obj) - -void __thiscall TCreature::Turn(TCreature *this,Object *Obj) - -{ - bool bVar1; - undefined4 *puVar2; - Object local_1c [5]; - - // try { // try from 080c09cf to 080c0a25 has its CatchHandler @ 080c0a26 - bVar1 = Object::exists(Obj); - if (bVar1) { - local_1c[0] = (Object)Obj->ObjectID; - ::Turn(this->ID,local_1c); - return; - } - puVar2 = (undefined4 *)__cxa_allocate_exception(4); - *puVar2 = 0x1f; - // WARNING: Subroutine does not return - __cxa_throw(puVar2,&RESULT::typeinfo,0); -} - -// DWARF original prototype: void NotifyGo(TCreature * this) - -void __thiscall TCreature::NotifyGo(TCreature *this) - -{ - int iVar1; - int iVar2; - TConnection *Connection; - bool bVar3; - bool bVar4; - bool bVar5; - int Waypoints; - int iVar6; - CreatureType CVar7; - ulong uVar8; - int iVar9; - TPlayer *pTVar10; - int dx; - uint uVar11; - TCreature *Window; - int dy; - uint uVar12; - TCreature *Obj_00; - TCreature *Con_00; - TPlayer *Partner; - bool DiagonalMove; - int dz; - int local_68; - int x; - int y; - int z; - Object Obj; - Object local_4c [4]; - Object local_3c [4]; - Object local_2c; - Object Con; - - local_2c.ObjectID = (this->CrObject).ObjectID; - GetObjectCoordinates(&local_2c,&local_68,&x,&y); - iVar9 = this->posx; - uVar11 = local_68 - iVar9; - iVar1 = this->posy; - uVar12 = x - iVar1; - iVar2 = this->posz; - bVar3 = false; - iVar6 = y - iVar2; - if (((iVar6 == 0) && (uVar11 != 0)) && (uVar12 != 0)) { - bVar3 = true; - } - MoveChainCreature(this,local_68,x); - CVar7 = this->Type; - if ((CVar7 == PLAYER) && (Connection = this->Connection, Connection != (TConnection *)0x0)) { - if (((iVar6 + 1U < 3) && (uVar11 + 1 < 3)) && (uVar12 + 1 < 3)) { - if (iVar6 == 1) { - this->posz = this->posz + 1; - this->posx = this->posx + -1; - this->posy = this->posy + -1; - SendFloors(Connection,false); - uVar11 = uVar11 + 1; - uVar12 = uVar12 + 1; - } - if (iVar6 == -1) { - this->posz = this->posz + -1; - uVar11 = uVar11 - 1; - this->posx = this->posx + 1; - uVar12 = uVar12 - 1; - this->posy = this->posy + 1; - SendFloors(this->Connection,true); - } - for (; 0 < (int)uVar11; uVar11 = uVar11 - 1) { - this->posx = this->posx + 1; - SendRow(this->Connection,1); - } - for (; (int)uVar11 < 0; uVar11 = uVar11 + 1) { - this->posx = this->posx + -1; - SendRow(this->Connection,3); - } - for (; 0 < (int)uVar12; uVar12 = uVar12 - 1) { - this->posy = this->posy + 1; - SendRow(this->Connection,2); - } - for (; (int)uVar12 < 0; uVar12 = uVar12 + 1) { - this->posy = this->posy + -1; - SendRow(this->Connection,0); - } - } - else { - this->posx = this->posx + uVar11; - this->posy = this->posy + uVar12; - this->posz = this->posz + iVar6; - SendFullScreen(Connection); - } - CVar7 = this->Type; - } - else { - this->posx = this->posx + uVar11; - this->posy = this->posy + uVar12; - this->posz = this->posz + iVar6; - } - if (CVar7 != PLAYER) goto LAB_080c0c2d; - Window = (TCreature *)0x0; - do { - Obj_00 = this; - Con_00 = Window; - TPlayer::GetOpenContainer((TPlayer *)&local_2c,(int)this); - local_3c[0].ObjectID = ::NONE.ObjectID; - if (local_2c.ObjectID != ::NONE.ObjectID) { - bVar4 = Object::exists(&local_2c); - if (bVar4) { - Con_00 = (TCreature *)0x1; - Obj_00 = (TCreature *)local_3c; - local_3c[0].ObjectID = local_2c.ObjectID; - bVar4 = ObjectAccessible(this->ID,(Object *)Obj_00,1); - if (bVar4) goto LAB_080c0c07; - local_4c[0] = (Object)::NONE.ObjectID; - Con_00 = (TCreature *)local_4c; - } - else { - error("TCreature::NotifyGo: OpenContainer existiert nicht. (%s, [%d,%d,%d]->[%d,%d,%d])\n" - ,this->Name,iVar9,iVar1,iVar2,this->posx,this->posy,this->posz); - local_3c[0].ObjectID = ::NONE.ObjectID; - Con_00 = (TCreature *)local_3c; - } - TPlayer::SetOpenContainer((TPlayer *)this,(int)Window,(Object *)Con_00); - Obj_00 = Window; - SendCloseContainer(this->Connection,(int)Window); - } -LAB_080c0c07: - Window = (TCreature *)((int)&Window->_vptr_TCreature + 1); - } while ((int)Window < 0x10); - local_4c[0].ObjectID = ::NONE.ObjectID; - local_3c[0].ObjectID = ::NONE.ObjectID; - if (this[1].super_TSkillBase.TimerList[0xb] == (TSkill *)::NONE.ObjectID) goto LAB_080c0c2d; - pTVar10 = GetPlayer((ulong)this[1].super_TSkillBase.TimerList[0xc]); - bVar4 = Object::exists((Object *)(this[1].super_TSkillBase.TimerList + 0xb)); - if (!bVar4) { - error("TCreature::NotifyGo: Handelsobjekt existiert nicht mehr.\n",Obj_00,Con_00); - error(&DAT_081072f3,this->Name,this->posx,this->posy,this->posz); - if (pTVar10 != (TPlayer *)0x0) { - error("# Partner %s an [%d,%d,%d]\n",(pTVar10->super_TCreature).Name, - (pTVar10->super_TCreature).posx,(pTVar10->super_TCreature).posy, - (pTVar10->super_TCreature).posz); - } - } - bVar4 = false; - if (pTVar10 == (TPlayer *)0x0) { -LAB_080c0dba: - bVar4 = true; - } - else { - local_3c[0].ObjectID = (ulong)this[1].super_TSkillBase.TimerList[0xb]; - bVar5 = ObjectAccessible(this->ID,local_3c,1); - if (!bVar5) goto LAB_080c0dba; - local_2c.ObjectID = (pTVar10->super_TCreature).CrObject.ObjectID; - z = (this->CrObject).ObjectID; - iVar9 = ObjectDistance((Object *)&z,&local_2c); - if ((2 < iVar9) || - (bVar5 = ThrowPossible(this->posx,this->posy,this->posz,(pTVar10->super_TCreature).posx, - (pTVar10->super_TCreature).posy,(pTVar10->super_TCreature).posz,0) - , !bVar5)) goto LAB_080c0dba; - } - if (bVar4) { - SendCloseTrade(this->Connection); - SendMessage(this->Connection,0x17,"Trade cancelled."); - TPlayer::RejectTrade((TPlayer *)this); - } -LAB_080c0c2d: - GetFirstObject(); - while( true ) { - Object::getObjectType(local_4c); - bVar4 = ObjectType::getFlag((ObjectType *)local_4c,BANK); - if (bVar4) break; - local_4c[0].ObjectID = ::NONE.ObjectID; - local_3c[0].ObjectID = ::NONE.ObjectID; - if (z == ::NONE.ObjectID) break; - Object::getNextObject(local_3c); - z = local_3c[0].ObjectID; - local_4c[0].ObjectID = z; - } - local_4c[0] = (Object)::NONE.ObjectID; - if (z == ::NONE.ObjectID) { - error("TCreature::NotifyGo: Auf Feld [%d,%d,%d] befindet sich kein Bank.\n",this->posx, - this->posy,this->posz); - } - else { - Object::getObjectType(local_4c); - uVar8 = ObjectType::getAttribute((ObjectType *)local_4c,WAYPOINTS); - if (bVar3) { - uVar8 = uVar8 * 3; - } - iVar9 = GetSpeed(this); - this->EarliestWalkTime = - ((Beat + -1 + (int)(uVar8 * 1000) / iVar9) / Beat) * Beat + ServerMilliseconds; - } - return; -} - - - -// DWARF original prototype: void NotifyTurn(TCreature * this, Object * DestCon) - -void __thiscall TCreature::NotifyTurn(TCreature *this,Object *DestCon) - -{ - int dy; - int iVar1; - int local_28; - int x; - int y; - int z; - - z = DestCon->ObjectID; - GetObjectCoordinates((Object *)&z,&local_28,&x,&y); - local_28 = local_28 - this->posx; - iVar1 = x - this->posy; - if (local_28 < 1) { - if (local_28 < 0) { - this->Direction = 3; - } - else if (iVar1 < 0) { - this->Direction = 0; - } - else if (x != this->posy && -1 < iVar1) { - this->Direction = 2; - } - } - else { - this->Direction = 1; - } - return; -} - - - -// DWARF original prototype: void NotifyDelete(TCreature * this) - -void __thiscall TCreature::NotifyDelete(TCreature *this) - -{ - CreatureType CVar1; - - if (this->Type == PLAYER) { - CVar1 = PLAYER; - if (this->Connection != (TConnection *)0x0) { - TConnection::Logout(this->Connection,0x1e,true); - CVar1 = this->Type; - this->LoggingOut = true; - } - if (CVar1 == PLAYER) { - TPlayer::RejectTrade((TPlayer *)this); - } - } - DeleteChainCreature(this); - return; -} - - - -// DWARF original prototype: void NotifyCreate(TCreature * this) - -void __thiscall TCreature::NotifyCreate(TCreature *this) - -{ - InsertChainCreature(this,0,0); - return; -} - - - -// DWARF original prototype: void NotifyChangeInventory(TCreature * this) - -void __thiscall TCreature::NotifyChangeInventory(TCreature *this) - -{ - TSkill *pTVar1; - anon_union_4_2_730cd3ca_for_TOutfit_2 aVar2; - bool bVar3; - bool bVar4; - int i; - int iVar5; - int iVar6; - ulong uVar7; - ulong uVar8; - bool SkillsChanged; - int i_1; - int b; - ulong uVar9; - int SkillNr; - ulong local_ac; - int iStack_9c; - int NewDelta [25]; - ulong local_2c; - Object Obj; - - local_2c = ::NONE.ObjectID; - if ((this->CrObject).ObjectID != ::NONE.ObjectID) { - bVar3 = Object::exists(&this->CrObject); - if (bVar3) { - TCombat::CheckCombatValues(&this->Combat); - if (this->Type == PLAYER) { - iVar5 = 0; - do { - NewDelta[iVar5 + -1] = 0; - iVar5 = iVar5 + 1; - } while (iVar5 < 0x19); - uVar9 = 1; - do { - bVar3 = false; - GetBodyObject((ulong)&local_2c,this->ID); - local_ac = ::NONE.ObjectID; - if (local_2c == ::NONE.ObjectID) { -LAB_080c12f2: - bVar3 = true; - } - else { - Object::getObjectType((Object *)&SkillNr); - bVar4 = ObjectType::getFlag((ObjectType *)&SkillNr,SKILLBOOST); - if (!bVar4) goto LAB_080c12f2; - } - if (!bVar3) { - Object::getObjectType((Object *)&SkillNr); - bVar3 = ObjectType::getFlag((ObjectType *)&SkillNr,CLOTHES); - if (bVar3) { - Object::getObjectType((Object *)&SkillNr); - uVar7 = ObjectType::getAttribute((ObjectType *)&SkillNr,BODYPOSITION); - if (uVar7 == uVar9) { - Object::getObjectType((Object *)&SkillNr); - uVar7 = ObjectType::getAttribute((ObjectType *)&SkillNr,SKILLNUMBER) - ; - if ((int)uVar7 < 0x19) { - Object::getObjectType((Object *)&SkillNr); - uVar8 = ObjectType::getAttribute - ((ObjectType *)&SkillNr,SKILLMODIFICATION); - if (0x7fff < (int)uVar8) { - uVar8 = uVar8 - 0x10000; - } - NewDelta[uVar7 - 1] = NewDelta[uVar7 - 1] + uVar8; - } - else { - Object::getObjectType((Object *)&SkillNr); - error(&DAT_08107080,SkillNr,uVar7); - } - } - } - else { - Object::getObjectType((Object *)&SkillNr); - error("TCreature::NotifyChangeInventory: Objekt %d hat SKILLBOOST, aber nicht CLOTHES.\n" - ,SkillNr); - } - } - uVar9 = uVar9 + 1; - } while ((int)uVar9 < 0xb); - bVar3 = false; - iVar5 = 0; - do { - pTVar1 = (this->super_TSkillBase).Skills[iVar5]; - if (pTVar1->DAct != NewDelta[iVar5 + -1]) { - pTVar1->DAct = NewDelta[iVar5 + -1]; - if (iVar5 == 4) { - AnnounceChangedCreature(this->ID,4); - } - if (iVar5 == 0x10) { - if (NewDelta[0xf] < 1) { - pTVar1 = (this->super_TSkillBase).Skills[0x10]; - iVar6 = (*pTVar1->_vptr_TSkill[0xd])(pTVar1); - if (iVar6 == 0) { - aVar2 = (this->OrgOutfit).field_1; - (this->Outfit).OutfitID = (this->OrgOutfit).OutfitID; - (this->Outfit).field_1 = aVar2; - } - } - else { - bVar3 = false; - if (((this->Outfit).OutfitID == 0) && - ((this->Outfit).field_1.ObjectType == 0)) { - bVar3 = true; - } - if ((!bVar3) && - (pTVar1 = (this->super_TSkillBase).Skills[0x10], - iVar6 = (*pTVar1->_vptr_TSkill[0xd])(pTVar1), iVar6 != 0)) { - TSkillBase::SetTimer(&this->super_TSkillBase); - } - (this->Outfit).OutfitID = 0; - (this->Outfit).field_1.ObjectType = 0; - } - AnnounceChangedCreature(this->ID,3); - } - bVar3 = true; - } - iVar5 = iVar5 + 1; - } while (iVar5 < 0x19); - if (bVar3) { - SendPlayerSkills(this->Connection); - TPlayer::CheckState((TPlayer *)this); - } - SendPlayerData(this->Connection); - } - } - else { - error("TCreature::NotifyChangeInventory: Kreatur-Objekt existiert nicht.\n"); - error("# Kreatur: %s, Position: %d/%d/%d.\n",this->Name,this->posx,this->posy,this->posz - ); - } - } - return; -} - - - -// WARNING: Type propagation algorithm not settling -// DWARF original prototype: void CreatureMoveStimulus(TCreature * this, ulong CreatureID, int Type) - -void __thiscall TCreature::CreatureMoveStimulus(TCreature *this,ulong CreatureID,int Type) - -{ - vector *this_00; - uint uVar1; - bool bVar2; - TToDoEntry *pTVar3; - TCreature *pTVar4; - int iVar5; - int *piVar6; - int Delay_1; - int Delay; - int local_64; - int local_60; - undefined1 local_5c [4]; - TToDoEntry TD; - Object local_3c [4]; - Object local_2c [7]; - - if (((((CreatureID != this->ID) && (CreatureID != 0)) && - (CreatureID == (this->Combat).AttackDest)) && ((Type == 2 && (this->LockToDo != false)))) - && ((this->IsDead == false && (this->ActToDo < this->NrToDo)))) { - this_00 = &this->ToDoList; - pTVar3 = vector::operator()(this_00,this->ActToDo); - if ((pTVar3->Code == TDAttack) && ((this->Combat).ChaseMode == '\x01')) { - uVar1 = (this->Combat).EarliestAttackTime; - if ((ServerMilliseconds < uVar1) && (200 < (int)(uVar1 - ServerMilliseconds))) { - pTVar4 = GetCreature((this->Combat).AttackDest); - if (pTVar4 != (TCreature *)0x0) { - local_2c[0].ObjectID = (pTVar4->CrObject).ObjectID; - local_3c[0].ObjectID = (this->CrObject).ObjectID; - iVar5 = ObjectDistance(local_3c,local_2c); - if (1 < iVar5) { - bVar2 = ToDoClear(this); - if ((bVar2) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); - } - local_5c = (undefined1 [4])0x0; - TD.Code = ServerMilliseconds + 200; - if (this->LockToDo != false) { - // try { // try from 080c16d0 to 080c16fb has its CatchHandler @ 080c19b4 - bVar2 = ToDoClear(this); - if ((bVar2) && (this->Type == PLAYER)) { - // try { // try from 080c184b to 080c184f has its CatchHandler @ 080c19b4 - SendSnapback(this->Connection); - } - } - pTVar3 = vector::operator()(this_00,this->NrToDo); - pTVar3->Code = (ToDoType)local_5c; - (pTVar3->field_1).Move.Obj = TD.Code; - ((anon_struct_4_1_898373eb_for_Wait *)((int)&pTVar3->field_1 + 4))->Time = - (ulong)TD.field_1.Wait.Time; - (pTVar3->field_1).Go.z = TD.field_1.Go.y; - (pTVar3->field_1).Move.z = TD.field_1.Go.z; - (pTVar3->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; - // try { // try from 080c1728 to 080c17c0 has its CatchHandler @ 080c1868 - TCombat::CanToDoAttack(&this->Combat); - iVar5 = TCombat::GetDistance(&this->Combat); - if (iVar5 != 1) { - local_5c = (undefined1 [4])0x0; - TD.Code = ServerMilliseconds + 100; - if (this->LockToDo != false) { - bVar2 = ToDoClear(this); - if ((bVar2) && (this->Type == PLAYER)) { - // try { // try from 080c1838 to 080c183c has its CatchHandler @ 080c1868 - SendSnapback(this->Connection); - } - } - pTVar3 = vector::operator()(this_00,this->NrToDo); - pTVar3->Code = (ToDoType)local_5c; - (pTVar3->field_1).Move.Obj = TD.Code; - ((anon_struct_4_1_898373eb_for_Wait *)((int)&pTVar3->field_1 + 4))->Time - = (ulong)TD.field_1.Wait.Time; - (pTVar3->field_1).Go.z = TD.field_1.Go.y; - (pTVar3->field_1).Move.z = TD.field_1.Go.z; - (pTVar3->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; - } - local_5c = (undefined1 [4])0x7; - ToDoAdd(this,(TToDoEntry *)local_5c); - if (this->NrToDo != 0) { - this->LockToDo = true; - this->ActToDo = 0; - // try { // try from 080c17e1 to 080c181c has its CatchHandler @ 080c19b4 - local_60 = CalculateDelay(this); - local_64 = 1; - piVar6 = &local_64; - if (0 < local_60) { - piVar6 = &local_60; - } - iVar5 = *piVar6; - priority_queue<>::insert(&ToDoQueue); - this->NextWakeup = iVar5 + ServerMilliseconds; - } - } - } - } - } - } - return; -} - - - -// DWARF original prototype: int CalculateDelay(TCreature * this) - -int __thiscall TCreature::CalculateDelay(TCreature *this) - -{ - ToDoType TVar1; - uint uVar2; - TToDoEntry *pTVar3; - ToDoType TVar4; - int *piVar5; - uint uVar6; - int local_34; - int local_30 [2]; - TToDoEntry TD; - - pTVar3 = vector::operator()(&this->ToDoList,this->ActToDo); - TVar1 = pTVar3->Code; - TD.Code = (pTVar3->field_1).Move.Obj; - TD.field_1.Wait.Time = (anon_struct_4_1_898373eb_for_Wait)(pTVar3->field_1).Go.y; - TD.field_1.Go.y = (pTVar3->field_1).Go.z; - TD.field_1.Go.z = (pTVar3->field_1).Move.z; - TD.field_1.Move.z = (pTVar3->field_1).Move.Count; - if ((TVar1 == TDGo) && (ServerMilliseconds < this->EarliestWalkTime)) { - return this->EarliestWalkTime - ServerMilliseconds; - } - if (((TVar1 != TDUse) || (TD.field_1.Go.x == 0)) || - (TVar4 = this->EarliestMultiuseTime, TVar4 <= ServerMilliseconds)) { - if (TVar1 == TDAttack) { - uVar2 = (this->Combat).EarliestAttackTime; - if (ServerMilliseconds < uVar2) { - uVar6 = this->EarliestSpellTime; -LAB_080c1a7f: - local_30[0] = uVar2 - ServerMilliseconds; - local_34 = uVar6 - ServerMilliseconds; - piVar5 = &local_34; - if ((int)(uVar6 - ServerMilliseconds) <= local_30[0]) { - piVar5 = local_30; - } - return *piVar5; - } - uVar6 = this->EarliestSpellTime; - if (ServerMilliseconds < uVar6) goto LAB_080c1a7f; - } - if ((TVar1 != TDWait) || - ((this->EarliestWalkTime <= ServerMilliseconds && (TD.Code <= ServerMilliseconds)))) { - return 0; - } - pTVar3 = &TD; - if (TD.Code <= this->EarliestWalkTime) { - pTVar3 = (TToDoEntry *)&this->EarliestWalkTime; - } - TVar4 = pTVar3->Code; - } - return TVar4 - ServerMilliseconds; -} - - - -// DWARF original prototype: void Execute(TCreature * this) - -void __thiscall TCreature::Execute(TCreature *this) - -{ - bool bVar1; - int iVar2; - TToDoEntry *pTVar3; - undefined4 *puVar4; - char *Addressee; - int Delay; - int Delay_1; - char *pcVar5; - bool SnapbackNecessary; - TToDoEntry TD_1; - Object local_5c [4]; - Object local_4c [4]; - ToDoType local_3c; - TToDoEntry TD; - - do { - if (this->LockToDo == false) { - return; - } - if (this->IsDead != false) { - return; - } - if (ServerMilliseconds < this->NextWakeup) { - return; - } - if (this->NrToDo <= this->ActToDo) { - ToDoClear(this); - (*this->_vptr_TCreature[8])(this); - return; - } - iVar2 = CalculateDelay(this); - if (0 < iVar2) { - if (this->Stop == false) { - priority_queue<>::insert(&ToDoQueue); - this->NextWakeup = iVar2 + ServerMilliseconds; - return; - } - ToDoClear(this); - if (this->Type != PLAYER) { return; } - SendSnapback(this->Connection); - return; - } - pTVar3 = vector::operator()(&this->ToDoList,this->ActToDo); - local_3c = pTVar3->Code; - TD.Code = (pTVar3->field_1).Move.Obj; - TD.field_1.Wait.Time = - (anon_struct_4_1_898373eb_for_Wait)*(ToDoType *)((int)&pTVar3->field_1 + 4); - TD.field_1.Go.y = *(int *)((int)&pTVar3->field_1 + 8); - TD.field_1.Go.z = *(int *)((int)&pTVar3->field_1 + 0xc); - TD.field_1.Move.z = *(int *)((int)&pTVar3->field_1 + 0x10); - this->ActToDo = this->ActToDo + 1; - switch(local_3c) { - case TDGo: - // try { // try from 080c1bb6 to 080c1ca3 has its CatchHandler @ 080c2050 - Go(this,TD.Code,TD.field_1.Go.x,TD.field_1.Go.y); - break; - case TDRotate: - local_4c[0].ObjectID = (this->CrObject).ObjectID; - this->Direction = TD.Code & 0xff; - AnnounceChangedObject(local_4c,2); - break; - case TDMove: - local_4c[0].ObjectID = TD.Code; - Move(this,local_4c,TD.field_1.Go.x,TD.field_1.Go.y,TD.field_1.Go.z, - (uchar)TD.field_1.Move.z); - break; - case TDTrade: - local_4c[0].ObjectID = TD.Code; - Trade(this,local_4c,TD.field_1.Move.Obj); - break; - case TDUse: - local_5c[0].ObjectID = TD.Code; - local_4c[0].ObjectID = (ulong)TD.field_1.Wait.Time; - Use(this,local_5c,local_4c,(uchar)TD.field_1.Trade.Partner); - break; - case TDTurn: - local_5c[0].ObjectID = TD.Code; - // try { // try from 080c1cb5 to 080c1d07 has its CatchHandler @ 080c1e43 - bVar1 = Object::exists(local_5c); - if (!bVar1) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = 0x1f; - // WARNING: Subroutine does not return - __cxa_throw(puVar4,&RESULT::typeinfo,0); - } - local_4c[0].ObjectID = local_5c[0].ObjectID; - ::Turn(this->ID,local_4c); - break; - case TDAttack: - // try { // try from 080c1d11 to 080c1d15 has its CatchHandler @ 080c1e43 - TCombat::Attack(&this->Combat); - break; - case TDTalk: - if (TD.Code == TDWait) { - pcVar5 = "TCreature::Execute: TD.Text ist Null bei %s.\n"; -LAB_080c1d33: - // try { // try from 080c1d33 to 080c1dc3 has its CatchHandler @ 080c2050 - error(pcVar5,this->Name); - } - else { - pcVar5 = GetDynamicString(TD.Code); - if (pcVar5 == (char *)0x0) { - pcVar5 = "TCreature::Execute: Text ist NULL bei %s.\n"; - goto LAB_080c1d33; + bVar2 = false; + z = ::NONE.ObjectID; + bVar6 = local_4c[0].ObjectID != ::NONE.ObjectID; + local_4c[0].ObjectID = ::NONE.ObjectID; + if (bVar6) { + Object::getObjectType(local_4c); + bVar6 = ObjectType::getFlag((ObjectType *)local_4c,DISTUSE); + if (bVar6) { + local_4c[0] = (Object)Obj2->ObjectID; + bVar6 = ObjectInRange(this->ID,local_4c,7); + if (!bVar6) { + bVar2 = true; + } } } - pcVar5 = GetDynamicString(TD.Code); - Addressee = GetDynamicString(TD.field_1.Trade.Partner); - Talk(this->ID,TD.field_1.Go.x,Addressee,pcVar5,SUB41(TD.field_1.Go.z,0)); - break; - case TDChangeState: - if (this->Type == NPC) { - ChangeNPCState(this,TD.Code,true); - } - } - if (this->Stop != false) { - ToDoClear(this); - if (this->Type == PLAYER) { - SendSnapback(this->Connection); - } - return; - } - } while( true ); -} - - - -// WARNING: Variable defined which should be unmapped: SnapbackNecessary -// DWARF original prototype: bool ToDoClear(TCreature * this) - -bool __thiscall TCreature::ToDoClear(TCreature *this) - -{ - TToDoEntry *pTVar1; - TToDoEntry *TD; - int i; - int i_00; - bool local_11; - bool SnapbackNecessary; - - local_11 = false; - if (0 < this->NrToDo) { - i_00 = 0; - do { - pTVar1 = vector::operator()(&this->ToDoList,i_00); - switch(pTVar1->Code) { - case TDGo: - if (this->ActToDo <= i_00) { - local_11 = true; - } - break; - case TDTalk: - DeleteDynamicString((pTVar1->field_1).Move.Obj); - DeleteDynamicString((pTVar1->field_1).Talk.Addressee); - break; - case TDChangeState: - if ((this->ActToDo <= i_00) && (this->Type == NPC)) { - ChangeNPCState(this,(pTVar1->field_1).Go.x,false); + if (!bVar2) { + z = Obj2->ObjectID; + if (z != ::NONE.ObjectID) { + this->EarliestMultiuseTime = ServerMilliseconds + 1000; + z = Obj2->ObjectID; } + local_4c[0] = (Object)Obj1->ObjectID; + ::Use(this->ID,local_4c,(Object *)&z,Dummy); + return; } - i_00 = i_00 + 1; - } while (i_00 < this->NrToDo); - } - this->LockToDo = false; - this->ActToDo = 0; - this->NrToDo = 0; - this->Stop = false; - return local_11; -} - - - -// DWARF original prototype: void ToDoStop(TCreature * this) - -void __thiscall TCreature::ToDoStop(TCreature *this) - -{ - if (this->LockToDo == false) { - if (this->Type == PLAYER) { - SendSnapback(this->Connection); - return; - } - } - else { - this->Stop = true; - } - return; -} - - - -// DWARF original prototype: void ToDoAdd(TCreature * this, TToDoEntry * TD) - -void __thiscall TCreature::ToDoAdd(TCreature *this,TToDoEntry *TD) - -{ - bool bVar1; - TToDoEntry *pTVar2; - - if (this->LockToDo != false) { - bVar1 = ToDoClear(this); - if ((bVar1) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); - } - } - pTVar2 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar2->Code = TD->Code; - (pTVar2->field_1).Wait.Time = (TD->field_1).Wait.Time; - (pTVar2->field_1).Go.y = (TD->field_1).Go.y; - (pTVar2->field_1).Go.z = (TD->field_1).Go.z; - (pTVar2->field_1).Move.z = (TD->field_1).Move.z; - (pTVar2->field_1).Move.Count = (TD->field_1).Move.Count; - this->NrToDo = this->NrToDo + 1; - return; -} - - - -// DWARF original prototype: void ToDoStart(TCreature * this) - -void __thiscall TCreature::ToDoStart(TCreature *this) - -{ - int iVar1; - int *piVar2; - int Delay; - int local_14; - int local_10; - - if (this->NrToDo != 0) { - this->LockToDo = true; - this->ActToDo = 0; - local_10 = CalculateDelay(this); - piVar2 = &local_14; - if (0 < local_10) { - piVar2 = &local_10; - } - local_14 = 1; - iVar1 = *piVar2; - priority_queue<>::insert(&ToDoQueue); - this->NextWakeup = iVar1 + ServerMilliseconds; - } - return; -} - - - -// WARNING: Type propagation algorithm not settling -// DWARF original prototype: void ToDoYield(TCreature * this) - -void __thiscall TCreature::ToDoYield(TCreature *this) - -{ - ulong uVar1; - TToDoEntry *pTVar2; - TToDoEntry TD; - - uVar1 = ServerMilliseconds; - if (this->LockToDo == false) { - pTVar2 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar2->Code = TDWait; - (pTVar2->field_1).Move.Obj = uVar1; - ((anon_struct_4_1_898373eb_for_Wait *)((int)&pTVar2->field_1 + 4))->Time = - (ulong)TD.field_1.Wait.Time; - (pTVar2->field_1).Go.z = TD.field_1.Go.y; - (pTVar2->field_1).Move.z = TD.field_1.Go.z; - (pTVar2->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; - ToDoStart(this); - } - return; -} - - - -// WARNING: Type propagation algorithm not settling -// DWARF original prototype: void ToDoWait(TCreature * this, int Delay) - -void __thiscall TCreature::ToDoWait(TCreature *this,int Delay) - -{ - bool bVar1; - int iVar2; - TToDoEntry *pTVar3; - TToDoEntry TD; - - iVar2 = Delay + ServerMilliseconds; - if (this->LockToDo != false) { - bVar1 = ToDoClear(this); - if ((bVar1) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); - } - } - pTVar3 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar3->Code = TDWait; - (pTVar3->field_1).Go.x = iVar2; - ((anon_struct_4_1_898373eb_for_Wait *)((int)&pTVar3->field_1 + 4))->Time = - (ulong)TD.field_1.Wait.Time; - (pTVar3->field_1).Go.z = TD.field_1.Go.y; - (pTVar3->field_1).Move.z = TD.field_1.Go.z; - (pTVar3->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; - return; -} - - - -// DWARF original prototype: void ToDoTalk(TCreature * this, int Mode, char * Addressee, char * -// Text, bool CheckSpamming) - -void __thiscall TCreature::ToDoTalk(TCreature *this) - -{ - bool bVar1; - ulong uVar2; - TToDoEntry *pTVar3; - int in_stack_00000008; - char *in_stack_0000000c; - char *in_stack_00000010; - undefined1 in_stack_00000014; - TToDoEntry TD; - - if (in_stack_0000000c == (char *)0x0) { - TD.field_1.Go.y = 0; - } - else { - TD.field_1.Trade.Partner = AddDynamicString(in_stack_0000000c); - } - TD.field_1.Go.z._0_1_ = in_stack_00000014; - if (in_stack_00000010 == (char *)0x0) { - error("TCreature::ToDoTalk: Text ist NULL bei %s.\n",this->Name); - } - uVar2 = AddDynamicString(in_stack_00000010); - if (uVar2 == 0) { - error("TCreature::ToDoTalk: TD.Text ist Null bei %s.\n",this->Name); - } - if (this->LockToDo != false) { - bVar1 = ToDoClear(this); - if ((bVar1) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); + puVar3 = (undefined4 *)__cxa_allocate_exception(4); + *puVar3 = 5; + goto LAB_080c0733; } } - pTVar3 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar3->Code = TDTalk; - (pTVar3->field_1).Move.Obj = uVar2; - (pTVar3->field_1).Go.y = in_stack_00000008; - (pTVar3->field_1).Go.z = TD.field_1.Go.y; - (pTVar3->field_1).Move.z = TD.field_1.Go.z; - (pTVar3->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; - return; + puVar3 = (undefined4 *)__cxa_allocate_exception(4); + *puVar3 = 0x1f; +LAB_080c0733: + // WARNING: Subroutine does not return + __cxa_throw(puVar3,&RESULT::typeinfo,0); } -// WARNING: Type propagation algorithm not settling -// DWARF original prototype: void ToDoChangeState(TCreature * this, int NewState) +// DWARF original prototype: void Turn(TCreature * this, Object * Obj) -void __thiscall TCreature::ToDoChangeState(TCreature *this,int NewState) +void __thiscall TCreature::Turn(TCreature *this,Object *Obj) { bool bVar1; - TToDoEntry *pTVar2; - TToDoEntry TD; + undefined4 *puVar2; + Object local_1c [5]; - if (this->LockToDo != false) { - bVar1 = ToDoClear(this); - if ((bVar1) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); - } + // try { // try from 080c09cf to 080c0a25 has its CatchHandler @ 080c0a26 + bVar1 = Object::exists(Obj); + if (bVar1) { + local_1c[0] = (Object)Obj->ObjectID; + ::Turn(this->ID,local_1c); + return; } - pTVar2 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar2->Code = TDChangeState; - (pTVar2->field_1).Go.x = NewState; - ((anon_struct_4_1_898373eb_for_Wait *)((int)&pTVar2->field_1 + 4))->Time = - (ulong)TD.field_1.Wait.Time; - (pTVar2->field_1).Go.z = TD.field_1.Go.y; - (pTVar2->field_1).Move.z = TD.field_1.Go.z; - (pTVar2->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; - return; + puVar2 = (undefined4 *)__cxa_allocate_exception(4); + *puVar2 = 0x1f; + // WARNING: Subroutine does not return + __cxa_throw(puVar2,&RESULT::typeinfo,0); } +// DWARF original prototype: void NotifyGo(TCreature * this) - -// DWARF original prototype: void ToDoGo(TCreature * this, int DestX, int DestY, int DestZ, bool -// Dest, int MaxSteps) - -void __thiscall -TCreature::ToDoGo(TCreature *this,int DestX,int DestY,int DestZ,bool Dest,int MaxSteps) +void __thiscall TCreature::NotifyGo(TCreature *this) { - vector *this_00; - bool bVar1; - undefined4 *puVar2; - TToDoEntry *pTVar3; + int iVar1; + int iVar2; + TConnection *Connection; + bool bVar3; + bool bVar4; + bool bVar5; + int Waypoints; + int iVar6; + CreatureType CVar7; + ulong uVar8; + int iVar9; + TPlayer *pTVar10; int dx; - uint uVar4; + uint uVar11; + TCreature *Window; int dy; - uint uVar5; - undefined1 local_6c [3]; - bool Dest_local; - TShortway Shortway; - TToDoEntry TD; + uint uVar12; + TCreature *Obj_00; + TCreature *Con_00; + TPlayer *Partner; + bool DiagonalMove; + int dz; + int local_68; + int x; + int y; + int z; + Object Obj; + Object local_4c [4]; + Object local_3c [4]; + Object local_2c; + Object Con; - if (this->posz < DestZ) { - puVar2 = (undefined4 *)__cxa_allocate_exception(4); - *puVar2 = 0x18; + local_2c.ObjectID = (this->CrObject).ObjectID; + GetObjectCoordinates(&local_2c,&local_68,&x,&y); + iVar9 = this->posx; + uVar11 = local_68 - iVar9; + iVar1 = this->posy; + uVar12 = x - iVar1; + iVar2 = this->posz; + bVar3 = false; + iVar6 = y - iVar2; + if (((iVar6 == 0) && (uVar11 != 0)) && (uVar12 != 0)) { + bVar3 = true; } - else { - if (this->posz <= DestZ) { - if (this->LockToDo != false) { - this_00 = &this->ToDoList; - pTVar3 = vector::operator()(this_00,this->NrToDo + -1); - if ((((pTVar3->Code == TDGo) && - (pTVar3 = vector::operator()(this_00,this->NrToDo + -1), - (pTVar3->field_1).Go.x == DestX)) && - (pTVar3 = vector::operator()(this_00,this->NrToDo + -1), - (pTVar3->field_1).Go.y == DestY)) && - (pTVar3 = vector::operator()(this_00,this->NrToDo + -1), - (pTVar3->field_1).Go.z == DestZ)) { - puVar2 = (undefined4 *)__cxa_allocate_exception(4); - *puVar2 = 0; - goto LAB_080c2810; - } + MoveChainCreature(this,local_68,x); + CVar7 = this->Type; + if ((CVar7 == PLAYER) && (Connection = this->Connection, Connection != (TConnection *)0x0)) { + if (((iVar6 + 1U < 3) && (uVar11 + 1 < 3)) && (uVar12 + 1 < 3)) { + if (iVar6 == 1) { + this->posz = this->posz + 1; + this->posx = this->posx + -1; + this->posy = this->posy + -1; + SendFloors(Connection,false); + uVar11 = uVar11 + 1; + uVar12 = uVar12 + 1; } - uVar5 = DestY - this->posy; - uVar4 = DestX - this->posx; - if (((uVar4 != 0) || (uVar5 != 0)) && ((Dest || ((2 < uVar4 + 1 || (2 < uVar5 + 1)))))) - { - if (0x7fffffff < uVar4) { - uVar4 = -uVar4; - } - if (0x7fffffff < uVar5) { - uVar5 = -uVar5; - } - if (uVar5 + uVar4 == 1) { - if (((this->LockToDo != false) && (bVar1 = ToDoClear(this), bVar1)) && - (this->Type == PLAYER)) { - SendSnapback(this->Connection); - } - // try { // try from 080c272a to 080c2827 has its CatchHandler @ 080c2870 - pTVar3 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar3->Code = TDGo; - (pTVar3->field_1).Go.x = DestX; - (pTVar3->field_1).Go.y = DestY; - (pTVar3->field_1).Go.z = DestZ; - (pTVar3->field_1).Move.z = TD.field_1.Go.z; - (pTVar3->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; - } - else { - // try { // try from 080c2660 to 080c2664 has its CatchHandler @ 080c2870 - TShortway::TShortway - ((TShortway *)local_6c,this,(uint)(this->Type != PLAYER) * 3 + 7, - (uint)(this->Type != PLAYER) * 3 + 7); - // try { // try from 080c2685 to 080c26f4 has its CatchHandler @ 080c2850 - bVar1 = TShortway::Calculate((TShortway *)local_6c,DestX,DestY,Dest,MaxSteps); - if (!bVar1) { - ToDoClear(this); - if (this->Type == PLAYER) { - SendSnapback(this->Connection); - } - puVar2 = (undefined4 *)__cxa_allocate_exception(4); - *puVar2 = 0x2c; - // WARNING: Subroutine does not return - __cxa_throw(puVar2,&RESULT::typeinfo,0); - } - TShortway::~TShortway((TShortway *)local_6c,DestX); - } + if (iVar6 == -1) { + this->posz = this->posz + -1; + uVar11 = uVar11 - 1; + this->posx = this->posx + 1; + uVar12 = uVar12 - 1; + this->posy = this->posy + 1; + SendFloors(this->Connection,true); + } + for (; 0 < (int)uVar11; uVar11 = uVar11 - 1) { + this->posx = this->posx + 1; + SendRow(this->Connection,1); + } + for (; (int)uVar11 < 0; uVar11 = uVar11 + 1) { + this->posx = this->posx + -1; + SendRow(this->Connection,3); + } + for (; 0 < (int)uVar12; uVar12 = uVar12 - 1) { + this->posy = this->posy + 1; + SendRow(this->Connection,2); + } + for (; (int)uVar12 < 0; uVar12 = uVar12 + 1) { + this->posy = this->posy + -1; + SendRow(this->Connection,0); } - return; } - puVar2 = (undefined4 *)__cxa_allocate_exception(4); - *puVar2 = 0x17; + else { + this->posx = this->posx + uVar11; + this->posy = this->posy + uVar12; + this->posz = this->posz + iVar6; + SendFullScreen(Connection); + } + CVar7 = this->Type; } -LAB_080c2810: - // WARNING: Subroutine does not return - __cxa_throw(puVar2,&RESULT::typeinfo,0); -} - - - -// WARNING: Type propagation algorithm not settling -// DWARF original prototype: void ToDoRotate(TCreature * this, int Direction) - -void __thiscall TCreature::ToDoRotate(TCreature *this,int Direction) - -{ - bool bVar1; - TToDoEntry *pTVar2; - undefined4 *puVar3; - TToDoEntry TD; - - if (Direction < 4) { - if (this->LockToDo != false) { - bVar1 = ToDoClear(this); - if ((bVar1) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); + else { + this->posx = this->posx + uVar11; + this->posy = this->posy + uVar12; + this->posz = this->posz + iVar6; + } + if (CVar7 != PLAYER) goto LAB_080c0c2d; + Window = (TCreature *)0x0; + do { + Obj_00 = this; + Con_00 = Window; + TPlayer::GetOpenContainer((TPlayer *)&local_2c,(int)this); + local_3c[0].ObjectID = ::NONE.ObjectID; + if (local_2c.ObjectID != ::NONE.ObjectID) { + bVar4 = Object::exists(&local_2c); + if (bVar4) { + Con_00 = (TCreature *)0x1; + Obj_00 = (TCreature *)local_3c; + local_3c[0].ObjectID = local_2c.ObjectID; + bVar4 = ObjectAccessible(this->ID,(Object *)Obj_00,1); + if (bVar4) goto LAB_080c0c07; + local_4c[0] = (Object)::NONE.ObjectID; + Con_00 = (TCreature *)local_4c; + } + else { + error("TCreature::NotifyGo: OpenContainer existiert nicht. (%s, [%d,%d,%d]->[%d,%d,%d])\n" + ,this->Name,iVar9,iVar1,iVar2,this->posx,this->posy,this->posz); + local_3c[0].ObjectID = ::NONE.ObjectID; + Con_00 = (TCreature *)local_3c; } + TPlayer::SetOpenContainer((TPlayer *)this,(int)Window,(Object *)Con_00); + Obj_00 = Window; + SendCloseContainer(this->Connection,(int)Window); + } +LAB_080c0c07: + Window = (TCreature *)((int)&Window->_vptr_TCreature + 1); + } while ((int)Window < 0x10); + local_4c[0].ObjectID = ::NONE.ObjectID; + local_3c[0].ObjectID = ::NONE.ObjectID; + if (this[1].super_TSkillBase.TimerList[0xb] == (TSkill *)::NONE.ObjectID) goto LAB_080c0c2d; + pTVar10 = GetPlayer((ulong)this[1].super_TSkillBase.TimerList[0xc]); + bVar4 = Object::exists((Object *)(this[1].super_TSkillBase.TimerList + 0xb)); + if (!bVar4) { + error("TCreature::NotifyGo: Handelsobjekt existiert nicht mehr.\n",Obj_00,Con_00); + error(&DAT_081072f3,this->Name,this->posx,this->posy,this->posz); + if (pTVar10 != (TPlayer *)0x0) { + error("# Partner %s an [%d,%d,%d]\n",(pTVar10->super_TCreature).Name, + (pTVar10->super_TCreature).posx,(pTVar10->super_TCreature).posy, + (pTVar10->super_TCreature).posz); } - // try { // try from 080c28c4 to 080c294f has its CatchHandler @ 080c2950 - pTVar2 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar2->Code = TDRotate; - (pTVar2->field_1).Go.x = Direction; - ((anon_struct_4_1_898373eb_for_Wait *)((int)&pTVar2->field_1 + 4))->Time = - (ulong)TD.field_1.Wait.Time; - (pTVar2->field_1).Go.z = TD.field_1.Go.y; - (pTVar2->field_1).Move.z = TD.field_1.Go.z; - (pTVar2->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; - return; } - puVar3 = (undefined4 *)__cxa_allocate_exception(4); - *puVar3 = 0xffffffff; - // WARNING: Subroutine does not return - __cxa_throw(puVar3,&RESULT::typeinfo,0); + bVar4 = false; + if (pTVar10 == (TPlayer *)0x0) { +LAB_080c0dba: + bVar4 = true; + } + else { + local_3c[0].ObjectID = (ulong)this[1].super_TSkillBase.TimerList[0xb]; + bVar5 = ObjectAccessible(this->ID,local_3c,1); + if (!bVar5) goto LAB_080c0dba; + local_2c.ObjectID = (pTVar10->super_TCreature).CrObject.ObjectID; + z = (this->CrObject).ObjectID; + iVar9 = ObjectDistance((Object *)&z,&local_2c); + if ((2 < iVar9) || + (bVar5 = ThrowPossible(this->posx,this->posy,this->posz,(pTVar10->super_TCreature).posx, + (pTVar10->super_TCreature).posy,(pTVar10->super_TCreature).posz,0) + , !bVar5)) goto LAB_080c0dba; + } + if (bVar4) { + SendCloseTrade(this->Connection); + SendMessage(this->Connection,0x17,"Trade cancelled."); + TPlayer::RejectTrade((TPlayer *)this); + } +LAB_080c0c2d: + GetFirstObject(); + while( true ) { + Object::getObjectType(local_4c); + bVar4 = ObjectType::getFlag((ObjectType *)local_4c,BANK); + if (bVar4) break; + local_4c[0].ObjectID = ::NONE.ObjectID; + local_3c[0].ObjectID = ::NONE.ObjectID; + if (z == ::NONE.ObjectID) break; + Object::getNextObject(local_3c); + z = local_3c[0].ObjectID; + local_4c[0].ObjectID = z; + } + local_4c[0] = (Object)::NONE.ObjectID; + if (z == ::NONE.ObjectID) { + error("TCreature::NotifyGo: Auf Feld [%d,%d,%d] befindet sich kein Bank.\n",this->posx, + this->posy,this->posz); + } + else { + Object::getObjectType(local_4c); + uVar8 = ObjectType::getAttribute((ObjectType *)local_4c,WAYPOINTS); + if (bVar3) { + uVar8 = uVar8 * 3; + } + iVar9 = GetSpeed(this); + this->EarliestWalkTime = + ((Beat + -1 + (int)(uVar8 * 1000) / iVar9) / Beat) * Beat + ServerMilliseconds; + } + return; } -// DWARF original prototype: void ToDoMove(TCreature * this, int sx, int sy, int sz, ObjectType * -// Type, uchar RNum, int zx, int zy, int zz, uchar Count) +// DWARF original prototype: void NotifyTurn(TCreature * this, Object * DestCon) -void __thiscall -TCreature::ToDoMove(TCreature *this,int sx,int sy,int sz,ObjectType *Type,uchar RNum,int zx,int zy, - int zz,uchar Count) +void __thiscall TCreature::NotifyTurn(TCreature *this,Object *DestCon) { - bool bVar1; - TCreature *pTVar2; - int iVar3; - TToDoEntry *pTVar4; - undefined4 *puVar5; - ObjectType *Type_00; - ulong x; - int iVar6; - int iVar7; - Object *pOVar8; - uchar Count_local; - TToDoEntry TD; - Object local_4c [4]; - Object local_3c; - Object Dest; - Object local_2c; - Object Obj; + int dy; + int iVar1; + int local_28; + int x; + int y; + int z; - // try { // try from 080c299f to 080c2c56 has its CatchHandler @ 080c2c90 - ObjectType::setTypeID((ObjectType *)&local_3c,Type->TypeID); - Type_00 = (ObjectType *)(uint)RNum; - x = this->ID; - iVar3 = sx; - iVar6 = sy; - iVar7 = sz; - pOVar8 = &local_3c; - GetObject((ulong)&local_2c,x,sx,sy,sz,Type_00); - bVar1 = Object::exists(&local_2c); - if (bVar1) { - if (sx != 0xffff) { - if (this->posz < sz) { - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 0x18; - goto LAB_080c2be8; - } - if (sz < this->posz) { - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 0x17; - goto LAB_080c2be8; - } - local_3c.ObjectID = local_2c.ObjectID; - bVar1 = ObjectInRange(this->ID,&local_3c,1); - if (!bVar1) { - Type_00 = (ObjectType *)0x7fffffff; - iVar7 = 0; - ToDoGo(this,sx,sy,sz,false,0x7fffffff); - } + z = DestCon->ObjectID; + GetObjectCoordinates((Object *)&z,&local_28,&x,&y); + local_28 = local_28 - this->posx; + iVar1 = x - this->posy; + if (local_28 < 1) { + if (local_28 < 0) { + this->Direction = 3; } - Object::getObjectType(&local_3c); - if (local_3c.ObjectID != 99) { - iVar3 = 100; -LAB_080c2b08: - ToDoWait(this,iVar3); - if (((this->LockToDo != false) && (bVar1 = ToDoClear(this), bVar1)) && - (this->Type == PLAYER)) { - SendSnapback(this->Connection); - } - pTVar4 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar4->Code = TDMove; - (pTVar4->field_1).Wait.Time = local_2c.ObjectID; - (pTVar4->field_1).Go.y = zx; - (pTVar4->field_1).Go.z = zy; - (pTVar4->field_1).Move.z = zz; - *(uint *)((int)&pTVar4->field_1 + 0x10) = (uint)Count; - this->NrToDo = this->NrToDo + 1; - return; + else if (iVar1 < 0) { + this->Direction = 0; } - x = zx; - iVar3 = zy; - iVar6 = zz; - GetFirstObject(); - bVar1 = Object::exists(&local_3c); - if (bVar1) { - Object::getObjectType(local_4c); - x = 0; - bVar1 = ObjectType::getFlag((ObjectType *)local_4c,BANK); - if (bVar1) { - Object::getObjectType(local_4c); - ObjectType::getAttribute((ObjectType *)local_4c,WAYPOINTS); - local_4c[0].ObjectID = local_2c.ObjectID; - pTVar2 = GetCreature(local_4c); - if (pTVar2 != (TCreature *)0x0) { - if (ServerMilliseconds < pTVar2->EarliestWalkTime) { - iVar3 = (pTVar2->EarliestWalkTime - ServerMilliseconds) + 1000; - } - else { - iVar3 = 1000; - } - goto LAB_080c2b08; - } - error("TCreature::ToDoMove: Kreatur existiert nicht.\n"); - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 0xffffffff; - goto LAB_080c2be8; - } + else if (x != this->posy && -1 < iVar1) { + this->Direction = 2; } } - puVar5 = (undefined4 *)__cxa_allocate_exception(4,x,iVar3,iVar6,iVar7,Type_00,pOVar8); - *puVar5 = 1; -LAB_080c2be8: - // WARNING: Subroutine does not return - __cxa_throw(puVar5,&RESULT::typeinfo,0); + else { + this->Direction = 1; + } + return; } -// WARNING: Type propagation algorithm not settling -// DWARF original prototype: void ToDoMove(TCreature * this, Object * Obj, int zx, int zy, int zz, -// uchar Count) +// DWARF original prototype: void NotifyDelete(TCreature * this) -void __thiscall TCreature::ToDoMove(TCreature *this,Object *Obj,int zx,int zy,int zz,uchar Count) +void __thiscall TCreature::NotifyDelete(TCreature *this) { - bool bVar1; - TToDoEntry *pTVar2; - undefined4 *puVar3; - int Delay; - int iStack_68; - uchar Count_local; - int x; - int y; - int z; - TToDoEntry TD; - Object local_3c [4]; - Object local_2c [7]; + CreatureType CVar1; - // try { // try from 080c2cd2 to 080c2e61 has its CatchHandler @ 080c2e62 - bVar1 = Object::exists(Obj); - if (!bVar1) { - puVar3 = (undefined4 *)__cxa_allocate_exception(4); - *puVar3 = 1; - // WARNING: Subroutine does not return - __cxa_throw(puVar3,&RESULT::typeinfo,0); - } - local_2c[0] = (Object)Obj->ObjectID; - bVar1 = ObjectInRange(this->ID,local_2c,1); - if (!bVar1) { - local_3c[0] = (Object)Obj->ObjectID; - GetObjectCoordinates(local_3c,&stack0xffffff98,&x,&y); - ToDoGo(this,iStack_68,x,y,false,0x7fffffff); - } - Object::getObjectType(local_3c); - Delay = 1000; - if (local_3c[0].ObjectID != 99) { - Delay = 100; - } - ToDoWait(this,Delay); - z = 3; - TD.Code = Obj->ObjectID; - TD.field_1.Move.z = (int)Count; - TD.field_1.Go.x = zx; - TD.field_1.Go.y = zy; - TD.field_1.Go.z = zz; - if (((this->LockToDo != false) && (bVar1 = ToDoClear(this), bVar1)) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); + if (this->Type == PLAYER) { + CVar1 = PLAYER; + if (this->Connection != (TConnection *)0x0) { + TConnection::Logout(this->Connection,0x1e,true); + CVar1 = this->Type; + this->LoggingOut = true; + } + if (CVar1 == PLAYER) { + TPlayer::RejectTrade((TPlayer *)this); + } } - pTVar2 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar2->Code = z; - (pTVar2->field_1).Move.Obj = TD.Code; - ((anon_struct_4_1_898373eb_for_Wait *)((int)&pTVar2->field_1 + 4))->Time = - (ulong)TD.field_1.Wait.Time; - (pTVar2->field_1).Go.z = TD.field_1.Go.y; - (pTVar2->field_1).Move.z = TD.field_1.Go.z; - (pTVar2->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; + DeleteChainCreature(this); return; } -// DWARF original prototype: void ToDoTrade(TCreature * this, int x, int y, int z, ObjectType * -// Type, uchar RNum, ulong TradePartner) +// DWARF original prototype: void NotifyCreate(TCreature * this) -void __thiscall -TCreature::ToDoTrade - (TCreature *this,int x,int y,int z,ObjectType *Type,uchar RNum,ulong TradePartner) +void __thiscall TCreature::NotifyCreate(TCreature *this) { - bool bVar1; - TCreature *pTVar2; - TToDoEntry *pTVar3; - undefined4 *puVar4; - char *Text; - Object *this_00; - TToDoEntry TD; - Object local_3c [4]; - Object local_2c; + InsertChainCreature(this,0,0); + return; +} + + + +// DWARF original prototype: void NotifyChangeInventory(TCreature * this) + +void __thiscall TCreature::NotifyChangeInventory(TCreature *this) + +{ + TSkill *pTVar1; + anon_union_4_2_730cd3ca_for_TOutfit_2 aVar2; + bool bVar3; + bool bVar4; + int i; + int iVar5; + int iVar6; + ulong uVar7; + ulong uVar8; + bool SkillsChanged; + int i_1; + int b; + ulong uVar9; + int SkillNr; + ulong local_ac; + int iStack_9c; + int NewDelta [25]; + ulong local_2c; Object Obj; - this_00 = &local_2c; - // try { // try from 080c2ea5 to 080c3132 has its CatchHandler @ 080c3185 - ObjectType::setTypeID((ObjectType *)local_3c,Type->TypeID); - GetObject((ulong)this_00,this->ID,x,y,z,(ObjectType *)(uint)RNum); - bVar1 = Object::exists(this_00); - if (!bVar1) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = 1; - goto LAB_080c30bb; - } - Object::getObjectType(local_3c); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,UNMOVE); - if (bVar1) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = 2; - goto LAB_080c30bb; - } - Object::getObjectType(local_3c); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,TAKE); - if (!bVar1) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = 3; - goto LAB_080c30bb; - } - Object::getObjectType(local_3c); - if (local_3c[0].ObjectID == 99) { - Text = "TCreature::ToDoTrade: Objekt ist eine Kreatur.\n"; -LAB_080c312e: - error(Text,this_00); - } - else { - if (TradePartner == 0) { - Text = "TCreature::ToDoTrade: Handelspartner ist Null.\n"; - goto LAB_080c312e; - } - pTVar2 = GetCreature(TradePartner); - if (pTVar2 == (TCreature *)0x0) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = 0x1b; - goto LAB_080c30bb; - } - if (pTVar2->Type == PLAYER) { - if (x == 0xffff) { -LAB_080c2fd4: - if (this->LockToDo != false) { - bVar1 = ToDoClear(this); - if ((bVar1) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); - } - } - pTVar3 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar3->Code = TDTrade; - (pTVar3->field_1).Wait.Time = local_2c.ObjectID; - (pTVar3->field_1).Trade.Partner = TradePartner; - (pTVar3->field_1).Go.z = TD.field_1.Go.y; - (pTVar3->field_1).Move.z = TD.field_1.Go.z; - (pTVar3->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; - return; - } - if (this->posz < z) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = 0x18; - } - else { - if (this->posz <= z) { - local_3c[0].ObjectID = local_2c.ObjectID; - bVar1 = ObjectInRange(this->ID,local_3c,1); - if (!bVar1) { - ToDoGo(this,x,y,z,false,0x7fffffff); + local_2c = ::NONE.ObjectID; + if ((this->CrObject).ObjectID != ::NONE.ObjectID) { + bVar3 = Object::exists(&this->CrObject); + if (bVar3) { + TCombat::CheckCombatValues(&this->Combat); + if (this->Type == PLAYER) { + iVar5 = 0; + do { + NewDelta[iVar5 + -1] = 0; + iVar5 = iVar5 + 1; + } while (iVar5 < 0x19); + uVar9 = 1; + do { + bVar3 = false; + GetBodyObject((ulong)&local_2c,this->ID); + local_ac = ::NONE.ObjectID; + if (local_2c == ::NONE.ObjectID) { +LAB_080c12f2: + bVar3 = true; + } + else { + Object::getObjectType((Object *)&SkillNr); + bVar4 = ObjectType::getFlag((ObjectType *)&SkillNr,SKILLBOOST); + if (!bVar4) goto LAB_080c12f2; + } + if (!bVar3) { + Object::getObjectType((Object *)&SkillNr); + bVar3 = ObjectType::getFlag((ObjectType *)&SkillNr,CLOTHES); + if (bVar3) { + Object::getObjectType((Object *)&SkillNr); + uVar7 = ObjectType::getAttribute((ObjectType *)&SkillNr,BODYPOSITION); + if (uVar7 == uVar9) { + Object::getObjectType((Object *)&SkillNr); + uVar7 = ObjectType::getAttribute((ObjectType *)&SkillNr,SKILLNUMBER) + ; + if ((int)uVar7 < 0x19) { + Object::getObjectType((Object *)&SkillNr); + uVar8 = ObjectType::getAttribute + ((ObjectType *)&SkillNr,SKILLMODIFICATION); + if (0x7fff < (int)uVar8) { + uVar8 = uVar8 - 0x10000; + } + NewDelta[uVar7 - 1] = NewDelta[uVar7 - 1] + uVar8; + } + else { + Object::getObjectType((Object *)&SkillNr); + error(&DAT_08107080,SkillNr,uVar7); + } + } + } + else { + Object::getObjectType((Object *)&SkillNr); + error("TCreature::NotifyChangeInventory: Objekt %d hat SKILLBOOST, aber nicht CLOTHES.\n" + ,SkillNr); + } + } + uVar9 = uVar9 + 1; + } while ((int)uVar9 < 0xb); + bVar3 = false; + iVar5 = 0; + do { + pTVar1 = (this->super_TSkillBase).Skills[iVar5]; + if (pTVar1->DAct != NewDelta[iVar5 + -1]) { + pTVar1->DAct = NewDelta[iVar5 + -1]; + if (iVar5 == 4) { + AnnounceChangedCreature(this->ID,4); + } + if (iVar5 == 0x10) { + if (NewDelta[0xf] < 1) { + pTVar1 = (this->super_TSkillBase).Skills[0x10]; + iVar6 = (*pTVar1->_vptr_TSkill[0xd])(pTVar1); + if (iVar6 == 0) { + aVar2 = (this->OrgOutfit).field_1; + (this->Outfit).OutfitID = (this->OrgOutfit).OutfitID; + (this->Outfit).field_1 = aVar2; + } + } + else { + bVar3 = false; + if (((this->Outfit).OutfitID == 0) && + ((this->Outfit).field_1.ObjectType == 0)) { + bVar3 = true; + } + if ((!bVar3) && + (pTVar1 = (this->super_TSkillBase).Skills[0x10], + iVar6 = (*pTVar1->_vptr_TSkill[0xd])(pTVar1), iVar6 != 0)) { + TSkillBase::SetTimer(&this->super_TSkillBase); + } + (this->Outfit).OutfitID = 0; + (this->Outfit).field_1.ObjectType = 0; + } + AnnounceChangedCreature(this->ID,3); + } + bVar3 = true; } - goto LAB_080c2fd4; - } - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = 0x17; - } - goto LAB_080c30bb; - } - error("TCreature::ToDoTrade: Handelspartner von %s ist kein Spieler.\n",this->Name); - } - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = 0xffffffff; -LAB_080c30bb: - // WARNING: Subroutine does not return - __cxa_throw(puVar4,&RESULT::typeinfo,0); -} - - - -// DWARF original prototype: void ToDoUse(TCreature * this, uchar Count, int x1, int y1, int z1, -// ObjectType * Type1, uchar RNum1, uchar Dummy, int x2, int y2, int z2, ObjectType * Type2, uchar -// RNum2) - -void __thiscall -TCreature::ToDoUse(TCreature *this,uchar Count,int x1,int y1,int z1,ObjectType *Type1,uchar RNum1, - uchar Dummy,int x2,int y2,int z2,ObjectType *Type2,uchar RNum2) - -{ - Object OVar1; - Object OVar2; - bool bVar3; - TToDoEntry *pTVar4; - undefined4 *puVar5; - uchar RNum2_local; - uchar Dummy_local; - uchar Count_local; - TToDoEntry TD; - Object local_6c [4]; - ulong local_5c [4]; - ObjectType local_4c [4]; - Object local_3c; - Object Obj2; - Object local_2c; - Object Obj1; - - local_3c.ObjectID = 0; - local_2c.ObjectID = 0; - // try { // try from 080c31ee to 080c3453 has its CatchHandler @ 080c3473 - ObjectType::setTypeID((ObjectType *)local_6c,Type1->TypeID); - GetObject((ulong)local_5c,this->ID,x1,y1,z1,(ObjectType *)(uint)RNum1); - local_2c.ObjectID = local_5c[0]; - local_4c[0].TypeID = local_5c[0]; - bVar3 = Object::exists(&local_2c); - if (bVar3) { - if (Count < 2) { - local_5c[0] = ::NONE.ObjectID; - local_3c.ObjectID = ::NONE.ObjectID; - local_6c[0].ObjectID = ::NONE.ObjectID; - } - else { - ObjectType::setTypeID(local_4c,Type2->TypeID); - GetObject((ulong)local_5c,this->ID,x2,y2,z2,(ObjectType *)(uint)RNum2); - local_3c.ObjectID = local_5c[0]; - local_6c[0].ObjectID = local_5c[0]; - bVar3 = Object::exists(&local_3c); - if (!bVar3) goto LAB_080c345c; - } - if (x1 == 0xffff) { -LAB_080c32b4: - ToDoWait(this,100); - OVar2.ObjectID = local_2c.ObjectID; - OVar1.ObjectID = local_3c.ObjectID; - if (this->LockToDo != false) { - bVar3 = ToDoClear(this); - if ((bVar3) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); + iVar5 = iVar5 + 1; + } while (iVar5 < 0x19); + if (bVar3) { + SendPlayerSkills(this->Connection); + TPlayer::CheckState((TPlayer *)this); } + SendPlayerData(this->Connection); } - pTVar4 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar4->Code = TDUse; - (pTVar4->field_1).Wait.Time = OVar2.ObjectID; - (pTVar4->field_1).Go.y = OVar1.ObjectID; - *(uint *)((int)&pTVar4->field_1 + 8) = (uint)Dummy; - (pTVar4->field_1).Move.z = TD.field_1.Go.z; - (pTVar4->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; - return; - } - if (this->posz < z1) { - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 0x18; } else { - if (this->posz <= z1) { - local_6c[0].ObjectID = local_2c.ObjectID; - bVar3 = ObjectInRange(this->ID,local_6c,1); - if (!bVar3) { - ToDoGo(this,x1,y1,z1,false,0x7fffffff); - } - goto LAB_080c32b4; - } - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 0x17; + error("TCreature::NotifyChangeInventory: Kreatur-Objekt existiert nicht.\n"); + error("# Kreatur: %s, Position: %d/%d/%d.\n",this->Name,this->posx,this->posy,this->posz + ); } } - else { -LAB_080c345c: - puVar5 = (undefined4 *)__cxa_allocate_exception(4); - *puVar5 = 1; - } - // WARNING: Subroutine does not return - __cxa_throw(puVar5,&RESULT::typeinfo,0); + return; } +// DWARF original prototype: void Execute(TCreature * this) - -// WARNING: Type propagation algorithm not settling -// DWARF original prototype: void ToDoUse(TCreature * this, uchar Count, Object * Obj1, Object * -// Obj2) - -void __thiscall TCreature::ToDoUse(TCreature *this,uchar Count,Object *Obj1,Object *Obj2) +void __thiscall TCreature::Execute(TCreature *this) { - Object OVar1; - bool bVar2; + bool bVar1; + int iVar2; TToDoEntry *pTVar3; undefined4 *puVar4; - int iStack_68; - uchar Count_local; - int x; - int y; - int z; + char *Addressee; + int Delay; + int Delay_1; + char *pcVar5; + bool SnapbackNecessary; + TToDoEntry TD_1; + Object local_5c [4]; + Object local_4c [4]; + ToDoType local_3c; TToDoEntry TD; - Object local_3c [4]; - Object local_2c [7]; - // try { // try from 080c34b5 to 080c3640 has its CatchHandler @ 080c3641 - bVar2 = Object::exists(Obj1); - OVar1 = ::NONE; - if (bVar2) { - if (Count < 2) { - Obj2->ObjectID = (ulong)::NONE; - local_2c[0].ObjectID = OVar1.ObjectID; + do { + if (this->LockToDo == false) { + return; } - else { - bVar2 = Object::exists(Obj2); - if (!bVar2) goto LAB_080c3617; + if (this->IsDead != false) { + return; } - local_3c[0] = (Object)Obj1->ObjectID; - bVar2 = ObjectInRange(this->ID,local_3c,1); - if (!bVar2) { - local_2c[0] = (Object)Obj1->ObjectID; - GetObjectCoordinates(local_2c,&stack0xffffff98,&x,&y); - ToDoGo(this,iStack_68,x,y,false,0x7fffffff); - } - ToDoWait(this,100); - z = 5; - TD.Code = Obj1->ObjectID; - TD.field_1.Go.y = (int)Count; - TD.field_1.Wait.Time = (anon_struct_4_1_898373eb_for_Wait)Obj2->ObjectID; - if (this->LockToDo != false) { - bVar2 = ToDoClear(this); - if ((bVar2) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); - } + if (ServerMilliseconds < this->NextWakeup) { + return; } - pTVar3 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar3->Code = z; - (pTVar3->field_1).Move.Obj = TD.Code; - ((anon_struct_4_1_898373eb_for_Wait *)((int)&pTVar3->field_1 + 4))->Time = - (ulong)TD.field_1.Wait.Time; - (pTVar3->field_1).Go.z = TD.field_1.Go.y; - (pTVar3->field_1).Move.z = TD.field_1.Go.z; - (pTVar3->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; - return; - } -LAB_080c3617: - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = 1; - // WARNING: Subroutine does not return - __cxa_throw(puVar4,&RESULT::typeinfo,0); -} - - - -// WARNING: Type propagation algorithm not settling -// DWARF original prototype: void ToDoTurn(TCreature * this, int x, int y, int z, ObjectType * Type, -// uchar RNum) - -void __thiscall TCreature::ToDoTurn(TCreature *this,int x,int y,int z,ObjectType *Type,uchar RNum) - -{ - bool bVar1; - TToDoEntry *pTVar2; - undefined4 *puVar3; - TToDoEntry TD; - Object local_3c [4]; - Object local_2c; - Object Obj; - - // try { // try from 080c3685 to 080c382e has its CatchHandler @ 080c3857 - ObjectType::setTypeID((ObjectType *)local_3c,Type->TypeID); - GetObject((ulong)&local_2c,this->ID,x,y,z,(ObjectType *)(uint)RNum); - bVar1 = Object::exists(&local_2c); - if (bVar1) { - if (x == 0xffff) { -LAB_080c3721: - ToDoWait(this,100); - if (this->LockToDo != false) { - bVar1 = ToDoClear(this); - if ((bVar1) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); - } - } - pTVar2 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar2->Code = TDTurn; - (pTVar2->field_1).Wait.Time = local_2c.ObjectID; - ((anon_struct_4_1_898373eb_for_Wait *)((int)&pTVar2->field_1 + 4))->Time = - (ulong)TD.field_1.Wait.Time; - (pTVar2->field_1).Go.z = TD.field_1.Go.y; - (pTVar2->field_1).Move.z = TD.field_1.Go.z; - (pTVar2->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; + if (this->NrToDo <= this->ActToDo) { + ToDoClear(this); + (*this->_vptr_TCreature[8])(this); return; } - if (this->posz < z) { - puVar3 = (undefined4 *)__cxa_allocate_exception(4); - *puVar3 = 0x18; + iVar2 = CalculateDelay(this); + if (0 < iVar2) { + if (this->Stop == false) { + priority_queue<>::insert(&ToDoQueue); + this->NextWakeup = iVar2 + ServerMilliseconds; + return; + } + ToDoClear(this); + if (this->Type != PLAYER) { + return; + } + SendSnapback(this->Connection); + return; } - else { - if (this->posz <= z) { - local_3c[0].ObjectID = local_2c.ObjectID; - bVar1 = ObjectInRange(this->ID,local_3c,1); - if (!bVar1) { - ToDoGo(this,x,y,z,false,0x7fffffff); + pTVar3 = vector::operator()(&this->ToDoList,this->ActToDo); + local_3c = pTVar3->Code; + TD.Code = (pTVar3->field_1).Move.Obj; + TD.field_1.Wait.Time = + (anon_struct_4_1_898373eb_for_Wait)*(ToDoType *)((int)&pTVar3->field_1 + 4); + TD.field_1.Go.y = *(int *)((int)&pTVar3->field_1 + 8); + TD.field_1.Go.z = *(int *)((int)&pTVar3->field_1 + 0xc); + TD.field_1.Move.z = *(int *)((int)&pTVar3->field_1 + 0x10); + this->ActToDo = this->ActToDo + 1; + switch(local_3c) { + case TDGo: + // try { // try from 080c1bb6 to 080c1ca3 has its CatchHandler @ 080c2050 + Go(this,TD.Code,TD.field_1.Go.x,TD.field_1.Go.y); + break; + case TDRotate: + local_4c[0].ObjectID = (this->CrObject).ObjectID; + this->Direction = TD.Code & 0xff; + AnnounceChangedObject(local_4c,2); + break; + case TDMove: + local_4c[0].ObjectID = TD.Code; + Move(this,local_4c,TD.field_1.Go.x,TD.field_1.Go.y,TD.field_1.Go.z, + (uchar)TD.field_1.Move.z); + break; + case TDTrade: + local_4c[0].ObjectID = TD.Code; + Trade(this,local_4c,TD.field_1.Move.Obj); + break; + case TDUse: + local_5c[0].ObjectID = TD.Code; + local_4c[0].ObjectID = (ulong)TD.field_1.Wait.Time; + Use(this,local_5c,local_4c,(uchar)TD.field_1.Trade.Partner); + break; + case TDTurn: + local_5c[0].ObjectID = TD.Code; + // try { // try from 080c1cb5 to 080c1d07 has its CatchHandler @ 080c1e43 + bVar1 = Object::exists(local_5c); + if (!bVar1) { + puVar4 = (undefined4 *)__cxa_allocate_exception(4); + *puVar4 = 0x1f; + // WARNING: Subroutine does not return + __cxa_throw(puVar4,&RESULT::typeinfo,0); + } + local_4c[0].ObjectID = local_5c[0].ObjectID; + ::Turn(this->ID,local_4c); + break; + case TDAttack: + // try { // try from 080c1d11 to 080c1d15 has its CatchHandler @ 080c1e43 + TCombat::Attack(&this->Combat); + break; + case TDTalk: + if (TD.Code == TDWait) { + pcVar5 = "TCreature::Execute: TD.Text ist Null bei %s.\n"; +LAB_080c1d33: + // try { // try from 080c1d33 to 080c1dc3 has its CatchHandler @ 080c2050 + error(pcVar5,this->Name); + } + else { + pcVar5 = GetDynamicString(TD.Code); + if (pcVar5 == (char *)0x0) { + pcVar5 = "TCreature::Execute: Text ist NULL bei %s.\n"; + goto LAB_080c1d33; } - goto LAB_080c3721; } - puVar3 = (undefined4 *)__cxa_allocate_exception(4); - *puVar3 = 0x17; + pcVar5 = GetDynamicString(TD.Code); + Addressee = GetDynamicString(TD.field_1.Trade.Partner); + Talk(this->ID,TD.field_1.Go.x,Addressee,pcVar5,SUB41(TD.field_1.Go.z,0)); + break; + case TDChangeState: + if (this->Type == NPC) { + ChangeNPCState(this,TD.Code,true); + } } - } - else { - puVar3 = (undefined4 *)__cxa_allocate_exception(4); - *puVar3 = 1; - } - // WARNING: Subroutine does not return - __cxa_throw(puVar3,&RESULT::typeinfo,0); -} - - - -// WARNING: Type propagation algorithm not settling -// DWARF original prototype: void ToDoAttack(TCreature * this) - -void __thiscall TCreature::ToDoAttack(TCreature *this) - -{ - bool bVar1; - int iVar2; - TToDoEntry *pTVar3; - TToDoEntry TD; - - // try { // try from 080c3888 to 080c3928 has its CatchHandler @ 080c3930 - TCombat::CanToDoAttack(&this->Combat); - iVar2 = TCombat::GetDistance(&this->Combat); - if (iVar2 != 1) { - ToDoWait(this,100); - } - if (this->LockToDo != false) { - bVar1 = ToDoClear(this); - if ((bVar1) && (this->Type == PLAYER)) { - SendSnapback(this->Connection); + if (this->Stop != false) { + ToDoClear(this); + if (this->Type == PLAYER) { + SendSnapback(this->Connection); + } + return; } - } - pTVar3 = vector::operator()(&this->ToDoList,this->NrToDo); - pTVar3->Code = TDAttack; - (pTVar3->field_1).Move.Obj = TD.Code; - ((anon_struct_4_1_898373eb_for_Wait *)((int)&pTVar3->field_1 + 4))->Time = - (ulong)TD.field_1.Wait.Time; - (pTVar3->field_1).Go.z = TD.field_1.Go.y; - (pTVar3->field_1).Move.z = TD.field_1.Go.z; - (pTVar3->field_1).Move.Count = TD.field_1.Move.z; - this->NrToDo = this->NrToDo + 1; - return; + } while( true ); } - - // WARNING: Unknown calling convention -- yet parameter storage is locked void _GLOBAL__I__ZN9TShortwayC2EP9TCreatureii(void) -- cgit v1.2.3