Mercurial > mm7
changeset 1330:82431a85b28e
turnbased start part cleaning
author | Gloval |
---|---|
date | Wed, 03 Jul 2013 01:06:41 +0400 |
parents | 27a699abee51 |
children | f0be1fecd642 ee2672b14d75 |
files | AudioPlayer.h TurnEngine.h mm7_2.cpp mm7_3.cpp |
diffstat | 4 files changed, 177 insertions(+), 214 deletions(-) [+] |
line wrap: on
line diff
--- a/AudioPlayer.h Tue Jul 02 14:08:40 2013 +0600 +++ b/AudioPlayer.h Wed Jul 03 01:06:41 2013 +0400 @@ -102,6 +102,7 @@ SOUND_Arcomage_131 = 0x83, SOUND_Arcomage_WallUpgrade = 0x84, SOUND_GoldReceived = 0xC8, + SOUND_207 =207, SOUND_OpenChest = 208, SOUND_PlayerCantCastSpell = 0xD1, SOUND_Bell = 0xD9,
--- a/TurnEngine.h Tue Jul 02 14:08:40 2013 +0600 +++ b/TurnEngine.h Wed Jul 03 01:06:41 2013 +0400 @@ -59,12 +59,12 @@ int field_0; int field_4; int field_8; - int uActorQueueSize; + int uActorQueueSize; //c int field_10; - int uActionPointsLeft; + int uActionPointsLeft; //14 int field_18; int field_1C; - TurnBased_QueueElem pQueue[2]; + TurnBased_QueueElem pQueue[504]; //20 }; #pragma pack(pop)
--- a/mm7_2.cpp Tue Jul 02 14:08:40 2013 +0600 +++ b/mm7_2.cpp Wed Jul 03 01:06:41 2013 +0400 @@ -6152,7 +6152,7 @@ assert(sizeof(GUIWindow) == 0x54); assert(sizeof(GUIProgressBar) == 0x1B8); assert(sizeof(GUIFont) == 0x1020); - assert(sizeof(stru262_TurnBased) == 0x40); + // assert(sizeof(stru262_TurnBased) == 0x40); assert(sizeof(ArcomageGame) == 0xFB); assert(sizeof(CastSpellInfo) == 0x14); assert(sizeof(ArcomageCard) == 0x6C);
--- a/mm7_3.cpp Tue Jul 02 14:08:40 2013 +0600 +++ b/mm7_3.cpp Wed Jul 03 01:06:41 2013 +0400 @@ -12569,216 +12569,178 @@ //----- (004059DB) -------------------------------------------------------- signed int stru262_TurnBased::Start() -{ - //stru262_TurnBased *v1; // ebx@1 - unsigned int v2; // edi@1 - int v3; // esi@1 - int v4; // eax@5 - unsigned int v5; // esi@7 - Actor *pActor; // edi@7 - unsigned int v7; // eax@9 - unsigned int v8; // edx@10 - //unsigned __int8 v9; // zf@14 - //unsigned __int8 v10; // sf@14 - //unsigned __int8 v11; // of@14 - //char *v12; // esi@15 - //int v13; // ecx@16 - //unsigned __int16 v14; // ax@17 - int v15; // ecx@18 - signed __int64 v16; // qax@19 - //int v17; // edx@22 - unsigned int v18; // esi@27 - char *v19; // esi@32 - int v20; // edx@33 - char *v21; // eax@33 - int v22; // ecx@33 - int v23; // eax@34 - char *v24; // eax@34 - char *v25; // ecx@34 - int v26; // edx@34 - int v27; // eax@38 - int v28; // ecx@38 - AIDirection v30; // [sp+Ch] [bp-68h]@10 - AIDirection v31; // [sp+28h] [bp-4Ch]@10 - AIDirection a3; // [sp+44h] [bp-30h]@10 - //int v33; // [sp+60h] [bp-14h]@10 - int *v34; // [sp+64h] [bp-10h]@6 - int v35; // [sp+68h] [bp-Ch]@5 - Player *pPlayer; // [sp+6Ch] [bp-8h]@1 - int v40b; - unsigned int v37; // [sp+70h] [bp-4h]@7 - - pTurnEngine->field_18 &= 0xFFFFFFFDu; - //v1 = this; - pEventTimer->TrackGameTime(); - pAudioPlayer->StopChannels(-1, -1); - v2 = 0; - pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|SOUND_EnteringAHouse|0x1), 0, 0, -1, 0, 0, 0, 0); - pPlayer = pParty->pPlayers; - dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength; - dword_50C994 = 0; - this->field_10 = 100; - this->field_0 = 0; - this->field_8 = 64; - this->field_4 = 1; - this->uActorQueueSize = 0; - for ( v3 = 0; pPlayer <= &pParty->pPlayers[3]; ++v3 ) - { - if ( pPlayer->CanAct() ) - { - this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Player,v3); - this->pQueue[this->uActorQueueSize].field_C = 2; - this->pQueue[this->uActorQueueSize].uActionLength = 0; - pParty->pTurnBasedPlayerRecoveryTimes[this->uActorQueueSize++] = 0; - } - ++pPlayer; - } - v35 = this->uActorQueueSize; - v4 = this->uActorQueueSize; - v40b = this->uActorQueueSize; - if ( v40b < v40b + ai_arrays_size ) - { - v34 = (int *)ai_near_actors_ids.data(); - do - { - v37 = *v34; - v5 = v37; - pActor = &pActors[v37]; - if ( v37 != 10 ) - { - if ( pActors[v37].CanAct() ) - { - v7 = pActor->uAttributes; - if ( pActor->uAttributes & 0x8000 ) - { - v8 = ai_near_actors_targets_pid[v5]; - LOBYTE(v7) = v7 | 0x80; - pActor->uAttributes = v7; - //v33 = PID(OBJECT_Actor,v5); - memcpy(&v31, Actor::GetDirectionInfo(PID(OBJECT_Actor,v5), v8, &a3, 0), sizeof(v31)); - memcpy(&v30, &v31, sizeof(v30)); - Actor::AI_StandOrBored(v37, 4, 32, &v30); - this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Actor,v5); + { + //stru262_TurnBased *v1; // ebx@1 + int v3; // esi@1 + int v4; // eax@5 + unsigned int actor_id; // esi@7 + Actor *pActor; // edi@7 + unsigned int v7; // eax@9 + unsigned int v8; // edx@10 + //unsigned __int8 v9; // zf@14 + //unsigned __int8 v10; // sf@14 + //unsigned __int8 v11; // of@14 + //char *v12; // esi@15 + //int v13; // ecx@16 + //unsigned __int16 v14; // ax@17 + int v15; // ecx@18 + signed __int64 v16; // qax@19 + int v17; // edx@22 + unsigned int v18; // esi@27 + char *v19; // esi@32 + int v20; // edx@33 + char *v21; // eax@33 + int v22; // ecx@33 + int v23; // eax@34 + char *v24; // eax@34 + char *v25; // ecx@34 + int v26; // edx@34 + int v27; // eax@38 + int v28; // ecx@38 + AIDirection v30; // [sp+Ch] [bp-68h]@10 + AIDirection v31; // [sp+28h] [bp-4Ch]@10 + AIDirection a3; // [sp+44h] [bp-30h]@10 + //int v33; // [sp+60h] [bp-14h]@10 + int *v34; // [sp+64h] [bp-10h]@6 + int v35; // [sp+68h] [bp-Ch]@5 + Player *pPlayer; // [sp+6Ch] [bp-8h]@1 + int v40b; + unsigned int v37; // [sp+70h] [bp-4h]@7 + int activ_players[4]; + int players_recovery_time[4]; + int a_players_count; + int i; + + + pTurnEngine->field_18 &= 0xFFFFFFFDu; + //v1 = this; + pEventTimer->TrackGameTime(); + pAudioPlayer->StopChannels(-1, -1); + pAudioPlayer->PlaySound(SOUND_207, 0, 0, -1, 0, 0, 0, 0); + pPlayer = pParty->pPlayers; + dword_50C998_turnbased_icon_1A = 8 * pIconsFrameTable->pIcons[uIconID_TurnStart].uAnimLength; + dword_50C994 = 0; + + this->field_10 = 100; + this->field_0 = 0; + this->field_8 = 64; + this->field_4 = 1; + this->uActorQueueSize = 0; + + for ( v3 = 0; v3 < 4 ; ++v3 ) + { + if ( pParty->pPlayers[v3].CanAct() ) + { + this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Player,v3); this->pQueue[this->uActorQueueSize].field_C = 2; - this->pQueue[this->uActorQueueSize++].uActionLength = 0; - } - } - v4 = v35; - } - ++v40b; - ++v34; - } - while ( v40b < v4 + ai_arrays_size ); - v2 = 0; - } - //v11 = __OFSUB__(this->uActorQueueSize, v2); - //v9 = this->uActorQueueSize == v2; - //v10 = ((this->uActorQueueSize - v2) & 0x80000000u) != 0; - v37 = v2; - //if ( !((unsigned __int8)(v10 ^ v11) | v9) ) - if ( this->uActorQueueSize > v2 ) - { - //v12 = (char *)&this->pQueue[0].field_4; - - //while ( 1 ) - for ( v40b = v2; v40b < this->uActorQueueSize; ++v40b ) - { - //v13 = PID_TYPE(this->pQueue[0].uPackedID); - if ( PID_TYPE(this->pQueue[0].uPackedID) != OBJECT_Player ) - break; - //v14 = pPlayers[(this->pQueue[0].uPackedID >> 3) + 1]->uTimeToRecovery; - if ( pPlayers[(this->pQueue[0].uPackedID >> 3) + 1]->uTimeToRecovery != (short)v2 ) - { - //v33 = pPlayers[(this->pQueue[0].uPackedID >> 3) + 1]->uTimeToRecovery; - v16 = (signed __int64)((double)pPlayers[(this->pQueue[0].uPackedID >> 3) + 1]->uTimeToRecovery * 0.46875); - *(int *)this->pQueue[0].field_4 = v16; - this->pQueue[0].field_4 += 16; - continue; - } - v15 = v37++; - *(&a3.uDistance + v15) = v40b; - - if ( PID_TYPE(this->pQueue[0].uPackedID) != 3 ) - { - this->pQueue[0].field_4 = 666; - this->pQueue[0].field_4 += 16; - continue; - } - //v17 = rand() % 99; - if ( rand() % 99 < 33 ) - { - *(int *)this->pQueue[0].field_4 = 1; - this->pQueue[0].field_4 += 16; - continue; - } - //LODWORD(v16) = SHIDWORD(v16) < 66; - LOBYTE(v16) = SHIDWORD(v16) >= 66; - LODWORD(v16) = 2 * v16 + 3; - *(int *)this->pQueue[0].field_4 = v16; - this->pQueue[0].field_4 += 16; - } - } - -LABEL_27: - v18 = 0; - if ( (signed int)v37 > (signed int)v2 ) - { - do - { - //__debugbreak(); - *(&v31.uDistance + v18) = pParty->pPlayers[this->pQueue[*(&a3.uDistance + v18)].uPackedID >> 3].GetAttackRecoveryTime(v2);//result crash - ++v18; - } - while ( (signed int)v18 < (signed int)v37 ); - if ( (signed int)v37 > (signed int)v2 ) - { - 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 ) + this->pQueue[this->uActorQueueSize].uActionLength = 0; + pParty->pTurnBasedPlayerRecoveryTimes[this->uActorQueueSize] = 0; + ++this->uActorQueueSize; + } + } + + for ( v3 = 0; v3 < ai_arrays_size ; ++v3 ) + { + actor_id = ai_near_actors_ids[v3]; + if (actor_id == 10) + continue; + if ( pActors[actor_id].CanAct() ) + { + if ( pActors[actor_id].uAttributes & 0x8000 ) + { + v8 = ai_near_actors_targets_pid[actor_id]; + pActors[actor_id].uAttributes |= 0x80; + memcpy(&v31, Actor::GetDirectionInfo(PID(OBJECT_Actor,actor_id), v8, &a3, 0), sizeof(AIDirection)); + memcpy(&v30, &v31, sizeof(AIDirection)); + Actor::AI_StandOrBored(actor_id, 4, 32, &v30); + this->pQueue[this->uActorQueueSize].uPackedID = PID(OBJECT_Actor,actor_id); + this->pQueue[this->uActorQueueSize].field_C = 2; + this->pQueue[this->uActorQueueSize].uActionLength = 0; + ++this->uActorQueueSize; + } + } + } + + a_players_count=0; + for ( v40b = 0; v40b < this->uActorQueueSize; ++v40b ) + { + //v13 = PID_TYPE(this->pQueue[0].uPackedID); + if ( PID_TYPE(this->pQueue[v40b].uPackedID) == OBJECT_Player ) + { + if ( pPlayers[PID_ID(this->pQueue[v40b].uPackedID) + 1]->uTimeToRecovery != 0 ) + { + //v33 = pPlayers[(this->pQueue[0].uPackedID >> 3) + 1]->uTimeToRecovery; + v16 = (signed int)((double)pPlayers[PID_ID(this->pQueue[v40b].uPackedID) + 1]->uTimeToRecovery * 0.46875); + this->pQueue[v40b].field_4 = v16; + } + else + { + activ_players[a_players_count] = v40b; + ++a_players_count; + } + } + else if ( PID_TYPE(this->pQueue[v40b].uPackedID) == OBJECT_Actor ) + { + v17 = rand() % 99; + if ( v17 < 33 ) + this->pQueue[v40b].field_4 = 1; + else + this->pQueue[v40b].field_4= (v17 >= 66)? 5 : 3; + } + else { - *(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; + this->pQueue[v40b].field_4 = 666; } - ++v40b; - } - while ( v40b < (signed int)v37 ); - } - v34 = (int *)((char *)v34 + 1); - v35 += 4; - } - while ( (signed int)((char *)v34 - 1) < (signed int)v37 ); - if ( (signed int)v37 > (signed int)v2 ) - { - do - { - v27 = v2 + 2; - v28 = *(&a3.uDistance + v2++); - //v11 = __OFSUB__(v2, v37); - //v10 = ((v2 - v37) & 0x80000000u) != 0; - this->pQueue[v28].field_4 = v27; - } - while ( v37 > v2 ); - } - } - } - return this->_404544(); -} + this->pQueue[v40b].field_4 += 16; + } + + + if ( a_players_count > 0 ) + { + 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) + { + this->pQueue[activ_players[i]].field_4 = i+2; + } + } + return this->_404544(); + }