From 3f557369c7bbd08fdf2e6dbd9271873b20a9a144 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Sat, 24 May 2025 20:57:24 -0300 Subject: halfway of `map.cc` and start of `objects.cc` --- reference/game.c | 5443 ++++++++++++------------------------------------------ 1 file changed, 1138 insertions(+), 4305 deletions(-) (limited to 'reference/game.c') diff --git a/reference/game.c b/reference/game.c index 1df63aa..1a48631 100644 --- a/reference/game.c +++ b/reference/game.c @@ -4965,173 +4965,6 @@ bool ObjectTypeExists(uchar Group,uchar Number) return (bool)((byte)~(byte)((uint)NewType[CONCAT11(Group,Number)] >> 0x18) >> 7); } - - -// DWARF original prototype: void setTypeID(ObjectType * this, int _TypeID) - -void __thiscall ObjectType::setTypeID(ObjectType *this,int _TypeID) - -{ - bool bVar1; - - bVar1 = false; - if ((ObjectTypes.min <= _TypeID) && (_TypeID <= ObjectTypes.max)) { - bVar1 = true; - } - if (!bVar1) { - error(&DAT_080f0a80,_TypeID); - _TypeID = 0; - } - this->TypeID = _TypeID; - return; -} - - - -// DWARF original prototype: char * getName(ObjectType * this, int Count) - -char * __thiscall ObjectType::getName(ObjectType *this) - -{ - char *pcVar1; - TObjectType *pTVar2; - int in_stack_00000008; - char local_4c [4]; - char ObjectName [50]; - - local_4c[0] = '\0'; - if (this->TypeID == 99) { - error("ObjectType::getName: Der Kreaturtyp hat keinen Namen.\n"); - pcVar1 = (char *)0x0; - } - else { - pTVar2 = vector<>::operator()(&ObjectTypes,this->TypeID); - if (pTVar2->Name != (char *)0x0) { - strcpy(local_4c,pTVar2->Name); - } - pcVar1 = Plural(local_4c,in_stack_00000008); - } - return pcVar1; -} - - - -// DWARF original prototype: char * getDescription(ObjectType * this) - -char * __thiscall ObjectType::getDescription(ObjectType *this) - -{ - TObjectType *pTVar1; - - pTVar1 = vector<>::operator()(&ObjectTypes,this->TypeID); - return pTVar1->Description; -} - - - -// DWARF original prototype: bool getFlag(ObjectType * this, FLAG Flag) - -bool __thiscall ObjectType::getFlag(ObjectType *this,FLAG Flag) - -{ - uint uVar1; - TObjectType *pTVar2; - FLAG FVar3; - uchar b; - - FVar3 = Flag + USEEVENT; - if (-1 < (int)Flag) { - FVar3 = Flag; - } - uVar1 = 1 << ((char)Flag + (char)((int)FVar3 >> 3) * -8 & 0x1fU); - pTVar2 = vector<>::operator()(&ObjectTypes,this->TypeID); - return (uint)(pTVar2->Flags[(int)FVar3 >> 3] & (byte)uVar1) == (uVar1 & 0xff); -} - - - -// DWARF original prototype: ulong getAttribute(ObjectType * this, TYPEATTRIBUTE Attribute) - -ulong __thiscall ObjectType::getAttribute(ObjectType *this,TYPEATTRIBUTE Attribute) - -{ - FLAG FVar1; - uint uVar2; - TObjectType *pTVar3; - ulong uVar4; - FLAG FVar5; - uchar b; - - FVar1 = TypeAttributeFlags[Attribute]; - FVar5 = FVar1 + USEEVENT; - if (-1 < (int)FVar1) { - FVar5 = FVar1; - } - uVar2 = 1 << ((char)FVar1 + (char)((int)FVar5 >> 3) * -8 & 0x1fU); - pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); - if ((uint)(pTVar3->Flags[(int)FVar5 >> 3] & (byte)uVar2) == (uVar2 & 0xff)) { - pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); - uVar4 = pTVar3->Attributes[Attribute]; - } - else { - error(&DAT_080f0c60,this->TypeID,TypeAttributeFlags[Attribute],Attribute); - uVar4 = 0; - } - return uVar4; -} - - - -// DWARF original prototype: int getAttributeOffset(ObjectType * this, INSTANCEATTRIBUTE Attribute) - -int __thiscall ObjectType::getAttributeOffset(ObjectType *this,INSTANCEATTRIBUTE Attribute) - -{ - FLAG FVar1; - uint uVar2; - TObjectType *pTVar3; - int iVar4; - FLAG FVar5; - uchar b; - - FVar1 = InstanceAttributeFlags[Attribute]; - FVar5 = FVar1 + USEEVENT; - if (-1 < (int)FVar1) { - FVar5 = FVar1; - } - uVar2 = 1 << ((char)FVar1 + (char)((int)FVar5 >> 3) * -8 & 0x1fU); - pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); - if ((uint)(pTVar3->Flags[(int)FVar5 >> 3] & (byte)uVar2) == (uVar2 & 0xff)) { -LAB_08055e2a: - pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); - iVar4 = pTVar3->AttributeOffsets[Attribute]; - } - else { - if (Attribute == CONTENT) { - pTVar3 = vector<>::operator()(&ObjectTypes,this->TypeID); - if ((pTVar3->Flags[0] & 0x20) != 0) goto LAB_08055e2a; - } - iVar4 = -1; - } - return iVar4; -} - - - -bool ObjectTypeExists(int TypeID) - -{ - bool bVar1; - - bVar1 = false; - if ((ObjectTypes.min <= TypeID) && (TypeID <= ObjectTypes.max)) { - bVar1 = true; - } - return bVar1; -} - - - ObjectType GetSpecialObject(SPECIALMEANING Meaning) { @@ -5359,232 +5192,299 @@ void __static_initialization_and_destruction_0(int __initialize_p,int __priority return; } +void CronMove(int Destination,int Source) + +{ + int iVar1; + uint uVar2; + TCronEntry *pTVar3; + TCronEntry *pTVar4; + TCronEntry *Entry; + undefined8 local_34; + int iStack_30; + + pTVar3 = vector::operator()(&CronEntry,Destination); + pTVar4 = vector::operator()(&CronEntry,Source); + (pTVar3->Obj).ObjectID = (pTVar4->Obj).ObjectID; + pTVar3->RoundNr = pTVar4->RoundNr; + iVar1 = pTVar4->Next; + pTVar3->Previous = pTVar4->Previous; + pTVar3->Next = iVar1; + pTVar3 = vector::operator()(&CronEntry,Destination); + if (pTVar3->Next != -1) { + pTVar4 = vector::operator()(&CronEntry,pTVar3->Next); + pTVar4->Previous = Destination; + } + if (pTVar3->Previous != -1) { + pTVar4 = vector::operator()(&CronEntry,pTVar3->Previous); + iVar1 = pTVar3->Previous; + pTVar4->Next = Destination; + if (iVar1 != -1) { + return; + } + } + uVar2 = (pTVar3->Obj).ObjectID; + CronHashTable + [uVar2 + ((uVar2 - (int)((ulonglong)uVar2 * 0x200401 >> 0x20) >> 1) + iStack_30 >> 10) * -0x7ff] + = Destination; + return; +} + -TObject * AccessObject(Object *Obj) +void CronHeapify(int Position) { - TObject *pTVar1; - ulong Position; - uint uVar2; + int i; + TCronEntry *pTVar1; + TCronEntry *pTVar2; + int Father; + int iVar3; - if (Obj->ObjectID == NONE.ObjectID) { - error(&DAT_080f1200); - pTVar1 = (TObject *)*HashTableData; + while (Position != 1) { + pTVar1 = vector::operator()(&CronEntry,Position); + iVar3 = Position / 2; + pTVar2 = vector::operator()(&CronEntry,iVar3); + if (pTVar2->RoundNr <= pTVar1->RoundNr) break; + CronMove(0,Position); + CronMove(Position,iVar3); + CronMove(iVar3,0); + Position = iVar3; } - else { - uVar2 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar2] == '\x02') { - UnswapSector(HashTableData[uVar2]); + while( true ) { + iVar3 = Position * 2; + if (CronEntries < iVar3) { + return; } - if ((HashTableType[uVar2] != '\x01') || - (pTVar1 = (TObject *)HashTableData[uVar2], pTVar1->ObjectID != Obj->ObjectID)) { - pTVar1 = (TObject *)*HashTableData; + i = iVar3 + 1; + if (i <= CronEntries) { + pTVar1 = vector::operator()(&CronEntry,i); + pTVar2 = vector::operator()(&CronEntry,iVar3); + if (pTVar1->RoundNr < pTVar2->RoundNr) { + iVar3 = i; + } } + pTVar1 = vector::operator()(&CronEntry,Position); + pTVar2 = vector::operator()(&CronEntry,iVar3); + if (pTVar1->RoundNr <= pTVar2->RoundNr) break; + CronMove(0,Position); + CronMove(Position,iVar3); + CronMove(iVar3,0); + Position = iVar3; } - return pTVar1; + return; } -// DWARF original prototype: bool exists(Object * this) - -bool __thiscall Object::exists(Object *this) +void CronSet(Object *Obj,ulong Delay) { bool bVar1; + int i; + TCronEntry *pTVar2; ulong Position; - uint uVar2; + uint uVar3; bVar1 = false; - if (this->ObjectID != 0) { - uVar2 = this->ObjectID & HashTableMask; - if (HashTableType[uVar2] == '\x02') { - UnswapSector(HashTableData[uVar2]); + if (Obj->ObjectID != 0) { + uVar3 = Obj->ObjectID & HashTableMask; + if (HashTableType[uVar3] == '\x02') { + UnswapSector(HashTableData[uVar3]); } - if ((HashTableType[uVar2] == '\x01') && (*(ulong *)HashTableData[uVar2] == this->ObjectID)) - { + if ((HashTableType[uVar3] == '\x01') && (*(ulong *)HashTableData[uVar3] == Obj->ObjectID)) { bVar1 = true; } else { bVar1 = false; } } - return bVar1; -} - - - -// DWARF original prototype: ObjectType getObjectType(Object * this) - -ObjectType __thiscall Object::getObjectType(Object *this) - -{ - TObject *pTVar1; - ulong *in_stack_00000008; - Object local_1c [5]; - - local_1c[0].ObjectID = *in_stack_00000008; - pTVar1 = AccessObject(local_1c); - ObjectType::setTypeID((ObjectType *)this,(pTVar1->Type).TypeID); - return (ObjectType)(int)this; + if (bVar1) { + CronEntries = CronEntries + 1; + pTVar2 = vector::operator()(&CronEntry,CronEntries); + (pTVar2->Obj).ObjectID = Obj->ObjectID; + pTVar2 = vector::operator()(&CronEntry,CronEntries); + pTVar2->RoundNr = Delay + RoundNr; + pTVar2 = vector::operator()(&CronEntry,CronEntries); + pTVar2->Previous = -1; + pTVar2 = vector::operator()(&CronEntry,CronEntries); + pTVar2->Next = CronHashTable[Obj->ObjectID % 0x7ff]; + i = CronEntries; + CronHashTable[Obj->ObjectID % 0x7ff] = CronEntries; + pTVar2 = vector::operator()(&CronEntry,i); + if (pTVar2->Next != -1) { + pTVar2 = vector::operator()(&CronEntry,CronEntries); + pTVar2 = vector::operator()(&CronEntry,pTVar2->Next); + pTVar2->Previous = CronEntries; + } + CronHeapify(CronEntries); + } + else { + error(&DAT_080f1480); + } + return; } -// DWARF original prototype: ulong getAttribute(Object * this, INSTANCEATTRIBUTE Attribute) - -ulong __thiscall Object::getAttribute(Object *this,INSTANCEATTRIBUTE Attribute) +void CronDelete(int Position) { - bool bVar1; - TObject *pTVar2; - int iVar3; - int Offset; - Object local_3c [4]; - Object local_2c [7]; + uint uVar1; + int iVar2; + bool bVar3; + TCronEntry *pTVar4; + TCronEntry *pTVar5; + TCronEntry *Entry; + undefined8 local_1c; + int iStack_18; - local_3c[0] = (Object)this->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); - iVar3 = ObjectType::getAttributeOffset((ObjectType *)local_2c,Attribute); - if (iVar3 == -1) { - local_2c[0] = (Object)this->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - error(&DAT_080f12a0,Attribute,local_3c[0].ObjectID); + bVar3 = false; + if ((0 < Position) && (Position <= CronEntries)) { + bVar3 = true; } - else { - bVar1 = false; - if ((-1 < iVar3) && (iVar3 < 4)) { - bVar1 = true; - } - if (bVar1) { - local_3c[0] = (Object)this->ObjectID; - pTVar2 = AccessObject(local_3c); - return pTVar2->Attributes[iVar3]; - } - local_2c[0] = (Object)this->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - error(&DAT_080f1240,iVar3,Attribute,local_3c[0].ObjectID); + if (!bVar3) { + error(&DAT_080f14c0,Position); + return; } - return 0; -} - - - -// DWARF original prototype: void setAttribute(Object * this, INSTANCEATTRIBUTE Attribute, ulong -// Value) - -void __thiscall Object::setAttribute(Object *this,INSTANCEATTRIBUTE Attribute,ulong Value) - -{ - bool bVar1; - TObject *pTVar2; - int iVar3; - int Offset; - Object local_3c [4]; - Object local_2c [7]; - - local_3c[0] = (Object)this->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); - iVar3 = ObjectType::getAttributeOffset((ObjectType *)local_2c,Attribute); - if (iVar3 == -1) { - local_2c[0] = (Object)this->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - error(&DAT_080f1360,Attribute,local_3c[0].ObjectID); + pTVar4 = vector::operator()(&CronEntry,Position); + if (pTVar4->Next != -1) { + pTVar5 = vector::operator()(&CronEntry,pTVar4->Next); + pTVar5->Previous = pTVar4->Previous; } - else { - bVar1 = false; - if ((-1 < iVar3) && (iVar3 < 4)) { - bVar1 = true; - } - if (bVar1) { - if (Value == 0) { - if (((Attribute == AMOUNT) || (Attribute == POOLLIQUIDTYPE)) || - (Attribute == CHARGES)) { - Value = 1; - } - if ((Value == 0) && (Attribute == REMAININGUSES)) { - local_2c[0] = (Object)this->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - Value = ObjectType::getAttribute((ObjectType *)local_3c,TOTALUSES); - } - } - local_3c[0] = (Object)this->ObjectID; - pTVar2 = AccessObject(local_3c); - pTVar2->Attributes[iVar3] = Value; - } - else { - local_2c[0] = (Object)this->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - error(&DAT_080f1300,iVar3,Attribute,local_3c[0].ObjectID); - } + if (pTVar4->Previous != -1) { + pTVar5 = vector::operator()(&CronEntry,pTVar4->Previous); + iVar2 = pTVar4->Previous; + pTVar5->Next = pTVar4->Next; + if (iVar2 != -1) goto LAB_08057e24; + } + uVar1 = (pTVar4->Obj).ObjectID; + CronHashTable + [uVar1 + ((uVar1 - (int)((ulonglong)uVar1 * 0x200401 >> 0x20) >> 1) + iStack_18 >> 10) * -0x7ff] + = pTVar4->Next; +LAB_08057e24: + iVar2 = CronEntries; + CronEntries = CronEntries + -1; + if (CronEntries < Position) { + return; } + CronMove(Position,iVar2); + CronHeapify(Position); return; } -// DWARF original prototype: Object getNextObject(Object * this) +// WARNING: Unknown calling convention -- yet parameter storage is locked -Object __thiscall Object::getNextObject(Object *this) +Object CronCheck(void) { - TObject *pTVar1; - ulong *in_stack_00000008; - Object local_1c [5]; + Object OVar1; + TCronEntry *pTVar2; + ulong *in_stack_00000004; - local_1c[0].ObjectID = *in_stack_00000008; - pTVar1 = AccessObject(local_1c); - this->ObjectID = (pTVar1->NextObject).ObjectID; - return (Object)(ulong)this; + OVar1.ObjectID = NONE.ObjectID; + if ((CronEntries != 0) && + (pTVar2 = vector::operator()(&CronEntry,1), OVar1 = NONE, + pTVar2->RoundNr <= RoundNr)) { + pTVar2 = vector::operator()(&CronEntry,1); + OVar1.ObjectID = (pTVar2->Obj).ObjectID; + } + *in_stack_00000004 = OVar1.ObjectID; + return (Object)(ulong)in_stack_00000004; } -// DWARF original prototype: Object getContainer(Object * this) - -Object __thiscall Object::getContainer(Object *this) +ulong CronInfo(Object *Obj,bool Delete) { - TObject *pTVar1; - ulong *in_stack_00000008; - Object local_1c [5]; + bool bVar1; + TCronEntry *pTVar2; + int Position; + uint uVar3; + int i; + ulong uVar4; + char *Text; + undefined8 local_44; + int iStack_40; + bool Delete_local; - local_1c[0].ObjectID = *in_stack_00000008; - pTVar1 = AccessObject(local_1c); - this->ObjectID = (pTVar1->Container).ObjectID; - return (Object)(ulong)this; + bVar1 = false; + if (Obj->ObjectID != 0) { + uVar3 = Obj->ObjectID & HashTableMask; + if (HashTableType[uVar3] == '\x02') { + UnswapSector(HashTableData[uVar3]); + } + if ((HashTableType[uVar3] == '\x01') && (*(ulong *)HashTableData[uVar3] == Obj->ObjectID)) { + bVar1 = true; + } + else { + bVar1 = false; + } + } + if (bVar1) { + uVar3 = Obj->ObjectID; + i = CronHashTable + [uVar3 + ((uVar3 - (int)((ulonglong)uVar3 * 0x200401 >> 0x20) >> 1) + iStack_40 >> 10) * + -0x7ff]; + while (i != -1) { + pTVar2 = vector::operator()(&CronEntry,i); + if ((pTVar2->Obj).ObjectID == Obj->ObjectID) { + pTVar2 = vector::operator()(&CronEntry,i); + uVar4 = pTVar2->RoundNr - RoundNr; + if ((int)uVar4 < 1) { + uVar4 = 1; + } + if (!Delete) { + return uVar4; + } + CronDelete(i); + return uVar4; + } + pTVar2 = vector::operator()(&CronEntry,i); + i = pTVar2->Next; + } + Text = "CronInfo: Objekt ist nicht im Cron-System eingetragen.\n"; + } + else { + Text = &DAT_080f1540; + } + error(Text); + return 0; } -// DWARF original prototype: ulong getCreatureID(Object * this) - -ulong __thiscall Object::getCreatureID(Object *this) +ulong CronStop(Object *Obj) { - TObject *pTVar1; + bool bVar1; ulong uVar2; - Object local_3c [4]; - ObjectType local_2c [7]; + ulong Position; + uint uVar3; + Object local_1c [4]; - local_3c[0] = (Object)this->ObjectID; - pTVar1 = AccessObject(local_3c); - ObjectType::setTypeID(local_2c,(pTVar1->Type).TypeID); - if (local_2c[0].TypeID == 99) { - local_3c[0] = (Object)this->ObjectID; - pTVar1 = AccessObject(local_3c); - uVar2 = pTVar1->Attributes[1]; + bVar1 = false; + if (Obj->ObjectID != 0) { + uVar3 = Obj->ObjectID & HashTableMask; + if (HashTableType[uVar3] == '\x02') { + UnswapSector(HashTableData[uVar3]); + } + if ((HashTableType[uVar3] == '\x01') && (*(ulong *)HashTableData[uVar3] == Obj->ObjectID)) { + bVar1 = true; + } + else { + bVar1 = false; + } + } + if (bVar1) { + local_1c[0] = (Object)Obj->ObjectID; + uVar2 = CronInfo(local_1c,true); } else { - error("Object::getCreatureID: Objekt ist keine Kreatur.\n"); + error(&DAT_080f1580); uVar2 = 0; } return uVar2; @@ -5592,16 +5492,15 @@ ulong __thiscall Object::getCreatureID(Object *this) -void GetObjectCoordinates(Object *Obj,int *x,int *y,int *z) +void CronExpire(Object *Obj,int Delay) { bool bVar1; TObject *pTVar2; ulong Position; uint uVar3; - Object local_4c [4]; Object local_3c [4]; - ObjectType local_2c [7]; + Object local_2c [7]; bVar1 = false; if (Obj->ObjectID != 0) { @@ -5617,46 +5516,38 @@ void GetObjectCoordinates(Object *Obj,int *x,int *y,int *z) } } if (bVar1) { - while( true ) { + local_3c[0] = (Object)Obj->ObjectID; + pTVar2 = AccessObject(local_3c); + ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); + bVar1 = ObjectType::getFlag((ObjectType *)local_2c,EXPIRE); + if (bVar1) { + if (Delay == -1) { + local_2c[0] = (Object)Obj->ObjectID; + pTVar2 = AccessObject(local_2c); + ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); + Delay = ObjectType::getAttribute((ObjectType *)local_3c,TOTALEXPIRETIME); + } local_3c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID(local_2c,(pTVar2->Type).TypeID); - if (local_2c[0].TypeID == 0) break; - local_4c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_4c); - local_2c[0].TypeID = (pTVar2->Container).ObjectID; - Obj->ObjectID = local_2c[0].TypeID; + CronSet(local_3c,Delay); } - local_4c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_4c); - *x = pTVar2->Attributes[1]; - local_4c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_4c); - *y = pTVar2->Attributes[2]; - local_4c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_4c); - *z = (uint)(byte)pTVar2->Attributes[3]; } else { - error(&DAT_080f1400); - *x = 0; - *y = 0; - *z = 0; + error(&DAT_080f15c0); } return; } -uchar GetMapContainerFlags(Object *Obj) +void CronChange(Object *Obj,int NewDelay) { bool bVar1; - TObject *pTVar2; - ulong Position; + TCronEntry *pTVar2; + int Position; uint uVar3; - Object local_3c [4]; - ObjectType local_2c [7]; + int i; + char *Text; bVar1 = false; if (Obj->ObjectID != 0) { @@ -5672,122 +5563,248 @@ uchar GetMapContainerFlags(Object *Obj) } } if (bVar1) { - local_3c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID(local_2c,(pTVar2->Type).TypeID); - if (local_2c[0].TypeID == 0) { - local_3c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_3c); - return *(uchar *)((int)pTVar2->Attributes + 0xd); + i = CronHashTable[Obj->ObjectID % 0x7ff]; + while (i != -1) { + pTVar2 = vector::operator()(&CronEntry,i); + if ((pTVar2->Obj).ObjectID == Obj->ObjectID) { + pTVar2 = vector::operator()(&CronEntry,i); + pTVar2->RoundNr = NewDelay + RoundNr; + CronHeapify(i); + return; + } + pTVar2 = vector::operator()(&CronEntry,i); + i = pTVar2->Next; } + Text = "CronChange: Objekt ist nicht im Cron-System eingetragen.\n"; + } + else { + Text = &DAT_080f1640; } - error("GetMapContainerFlags: Objekt ist kein MapContainer.\n"); - return '\0'; + error(Text); + return; } -void CronMove(int Destination,int Source) +Object SplitObject(Object *Obj,int Count) { - int iVar1; - uint uVar2; - TCronEntry *pTVar3; - TCronEntry *pTVar4; - TCronEntry *Entry; - undefined8 local_34; - int iStack_30; + bool bVar1; + TObject *pTVar2; + ulong uVar3; + ulong Position; + uint uVar4; + ulong in_stack_0000000c; + Object local_5c [4]; + Object local_4c [4]; + Object local_3c; + Object Copy; + ObjectType local_2c [7]; - pTVar3 = vector::operator()(&CronEntry,Destination); - pTVar4 = vector::operator()(&CronEntry,Source); - (pTVar3->Obj).ObjectID = (pTVar4->Obj).ObjectID; - pTVar3->RoundNr = pTVar4->RoundNr; - iVar1 = pTVar4->Next; - pTVar3->Previous = pTVar4->Previous; - pTVar3->Next = iVar1; - pTVar3 = vector::operator()(&CronEntry,Destination); - if (pTVar3->Next != -1) { - pTVar4 = vector::operator()(&CronEntry,pTVar3->Next); - pTVar4->Previous = Destination; - } - if (pTVar3->Previous != -1) { - pTVar4 = vector::operator()(&CronEntry,pTVar3->Previous); - iVar1 = pTVar3->Previous; - pTVar4->Next = Destination; - if (iVar1 != -1) { - return; + bVar1 = false; + if (*(uint *)Count != 0) { + uVar4 = *(uint *)Count & HashTableMask; + if (HashTableType[uVar4] == '\x02') { + UnswapSector(HashTableData[uVar4]); + } + if ((HashTableType[uVar4] == '\x01') && (*(int *)HashTableData[uVar4] == *(int *)Count)) { + bVar1 = true; + } + else { + bVar1 = false; } } - uVar2 = (pTVar3->Obj).ObjectID; - CronHashTable - [uVar2 + ((uVar2 - (int)((ulonglong)uVar2 * 0x200401 >> 0x20) >> 1) + iStack_30 >> 10) * -0x7ff] - = Destination; - return; + if (!bVar1) { + error(&DAT_080f1680); + local_3c = NONE; + goto LAB_08058380; + } + local_3c.ObjectID = *(ulong *)Count; + pTVar2 = AccessObject(&local_3c); + ObjectType::setTypeID(local_2c,(pTVar2->Type).TypeID); + bVar1 = ObjectType::getFlag(local_2c,CUMULATIVE); + if (bVar1) { + if (0 < (int)in_stack_0000000c) { + uVar3 = Object::getAttribute((Object *)Count,AMOUNT); + if ((int)in_stack_0000000c <= (int)uVar3) { + uVar3 = Object::getAttribute((Object *)Count,AMOUNT); + if (in_stack_0000000c != uVar3) { + local_5c[0].ObjectID = *(ulong *)Count; + local_2c[0].TypeID = local_5c[0].ObjectID; + pTVar2 = AccessObject(local_5c); + local_4c[0].ObjectID = (pTVar2->Container).ObjectID; + CopyObject(&local_3c,local_4c); + uVar3 = Object::getAttribute((Object *)Count,AMOUNT); + Object::setAttribute((Object *)Count,AMOUNT,uVar3 - in_stack_0000000c); + Object::setAttribute(&local_3c,AMOUNT,in_stack_0000000c); + goto LAB_08058380; + } + goto LAB_080583fc; + } + } + error(&DAT_080f16c0,in_stack_0000000c); + } + else { + error("SplitObject: Objekt ist nicht kumulierbar.\n"); + } +LAB_080583fc: + local_3c.ObjectID = *(ulong *)Count; +LAB_08058380: + Obj->ObjectID = (ulong)local_3c; + return (Object)(ulong)Obj; } -void CronHeapify(int Position) +void MergeObjects(Object *Obj,Object *Dest) { - int i; - TCronEntry *pTVar1; - TCronEntry *pTVar2; - int Father; - int iVar3; + Object OVar1; + bool bVar2; + TObject *pTVar3; + ulong uVar4; + ulong uVar5; + ulong Position; + uint uVar6; + char *Text; + Object local_6c [4]; + Object local_5c [4]; + Object local_4c [4]; + Object local_3c [4]; + ObjectType local_2c [7]; - while (Position != 1) { - pTVar1 = vector::operator()(&CronEntry,Position); - iVar3 = Position / 2; - pTVar2 = vector::operator()(&CronEntry,iVar3); - if (pTVar2->RoundNr <= pTVar1->RoundNr) break; - CronMove(0,Position); - CronMove(Position,iVar3); - CronMove(iVar3,0); - Position = iVar3; + bVar2 = false; + if (Obj->ObjectID != 0) { + uVar6 = Obj->ObjectID & HashTableMask; + if (HashTableType[uVar6] == '\x02') { + UnswapSector(HashTableData[uVar6]); + } + if ((HashTableType[uVar6] == '\x01') && (*(ulong *)HashTableData[uVar6] == Obj->ObjectID)) { + bVar2 = true; + } + else { + bVar2 = false; + } } - while( true ) { - iVar3 = Position * 2; - if (CronEntries < iVar3) { - return; + if (bVar2) { + bVar2 = false; + if (Dest->ObjectID != 0) { + uVar6 = Dest->ObjectID & HashTableMask; + if (HashTableType[uVar6] == '\x02') { + UnswapSector(HashTableData[uVar6]); + } + if ((HashTableType[uVar6] == '\x01') && + (*(ulong *)HashTableData[uVar6] == Dest->ObjectID)) { + bVar2 = true; + } + else { + bVar2 = false; + } } - i = iVar3 + 1; - if (i <= CronEntries) { - pTVar1 = vector::operator()(&CronEntry,i); - pTVar2 = vector::operator()(&CronEntry,iVar3); - if (pTVar1->RoundNr < pTVar2->RoundNr) { - iVar3 = i; + if (bVar2) { + local_3c[0] = (Object)Obj->ObjectID; + pTVar3 = AccessObject(local_3c); + ObjectType::setTypeID(local_2c,(pTVar3->Type).TypeID); + local_4c[0] = (Object)Dest->ObjectID; + pTVar3 = AccessObject(local_4c); + ObjectType::setTypeID((ObjectType *)local_3c,(pTVar3->Type).TypeID); + ObjectType::setTypeID((ObjectType *)local_4c,local_3c[0].ObjectID); + if (local_2c[0].TypeID != local_4c[0].ObjectID) { + local_5c[0] = (Object)Dest->ObjectID; + pTVar3 = AccessObject(local_5c); + ObjectType::setTypeID((ObjectType *)local_4c,(pTVar3->Type).TypeID); + OVar1.ObjectID = local_4c[0].ObjectID; + local_6c[0] = (Object)Obj->ObjectID; + pTVar3 = AccessObject(local_6c); + ObjectType::setTypeID((ObjectType *)local_5c,(pTVar3->Type).TypeID); + error("MergeObjects: Objekttypen %d und %d sind nicht identisch.\n", + local_5c[0].ObjectID,OVar1.ObjectID); + return; + } + local_5c[0] = (Object)Obj->ObjectID; + pTVar3 = AccessObject(local_5c); + ObjectType::setTypeID((ObjectType *)local_6c,(pTVar3->Type).TypeID); + bVar2 = ObjectType::getFlag((ObjectType *)local_6c,CUMULATIVE); + if (!bVar2) { + local_5c[0] = (Object)Obj->ObjectID; + pTVar3 = AccessObject(local_5c); + ObjectType::setTypeID((ObjectType *)local_6c,(pTVar3->Type).TypeID); + error("MergeObjects: Objekttyp %d/%d ist nicht kumulierbar.\n",local_6c[0].ObjectID) + ; + return; + } + uVar4 = Object::getAttribute(Obj,AMOUNT); + if (uVar4 == 0) { + error(&DAT_080f18c0); + Object::setAttribute(Obj,AMOUNT,1); + } + uVar4 = Object::getAttribute(Dest,AMOUNT); + if (uVar4 == 0) { + error(&DAT_080f1880); + Object::setAttribute(Dest,AMOUNT,1); + } + uVar4 = Object::getAttribute(Obj,AMOUNT); + uVar5 = Object::getAttribute(Dest,AMOUNT); + Object::setAttribute(Dest,AMOUNT,uVar5 + uVar4); + uVar4 = Object::getAttribute(Dest,AMOUNT); + if (100 < uVar4) { + error(&DAT_080f1840); + Object::setAttribute(Dest,AMOUNT,100); + } + local_6c[0] = (Object)Obj->ObjectID; + bVar2 = false; + if (local_6c[0].ObjectID != 0) { + uVar6 = local_6c[0].ObjectID & HashTableMask; + if (HashTableType[uVar6] == '\x02') { + UnswapSector(HashTableData[uVar6]); + } + if ((HashTableType[uVar6] == '\x01') && + (*(uint *)HashTableData[uVar6] == local_6c[0].ObjectID)) { + bVar2 = true; + } + else { + bVar2 = false; + } + } + if (bVar2) { + local_5c[0].ObjectID = local_6c[0].ObjectID; + CutObject(local_5c); + local_5c[0].ObjectID = local_6c[0].ObjectID; + DestroyObject(local_5c); + return; } + Text = &DAT_080f1800; } - pTVar1 = vector::operator()(&CronEntry,Position); - pTVar2 = vector::operator()(&CronEntry,iVar3); - if (pTVar1->RoundNr <= pTVar2->RoundNr) break; - CronMove(0,Position); - CronMove(Position,iVar3); - CronMove(iVar3,0); - Position = iVar3; + else { + Text = &DAT_080f1740; + } + } + else { + Text = &DAT_080f1900; } + error(Text); return; } -void CronSet(Object *Obj,ulong Delay) +void MoveObject(Object *Obj,Object *Con) { bool bVar1; - int i; - TCronEntry *pTVar2; ulong Position; - uint uVar3; + uint uVar2; + char *Text; + Object local_3c [4]; + Object local_2c [7]; bVar1 = false; if (Obj->ObjectID != 0) { - uVar3 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar3] == '\x02') { - UnswapSector(HashTableData[uVar3]); + uVar2 = Obj->ObjectID & HashTableMask; + if (HashTableType[uVar2] == '\x02') { + UnswapSector(HashTableData[uVar2]); } - if ((HashTableType[uVar3] == '\x01') && (*(ulong *)HashTableData[uVar3] == Obj->ObjectID)) { + if ((HashTableType[uVar2] == '\x01') && (*(ulong *)HashTableData[uVar2] == Obj->ObjectID)) { bVar1 = true; } else { @@ -5795,215 +5812,89 @@ void CronSet(Object *Obj,ulong Delay) } } if (bVar1) { - CronEntries = CronEntries + 1; - pTVar2 = vector::operator()(&CronEntry,CronEntries); - (pTVar2->Obj).ObjectID = Obj->ObjectID; - pTVar2 = vector::operator()(&CronEntry,CronEntries); - pTVar2->RoundNr = Delay + RoundNr; - pTVar2 = vector::operator()(&CronEntry,CronEntries); - pTVar2->Previous = -1; - pTVar2 = vector::operator()(&CronEntry,CronEntries); - pTVar2->Next = CronHashTable[Obj->ObjectID % 0x7ff]; - i = CronEntries; - CronHashTable[Obj->ObjectID % 0x7ff] = CronEntries; - pTVar2 = vector::operator()(&CronEntry,i); - if (pTVar2->Next != -1) { - pTVar2 = vector::operator()(&CronEntry,CronEntries); - pTVar2 = vector::operator()(&CronEntry,pTVar2->Next); - pTVar2->Previous = CronEntries; + bVar1 = false; + if (Con->ObjectID != 0) { + uVar2 = Con->ObjectID & HashTableMask; + if (HashTableType[uVar2] == '\x02') { + UnswapSector(HashTableData[uVar2]); + } + if ((HashTableType[uVar2] == '\x01') && + (*(ulong *)HashTableData[uVar2] == Con->ObjectID)) { + bVar1 = true; + } + else { + bVar1 = false; + } } - CronHeapify(CronEntries); - } - else { - error(&DAT_080f1480); - } - return; -} - - - -void CronDelete(int Position) - -{ - uint uVar1; - int iVar2; - bool bVar3; - TCronEntry *pTVar4; - TCronEntry *pTVar5; - TCronEntry *Entry; - undefined8 local_1c; - int iStack_18; - - bVar3 = false; - if ((0 < Position) && (Position <= CronEntries)) { - bVar3 = true; - } - if (!bVar3) { - error(&DAT_080f14c0,Position); - return; - } - pTVar4 = vector::operator()(&CronEntry,Position); - if (pTVar4->Next != -1) { - pTVar5 = vector::operator()(&CronEntry,pTVar4->Next); - pTVar5->Previous = pTVar4->Previous; - } - if (pTVar4->Previous != -1) { - pTVar5 = vector::operator()(&CronEntry,pTVar4->Previous); - iVar2 = pTVar4->Previous; - pTVar5->Next = pTVar4->Next; - if (iVar2 != -1) goto LAB_08057e24; - } - uVar1 = (pTVar4->Obj).ObjectID; - CronHashTable - [uVar1 + ((uVar1 - (int)((ulonglong)uVar1 * 0x200401 >> 0x20) >> 1) + iStack_18 >> 10) * -0x7ff] - = pTVar4->Next; -LAB_08057e24: - iVar2 = CronEntries; - CronEntries = CronEntries + -1; - if (CronEntries < Position) { - return; - } - CronMove(Position,iVar2); - CronHeapify(Position); - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -Object CronCheck(void) - -{ - Object OVar1; - TCronEntry *pTVar2; - ulong *in_stack_00000004; - - OVar1.ObjectID = NONE.ObjectID; - if ((CronEntries != 0) && - (pTVar2 = vector::operator()(&CronEntry,1), OVar1 = NONE, - pTVar2->RoundNr <= RoundNr)) { - pTVar2 = vector::operator()(&CronEntry,1); - OVar1.ObjectID = (pTVar2->Obj).ObjectID; - } - *in_stack_00000004 = OVar1.ObjectID; - return (Object)(ulong)in_stack_00000004; -} - - - -ulong CronInfo(Object *Obj,bool Delete) - -{ - bool bVar1; - TCronEntry *pTVar2; - int Position; - uint uVar3; - int i; - ulong uVar4; - char *Text; - undefined8 local_44; - int iStack_40; - bool Delete_local; - - bVar1 = false; - if (Obj->ObjectID != 0) { - uVar3 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar3] == '\x02') { - UnswapSector(HashTableData[uVar3]); - } - if ((HashTableType[uVar3] == '\x01') && (*(ulong *)HashTableData[uVar3] == Obj->ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (bVar1) { - uVar3 = Obj->ObjectID; - i = CronHashTable - [uVar3 + ((uVar3 - (int)((ulonglong)uVar3 * 0x200401 >> 0x20) >> 1) + iStack_40 >> 10) * - -0x7ff]; - while (i != -1) { - pTVar2 = vector::operator()(&CronEntry,i); - if ((pTVar2->Obj).ObjectID == Obj->ObjectID) { - pTVar2 = vector::operator()(&CronEntry,i); - uVar4 = pTVar2->RoundNr - RoundNr; - if ((int)uVar4 < 1) { - uVar4 = 1; - } - if (!Delete) { - return uVar4; - } - CronDelete(i); - return uVar4; - } - pTVar2 = vector::operator()(&CronEntry,i); - i = pTVar2->Next; + if (bVar1) { + local_2c[0] = (Object)Obj->ObjectID; + CutObject(local_2c); + local_2c[0] = (Object)Con->ObjectID; + local_3c[0] = (Object)Obj->ObjectID; + PlaceObject(local_3c,local_2c,false); + return; } - Text = "CronInfo: Objekt ist nicht im Cron-System eingetragen.\n"; + Text = &DAT_080f1940; } else { - Text = &DAT_080f1540; + Text = &DAT_080f1980; } error(Text); - return 0; + return; } +// WARNING: Variable defined which should be unmapped: Attribute_local -ulong CronStop(Object *Obj) +void ChangeObject(Object *Obj,INSTANCEATTRIBUTE Attribute,ulong Value) { bool bVar1; - ulong uVar2; ulong Position; - uint uVar3; - Object local_1c [4]; + uint uVar2; + INSTANCEATTRIBUTE Attribute_local; bVar1 = false; if (Obj->ObjectID != 0) { - uVar3 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar3] == '\x02') { - UnswapSector(HashTableData[uVar3]); + uVar2 = Obj->ObjectID & HashTableMask; + if (HashTableType[uVar2] == '\x02') { + UnswapSector(HashTableData[uVar2]); } - if ((HashTableType[uVar3] == '\x01') && (*(ulong *)HashTableData[uVar3] == Obj->ObjectID)) { + if ((HashTableType[uVar2] == '\x01') && (*(ulong *)HashTableData[uVar2] == Obj->ObjectID)) { bVar1 = true; } else { bVar1 = false; } } - if (bVar1) { - local_1c[0] = (Object)Obj->ObjectID; - uVar2 = CronInfo(local_1c,true); - } - else { - error(&DAT_080f1580); - uVar2 = 0; + if (!bVar1) { + error(&DAT_080f19c0); + return; } - return uVar2; + Object::setAttribute(Obj,Attribute,Value); + return; } - - -void CronExpire(Object *Obj,int Delay) +Object SetObject(Object *Con,ObjectType *Type,ulong CreatureID) { bool bVar1; TObject *pTVar2; ulong Position; uint uVar3; + ulong in_stack_00000010; + Object local_4c [4]; Object local_3c [4]; - Object local_2c [7]; + ulong local_2c; + Object Obj; bVar1 = false; - if (Obj->ObjectID != 0) { - uVar3 = Obj->ObjectID & HashTableMask; + if (Type->TypeID != 0) { + uVar3 = Type->TypeID & HashTableMask; if (HashTableType[uVar3] == '\x02') { UnswapSector(HashTableData[uVar3]); } - if ((HashTableType[uVar3] == '\x01') && (*(ulong *)HashTableData[uVar3] == Obj->ObjectID)) { + if ((HashTableType[uVar3] == '\x01') && (*(int *)HashTableData[uVar3] == Type->TypeID)) { bVar1 = true; } else { @@ -6011,46 +5902,60 @@ void CronExpire(Object *Obj,int Delay) } } if (bVar1) { - local_3c[0] = (Object)Obj->ObjectID; + CreateObject(); + ObjectType::setTypeID((ObjectType *)local_3c,*(int *)CreatureID); + local_4c[0].ObjectID = local_2c; + ChangeObject(local_4c,(ObjectType *)local_3c); + local_4c[0].ObjectID = Type->TypeID; + local_3c[0].ObjectID = local_2c; + PlaceObject(local_3c,local_4c,false); + local_3c[0].ObjectID = local_2c; pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_2c,EXPIRE); - if (bVar1) { - if (Delay == -1) { - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - Delay = ObjectType::getAttribute((ObjectType *)local_3c,TOTALEXPIRETIME); + ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); + if (local_4c[0].ObjectID == 99) { + if (in_stack_00000010 == 0) { + error(&DAT_080f1d60); } - local_3c[0] = (Object)Obj->ObjectID; - CronSet(local_3c,Delay); + local_4c[0].ObjectID = local_2c; + pTVar2 = AccessObject(local_4c); + pTVar2->Attributes[1] = in_stack_00000010; } } else { - error(&DAT_080f15c0); + error(&DAT_080f1d20); + local_2c = NONE.ObjectID; } - return; + Con->ObjectID = local_2c; + return (Object)(ulong)Con; } -void CronChange(Object *Obj,int NewDelay) +Object CopyObject(Object *Con,Object *Source) { bool bVar1; - TCronEntry *pTVar2; - int Position; - uint uVar3; - int i; - char *Text; + TObject *pTVar2; + TObject *pTVar3; + ulong uVar4; + ulong Position; + uint uVar5; + int iVar6; + uint *in_stack_0000000c; + char *pcVar7; + Object local_4c [4]; + Object local_3c; + Object Obj; + Object local_2c [7]; bVar1 = false; - if (Obj->ObjectID != 0) { - uVar3 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar3] == '\x02') { - UnswapSector(HashTableData[uVar3]); + if (*in_stack_0000000c != 0) { + uVar5 = *in_stack_0000000c & HashTableMask; + if (HashTableType[uVar5] == '\x02') { + UnswapSector(HashTableData[uVar5]); } - if ((HashTableType[uVar3] == '\x01') && (*(ulong *)HashTableData[uVar3] == Obj->ObjectID)) { + if ((HashTableType[uVar5] == '\x01') && + (*(uint *)HashTableData[uVar5] == *in_stack_0000000c)) { bVar1 = true; } else { @@ -6058,51 +5963,117 @@ void CronChange(Object *Obj,int NewDelay) } } if (bVar1) { - i = CronHashTable[Obj->ObjectID % 0x7ff]; - while (i != -1) { - pTVar2 = vector::operator()(&CronEntry,i); - if ((pTVar2->Obj).ObjectID == Obj->ObjectID) { - pTVar2 = vector::operator()(&CronEntry,i); - pTVar2->RoundNr = NewDelay + RoundNr; - CronHeapify(i); - return; - } - pTVar2 = vector::operator()(&CronEntry,i); - i = pTVar2->Next; + bVar1 = false; + if (Source->ObjectID != 0) { + uVar5 = Source->ObjectID & HashTableMask; + if (HashTableType[uVar5] == '\x02') { + UnswapSector(HashTableData[uVar5]); + } + if ((HashTableType[uVar5] == '\x01') && + (*(ulong *)HashTableData[uVar5] == Source->ObjectID)) { + bVar1 = true; + } + else { + bVar1 = false; + } + } + if (bVar1) { + local_3c.ObjectID = *in_stack_0000000c; + pTVar2 = AccessObject(&local_3c); + ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); + if (local_2c[0].ObjectID != 99) { + local_4c[0].ObjectID = *in_stack_0000000c; + pTVar2 = AccessObject(local_4c); + ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); + local_4c[0] = (Object)Source->ObjectID; + iVar6 = 0; + SetObject(&local_3c,(ObjectType *)local_4c,(ulong)local_2c); + do { + local_4c[0].ObjectID = local_3c.ObjectID; + pTVar2 = AccessObject(local_4c); + local_2c[0].ObjectID = *in_stack_0000000c; + pTVar3 = AccessObject(local_2c); + pTVar2->Attributes[iVar6] = pTVar3->Attributes[iVar6]; + iVar6 = iVar6 + 1; + } while (iVar6 < 4); + local_2c[0].ObjectID = local_3c.ObjectID; + pTVar2 = AccessObject(local_2c); + ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); + bVar1 = ObjectType::getFlag((ObjectType *)local_4c,CONTAINER); + if (bVar1) { +LAB_08059ea9: + Object::setAttribute(&local_3c,CONTENT,0); + } + else { + local_2c[0].ObjectID = local_3c.ObjectID; + pTVar2 = AccessObject(local_2c); + ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); + bVar1 = ObjectType::getFlag((ObjectType *)local_4c,CHEST); + if (bVar1) goto LAB_08059ea9; + } + local_2c[0].ObjectID = local_3c.ObjectID; + pTVar2 = AccessObject(local_2c); + ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); + bVar1 = ObjectType::getFlag((ObjectType *)local_4c,TEXT); + if ((bVar1) && (uVar4 = Object::getAttribute(&local_3c,TEXTSTRING), uVar4 != 0)) { + uVar4 = Object::getAttribute(&local_3c,TEXTSTRING); + pcVar7 = GetDynamicString(uVar4); + uVar4 = AddDynamicString(pcVar7); + Object::setAttribute(&local_3c,TEXTSTRING,uVar4); + } + local_2c[0].ObjectID = local_3c.ObjectID; + pTVar2 = AccessObject(local_2c); + ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); + bVar1 = ObjectType::getFlag((ObjectType *)local_4c,TEXT); + if ((bVar1) && (uVar4 = Object::getAttribute(&local_3c,EDITOR), uVar4 != 0)) { + uVar4 = Object::getAttribute(&local_3c,EDITOR); + pcVar7 = GetDynamicString(uVar4); + uVar4 = AddDynamicString(pcVar7); + Object::setAttribute(&local_3c,EDITOR,uVar4); + } + goto LAB_08059d74; + } + pcVar7 = &DAT_080f1de0; + } + else { + pcVar7 = "CopyObject: Zielcontainer existiert nicht.\n"; } - Text = "CronChange: Objekt ist nicht im Cron-System eingetragen.\n"; } else { - Text = &DAT_080f1640; + pcVar7 = "CopyObject: Vorlage existiert nicht.\n"; } - error(Text); - return; + error(pcVar7); + local_3c = NONE; +LAB_08059d74: + Con->ObjectID = (ulong)local_3c; + return (Object)(ulong)Con; } - - -Object SplitObject(Object *Obj,int Count) +void CutObject(Object *Obj) { bool bVar1; TObject *pTVar2; - ulong uVar3; + TObject *pTVar3; ulong Position; uint uVar4; - ulong in_stack_0000000c; + Object local_8c [4]; + Object local_7c [4]; + Object local_6c [4]; Object local_5c [4]; Object local_4c [4]; Object local_3c; - Object Copy; - ObjectType local_2c [7]; + Object Search; + Object local_2c; + Object Con; bVar1 = false; - if (*(uint *)Count != 0) { - uVar4 = *(uint *)Count & HashTableMask; + if (Obj->ObjectID != 0) { + uVar4 = Obj->ObjectID & HashTableMask; if (HashTableType[uVar4] == '\x02') { UnswapSector(HashTableData[uVar4]); } - if ((HashTableType[uVar4] == '\x01') && (*(int *)HashTableData[uVar4] == *(int *)Count)) { + if ((HashTableType[uVar4] == '\x01') && (*(ulong *)HashTableData[uVar4] == Obj->ObjectID)) { bVar1 = true; } else { @@ -6110,188 +6081,190 @@ Object SplitObject(Object *Obj,int Count) } } if (!bVar1) { - error(&DAT_080f1680); - local_3c = NONE; - goto LAB_08058380; + error(&DAT_080f1ea0); + return; } - local_3c.ObjectID = *(ulong *)Count; + local_3c = (Object)Obj->ObjectID; pTVar2 = AccessObject(&local_3c); - ObjectType::setTypeID(local_2c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag(local_2c,CUMULATIVE); - if (bVar1) { - if (0 < (int)in_stack_0000000c) { - uVar3 = Object::getAttribute((Object *)Count,AMOUNT); - if ((int)in_stack_0000000c <= (int)uVar3) { - uVar3 = Object::getAttribute((Object *)Count,AMOUNT); - if (in_stack_0000000c != uVar3) { - local_5c[0].ObjectID = *(ulong *)Count; - local_2c[0].TypeID = local_5c[0].ObjectID; - pTVar2 = AccessObject(local_5c); - local_4c[0].ObjectID = (pTVar2->Container).ObjectID; - CopyObject(&local_3c,local_4c); - uVar3 = Object::getAttribute((Object *)Count,AMOUNT); - Object::setAttribute((Object *)Count,AMOUNT,uVar3 - in_stack_0000000c); - Object::setAttribute(&local_3c,AMOUNT,in_stack_0000000c); - goto LAB_08058380; - } - goto LAB_080583fc; + local_4c[0].ObjectID = (pTVar2->Container).ObjectID; + local_5c[0].ObjectID = NONE.ObjectID; + local_2c.ObjectID = local_4c[0].ObjectID; + if (local_4c[0].ObjectID == NONE.ObjectID) { + error(&DAT_080f1b80); + local_3c = NONE; + } + else { + Object::getObjectType(local_5c); + bVar1 = ObjectType::getFlag((ObjectType *)local_5c,CONTAINER); + if (!bVar1) { + Object::getObjectType(local_5c); + bVar1 = ObjectType::getFlag((ObjectType *)local_5c,CHEST); + if (!bVar1) { + Object::getObjectType(local_5c); + error("GetFirstContainerObject: Con (%d) ist kein Container.\n",local_5c[0].ObjectID + ); + local_3c = NONE; + goto LAB_0805a144; } } - error(&DAT_080f16c0,in_stack_0000000c); + local_3c.ObjectID = Object::getAttribute(local_4c,CONTENT); + } +LAB_0805a144: + local_5c[0] = (Object)Obj->ObjectID; + if (local_3c.ObjectID == local_5c[0].ObjectID) { + local_6c[0].ObjectID = local_5c[0].ObjectID; + pTVar2 = AccessObject(local_6c); + local_4c[0].ObjectID = (pTVar2->NextObject).ObjectID; + Object::setAttribute(&local_2c,CONTENT,local_4c[0].ObjectID); } else { - error("SplitObject: Objekt ist nicht kumulierbar.\n"); + while( true ) { + local_4c[0].ObjectID = local_3c.ObjectID; + pTVar2 = AccessObject(local_4c); + local_6c[0].ObjectID = (pTVar2->NextObject).ObjectID; + local_7c[0] = (Object)Obj->ObjectID; + if (local_6c[0].ObjectID == local_7c[0].ObjectID) break; + local_4c[0].ObjectID = local_3c.ObjectID; + pTVar2 = AccessObject(local_4c); + local_3c.ObjectID = (pTVar2->NextObject).ObjectID; + local_7c[0].ObjectID = local_3c.ObjectID; + local_6c[0].ObjectID = local_3c.ObjectID; + } + local_6c[0].ObjectID = local_3c.ObjectID; + local_4c[0].ObjectID = local_7c[0].ObjectID; + pTVar2 = AccessObject(local_6c); + local_8c[0] = (Object)Obj->ObjectID; + pTVar3 = AccessObject(local_8c); + local_4c[0].ObjectID = (pTVar3->NextObject).ObjectID; + (pTVar2->NextObject).ObjectID = local_4c[0].ObjectID; } -LAB_080583fc: - local_3c.ObjectID = *(ulong *)Count; -LAB_08058380: - Obj->ObjectID = (ulong)local_3c; - return (Object)(ulong)Obj; + local_7c[0] = (Object)Obj->ObjectID; + pTVar2 = AccessObject(local_7c); + local_8c[0] = NONE; + local_6c[0].ObjectID = NONE.ObjectID; + (pTVar2->NextObject).ObjectID = NONE.ObjectID; + local_7c[0] = (Object)Obj->ObjectID; + pTVar2 = AccessObject(local_7c); + (pTVar2->Container).ObjectID = NONE.ObjectID; + return; } -void MergeObjects(Object *Obj,Object *Dest) +void DestroyObject(Object *Obj) { - Object OVar1; - bool bVar2; - TObject *pTVar3; - ulong uVar4; - ulong uVar5; - ulong Position; - uint uVar6; + bool bVar1; + TObject *pTVar2; + ulong uVar3; + ulong nr; + uint uVar4; char *Text; - Object local_6c [4]; - Object local_5c [4]; - Object local_4c [4]; Object local_3c [4]; - ObjectType local_2c [7]; + Object local_2c [7]; - bVar2 = false; + bVar1 = false; if (Obj->ObjectID != 0) { - uVar6 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar6] == '\x02') { - UnswapSector(HashTableData[uVar6]); + uVar4 = Obj->ObjectID & HashTableMask; + if (HashTableType[uVar4] == '\x02') { + UnswapSector(HashTableData[uVar4]); } - if ((HashTableType[uVar6] == '\x01') && (*(ulong *)HashTableData[uVar6] == Obj->ObjectID)) { - bVar2 = true; + if ((HashTableType[uVar4] == '\x01') && (*(ulong *)HashTableData[uVar4] == Obj->ObjectID)) { + bVar1 = true; } else { - bVar2 = false; + bVar1 = false; } } - if (bVar2) { - bVar2 = false; - if (Dest->ObjectID != 0) { - uVar6 = Dest->ObjectID & HashTableMask; - if (HashTableType[uVar6] == '\x02') { - UnswapSector(HashTableData[uVar6]); - } - if ((HashTableType[uVar6] == '\x01') && - (*(ulong *)HashTableData[uVar6] == Dest->ObjectID)) { - bVar2 = true; - } - else { - bVar2 = false; - } - } - if (bVar2) { - local_3c[0] = (Object)Obj->ObjectID; - pTVar3 = AccessObject(local_3c); - ObjectType::setTypeID(local_2c,(pTVar3->Type).TypeID); - local_4c[0] = (Object)Dest->ObjectID; - pTVar3 = AccessObject(local_4c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar3->Type).TypeID); - ObjectType::setTypeID((ObjectType *)local_4c,local_3c[0].ObjectID); - if (local_2c[0].TypeID != local_4c[0].ObjectID) { - local_5c[0] = (Object)Dest->ObjectID; - pTVar3 = AccessObject(local_5c); - ObjectType::setTypeID((ObjectType *)local_4c,(pTVar3->Type).TypeID); - OVar1.ObjectID = local_4c[0].ObjectID; - local_6c[0] = (Object)Obj->ObjectID; - pTVar3 = AccessObject(local_6c); - ObjectType::setTypeID((ObjectType *)local_5c,(pTVar3->Type).TypeID); - error("MergeObjects: Objekttypen %d und %d sind nicht identisch.\n", - local_5c[0].ObjectID,OVar1.ObjectID); - return; - } - local_5c[0] = (Object)Obj->ObjectID; - pTVar3 = AccessObject(local_5c); - ObjectType::setTypeID((ObjectType *)local_6c,(pTVar3->Type).TypeID); - bVar2 = ObjectType::getFlag((ObjectType *)local_6c,CUMULATIVE); - if (!bVar2) { - local_5c[0] = (Object)Obj->ObjectID; - pTVar3 = AccessObject(local_5c); - ObjectType::setTypeID((ObjectType *)local_6c,(pTVar3->Type).TypeID); - error("MergeObjects: Objekttyp %d/%d ist nicht kumulierbar.\n",local_6c[0].ObjectID) - ; - return; - } - uVar4 = Object::getAttribute(Obj,AMOUNT); - if (uVar4 == 0) { - error(&DAT_080f18c0); - Object::setAttribute(Obj,AMOUNT,1); - } - uVar4 = Object::getAttribute(Dest,AMOUNT); - if (uVar4 == 0) { - error(&DAT_080f1880); - Object::setAttribute(Dest,AMOUNT,1); - } - uVar4 = Object::getAttribute(Obj,AMOUNT); - uVar5 = Object::getAttribute(Dest,AMOUNT); - Object::setAttribute(Dest,AMOUNT,uVar5 + uVar4); - uVar4 = Object::getAttribute(Dest,AMOUNT); - if (100 < uVar4) { - error(&DAT_080f1840); - Object::setAttribute(Dest,AMOUNT,100); - } - local_6c[0] = (Object)Obj->ObjectID; - bVar2 = false; - if (local_6c[0].ObjectID != 0) { - uVar6 = local_6c[0].ObjectID & HashTableMask; - if (HashTableType[uVar6] == '\x02') { - UnswapSector(HashTableData[uVar6]); + if (!bVar1) { + Text = &DAT_080f1ee0; + goto LAB_0805a343; + } + local_3c[0] = (Object)Obj->ObjectID; + pTVar2 = AccessObject(local_3c); + ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); + bVar1 = ObjectType::getFlag((ObjectType *)local_2c,TEXT); + if (bVar1) { + uVar3 = Object::getAttribute(Obj,TEXTSTRING); + DeleteDynamicString(uVar3); + uVar3 = Object::getAttribute(Obj,EDITOR); + DeleteDynamicString(uVar3); + } + local_2c[0] = (Object)Obj->ObjectID; + pTVar2 = AccessObject(local_2c); + ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); + bVar1 = ObjectType::getFlag((ObjectType *)local_3c,CONTAINER); + if (bVar1) { +LAB_0805a400: + while (uVar3 = Object::getAttribute(Obj,CONTENT), uVar3 != 0) { + local_3c[0].ObjectID = Object::getAttribute(Obj,CONTENT); + bVar1 = false; + if (local_3c[0].ObjectID != 0) { + uVar4 = local_3c[0].ObjectID & HashTableMask; + if (HashTableType[uVar4] == '\x02') { + UnswapSector(HashTableData[uVar4]); } - if ((HashTableType[uVar6] == '\x01') && - (*(uint *)HashTableData[uVar6] == local_6c[0].ObjectID)) { - bVar2 = true; + if ((HashTableType[uVar4] == '\x01') && + (*(ulong *)HashTableData[uVar4] == local_3c[0].ObjectID)) { + bVar1 = true; } else { - bVar2 = false; + bVar1 = false; } } - if (bVar2) { - local_5c[0].ObjectID = local_6c[0].ObjectID; - CutObject(local_5c); - local_5c[0].ObjectID = local_6c[0].ObjectID; - DestroyObject(local_5c); - return; + if (bVar1) { + local_2c[0].ObjectID = local_3c[0].ObjectID; + CutObject(local_2c); + local_2c[0].ObjectID = local_3c[0].ObjectID; + DestroyObject(local_2c); + } + else { + error(&DAT_080f1800); } - Text = &DAT_080f1800; - } - else { - Text = &DAT_080f1740; } } else { - Text = &DAT_080f1900; + local_2c[0] = (Object)Obj->ObjectID; + pTVar2 = AccessObject(local_2c); + ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); + bVar1 = ObjectType::getFlag((ObjectType *)local_3c,CHEST); + if (bVar1) goto LAB_0805a400; + } + local_2c[0] = (Object)Obj->ObjectID; + pTVar2 = AccessObject(local_2c); + ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); + bVar1 = ObjectType::getFlag((ObjectType *)local_3c,EXPIRE); + if (bVar1) { + local_3c[0] = (Object)Obj->ObjectID; + CronStop(local_3c); + } + if (Obj->ObjectID == 0) { + error(&DAT_080f1f60,0); + return; + } + uVar4 = Obj->ObjectID & HashTableMask; + if (HashTableType[uVar4] == '\x01') { + PutFreeObjectSlot((TObject *)HashTableData[uVar4]); + HashTableType[uVar4] = '\0'; + HashTableFree = HashTableFree + 1; + DecrementObjectCounter(); + return; } + Text = "DestroyObject: Objekt steht nicht im Speicher.\n"; +LAB_0805a343: error(Text); return; } -void MoveObject(Object *Obj,Object *Con) +void DeleteObject(Object *Obj) { bool bVar1; ulong Position; uint uVar2; - char *Text; - Object local_3c [4]; - Object local_2c [7]; + Object local_1c [4]; bVar1 = false; if (Obj->ObjectID != 0) { @@ -6307,2835 +6280,467 @@ void MoveObject(Object *Obj,Object *Con) } } if (bVar1) { - bVar1 = false; - if (Con->ObjectID != 0) { - uVar2 = Con->ObjectID & HashTableMask; - if (HashTableType[uVar2] == '\x02') { - UnswapSector(HashTableData[uVar2]); - } - if ((HashTableType[uVar2] == '\x01') && - (*(ulong *)HashTableData[uVar2] == Con->ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (bVar1) { - local_2c[0] = (Object)Obj->ObjectID; - CutObject(local_2c); - local_2c[0] = (Object)Con->ObjectID; - local_3c[0] = (Object)Obj->ObjectID; - PlaceObject(local_3c,local_2c,false); - return; - } - Text = &DAT_080f1940; + local_1c[0] = (Object)Obj->ObjectID; + CutObject(local_1c); + local_1c[0] = (Object)Obj->ObjectID; + DestroyObject(local_1c); } else { - Text = &DAT_080f1980; + error(&DAT_080f1800); } - error(Text); return; } +// WARNING: Unknown calling convention -- yet parameter storage is locked + +Object GetFirstSpecObject(void) +{ + TObject *pTVar1; + ulong *in_stack_00000004; + int *in_stack_00000014; + Object local_5c [4]; + ObjectType local_4c [4]; + Object local_3c [4]; + ulong local_2c; + Object Obj; + + GetFirstObject(); + if (local_2c != NONE.ObjectID) { + do { + local_4c[0].TypeID = NONE.ObjectID; + local_3c[0].ObjectID = local_2c; + pTVar1 = AccessObject(local_3c); + ObjectType::setTypeID(local_4c,(pTVar1->Type).TypeID); + ObjectType::setTypeID((ObjectType *)local_3c,*in_stack_00000014); + if (local_4c[0].TypeID == local_3c[0].ObjectID) { + *in_stack_00000004 = local_2c; + return (Object)(ulong)in_stack_00000004; + } + local_5c[0].ObjectID = local_2c; + pTVar1 = AccessObject(local_5c); + local_2c = (pTVar1->NextObject).ObjectID; + } while (local_2c != NONE.ObjectID); + } + *in_stack_00000004 = NONE.ObjectID; + return (Object)(ulong)in_stack_00000004; +} -void ChangeObject(Object *Obj,ObjectType *Type) +bool IsOnMap(int x,int y,int z) { bool bVar1; - TObject *pTVar2; - ulong uVar3; - ulong Position; - uint uVar4; - ulong *puVar5; - ulong local_5c; - ulong SavedExpireTime; - int Delay; - ulong local_50; - ulong Amount; - Object local_3c [4]; - Object local_2c [7]; + int sx; + int iVar2; + bool bVar3; + iVar2 = x + 0x1f; + if (-1 < x) { + iVar2 = x; + } + if (0x7fffffff < (uint)y) { + y = y + 0x1f; + } bVar1 = false; - local_5c = 0; - SavedExpireTime = 0xffffffff; - local_50 = 0; - if (Obj->ObjectID != 0) { - uVar4 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar4] == '\x02') { - UnswapSector(HashTableData[uVar4]); - } - if ((HashTableType[uVar4] == '\x01') && (*(ulong *)HashTableData[uVar4] == Obj->ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; - } + bVar3 = false; + if ((SectorXMin <= iVar2 >> 5) && (bVar1 = true, SectorXMax < iVar2 >> 5)) { + bVar1 = false; } if (bVar1) { - local_3c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); - ObjectType::setTypeID((ObjectType *)local_3c,0); - if (local_2c[0].ObjectID != local_3c[0].ObjectID) { - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,CUMULATIVE); - if (bVar1) { - local_50 = Object::getAttribute(Obj,AMOUNT); - } - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,EXPIRE); - if (bVar1) { - local_3c[0] = (Object)Obj->ObjectID; - local_5c = CronStop(local_3c); - bVar1 = ObjectType::getFlag(Type,CUMULATIVE); - if (bVar1) { - local_50 = 1; - } + bVar1 = false; + if ((SectorYMin <= y >> 5) && (bVar1 = true, SectorYMax < y >> 5)) { + bVar1 = false; + } + if (bVar1) { + bVar1 = false; + if ((SectorZMin <= z) && (bVar1 = true, SectorZMax < z)) { + bVar1 = bVar3; } - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,TEXT); - if (bVar1) { - bVar1 = ObjectType::getFlag(Type,TEXT); - if (!bVar1) { - uVar3 = Object::getAttribute(Obj,TEXTSTRING); - DeleteDynamicString(uVar3); - Object::setAttribute(Obj,TEXTSTRING,0); - uVar3 = Object::getAttribute(Obj,EDITOR); - DeleteDynamicString(uVar3); - Object::setAttribute(Obj,EDITOR,0); - } + if (bVar1 != false) { + bVar3 = true; } - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,EXPIRESTOP); - if (bVar1) { - uVar3 = Object::getAttribute(Obj,SAVEDEXPIRETIME); - if (uVar3 != 0) { - SavedExpireTime = Object::getAttribute(Obj,SAVEDEXPIRETIME); - } - } - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,MAGICFIELD); - if (bVar1) { - Object::setAttribute(Obj,RESPONSIBLE,0); - } - } - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)&Amount,Type->TypeID); - ObjectType::setTypeID(&pTVar2->Type,Amount); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - local_3c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)&Amount,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)&Amount,CUMULATIVE); - if (bVar1) { - Delay = 1; - puVar5 = (ulong *)&Delay; - if (local_50 != 0) { - puVar5 = &local_50; - } - Object::setAttribute(Obj,AMOUNT,*puVar5); - } - local_3c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)&Amount,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)&Amount,RUNE); - if (bVar1) { - uVar3 = Object::getAttribute(Obj,CHARGES); - if (uVar3 == 0) { - Object::setAttribute(Obj,CHARGES,1); - } - } - local_3c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)&Amount,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)&Amount,LIQUIDPOOL); - if (bVar1) { - uVar3 = Object::getAttribute(Obj,POOLLIQUIDTYPE); - if (uVar3 == 0) { - Object::setAttribute(Obj,POOLLIQUIDTYPE,1); - } - } - local_3c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)&Amount,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)&Amount,WEAROUT); - if (bVar1) { - uVar3 = Object::getAttribute(Obj,REMAININGUSES); - if (uVar3 == 0) { - uVar3 = ObjectType::getAttribute(Type,TOTALUSES); - Object::setAttribute(Obj,REMAININGUSES,uVar3); - } - } - local_3c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)&Amount,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)&Amount,EXPIRESTOP); - if (bVar1) { - Object::setAttribute(Obj,SAVEDEXPIRETIME,local_5c); } - Amount = Obj->ObjectID; - CronExpire((Object *)&Amount,SavedExpireTime); - } - else { - error(&DAT_080f19c0); } - return; + return bVar3; } -// WARNING: Variable defined which should be unmapped: Attribute_local +// WARNING: Unknown calling convention -- yet parameter storage is locked -void ChangeObject(Object *Obj,INSTANCEATTRIBUTE Attribute,ulong Value) +bool CoordinateFlag(void) { bool bVar1; - ulong Position; - uint uVar2; - INSTANCEATTRIBUTE Attribute_local; + TObject *pTVar2; + FLAG in_stack_00000010; + Object local_5c [4]; + ObjectType local_4c [4]; + Object local_3c [4]; + ulong local_2c; + Object Obj; - bVar1 = false; - if (Obj->ObjectID != 0) { - uVar2 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar2] == '\x02') { - UnswapSector(HashTableData[uVar2]); - } - if ((HashTableType[uVar2] == '\x01') && (*(ulong *)HashTableData[uVar2] == Obj->ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (!bVar1) { - error(&DAT_080f19c0); - return; + GetFirstObject(); + if (local_2c != NONE.ObjectID) { + do { + local_4c[0].TypeID = NONE.ObjectID; + local_3c[0].ObjectID = local_2c; + pTVar2 = AccessObject(local_3c); + ObjectType::setTypeID(local_4c,(pTVar2->Type).TypeID); + bVar1 = ObjectType::getFlag(local_4c,in_stack_00000010); + if (bVar1) { + return true; + } + local_5c[0].ObjectID = local_2c; + pTVar2 = AccessObject(local_5c); + local_2c = (pTVar2->NextObject).ObjectID; + } while (local_2c != NONE.ObjectID); } - Object::setAttribute(Obj,Attribute,Value); - return; + return false; } -// WARNING: Unknown calling convention -- yet parameter storage is locked - -TObject * GetFreeObjectSlot(void) +bool IsPremiumArea(int x,int y,int param_3) { - ulong *puVar1; - TObject *Help; - TObject *pTVar2; + bool bVar1; + int iVar2; + int iVar3; - if (FirstFreeObject == (TObject *)0x0) { - SwapSector(); + iVar2 = x + 0x1f; + if (-1 < x) { + iVar2 = x; } - pTVar2 = FirstFreeObject; - if (FirstFreeObject == (TObject *)0x0) { - error("GetFreeObjectSlot: Kein freier Platz mehr.\n"); - pTVar2 = (TObject *)0x0; + iVar2 = iVar2 >> 5; + if (0x7fffffff < (uint)y) { + y = y + 0x1f; } - else { - puVar1 = &FirstFreeObject->ObjectID; - FirstFreeObject = (TObject *)(FirstFreeObject->NextObject).ObjectID; - *puVar1 = 0; - (pTVar2->NextObject).ObjectID = 0; - (pTVar2->Container).ObjectID = 0; - (pTVar2->Type).TypeID = 0; - pTVar2->Attributes[0] = 0; - pTVar2->Attributes[1] = 0; - pTVar2->Attributes[2] = 0; - pTVar2->Attributes[3] = 0; + bVar1 = true; + iVar3 = y >> 5; + if ((((iVar2 < 0x40c) && ((iVar2 < 0x408 || (bVar1 = true, 0x3e6 < iVar3)))) && + ((iVar2 < 0x406 || (bVar1 = true, iVar3 < 0x3f0)))) && + (((iVar2 < 0x405 || (bVar1 = true, iVar3 < 0x3f1)) && + ((iVar2 < 0x3fe || (bVar1 = true, iVar3 < 0x3f6)))))) { + bVar1 = 0x3f7 < iVar3; } - return pTVar2; + return bVar1; } -// WARNING: Variable defined which should be unmapped: NewMask // WARNING: Unknown calling convention -- yet parameter storage is locked -void ResizeHashTable(void) +bool IsProtectionZone(void) { - uint *puVar1; - size_t __size; - ulong *puVar2; - uchar *__s; - uchar *__ptr; - int iVar3; - int i; - int iVar4; - ulong nr; - size_t __size_00; - uint uVar5; - uchar *NewType; - TObject *Entry; - ulong *NewData; - int NewMask; - - iVar4 = 1; - __size = HashTableSize * 2; - __size_00 = HashTableSize << 3; - error(&DAT_080f1a40,__size); - puVar2 = (ulong *)malloc(__size_00); - __s = (uchar *)malloc(__size); - memset(__s,0,__size); - *__s = 0xff; - iVar3 = HashTableSize; - *puVar2 = *HashTableData; - __ptr = HashTableType; - if (1 < iVar3) { - do { - if (__ptr[iVar4] != '\0') { - if (__ptr[iVar4] == '\x02') { - UnswapSector(HashTableData[iVar4]); - __ptr = HashTableType; - } - if (__ptr[iVar4] == '\x01') { - puVar1 = (uint *)HashTableData[iVar4]; - uVar5 = __size - 1 & *puVar1; - __s[uVar5] = '\x01'; - puVar2[uVar5] = (ulong)puVar1; - iVar3 = HashTableSize; - } - else { - error("ResizeHashTable: Fehler beim Reorganisieren der HashTabelle.\n"); - __ptr = HashTableType; - iVar3 = HashTableSize; - } - } - iVar4 = iVar4 + 1; - } while (iVar4 < iVar3); + byte bVar1; + bool bVar2; + int in_stack_00000004; + int in_stack_00000008; + Object local_2c [4]; + ulong local_1c; + Object Con; + + GetMapContainer((int)&local_1c,in_stack_00000004,in_stack_00000008); + bVar2 = false; + if (local_1c != NONE.ObjectID) { + local_2c[0].ObjectID = local_1c; + bVar1 = GetMapContainerFlags(local_2c); + bVar2 = (bool)(bVar1 >> 2 & 1); } - free(__ptr); - free(HashTableData); - iVar3 = HashTableSize; - HashTableSize = __size; - HashTableType = __s; - HashTableFree = HashTableFree + iVar3; - HashTableData = puVar2; - HashTableMask = __size - 1; - return; + return bVar2; } // WARNING: Unknown calling convention -- yet parameter storage is locked -Object CreateObject(void) +bool IsNoLogoutField(void) { - uchar uVar1; - ulong *puVar2; - ulong uVar3; - TObject *Help; - int iVar4; - Object OVar5; - TObject *pTVar6; - ulong *in_stack_00000004; + byte bVar1; + bool bVar2; + int in_stack_00000004; + int in_stack_00000008; + Object local_2c [4]; + ulong local_1c; + Object Con; - iVar4 = HashTableSize; - if (0x7fffffff < (uint)HashTableSize) { - iVar4 = HashTableSize + 0xf; - } - if (HashTableFree < iVar4 >> 4) { - ResizeHashTable(); - } - uVar1 = HashTableType[CreateObject::Iterator & HashTableMask]; - while (uVar1 != '\0') { - CreateObject::Iterator = CreateObject::Iterator + 1; - uVar1 = HashTableType[CreateObject::Iterator & HashTableMask]; - } - if (FirstFreeObject == (TObject *)0x0) { - SwapSector(); - } - pTVar6 = FirstFreeObject; - if (FirstFreeObject == (TObject *)0x0) { - pTVar6 = (TObject *)0x0; - error("GetFreeObjectSlot: Kein freier Platz mehr.\n"); - } - else { - puVar2 = &FirstFreeObject->ObjectID; - FirstFreeObject = (TObject *)(FirstFreeObject->NextObject).ObjectID; - *puVar2 = 0; - (pTVar6->NextObject).ObjectID = 0; - (pTVar6->Container).ObjectID = 0; - (pTVar6->Type).TypeID = 0; - pTVar6->Attributes[0] = 0; - pTVar6->Attributes[1] = 0; - pTVar6->Attributes[2] = 0; - pTVar6->Attributes[3] = 0; - } - uVar3 = HashTableMask; - iVar4 = CreateObject::Iterator; - if (pTVar6 == (TObject *)0x0) { - error("CreateObject: Kann Objekt nicht anlegen.\n"); - OVar5 = NONE; - } - else { - pTVar6->ObjectID = CreateObject::Iterator; - HashTableData[iVar4 & uVar3] = (ulong)pTVar6; - HashTableType[iVar4 & HashTableMask] = '\x01'; - HashTableFree = HashTableFree + -1; - IncrementObjectCounter(); - OVar5.ObjectID = CreateObject::Iterator; - } - *in_stack_00000004 = OVar5.ObjectID; - return (Object)(ulong)in_stack_00000004; + GetMapContainer((int)&local_1c,in_stack_00000004,in_stack_00000008); + bVar2 = false; + if (local_1c != NONE.ObjectID) { + local_2c[0].ObjectID = local_1c; + bVar1 = GetMapContainerFlags(local_2c); + bVar2 = (bool)(bVar1 >> 1 & 1); + } + return bVar2; } -int GetObjectPriority(Object *Obj) +bool IsHouse(int x,int y,int z) { bool bVar1; - TObject *pTVar2; - int iVar3; - ulong Position; - uint uVar4; + short sVar2; + TObject *pTVar3; Object local_3c [4]; - Object local_2c [7]; + Object local_2c; + Object Con; - bVar1 = false; - if (Obj->ObjectID != 0) { - uVar4 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar4] == '\x02') { - UnswapSector(HashTableData[uVar4]); - } - if ((HashTableType[uVar4] == '\x01') && (*(ulong *)HashTableData[uVar4] == Obj->ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (bVar1) { - local_3c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_2c,BANK); - iVar3 = 0; - if (!bVar1) { - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,CLIP); - iVar3 = 1; - if (!bVar1) { - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,BOTTOM); - iVar3 = 2; - if (!bVar1) { - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,TOP); - iVar3 = 3; - if (!bVar1) { - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - iVar3 = (local_3c[0].ObjectID != 99) + 4; - } - } - } + GetMapContainer((int)&local_2c,x,y); + local_3c[0].ObjectID = NONE.ObjectID; + if (local_2c.ObjectID != NONE.ObjectID) { + bVar1 = Object::exists(&local_2c); + if (bVar1) { + local_3c[0].ObjectID = local_2c.ObjectID; + pTVar3 = AccessObject(local_3c); + sVar2 = *(short *)((int)pTVar3->Attributes + 0xe); + goto LAB_0805b121; } + error(&DAT_080f20a0,x,y,z); } - else { - error(&DAT_080f1b00); - iVar3 = 0x7fffffff; - } - return iVar3; + sVar2 = 0; +LAB_0805b121: + return sVar2 != 0; } -void PlaceObject(Object *Obj,Object *Con,bool Append) +ushort GetHouseID(int x,int y,int z) { bool bVar1; TObject *pTVar2; - int iVar3; - int iVar4; - int SearchPriority; - Object *pAddr; - uint uVar5; - Object *pOVar6; - int ObjPriority; - char *pcVar7; - int iStack_78; - bool Append_local; - int x; - int y; - int z; - Object local_5c [4]; - Object local_4c [4]; + ushort uVar3; + ulong Position; + uint uVar4; Object local_3c [4]; - ulong local_2c; - Object Search; + uint local_2c; + Object Con; - local_2c = 0; - bVar1 = false; - if (Obj->ObjectID != 0) { - uVar5 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar5] == '\x02') { - UnswapSector(HashTableData[uVar5]); - } - if ((HashTableType[uVar5] == '\x01') && (*(ulong *)HashTableData[uVar5] == Obj->ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (!bVar1) { - pcVar7 = &DAT_080f1ca0; -LAB_080595eb: - error(pcVar7); - return; - } - bVar1 = false; - if (Con->ObjectID != 0) { - uVar5 = Con->ObjectID & HashTableMask; - if (HashTableType[uVar5] == '\x02') { - UnswapSector(HashTableData[uVar5]); - } - if ((HashTableType[uVar5] == '\x01') && (*(ulong *)HashTableData[uVar5] == Con->ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; + GetMapContainer((int)&local_2c,x,y); + uVar3 = 0; + local_3c[0].ObjectID = NONE.ObjectID; + if (local_2c != NONE.ObjectID) { + bVar1 = false; + if (local_2c != 0) { + uVar4 = local_2c & HashTableMask; + if (HashTableType[uVar4] == '\x02') { + UnswapSector(HashTableData[uVar4]); + } + if ((HashTableType[uVar4] == '\x01') && (*(uint *)HashTableData[uVar4] == local_2c)) { + bVar1 = true; + } + else { + bVar1 = false; + } } - } - if (!bVar1) { - pcVar7 = &DAT_080f1b40; - goto LAB_080595eb; - } - local_4c[0] = (Object)Con->ObjectID; - pTVar2 = AccessObject(local_4c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,CONTAINER); - if (!bVar1) { - local_3c[0] = (Object)Con->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_4c,CHEST); - if (!bVar1) { - local_3c[0] = (Object)Con->ObjectID; + if (bVar1) { + local_3c[0].ObjectID = local_2c; pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); - error("PlaceObject: Con (%d) ist kein Container.\n",local_4c[0].ObjectID); - return; + uVar3 = *(ushort *)((int)pTVar2->Attributes + 0xe); } - } - local_3c[0] = (Object)Con->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); - if (local_4c[0].ObjectID != 0) { - z = Con->ObjectID; - pTVar2 = AccessObject((Object *)&z); - pOVar6 = (Object *)pTVar2->Attributes; - local_2c = Object::getAttribute(Con,CONTENT); - z = local_2c; - if ((Append) && (z = NONE.ObjectID, local_2c != NONE.ObjectID)) { - do { - z = local_2c; - local_5c[0].ObjectID = NONE.ObjectID; - pTVar2 = AccessObject((Object *)&z); - pOVar6 = &pTVar2->NextObject; - local_4c[0].ObjectID = local_2c; - pTVar2 = AccessObject(local_4c); - local_2c = (pTVar2->NextObject).ObjectID; - z = NONE.ObjectID; - } while (local_2c != NONE.ObjectID); - } - goto LAB_08059780; - } - local_4c[0] = (Object)Obj->ObjectID; - iVar3 = GetObjectPriority(local_4c); - local_4c[0] = (Object)Con->ObjectID; - pTVar2 = AccessObject(local_4c); - pOVar6 = (Object *)pTVar2->Attributes; - local_5c[0] = (Object)Con->ObjectID; - z = NONE.ObjectID; - if (local_5c[0].ObjectID == NONE.ObjectID) { - error(&DAT_080f1b80); -LAB_080596ed: - local_3c[0].ObjectID = NONE.ObjectID; - } - else { - Object::getObjectType((Object *)&z); - bVar1 = ObjectType::getFlag((ObjectType *)&z,CONTAINER); - if (!bVar1) { - Object::getObjectType((Object *)&z); - bVar1 = ObjectType::getFlag((ObjectType *)&z,CHEST); - if (!bVar1) { - Object::getObjectType((Object *)&z); - error("GetFirstContainerObject: Con (%d) ist kein Container.\n",z); - goto LAB_080596ed; - } + else { + error(&DAT_080f20a0,x,y,z); + uVar3 = 0; } - local_3c[0].ObjectID = Object::getAttribute(local_5c,CONTENT); - } - z = NONE.ObjectID; - local_2c = local_3c[0].ObjectID; - local_4c[0].ObjectID = local_3c[0].ObjectID; - if (local_3c[0].ObjectID != NONE.ObjectID) { - do { - z = local_2c; - local_5c[0].ObjectID = NONE.ObjectID; - iVar4 = GetObjectPriority((Object *)&z); - if (iVar3 < iVar4) break; - if ((Append) || (1 < iVar4 - 4U)) { - if ((iVar4 == iVar3) && (((iVar3 == 0 || (iVar3 == 2)) || (iVar3 == 3)))) { - z = Con->ObjectID; - GetObjectCoordinates((Object *)&z,&stack0xffffff88,&x,&y); - local_5c[0].ObjectID = local_2c; - pTVar2 = AccessObject(local_5c); - ObjectType::setTypeID((ObjectType *)&z,(pTVar2->Type).TypeID); - iVar4 = z; - local_4c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_4c); - ObjectType::setTypeID((ObjectType *)local_5c,(pTVar2->Type).TypeID); - if (iVar3 == 0) { - pcVar7 = "BANK"; - } - else { - pcVar7 = "BOTTOM"; - if (iVar3 != 2) { - pcVar7 = "TOP"; - } - } - error("PlaceObject: Zwei %s-Objekte (%d und %d) auf Feld [%d,%d,%d].\n",pcVar7, - local_5c[0].ObjectID,iVar4,iStack_78,x,y); - } - } - else if (iVar4 == iVar3) break; - z = local_2c; - pTVar2 = AccessObject((Object *)&z); - pOVar6 = &pTVar2->NextObject; - local_4c[0].ObjectID = local_2c; - pTVar2 = AccessObject(local_4c); - local_2c = (pTVar2->NextObject).ObjectID; - z = NONE.ObjectID; - } while (local_2c != NONE.ObjectID); } -LAB_08059780: - local_5c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_5c); - local_4c[0].ObjectID = local_2c; - (pTVar2->NextObject).ObjectID = local_2c; - z = local_2c; - local_5c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_5c); - (pTVar2->Container).ObjectID = Con->ObjectID; - pOVar6->ObjectID = Obj->ObjectID; - return; + return uVar3; } -Object AppendObject(Object *Con,ObjectType *Type) +void SetHouseID(int x,int y,int z,ushort ID) { bool bVar1; + bool bVar2; + ushort uVar3; + TObject *pTVar4; + int sy; + int iVar5; + int sx; + int iVar6; ulong Position; - uint uVar2; - int *in_stack_0000000c; - Object local_4c [4]; - Object local_3c [4]; - ulong local_2c; - Object Obj; + uint uVar7; + ushort ID_local; + uint local_2c; + Object Con; + iVar6 = x; + if (0x7fffffff < (uint)x) { + iVar6 = x + 0x1f; + } + iVar5 = y; + if (0x7fffffff < (uint)y) { + iVar5 = y + 0x1f; + } bVar1 = false; - if (Type->TypeID != 0) { - uVar2 = Type->TypeID & HashTableMask; - if (HashTableType[uVar2] == '\x02') { - UnswapSector(HashTableData[uVar2]); - } - if ((HashTableType[uVar2] == '\x01') && (*(int *)HashTableData[uVar2] == Type->TypeID)) { - bVar1 = true; + bVar2 = false; + if ((SectorXMin <= iVar6 >> 5) && (bVar1 = true, SectorXMax < iVar6 >> 5)) { + bVar1 = false; + } + if (bVar1) { + bVar1 = false; + if ((SectorYMin <= iVar5 >> 5) && (bVar1 = true, SectorYMax < iVar5 >> 5)) { + bVar1 = false; } - else { + if (bVar1) { bVar1 = false; + if ((SectorZMin <= z) && (bVar1 = true, SectorZMax < z)) { + bVar1 = bVar2; + } + if (bVar1) { + bVar2 = true; + } + } + } + if (!bVar2) { + return; + } + iVar6 = z; + GetMapContainer((int)&local_2c,x,y); + bVar1 = false; + _ID_local = NONE.ObjectID; + if (local_2c != NONE.ObjectID) { + bVar2 = false; + if (local_2c != 0) { + uVar7 = local_2c & HashTableMask; + if (HashTableType[uVar7] == '\x02') { + UnswapSector(HashTableData[uVar7]); + } + if ((HashTableType[uVar7] == '\x01') && (*(uint *)HashTableData[uVar7] == local_2c)) { + bVar2 = true; + } + else { + bVar2 = false; + } } + if (bVar2) goto LAB_0805b36c; } + bVar1 = true; +LAB_0805b36c: if (bVar1) { - CreateObject(); - ObjectType::setTypeID((ObjectType *)local_3c,*in_stack_0000000c); - local_4c[0].ObjectID = local_2c; - ChangeObject(local_4c,(ObjectType *)local_3c); - local_4c[0].ObjectID = Type->TypeID; - local_3c[0].ObjectID = local_2c; - PlaceObject(local_3c,local_4c,true); + print(); } else { - error(&DAT_080f1ce0); - local_2c = NONE.ObjectID; + uVar3 = GetHouseID(x,y,z); + if (uVar3 == 0) { + _ID_local = local_2c; + pTVar4 = AccessObject((Object *)&ID_local); + pTVar4->Attributes[3] = pTVar4->Attributes[3] + (uint)ID * 0x10000; + } + else { + error(&DAT_080f2160,y,z,iVar6); + } } - Con->ObjectID = local_2c; - return (Object)(ulong)Con; + return; } -Object SetObject(Object *Con,ObjectType *Type,ulong CreatureID) +int GetDepotNumber(char *Town) { - bool bVar1; - TObject *pTVar2; - ulong Position; - uint uVar3; - ulong in_stack_00000010; - Object local_4c [4]; - Object local_3c [4]; - ulong local_2c; - Object Obj; + TDepotInfo *s1; + int iVar1; + int i; + int i_00; - bVar1 = false; - if (Type->TypeID != 0) { - uVar3 = Type->TypeID & HashTableMask; - if (HashTableType[uVar3] == '\x02') { - UnswapSector(HashTableData[uVar3]); - } - if ((HashTableType[uVar3] == '\x01') && (*(int *)HashTableData[uVar3] == Type->TypeID)) { - bVar1 = true; - } - else { - bVar1 = false; - } + if (Town == (char *)0x0) { + error("GetDepotNumber: Town ist NULL.\n"); } - if (bVar1) { - CreateObject(); - ObjectType::setTypeID((ObjectType *)local_3c,*(int *)CreatureID); - local_4c[0].ObjectID = local_2c; - ChangeObject(local_4c,(ObjectType *)local_3c); - local_4c[0].ObjectID = Type->TypeID; - local_3c[0].ObjectID = local_2c; - PlaceObject(local_3c,local_4c,false); - local_3c[0].ObjectID = local_2c; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); - if (local_4c[0].ObjectID == 99) { - if (in_stack_00000010 == 0) { - error(&DAT_080f1d60); + else if ((*Town != '\0') && (i_00 = DepotInfo.min, DepotInfo.min <= DepotInfo.max)) { + do { + s1 = vector::operator()(&DepotInfo,i_00); + iVar1 = stricmp(s1->Town,Town,-1); + if (iVar1 == 0) { + return i_00; } - local_4c[0].ObjectID = local_2c; - pTVar2 = AccessObject(local_4c); - pTVar2->Attributes[1] = in_stack_00000010; - } - } - else { - error(&DAT_080f1d20); - local_2c = NONE.ObjectID; + i_00 = i_00 + 1; + } while (i_00 <= DepotInfo.max); } - Con->ObjectID = local_2c; - return (Object)(ulong)Con; + return -1; } -Object CopyObject(Object *Con,Object *Source) +char * GetDepotName(int DepotNumber) { - bool bVar1; - TObject *pTVar2; - TObject *pTVar3; - ulong uVar4; - ulong Position; - uint uVar5; - int iVar6; - uint *in_stack_0000000c; - char *pcVar7; - Object local_4c [4]; - Object local_3c; - Object Obj; - Object local_2c [7]; - - bVar1 = false; - if (*in_stack_0000000c != 0) { - uVar5 = *in_stack_0000000c & HashTableMask; - if (HashTableType[uVar5] == '\x02') { - UnswapSector(HashTableData[uVar5]); - } - if ((HashTableType[uVar5] == '\x01') && - (*(uint *)HashTableData[uVar5] == *in_stack_0000000c)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (bVar1) { - bVar1 = false; - if (Source->ObjectID != 0) { - uVar5 = Source->ObjectID & HashTableMask; - if (HashTableType[uVar5] == '\x02') { - UnswapSector(HashTableData[uVar5]); - } - if ((HashTableType[uVar5] == '\x01') && - (*(ulong *)HashTableData[uVar5] == Source->ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (bVar1) { - local_3c.ObjectID = *in_stack_0000000c; - pTVar2 = AccessObject(&local_3c); - ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); - if (local_2c[0].ObjectID != 99) { - local_4c[0].ObjectID = *in_stack_0000000c; - pTVar2 = AccessObject(local_4c); - ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); - local_4c[0] = (Object)Source->ObjectID; - iVar6 = 0; - SetObject(&local_3c,(ObjectType *)local_4c,(ulong)local_2c); - do { - local_4c[0].ObjectID = local_3c.ObjectID; - pTVar2 = AccessObject(local_4c); - local_2c[0].ObjectID = *in_stack_0000000c; - pTVar3 = AccessObject(local_2c); - pTVar2->Attributes[iVar6] = pTVar3->Attributes[iVar6]; - iVar6 = iVar6 + 1; - } while (iVar6 < 4); - local_2c[0].ObjectID = local_3c.ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_4c,CONTAINER); - if (bVar1) { -LAB_08059ea9: - Object::setAttribute(&local_3c,CONTENT,0); - } - else { - local_2c[0].ObjectID = local_3c.ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_4c,CHEST); - if (bVar1) goto LAB_08059ea9; - } - local_2c[0].ObjectID = local_3c.ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_4c,TEXT); - if ((bVar1) && (uVar4 = Object::getAttribute(&local_3c,TEXTSTRING), uVar4 != 0)) { - uVar4 = Object::getAttribute(&local_3c,TEXTSTRING); - pcVar7 = GetDynamicString(uVar4); - uVar4 = AddDynamicString(pcVar7); - Object::setAttribute(&local_3c,TEXTSTRING,uVar4); - } - local_2c[0].ObjectID = local_3c.ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_4c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_4c,TEXT); - if ((bVar1) && (uVar4 = Object::getAttribute(&local_3c,EDITOR), uVar4 != 0)) { - uVar4 = Object::getAttribute(&local_3c,EDITOR); - pcVar7 = GetDynamicString(uVar4); - uVar4 = AddDynamicString(pcVar7); - Object::setAttribute(&local_3c,EDITOR,uVar4); - } - goto LAB_08059d74; - } - pcVar7 = &DAT_080f1de0; - } - else { - pcVar7 = "CopyObject: Zielcontainer existiert nicht.\n"; - } - } - else { - pcVar7 = "CopyObject: Vorlage existiert nicht.\n"; - } - error(pcVar7); - local_3c = NONE; -LAB_08059d74: - Con->ObjectID = (ulong)local_3c; - return (Object)(ulong)Con; -} - - - -void PutFreeObjectSlot(TObject *Entry) - -{ - if (Entry == (TObject *)0x0) { - error("PutFreeObjectSlot: Entry ist NULL.\n"); - } - else { - (Entry->NextObject).ObjectID = (ulong)FirstFreeObject; - FirstFreeObject = Entry; - } - return; -} - - - -void CutObject(Object *Obj) - -{ - bool bVar1; - TObject *pTVar2; - TObject *pTVar3; - ulong Position; - uint uVar4; - Object local_8c [4]; - Object local_7c [4]; - Object local_6c [4]; - Object local_5c [4]; - Object local_4c [4]; - Object local_3c; - Object Search; - Object local_2c; - Object Con; - - bVar1 = false; - if (Obj->ObjectID != 0) { - uVar4 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar4] == '\x02') { - UnswapSector(HashTableData[uVar4]); - } - if ((HashTableType[uVar4] == '\x01') && (*(ulong *)HashTableData[uVar4] == Obj->ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (!bVar1) { - error(&DAT_080f1ea0); - return; - } - local_3c = (Object)Obj->ObjectID; - pTVar2 = AccessObject(&local_3c); - local_4c[0].ObjectID = (pTVar2->Container).ObjectID; - local_5c[0].ObjectID = NONE.ObjectID; - local_2c.ObjectID = local_4c[0].ObjectID; - if (local_4c[0].ObjectID == NONE.ObjectID) { - error(&DAT_080f1b80); - local_3c = NONE; - } - else { - Object::getObjectType(local_5c); - bVar1 = ObjectType::getFlag((ObjectType *)local_5c,CONTAINER); - if (!bVar1) { - Object::getObjectType(local_5c); - bVar1 = ObjectType::getFlag((ObjectType *)local_5c,CHEST); - if (!bVar1) { - Object::getObjectType(local_5c); - error("GetFirstContainerObject: Con (%d) ist kein Container.\n",local_5c[0].ObjectID - ); - local_3c = NONE; - goto LAB_0805a144; - } - } - local_3c.ObjectID = Object::getAttribute(local_4c,CONTENT); - } -LAB_0805a144: - local_5c[0] = (Object)Obj->ObjectID; - if (local_3c.ObjectID == local_5c[0].ObjectID) { - local_6c[0].ObjectID = local_5c[0].ObjectID; - pTVar2 = AccessObject(local_6c); - local_4c[0].ObjectID = (pTVar2->NextObject).ObjectID; - Object::setAttribute(&local_2c,CONTENT,local_4c[0].ObjectID); - } - else { - while( true ) { - local_4c[0].ObjectID = local_3c.ObjectID; - pTVar2 = AccessObject(local_4c); - local_6c[0].ObjectID = (pTVar2->NextObject).ObjectID; - local_7c[0] = (Object)Obj->ObjectID; - if (local_6c[0].ObjectID == local_7c[0].ObjectID) break; - local_4c[0].ObjectID = local_3c.ObjectID; - pTVar2 = AccessObject(local_4c); - local_3c.ObjectID = (pTVar2->NextObject).ObjectID; - local_7c[0].ObjectID = local_3c.ObjectID; - local_6c[0].ObjectID = local_3c.ObjectID; - } - local_6c[0].ObjectID = local_3c.ObjectID; - local_4c[0].ObjectID = local_7c[0].ObjectID; - pTVar2 = AccessObject(local_6c); - local_8c[0] = (Object)Obj->ObjectID; - pTVar3 = AccessObject(local_8c); - local_4c[0].ObjectID = (pTVar3->NextObject).ObjectID; - (pTVar2->NextObject).ObjectID = local_4c[0].ObjectID; - } - local_7c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_7c); - local_8c[0] = NONE; - local_6c[0].ObjectID = NONE.ObjectID; - (pTVar2->NextObject).ObjectID = NONE.ObjectID; - local_7c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_7c); - (pTVar2->Container).ObjectID = NONE.ObjectID; - return; -} - - - -void DestroyObject(Object *Obj) - -{ - bool bVar1; - TObject *pTVar2; - ulong uVar3; - ulong nr; - uint uVar4; - char *Text; - Object local_3c [4]; - Object local_2c [7]; - - bVar1 = false; - if (Obj->ObjectID != 0) { - uVar4 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar4] == '\x02') { - UnswapSector(HashTableData[uVar4]); - } - if ((HashTableType[uVar4] == '\x01') && (*(ulong *)HashTableData[uVar4] == Obj->ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (!bVar1) { - Text = &DAT_080f1ee0; - goto LAB_0805a343; - } - local_3c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_2c,TEXT); - if (bVar1) { - uVar3 = Object::getAttribute(Obj,TEXTSTRING); - DeleteDynamicString(uVar3); - uVar3 = Object::getAttribute(Obj,EDITOR); - DeleteDynamicString(uVar3); - } - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,CONTAINER); - if (bVar1) { -LAB_0805a400: - while (uVar3 = Object::getAttribute(Obj,CONTENT), uVar3 != 0) { - local_3c[0].ObjectID = Object::getAttribute(Obj,CONTENT); - bVar1 = false; - if (local_3c[0].ObjectID != 0) { - uVar4 = local_3c[0].ObjectID & HashTableMask; - if (HashTableType[uVar4] == '\x02') { - UnswapSector(HashTableData[uVar4]); - } - if ((HashTableType[uVar4] == '\x01') && - (*(ulong *)HashTableData[uVar4] == local_3c[0].ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (bVar1) { - local_2c[0].ObjectID = local_3c[0].ObjectID; - CutObject(local_2c); - local_2c[0].ObjectID = local_3c[0].ObjectID; - DestroyObject(local_2c); - } - else { - error(&DAT_080f1800); - } - } - } - else { - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,CHEST); - if (bVar1) goto LAB_0805a400; - } - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,EXPIRE); - if (bVar1) { - local_3c[0] = (Object)Obj->ObjectID; - CronStop(local_3c); - } - if (Obj->ObjectID == 0) { - error(&DAT_080f1f60,0); - return; - } - uVar4 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar4] == '\x01') { - PutFreeObjectSlot((TObject *)HashTableData[uVar4]); - HashTableType[uVar4] = '\0'; - HashTableFree = HashTableFree + 1; - DecrementObjectCounter(); - return; - } - Text = "DestroyObject: Objekt steht nicht im Speicher.\n"; -LAB_0805a343: - error(Text); - return; -} - - - -void DeleteObject(Object *Obj) - -{ - bool bVar1; - ulong Position; - uint uVar2; - Object local_1c [4]; - - bVar1 = false; - if (Obj->ObjectID != 0) { - uVar2 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar2] == '\x02') { - UnswapSector(HashTableData[uVar2]); - } - if ((HashTableType[uVar2] == '\x01') && (*(ulong *)HashTableData[uVar2] == Obj->ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (bVar1) { - local_1c[0] = (Object)Obj->ObjectID; - CutObject(local_1c); - local_1c[0] = (Object)Obj->ObjectID; - DestroyObject(local_1c); - } - else { - error(&DAT_080f1800); - } - return; -} - - - -Object GetMapContainer(int x,int y,int z) - -{ - int iVar1; - bool bVar2; - bool bVar3; - matrix3d *pmVar4; - int sx; - int iVar5; - Object OVar6; - TSector **ppTVar7; - int sy; - int iVar8; - int iVar9; - int iVar10; - int iVar11; - int in_stack_00000010; - - pmVar4 = Sector; - bVar3 = false; - iVar9 = y + 0x1f; - iVar11 = z + 0x1f; - iVar10 = iVar9; - if (-1 < y) { - iVar10 = y; - } - iVar5 = iVar11; - if (-1 < z) { - iVar5 = z; - } - bVar2 = false; - if ((SectorXMin <= iVar10 >> 5) && (bVar2 = true, SectorXMax < iVar10 >> 5)) { - bVar2 = false; - } - if (bVar2) { - bVar2 = false; - if (SectorYMin <= iVar5 >> 5) { - bVar2 = true; - if (SectorYMax < iVar5 >> 5) { - bVar2 = false; - } - } - if (((bVar2) && (bVar3 = false, SectorZMin <= in_stack_00000010)) && - (bVar3 = true, SectorZMax < in_stack_00000010)) { - bVar3 = false; - } - } - if (bVar3) { - iVar10 = iVar9; - if (-1 < y) { - iVar10 = y; - } - iVar5 = iVar11; - if (-1 < z) { - iVar5 = z; - } - iVar8 = (iVar5 >> 5) - Sector->ymin; - iVar5 = in_stack_00000010 - Sector->zmin; - iVar10 = (iVar10 >> 5) - Sector->xmin; - if ((((iVar10 < 0) || (iVar1 = Sector->dx, iVar1 <= iVar10)) || - ((iVar8 < 0 || ((Sector->dy <= iVar8 || (iVar5 < 0)))))) || (Sector->dz <= iVar5)) { - error("matrix3d::operator(): Ungueltiger Index %d/%d/%d.\n",iVar10 + Sector->xmin, - iVar8 + Sector->ymin,iVar5 + Sector->zmin); - ppTVar7 = pmVar4->entry; - } - else { - ppTVar7 = Sector->entry + iVar10 + iVar8 * iVar1 + iVar5 * iVar1 * Sector->dy; - } - pmVar4 = Sector; - OVar6.ObjectID = NONE.ObjectID; - if (*ppTVar7 != (TSector *)0x0) { - iVar10 = iVar9; - if (-1 < y) { - iVar10 = y; - } - iVar5 = iVar11; - if (-1 < z) { - iVar5 = z; - } - iVar8 = (iVar5 >> 5) - Sector->ymin; - iVar5 = in_stack_00000010 - Sector->zmin; - iVar10 = (iVar10 >> 5) - Sector->xmin; - if (((((iVar10 < 0) || (iVar1 = Sector->dx, iVar1 <= iVar10)) || (iVar8 < 0)) || - ((Sector->dy <= iVar8 || (iVar5 < 0)))) || (Sector->dz <= iVar5)) { - error("matrix3d::operator(): Ungueltiger Index %d/%d/%d.\n",iVar10 + Sector->xmin, - iVar8 + Sector->ymin,iVar5 + Sector->zmin); - ppTVar7 = pmVar4->entry; - } - else { - ppTVar7 = Sector->entry + iVar10 + iVar8 * iVar1 + iVar5 * iVar1 * Sector->dy; - } - (*ppTVar7)->TimeStamp = RoundNr; - pmVar4 = Sector; - if (-1 < y) { - iVar9 = y; - } - if (-1 < z) { - iVar11 = z; - } - iVar8 = (iVar11 >> 5) - Sector->ymin; - iVar10 = in_stack_00000010 - Sector->zmin; - iVar5 = (iVar9 >> 5) - Sector->xmin; - if (((iVar5 < 0) || (iVar1 = Sector->dx, iVar1 <= iVar5)) || - ((iVar8 < 0 || (((Sector->dy <= iVar8 || (iVar10 < 0)) || (Sector->dz <= iVar10)))))) - { - error("matrix3d::operator(): Ungueltiger Index %d/%d/%d.\n",iVar5 + Sector->xmin, - iVar8 + Sector->ymin,iVar10 + Sector->zmin); - ppTVar7 = pmVar4->entry; - } - else { - ppTVar7 = Sector->entry + iVar10 * iVar1 * Sector->dy + iVar8 * iVar1 + iVar5; - } - OVar6.ObjectID = - *(ulong *)((z + (iVar11 >> 5) * -0x20 + (y + (iVar9 >> 5) * -0x20) * 0x20) * 4 + - (int)*ppTVar7); - } - *(ulong *)x = OVar6.ObjectID; - } - else { - *(ulong *)x = NONE.ObjectID; - } - return (Object)x; -} - - - -Object GetMapContainer(Object *Obj) - -{ - bool bVar1; - TObject *pTVar2; - Object OVar3; - ulong Position; - uint uVar4; - uint *in_stack_00000008; - Object local_4c [4]; - Object local_3c [4]; - ObjectType local_2c [7]; - - bVar1 = false; - if (*in_stack_00000008 != 0) { - uVar4 = *in_stack_00000008 & HashTableMask; - if (HashTableType[uVar4] == '\x02') { - UnswapSector(HashTableData[uVar4]); - } - if ((HashTableType[uVar4] == '\x01') && - (*(uint *)HashTableData[uVar4] == *in_stack_00000008)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (bVar1) { - while( true ) { - local_3c[0].ObjectID = *in_stack_00000008; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID(local_2c,(pTVar2->Type).TypeID); - if (local_2c[0].TypeID == 0) break; - local_4c[0].ObjectID = *in_stack_00000008; - pTVar2 = AccessObject(local_4c); - local_2c[0].TypeID = (pTVar2->Container).ObjectID; - *in_stack_00000008 = local_2c[0].TypeID; - } - OVar3.ObjectID = *in_stack_00000008; - } - else { - error(&DAT_080f1fe0); - OVar3 = NONE; - } - Obj->ObjectID = (ulong)OVar3; - return (Object)(ulong)Obj; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -Object GetFirstObject(void) - -{ - Object OVar1; - ulong *in_stack_00000004; - int in_stack_00000008; - int in_stack_0000000c; - Object local_1c; - Object MapCon; - - GetMapContainer((int)&local_1c,in_stack_00000008,in_stack_0000000c); - OVar1 = NONE; - if (local_1c.ObjectID != NONE.ObjectID) { - OVar1.ObjectID = Object::getAttribute(&local_1c,CONTENT); - } - *in_stack_00000004 = OVar1.ObjectID; - return (Object)(ulong)in_stack_00000004; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -Object GetFirstSpecObject(void) - -{ - TObject *pTVar1; - ulong *in_stack_00000004; - int *in_stack_00000014; - Object local_5c [4]; - ObjectType local_4c [4]; - Object local_3c [4]; - ulong local_2c; - Object Obj; - - GetFirstObject(); - if (local_2c != NONE.ObjectID) { - do { - local_4c[0].TypeID = NONE.ObjectID; - local_3c[0].ObjectID = local_2c; - pTVar1 = AccessObject(local_3c); - ObjectType::setTypeID(local_4c,(pTVar1->Type).TypeID); - ObjectType::setTypeID((ObjectType *)local_3c,*in_stack_00000014); - if (local_4c[0].TypeID == local_3c[0].ObjectID) { - *in_stack_00000004 = local_2c; - return (Object)(ulong)in_stack_00000004; - } - local_5c[0].ObjectID = local_2c; - pTVar1 = AccessObject(local_5c); - local_2c = (pTVar1->NextObject).ObjectID; - } while (local_2c != NONE.ObjectID); - } - *in_stack_00000004 = NONE.ObjectID; - return (Object)(ulong)in_stack_00000004; -} - - - -Object GetFirstContainerObject(Object *Con) - -{ - bool bVar1; - TObject *pTVar2; - Object OVar3; - Object *in_stack_00000008; - Object local_3c [4]; - Object local_2c [7]; - - local_2c[0].ObjectID = NONE.ObjectID; - local_3c[0].ObjectID = in_stack_00000008->ObjectID; - if (local_3c[0].ObjectID == NONE.ObjectID) { - error(&DAT_080f1b80); - OVar3 = NONE; - } - else { - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_2c,CONTAINER); - if (!bVar1) { - local_2c[0].ObjectID = in_stack_00000008->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_3c,CHEST); - if (!bVar1) { - local_2c[0].ObjectID = in_stack_00000008->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)local_3c,(pTVar2->Type).TypeID); - error("GetFirstContainerObject: Con (%d) ist kein Container.\n",local_3c[0].ObjectID - ); - OVar3 = NONE; - goto LAB_0805abe7; - } - } - OVar3.ObjectID = Object::getAttribute(in_stack_00000008,CONTENT); - } -LAB_0805abe7: - Con->ObjectID = (ulong)OVar3; - return (Object)(ulong)Con; -} - - - -Object GetContainerObject(Object *Con,int nr) - -{ - bool bVar1; - TObject *pTVar2; - ulong Position; - uint uVar3; - int in_stack_0000000c; - Object local_5c [4]; - ulong local_4c; - ulong local_3c; - Object local_2c; - Object Obj; - - bVar1 = false; - if (*(uint *)nr != 0) { - uVar3 = *(uint *)nr & HashTableMask; - if (HashTableType[uVar3] == '\x02') { - UnswapSector(HashTableData[uVar3]); - } - if ((HashTableType[uVar3] == '\x01') && (*(int *)HashTableData[uVar3] == *(int *)nr)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (bVar1) { - if (-1 < in_stack_0000000c) { - local_3c = *(ulong *)nr; - GetFirstContainerObject(&local_2c); - if (local_2c.ObjectID != NONE.ObjectID) { - do { - if (in_stack_0000000c == 0) goto LAB_0805ad80; - in_stack_0000000c = in_stack_0000000c + -1; - local_5c[0].ObjectID = local_2c.ObjectID; - local_4c = NONE.ObjectID; - local_3c = NONE.ObjectID; - pTVar2 = AccessObject(local_5c); - local_2c.ObjectID = (pTVar2->NextObject).ObjectID; - } while (local_2c.ObjectID != NONE.ObjectID); - } - Con->ObjectID = (ulong)NONE; - return (Object)(ulong)Con; - } - error(&DAT_080f2020); - local_2c = NONE; - } - else { - error(&DAT_080f2060); - local_2c = NONE; - } -LAB_0805ad80: - Con->ObjectID = (ulong)local_2c; - return (Object)(ulong)Con; -} - - - -bool IsOnMap(int x,int y,int z) - -{ - bool bVar1; - int sx; - int iVar2; - bool bVar3; - - iVar2 = x + 0x1f; - if (-1 < x) { - iVar2 = x; - } - if (0x7fffffff < (uint)y) { - y = y + 0x1f; - } - bVar1 = false; - bVar3 = false; - if ((SectorXMin <= iVar2 >> 5) && (bVar1 = true, SectorXMax < iVar2 >> 5)) { - bVar1 = false; - } - if (bVar1) { - bVar1 = false; - if ((SectorYMin <= y >> 5) && (bVar1 = true, SectorYMax < y >> 5)) { - bVar1 = false; - } - if (bVar1) { - bVar1 = false; - if ((SectorZMin <= z) && (bVar1 = true, SectorZMax < z)) { - bVar1 = bVar3; - } - if (bVar1 != false) { - bVar3 = true; - } - } - } - return bVar3; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -bool CoordinateFlag(void) - -{ - bool bVar1; - TObject *pTVar2; - FLAG in_stack_00000010; - Object local_5c [4]; - ObjectType local_4c [4]; - Object local_3c [4]; - ulong local_2c; - Object Obj; - - GetFirstObject(); - if (local_2c != NONE.ObjectID) { - do { - local_4c[0].TypeID = NONE.ObjectID; - local_3c[0].ObjectID = local_2c; - pTVar2 = AccessObject(local_3c); - ObjectType::setTypeID(local_4c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag(local_4c,in_stack_00000010); - if (bVar1) { - return true; - } - local_5c[0].ObjectID = local_2c; - pTVar2 = AccessObject(local_5c); - local_2c = (pTVar2->NextObject).ObjectID; - } while (local_2c != NONE.ObjectID); - } - return false; -} - - - -bool IsPremiumArea(int x,int y,int param_3) - -{ - bool bVar1; - int iVar2; - int iVar3; - - iVar2 = x + 0x1f; - if (-1 < x) { - iVar2 = x; - } - iVar2 = iVar2 >> 5; - if (0x7fffffff < (uint)y) { - y = y + 0x1f; - } - bVar1 = true; - iVar3 = y >> 5; - if ((((iVar2 < 0x40c) && ((iVar2 < 0x408 || (bVar1 = true, 0x3e6 < iVar3)))) && - ((iVar2 < 0x406 || (bVar1 = true, iVar3 < 0x3f0)))) && - (((iVar2 < 0x405 || (bVar1 = true, iVar3 < 0x3f1)) && - ((iVar2 < 0x3fe || (bVar1 = true, iVar3 < 0x3f6)))))) { - bVar1 = 0x3f7 < iVar3; - } - return bVar1; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -bool IsProtectionZone(void) - -{ - byte bVar1; - bool bVar2; - int in_stack_00000004; - int in_stack_00000008; - Object local_2c [4]; - ulong local_1c; - Object Con; - - GetMapContainer((int)&local_1c,in_stack_00000004,in_stack_00000008); - bVar2 = false; - if (local_1c != NONE.ObjectID) { - local_2c[0].ObjectID = local_1c; - bVar1 = GetMapContainerFlags(local_2c); - bVar2 = (bool)(bVar1 >> 2 & 1); - } - return bVar2; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -bool IsNoLogoutField(void) - -{ - byte bVar1; - bool bVar2; - int in_stack_00000004; - int in_stack_00000008; - Object local_2c [4]; - ulong local_1c; - Object Con; - - GetMapContainer((int)&local_1c,in_stack_00000004,in_stack_00000008); - bVar2 = false; - if (local_1c != NONE.ObjectID) { - local_2c[0].ObjectID = local_1c; - bVar1 = GetMapContainerFlags(local_2c); - bVar2 = (bool)(bVar1 >> 1 & 1); - } - return bVar2; -} - - - -bool IsHouse(int x,int y,int z) - -{ - bool bVar1; - short sVar2; - TObject *pTVar3; - Object local_3c [4]; - Object local_2c; - Object Con; - - GetMapContainer((int)&local_2c,x,y); - local_3c[0].ObjectID = NONE.ObjectID; - if (local_2c.ObjectID != NONE.ObjectID) { - bVar1 = Object::exists(&local_2c); - if (bVar1) { - local_3c[0].ObjectID = local_2c.ObjectID; - pTVar3 = AccessObject(local_3c); - sVar2 = *(short *)((int)pTVar3->Attributes + 0xe); - goto LAB_0805b121; - } - error(&DAT_080f20a0,x,y,z); - } - sVar2 = 0; -LAB_0805b121: - return sVar2 != 0; -} - - - -ushort GetHouseID(int x,int y,int z) - -{ - bool bVar1; - TObject *pTVar2; - ushort uVar3; - ulong Position; - uint uVar4; - Object local_3c [4]; - uint local_2c; - Object Con; - - GetMapContainer((int)&local_2c,x,y); - uVar3 = 0; - local_3c[0].ObjectID = NONE.ObjectID; - if (local_2c != NONE.ObjectID) { - bVar1 = false; - if (local_2c != 0) { - uVar4 = local_2c & HashTableMask; - if (HashTableType[uVar4] == '\x02') { - UnswapSector(HashTableData[uVar4]); - } - if ((HashTableType[uVar4] == '\x01') && (*(uint *)HashTableData[uVar4] == local_2c)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (bVar1) { - local_3c[0].ObjectID = local_2c; - pTVar2 = AccessObject(local_3c); - uVar3 = *(ushort *)((int)pTVar2->Attributes + 0xe); - } - else { - error(&DAT_080f20a0,x,y,z); - uVar3 = 0; - } - } - return uVar3; -} - - - -void SetHouseID(int x,int y,int z,ushort ID) - -{ - bool bVar1; - bool bVar2; - ushort uVar3; - TObject *pTVar4; - int sy; - int iVar5; - int sx; - int iVar6; - ulong Position; - uint uVar7; - ushort ID_local; - uint local_2c; - Object Con; - - iVar6 = x; - if (0x7fffffff < (uint)x) { - iVar6 = x + 0x1f; - } - iVar5 = y; - if (0x7fffffff < (uint)y) { - iVar5 = y + 0x1f; - } - bVar1 = false; - bVar2 = false; - if ((SectorXMin <= iVar6 >> 5) && (bVar1 = true, SectorXMax < iVar6 >> 5)) { - bVar1 = false; - } - if (bVar1) { - bVar1 = false; - if ((SectorYMin <= iVar5 >> 5) && (bVar1 = true, SectorYMax < iVar5 >> 5)) { - bVar1 = false; - } - if (bVar1) { - bVar1 = false; - if ((SectorZMin <= z) && (bVar1 = true, SectorZMax < z)) { - bVar1 = bVar2; - } - if (bVar1) { - bVar2 = true; - } - } - } - if (!bVar2) { - return; - } - iVar6 = z; - GetMapContainer((int)&local_2c,x,y); - bVar1 = false; - _ID_local = NONE.ObjectID; - if (local_2c != NONE.ObjectID) { - bVar2 = false; - if (local_2c != 0) { - uVar7 = local_2c & HashTableMask; - if (HashTableType[uVar7] == '\x02') { - UnswapSector(HashTableData[uVar7]); - } - if ((HashTableType[uVar7] == '\x01') && (*(uint *)HashTableData[uVar7] == local_2c)) { - bVar2 = true; - } - else { - bVar2 = false; - } - } - if (bVar2) goto LAB_0805b36c; - } - bVar1 = true; -LAB_0805b36c: - if (bVar1) { - print(); - } - else { - uVar3 = GetHouseID(x,y,z); - if (uVar3 == 0) { - _ID_local = local_2c; - pTVar4 = AccessObject((Object *)&ID_local); - pTVar4->Attributes[3] = pTVar4->Attributes[3] + (uint)ID * 0x10000; - } - else { - error(&DAT_080f2160,y,z,iVar6); - } - } - return; -} - - - -int GetDepotNumber(char *Town) - -{ - TDepotInfo *s1; - int iVar1; - int i; - int i_00; - - if (Town == (char *)0x0) { - error("GetDepotNumber: Town ist NULL.\n"); - } - else if ((*Town != '\0') && (i_00 = DepotInfo.min, DepotInfo.min <= DepotInfo.max)) { - do { - s1 = vector::operator()(&DepotInfo,i_00); - iVar1 = stricmp(s1->Town,Town,-1); - if (iVar1 == 0) { - return i_00; - } - i_00 = i_00 + 1; - } while (i_00 <= DepotInfo.max); - } - return -1; -} - - - -char * GetDepotName(int DepotNumber) - -{ - TDepotInfo *pTVar1; - char *Text; - - if ((DepotNumber < DepotInfo.min) || (DepotInfo.max < DepotNumber)) { - Text = &DAT_080f21c0; - } - else { - pTVar1 = vector::operator()(&DepotInfo,DepotNumber); - if (pTVar1 != (TDepotInfo *)0x0) { - pTVar1 = vector::operator()(&DepotInfo,DepotNumber); - return pTVar1->Town; - } - Text = &DAT_080f2200; - } - error(Text,DepotNumber); - return "unknown"; -} - - - -// WARNING: Variable defined which should be unmapped: PremiumAccount_local - -int GetDepotSize(int DepotNumber,bool PremiumAccount) - -{ - int iVar1; - TDepotInfo *pTVar2; - bool PremiumAccount_local; - - if ((DepotNumber < DepotInfo.min) || (DepotInfo.max < DepotNumber)) { - error(&DAT_080f2240,DepotNumber); - iVar1 = 1; - } - else { - pTVar2 = vector::operator()(&DepotInfo,DepotNumber); - if (pTVar2->Size < 1) { - pTVar2 = vector::operator()(&DepotInfo,DepotNumber); - error(&DAT_080f2280,pTVar2->Size,DepotNumber); - pTVar2 = vector::operator()(&DepotInfo,DepotNumber); - pTVar2->Size = 1; - } - if (PremiumAccount) { - pTVar2 = vector::operator()(&DepotInfo,DepotNumber); - iVar1 = pTVar2->Size * 2; - } - else { - pTVar2 = vector::operator()(&DepotInfo,DepotNumber); - iVar1 = pTVar2->Size; - } - } - return iVar1; -} - - - -void GetStartPosition(int *x,int *y,int *z,bool Newbie) - -{ - int iVar1; - - if (Newbie) { - *x = NewbieStartPositionX; - *y = NewbieStartPositionY; - iVar1 = NewbieStartPositionZ; - } - else { - *x = VeteranStartPositionX; - *y = VeteranStartPositionY; - iVar1 = VeteranStartPositionZ; - } - *z = iVar1; - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -bool GetMarkPosition(void) - -{ - TMark *pTVar1; - int iVar2; - int i; - int i_00; - char *in_stack_00000004; - int *in_stack_00000008; - int *in_stack_0000000c; - int *in_stack_00000010; - - i_00 = 0; - if (0 < Marks) { - do { - pTVar1 = vector::operator()(&Mark,i_00); - iVar2 = stricmp(pTVar1->Name,in_stack_00000004,-1); - if (iVar2 == 0) { - pTVar1 = vector::operator()(&Mark,i_00); - *in_stack_00000008 = pTVar1->x; - pTVar1 = vector::operator()(&Mark,i_00); - *in_stack_0000000c = pTVar1->y; - pTVar1 = vector::operator()(&Mark,i_00); - *in_stack_00000010 = pTVar1->z; - return true; - } - i_00 = i_00 + 1; - } while (i_00 < Marks); - } - return false; -} - - - -void InitSector(int x,int y,int z) - -{ - int iVar1; - matrix3d *pmVar2; - int iVar3; - TSector *pTVar4; - TSector **ppTVar5; - uint uVar6; - TObject *pTVar7; - int iVar8; - int iVar9; - TSector *pTVar10; - int yy; - TSector *Sec; - int local_5c; - int xx; - Object local_3c [4]; - ulong local_2c; - Object Obj; - - pmVar2 = Sector; - iVar9 = y - Sector->ymin; - iVar3 = z - Sector->zmin; - iVar8 = x - Sector->xmin; - if ((((iVar8 < 0) || (iVar1 = Sector->dx, iVar1 <= iVar8)) || (iVar9 < 0)) || - (((Sector->dy <= iVar9 || (iVar3 < 0)) || (Sector->dz <= iVar3)))) { - error("matrix3d::operator(): Ungueltiger Index %d/%d/%d.\n",iVar8 + Sector->xmin, - iVar9 + Sector->ymin,iVar3 + Sector->zmin); - ppTVar5 = pmVar2->entry; - } - else { - ppTVar5 = Sector->entry + iVar3 * iVar1 * Sector->dy + iVar9 * iVar1 + iVar8; - } - if (*ppTVar5 == (TSector *)0x0) { - pTVar4 = (TSector *)malloc(0x1008); - pmVar2 = Sector; - iVar9 = y - Sector->ymin; - iVar3 = z - Sector->zmin; - iVar8 = x - Sector->xmin; - if (((iVar8 < 0) || (iVar1 = Sector->dx, iVar1 <= iVar8)) || - ((iVar9 < 0 || (((Sector->dy <= iVar9 || (iVar3 < 0)) || (Sector->dz <= iVar3)))))) { - error("matrix3d::operator(): Ungueltiger Index %d/%d/%d.\n",iVar8 + Sector->xmin, - iVar9 + Sector->ymin,iVar3 + Sector->zmin); - ppTVar5 = pmVar2->entry; - } - else { - ppTVar5 = Sector->entry + iVar3 * iVar1 * Sector->dy + iVar9 * iVar1 + iVar8; - } - *ppTVar5 = pTVar4; - uVar6 = 0x1008; - pTVar10 = pTVar4; - if (((uint)pTVar4 & 4) != 0) { - pTVar4->MapCon[0][0].ObjectID = 0; - uVar6 = 0x1004; - pTVar10 = (TSector *)(pTVar4->MapCon[0] + 1); - } - for (uVar6 = uVar6 >> 2; uVar6 != 0; uVar6 = uVar6 - 1) { - pTVar10->MapCon[0][0].ObjectID = 0; - pTVar10 = (TSector *)(pTVar10->MapCon[0] + 1); - } - pTVar4->Status = '\0'; - pTVar4->TimeStamp = RoundNr; - local_5c = 0; - do { - iVar3 = 0; - do { - CreateObject(); - local_3c[0].ObjectID = local_2c; - pTVar7 = AccessObject(local_3c); - pTVar7->Attributes[1] = x * 0x20 + local_5c; - local_3c[0].ObjectID = local_2c; - pTVar7 = AccessObject(local_3c); - pTVar7->Attributes[2] = y * 0x20 + iVar3; - local_3c[0].ObjectID = local_2c; - pTVar7 = AccessObject(local_3c); - pTVar7->Attributes[3] = z; - iVar8 = iVar3 + 1; - pTVar4->MapCon[local_5c][iVar3].ObjectID = local_2c; - iVar3 = iVar8; - } while (iVar8 < 0x20); - local_5c = local_5c + 1; - } while (local_5c < 0x20); - pTVar4->MapFlags = '\0'; - pTVar4->Status = '\x01'; - } - else { - error("InitSector: Sektor %d/%d/%d existiert schon.\n",x,y,z); - } - return; -} - - - -void SwapObject(TWriteBinaryFile *File,Object *Obj,ulong FileNumber) - -{ - TObject *Entry_00; - bool bVar1; - TObject *pTVar2; - ulong Position; - uint uVar3; - TObject *Entry; - TObject *local_5c; - TObject *local_4c; - Object Help; - Object local_3c; - Object Search; - Object local_2c [7]; - - bVar1 = false; - if (Obj->ObjectID != 0) { - uVar3 = Obj->ObjectID & HashTableMask; - if (HashTableType[uVar3] == '\x02') { - UnswapSector(HashTableData[uVar3]); - } - if ((HashTableType[uVar3] == '\x01') && (*(ulong *)HashTableData[uVar3] == Obj->ObjectID)) { - bVar1 = true; - } - else { - bVar1 = false; - } - } - if (!bVar1) { - // try { // try from 0805b9bf to 0805bb3b has its CatchHandler @ 0805bb46 - error(&DAT_080f2300); - return; - } - Entry_00 = (TObject *)HashTableData[HashTableMask & Obj->ObjectID]; - (*(File->super_TWriteStream)._vptr_TWriteStream[5])(File,Entry_00,0x20); - local_3c = (Object)Obj->ObjectID; - pTVar2 = AccessObject(&local_3c); - ObjectType::setTypeID((ObjectType *)local_2c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)local_2c,CONTAINER); - if (!bVar1) { - local_2c[0] = (Object)Obj->ObjectID; - pTVar2 = AccessObject(local_2c); - ObjectType::setTypeID((ObjectType *)&local_3c,(pTVar2->Type).TypeID); - bVar1 = ObjectType::getFlag((ObjectType *)&local_3c,CHEST); - if (!bVar1) goto LAB_0805bad8; - } - local_3c.ObjectID = Object::getAttribute(Obj,CONTENT); - local_2c[0].ObjectID = NONE.ObjectID; - local_4c = (TObject *)NONE.ObjectID; - if (local_3c.ObjectID != NONE.ObjectID) { - do { - Entry = (TObject *)local_3c.ObjectID; - local_4c = (TObject *)local_3c.ObjectID; - local_2c[0].ObjectID = NONE.ObjectID; - pTVar2 = AccessObject((Object *)&Entry); - local_5c = (TObject *)(pTVar2->NextObject).ObjectID; - Entry = local_4c; - local_3c.ObjectID = (ulong)local_5c; - local_2c[0].ObjectID = (ulong)local_5c; - SwapObject(File,(Object *)&Entry,FileNumber); - local_2c[0].ObjectID = NONE.ObjectID; - local_4c = (TObject *)NONE.ObjectID; - } while (local_3c.ObjectID != NONE.ObjectID); - } -LAB_0805bad8: - PutFreeObjectSlot(Entry_00); - HashTableType[HashTableMask & Obj->ObjectID] = '\x02'; - HashTableData[HashTableMask & Obj->ObjectID] = FileNumber; - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void SwapSector(void) - -{ - int iVar1; - TSector *pTVar2; - matrix3d *pmVar3; - bool bVar4; - TSector *Help; - int iVar5; - TSector **ppTVar6; - int iVar7; - int iVar8; - int *piVar9; - Object *Obj; - char *__oflag; - int local_206c; - int local_2068; - int yy; - int xx; - TSector *local_205c; - int z; - int y; - int x; - ulong Oldest; - TSector *Sec; - int SecZ; - int SecY; - int SecX; - undefined1 local_202c [4]; - TWriteBinaryFile File; - char local_101c [4]; - char FileName [4096]; - - Oldest = 0; - SecY = 0; - SecZ = 0; - x = RoundNr + 1; - Sec = (TSector *)0x0; - y = SectorXMin; - iVar5 = SectorYMax; - iVar7 = SectorXMax; - if (SectorXMin <= SectorXMax) { - do { - z = SectorYMin; - if (SectorYMin <= iVar5) { - local_206c = SectorZMax; - do { - local_205c = (TSector *)SectorZMin; - if (SectorZMin <= local_206c) { - do { - pmVar3 = Sector; - iVar8 = z - Sector->ymin; - iVar5 = (int)local_205c - Sector->zmin; - iVar7 = y - Sector->xmin; - if (((((iVar7 < 0) || (iVar1 = Sector->dx, iVar1 <= iVar7)) || - (iVar8 < 0)) || ((Sector->dy <= iVar8 || (iVar5 < 0)))) || - (Sector->dz <= iVar5)) { - error("matrix3d::operator(): Ungueltiger Index %d/%d/%d.\n", - iVar7 + Sector->xmin,iVar8 + Sector->ymin,iVar5 + Sector->zmin - ); - ppTVar6 = pmVar3->entry; - local_206c = SectorZMax; - } - else { - ppTVar6 = Sector->entry + - iVar5 * iVar1 * Sector->dy + iVar8 * iVar1 + iVar7; - } - pTVar2 = *ppTVar6; - if (((pTVar2 != (TSector *)0x0) && (pTVar2->Status == '\x01')) && - (pTVar2->TimeStamp < (uint)x)) { - SecZ = z; - SecY = y; - Sec = local_205c; - x = pTVar2->TimeStamp; - Oldest = (ulong)pTVar2; - } - local_205c = (TSector *)((int)&local_205c->MapCon[0][0].ObjectID + 1); - iVar5 = SectorYMax; - } while ((int)local_205c <= local_206c); - } - z = z + 1; - iVar7 = SectorXMax; - } while (z <= iVar5); - } - y = y + 1; - } while (y <= iVar7); - } - if (Oldest == 0) { - error("FATAL ERROR in SwapSector: Es kann kein Sektor ausgelagert werden.\n"); - // WARNING: Subroutine does not return - abort(); - } - do { - SwapSector::lexical_block_2::FileNumber = SwapSector::lexical_block_2::FileNumber + 1; - if (99999999 < SwapSector::lexical_block_2::FileNumber) { - SwapSector::lexical_block_2::FileNumber = 1; - } - __oflag = SAVEPATH; - sprintf(local_101c,"%s/%08ld.swp",SAVEPATH,SwapSector::lexical_block_2::FileNumber); - bVar4 = FileExists(local_101c); - } while (bVar4); - TWriteBinaryFile::TWriteBinaryFile((TWriteBinaryFile *)local_202c); - // try { // try from 0805bd5f to 0805be46 has its CatchHandler @ 0805bee3 - TWriteBinaryFile::open((TWriteBinaryFile *)local_202c,local_101c,(int)__oflag); - print(); - TWriteStream::writeQuad((TWriteStream *)local_202c,SecY); - TWriteStream::writeQuad((TWriteStream *)local_202c,SecZ); - TWriteStream::writeQuad((TWriteStream *)local_202c,(ulong)Sec); - yy = 0; - do { - local_2068 = 0; - piVar9 = (int *)(Oldest + yy * 0x80); - do { - SecX = *piVar9; - Obj = (Object *)&SecX; - SwapObject((TWriteBinaryFile *)local_202c,Obj,SwapSector::lexical_block_2::FileNumber); - local_2068 = local_2068 + 1; - piVar9 = piVar9 + 1; - } while (local_2068 < 0x20); - yy = yy + 1; - } while (yy < 0x20); - *(undefined1 *)(Oldest + 0x1004) = 2; - TWriteBinaryFile::close((TWriteBinaryFile *)local_202c,(int)Obj); - TWriteBinaryFile::~TWriteBinaryFile((TWriteBinaryFile *)local_202c,(int)Obj); - return; -} - - - -void UnswapSector(ulong FileNumber) - -{ - int iVar1; - TSector *pTVar2; - ulong *puVar3; - matrix3d *pmVar4; - uchar *puVar5; - int iVar6; - TObject *pTVar7; - ulong uVar8; - ulong uVar9; - int iVar10; - TSector **ppTVar11; - int iVar12; - ulong nr; - int iVar13; - uint uVar14; - TSector *Sec; - char *pcVar15; - ulong uVar16; - TObject *local_204c; - int SecZ; - int SecY; - int SecX; - int FileSize; - TReadBinaryFile File; - char local_101c [4]; - char FileName [4096]; - - pcVar15 = SAVEPATH; - sprintf(local_101c,"%s/%08ld.swp",SAVEPATH,FileNumber); - TReadBinaryFile::TReadBinaryFile((TReadBinaryFile *)&FileSize); - // try { // try from 0805bf7c to 0805c0c2 has its CatchHandler @ 0805c257 - TReadBinaryFile::open((TReadBinaryFile *)&FileSize,local_101c,(int)pcVar15); - iVar6 = TReadBinaryFile::getSize((TReadBinaryFile *)&FileSize); - pTVar7 = (TObject *)TReadStream::readQuad((TReadStream *)&FileSize); - uVar8 = TReadStream::readQuad((TReadStream *)&FileSize); - uVar9 = TReadStream::readQuad((TReadStream *)&FileSize); - pcVar15 = "Lagere Sector %d/%d/%d ein...\n"; - uVar16 = uVar9; - print(); - pmVar4 = Sector; - iVar13 = uVar8 - Sector->ymin; - iVar10 = uVar9 - Sector->zmin; - iVar12 = (int)pTVar7 - Sector->xmin; - if ((((iVar12 < 0) || (iVar1 = Sector->dx, iVar1 <= iVar12)) || (iVar13 < 0)) || - (((Sector->dy <= iVar13 || (iVar10 < 0)) || (Sector->dz <= iVar10)))) { - pcVar15 = (char *)(iVar12 + Sector->xmin); - error("matrix3d::operator(): Ungueltiger Index %d/%d/%d.\n",pcVar15,iVar13 + Sector->ymin, - iVar10 + Sector->zmin,uVar16); - ppTVar11 = pmVar4->entry; - } - else { - ppTVar11 = Sector->entry + iVar12 + iVar13 * iVar1 + iVar10 * iVar1 * Sector->dy; - } - pTVar2 = *ppTVar11; - if (pTVar2 == (TSector *)0x0) { - pcVar15 = "UnswapSector: Sektor %d/%d/%d existiert nicht.\n"; - } - else { - if (pTVar2->Status == '\x02') { - while( true ) { - // try { // try from 0805c0db to 0805c1ee has its CatchHandler @ 0805c257 - iVar10 = TReadBinaryFile::getPosition((TReadBinaryFile *)&FileSize); - if (iVar6 <= iVar10) break; - if (FirstFreeObject == (TObject *)0x0) { - SwapSector(); - } - local_204c = FirstFreeObject; - if (FirstFreeObject == (TObject *)0x0) { - error("GetFreeObjectSlot: Kein freier Platz mehr.\n"); - local_204c = (TObject *)0x0; - } - else { - puVar3 = &FirstFreeObject->ObjectID; - FirstFreeObject = (TObject *)(FirstFreeObject->NextObject).ObjectID; - *puVar3 = 0; - (local_204c->NextObject).ObjectID = 0; - (local_204c->Container).ObjectID = 0; - (local_204c->Type).TypeID = 0; - local_204c->Attributes[0] = 0; - local_204c->Attributes[1] = 0; - local_204c->Attributes[2] = 0; - local_204c->Attributes[3] = 0; - } - pTVar7 = local_204c; - TReadBinaryFile::readBytes((TReadBinaryFile *)&FileSize,(uchar *)local_204c,0x20); - puVar5 = HashTableType; - pcVar15 = (char *)local_204c->ObjectID; - uVar14 = (uint)pcVar15 & HashTableMask; - if (HashTableType[uVar14] == '\x02') { - HashTableData[uVar14] = (ulong)local_204c; - puVar5[uVar14] = '\x01'; - pcVar15 = (char *)pTVar7; - } - else { - error("UnswapSector: Objekt %ld existiert schon.\n"); - } - } - pTVar2->Status = '\x01'; - TReadBinaryFile::close((TReadBinaryFile *)&FileSize,(int)pcVar15); - unlink(local_101c); - goto LAB_0805c0c3; - } - pcVar15 = "UnswapSector: Sektor %d/%d/%d ist nicht ausgelagert.\n"; - } - error(pcVar15,pTVar7,uVar8,uVar9,uVar16); - TReadBinaryFile::close((TReadBinaryFile *)&FileSize,(int)pTVar7); - pcVar15 = (char *)pTVar7; -LAB_0805c0c3: - TReadBinaryFile::~TReadBinaryFile((TReadBinaryFile *)&FileSize,(int)pcVar15); - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void DeleteSwappedSectors(void) - -{ - DIR *__dirp; - dirent *pdVar1; - size_t sVar2; - int iVar3; - dirent *DirEntry; - char *pcVar4; - char *pcVar5; - bool bVar6; - char *s; - DIR *WorkDir; - char FileName [4096]; - - __dirp = opendir(SAVEPATH); - if (__dirp == (DIR *)0x0) { - error("DeleteSwappedSectors: Unterverzeichnis %s nicht gefunden\n",SAVEPATH); - } - else { - while (pdVar1 = readdir(__dirp), pdVar1 != (dirent *)0x0) { - sVar2 = strlen(pdVar1->d_name); - bVar6 = sVar2 == 0xc; - if (bVar6) { - iVar3 = 4; - pcVar4 = pdVar1->d_name + 8; - pcVar5 = ".swp"; - do { - if (iVar3 == 0) break; - iVar3 = iVar3 + -1; - bVar6 = *pcVar4 == *pcVar5; - pcVar4 = pcVar4 + 1; - pcVar5 = pcVar5 + 1; - } while (bVar6); - if (bVar6) { - sprintf((char *)&WorkDir,"%s/%s",SAVEPATH,pdVar1->d_name); - unlink((char *)&WorkDir); - } - } - } - closedir(__dirp); - } - return; -} - - - -int GetInstanceAttributeByName(char *Name) - -{ - int iVar1; - int i; - int iVar2; - char (*s1) [30]; - - iVar2 = 0; - s1 = InstanceAttributeNames; - do { - iVar1 = stricmp(*s1,Name,-1); - if (iVar1 == 0) { - return iVar2; - } - iVar2 = iVar2 + 1; - s1 = s1 + 1; - } while (iVar2 < 0x12); - return -1; -} - - - -// WARNING: Variable defined which should be unmapped: Skip_local - -void LoadObjects(TReadScriptFile *Script,TWriteStream *Stream,bool Skip) - -{ - bool bVar1; - char cVar2; - uint uVar3; - undefined4 *puVar4; - char *pcVar5; - int iVar6; - ushort TypeID; - char (*s1) [30]; - uint local_24; - int i; - int iStack_18; - bool ProcessObjects; - int Depth; - bool Skip_local; - - iStack_18 = 1; - // try { // try from 0805c41e to 0805c65e has its CatchHandler @ 0805c661 - TReadScriptFile::readSymbol(Script,'{'); - bVar1 = true; - TReadScriptFile::nextToken(Script); - do { - if (bVar1) { - if (Script->Token == SPECIAL) { - cVar2 = TReadScriptFile::getSpecial(Script); - if (cVar2 == '}') { - if (!Skip) { - (*Stream->_vptr_TWriteStream[2])(Stream,0xffff); - } - iStack_18 = iStack_18 + -1; - bVar1 = false; - if (iStack_18 < 1) { - return; - } - goto LAB_0805c45f; - } - if ((Script->Token == SPECIAL) && - (cVar2 = TReadScriptFile::getSpecial(Script), cVar2 == ',')) { - TReadScriptFile::nextToken(Script); - } - } - uVar3 = TReadScriptFile::getNumber(Script); - bVar1 = ObjectTypeExists(uVar3 & 0xffff); - if (!bVar1) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "unknown object type"; -LAB_0805c49b: - // WARNING: Subroutine does not return - __cxa_throw(puVar4,char_const*::typeinfo,0); - } - if (!Skip) { - (*Stream->_vptr_TWriteStream[2])(Stream,uVar3 & 0xffff); - } - bVar1 = false; -LAB_0805c45f: - TReadScriptFile::nextToken(Script); - } - else { - if (Script->Token != SPECIAL) { - pcVar5 = TReadScriptFile::getIdentifier(Script); - s1 = InstanceAttributeNames; - local_24 = 0; - do { - iVar6 = stricmp(*s1,pcVar5,-1); - if (iVar6 == 0) goto LAB_0805c564; - local_24 = local_24 + 1; - s1 = s1 + 1; - } while ((int)local_24 < 0x12); - local_24 = 0xffffffff; -LAB_0805c564: - if (local_24 == 0xffffffff) { - puVar4 = (undefined4 *)__cxa_allocate_exception(4); - *puVar4 = "unknown attribute"; - goto LAB_0805c49b; - } - TReadScriptFile::readSymbol(Script,'='); - if (!Skip) { - (*Stream->_vptr_TWriteStream[1])(Stream,local_24 & 0xff); - } - if (local_24 == 0) { - iStack_18 = iStack_18 + 1; - TReadScriptFile::readSymbol(Script,'{'); - bVar1 = true; - } - else if (local_24 - 9 < 2) { - if (Skip) { - TReadScriptFile::readString(Script); - } - else { - pcVar5 = TReadScriptFile::readString(Script); - (*Stream->_vptr_TWriteStream[4])(Stream,pcVar5); - } - } - else if (Skip) { - TReadScriptFile::readNumber(Script); - } - else { - iVar6 = TReadScriptFile::readNumber(Script); - (*Stream->_vptr_TWriteStream[3])(Stream,iVar6); - } - goto LAB_0805c45f; - } - if (!Skip) { - (*Stream->_vptr_TWriteStream[1])(Stream,0xff); - } - bVar1 = true; - } - if (iStack_18 < 1) { - return; + TDepotInfo *pTVar1; + char *Text; + + if ((DepotNumber < DepotInfo.min) || (DepotInfo.max < DepotNumber)) { + Text = &DAT_080f21c0; + } + else { + pTVar1 = vector::operator()(&DepotInfo,DepotNumber); + if (pTVar1 != (TDepotInfo *)0x0) { + pTVar1 = vector::operator()(&DepotInfo,DepotNumber); + return pTVar1->Town; } - } while( true ); + Text = &DAT_080f2200; + } + error(Text,DepotNumber); + return "unknown"; } -void LoadObjects(TReadStream *Stream,Object *Con) +// WARNING: Variable defined which should be unmapped: PremiumAccount_local + +int GetDepotSize(int DepotNumber,bool PremiumAccount) { - bool bVar1; - char cVar2; - ulong Value; - uint uVar3; - TObject *pTVar4; - INSTANCEATTRIBUTE IVar5; - ulong Value_00; - int NewDelay; - ulong Value_1; - ushort TypeID; - int Depth; - int iVar6; - char local_108c [3]; - bool ProcessObjects; - char Help [4096]; - ObjectType local_7c [4]; - ulong local_6c [4]; - Object local_5c; - ObjectType Type; - Object local_3c [4]; - Object local_2c; - Object Obj; + int iVar1; + TDepotInfo *pTVar2; + bool PremiumAccount_local; - iVar6 = 1; - bVar1 = true; - local_2c.ObjectID = NONE.ObjectID; - do { - if (bVar1) { - // try { // try from 0805c6bb to 0805c867 has its CatchHandler @ 0805c870 - uVar3 = (*Stream->_vptr_TReadStream[2])(Stream); - if ((short)uVar3 == -1) { - iVar6 = iVar6 + -1; - local_5c = (Object)Con->ObjectID; - local_3c[0].ObjectID = local_5c.ObjectID; - local_2c.ObjectID = local_5c.ObjectID; - pTVar4 = AccessObject(&local_5c); - local_3c[0].ObjectID = (pTVar4->Container).ObjectID; - Con->ObjectID = (ulong)local_3c[0]; - } - else { - ObjectCounter = ObjectCounter + 1; - ObjectType::setTypeID((ObjectType *)&local_5c,uVar3 & 0xffff); - bVar1 = false; - if ((0 < (int)local_5c.ObjectID) && ((int)local_5c.ObjectID < 0xb)) { - bVar1 = true; - } - if (bVar1) { - local_6c[0] = Con->ObjectID; - GetContainerObject(local_3c,(int)local_6c); - } - else { - ObjectType::setTypeID(local_7c,local_5c.ObjectID); - Help._4092_4_ = Con->ObjectID; - AppendObject(local_3c,(ObjectType *)(Help + 0xffc)); - } - local_2c.ObjectID = local_3c[0].ObjectID; - } - bVar1 = false; + if ((DepotNumber < DepotInfo.min) || (DepotInfo.max < DepotNumber)) { + error(&DAT_080f2240,DepotNumber); + iVar1 = 1; + } + else { + pTVar2 = vector::operator()(&DepotInfo,DepotNumber); + if (pTVar2->Size < 1) { + pTVar2 = vector::operator()(&DepotInfo,DepotNumber); + error(&DAT_080f2280,pTVar2->Size,DepotNumber); + pTVar2 = vector::operator()(&DepotInfo,DepotNumber); + pTVar2->Size = 1; } - else { - IVar5 = (*Stream->_vptr_TReadStream[1])(Stream); - cVar2 = (char)IVar5; - if (cVar2 != -1) { - if (cVar2 != '\0') { - if ((byte)(cVar2 - 9U) < 2) { - (*Stream->_vptr_TReadStream[4])(Stream,local_108c,0x1000); - Value_00 = AddDynamicString(local_108c); - } - else { - if (cVar2 == '\x0f') { - NewDelay = (*Stream->_vptr_TReadStream[3])(Stream); - if (NewDelay != 0) { - Help[0xffc] = (undefined1)local_2c.ObjectID; - Help[0xffd] = local_2c.ObjectID._1_1_; - Help[0xffe] = local_2c.ObjectID._2_1_; - Help[0xfff] = local_2c.ObjectID._3_1_; - CronChange((Object *)(Help + 0xffc),NewDelay); - } - goto LAB_0805c72d; - } - Value_00 = (*Stream->_vptr_TReadStream[3])(Stream); - } - Object::setAttribute(&local_2c,IVar5 & 0xff,Value_00); - goto LAB_0805c72d; - } - iVar6 = iVar6 + 1; - local_7c[0].TypeID = local_2c.ObjectID; - Con->ObjectID = (ulong)local_2c; - Help[0xffc] = (undefined1)local_2c.ObjectID; - Help[0xffd] = local_2c.ObjectID._1_1_; - Help[0xffe] = local_2c.ObjectID._2_1_; - Help[0xfff] = local_2c.ObjectID._3_1_; - } - bVar1 = true; + if (PremiumAccount) { + pTVar2 = vector::operator()(&DepotInfo,DepotNumber); + iVar1 = pTVar2->Size * 2; } -LAB_0805c72d: - if (iVar6 < 1) { - return; + else { + pTVar2 = vector::operator()(&DepotInfo,DepotNumber); + iVar1 = pTVar2->Size; } - } while( true ); + } + return iVar1; } -void LoadSector(char *FileName,int x,int y,int z) +void GetStartPosition(int *x,int *y,int *z,bool Newbie) { int iVar1; - TSector *pTVar2; - bool bVar3; - matrix3d *pmVar4; - char cVar5; - uchar *Help; - int iVar6; - TSector **ppTVar7; - char *pcVar8; - TObject *pTVar9; - byte *pbVar10; - int iVar11; - int iVar12; - int iVar13; - char *pcVar14; - undefined1 uVar15; - char *pcVar16; - uint local_4034; - int yy; - int xx; - TSector *Sec; - undefined1 local_400c [4]; - TReadBuffer ReadBuffer; - TReadScriptFile Script; - bVar3 = false; - if ((SectorXMin <= x) && (x <= SectorXMax)) { - bVar3 = true; + if (Newbie) { + *x = NewbieStartPositionX; + *y = NewbieStartPositionY; + iVar1 = NewbieStartPositionZ; } - if (bVar3) { - bVar3 = false; - if ((SectorYMin <= y) && (y <= SectorYMax)) { - bVar3 = true; - } - if (bVar3) { - bVar3 = false; - if ((SectorZMin <= z) && (z <= SectorZMax)) { - bVar3 = true; - } - if (bVar3) { - iVar12 = z; - // try { // try from 0805c920 to 0805c932 has its CatchHandler @ 0805cde4 - InitSector(x,y,z); - TReadScriptFile::TReadScriptFile((TReadScriptFile *)&ReadBuffer.Position); - // try { // try from 0805c943 to 0805cd14 has its CatchHandler @ 0805cd60 - TReadScriptFile::open((TReadScriptFile *)&ReadBuffer.Position,FileName,iVar12); - pcVar16 = "Lade Sektor %d/%d/%d ...\n"; - iVar12 = z; - print(); - pmVar4 = Sector; - iVar13 = y - Sector->ymin; - iVar6 = z - Sector->zmin; - iVar11 = x - Sector->xmin; - if (((((iVar11 < 0) || (iVar1 = Sector->dx, iVar1 <= iVar11)) || (iVar13 < 0)) || - ((Sector->dy <= iVar13 || (iVar6 < 0)))) || (Sector->dz <= iVar6)) { - pcVar16 = (char *)(iVar11 + Sector->xmin); - error("matrix3d::operator(): Ungueltiger Index %d/%d/%d.\n",pcVar16, - iVar13 + Sector->ymin,iVar6 + Sector->zmin,iVar12); - ppTVar7 = pmVar4->entry; - } - else { - ppTVar7 = Sector->entry + iVar6 * iVar1 * Sector->dy + iVar13 * iVar1 + iVar11; - } - pTVar2 = *ppTVar7; - yy = -1; - local_4034 = 0xffffffff; -LAB_0805ca1d: - do { - while( true ) { - while( true ) { - do { - TReadScriptFile::nextToken((TReadScriptFile *)&ReadBuffer.Position); - if (ReadBuffer.Position == 0) { - TReadScriptFile::close - ((TReadScriptFile *)&ReadBuffer.Position,(int)pcVar16) - ; - // try { // try from 0805cd1e to 0805cd22 has its CatchHandler @ 0805cde4 - TReadScriptFile::~TReadScriptFile - ((TReadScriptFile *)&ReadBuffer.Position,(int)pcVar16) - ; - return; - } - } while ((ReadBuffer.Position == 6) && - (cVar5 = TReadScriptFile::getSpecial - ((TReadScriptFile *)&ReadBuffer.Position), - cVar5 == ',')); - if (ReadBuffer.Position != 4) break; - pbVar10 = TReadScriptFile::getBytesequence - ((TReadScriptFile *)&ReadBuffer.Position); - yy = (int)*pbVar10; - local_4034 = (uint)pbVar10[1]; - pcVar16 = (char *)0x3a; - TReadScriptFile::readSymbol((TReadScriptFile *)&ReadBuffer.Position,':') - ; - } - if (ReadBuffer.Position == 1) break; - pcVar16 = "next map point expected"; -LAB_0805ca73: - TReadScriptFile::error((TReadScriptFile *)&ReadBuffer.Position,pcVar16); - } - uVar15 = yy == -1; - if ((bool)uVar15) { - pcVar16 = "coordinate expected"; - TReadScriptFile::error - ((TReadScriptFile *)&ReadBuffer.Position,"coordinate expected"); - } - pcVar8 = TReadScriptFile::getIdentifier((TReadScriptFile *)&ReadBuffer.Position) - ; - iVar12 = 8; - pcVar14 = "refresh"; - do { - if (iVar12 == 0) break; - iVar12 = iVar12 + -1; - uVar15 = *pcVar8 == *pcVar14; - pcVar8 = pcVar8 + 1; - pcVar14 = pcVar14 + 1; - } while ((bool)uVar15); - if (!(bool)uVar15) { - pcVar8 = TReadScriptFile::getIdentifier - ((TReadScriptFile *)&ReadBuffer.Position); - iVar12 = 9; - pcVar14 = "nologout"; - do { - if (iVar12 == 0) break; - iVar12 = iVar12 + -1; - uVar15 = *pcVar8 == *pcVar14; - pcVar8 = pcVar8 + 1; - pcVar14 = pcVar14 + 1; - } while ((bool)uVar15); - if ((bool)uVar15) { - pTVar2->MapFlags = pTVar2->MapFlags | 2; - local_400c = (undefined1 [4])pTVar2->MapCon[yy][local_4034].ObjectID; - pTVar9 = AccessObject((Object *)local_400c); - pTVar9->Attributes[3] = pTVar9->Attributes[3] | 0x200; - } - else { - pcVar8 = TReadScriptFile::getIdentifier - ((TReadScriptFile *)&ReadBuffer.Position); - iVar12 = 0xf; - pcVar14 = "protectionzone"; - do { - if (iVar12 == 0) break; - iVar12 = iVar12 + -1; - uVar15 = *pcVar8 == *pcVar14; - pcVar8 = pcVar8 + 1; - pcVar14 = pcVar14 + 1; - } while ((bool)uVar15); - if ((bool)uVar15) { - pTVar2->MapFlags = pTVar2->MapFlags | 4; - local_400c = (undefined1 [4]) - pTVar2->MapCon[yy][local_4034].ObjectID; - pTVar9 = AccessObject((Object *)local_400c); - pTVar9->Attributes[3] = pTVar9->Attributes[3] | 0x400; - } - else { - pcVar16 = TReadScriptFile::getIdentifier - ((TReadScriptFile *)&ReadBuffer.Position); - iVar12 = 8; - pcVar8 = "content"; - do { - if (iVar12 == 0) break; - iVar12 = iVar12 + -1; - uVar15 = *pcVar16 == *pcVar8; - pcVar16 = pcVar16 + 1; - pcVar8 = pcVar8 + 1; - } while ((bool)uVar15); - if (!(bool)uVar15) { - pcVar16 = "unknown map flag"; - goto LAB_0805ca73; - } - TReadScriptFile::readSymbol - ((TReadScriptFile *)&ReadBuffer.Position,'='); - HelpBuffer.super_TWriteBuffer.Position = 0; - LoadObjects((TReadScriptFile *)&ReadBuffer.Position, - (TWriteStream *)&HelpBuffer,false); - TReadBuffer::TReadBuffer - ((TReadBuffer *)local_400c, - HelpBuffer.super_TWriteBuffer.Data, - HelpBuffer.super_TWriteBuffer.Position); - GetMapContainer((int)&Sec,x * 0x20 + yy,y * 0x20 + local_4034); - pcVar16 = (char *)&Sec; - LoadObjects((TReadStream *)local_400c,(Object *)pcVar16); - } - } - goto LAB_0805ca1d; - } - pTVar2->MapFlags = pTVar2->MapFlags | 1; - local_400c = (undefined1 [4])pTVar2->MapCon[yy][local_4034].ObjectID; - pTVar9 = AccessObject((Object *)local_400c); - pTVar9->Attributes[3] = pTVar9->Attributes[3] | 0x100; - } while( true ); - } - } + else { + *x = VeteranStartPositionX; + *y = VeteranStartPositionY; + iVar1 = VeteranStartPositionZ; } + *z = iVar1; return; } @@ -9143,71 +6748,59 @@ LAB_0805ca73: // WARNING: Unknown calling convention -- yet parameter storage is locked -void LoadMap(void) +bool GetMarkPosition(void) { - char *__s; - DIR *__dirp; - dirent *pdVar1; - size_t sVar2; - undefined4 *puVar3; - int iVar4; - dirent *DirEntry; - char *pcVar5; - char *pcVar6; - bool bVar7; - DIR *WorkDir; - int SectorCounter; - int x; - int y; - int z; - char FileName [4096]; + TMark *pTVar1; + int iVar2; + int i; + int i_00; + char *in_stack_00000004; + int *in_stack_00000008; + int *in_stack_0000000c; + int *in_stack_00000010; - __dirp = opendir(MAPPATH); - if (__dirp == (DIR *)0x0) { - error("LoadMap: Unterverzeichnis %s nicht gefunden\n",MAPPATH); - puVar3 = (undefined4 *)__cxa_allocate_exception(4); - *puVar3 = "Cannot load map"; - // WARNING: Subroutine does not return - __cxa_throw(puVar3,char_const*::typeinfo,0); - } - // try { // try from 0805ce35 to 0805cfb2 has its CatchHandler @ 0805cfb3 - print(); - ObjectCounter = 0; - do { - do { - pdVar1 = readdir(__dirp); - if (pdVar1 == (dirent *)0x0) { - closedir(__dirp); - print(); - print(); - return; - } - __s = pdVar1->d_name; - sVar2 = strlen(__s); - bVar7 = sVar2 == 8; - } while (sVar2 < 9); - iVar4 = 5; - pcVar5 = pdVar1->d_name + (sVar2 - 4); - pcVar6 = ".sec"; + i_00 = 0; + if (0 < Marks) { do { - if (iVar4 == 0) break; - iVar4 = iVar4 + -1; - bVar7 = *pcVar5 == *pcVar6; - pcVar5 = pcVar5 + 1; - pcVar6 = pcVar6 + 1; - } while (bVar7); - if (bVar7) { - iVar4 = sscanf(__s,"%d-%d-%d.sec",&SectorCounter,&x,&y); - if (iVar4 == 3) { - sprintf((char *)&z,"%s/%s",MAPPATH,__s); - LoadSector((char *)&z,SectorCounter,x,y); + pTVar1 = vector::operator()(&Mark,i_00); + iVar2 = stricmp(pTVar1->Name,in_stack_00000004,-1); + if (iVar2 == 0) { + pTVar1 = vector::operator()(&Mark,i_00); + *in_stack_00000008 = pTVar1->x; + pTVar1 = vector::operator()(&Mark,i_00); + *in_stack_0000000c = pTVar1->y; + pTVar1 = vector::operator()(&Mark,i_00); + *in_stack_00000010 = pTVar1->z; + return true; } - } - } while( true ); + i_00 = i_00 + 1; + } while (i_00 < Marks); + } + return false; } +int GetInstanceAttributeByName(char *Name) + +{ + int iVar1; + int i; + int iVar2; + char (*s1) [30]; + + iVar2 = 0; + s1 = InstanceAttributeNames; + do { + iVar1 = stricmp(*s1,Name,-1); + if (iVar1 == 0) { + return iVar2; + } + iVar2 = iVar2 + 1; + s1 = s1 + 1; + } while (iVar2 < 0x12); + return -1; +} void SaveObjects(Object *Obj,TWriteStream *Stream,bool Stop) @@ -9442,193 +7035,6 @@ void SaveObjects(TReadStream *Stream,TWriteScriptFile *Script) return; } - - -void SaveSector(char *FileName,int x,int y,int z) - -{ - int iVar1; - TSector *pTVar2; - bool bVar3; - bool bVar4; - matrix3d *pmVar5; - byte bVar6; - int iVar7; - TSector **ppTVar8; - int iVar9; - int iVar10; - TSector *Sec; - int Flags; - char *__fd; - int in_stack_ffffef5c; - int local_106c; - int yy; - int xx; - bool Empty; - undefined1 local_105c [4]; - TReadBuffer ReadBuffer; - _func_int_varargs **local_103c; - Object Obj; - undefined1 local_102c [4]; - TWriteScriptFile Script; - - pmVar5 = Sector; - iVar10 = y - Sector->ymin; - iVar7 = z - Sector->zmin; - iVar9 = x - Sector->xmin; - if (((((iVar9 < 0) || (iVar1 = Sector->dx, iVar1 <= iVar9)) || (iVar10 < 0)) || - ((Sector->dy <= iVar10 || (iVar7 < 0)))) || (Sector->dz <= iVar7)) { - in_stack_ffffef5c = iVar10 + Sector->ymin; - error("matrix3d::operator(): Ungueltiger Index %d/%d/%d.\n",iVar9 + Sector->xmin, - in_stack_ffffef5c,iVar7 + Sector->zmin); - ppTVar8 = pmVar5->entry; - } - else { - ppTVar8 = Sector->entry + iVar7 * iVar1 * Sector->dy + iVar10 * iVar1 + iVar9; - } - pTVar2 = *ppTVar8; - if (pTVar2 != (TSector *)0x0) { - TWriteScriptFile::TWriteScriptFile((TWriteScriptFile *)local_102c); - // try { // try from 0805d5d8 to 0805d76d has its CatchHandler @ 0805d923 - TWriteScriptFile::open((TWriteScriptFile *)local_102c,FileName,in_stack_ffffef5c); - print(); - TWriteScriptFile::writeText - ((TWriteScriptFile *)local_102c,"# Tibia - graphical Multi-User-Dungeon"); - TWriteScriptFile::writeLn((TWriteScriptFile *)local_102c); - TWriteScriptFile::writeText((TWriteScriptFile *)local_102c,"# Data for sector "); - TWriteScriptFile::writeNumber((TWriteScriptFile *)local_102c,x); - TWriteScriptFile::writeText((TWriteScriptFile *)local_102c,"/"); - TWriteScriptFile::writeNumber((TWriteScriptFile *)local_102c,y); - TWriteScriptFile::writeText((TWriteScriptFile *)local_102c,"/"); - TWriteScriptFile::writeNumber((TWriteScriptFile *)local_102c,z); - TWriteScriptFile::writeLn((TWriteScriptFile *)local_102c); - TWriteScriptFile::writeLn((TWriteScriptFile *)local_102c); - bVar4 = true; - yy = 0; - do { - local_106c = 0; - do { - __fd = (char *)(x * 0x20 + yy); - GetFirstObject(); - ReadBuffer.Position = pTVar2->MapCon[yy][local_106c].ObjectID; - bVar6 = GetMapContainerFlags((Object *)&ReadBuffer.Position); - bVar3 = false; - ReadBuffer.Position = NONE.ObjectID; - if ((local_103c == (_func_int_varargs **)NONE.ObjectID) && (bVar6 == 0)) { - bVar3 = true; - } - if (!bVar3) { - TWriteScriptFile::writeNumber((TWriteScriptFile *)local_102c,yy); - TWriteScriptFile::writeText((TWriteScriptFile *)local_102c,"-"); - TWriteScriptFile::writeNumber((TWriteScriptFile *)local_102c,local_106c); - __fd = &DAT_080f2ab7; - TWriteScriptFile::writeText((TWriteScriptFile *)local_102c,": "); - if ((bVar6 & 1) != 0) { - __fd = "Refresh, "; - TWriteScriptFile::writeText((TWriteScriptFile *)local_102c,"Refresh, "); - } - if ((bVar6 & 2) != 0) { - __fd = "NoLogout, "; - TWriteScriptFile::writeText((TWriteScriptFile *)local_102c,"NoLogout, "); - } - if ((bVar6 & 4) != 0) { - __fd = "ProtectionZone, "; - TWriteScriptFile::writeText - ((TWriteScriptFile *)local_102c,"ProtectionZone, "); - } - ReadBuffer.Position = NONE.ObjectID; - local_105c = (undefined1 [4])NONE.ObjectID; - if (local_103c != (_func_int_varargs **)NONE.ObjectID) { - TWriteScriptFile::writeText((TWriteScriptFile *)local_102c,"Content="); - HelpBuffer.super_TWriteBuffer.Position = 0; - local_105c = (undefined1 [4])local_103c; - SaveObjects((Object *)local_105c,(TWriteStream *)&HelpBuffer,false); - TReadBuffer::TReadBuffer - ((TReadBuffer *)local_105c,HelpBuffer.super_TWriteBuffer.Data, - HelpBuffer.super_TWriteBuffer.Position); - __fd = (char *)local_102c; - SaveObjects((TReadStream *)local_105c,(TWriteScriptFile *)local_102c); - } - TWriteScriptFile::writeLn((TWriteScriptFile *)local_102c); - bVar4 = false; - } - local_106c = local_106c + 1; - } while (local_106c < 0x20); - yy = yy + 1; - } while (yy < 0x20); - TWriteScriptFile::close((TWriteScriptFile *)local_102c,(int)__fd); - if (bVar4) { - // try { // try from 0805d7ac to 0805d8f2 has its CatchHandler @ 0805d923 - error("SaveSector: Sektor %d/%d/%d ist leer.\n",x,y,z); - unlink(FileName); - __fd = (char *)x; - } - TWriteScriptFile::~TWriteScriptFile((TWriteScriptFile *)local_102c,(int)__fd); - } - return; -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void SaveMap(void) - -{ - int iVar1; - int iVar2; - int iVar3; - int z; - int iVar4; - int y; - int y_00; - int x; - int x_00; - char local_101c [4]; - char FileName [4096]; - - if (SaveMap::SavingMap) { - error("SaveMap: Karte wird schon gespeichert.\n"); - } - else { - SaveMap::SavingMap = true; - print(); - ObjectCounter = 0; - iVar2 = SectorXMax; - iVar3 = SectorYMax; - x_00 = SectorXMin; - if (SectorXMin <= SectorXMax) { - do { - iVar1 = SectorZMax; - y_00 = SectorYMin; - if (SectorYMin <= iVar3) { - do { - iVar2 = SectorZMin; - if (SectorZMin <= iVar1) { - do { - sprintf(local_101c,"%s/%04u-%04u-%02u.sec",MAPPATH,x_00,y_00,iVar2); - iVar4 = iVar2 + 1; - SaveSector(local_101c,x_00,y_00,iVar2); - iVar1 = SectorZMax; - iVar3 = SectorYMax; - iVar2 = iVar4; - } while (iVar4 <= SectorZMax); - } - y_00 = y_00 + 1; - iVar2 = SectorXMax; - } while (y_00 <= iVar3); - } - x_00 = x_00 + 1; - } while (x_00 <= iVar2); - } - print(); - SaveMap::SavingMap = false; - } - return; -} - - - void RefreshSector(int x,int y,int z,TReadStream *Stream) { @@ -10295,579 +7701,6 @@ LAB_0805e958: goto LAB_0805e966; } - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void ReadMapConfig(void) - -{ - TReadScriptFile *pTVar1; - char *pcVar2; - TMark *pTVar3; - size_t sVar4; - TDepotInfo *pTVar5; - undefined4 *puVar6; - int iVar7; - undefined1 uVar8; - int *__s; - char *pcVar9; - int *piVar10; - int DepotNumber; - char Ident [30]; - TReadScriptFile Script; - int local_101c; - char FileName [4096]; - - NewbieStartPositionY = 0; - SectorYMin = 1000; - SectorYMax = 0x3f7; - SectorZMax = 0xf; - RefreshedCylinders = 1; - SectorXMax = 0x3f7; - HashTableSize = 0x100000; - SectorXMin = 1000; - SectorZMin = 0; - OBCount = 0xa0000; - NewbieStartPositionX = 0; - VeteranStartPositionX = 0; - __s = &local_101c; - Marks = 0; - NewbieStartPositionZ = 0; - VeteranStartPositionY = 0; - VeteranStartPositionZ = 0; - pcVar9 = DATAPATH; - sprintf((char *)__s,"%s/map.dat"); - // try { // try from 0805f114 to 0805f118 has its CatchHandler @ 0805f850 - TReadScriptFile::TReadScriptFile((TReadScriptFile *)(Ident + 0x1c)); - // try { // try from 0805f126 to 0805f5e6 has its CatchHandler @ 0805f831 - TReadScriptFile::open((TReadScriptFile *)(Ident + 0x1c),(char *)__s,(int)pcVar9); - do { - TReadScriptFile::nextToken((TReadScriptFile *)(Ident + 0x1c)); - if (stack0xffffb004 == 0) { - TReadScriptFile::close((TReadScriptFile *)(Ident + 0x1c),(int)__s); - if (SectorXMin < 1) { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "illegal value for SectorXMin"; - } - else if (SectorXMax < 0x7ff) { - if (SectorYMin < 1) { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "illegal value for SectorYMin"; - } - else if (SectorYMax < 0x7ff) { - if (SectorZMin < 0) { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "illegal value for SectorZMin"; - } - else if (SectorZMax < 0x10) { - if (SectorXMax < SectorXMin) { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "SectorXMin is greater than SectorXMax"; - } - else if (SectorYMax < SectorYMin) { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "SectorYMin is greater than SectorYMax"; - } - else if (SectorZMax < SectorZMin) { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "SectorZMin is greater than SectorZMax"; - } - else if ((OBCount & 0x7fffU) == 0) { - if (OBCount < 1) { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "illegal value for CacheSize"; - } - else { - if (0x7fffffff < (uint)OBCount) { - OBCount = OBCount + 0x7fff; - } - OBCount = OBCount >> 0xf; - if (HashTableSize < 1) { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "illegal value for Objects"; - } - else if ((HashTableSize - 1U & HashTableSize) == 0) { - if (NewbieStartPositionX == 0) { - puVar6 = (undefined4 *) - __cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "no start position for newbies specified"; - } - else { - if (VeteranStartPositionX != 0) { - // try { // try from 0805f6c4 to 0805f6c8 has its CatchHandler @ 0805f850 - TReadScriptFile::~TReadScriptFile - ((TReadScriptFile *)(Ident + 0x1c),(int)__s); - return; - } - puVar6 = (undefined4 *) - __cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "no start position for veterans specified"; - } - } - else { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "Objects must be a power of 2"; - } - } - } - else { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "CacheSize must be a multiple of 32768"; - } - } - else { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "illegal value for SectorZMax"; - } - } - else { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "illegal value for SectorYMax"; - } - } - else { - puVar6 = (undefined4 *)__cxa_allocate_exception(4,__s,pcVar9); - *puVar6 = "illegal value for SectorXMax"; - } - // WARNING: Subroutine does not return - // try { // try from 0805f6f9 to 0805f6fd has its CatchHandler @ 0805f831 - __cxa_throw(puVar6,char_const*::typeinfo,0); - } - uVar8 = stack0xffffb004 == 1; - if (!(bool)uVar8) { - TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"Identifier expected"); - } - pcVar2 = TReadScriptFile::getIdentifier((TReadScriptFile *)(Ident + 0x1c)); - strcpy((char *)&DepotNumber,pcVar2); - __s = (int *)0x3d; - TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'='); - iVar7 = 0xb; - piVar10 = &DepotNumber; - pcVar2 = "sectorxmin"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - SectorXMin = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - } - iVar7 = 0xb; - piVar10 = &DepotNumber; - pcVar2 = "sectorxmax"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - SectorXMax = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - } - iVar7 = 0xb; - piVar10 = &DepotNumber; - pcVar2 = "sectorymin"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - SectorYMin = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - } - iVar7 = 0xb; - piVar10 = &DepotNumber; - pcVar2 = "sectorymax"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - SectorYMax = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - } - iVar7 = 0xb; - piVar10 = &DepotNumber; - pcVar2 = "sectorzmin"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - SectorZMin = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - } - iVar7 = 0xb; - piVar10 = &DepotNumber; - pcVar2 = "sectorzmax"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - SectorZMax = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - } - iVar7 = 0x13; - piVar10 = &DepotNumber; - pcVar2 = "refreshedcylinders"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - RefreshedCylinders = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - } - iVar7 = 8; - piVar10 = &DepotNumber; - pcVar2 = "objects"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - HashTableSize = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - } - iVar7 = 10; - piVar10 = &DepotNumber; - pcVar2 = "cachesize"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - OBCount = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - } - iVar7 = 6; - piVar10 = &DepotNumber; - pcVar2 = "depot"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'('); - iVar7 = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - pTVar1 = (TReadScriptFile *)(Ident + 0x1c); - TReadScriptFile::readSymbol(pTVar1,','); - TReadScriptFile::nextToken(pTVar1); - if (stack0xffffb004 != 3) { - TReadScriptFile::error(pTVar1,"town name expected"); - } - pcVar2 = TReadScriptFile::getString((TReadScriptFile *)(Ident + 0x1c)); - sVar4 = strlen(pcVar2); - uVar8 = sVar4 == 0x13; - if (0x13 < sVar4) { - TReadScriptFile::error((TReadScriptFile *)(Ident + 0x1c),"town name too long"); - } - pcVar2 = TReadScriptFile::getString((TReadScriptFile *)(Ident + 0x1c)); - pTVar5 = vector::operator()(&DepotInfo,iVar7); - strcpy(pTVar5->Town,pcVar2); - TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),','); - pTVar5 = vector::operator()(&DepotInfo,iVar7); - iVar7 = TReadScriptFile::readNumber((TReadScriptFile *)(Ident + 0x1c)); - pTVar5->Size = iVar7; - __s = (int *)0x29; - TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),')'); - } - iVar7 = 5; - piVar10 = &DepotNumber; - pcVar2 = "mark"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - TReadScriptFile::readSymbol((TReadScriptFile *)(Ident + 0x1c),'('); - pcVar9 = TReadScriptFile::readString((TReadScriptFile *)(Ident + 0x1c)); - pTVar3 = vector::operator()(&Mark,Marks); - pTVar1 = (TReadScriptFile *)(Ident + 0x1c); - strcpy(pTVar3->Name,pcVar9); - TReadScriptFile::readSymbol(pTVar1,','); - vector::operator()(&Mark,Marks); - pTVar3 = vector::operator()(&Mark,Marks); - pcVar9 = (char *)&pTVar3->y; - vector::operator()(&Mark,Marks); - TReadScriptFile::readCoordinate(pTVar1); - __s = (int *)0x29; - TReadScriptFile::readSymbol(pTVar1,')'); - Marks = Marks + 1; - uVar8 = Marks == 0; - } - iVar7 = 0xc; - piVar10 = &DepotNumber; - pcVar2 = "newbiestart"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - piVar10 = &NewbieStartPositionY; - __s = &NewbieStartPositionX; - TReadScriptFile::readCoordinate((TReadScriptFile *)(Ident + 0x1c)); - pcVar9 = (char *)piVar10; - } - iVar7 = 0xd; - piVar10 = &DepotNumber; - pcVar2 = "veteranstart"; - do { - if (iVar7 == 0) break; - iVar7 = iVar7 + -1; - uVar8 = (char)*piVar10 == *pcVar2; - piVar10 = (int *)((int)piVar10 + 1); - pcVar2 = pcVar2 + 1; - } while ((bool)uVar8); - if ((bool)uVar8) { - piVar10 = &VeteranStartPositionY; - __s = &VeteranStartPositionX; - TReadScriptFile::readCoordinate((TReadScriptFile *)(Ident + 0x1c)); - pcVar9 = (char *)piVar10; - } - } while( true ); -} - - - -// WARNING: Unknown calling convention -- yet parameter storage is locked - -void InitMap(void) - -{ - int iVar1; - ulong *puVar2; - TObjectBlock **ppTVar3; - ulong *puVar4; - int i_2; - matrix3d *this; - TObject *pTVar5; - TObjectBlock *pTVar6; - int j; - int iVar7; - int iVar8; - TObject *Help; - int i_1; - int iVar9; - int i; - int iVar10; - - // try { // try from 0805f869 to 0805f879 has its CatchHandler @ 0805fad4 - ReadMapConfig(); - this = (matrix3d *)operator_new(0x1c); - // try { // try from 0805f8bd to 0805f8c1 has its CatchHandler @ 0805fab7 - matrix3d::matrix3d - (this,SectorXMin,SectorXMax,SectorYMin,SectorYMax,SectorZMin,SectorZMax,(TSector *)0x0 - ); - Sector = this; - // try { // try from 0805f8c8 to 0805fa67 has its CatchHandler @ 0805fad4 - DeleteSwappedSectors(); - iVar10 = 0; - ObjectBlock = (TObjectBlock **)malloc(OBCount << 2); - if (0 < OBCount) { - do { - ppTVar3 = ObjectBlock; - pTVar6 = (TObjectBlock *)malloc(0x100000); - ppTVar3[iVar10] = pTVar6; - iVar10 = iVar10 + 1; - } while (iVar10 < OBCount); - } - iVar10 = OBCount; - ppTVar3 = ObjectBlock; - iVar9 = 0; - if (0 < OBCount) { - iVar1 = OBCount + -1; - do { - iVar7 = 0; - do { - iVar8 = iVar7 + 1; - ppTVar3[iVar9]->Object[iVar7].NextObject.ObjectID = - (ulong)(ppTVar3[iVar9]->Object + iVar7 + 1); - iVar7 = iVar8; - } while (iVar8 < 0x7fff); - if (iVar9 < iVar1) { - ppTVar3[iVar9]->Object[0x7fff].NextObject.ObjectID = (ulong)ppTVar3[iVar9 + 1]; - } - else { - ppTVar3[iVar9]->Object[0x7fff].NextObject.ObjectID = 0; - } - iVar9 = iVar9 + 1; - } while (iVar9 < iVar10); - } - FirstFreeObject = (*ObjectBlock)->Object; - HashTableMask = HashTableSize - 1; - HashTableData = (ulong *)malloc(HashTableSize << 2); - HashTableType = (uchar *)malloc(HashTableSize); - memset(HashTableType,0,HashTableSize); - HashTableFree = HashTableSize + -1; - *HashTableType = 0xff; - puVar4 = HashTableData; - if (FirstFreeObject == (TObject *)0x0) { - SwapSector(); - } - pTVar5 = FirstFreeObject; - if (FirstFreeObject == (TObject *)0x0) { - error("GetFreeObjectSlot: Kein freier Platz mehr.\n"); - pTVar5 = (TObject *)0x0; - } - else { - puVar2 = &FirstFreeObject->ObjectID; - FirstFreeObject = (TObject *)(FirstFreeObject->NextObject).ObjectID; - *puVar2 = 0; - (pTVar5->NextObject).ObjectID = 0; - (pTVar5->Container).ObjectID = 0; - (pTVar5->Type).TypeID = 0; - pTVar5->Attributes[0] = 0; - pTVar5->Attributes[1] = 0; - pTVar5->Attributes[2] = 0; - pTVar5->Attributes[3] = 0; - } - *puVar4 = (ulong)pTVar5; - iVar10 = 0; - do { - CronHashTable[iVar10] = -1; - iVar10 = iVar10 + 1; - } while (iVar10 < 0x7ff); - CronEntries = 0; - LoadMap(); - return; -} - - - -// WARNING: Variable defined which should be unmapped: x - -void ExitMap(bool save) - -{ - TObjectBlock **ppTVar1; - int iVar2; - TSector **ppTVar3; - int iVar4; - int iVar5; - int i; - int iVar6; - matrix3d *pmVar7; - int local_1c; - int z; - int y; - int x; - - if (save) { - SaveMap(); - } - iVar6 = 0; - free(HashTableType); - free(HashTableData); - if (0 < OBCount) { - do { - ppTVar1 = ObjectBlock + iVar6; - iVar6 = iVar6 + 1; - free(*ppTVar1); - } while (iVar6 < OBCount); - } - free(ObjectBlock); - y = SectorXMin; - iVar6 = SectorXMax; - iVar4 = SectorYMax; - pmVar7 = Sector; - if (SectorXMin <= SectorXMax) { - do { - z = SectorYMin; - iVar5 = SectorZMax; - if (SectorYMin <= iVar4) { - do { - local_1c = SectorZMin; - if (SectorZMin <= iVar5) { - do { - iVar5 = z - pmVar7->ymin; - iVar6 = local_1c - pmVar7->zmin; - iVar4 = y - pmVar7->xmin; - if ((((iVar4 < 0) || (iVar2 = pmVar7->dx, iVar2 <= iVar4)) || - (iVar5 < 0)) || - (((pmVar7->dy <= iVar5 || (iVar6 < 0)) || (pmVar7->dz <= iVar6)))) { - error("matrix3d::operator(): Ungueltiger Index %d/%d/%d.\n", - iVar4 + pmVar7->xmin,iVar5 + pmVar7->ymin,iVar6 + pmVar7->zmin - ); - ppTVar3 = pmVar7->entry; - pmVar7 = Sector; - } - else { - ppTVar3 = pmVar7->entry + - iVar6 * iVar2 * pmVar7->dy + iVar5 * iVar2 + iVar4; - } - if (*ppTVar3 != (TSector *)0x0) { - iVar5 = z - pmVar7->ymin; - iVar6 = local_1c - pmVar7->zmin; - iVar4 = y - pmVar7->xmin; - if (((iVar4 < 0) || (iVar2 = pmVar7->dx, iVar2 <= iVar4)) || - ((iVar5 < 0 || - (((pmVar7->dy <= iVar5 || (iVar6 < 0)) || (pmVar7->dz <= iVar6)) - )))) { - error("matrix3d::operator(): Ungueltiger Index %d/%d/%d.\n", - iVar4 + pmVar7->xmin,iVar5 + pmVar7->ymin, - iVar6 + pmVar7->zmin); - ppTVar3 = pmVar7->entry; - } - else { - ppTVar3 = pmVar7->entry + - iVar6 * iVar2 * pmVar7->dy + iVar5 * iVar2 + iVar4; - } - free(*ppTVar3); - pmVar7 = Sector; - } - local_1c = local_1c + 1; - iVar5 = SectorZMax; - iVar4 = SectorYMax; - } while (local_1c <= SectorZMax); - } - z = z + 1; - iVar6 = SectorXMax; - } while (z <= iVar4); - } - y = y + 1; - } while (y <= iVar6); - } - if (pmVar7 != (matrix3d *)0x0) { - if (pmVar7->entry != (TSector **)0x0) { - operator_delete__(pmVar7->entry); - } - operator_delete(pmVar7); - } - DeleteSwappedSectors(); - return; -} - - - void __tcf_0(void *param_1) { -- cgit v1.2.3