Mercurial > mm7
changeset 1337:c6695ebd8fe6
Слияние
author | Ritor1 |
---|---|
date | Thu, 04 Jul 2013 09:21:57 +0600 |
parents | 3358b59b8fe8 (current diff) f0be1fecd642 (diff) |
children | 9749edd941c6 |
files | mm7_4.cpp mm7_5.cpp |
diffstat | 4 files changed, 142 insertions(+), 141 deletions(-) [+] |
line wrap: on
line diff
--- a/TurnEngine.h Thu Jul 04 09:21:40 2013 +0600 +++ b/TurnEngine.h Thu Jul 04 09:21:57 2013 +0600 @@ -36,9 +36,9 @@ field_1C = 0; } - signed int _404544(); + void _404544(); void _40471C(); - signed int Start(); + void Start(); void End(bool bPlaySound); void _405E14(); __int16 StartTurn();
--- a/mm7_3.cpp Thu Jul 04 09:21:40 2013 +0600 +++ b/mm7_3.cpp Thu Jul 04 09:21:57 2013 +0600 @@ -12419,8 +12419,8 @@ } //----- (00404544) -------------------------------------------------------- -signed int stru262_TurnBased::_404544() -{ +void stru262_TurnBased::_404544() + { stru262_TurnBased *v1; // ebx@1 TurnBased_QueueElem *v2; // esi@2 Actor *v3; // edi@4 @@ -12444,6 +12444,8 @@ signed int v21; // [sp+28h] [bp-4h]@16 int v22; // [sp+28h] [bp-4h]@31 + int i; + v20 = 0; v1 = this; v19 = this->uActorQueueSize; @@ -12464,15 +12466,16 @@ LOBYTE(v3->uAttributes) &= 0x7Fu; } } + if ( PID_TYPE(v2->uPackedID) == OBJECT_Player) { v5 = &pParty->pPlayers[v2->uPackedID >> 3]; - if ( v5->pConditions[14] - || v5->pConditions[16] - || v5->pConditions[15] - || v5->pConditions[13] - || v5->pConditions[12] - || v5->pConditions[2] ) + if ( v5->pConditions[Player::Condition_Dead] + || v5->pConditions[Player::Condition_Eradicated] + || v5->pConditions[Player::Condition_Pertified] + || v5->pConditions[Player::Condition_Unconcious] + || v5->pConditions[Player::Condition_Paralyzed] + || v5->pConditions[Player::Condition_Sleep] ) { --v19; v2->field_4 = 1001; @@ -12483,6 +12486,8 @@ } while ( v20 < v1->uActorQueueSize ); } + + //sort v6 = v1->uActorQueueSize; if ( v6 > 0 ) { @@ -12498,10 +12503,10 @@ { v9 = v8->field_4; v10 = v7->field_4; - if ( v9 < v10 - || v9 == v10 - && ((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)) ) + if ( v8->field_4 < v7->field_4 || v8->field_4 == v7->field_4 + && (( PID_TYPE(v8->uPackedID) == OBJECT_Player) && PID_TYPE(v7->uPackedID) == OBJECT_Actor + || PID_TYPE(v8->uPackedID) == PID_TYPE(v7->uPackedID) && + (v8->uPackedID & 0xFFFFFFF8) < (v7->uPackedID & 0xFFFFFFF8)) ) { v12 = v7->uPackedID; v13 = v7->field_4; @@ -12528,33 +12533,26 @@ while ( v21 - 1 < v6 ); } v1->uActorQueueSize = v19; - result = v1->pQueue[0].uPackedID; - if ( PID_TYPE(v1->pQueue[0].uPackedID) == OBJECT_Player) - { - result = PID_ID(result) + 1; - uActiveCharacter = result; - v1->field_18 |= 4u; + + + if ( PID_TYPE(pQueue[0].uPackedID) == OBJECT_Player) + { + uActiveCharacter = PID_ID(pQueue[0].uPackedID)+1; + field_18 |= 4u; } else { uActiveCharacter = 0; - v1->field_18 &= 0xFFFFFFFBu; - } - v22 = 0; - if ( v1->uActorQueueSize > 0 ) - { - v17 = v1->pQueue; - do - { - if ( PID_TYPE(v17->uPackedID) == OBJECT_Player) - pParty->pPlayers[PID_ID(v17->uPackedID)].uTimeToRecovery = (signed __int64)((double)v17->field_4 * 0.46875); - ++v22; - ++v17; - result = v22; - } - while ( v22 < v1->uActorQueueSize ); - } - return result; + field_18 &= 0xFFFFFFFBu; + } + + for(i=0; i<uActorQueueSize; ++i) + { + if ( PID_TYPE(pQueue[i].uPackedID) == OBJECT_Player) + pParty->pPlayers[PID_ID(pQueue[i].uPackedID)].uTimeToRecovery = (signed __int64)((double)pQueue[i].field_4 * 0.46875); + } + + } //----- (0040471C) -------------------------------------------------------- @@ -12568,7 +12566,7 @@ } //----- (004059DB) -------------------------------------------------------- -signed int stru262_TurnBased::Start() +void stru262_TurnBased::Start() { //stru262_TurnBased *v1; // ebx@1 int v3; // esi@1 @@ -12609,7 +12607,8 @@ int activ_players[4]; int players_recovery_time[4]; int a_players_count; - int i; + int i,j; + int temp; pTurnEngine->field_18 &= 0xFFFFFFFDu; @@ -12700,47 +12699,27 @@ for (i=0; i<a_players_count; ++i) players_recovery_time[i] = pParty->pPlayers[PID_ID(this->pQueue[activ_players[i]].uPackedID)].GetAttackRecoveryTime(0); //sort players by recovery time - for (i=0; i<a_players_count; ++i) - { //to fix - //v35 = v2; - //v34 = (int *)1; - //do - // { - // v40b = (int)v34; - // if ( (signed int)v34 < (signed int)v37 ) - // { - // v19 = (char *)&v31.uDistance + v35; - // do - // { - // v20 = *(int *)v19; - // //v33 = 4 * v40b; - // v21 = (char *)(&v31.uDistance + v40b); - // v22 = *(int *)v21; - // if ( *(int *)v21 < v20 ) - // { - // *(int *)v21 = v20; - // v23 = 4 * v40b; - // *(int *)v19 = v22; - // v24 = (char *)&a3.uDistance + v23; - // v25 = (char *)&a3.uDistance + v35; - // v26 = *(int *)v24; - // *(int *)v24 = *(unsigned int *)((char *)&a3.uDistance + v35); - // *(int *)v25 = v26; - // v2 = 0; - // } - // ++v40b; - // } - // while ( v40b < (signed int)v37 ); - // } - // v34 = (int *)((char *)v34 + 1); - // v35 += 4; - // } - // while ( (signed int)((char *)v34 - 1) < (signed int)v37 ); + for (i=0; i < a_players_count; ++i) + { + for(j=i+1; j<a_players_count;++j ) + { + if (players_recovery_time[j] < players_recovery_time[i]) //swap values + { + temp = players_recovery_time[i]; + players_recovery_time[i] = players_recovery_time[j]; + players_recovery_time[j] = temp; + + temp = activ_players[i]; + activ_players[i] = activ_players[j]; + activ_players[j] = temp; + } + } } + for (i=0; i<a_players_count; ++i) { this->pQueue[activ_players[i]].field_4 = i+2; } } - return this->_404544(); - } + this->_404544(); + }
--- a/mm7_4.cpp Thu Jul 04 09:21:40 2013 +0600 +++ b/mm7_4.cpp Thu Jul 04 09:21:57 2013 +0600 @@ -6280,7 +6280,6 @@ void stru262_TurnBased::End(bool bPlaySound) { stru262_TurnBased *v2; // edi@1 - int v3; // ebx@1 int v4; // esi@1 unsigned __int8 v5; // zf@1 unsigned __int8 v6; // sf@1 @@ -6294,7 +6293,6 @@ int v14; // [sp+Ch] [bp-4h]@11 v2 = this; - v3 = 0; v4 = 0; v5 = this->uActorQueueSize == 0; v6 = this->uActorQueueSize < 0; @@ -6311,6 +6309,7 @@ } while ( v4 < v2->uActorQueueSize ); } + if ( (signed int)uNumSpriteObjects > 0 ) { pAttributes = &pSpriteObjects[0].uAttributes; @@ -6328,6 +6327,7 @@ } while ( v9 ); } + v14 = 0; if ( v2->uActorQueueSize > 0 ) { @@ -6349,15 +6349,15 @@ ++v11; } while ( v14 < v2->uActorQueueSize ); - v3 = 0; } + pAudioPlayer->StopChannels(-1, -1); - if ( bPlaySound != v3 ) - pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|SOUND_EnteringAHouse), v3, v3, -1, v3, v3, v3, v3); + if ( bPlaySound != 0 ) + pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|SOUND_EnteringAHouse), 0, 0, -1, 0, 0, 0, 0); pTurnEngine->field_18 &= 0xFFFFFFFDu; pEventTimer->StopGameTime(); - dword_50C994 = v3; - dword_50C998_turnbased_icon_1A = v3; + dword_50C994 = 0; + dword_50C998_turnbased_icon_1A = 0; } // 50C994: using guessed type int dword_50C994; // 50C998: using guessed type int dword_50C998_turnbased_icon_1A;
--- a/mm7_5.cpp Thu Jul 04 09:21:40 2013 +0600 +++ b/mm7_5.cpp Thu Jul 04 09:21:57 2013 +0600 @@ -5242,7 +5242,7 @@ unsigned int v5; // edi@14 v1 = this; - LOWORD(v2) = _404544(); + _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 = (PID_ID(v2)) + 1, uActiveCharacter = v2), viewparams->bRedrawGameUI = 1, @@ -5583,43 +5583,44 @@ //----- (00406A63) -------------------------------------------------------- void stru262_TurnBased::_406A63() { - //stru262_TurnBased *v1; // ebx@1 - //int v2; // esi@1 - //unsigned __int8 v3; // zf@1 - //unsigned __int8 v4; // sf@1 - //signed int v5; // ecx@4 + stru262_TurnBased *v1; // ebx@1 + int v2; // esi@1 + unsigned __int8 v3; // zf@1 + unsigned __int8 v4; // sf@1 + signed int v5; // ecx@4 AIDirection a3; // [sp+8h] [bp-44h]@5 AIDirection v7; // [sp+24h] [bp-28h]@5 unsigned int v8; // [sp+40h] [bp-Ch]@5 signed int a2; // [sp+44h] [bp-8h]@1 - //TurnBased_QueueElem *v10; // [sp+48h] [bp-4h]@2 - - //v1 = this; - //v2 = 0; + TurnBased_QueueElem *v10; // [sp+48h] [bp-4h]@2 + + v1 = this; + v2 = 0; this->field_8 = 64; dword_50C994 = 0; uActiveCharacter = 0; - //v3 = this->uActorQueueSize == 0; - //v4 = this->uActorQueueSize < 0; - - if ( this->uActorQueueSize ) + v3 = this->uActorQueueSize == 0; + v4 = this->uActorQueueSize < 0; + a2 = 0; + if ( !(v4 | v3) ) { - //v10 = this->pQueue; - - for ( a2 = 0; a2 < this->uActorQueueSize; ++a2 ) + v10 = this->pQueue; + while ( 1 ) { - //v5 = this->pQueue[a2].uPackedID; - if (PID_TYPE(this->pQueue[a2].uPackedID) == OBJECT_Actor) + v5 = v10->uPackedID; + if (PID_TYPE(v10->uPackedID) == OBJECT_Actor) { - v8 = ai_near_actors_targets_pid[PID_ID(this->pQueue[a2].uPackedID)]; - memcpy(&v7, Actor::GetDirectionInfo(this->pQueue[a2].uPackedID, v8, &a3, 0), sizeof(v7)); - if ( !this->_406D10(a2) ) - Actor::AI_Stand(PID_ID(this->pQueue[a2].uPackedID), v8, 0x20u, &v7);//actors move + 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(PID_ID(v10->uPackedID), v8, 0x20u, &v7); } - //++v10; - //v2 = 0; + ++a2; + ++v10; + if ( a2 >= v1->uActorQueueSize ) + break; + v2 = 0; } - } } // 50C994: using guessed type int dword_50C994; @@ -5674,58 +5675,79 @@ int stru262_TurnBased::_406B9F() { signed int result; // eax@1 - Actor *pCurrentActor; // ebx@5 + unsigned __int8 v2; // zf@1 + unsigned __int8 v3; // sf@1 + int v4; // esi@4 + unsigned int v5; // esi@5 + Actor *v6; // ebx@5 + unsigned __int16 v7; // cx@15 AIDirection a3; // [sp+0h] [bp-50h]@15 AIDirection v9; // [sp+1Ch] [bp-34h]@15 + signed int a1; // [sp+38h] [bp-18h]@4 + stru262_TurnBased *thisa; // [sp+3Ch] [bp-14h]@1 unsigned int v12; // [sp+40h] [bp-10h]@5 unsigned int v13; // [sp+44h] [bp-Ch]@8 + TurnBased_QueueElem *v14; // [sp+48h] [bp-8h]@2 signed int a2; // [sp+4Ch] [bp-4h]@1 result = 0; - if ( this->uActorQueueSize ) + thisa = this; + v2 = this->uActorQueueSize == 0; + v3 = this->uActorQueueSize < 0; + a2 = 0; + if ( !(v3 | v2) ) { - - for ( a2 = 0; a2 < this->uActorQueueSize; ++a2 ) + v14 = this->pQueue; + while ( 1 ) { - if (PID_TYPE(this->pQueue[a2].uPackedID) != OBJECT_Player) + v4 = v14->uPackedID; + a1 = v14->uPackedID; + if (PID_TYPE(a1) != OBJECT_Player) { - pCurrentActor = &pActors[PID_ID(this->pQueue[a2].uPackedID)]; - if ( pCurrentActor->pActorBuffs[5].uExpireTime <= 0 ) - v13 = 0; + v5 = PID_ID(v4); + v12 = v5; + v6 = &pActors[v5]; + if ( SHIDWORD(v6->pActorBuffs[5].uExpireTime) < result + || SHIDWORD(v6->pActorBuffs[5].uExpireTime) <= result && LODWORD(v6->pActorBuffs[5].uExpireTime) <= result ) + v13 = result; else v13 = 1; - if ( pCurrentActor->pActorBuffs[6].uExpireTime >= 0 ) - v12 = 1; - if ( !(v13 != 0 || v12 || pCurrentActor->uAIState == Dead || pCurrentActor->uAIState == Removed || pCurrentActor->uAIState == Disabled) ) + if ( SHIDWORD(v6->pActorBuffs[6].uExpireTime) >= result + && (SHIDWORD(v6->pActorBuffs[6].uExpireTime) > result || LODWORD(v6->pActorBuffs[6].uExpireTime) > result) ) + result = 1; + if ( !(v13 != 0 || result || v6->uAIState == 5 || v6->uAIState == 11 || v6->uAIState == 19) ) { - v13 = ai_near_actors_targets_pid[PID_ID(this->pQueue[a2].uPackedID)]; - memcpy(&v9, Actor::GetDirectionInfo(this->pQueue[a2].uPackedID, v13, &a3, 0), sizeof(v9)); - if ( pCurrentActor->uAIState == Pursuing || pCurrentActor->uAIState == Tethered ) + v13 = ai_near_actors_targets_pid[v5]; + memcpy(&v9, Actor::GetDirectionInfo(a1, v13, &a3, 0), sizeof(v9)); + v7 = v6->uAIState; + if ( v7 == 6 || v7 == 1 ) { if ( (double)(signed int)v9.uDistance < 307.2 ) + goto LABEL_26; + } + v6->uCurrentActionTime += pEventTimer->uTimeElapsed; + if ( (signed int)v6->uCurrentActionTime > v6->uCurrentActionLength ) + { + if ( v7 == 4 ) { - Actor::AI_Stand(PID_ID(this->pQueue[a2].uPackedID), v13, 0x20u, &v9); - continue; + v6->uCurrentActionTime = 0; + v6->uCurrentActionLength = 0; + v6->uAIState = Dead; + v6->UpdateAnimation(); } - } - pCurrentActor->uCurrentActionTime += pEventTimer->uTimeElapsed; - if ( (signed int)pCurrentActor->uCurrentActionTime > pCurrentActor->uCurrentActionLength ) - { - if ( pCurrentActor->uAIState == Dying ) - { - pCurrentActor->uCurrentActionTime = 0; - pCurrentActor->uCurrentActionLength = 0; - pCurrentActor->uAIState = Dead; - pCurrentActor->UpdateAnimation(); - } - if ( !this->_406D10(a2) ) - Actor::AI_Stand(PID_ID(this->pQueue[a2].uPackedID), v13, 0x20u, &v9); + if ( !thisa->_406D10(a2) ) +LABEL_26: + Actor::AI_Stand(v12, v13, 0x20u, &v9); } } } + ++a2; + result = (signed int)thisa; + ++v14; + if ( a2 >= thisa->uActorQueueSize ) + break; result = 0; } - } return result; } @@ -5763,7 +5785,7 @@ unsigned int uActorID; // [sp+50h] [bp-4h]@2 unsigned int a2a; // [sp+5Ch] [bp+8h]@7 - //__debugbreak();// + // __debugbreak();// v2 = *(&this->field_0 + 4 * (a2 + 2)); if (PID_TYPE(v2) == OBJECT_Player) return 0;