# HG changeset patch # User zipi # Date 1364723083 -3600 # Node ID ceef506115676f6fab8b80e8fef40a1dc1ae959b # Parent e398541aee602ccd614c054e3fc415b8586ec64f * AI fixed (temporary) * PID_ID, PID_TYPE replaces * >> 7 error in AudioPlayer diff -r e398541aee60 -r ceef50611567 Actor.cpp --- a/Actor.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/Actor.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -1757,8 +1757,8 @@ int outx; // [sp+48h] [bp-4h]@6 float a4a; // [sp+58h] [bp+Ch]@45 - v4 = (signed int)uObj1ID >> 3; - v5 = (uObj1ID & 7) - 2; + v4 = PID_ID(uObj1ID); + v5 = PID_TYPE(uObj1ID) - 2; v6 = uObj2ID; if ( !v5 ) { @@ -1868,8 +1868,8 @@ } LABEL_28: v20 = v6; - v21 = v6 & 7; - v22 = v20 >> 3; + v21 = PID_TYPE(v6); + v22 = PID_ID(v20); if ( v21 == 2 ) { v30 = v22; @@ -2050,7 +2050,7 @@ } //----- (00403C6C) -------------------------------------------------------- -void Actor::_403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0) +void Actor::_403C6C(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0) { Actor *v3; // ebx@1 char v4; // zf@1 @@ -2071,31 +2071,31 @@ AIDirection a3; // [sp+Ch] [bp-48h]@12 AIDirection v20; // [sp+28h] [bp-2Ch]@12 unsigned int v21; // [sp+44h] [bp-10h]@9 - signed int a2; // [sp+48h] [bp-Ch]@1 + //signed int a2; // [sp+48h] [bp-Ch]@1 int v23; // [sp+4Ch] [bp-8h]@6 unsigned int v24; // [sp+50h] [bp-4h]@1 unsigned int v25; // [sp+5Ch] [bp+8h]@13 v3 = &pActors[uActorID]; - a2 = edx0; + //a2 = edx0; v4 = v3->pMonsterInfo.uMovementType == 5; v24 = uActorID; if ( v4 && v3->pMonsterInfo.uAIType == 1 ) { - Actor::AI_Stand(uActorID, edx0, 0, arg0); + Actor::AI_Stand(uActorID, sTargetPid, 0, arg0); return; } - if ( (edx0 & 7) == OBJECT_Actor) + if ( PID_TYPE(sTargetPid) == OBJECT_Actor) { - v8 = edx0 >> 3; + v8 = PID_ID(sTargetPid); v6 = (AIDirection *)pActors[v8].vPosition.x; v7 = (AIDirection *)pActors[v8].vPosition.y; v23 = (signed __int64)((double)pActors[v8].uActorHeight * 0.75 + (double)pActors[v8].vPosition.z); } else { - if ( (edx0 & 7) == OBJECT_Player) + if ( PID_TYPE(sTargetPid) == OBJECT_Player) { v6 = (AIDirection *)pParty->vPosition.x; v7 = (AIDirection *)pParty->vPosition.y; @@ -2119,7 +2119,7 @@ v13 = 0; if ( !arg0 ) { - v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), a2, &a3, 0); + v14 = Actor::GetDirectionInfo(PID(OBJECT_Actor, v24), sTargetPid, &a3, 0); v12 = &v20; memcpy(&v20, v14, sizeof(v20)); v13 = 0; @@ -2149,7 +2149,7 @@ v3->UpdateAnimation(); } else - Actor::_402AD7(v24, a2, rand() % 2, 64, arg0); + Actor::_402AD7(v24, sTargetPid, rand() % 2, 64, arg0); } //----- (00438CF3) -------------------------------------------------------- @@ -2482,16 +2482,16 @@ v22 = uActorID; v3 = &pActors[uActorID]; a2 = edx0; - if ( (edx0 & 7) == OBJECT_Actor) + if ( PID_TYPE(edx0) == OBJECT_Actor) { - v6 = edx0 >> 3; + v6 = PID_ID(edx0); v4 = (AIDirection *)pActors[v6].vPosition.x; v5 = (AIDirection *)pActors[v6].vPosition.y; v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); } else { - if ( (edx0 & 7) == OBJECT_Player) + if ( PID_TYPE(edx0) == OBJECT_Player) { v4 = (AIDirection *)pParty->vPosition.x; v5 = (AIDirection *)pParty->vPosition.y; @@ -2561,7 +2561,7 @@ } //----- (00403854) -------------------------------------------------------- -void Actor::_403854(unsigned int uActorID, signed int edx0, AIDirection *pDir) +void Actor::_403854(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) { Actor *v3; // ebx@1 AIDirection *v4; // esi@3 @@ -2580,24 +2580,24 @@ AIDirection a3; // [sp+Ch] [bp-48h]@9 AIDirection v18; // [sp+28h] [bp-2Ch]@9 int v19; // [sp+44h] [bp-10h]@6 - signed int a2; // [sp+48h] [bp-Ch]@1 + //signed int a2; // [sp+48h] [bp-Ch]@1 int v21; // [sp+4Ch] [bp-8h]@3 unsigned int v22; // [sp+50h] [bp-4h]@1 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 v22 = uActorID; v3 = &pActors[uActorID]; - a2 = edx0; - if ( (edx0 & 7) == OBJECT_Actor) + //a2 = edx0; + if ( PID_TYPE(sTargetPid) == OBJECT_Actor) { - v6 = edx0 >> 3; + v6 = PID_ID(sTargetPid); v4 = (AIDirection *)pActors[v6].vPosition.x; v5 = (AIDirection *)pActors[v6].vPosition.y; v21 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); } else { - if ( (edx0 & 7) == OBJECT_Player) + if ( PID_TYPE(sTargetPid) == OBJECT_Player) { v4 = (AIDirection *)pParty->vPosition.x; v5 = (AIDirection *)pParty->vPosition.y; @@ -2619,7 +2619,7 @@ v10 = 0; if ( !pDir ) { - v11 = Actor::GetDirectionInfo(8 * v22 | OBJECT_Actor, a2, &a3, 0); + v11 = Actor::GetDirectionInfo(8 * v22 | OBJECT_Actor, sTargetPid, &a3, 0); v9 = &v18; memcpy(&v18, v11, sizeof(v18)); v10 = 0; @@ -2663,11 +2663,11 @@ v3->UpdateAnimation(); } else - Actor::_402AD7(v22, a2, v22, 64, pDir); + Actor::_402AD7(v22, sTargetPid, v22, 64, pDir); } //----- (0040368B) -------------------------------------------------------- -void Actor::_40368B(unsigned int uActorID, signed int edx0, AIDirection *pDir) +void Actor::_40368B(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) { Actor *v3; // ebx@1 AIDirection *v4; // esi@3 @@ -2685,24 +2685,24 @@ AIDirection a3; // [sp+Ch] [bp-48h]@9 AIDirection v17; // [sp+28h] [bp-2Ch]@9 int v18; // [sp+44h] [bp-10h]@6 - signed int a2; // [sp+48h] [bp-Ch]@1 + //signed int a2; // [sp+48h] [bp-Ch]@1 int v20; // [sp+4Ch] [bp-8h]@3 unsigned int v21; // [sp+50h] [bp-4h]@1 unsigned int pDira; // [sp+5Ch] [bp+8h]@10 v21 = uActorID; v3 = &pActors[uActorID]; - a2 = edx0; - if ( (edx0 & 7) == OBJECT_Actor) + //a2 = edx0; + if ( PID_TYPE(sTargetPid) == OBJECT_Actor) { - v6 = edx0 >> 3; + v6 = PID_ID(sTargetPid); v4 = (AIDirection *)pActors[v6].vPosition.x; v5 = (AIDirection *)pActors[v6].vPosition.y; v20 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); } else { - if ( (edx0 & 7) == OBJECT_Player) + if ( PID_TYPE(sTargetPid) == OBJECT_Player) { v4 = (AIDirection *)pParty->vPosition.x; v5 = (AIDirection *)pParty->vPosition.y; @@ -2724,7 +2724,7 @@ v10 = 0; if ( !pDir ) { - v11 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, a2, &a3, 0); + v11 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, sTargetPid, &a3, 0); v9 = &v17; memcpy(&v17, v11, sizeof(v17)); v10 = 0; @@ -2754,11 +2754,11 @@ v3->UpdateAnimation(); } else - Actor::_402AD7(v21, a2, v21, 64, pDir); + Actor::_402AD7(v21, sTargetPid, v21, 64, pDir); } //----- (00403476) -------------------------------------------------------- -void Actor::_403476(unsigned int uActorID, signed int edx0, AIDirection *pDir) +void Actor::_403476(unsigned int uActorID, signed int sTargetPid, AIDirection *pDir) { Actor *v3; // ebx@1 int v4; // esi@3 @@ -2777,24 +2777,24 @@ AIDirection a3; // [sp+Ch] [bp-48h]@10 AIDirection v18; // [sp+28h] [bp-2Ch]@10 int v19; // [sp+44h] [bp-10h]@6 - signed int a2; // [sp+48h] [bp-Ch]@1 + //signed int a2; // [sp+48h] [bp-Ch]@1 unsigned int v21; // [sp+4Ch] [bp-8h]@1 int v22; // [sp+50h] [bp-4h]@3 unsigned int pDira; // [sp+5Ch] [bp+8h]@11 v21 = uActorID; v3 = &pActors[uActorID]; - a2 = edx0; - if ( (edx0 & 7) == OBJECT_Actor) + //a2 = edx0; + if ( PID_TYPE(sTargetPid) == OBJECT_Actor) { - v6 = edx0 >> 3; + v6 = PID_ID(sTargetPid); v4 = pActors[v6].vPosition.x; v5 = pActors[v6].vPosition.y; v22 = (signed __int64)((double)pActors[v6].uActorHeight * 0.75 + (double)pActors[v6].vPosition.z); } else { - if ( (edx0 & 7) == OBJECT_Player) + if ( PID_TYPE(sTargetPid) == OBJECT_Player) { v4 = pParty->vPosition.x; v5 = pParty->vPosition.y; @@ -2824,7 +2824,7 @@ v11 = 0; if ( !pDir ) { - v12 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, a2, &a3, 0); + v12 = Actor::GetDirectionInfo(8 * v21 | OBJECT_Actor, sTargetPid, &a3, 0); v10 = &v18; memcpy(&v18, v12, sizeof(v18)); v11 = 0; @@ -2858,7 +2858,7 @@ v3->UpdateAnimation(); } else - Actor::_402AD7(v21, a2, v21, 64, pDir); + Actor::_402AD7(v21, sTargetPid, v21, 64, pDir); } //----- (004032B2) -------------------------------------------------------- @@ -3304,7 +3304,7 @@ } //----- (00402968) -------------------------------------------------------- -void Actor::_402968(unsigned int uActorID, signed int edx0, int uActionLength, AIDirection *a4) +void Actor::_402968(unsigned int uActorID, signed int sTargetPid, int uActionLength, AIDirection *a4) { unsigned int v4; // esi@1 Actor *v5; // ebx@1 @@ -3318,10 +3318,10 @@ AIDirection v13; // [sp+5Ch] [bp-28h]@4 signed int a1; // [sp+78h] [bp-Ch]@2 unsigned int v15; // [sp+7Ch] [bp-8h]@1 - signed int a2; // [sp+80h] [bp-4h]@1 + //signed int a2; // [sp+80h] [bp-4h]@1 v4 = uActorID; - a2 = edx0; + //a2 = edx0; v15 = uActorID; v5 = &pActors[uActorID]; //result = pActors[uActorID].CanAct(); @@ -3332,13 +3332,13 @@ if ( !a4 ) { a4 = &v12; - memcpy(&v12, Actor::GetDirectionInfo(v7, a2, &a3, v5->pMonsterInfo.uFlying), sizeof(v12)); + memcpy(&v12, Actor::GetDirectionInfo(v7, sTargetPid, &a3, v5->pMonsterInfo.uFlying), sizeof(v12)); v7 = a1; } memcpy(&a3, Actor::GetDirectionInfo(v7, 4u, &v10, 0), sizeof(a3)); memcpy(&v13, &a3, sizeof(v13)); if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) - || (a2 & 7) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 ) + || PID_TYPE(sTargetPid) == OBJECT_Actor && (double)(signed int)v13.uDistance < 307.2 ) { if ( !uActionLength ) uActionLength = 256; @@ -3660,7 +3660,7 @@ v14 = 4; if ( v14 != 0 ) { - v15 = dword_4DF390; + v15 = dword_4DF380[4]; if ( !_this->pMonsterInfo.uHostilityType ) v15 = dword_4DF380[v14]; v16 = abs(_this->vPosition.x - pParty->vPosition.x); diff -r e398541aee60 -r ceef50611567 Actor.h --- a/Actor.h Sat Mar 30 19:36:05 2013 +0400 +++ b/Actor.h Sun Mar 31 10:44:43 2013 +0100 @@ -43,7 +43,7 @@ ACTOR_BUFF_CHARM = 1, // an assumption ACTOR_BUFF_SHRINK = 3, // an assumption ACTOR_BUFF_STONED = 5, - ACTOR_BUFF_PARALYZED = 6, + ACTOR_BUFF_PARALYZED = 6 }; @@ -204,11 +204,11 @@ static void _4030AD(unsigned int uActorID, signed int edx0, int arg0); static char __fastcall _4031C1_update_job(unsigned int uActorID, signed int a2, int a3); static void _4032B2(unsigned int a1, unsigned int a2, int a3, int uActionLength); - static void _403476(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); - static void _40368B(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); - static void _403854(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); - static void _403A60(unsigned int uActorID, signed int edx0, struct AIDirection *pDir); - static void _403C6C(unsigned int uActorID, signed int edx0, struct AIDirection *arg0); + static void _403476(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); + static void _40368B(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); + static void _403854(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); + static void _403A60(unsigned int uActorID, signed int sTargetPid, struct AIDirection *pDir); + static void _403C6C(unsigned int uActorID, signed int sTargetPid, struct AIDirection *arg0); static void __fastcall StandAwhile(unsigned int uActorID); static void AI_Stand(unsigned int uActorID, unsigned int object_to_face_pid, unsigned int uActionLength, struct AIDirection *a4); static void AI_StandOrBored(unsigned int uActorID, signed int uObjID, int uActionLength, struct AIDirection *a4); diff -r e398541aee60 -r ceef50611567 AudioPlayer.cpp --- a/AudioPlayer.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/AudioPlayer.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -21,7 +21,7 @@ #include "Bink_Smacker.h" #include "mm7_data.h" - +#include "MM7.h" PCMWAVEFORMAT pcmWaveFormat; @@ -773,8 +773,8 @@ } else { - int object_type = a3 & 7, - object_id = a3 >> 7; + int object_type = PID_TYPE(a3), + object_id = PID_ID(a3); switch (object_type) { case OBJECT_BLVDoor: @@ -971,8 +971,8 @@ sample_volume = uVolume; AIL_set_sample_volume(channel->hSample, sample_volume); - int object_type = a3 & 7, - object_id = a3 >> 7; + int object_type = PID_TYPE(a3), + object_id = PID_ID(a3); if (PartyX != -1) { if (!PartyX) PartyX = pParty->vPosition.x; @@ -1065,7 +1065,7 @@ v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; goto LABEL_47; } - if ( (a3 & 7) == 2 ) + if ( PID_TYPE(a3) == 2 ) { v22 = pAudioPlayer->uNum3DSamples; if ( v22 < 16 ) @@ -1078,11 +1078,11 @@ v96 = 7; v12 = 5; } - pLayingItem = &pSpriteObjects[a3 >> 3]; + pLayingItem = &pSpriteObjects[PID_ID(a3)]; } else { - if ( (a3 & 7) == 3 ) + if ( PID_TYPE(a3) == 3 ) { v18 = pAudioPlayer->uNum3DSamples; v12 = 0; @@ -1090,7 +1090,7 @@ v96 = 3 * v18 / 16; else v96 = 3; - pActor1 = &pActors[a3 >> 3]; + pActor1 = &pActors[PID_ID(a3)]; v20 = pActor1->vPosition.y; pRenderVertexSoft.vWorldPosition.x = (double)pActor1->vPosition.x; v100 = pActor1->vPosition.z; @@ -1098,10 +1098,10 @@ v21 = (double)v100; goto LABEL_47; } - if ( (a3 & 7) != 5 ) + if ( PID_TYPE(a3) != 5 ) { v13 = pAudioPlayer->uNum3DSamples; - if ( (a3 & 7) == 6 ) + if ( PID_TYPE(a3) == 6 ) { if ( v13 >= 16 ) { @@ -1151,7 +1151,7 @@ v12 = 4; v96 = 4; } - pLayingItem = (SpriteObject *)&pLevelDecorations[a3 >> 3]; + pLayingItem = (SpriteObject *)&pLevelDecorations[PID_ID(a3)]; } pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem->vPosition.x; pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem->vPosition.y; @@ -1273,12 +1273,12 @@ AIL_set_3D_sample_loop_count(*(int *)v42, v86); if ( PartyX == -1 ) { - if ( (a3 & 7) == 1 ) + if ( PID_TYPE(a3) == 1 ) { if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) { //goto LABEL_103; - pBLVDoor = &pIndoor->pDoors[a3 >> 3]; + pBLVDoor = &pIndoor->pDoors[PID_ID(a3)]; if ( !pBLVDoor->uDoorID ) return; pRenderVertexSoft.vWorldPosition.x = (double)*pBLVDoor->pXOffsets; @@ -1323,15 +1323,15 @@ } return; } - if ( (a3 & 7) == 2 ) + if ( PID_TYPE(a3) == 2 ) { - pLayingItem2 = &pSpriteObjects[a3 >> 3]; + pLayingItem2 = &pSpriteObjects[PID_ID(a3)]; } else { - if ( (a3 & 7) == 3 ) + if ( PID_TYPE(a3) == 3 ) { - pActor = &pActors[a3 >> 3]; + pActor = &pActors[PID_ID(a3)]; v46 = pActor->vPosition.y; pRenderVertexSoft.vWorldPosition.x = (double)pActor->vPosition.x; uNumRepeatsb = pActor->vPosition.z; @@ -1339,7 +1339,7 @@ v47 = (double)uNumRepeatsb; goto LABEL_101; } - if ( (a3 & 7) != 5 ) + if ( PID_TYPE(a3) != 5 ) { pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; v43 = (double)pParty->vPosition.y; @@ -1348,7 +1348,7 @@ v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; goto LABEL_101; } - pLayingItem2 = (SpriteObject *)&pLevelDecorations[a3 >> 3]; + pLayingItem2 = (SpriteObject *)&pLevelDecorations[PID_ID(a3)]; } pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem2->vPosition.x; pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem2->vPosition.y; @@ -1462,7 +1462,7 @@ v6 = this->p3DSamples; while ( 1 ) { - v7 = v6->field_4 & 7; + v7 = PID_TYPE(v6->field_4); if ( AIL_3D_sample_status(v6->hSample) == 2 ) { AIL_end_3D_sample(v6->hSample); @@ -1475,7 +1475,7 @@ break; if ( uCurrentlyLoadedLevelType != LEVEL_Indoor ) goto LABEL_31; - v15 = &pIndoor->pDoors[v6->field_4 >> 3]; + v15 = &pIndoor->pDoors[PID_ID(v6->field_4)]; if ( v15->uDoorID ) { uNumRepeats = *v15->pXOffsets; @@ -1502,7 +1502,7 @@ v10 = v9 - 1; if ( !v10 ) { - v13 = &pActors[v6->field_4 >> 3]; + v13 = &pActors[PID_ID(v6->field_4)]; uNumRepeats = v13->vPosition.x; v14 = v13->vPosition.y; a1.vWorldPosition.x = (double)uNumRepeats; @@ -1518,11 +1518,11 @@ v11 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; goto LABEL_21; } - v12 = (SpriteObject *)&pLevelDecorations[v6->field_4 >> 3]; + v12 = (SpriteObject *)&pLevelDecorations[PID_ID(v6->field_4)]; } else { - v12 = &pSpriteObjects[v6->field_4 >> 3]; + v12 = &pSpriteObjects[PID_ID(v6->field_4)]; } a1.vWorldPosition.x = (double)v12->vPosition.x; a1.vWorldPosition.y = (double)v12->vPosition.y; @@ -1623,8 +1623,8 @@ if (channel->source_pid <= 0) continue; - int source_type = channel->source_pid & 7, - source_id = channel->source_pid >> 3; + int source_type = PID_TYPE(channel->source_pid), + source_id = PID_ID(channel->source_pid); int source_x, source_y, source_z; diff -r e398541aee60 -r ceef50611567 Chest.cpp --- a/Chest.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/Chest.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -20,7 +20,7 @@ #include "Overlays.h" #include "mm7_data.h" - +#include "MM7.h" @@ -109,9 +109,9 @@ v31 = 813; v32 = 814; v5 = rand() % 4; - v6 = EvtTargetObj >> 3; + v6 = PID_ID(EvtTargetObj); v35 = v5; - if ( (EvtTargetObj & 7) == OBJECT_Decoration) + if ( PID_TYPE(EvtTargetObj) == OBJECT_Decoration) { v16 = v6; v14 = pLevelDecorations[v6].vPosition.x; @@ -121,7 +121,7 @@ } else { - if ( (EvtTargetObj & 7) != OBJECT_BModel) + if ( PID_TYPE(EvtTargetObj) != OBJECT_BModel) goto LABEL_12; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) { diff -r e398541aee60 -r ceef50611567 Indoor.cpp --- a/Indoor.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/Indoor.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -4082,12 +4082,12 @@ v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16; v0->uSectorID = LOWORD(stru_721530.uSectorID); stru_721530.field_70 += stru_721530.field_7C; - v37 = v36 >> 3; - if ( (v36 & 7) != OBJECT_Actor) + v37 = PID_ID(v36); + if ( PID_TYPE(v36) != OBJECT_Actor) { - if ( (v36 & 7) != OBJECT_Player) + if ( PID_TYPE(v36) != OBJECT_Player) { - if ( (v36 & 7) == OBJECT_Decoration) + if ( PID_TYPE(v36) == OBJECT_Decoration) { _this = integer_sqrt(v0->vVelocity.x * v0->vVelocity.x + v0->vVelocity.y * v0->vVelocity.y); v45 = stru_5C6E00->Atan2( @@ -4104,7 +4104,7 @@ v0->vVelocity.y = WORD1(v48); goto LABEL_119; } - if ( (v36 & 7) == OBJECT_BModel) + if ( PID_TYPE(v36) == OBJECT_BModel) { stru_721530.field_84 = v36 >> 3; v38 = &pIndoor->pFaces[v37]; diff -r e398541aee60 -r ceef50611567 Party.cpp --- a/Party.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/Party.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -142,7 +142,7 @@ { if ( pTurnEngine->field_4 != 2 || PID_TYPE(pTurnEngine->pQueue[0].uPackedID) != OBJECT_Player) return 0; - v2 = pTurnEngine->pQueue[0].uPackedID >> 3; + v2 = PID_ID(pTurnEngine->pQueue[0].uPackedID); return v2 + 1; } v4 = 0; diff -r e398541aee60 -r ceef50611567 UIPopup.cpp --- a/UIPopup.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/UIPopup.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -2131,20 +2131,20 @@ if ( pRenderer->uNumSceneBegins ) { pWindow.DrawMessageBox(1); - MonsterPopup_Draw(v6 >> 3, &pWindow); + MonsterPopup_Draw(PID_ID(v6), &pWindow); } else { pRenderer->BeginScene(); pWindow.DrawMessageBox(1); - MonsterPopup_Draw(v6 >> 3, &pWindow); + MonsterPopup_Draw(PID_ID(v6), &pWindow); pRenderer->EndScene(); } } } else { - v7 = v6 >> 3; + v7 = PID_ID(v6); if ( ! (pObjectList->pObjects[pSpriteObjects[v7].uObjectDescID].uFlags & 0x10 ) ) { v8 = &pSpriteObjects[v7].stru_24; diff -r e398541aee60 -r ceef50611567 UiGame.cpp --- a/UiGame.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/UiGame.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -1420,7 +1420,7 @@ if ( pParty->uFlags & 0x20 ) v16 = dword_5079C8; } - pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[pElem->uPackedID >> 3] - 4, + pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pElem->uPackedID)] - 4, 0x181u, (Texture *)(v16 != -1 ? &pIcons_LOD->pTextures[v16] : 0)); } } diff -r e398541aee60 -r ceef50611567 Vis.cpp --- a/Vis.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/Vis.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -1559,8 +1559,8 @@ case VisObjectType_Sprite: { v5 = filter->field_10; - int object_idx = (pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid & 0xFFFF) >> 3; - int object_type = pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid & 7; + int object_idx = PID_ID(pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid); + int object_type = PID_TYPE(pBillboardRenderList[pRenderer->pBillboardRenderListD3D[(int)uD3DBillboardIdx_or_pBLVFace_or_pODMFace].uParentBillboardID].object_pid); if ( v5 & 2 ) { if (object_type == filter->object_id) diff -r e398541aee60 -r ceef50611567 mm7_1.cpp --- a/mm7_1.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/mm7_1.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -1076,7 +1076,7 @@ v1 = pMouse->GetCursorPos(&a2); v0 = pRenderer->pActiveZBuffer[v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v25)->y]]; } - if ( (v0 & 7) == OBJECT_Item) + if ( PID_TYPE(v0) == OBJECT_Item) { a2.y = (signed int)(unsigned __int16)v0 >> 3; v21 = (signed int)(unsigned __int16)v0 >> 3; @@ -1111,9 +1111,9 @@ return; goto LABEL_14; } - if ( (v0 & 7) != OBJECT_Actor) + if ( PID_TYPE(v0) != OBJECT_Actor) { - if ( (v0 & 7) == OBJECT_Decoration) + if ( PID_TYPE(v0) == OBJECT_Decoration) { v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 ) @@ -1139,7 +1139,7 @@ } else { - if ( (v0 & 7) != OBJECT_BModel || (signed)v0 >= 0x2000000 ) + if ( PID_TYPE(v0) != OBJECT_BModel || (signed)v0 >= 0x2000000 ) { v4 = pParty->pPickedItem.uItemID; if ( !pParty->pPickedItem.uItemID ) diff -r e398541aee60 -r ceef50611567 mm7_2.cpp --- a/mm7_2.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/mm7_2.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -382,7 +382,7 @@ do { v2 = v1->uAIState; - if ( v1->uAIState == Dead || v2 == Removed || v2 == Disabled || (v3 = v1->uSummonerID) != 0 && (v3 & 7) == OBJECT_Player) + if ( v1->uAIState == Dead || v2 == Removed || v2 == Disabled || (v3 = v1->uSummonerID) != 0 && PID_TYPE(v3) == OBJECT_Player) ++v0; ++v1; --v7; @@ -4982,7 +4982,7 @@ LOWORD(v7) = v5 & 0xE0; v12 = v7 + v11; LOWORD(v7) = v8 & 0xE0; - return ((v8 & 7) + (v5 & 7) + (a3a & 7) + (v6 & 7)) | (v7 + v12) | ((v8 & 0x1C00) + return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) | (v7 + v12) | ((v8 & 0x1C00) + (v5 & 0x1C00) + v9 + (__PAIR__(v10, (unsigned __int16)a4 >> 2) & 0x1C00)); @@ -10213,11 +10213,11 @@ } while ( v6 < v22 ); } - if ( (v7 & 7) == OBJECT_Decoration) + if ( PID_TYPE(v7) == OBJECT_Decoration) { - v16 = (unsigned int)v7 >> 3; + v16 = (unsigned int)PID_ID(v7); if ( (signed int)(((unsigned int)*v21 >> 16) - - pDecorationList->pDecorations[pLevelDecorations[(unsigned int)v7 >> 3].uDecorationDescID].uRadius) <= 512 ) + - pDecorationList->pDecorations[pLevelDecorations[(unsigned int)PID_ID(v7)].uDecorationDescID].uRadius) <= 512 ) if ( v19 == v22 && v4 < 100 ) { ++v22; @@ -10311,12 +10311,12 @@ v26 = a2; v2 = a1; - switch ( a1 & 7 ) + switch ( PID_TYPE(a1) ) { case OBJECT_Item: // take the item - v17 = a1 >> 3; - v26 = a1 >> 3; - v18 = a1 >> 3; + v17 = PID_ID(a1); + v26 = PID_ID(a1); + v18 = PID_ID(a1); if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10 || v17 >= 1000 || !pSpriteObjects[v18].uObjectDescID ) @@ -10348,14 +10348,14 @@ break; case OBJECT_Actor: - v12 = a1 >> 3; - v13 = &pActors[a1 >> 3]; + v12 = PID_ID(a1); + v13 = &pActors[PID_ID(a1)]; v14 = v13->uAIState; if ( v14 == 4 || v14 == 17 ) return 1; if ( v14 == 5 ) { - stru_50C198.LootActor(&pActors[a1 >> 3]); + stru_50C198.LootActor(&pActors[PID_ID(a1)]); } else { @@ -10392,7 +10392,7 @@ break; case OBJECT_Decoration: - v8 = &pLevelDecorations[a1 >> 3]; + v8 = &pLevelDecorations[PID_ID(a1)]; v9 = v8->field_16_event_id; if ( v9 ) { @@ -10401,7 +10401,7 @@ } else { - if ( !pLevelDecorations[a1 >> 3].IsInteractive() ) + if ( !pLevelDecorations[PID_ID(a1)].IsInteractive() ) return 1; v10 = v8->_idx_in_stru123; v24 = 1; @@ -10413,7 +10413,7 @@ break; default: - if ( (a1 & 7) != OBJECT_BModel) + if ( PID_TYPE(a1) != OBJECT_BModel) { MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0); return 1; @@ -10421,13 +10421,13 @@ if ( uCurrentlyLoadedLevelType != LEVEL_Indoor ) { if ( a1 >> 9 >= pOutdoor->uNumBModels - || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(a1 >> 3) & 0x3F], BYTE2(v7->uAttributes) & 0x10) + || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(PID_ID(a1)) & 0x3F], BYTE2(v7->uAttributes) & 0x10) || (v6 = v7->sCogTriggeredID) == 0 ) return 1; EventProcessor((signed __int16)v6, v2, 1); return 0; } - v4 = &pIndoor->pFaces[a1 >> 3]; + v4 = &pIndoor->pFaces[PID_ID(a1)]; v5 = v4->uAttributes; if ( !(v5 & 0x2000000) ) { @@ -10488,11 +10488,11 @@ v6 = ((v12 - v4 - 1) >> 1) + 1; do { - if ( (*(char *)v5 & 7) == OBJECT_Actor) + if ( PID_TYPE(*(char *)v5) == OBJECT_Actor) { if ( *v5 <= a3 << 16 ) { - v7 = (signed int)(unsigned __int16)*v5 >> 3; + v7 = PID_ID((signed int)(unsigned __int16)*v5); v8 = pActors[v7].uAIState; if ( v8 != 5 ) { @@ -10559,11 +10559,11 @@ v3 = pRenderer->GetParentBillboardID(a1a); v4 = pBillboardRenderList[v3].sZValue; v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; - if ( (v5 & 7) == OBJECT_Actor) + if ( PID_TYPE(v5) == OBJECT_Actor) { if ( v4 <= (unsigned int)(a3 << 16) ) { - v6 = v5 >> 3; + v6 = PID_ID(v5); v7 = v6; v8 = pActors[v6].uAIState; if ( v8 != 5 ) @@ -10817,8 +10817,8 @@ while ( 1 ) { v19 = dword_720020_zvalues[v18] & 0xFFFF; - v20 = (dword_720020_zvalues[v18] & 0xFFFFu) >> 3; - if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Item) + v20 = PID_ID(dword_720020_zvalues[v18]); + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Item) { if ( v20 >= 0x3E8 ) return 0; @@ -10831,16 +10831,16 @@ } goto LABEL_41; } - if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Actor) + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor) { if ( v20 >= 0xBB8 ) return 0; v24 = (const char *)&pActors[v20]; goto LABEL_51; } - if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Decoration) + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration) break; - if ( (dword_720020_zvalues[v18] & 7) == OBJECT_BModel) + if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel) { if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) { @@ -10853,7 +10853,7 @@ { if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 >= pOutdoor->uNumBModels ) goto LABEL_41; - v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[((dword_720020_zvalues[v18] & 0xFFFFu) >> 3) & 0x3F].sCogTriggeredID; + v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID; } if ( v22 ) { @@ -11160,15 +11160,15 @@ v2 = &pSpriteObjects[uLayingItemID]; v3 = &pObjectList->pObjects[v2->uObjectDescID]; v145 = a2; - v151 = a2 & 7; - if ( (a2 & 7) == OBJECT_Actor) - { - if ( (v2->spell_caster_pid & 7) == OBJECT_Actor && !pActors[v2->spell_caster_pid >> 3].GetActorsRelation(&pActors[a2 >> 3]) ) + v151 = PID_TYPE(a2); + if ( PID_TYPE(a2) == OBJECT_Actor) + { + if ( PID_TYPE(v2->spell_caster_pid) == OBJECT_Actor && !pActors[PID_ID(v2->spell_caster_pid)].GetActorsRelation(&pActors[PID_ID(a2)]) ) return 1; } else { - if ( (a2 & 7) == OBJECT_Player && (v2->spell_caster_pid & 7) == OBJECT_Player) + if ( PID_TYPE(a2) == OBJECT_Player && PID_TYPE(v2->spell_caster_pid) == OBJECT_Player) return 1; } if ( pParty->bTurnBasedModeOn == 1 ) @@ -11180,8 +11180,8 @@ v2->uAttributes = v5 & 0xFFFB; } } - if ( v151 == OBJECT_BModel && (v2->spell_caster_pid & 7) != OBJECT_Player) - BYTE2(pActors[v2->spell_caster_pid >> 3].uAttributes) |= 4u; + if ( v151 == OBJECT_BModel && PID_TYPE(v2->spell_caster_pid) != OBJECT_Player) + BYTE2(pActors[PID_ID(v2->spell_caster_pid)].uAttributes) |= 4u; v6 = v2->uType; v7 = v2->uType; if ( v7 > 3060 ) @@ -11295,7 +11295,7 @@ } v106 = v145; v150 = 0; - v139 = v106 >> 3; + v139 = PID_ID(v106); v137 = v2->spell_level; v152 = v2->spell_skill; v136 = v2->spell_id; @@ -11368,7 +11368,7 @@ if ( v7 == 8010 ) { if ( v151 == 3 - && MonsterStats::BelongsToSupertype(pActors[v145 >> 3].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) + && MonsterStats::BelongsToSupertype(pActors[PID_ID(v145)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) sub_43A97E(v153, v145); v93 = pObjectList->uNumObjects; ++v2->uType; diff -r e398541aee60 -r ceef50611567 mm7_3.cpp --- a/mm7_3.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/mm7_3.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -898,9 +898,9 @@ //int v34; // ebx@64 int v35; // edi@64 int v36; // eax@64 - unsigned __int16 v37; // cx@66 + //unsigned __int16 v37; // cx@66 signed int v38; // edx@71 - signed int v39; // edi@71 + unsigned int v39; // edi@71 BSPModel *v40; // eax@75 ODMFace *v41; // edi@75 int v42; // ebx@76 @@ -913,8 +913,8 @@ int v49; // edi@85 int v50; // eax@85 unsigned __int64 v51; // qax@85 - unsigned __int8 v52; // zf@87 - unsigned __int8 v53; // sf@87 + //unsigned __int8 v52; // zf@87 + //unsigned __int8 v53; // sf@87 // unsigned __int8 v54; // of@104 int v55; // eax@107 unsigned int v56; // edi@107 @@ -1139,8 +1139,7 @@ { if ( v35 < v36 + 60 ) { - v37 = v0->uAIState; - if ( v37 == 5 || v37 == 4 || v37 == 11 || v37 == 19 ) + if ( uAIState == Dead || uAIState == Dying || uAIState == Removed || uAIState == Disabled ) { if ( v64 ) v61 = v36 + 30; @@ -1167,7 +1166,7 @@ v38 = stru_721530.uFaceID; v0->vPosition.z += (unsigned int)(stru_721530.field_7C * stru_721530.field_58.z) >> 16; stru_721530.field_70 += stru_721530.field_7C; - v39 = v38 >> 3; + v39 = PID_ID(v38); switch ( PID_TYPE(v38) ) { case OBJECT_Actor: @@ -1207,8 +1206,8 @@ Actor::FaceObject(v75, v38, 0, (AIDirection *)0); break; } - v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0; - v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0; + //v52 = HIDWORD(pParty->pPartyBuffs[11].uExpireTime) == 0; + //v53 = SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) < 0; v0->vVelocity.y = 0; v0->vVelocity.x = 0; //if ( !v53 && (!(v53 | v52) || LODWORD(pParty->pPartyBuffs[11].uExpireTime) > 0) ) @@ -1372,7 +1371,7 @@ v4 = &pObjectList->pObjects[item->uObjectDescID]; if (item->AttachedToActor()) { - v5 = item->spell_target_pid >> 3; + v5 = PID_ID(item->spell_target_pid); *(int *)(v2 - 26) = pActors[v5].vPosition.x; *(int *)(v2 - 22) = pActors[v5].vPosition.y; *(int *)(v2 - 18) = pActors[v5].vPosition.z + pActors[v5].uActorHeight; @@ -1915,7 +1914,7 @@ uSectorID = stru_721530.uSectorID; stru_721530.field_70 += stru_721530.field_7C; auto v87 = ((unsigned __int64)(stru_721530.field_7C * (signed __int64)stru_721530.field_58.z) >> 16) + new_party_z; - if ( (stru_721530.uFaceID & 7) == OBJECT_Actor) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) { if ( SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) >= 0 && (SHIDWORD(pParty->pPartyBuffs[11].uExpireTime) > 0 || LODWORD(pParty->pPartyBuffs[11].uExpireTime)) ) @@ -1923,7 +1922,7 @@ viewparams->bRedrawGameUI = 1; goto LABEL_152; } - if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { v53 = integer_sqrt(v2 * v2 + v1 * v1); v80 = v53; @@ -1935,7 +1934,7 @@ } else { - if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { v44 = &pIndoor->pFaces[(signed int)stru_721530.uFaceID >> 3]; v45 = v44->uPolygonType; @@ -2839,7 +2838,7 @@ pY = _angle_y; v45 = stru_721530.uFaceID; pZ = v40; - if ( (stru_721530.uFaceID & 7) == OBJECT_Actor) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Actor) { if (pParty->Invisible()) pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].Reset(); @@ -2847,7 +2846,7 @@ viewparams->bRedrawGameUI = 1; goto LABEL_234; } - if ( (stru_721530.uFaceID & 7) == OBJECT_Decoration) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_Decoration) { v56 = integer_sqrt(v2 * v2 + v128 * v128); v118 = v56; @@ -2868,7 +2867,7 @@ } else { - if ( (stru_721530.uFaceID & 7) == OBJECT_BModel) + if ( PID_TYPE(stru_721530.uFaceID) == OBJECT_BModel) { pParty->bFlying = 0; v46 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; @@ -12788,7 +12787,7 @@ ++num_dead_actors; else { - int sumonner_type = pActors[i].uSummonerID & 7;; + int sumonner_type = PID_TYPE(pActors[i].uSummonerID); if (sumonner_type == OBJECT_Player) ++num_dead_actors; } @@ -15143,7 +15142,7 @@ AIDirection a3; // [sp+1Ch] [bp-94h]@129 AIDirection v74; // [sp+38h] [bp-78h]@246 AIDirection v75; // [sp+54h] [bp-5Ch]@129 - int actor_pid_type; // [sp+70h] [bp-40h]@83 + int target_pid_type; // [sp+70h] [bp-40h]@83 signed int a1; // [sp+74h] [bp-3Ch]@129 int v78; // [sp+78h] [bp-38h]@79 AIDirection pDir; // [sp+7Ch] [bp-34h]@129 @@ -15152,7 +15151,7 @@ //int v82; // [sp+A0h] [bp-10h]@45 //unsigned int uActorID; // [sp+A4h] [bp-Ch]@32 unsigned int v84; // [sp+A8h] [bp-8h]@11 - signed int actor_pid; // [sp+ACh] [bp-4h]@83 + signed int target_pid; // [sp+ACh] [bp-4h]@83 AIState uAIState; if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) @@ -15342,9 +15341,9 @@ Actor::_SelectTarget(actor_id, &ai_near_actors_targets_pid[actor_id], true); if (v21->pMonsterInfo.uHostilityType && !ai_near_actors_targets_pid[actor_id]) v21->pMonsterInfo.uHostilityType = MonsterInfo::Hostility_Friendly; - actor_pid = ai_near_actors_targets_pid[actor_id]; - actor_pid_type = PID_TYPE(actor_pid); - if ( actor_pid_type == OBJECT_Actor) + target_pid = ai_near_actors_targets_pid[actor_id]; + target_pid_type = PID_TYPE(target_pid); + if ( target_pid_type == OBJECT_Actor) v80 = 0.5; else v80 = 1.0; @@ -15389,7 +15388,7 @@ if ( !(v21->uAttributes & 0x8000) ) v21->uAttributes |= 0x8000; a1 = 8 * actor_id | OBJECT_Actor; - v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, actor_pid, &a3, 0); + v30 = Actor::GetDirectionInfo(8 * actor_id | OBJECT_Actor, target_pid, &a3, 0); memcpy(&v75, v30, sizeof(v75)); memcpy(&pDir, &v75, sizeof(pDir)); uAIState = v21->uAIState; @@ -15400,13 +15399,14 @@ || ( v21->pMonsterInfo.uMissleAttack1Type && uAIState == Stunned ) ) { v32 = actor_id; - }*/ + } + else + */ if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly || (signed int)v21->pMonsterInfo.uRecoveryTime > 0 || v80 * 307.2 < (double)(signed int)v75.uDistance || uAIState != Pursuing && uAIState != Standing && uAIState != Tethered && uAIState != Fidgeting && !v21->pMonsterInfo.uMissleAttack1Type || uAIState != Stunned ) - //else { if ( (signed int)v21->uCurrentActionTime < v21->uCurrentActionLength ) { @@ -15435,31 +15435,28 @@ v34 = v21->pMonsterInfo.uMissleAttack2Type; Actor::_404874(actor_id, &pDir, v34, 1); } - else + else if ( v21->uAIState == AttackingRanged3 ) { - if ( v21->uAIState == AttackingRanged3 ) - { - v65 = v21->pMonsterInfo.uSpellSkillAndMastery1; - v33 = v21->pMonsterInfo.uSpell1ID; - Actor::_404AC7(actor_id, &pDir, v33, 2, v65); - } - else if ( v21->uAIState == AttackingRanged4 ) - { - v65 = v21->pMonsterInfo.uSpellSkillAndMastery2; - v33 = v21->pMonsterInfo.uSpell2ID; - Actor::_404AC7(actor_id, &pDir, v33, 3, v65); - } + v65 = v21->pMonsterInfo.uSpellSkillAndMastery1; + v33 = v21->pMonsterInfo.uSpell1ID; + Actor::_404AC7(actor_id, &pDir, v33, 2, v65); + } + else if ( v21->uAIState == AttackingRanged4 ) + { + v65 = v21->pMonsterInfo.uSpellSkillAndMastery2; + v33 = v21->pMonsterInfo.uSpell2ID; + Actor::_404AC7(actor_id, &pDir, v33, 3, v65); } } v36 = v75.uDistance; if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Friendly) { - if ( actor_pid_type == OBJECT_Actor ) + if ( target_pid_type == OBJECT_Actor ) { v36 = v75.uDistance; v37 = (unsigned __int8)*(&byte_5C8D1A[89 * (v21->pMonsterInfo.uID - 1) / 3] - + (pActors[actor_pid >> 3].pMonsterInfo.uID - 1) / 3); + + (pActors[PID_ID(target_pid)].pMonsterInfo.uID - 1) / 3); } else { @@ -15488,29 +15485,29 @@ { if ( (signed int)v36 >= 10240 ) { - Actor::_4032B2(actor_id, actor_pid, 1024, 0); + Actor::_4032B2(actor_id, target_pid, 1024, 0); } else { //peasents after attacked //guard after attacked - Actor::_402968(actor_id, actor_pid, 0, &pDir); + Actor::_402968(actor_id, target_pid, 0, &pDir); } continue; } - if ( v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long && actor_pid ) + if ( /*v21->pMonsterInfo.uHostilityType == MonsterInfo::Hostility_Long &&*/ target_pid ) // temporary { if ( v21->pMonsterInfo.uAIType == 1 ) { if ( v21->pMonsterInfo.uMovementType == 5 ) { - Actor::AI_Stand(actor_id, actor_pid, (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333), &pDir); + Actor::AI_Stand(actor_id, target_pid, (signed __int64)((double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333), &pDir); } else { - Actor::_402968(actor_id, actor_pid, 0, &pDir); + Actor::_402968(actor_id, target_pid, 0, &pDir); continue; } @@ -15527,15 +15524,15 @@ v42 = (double)(signed int)v84; if ( v43 > v42 && (signed int)v36 < 10240 ) { - Actor::_402968(actor_id, actor_pid, 0, &pDir); + Actor::_402968(actor_id, target_pid, 0, &pDir); continue; } } } v81 = v36 - v21->uActorRadius; - if ( actor_pid_type == OBJECT_Actor ) - v81 -= pActors[actor_pid >> 3].uActorRadius; + if ( target_pid_type == OBJECT_Actor ) + v81 -= pActors[PID_ID(target_pid)].uActorRadius; if ( v81 < 0 ) v81 = 0; rand(); @@ -15549,13 +15546,13 @@ { if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 ) { - Actor::_403476(actor_id, actor_pid, &pDir); + Actor::_403476(actor_id, target_pid, &pDir); } else if ( v21->pMonsterInfo.uMovementType == 5 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { @@ -15563,10 +15560,10 @@ if ( !(v54 | v55) ) { v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); continue; } - Actor::_402AD7(actor_id, actor_pid, actor_id, (signed __int64)v47, &pDir); + Actor::_402AD7(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); } } else @@ -15580,19 +15577,19 @@ { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { //monsters - Actor::_402686(actor_id, actor_pid, 0, &pDir); + Actor::_402686(actor_id, target_pid, 0, &pDir); } } else if ( v21->pMonsterInfo.uMovementType == 5 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { @@ -15600,19 +15597,19 @@ //monsters //guard after player runs away // follow player - Actor::_40281C(actor_id, actor_pid, 0, &pDir, v70); + Actor::_40281C(actor_id, target_pid, 0, &pDir, v70); } } else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { //monsters - Actor::_403C6C(actor_id, actor_pid, &pDir); + Actor::_403C6C(actor_id, target_pid, &pDir); } } continue; @@ -15628,20 +15625,20 @@ if ( (signed int)v21->pMonsterInfo.uRecoveryTime <= 0 ) { if ( v45 == 2 ) - Actor::_403854(actor_id, actor_pid, &pDir); + Actor::_403854(actor_id, target_pid, &pDir); else - Actor::_403A60(actor_id, actor_pid, &pDir); + Actor::_403A60(actor_id, target_pid, &pDir); } else if ( v80 * 307.2 > (double)v81 || v21->pMonsterInfo.uMovementType == 5 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; - Actor::_402AD7(actor_id, actor_pid, actor_id, (signed __int64)v47, &pDir); + Actor::_402AD7(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); } } else @@ -15655,34 +15652,34 @@ { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { - Actor::_402686(actor_id, actor_pid, 256, &pDir); + Actor::_402686(actor_id, target_pid, 256, &pDir); } } else if ( v21->pMonsterInfo.uMovementType == 5 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { v70 = (signed __int64)v48; - Actor::_40281C(actor_id, actor_pid, 0, &pDir, v70); + Actor::_40281C(actor_id, target_pid, 0, &pDir, v70); } } else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { - Actor::_403C6C(actor_id, actor_pid, &pDir); + Actor::_403C6C(actor_id, target_pid, &pDir); } } continue; @@ -15690,7 +15687,7 @@ } } - if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !actor_pid || v81 >= 5120 || v45 != 1 ) + if ( v21->pMonsterInfo.uHostilityType != MonsterInfo::Hostility_Long || !target_pid || v81 >= 5120 || v45 != 1 ) { if ( !v21->pMonsterInfo.uMovementType ) { @@ -15729,34 +15726,34 @@ { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { - Actor::_402686(actor_id, actor_pid, 256, &pDir); + Actor::_402686(actor_id, target_pid, 256, &pDir); } } else if ( v21->pMonsterInfo.uMovementType == 5 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { v70 = (signed __int64)v56; - Actor::_40281C(actor_id, actor_pid, 0, &pDir, v70); + Actor::_40281C(actor_id, target_pid, 0, &pDir, v70); } } else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) { v47 = (double)(signed int)v21->pMonsterInfo.uRecoveryTime * 2.133333333333333; v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { - Actor::_403C6C(actor_id, actor_pid, &pDir); + Actor::_403C6C(actor_id, target_pid, &pDir); } } else if ( (signed int)v21->pMonsterInfo.uRecoveryTime > 0 ) @@ -15765,16 +15762,16 @@ if ( !(v54 | v55) || v21->pMonsterInfo.uMovementType == 5 ) { v64 = (signed __int64)v47; - Actor::AI_Stand(actor_id, actor_pid, v64, &pDir); + Actor::AI_Stand(actor_id, target_pid, v64, &pDir); } else { - Actor::_402AD7(actor_id, actor_pid, actor_id, (signed __int64)v47, &pDir); + Actor::_402AD7(actor_id, target_pid, actor_id, (signed __int64)v47, &pDir); } } else { - Actor::_40368B(actor_id, actor_pid, &pDir); + Actor::_40368B(actor_id, target_pid, &pDir); } } } @@ -15852,10 +15849,10 @@ v2 = this->pQueue; do { - if ( (v2->uPackedID & 7) == OBJECT_Actor ) - { - v3 = &pActors[v2->uPackedID >> 3]; - v4 = &pActors[v2->uPackedID >> 3]; + if ( PID_TYPE(v2->uPackedID) == OBJECT_Actor ) + { + v3 = &pActors[PID_ID(v2->uPackedID)]; + v4 = &pActors[PID_ID(v2->uPackedID)]; LOBYTE(v4->uAttributes) |= 0x80u; if ( !v4->CanAct() ) { @@ -15864,7 +15861,7 @@ LOBYTE(v3->uAttributes) &= 0x7Fu; } } - if ( (v2->uPackedID & 7) == OBJECT_Player) + if ( PID_TYPE(v2->uPackedID) == OBJECT_Player) { v5 = &pParty->pPlayers[v2->uPackedID >> 3]; if ( v5->pConditions[14] @@ -15900,8 +15897,8 @@ v10 = v7->field_4; if ( v9 < v10 || v9 == v10 - && ((v11 = v8->uPackedID & 7, v11 == OBJECT_Player) && (v7->uPackedID & 7) == OBJECT_Actor - || v11 == (v7->uPackedID & 7) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) + && ((v11 = PID_TYPE(v8->uPackedID), v11 == OBJECT_Player) && PID_TYPE(v7->uPackedID) == OBJECT_Actor + || v11 == PID_TYPE(v7->uPackedID) && (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) { v12 = v7->uPackedID; v13 = v7->field_4; @@ -15929,7 +15926,7 @@ } v1->uActorQueueSize = v19; result = v1->pQueue[0].uPackedID; - if ( (v1->pQueue[0].uPackedID & 7) == OBJECT_Player) + if ( PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) { result = (result >> 3) + 1; uActiveCharacter = result; @@ -15946,7 +15943,7 @@ v17 = v1->pQueue; do { - if ( (v17->uPackedID & 7) == OBJECT_Player) + if ( PID_TYPE(v17->uPackedID) == OBJECT_Player) pParty->pPlayers[v17->uPackedID >> 3].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875); ++v22; ++v17; @@ -16084,7 +16081,7 @@ v12 = (char *)&v1->pQueue[0].field_4; while ( 1 ) { - v13 = *((int *)v12 - 1) & 7; + v13 = PID_TYPE(*((int *)v12 - 1)); if ( v13 != OBJECT_Player ) break; v14 = pPlayers[(*((int *)v12 - 1) >> 3) + 1]->uTimeToRecovery; diff -r e398541aee60 -r ceef50611567 mm7_4.cpp --- a/mm7_4.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/mm7_4.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -1119,7 +1119,7 @@ do { v4 = *v3; - if ( (v4 & 7) == OBJECT_Decoration) + if ( PID_TYPE(v4) == OBJECT_Decoration) { v5 = &pLevelDecorations[(signed __int16)v4 >> 3]; if ( !(v5->field_2 & 0x20) ) @@ -1515,7 +1515,7 @@ v2 = this; v3 = operator new(8 * a2 + 16); v2->pBlockBase = v3; - v4 = (char *)v3 + (-(signed int)v3 & 7); + v4 = (char *)v3 + PID_TYPE(-(signed int)v3); result = v2; v2->pAlignedBlock = v4; } @@ -8582,8 +8582,8 @@ v7 = this->pQueue; do { - if ( (v7->uPackedID & 7) == OBJECT_Actor ) - LOBYTE(pActors[v7->uPackedID >> 3].uAttributes) &= 0x7Fu; + if ( PID_TYPE(v7->uPackedID) == OBJECT_Actor ) + LOBYTE(pActors[PID_ID(v7->uPackedID)].uAttributes) &= 0x7Fu; ++v4; ++v7; } @@ -8612,8 +8612,8 @@ v11 = v2->pQueue; do { - objType = (ObjectType)(v11->uPackedID & 7); - objID = v11->uPackedID >> 3; + objType = (ObjectType)PID_TYPE(v11->uPackedID); + objID = PID_ID(v11->uPackedID); if ( objType == OBJECT_Player ) { pPlayers[objID + 1]->uTimeToRecovery = (signed __int64)((double)v11->field_4 * 2.133333333333333); diff -r e398541aee60 -r ceef50611567 mm7_5.cpp --- a/mm7_5.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/mm7_5.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -1741,9 +1741,9 @@ v42 = pRenderer->pActiveZBuffer[*(int *)uNumSeconds + pSRZBufferLineOffsets[pPoint->y]]; } v44 = (unsigned __int16)v42; - v45 = v44 & 7; + v45 = PID_TYPE(v44); uNumSeconds = v44; - v46 = v44 >> 3; + v46 = PID_ID(v44); if ( v45 == 3 ) { v47 = pActors[v46].uAIState == Dead; @@ -2397,7 +2397,7 @@ v83 = v81; v44 = (unsigned __int16)v81; v84 = v83 >> 16; - if ( (v44 & 7) != 3 || v84 >= 5120 ) + if ( PID_TYPE(v44) != 3 || v84 >= 5120 ) //goto LABEL_90; { v1 = ""; @@ -4532,24 +4532,24 @@ v1 = (char *)stru_50FE08.pZs; do { - v2 = *((short *)v1 - 300) & 7; - v3 = (signed int)*((short *)v1 - 300) >> 3; - v39 = (signed int)*((short *)v1 - 300) >> 3; + v2 = PID_TYPE(*((short *)v1 - 300)); + v3 = PID_ID((signed int)*((short *)v1 - 300)); + v39 = PID_ID((signed int)*((short *)v1 - 300)); if ( v2 == 2 ) { v4 = &pSpriteObjects[v3]; v36 = v4; v5 = v4->spell_caster_pid; - v2 = v5 & 7; - v3 = v5 >> 3; + v2 = PID_TYPE(v5); + v3 = PID_ID(v5); } v41 = v2; v37 = v3; if ( stru_50FE08.field_3EC[v0] & 1 ) { v6 = ai_near_actors_targets_pid[v3]; - v7 = v6 >> 3; - v8 = (v6 & 7) - 3; + v7 = PID_ID(v6); + v8 = PID_TYPE(v6) - 3; uActorID = v7; if ( v8 ) { @@ -4775,9 +4775,9 @@ v61 = 0; v59 = 0; v62 = 0; - if ( (a1 & 7) == OBJECT_Item) - { - v4 = &pSpriteObjects[a1 >> 3]; + if ( PID_TYPE(a1) == OBJECT_Item) + { + v4 = &pSpriteObjects[PID_ID(a1)]; //uDamageAmount = (int)v4; v61 = v4->field_60_distance_related_prolly_lod; a1 = v4->spell_caster_pid; @@ -4785,11 +4785,11 @@ } //v5 = a1 & 7; //uPlayerID = a1 >> 3; - if ((a1 & 7) != OBJECT_Player) + if (PID_TYPE(a1) != OBJECT_Player) return; - assert(abs(a1 >> 3) < 4); - auto player = &pParty->pPlayers[a1 >> 3]; + assert(PID_ID(abs(a1)) < 4); + auto player = &pParty->pPlayers[PID_ID(a1)]; pMonster = &pActors[uActorID_Monster_]; //uPlayerID = pMonster->IsAlive(); if (pMonster->IsNotAlive()) @@ -5250,8 +5250,8 @@ signed int a4a; // [sp+60h] [bp+Ch]@162 Player *a4b; // [sp+60h] [bp+Ch]@168 - v4 = (signed int)uObjID >> 3; - v5 = (uObjID & 7) - 2; + v4 = PID_ID(uObjID); + v5 = PID_TYPE(uObjID) - 2; v74 = a2; uActorID = v4; if ( v5 ) @@ -5448,10 +5448,10 @@ return; } v37 = &pSpriteObjects[uActorID]; - v38 = v37->spell_caster_pid & 7; - v39 = v37->spell_caster_pid >> 3; - v40 = v37->spell_caster_pid & 7; - uActorID = v37->spell_caster_pid >> 3; + v38 = PID_TYPE(v37->spell_caster_pid); + v39 = PID_ID(v37->spell_caster_pid); + v40 = PID_TYPE(v37->spell_caster_pid); + uActorID = PID_ID(v37->spell_caster_pid); v41 = v40 - 2; if ( !v41 ) goto LABEL_80; @@ -5847,9 +5847,9 @@ a2 = uObjID; if ( !pActors[uActorID].IsNotAlive() ) { - if ( (a2 & 7) == OBJECT_Item) - { - v4 = &pSpriteObjects[(signed int)a2 >> 3]; + if ( PID_TYPE(a2) == OBJECT_Item) + { + v4 = &pSpriteObjects[PID_ID(a2)]; v5 = v4->spell_id; if ( v5 ) { @@ -5906,17 +5906,17 @@ v4 = 0; uActorID = a2; v17 = a1; - if ( (a1 & 7) == OBJECT_Item) - { - v5 = &pSpriteObjects[a1 >> 3]; + if ( PID_TYPE(a1) == OBJECT_Item) + { + v5 = &pSpriteObjects[PID_ID(a1)]; v4 = v5->field_60_distance_related_prolly_lod; v17 = v5->spell_caster_pid; } - LOWORD(v6) = v17 & 7; + LOWORD(v6) = PID_TYPE(v17); if ( v6 == OBJECT_Actor) { v7 = &pActors[a2]; - v8 = &pActors[v17 >> 3]; + v8 = &pActors[PID_ID(v17)]; v6 = pActors[a2].IsNotAlive(); if ( !v6 ) { @@ -6759,7 +6759,7 @@ while ( 1 ) { v5 = v16->uPackedID; - if ( (v16->uPackedID & 7) == OBJECT_Player) + if ( PID_TYPE(v16->uPackedID) == OBJECT_Player) break; LABEL_8: ++v17; @@ -6767,8 +6767,8 @@ if ( v17 >= v1->uActorQueueSize ) goto LABEL_11; } - v15 = v5 >> 3; - if ( !pPlayers[(v5 >> 3) + 1]->CanAct() || v19 != v15 ) + v15 = PID_ID(v5); + if ( !pPlayers[(PID_ID(v5)) + 1]->CanAct() || v19 != v15 ) { v2 = 0; goto LABEL_8; @@ -6802,7 +6802,7 @@ v8 = v1->pQueue; do { - if ( (v8->uPackedID & 7) == OBJECT_Actor && ai_near_actors_ids[v20] == v8->uPackedID >> 3 ) + if ( PID_TYPE(v8->uPackedID) == OBJECT_Actor && ai_near_actors_ids[v20] == PID_ID(v8->uPackedID) ) break; ++v18; ++v8; @@ -6846,7 +6846,7 @@ v13 = (char *)&v1->pQueue[0].field_4; do { - v11 = *((int *)v13 - 1) & 7; + v11 = PID_TYPE(*((int *)v13 - 1)); if ( (char)v11 == 4 ) break; if ( *(int *)v13 > 0 ) @@ -6936,7 +6936,7 @@ if ( v6 != 8 ) goto LABEL_19; v3 = 0; - Actor::AI_StandOrBored(v2->uPackedID >> 3, ai_near_actors_targets_pid[v2->uPackedID >> 3], 32, 0); + Actor::AI_StandOrBored(PID_ID(v2->uPackedID), ai_near_actors_targets_pid[PID_ID(v2->uPackedID)], 32, 0); } } } @@ -7039,7 +7039,7 @@ } else { - v8 = &pActors[v1->pQueue[0].uPackedID >> 3]; + v8 = &pActors[PID_ID(v1->pQueue[0].uPackedID)]; if ( v4 > 0 ) { do @@ -7091,10 +7091,10 @@ v2 = this; v3 = *(&this->field_0 + 4 * (a2 + 2)); - if ( (*((char *)&this->field_0 + 16 * (a2 + 2)) & 7) == OBJECT_Player) - { - v4 = v3 >> 3; - v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[v3 >> 3]; + if ( (*((char *)&this->field_0 + 16 * PID_TYPE(a2 + 2))) == OBJECT_Player) + { + v4 = PID_ID(v3); + v5 = (char *)&pParty->pTurnBasedPlayerRecoveryTimes[PID_ID(v3)]; v6 = *(int *)v5; if ( *(int *)v5 ) *(int *)v5 = 0; @@ -7105,7 +7105,7 @@ } else { - v6 = pMonsterStats->pInfos[pActors[v3 >> 3].pMonsterInfo.uID].uRecoveryTime; + v6 = pMonsterStats->pInfos[pActors[PID_ID(v3)].pMonsterInfo.uID].uRecoveryTime; } v2->pQueue[a2].field_4 = v6; v2->_404544(); @@ -7143,7 +7143,7 @@ //----- (0040652A) -------------------------------------------------------- void stru262_TurnBased::_40652A() { - char *v1; // edx@2 + int *v1; // edx@2 Actor *v2; // eax@5 unsigned __int16 v3; // si@5 unsigned int v4; // esi@8 @@ -7152,14 +7152,14 @@ v5 = 0; if ( this->uActorQueueSize > 0 ) { - v1 = (char *)&this->pQueue[0].field_4; + v1 = &this->pQueue[0].field_4; do { if ( !*(int *)v1 ) { - if ( (*(v1 - 4) & 7) == OBJECT_Player) + if ( PID_TYPE(*(v1 - 4)) == OBJECT_Player) return; - v2 = &pActors[*((int *)v1 - 1) >> 3]; + v2 = &pActors[PID_ID(*(v1 - 1))]; v3 = v2->uAIState; if (v3 == Standing || v3 == Fleeing || v3 == Fidgeting) { @@ -7188,7 +7188,7 @@ v1 = this; LOWORD(v2) = _404544(); if ( v1->pQueue[0].field_4 <= 0 - || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, PID_TYPE(v1->pQueue[0].uPackedID) != OBJECT_Player) ? (uActiveCharacter = 0) : (v2 = (v2 >> 3) + 1, uActiveCharacter = v2), + || ((_4063A1(), v2 = v1->pQueue[0].uPackedID, PID_TYPE(v1->pQueue[0].uPackedID) != OBJECT_Player) ? (uActiveCharacter = 0) : (v2 = (PID_ID(v2)) + 1, uActiveCharacter = v2), viewparams->bRedrawGameUI = 1, v1->pQueue[0].field_4 <= 0) ) { @@ -7199,7 +7199,7 @@ do { v2 = *(int *)v4; - if ( (*(char *)v4 & 7) == OBJECT_Player || *(int *)(v4 + 4) > 0 ) + if ( PID_TYPE(*(char *)v4) == OBJECT_Player || *(int *)(v4 + 4) > 0 ) break; if ( *(int *)(v4 + 8) <= 0 ) { @@ -7262,7 +7262,7 @@ a2a = ai_near_actors_targets_pid[PID_ID(v3)]; memcpy(&a3, Actor::GetDirectionInfo(v1->uPackedID, ai_near_actors_targets_pid[PID_ID(v3)], &a3, 0), sizeof(a3)); memcpy(&a4, &a3, sizeof(a4)); - v5 = &pActors[PID_ID(v3 >> 3)]; + v5 = &pActors[PID_ID(v3)]; LOWORD(v3) = v5->uAIState; if ( (short)v3 != Dead ) { @@ -7369,8 +7369,8 @@ __int16 stru262_TurnBased::_40680F(int a2) { TurnBased_QueueElem *v2; // eax@1 - TurnBased_QueueElem *v3; // eax@1 - TurnBased_QueueElem *v4; // edi@2 + unsigned int v3; // eax@1 + unsigned int v4; // edi@2 Actor *v5; // ebx@2 unsigned int *v6; // esi@7 AIDirection *v7; // esi@10 @@ -7392,13 +7392,13 @@ v2 = (TurnBased_QueueElem *)((char *)this + 16 * (a2 + 2)); v21 = v2; v2->uActionLength = 0; - v3 = (TurnBased_QueueElem *)v2->uPackedID; + v3 = v2->uPackedID; if ( (unsigned __int8)v3 & 3 ) { - v3 = (TurnBased_QueueElem *)((signed int)v3 >> 3); + v3 = PID_ID(v3); v4 = v3; - a2a = (int)v3; - v5 = &pActors[(int)v3]; + a2a = v3; + v5 = &pActors[v3]; LOWORD(v3) = v5->uAIState; if ( (short)v3 != 5 ) { @@ -7421,7 +7421,7 @@ v20 = 0; } if (PID_TYPE(v22) == OBJECT_Actor) - v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[v22 >> 3].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3); + v10 = (unsigned __int8)*(&byte_5C8D1A[89 * (pMonsterStats->pInfos[pActors[PID_ID(v22)].pMonsterInfo.uID].uID - 1) / 3] + (v5->pMonsterInfo.uID - 1) / 3); else v10 = 4; if ( v10 == 1 ) @@ -7496,24 +7496,25 @@ { Actor::_403476(v13, v22, &v18); LABEL_43: - v3 = v21; + //v3 = v21; v21->field_C = 1; LABEL_48: - v3->uActionLength = v5->uCurrentActionLength; - return (signed __int16)v3; + v21->uActionLength = v5->uCurrentActionLength; + //return (signed __int16)v3; + return (signed __int16)&v21; } } LABEL_44: if ( (double)(signed int)v20 < 307.2 ) { Actor::_403C6C(v13, v22, &v18); - v3 = v21; + //v3 = v21; v21->field_C = 3; goto LABEL_48; } LABEL_47: Actor::AI_Stand(v13, v22, 0x40u, &v18); - v3 = v21; + //v3 = v21; v21->field_C = 0; goto LABEL_48; } @@ -7555,7 +7556,7 @@ v8 = ai_near_actors_targets_pid[PID_ID(v5)]; memcpy(&v7, Actor::GetDirectionInfo(v5, v8, &a3, v2), sizeof(v7)); if ( !v1->_406D10(a2) ) - Actor::AI_Stand(v10->uPackedID >> 3, v8, 0x20u, &v7); + Actor::AI_Stand(PID_ID(v10->uPackedID), v8, 0x20u, &v7); } ++a2; ++v10; @@ -7646,7 +7647,7 @@ a1 = v14->uPackedID; if (PID_TYPE(a1) != OBJECT_Player) { - v5 = v4 >> 3; + v5 = PID_ID(v4); v12 = v5; v6 = &pActors[v5]; if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result @@ -8042,8 +8043,8 @@ int v65; // [sp+60h] [bp-8h]@4 int v66; // [sp+64h] [bp-4h]@7 - v2 = (signed int)uObjID >> 3; - v3 = (uObjID & 7) - 2; + v2 = PID_ID(uObjID); + v3 = PID_TYPE(uObjID) - 2; v4 = uObj2ID; if ( v3 ) { @@ -8078,8 +8079,8 @@ v65 = v11; } v66 = v7; - v12 = v4 >> 3; - v13 = (v4 & 7) - 2; + v12 = PID_ID(v4); + v13 = PID_TYPE(v4) - 2; if ( v13 ) { v14 = v13 - 1; diff -r e398541aee60 -r ceef50611567 mm7_6.cpp --- a/mm7_6.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/mm7_6.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -3557,7 +3557,7 @@ a1.vPosition.x = pActors[PID_ID(a2)].vPosition.x; a1.vPosition.z = pActors[PID_ID(a2)].vPosition.z; a1.vPosition.y = pActors[PID_ID(a2)].vPosition.y; - a1.spell_target_pid = PID(OBJECT_Actor, a2 >> 3); + a1.spell_target_pid = PID(OBJECT_Actor, PID_ID(a2)); auto obj_id = a1.Create(0, 0, 0, 0); DamageMonsterFromParty(PID(OBJECT_Item, obj_id), PID_ID(a2), &v697); LODWORD(v727) = 1; @@ -3569,12 +3569,12 @@ if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - if ( !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 3u) ) + if ( !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 3u) ) { LODWORD(v727) = 1; goto play_sound_and_continue; } - pActors[a2 >> 3].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0); + pActors[PID_ID(a2)].pActorBuffs[10].Apply(pMiscTimer->uTotalGameTimeElapsed + 128, 0, 0, 0, 0); v704.x = 0; v704.y = 0; v704.z = 0; @@ -3730,7 +3730,7 @@ if (PID_TYPE(a2) != OBJECT_Actor || (v730 = PID_ID(a2), v721 = (int)&pActors[PID_ID(a2)], - !stru_50C198.GetMagicalResistance(&pActors[a2 >> 3], 9u)) ) + !stru_50C198.GetMagicalResistance(&pActors[PID_ID(a2)], 9u)) ) { LODWORD(v727) = 1; goto play_sound_and_continue; @@ -3784,7 +3784,7 @@ v58 = (signed __int64)((double)(23040 * v2) * 0.033333335); v59 = v721; //((SpellBuff *)((char *)&pActors[0].pActorBuffs[7] + v721))->Apply( - pActors[a2 >> 3].pActorBuffs[7].Apply(pParty->uTimePlayed + (signed int)v58, + pActors[PID_ID(a2)].pActorBuffs[7].Apply(pParty->uTimePlayed + (signed int)v58, v731, amount, 0, @@ -3826,7 +3826,7 @@ a1.spell_level = v2; a1.spell_skill = v731; v60 = pObjectList->ObjectIDByItemID(a1.uType); - v61 = a2 >> 3; + v61 = PID_ID(a2); goto LABEL_1086; } @@ -4365,7 +4365,7 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - LODWORD(v725) = a2 & 7; + LODWORD(v725) = PID_TYPE(a2); if (PID_TYPE(a2) == OBJECT_Actor) { uRequiredMana = pActors[PID_ID(a2)].vPosition.x; @@ -4731,11 +4731,11 @@ } if ( !pPlayer->CanCastSpell(uRequiredMana) ) goto play_sound_and_continue; - v208 = a2 & 7; - LODWORD(v725) = a2 & 7; + v208 = PID_TYPE(a2); + LODWORD(v725) = PID_TYPE(a2); if ( v208 == 3 ) { - v209 = a2 >> 3; + v209 = PID_ID(a2); LODWORD(v718) = pActors[v209].vPosition.x; v210 = pActors[v209].vPosition.y; v211 = pActors[v209].vPosition.z; @@ -5672,7 +5672,7 @@ } if (PID_TYPE(v342) == OBJECT_Actor) { - v343 = v342 >> 3; + v343 = PID_ID(v342); HIDWORD(v344) = 0 + ((pParty->uTimePlayed + 1280) >> 32); LODWORD(v344) = LODWORD(pParty->uTimePlayed) + 1280; pActors[v343].pActorBuffs[11].Apply(v344, v731, amount, 0, 0); @@ -7028,7 +7028,7 @@ } goto play_sound_and_continue; } - v577 = (Player *)(v576 >> 3); + v577 = (Player *)(PID_ID(v576)); //v726 = v577; if ( v577 == (Player *)-1 ) { @@ -7791,13 +7791,13 @@ //v7 = pMouse->uPointingObjectID; int target_pid = pMouse->uPointingObjectID; - int target_type = target_pid & 7, - target_id = target_pid >> 3; + int target_type = PID_TYPE(target_pid), + target_id = PID_ID(target_pid); if (target_type != OBJECT_Actor || !pActors[target_id].CanAct()) { target_pid = stru_50C198.FindClosestActor(5120, 0, 0); - target_type = target_pid & 7; - target_id = target_pid >> 3; + target_type = PID_TYPE(target_pid); + target_id = PID_ID(target_pid); } auto actor = &pActors[target_id]; diff -r e398541aee60 -r ceef50611567 mm7_data.cpp --- a/mm7_data.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/mm7_data.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -346,8 +346,8 @@ int (__stdcall *off_4DAFDC)(char); // weak char asc_4DB724[777]; // idb int dword_4DBD94; // weak -int dword_4DF380[777]; // weak -int dword_4DF390; // weak +int dword_4DF380[5]={0,1024,2560,5120,10240}; // weak +//int dword_4DF390; // weak char Str2[777]; // idb int dword_4DF3A4; // weak char byte_4E185C; // weak diff -r e398541aee60 -r ceef50611567 stru6.cpp --- a/stru6.cpp Sat Mar 30 19:36:05 2013 +0400 +++ b/stru6.cpp Sun Mar 31 10:44:43 2013 +0100 @@ -832,7 +832,7 @@ AddMobileLight(a2, 0xFF3C1E, 256); if (pRenderer->pRenderD3D) { - result = a2->spell_caster_pid & 7; + result = PID_TYPE(a2->spell_caster_pid); if (PID_TYPE(a2->spell_caster_pid) != OBJECT_Actor && PID_TYPE(a2->spell_caster_pid) != OBJECT_Item) {