comparison mm7_2.cpp @ 848:ceef50611567

* AI fixed (temporary) * PID_ID, PID_TYPE replaces * >> 7 error in AudioPlayer
author zipi
date Sun, 31 Mar 2013 10:44:43 +0100
parents d061180f2b42
children 8fafe3645f36 cb0b3badc7f7
comparison
equal deleted inserted replaced
847:e398541aee60 848:ceef50611567
380 v1 = pActors;//[0].uAIState; 380 v1 = pActors;//[0].uAIState;
381 v7 = uNumActors; 381 v7 = uNumActors;
382 do 382 do
383 { 383 {
384 v2 = v1->uAIState; 384 v2 = v1->uAIState;
385 if ( v1->uAIState == Dead || v2 == Removed || v2 == Disabled || (v3 = v1->uSummonerID) != 0 && (v3 & 7) == OBJECT_Player) 385 if ( v1->uAIState == Dead || v2 == Removed || v2 == Disabled || (v3 = v1->uSummonerID) != 0 && PID_TYPE(v3) == OBJECT_Player)
386 ++v0; 386 ++v0;
387 ++v1; 387 ++v1;
388 --v7; 388 --v7;
389 } 389 }
390 while ( v7 ); 390 while ( v7 );
4980 LOWORD(v9) = v9 & 0x1C00; 4980 LOWORD(v9) = v9 & 0x1C00;
4981 v11 = v7 + v4; 4981 v11 = v7 + v4;
4982 LOWORD(v7) = v5 & 0xE0; 4982 LOWORD(v7) = v5 & 0xE0;
4983 v12 = v7 + v11; 4983 v12 = v7 + v11;
4984 LOWORD(v7) = v8 & 0xE0; 4984 LOWORD(v7) = v8 & 0xE0;
4985 return ((v8 & 7) + (v5 & 7) + (a3a & 7) + (v6 & 7)) | (v7 + v12) | ((v8 & 0x1C00) 4985 return (PID_TYPE(v8) + PID_TYPE(v5) + PID_TYPE(a3a) + PID_TYPE(v6)) | (v7 + v12) | ((v8 & 0x1C00)
4986 + (v5 & 0x1C00) 4986 + (v5 & 0x1C00)
4987 + v9 4987 + v9
4988 + (__PAIR__(v10, (unsigned __int16)a4 >> 2) & 0x1C00)); 4988 + (__PAIR__(v10, (unsigned __int16)a4 >> 2) & 0x1C00));
4989 } 4989 }
4990 4990
10211 ++v6; 10211 ++v6;
10212 v19 = v6; 10212 v19 = v6;
10213 } 10213 }
10214 while ( v6 < v22 ); 10214 while ( v6 < v22 );
10215 } 10215 }
10216 if ( (v7 & 7) == OBJECT_Decoration) 10216 if ( PID_TYPE(v7) == OBJECT_Decoration)
10217 { 10217 {
10218 v16 = (unsigned int)v7 >> 3; 10218 v16 = (unsigned int)PID_ID(v7);
10219 if ( (signed int)(((unsigned int)*v21 >> 16) 10219 if ( (signed int)(((unsigned int)*v21 >> 16)
10220 - pDecorationList->pDecorations[pLevelDecorations[(unsigned int)v7 >> 3].uDecorationDescID].uRadius) <= 512 ) 10220 - pDecorationList->pDecorations[pLevelDecorations[(unsigned int)PID_ID(v7)].uDecorationDescID].uRadius) <= 512 )
10221 if ( v19 == v22 && v4 < 100 ) 10221 if ( v19 == v22 && v4 < 100 )
10222 { 10222 {
10223 ++v22; 10223 ++v22;
10224 ++v4; 10224 ++v4;
10225 v8 = *v21; 10225 v8 = *v21;
10309 int v26; // [sp+Ch] [bp-8h]@1 10309 int v26; // [sp+Ch] [bp-8h]@1
10310 int a3; // [sp+13h] [bp-1h]@5 10310 int a3; // [sp+13h] [bp-1h]@5
10311 10311
10312 v26 = a2; 10312 v26 = a2;
10313 v2 = a1; 10313 v2 = a1;
10314 switch ( a1 & 7 ) 10314 switch ( PID_TYPE(a1) )
10315 { 10315 {
10316 case OBJECT_Item: // take the item 10316 case OBJECT_Item: // take the item
10317 v17 = a1 >> 3; 10317 v17 = PID_ID(a1);
10318 v26 = a1 >> 3; 10318 v26 = PID_ID(a1);
10319 v18 = a1 >> 3; 10319 v18 = PID_ID(a1);
10320 if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10 10320 if ( pObjectList->pObjects[pSpriteObjects[v18].uObjectDescID].uFlags & 0x10
10321 || v17 >= 1000 10321 || v17 >= 1000
10322 || !pSpriteObjects[v18].uObjectDescID ) 10322 || !pSpriteObjects[v18].uObjectDescID )
10323 return 1; 10323 return 1;
10324 v19 = &pSpriteObjects[v18].stru_24; 10324 v19 = &pSpriteObjects[v18].stru_24;
10346 } 10346 }
10347 SpriteObject::OnInteraction(v21); 10347 SpriteObject::OnInteraction(v21);
10348 break; 10348 break;
10349 10349
10350 case OBJECT_Actor: 10350 case OBJECT_Actor:
10351 v12 = a1 >> 3; 10351 v12 = PID_ID(a1);
10352 v13 = &pActors[a1 >> 3]; 10352 v13 = &pActors[PID_ID(a1)];
10353 v14 = v13->uAIState; 10353 v14 = v13->uAIState;
10354 if ( v14 == 4 || v14 == 17 ) 10354 if ( v14 == 4 || v14 == 17 )
10355 return 1; 10355 return 1;
10356 if ( v14 == 5 ) 10356 if ( v14 == 5 )
10357 { 10357 {
10358 stru_50C198.LootActor(&pActors[a1 >> 3]); 10358 stru_50C198.LootActor(&pActors[PID_ID(a1)]);
10359 } 10359 }
10360 else 10360 else
10361 { 10361 {
10362 if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() ) 10362 if ( !v13->GetActorsRelation(0) && !(BYTE2(v13->uAttributes) & 8) && v13->CanAct() )
10363 { 10363 {
10390 } 10390 }
10391 } 10391 }
10392 break; 10392 break;
10393 10393
10394 case OBJECT_Decoration: 10394 case OBJECT_Decoration:
10395 v8 = &pLevelDecorations[a1 >> 3]; 10395 v8 = &pLevelDecorations[PID_ID(a1)];
10396 v9 = v8->field_16_event_id; 10396 v9 = v8->field_16_event_id;
10397 if ( v9 ) 10397 if ( v9 )
10398 { 10398 {
10399 EventProcessor(v9, a1, 1); 10399 EventProcessor(v9, a1, 1);
10400 LOBYTE(v8->field_2) |= 8u; 10400 LOBYTE(v8->field_2) |= 8u;
10401 } 10401 }
10402 else 10402 else
10403 { 10403 {
10404 if ( !pLevelDecorations[a1 >> 3].IsInteractive() ) 10404 if ( !pLevelDecorations[PID_ID(a1)].IsInteractive() )
10405 return 1; 10405 return 1;
10406 v10 = v8->_idx_in_stru123; 10406 v10 = v8->_idx_in_stru123;
10407 v24 = 1; 10407 v24 = 1;
10408 v11 = stru_5E4C90._decor_events[v10 - 75] + 380; 10408 v11 = stru_5E4C90._decor_events[v10 - 75] + 380;
10409 activeLevelDecoration = v8; 10409 activeLevelDecoration = v8;
10411 activeLevelDecoration = NULL; 10411 activeLevelDecoration = NULL;
10412 } 10412 }
10413 break; 10413 break;
10414 10414
10415 default: 10415 default:
10416 if ( (a1 & 7) != OBJECT_BModel) 10416 if ( PID_TYPE(a1) != OBJECT_BModel)
10417 { 10417 {
10418 MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0); 10418 MessageBoxW(nullptr, L"Warning: Invalid ID reached!", L"E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\Mouse.cpp:2020", 0);
10419 return 1; 10419 return 1;
10420 } 10420 }
10421 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor ) 10421 if ( uCurrentlyLoadedLevelType != LEVEL_Indoor )
10422 { 10422 {
10423 if ( a1 >> 9 >= pOutdoor->uNumBModels 10423 if ( a1 >> 9 >= pOutdoor->uNumBModels
10424 || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(a1 >> 3) & 0x3F], BYTE2(v7->uAttributes) & 0x10) 10424 || (v7 = &pOutdoor->pBModels[a1 >> 9].pFaces[(PID_ID(a1)) & 0x3F], BYTE2(v7->uAttributes) & 0x10)
10425 || (v6 = v7->sCogTriggeredID) == 0 ) 10425 || (v6 = v7->sCogTriggeredID) == 0 )
10426 return 1; 10426 return 1;
10427 EventProcessor((signed __int16)v6, v2, 1); 10427 EventProcessor((signed __int16)v6, v2, 1);
10428 return 0; 10428 return 0;
10429 } 10429 }
10430 v4 = &pIndoor->pFaces[a1 >> 3]; 10430 v4 = &pIndoor->pFaces[PID_ID(a1)];
10431 v5 = v4->uAttributes; 10431 v5 = v4->uAttributes;
10432 if ( !(v5 & 0x2000000) ) 10432 if ( !(v5 & 0x2000000) )
10433 { 10433 {
10434 ShowNothingHereStatus(); 10434 ShowNothingHereStatus();
10435 return 1; 10435 return 1;
10486 { 10486 {
10487 v5 = v15; 10487 v5 = v15;
10488 v6 = ((v12 - v4 - 1) >> 1) + 1; 10488 v6 = ((v12 - v4 - 1) >> 1) + 1;
10489 do 10489 do
10490 { 10490 {
10491 if ( (*(char *)v5 & 7) == OBJECT_Actor) 10491 if ( PID_TYPE(*(char *)v5) == OBJECT_Actor)
10492 { 10492 {
10493 if ( *v5 <= a3 << 16 ) 10493 if ( *v5 <= a3 << 16 )
10494 { 10494 {
10495 v7 = (signed int)(unsigned __int16)*v5 >> 3; 10495 v7 = PID_ID((signed int)(unsigned __int16)*v5);
10496 v8 = pActors[v7].uAIState; 10496 v8 = pActors[v7].uAIState;
10497 if ( v8 != 5 ) 10497 if ( v8 != 5 )
10498 { 10498 {
10499 if ( v8 != 4 && v8 != 11 && v8 != 17 && v8 != 19 ) 10499 if ( v8 != 4 && v8 != 11 && v8 != 17 && v8 != 19 )
10500 { 10500 {
10557 do 10557 do
10558 { 10558 {
10559 v3 = pRenderer->GetParentBillboardID(a1a); 10559 v3 = pRenderer->GetParentBillboardID(a1a);
10560 v4 = pBillboardRenderList[v3].sZValue; 10560 v4 = pBillboardRenderList[v3].sZValue;
10561 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid; 10561 v5 = (unsigned __int16)pBillboardRenderList[v3].object_pid;
10562 if ( (v5 & 7) == OBJECT_Actor) 10562 if ( PID_TYPE(v5) == OBJECT_Actor)
10563 { 10563 {
10564 if ( v4 <= (unsigned int)(a3 << 16) ) 10564 if ( v4 <= (unsigned int)(a3 << 16) )
10565 { 10565 {
10566 v6 = v5 >> 3; 10566 v6 = PID_ID(v5);
10567 v7 = v6; 10567 v7 = v6;
10568 v8 = pActors[v6].uAIState; 10568 v8 = pActors[v6].uAIState;
10569 if ( v8 != 5 ) 10569 if ( v8 != 5 )
10570 { 10570 {
10571 if ( v8 != 4 ) 10571 if ( v8 != 4 )
10815 if ( v0 <= 0 ) 10815 if ( v0 <= 0 )
10816 return 0; 10816 return 0;
10817 while ( 1 ) 10817 while ( 1 )
10818 { 10818 {
10819 v19 = dword_720020_zvalues[v18] & 0xFFFF; 10819 v19 = dword_720020_zvalues[v18] & 0xFFFF;
10820 v20 = (dword_720020_zvalues[v18] & 0xFFFFu) >> 3; 10820 v20 = PID_ID(dword_720020_zvalues[v18]);
10821 if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Item) 10821 if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Item)
10822 { 10822 {
10823 if ( v20 >= 0x3E8 ) 10823 if ( v20 >= 0x3E8 )
10824 return 0; 10824 return 0;
10825 if ( !(pSpriteObjects[v20].uAttributes & 0x10) ) 10825 if ( !(pSpriteObjects[v20].uAttributes & 0x10) )
10826 { 10826 {
10829 v24 = v23; 10829 v24 = v23;
10830 goto LABEL_51; 10830 goto LABEL_51;
10831 } 10831 }
10832 goto LABEL_41; 10832 goto LABEL_41;
10833 } 10833 }
10834 if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Actor) 10834 if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Actor)
10835 { 10835 {
10836 if ( v20 >= 0xBB8 ) 10836 if ( v20 >= 0xBB8 )
10837 return 0; 10837 return 0;
10838 v24 = (const char *)&pActors[v20]; 10838 v24 = (const char *)&pActors[v20];
10839 goto LABEL_51; 10839 goto LABEL_51;
10840 } 10840 }
10841 if ( (dword_720020_zvalues[v18] & 7) == OBJECT_Decoration) 10841 if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_Decoration)
10842 break; 10842 break;
10843 if ( (dword_720020_zvalues[v18] & 7) == OBJECT_BModel) 10843 if ( PID_TYPE(dword_720020_zvalues[v18]) == OBJECT_BModel)
10844 { 10844 {
10845 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 10845 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
10846 { 10846 {
10847 v21 = &pIndoor->pFaces[v20]; 10847 v21 = &pIndoor->pFaces[v20];
10848 if ( !(BYTE3(v21->uAttributes) & 2) ) 10848 if ( !(BYTE3(v21->uAttributes) & 2) )
10851 } 10851 }
10852 else 10852 else
10853 { 10853 {
10854 if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 >= pOutdoor->uNumBModels ) 10854 if ( (dword_720020_zvalues[v18] & 0xFFFFu) >> 9 >= pOutdoor->uNumBModels )
10855 goto LABEL_41; 10855 goto LABEL_41;
10856 v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[((dword_720020_zvalues[v18] & 0xFFFFu) >> 3) & 0x3F].sCogTriggeredID; 10856 v22 = pOutdoor->pBModels[(dword_720020_zvalues[v18] & 0xFFFFu) >> 9].pFaces[v20 & 0x3F].sCogTriggeredID;
10857 } 10857 }
10858 if ( v22 ) 10858 if ( v22 )
10859 { 10859 {
10860 v23 = GetEventHintString(v22); 10860 v23 = GetEventHintString(v22);
10861 if ( v23 ) 10861 if ( v23 )
11158 11158
11159 v153 = uLayingItemID; 11159 v153 = uLayingItemID;
11160 v2 = &pSpriteObjects[uLayingItemID]; 11160 v2 = &pSpriteObjects[uLayingItemID];
11161 v3 = &pObjectList->pObjects[v2->uObjectDescID]; 11161 v3 = &pObjectList->pObjects[v2->uObjectDescID];
11162 v145 = a2; 11162 v145 = a2;
11163 v151 = a2 & 7; 11163 v151 = PID_TYPE(a2);
11164 if ( (a2 & 7) == OBJECT_Actor) 11164 if ( PID_TYPE(a2) == OBJECT_Actor)
11165 { 11165 {
11166 if ( (v2->spell_caster_pid & 7) == OBJECT_Actor && !pActors[v2->spell_caster_pid >> 3].GetActorsRelation(&pActors[a2 >> 3]) ) 11166 if ( PID_TYPE(v2->spell_caster_pid) == OBJECT_Actor && !pActors[PID_ID(v2->spell_caster_pid)].GetActorsRelation(&pActors[PID_ID(a2)]) )
11167 return 1; 11167 return 1;
11168 } 11168 }
11169 else 11169 else
11170 { 11170 {
11171 if ( (a2 & 7) == OBJECT_Player && (v2->spell_caster_pid & 7) == OBJECT_Player) 11171 if ( PID_TYPE(a2) == OBJECT_Player && PID_TYPE(v2->spell_caster_pid) == OBJECT_Player)
11172 return 1; 11172 return 1;
11173 } 11173 }
11174 if ( pParty->bTurnBasedModeOn == 1 ) 11174 if ( pParty->bTurnBasedModeOn == 1 )
11175 { 11175 {
11176 v5 = v2->uAttributes; 11176 v5 = v2->uAttributes;
11178 { 11178 {
11179 --pTurnEngine->field_1C; 11179 --pTurnEngine->field_1C;
11180 v2->uAttributes = v5 & 0xFFFB; 11180 v2->uAttributes = v5 & 0xFFFB;
11181 } 11181 }
11182 } 11182 }
11183 if ( v151 == OBJECT_BModel && (v2->spell_caster_pid & 7) != OBJECT_Player) 11183 if ( v151 == OBJECT_BModel && PID_TYPE(v2->spell_caster_pid) != OBJECT_Player)
11184 BYTE2(pActors[v2->spell_caster_pid >> 3].uAttributes) |= 4u; 11184 BYTE2(pActors[PID_ID(v2->spell_caster_pid)].uAttributes) |= 4u;
11185 v6 = v2->uType; 11185 v6 = v2->uType;
11186 v7 = v2->uType; 11186 v7 = v2->uType;
11187 if ( v7 > 3060 ) 11187 if ( v7 > 3060 )
11188 { 11188 {
11189 if ( v7 > 6090 ) 11189 if ( v7 > 6090 )
11293 SpriteObject::OnInteraction(v153); 11293 SpriteObject::OnInteraction(v153);
11294 return 0; 11294 return 0;
11295 } 11295 }
11296 v106 = v145; 11296 v106 = v145;
11297 v150 = 0; 11297 v150 = 0;
11298 v139 = v106 >> 3; 11298 v139 = PID_ID(v106);
11299 v137 = v2->spell_level; 11299 v137 = v2->spell_level;
11300 v152 = v2->spell_skill; 11300 v152 = v2->spell_skill;
11301 v136 = v2->spell_id; 11301 v136 = v2->spell_id;
11302 if ( v6 == 9030 ) 11302 if ( v6 == 9030 )
11303 { 11303 {
11366 if ( v7 == 8090 || v7 == 7030 || v7 == 7090 || v7 == 8000 ) 11366 if ( v7 == 8090 || v7 == 7030 || v7 == 7090 || v7 == 8000 )
11367 goto LABEL_93; 11367 goto LABEL_93;
11368 if ( v7 == 8010 ) 11368 if ( v7 == 8010 )
11369 { 11369 {
11370 if ( v151 == 3 11370 if ( v151 == 3
11371 && MonsterStats::BelongsToSupertype(pActors[v145 >> 3].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) ) 11371 && MonsterStats::BelongsToSupertype(pActors[PID_ID(v145)].pMonsterInfo.uID, MONSTER_SUPERTYPE_UNDEAD) )
11372 sub_43A97E(v153, v145); 11372 sub_43A97E(v153, v145);
11373 v93 = pObjectList->uNumObjects; 11373 v93 = pObjectList->uNumObjects;
11374 ++v2->uType; 11374 ++v2->uType;
11375 v9 = 0; 11375 v9 = 0;
11376 v52 = 0; 11376 v52 = 0;