# HG changeset patch # User Ritor1 # Date 1394819750 -21600 # Node ID d8b4a36f54a48d77e75f4bc3291b4df06fec7509 # Parent a5926b36a1b468293e4d2301907582e01e188cc7 AI_RandomMove cleaned diff -r a5926b36a1b4 -r d8b4a36f54a4 Actor.cpp --- a/Actor.cpp Fri Mar 14 22:41:35 2014 +0600 +++ b/Actor.cpp Fri Mar 14 23:55:50 2014 +0600 @@ -1747,27 +1747,23 @@ //----- (004032B2) -------------------------------------------------------- void Actor::AI_RandomMove( unsigned int uActor_id, unsigned int uTarget_id, int radius, int uActionLength ) { - Actor *v5; // esi@1 int x; // ebx@1 int absy; // eax@1 unsigned int v9; // ebx@11 int v10; // ebx@13 AIDirection doNotInitializeBecauseShouldBeRandom; // [sp+Ch] [bp-30h]@7 - unsigned int v16; // [sp+2Ch] [bp-10h]@1 int y; // [sp+30h] [bp-Ch]@1 int absx; // [sp+38h] [bp-4h]@1 - - v5 = &pActors[uActor_id]; - v16 = uTarget_id; - x = v5->vInitialPosition.x - v5->vPosition.x; - y = v5->vInitialPosition.y - v5->vPosition.y; + + x = pActors[uActor_id].vInitialPosition.x - pActors[uActor_id].vPosition.x; + y = pActors[uActor_id].vInitialPosition.y - pActors[uActor_id].vPosition.y; absx = abs(x); absy = abs(y); if ( absx <= absy ) absx = absy + (absx / 2 ); else absx = absx + absy / 2; - if ( MonsterStats::BelongsToSupertype(v5->pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) + if ( MonsterStats::BelongsToSupertype(pActors[uActor_id].pMonsterInfo.uID, MONSTER_SUPERTYPE_TREANT) ) { if ( !uActionLength ) uActionLength = 256; @@ -1787,21 +1783,21 @@ return; } v10 = v9 + rand() % 256 - 128; - if ( abs(v10 - v5->uYawAngle) > 256 && !(v5->uAttributes & 0x200000) ) + if ( abs(v10 - pActors[uActor_id].uYawAngle) > 256 && !(pActors[uActor_id].uAttributes & 0x200000) ) { Actor::AI_Stand(uActor_id, uTarget_id, 256, &doNotInitializeBecauseShouldBeRandom); return; } - v5->uYawAngle = v10; - if ( v5->uMovementSpeed) - v5->uCurrentActionLength = 32 * absx / v5->uMovementSpeed; + pActors[uActor_id].uYawAngle = v10; + if ( pActors[uActor_id].uMovementSpeed) + pActors[uActor_id].uCurrentActionLength = 32 * absx / pActors[uActor_id].uMovementSpeed; else - v5->uCurrentActionLength = 0; - v5->uCurrentActionTime = 0; - v5->uAIState = Tethered; + pActors[uActor_id].uCurrentActionLength = 0; + pActors[uActor_id].uCurrentActionTime = 0; + pActors[uActor_id].uAIState = Tethered; if ( rand() % 100 < 2 ) Actor::PlaySound(uActor_id, 3); - v5->UpdateAnimation(); + pActors[uActor_id].UpdateAnimation(); } //----- (004031C1) -------------------------------------------------------- @@ -3160,15 +3156,15 @@ { if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_SHORT ) Actor::AI_RandomMove(actor_id, 4, 1024, 0); - else if ( pActor->pMonsterInfo.uMovementType == 1 ) + else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_MEDIUM ) Actor::AI_RandomMove(actor_id, 4, 2560, 0); - else if ( pActor->pMonsterInfo.uMovementType == 2 ) + else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_LONG ) Actor::AI_RandomMove(actor_id, 4, 5120, 0); - else if ( pActor->pMonsterInfo.uMovementType == 4 ) + else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_FREE ) Actor::AI_RandomMove(actor_id, 4, 10240, 0); else if ( pActor->pMonsterInfo.uMovementType == MONSTER_MOVEMENT_TYPE_STAIONARY ) { - Actor::GetDirectionInfo(a1, 4u, &v72, 0); + Actor::GetDirectionInfo(a1, 4, &v72, 0); v58 = (uint)(pActor->pMonsterInfo.uRecoveryTime * 2.133333333333333); Actor::AI_Stand(actor_id, 4, v58, &v72); } diff -r a5926b36a1b4 -r d8b4a36f54a4 Indoor.cpp --- a/Indoor.cpp Fri Mar 14 22:41:35 2014 +0600 +++ b/Indoor.cpp Fri Mar 14 23:55:50 2014 +0600 @@ -2726,7 +2726,8 @@ for ( actor_id = 0; actor_id < uNumActors; actor_id++ ) { - if ( pActors[actor_id].uAIState == 11 || pActors[actor_id].uAIState == 19 || pActors[actor_id].uAIState == 17 || !pActors[actor_id].uMovementSpeed ) + if ( pActors[actor_id].uAIState == Removed || pActors[actor_id].uAIState == Disabled + || pActors[actor_id].uAIState == Summoned || !pActors[actor_id].uMovementSpeed ) continue; uSectorID = pActors[actor_id].uSectorID; v2 = collide_against_floor(pActors[actor_id].vPosition.x, pActors[actor_id].vPosition.y, pActors[actor_id].vPosition.z, &uSectorID, &uFaceID); @@ -2761,7 +2762,7 @@ } if ( pActors[actor_id].uAIState == Pursuing || pActors[actor_id].uAIState == Fleeing ) v6 *= 2; - if ( pParty->bTurnBasedModeOn == 1 && pTurnEngine->turn_stage == TE_WAIT ) + if ( pParty->bTurnBasedModeOn == true && pTurnEngine->turn_stage == TE_WAIT ) v6 = (signed __int64)((double)v6 * flt_6BE3AC_debug_recmod1_x_1_6); if ( v6 > 1000 ) v6 = 1000; @@ -2796,7 +2797,8 @@ if ( v59 && !v62 ) pActors[actor_id].vVelocity.z += -8 * LOWORD(pEventTimer->uTimeElapsed) * GetGravityStrength(); } - if ( pActors[actor_id].vVelocity.x * pActors[actor_id].vVelocity.x + pActors[actor_id].vVelocity.y * pActors[actor_id].vVelocity.y + if ( pActors[actor_id].vVelocity.x * pActors[actor_id].vVelocity.x + + pActors[actor_id].vVelocity.y * pActors[actor_id].vVelocity.y + pActors[actor_id].vVelocity.z * pActors[actor_id].vVelocity.z >= 400 ) { stru_721530.field_84 = -1; @@ -2877,7 +2879,7 @@ pActors[actor_id].vPosition.y = LOWORD(stru_721530.normal2.y); pActors[actor_id].vPosition.z = LOWORD(stru_721530.normal2.z) - LOWORD(stru_721530.prolly_normal_d) - 1; pActors[actor_id].uSectorID = LOWORD(stru_721530.uSectorID); - continue; + goto LABEL_123; } pActors[actor_id].vPosition.x += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.x); pActors[actor_id].vPosition.y += fixpoint_mul(stru_721530.field_7C, stru_721530.direction.y); @@ -3036,11 +3038,11 @@ else { if ( pParty->bTurnBasedModeOn == 1 && (pTurnEngine->turn_stage == TE_ATTACK || pTurnEngine->turn_stage == TE_MOVEMENT) ) - continue; + goto LABEL_123; if ( !pActors[actor_id].pMonsterInfo.uHostilityType || v56 != v22 ) { Actor::AI_StandOrBored(actor_id, 4, v22, &v52); - continue; + goto LABEL_123; } } } @@ -3057,8 +3059,8 @@ pActors[actor_id].uAIState = Removed; } } -//LABEL_123: - //; +LABEL_123: + ; } } diff -r a5926b36a1b4 -r d8b4a36f54a4 IndoorCameraD3D.cpp --- a/IndoorCameraD3D.cpp Fri Mar 14 22:41:35 2014 +0600 +++ b/IndoorCameraD3D.cpp Fri Mar 14 23:55:50 2014 +0600 @@ -615,28 +615,14 @@ //----- (004379EE) -------------------------------------------------------- void IndoorCameraD3D::debug_outline_sw(RenderVertexSoft *a2, unsigned int uNumVertices, unsigned int uDiffuse, float a5) { - unsigned int v5; // esi@1 - RenderVertexSoft *v6; // eax@2 - RenderVertexSoft *v7; // edi@3 - char v8; // zf@3 - unsigned int uNumVerticesa; // [sp+20h] [bp+Ch]@2 - - v5 = 0; + if ( !uNumVertices ) + return; if ( (signed int)(uNumVertices - 1) > 0 ) { - v6 = a2; - v5 = uNumVertices - 1; - uNumVerticesa = uNumVertices - 1; - do - { - v7 = v6 + 1; - do_draw_debug_line_sw(v6, uDiffuse, v6 + 1, uDiffuse, 0, a5); - v8 = uNumVerticesa-- == 1; - v6 = v7; - } - while ( !v8 ); + for ( uint i = 0; i < uNumVertices - 1; i++ ) + do_draw_debug_line_sw(&a2[i], uDiffuse, &a2[i + 1], uDiffuse, 0, a5); } - do_draw_debug_line_sw(&a2[v5], uDiffuse, a2, uDiffuse, 0, a5); + do_draw_debug_line_sw(&a2[uNumVertices - 1], uDiffuse, a2, uDiffuse, 0, a5); } diff -r a5926b36a1b4 -r d8b4a36f54a4 mm7_2.cpp --- a/mm7_2.cpp Fri Mar 14 22:41:35 2014 +0600 +++ b/mm7_2.cpp Fri Mar 14 23:55:50 2014 +0600 @@ -2376,17 +2376,17 @@ pIcons_LOD->_inlined_sub2(); pWindow_MMT_MainMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_MainMenu, 0, 0); - Texture* MMT_MM6 = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); - Texture* MMT_MM7 = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); - Texture* MMT_MM8 = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); + Texture* MMT_MM6 = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE); + Texture* MMT_MM7 = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE); + Texture* MMT_MM8 = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE); Texture* MMT_Continue = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); - Texture* MMT_Exit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); - - pMMT_MainMenu_BtnMM6 = pWindow_MMT_MainMenu->CreateButton((window->GetWidth() / 4) - 100, window->GetHeight() / 4, MMT_MM6->uTextureWidth, MMT_MM6->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM6, 0, 0, "", MMT_MM6, 0); - pMMT_MainMenu_BtnMM7 = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - (window->GetWidth() / 4), window->GetHeight() / 4, MMT_MM7->uTextureWidth, MMT_MM7->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM7, 1, 0, "", MMT_MM7, 0); - pMMT_MainMenu_BtnMM8 = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - (window->GetWidth() / 4), window->GetHeight() - ((window->GetHeight() / 4) + 50), MMT_MM8->uTextureWidth, MMT_MM8->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM8, 2, 0, "", MMT_MM8, 0); + Texture* MMT_Exit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE); + + pMMT_MainMenu_BtnMM6 = pWindow_MMT_MainMenu->CreateButton((window->GetWidth() / 4) - 100, window->GetHeight() / 4, MMT_MM6->uTextureWidth, MMT_MM6->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM6, 0, 0, "", MMT_MM6, 0); + pMMT_MainMenu_BtnMM7 = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - (window->GetWidth() / 4), window->GetHeight() / 4, MMT_MM7->uTextureWidth, MMT_MM7->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM7, 1, 0, "", MMT_MM7, 0); + pMMT_MainMenu_BtnMM8 = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - (window->GetWidth() / 4), window->GetHeight() - ((window->GetHeight() / 4) + 50), MMT_MM8->uTextureWidth, MMT_MM8->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_MM8, 2, 0, "", MMT_MM8, 0); pMMT_MainMenu_BtnContinue = pWindow_MMT_MainMenu->CreateButton((window->GetWidth() / 4) - 100, window->GetHeight() - ((window->GetHeight() / 4) + 50), MMT_Continue->uTextureWidth, MMT_Continue->uTextureHeight, 1, 0, UIMSG_MMT_MainMenu_Continue, 3, 0, "", MMT_Continue, 0); - pMMT_MainMenu_BtnExit = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - 130, window->GetHeight() - 35, MMT_Exit->uTextureWidth, MMT_Exit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 4, 0, "", MMT_Exit, 0); + pMMT_MainMenu_BtnExit = pWindow_MMT_MainMenu->CreateButton(window->GetWidth() - 130, window->GetHeight() - 35, MMT_Exit->uTextureWidth, MMT_Exit->uTextureHeight, 1, 0, UIMSG_ExitToWindows, 4, 0, "", MMT_Exit, 0); pTexture_PCX.Release(); //pTexture_PCX.Load("MMTTITLE.pcx", 0);