Mercurial > mm7
changeset 2214:20995bb8895a
GameResultsApply() full refactored
author | Ritor1 |
---|---|
date | Thu, 13 Feb 2014 23:02:32 +0600 |
parents | 05e74b19991d |
children | e9625ad08541 |
files | Arcomage.cpp Arcomage.h OSWindow.cpp UI/UIHouses.cpp _deleted.cpp |
diffstat | 5 files changed, 121 insertions(+), 136 deletions(-) [+] |
line wrap: on
line diff
--- a/Arcomage.cpp Thu Feb 13 17:34:47 2014 +0600 +++ b/Arcomage.cpp Thu Feb 13 23:02:32 2014 +0600 @@ -3370,58 +3370,57 @@ //----- (0040D444) -------------------------------------------------------- void GameResultsApply() { - int v0; // esi@1 - int v1; // edi@1 - int v2; // eax@1 - int v3; // eax@23 - int v4; // edx@25 - int v5; // ecx@28 - int v6; // eax@28 - GUIWindow *v7; // ecx@50 - signed int v8; // eax@50 - char v9; // eax@52 - signed int v10; // eax@54 - char *v11; // esi@59 - char *v12; // esi@65 - signed int v14; // [sp-4h] [bp-58h]@46 + int winner; // esi@1 + int victory_type; // edi@1 + int pl_resource; // edx@25 + int en_resource; // eax@28 + unsigned int tavern_num; // eax@54 char pText[64]; // [sp+Ch] [bp-48h]@1 POINT xy; // [sp+4Ch] [bp-8h]@1 - v0 = -1; - v1 = -1; + winner = -1; + victory_type = -1; //nullsub_1(); - xy.x = 0; - xy.y = 0; - strcpy(pText, "The Winner is: ");//"Победил: " - // v2 = 0; + /*strcpy(pText, "The Winner is: ");//"Победил: " Ritor1: архаизм xy.y = 160; xy.x = 320; //- 12 * v2 / 2; -// am_DrawText(-1, pText, xy); + am_DrawText(-1, pText, &xy);*/ //проверка построена ли башня - v1 = 0; if ( am_Players[0].tower_height < max_tower_height && am_Players[1].tower_height >= max_tower_height )//наша башня не построена, а у врага построена - v0 = 2;//победил игрок 2(враг) + { + winner = 2;//победил игрок 2(враг) + victory_type = 0; + } else if ( am_Players[0].tower_height >= max_tower_height && am_Players[1].tower_height < max_tower_height )//наша башня построена, а у врага нет - v0 = 1;//победил игрок 1(мы) + { + winner = 1;//победил игрок 1(мы) + victory_type = 0; + } else if ( am_Players[0].tower_height >= max_tower_height && am_Players[1].tower_height >= max_tower_height )//и у нас, и у врага построена { if ( am_Players[0].tower_height == am_Players[1].tower_height )//наши башни равны { - v0 = 0;//никто не победил - v1 = 4;//ничья + winner = 0;//никто не победил + victory_type = 4;//ничья } - else - v0 = (am_Players[0].tower_height <= am_Players[1].tower_height) + 1;//победил тот, у кого выше + else//наши башни не равны + { + winner = (am_Players[0].tower_height <= am_Players[1].tower_height) + 1;//победил тот, у кого выше + victory_type = 0; + } } //проверка разрушена ли башня if ( am_Players[0].tower_height <= 0 && am_Players[1].tower_height > 0 )//наша башня разрушена, а у врага нет - v0 = 2;// победил игрок 2(враг) + { + winner = 2;// победил игрок 2(враг) + victory_type = 2;//победил разрушив башню врага + } else if ( am_Players[0].tower_height > 0 && am_Players[1].tower_height <= 0 )//у врага башня разрушена, а у нас нет { - v0 = 1;//победил игрок 1(мы) - v1 = 2; + winner = 1;//победил игрок 1(мы) + victory_type = 2;//победил разрушив башню врага } else if ( am_Players[0].tower_height <= 0 && am_Players[1].tower_height <= 0 )//наша башня разрушена, и у врага разрушена { @@ -3429,138 +3428,124 @@ { if ( am_Players[0].wall_height == am_Players[1].wall_height )//если стены равны { - v0 = 0; - v1 = 4; + winner = 0; + victory_type = 4; } else//если стены не равны { - v0 = (am_Players[0].wall_height <= am_Players[1].wall_height) + 1;//победил тот, у кого стена выше - v1 = 1; + winner = (am_Players[0].wall_height <= am_Players[1].wall_height) + 1;//победил тот, у кого стена выше + victory_type = 1;//победа когда больше стена при ничье } } - else - v0 = (am_Players[0].tower_height <= am_Players[1].tower_height) + 1;// побеждает тот у кого башня больше - } - - //проверка набраны ли ресурсы - v3 = am_Players[0].resource_bricks; - if ( am_Players[0].resource_bricks <= am_Players[0].resource_gems ) - { - v3 = am_Players[0].resource_beasts; - v4 = am_Players[0].resource_gems; - if ( am_Players[0].resource_gems > am_Players[0].resource_beasts ) - goto LABEL_28; - } - else - { - if ( am_Players[0].resource_bricks <= am_Players[0].resource_beasts ) + else//башни не равны { - v4 = am_Players[0].resource_beasts; - goto LABEL_28; + winner = (am_Players[0].tower_height <= am_Players[1].tower_height) + 1;// побеждает тот у кого башня больше + victory_type = 2;//победил разрушив башню врага } } - v4 = v3; -LABEL_28: - v5 = am_Players[1].resource_bricks; - v6 = am_Players[1].resource_gems; - if ( am_Players[1].resource_bricks <= am_Players[1].resource_gems ) + + //проверка набраны ли ресурсы + //проверка какого ресурса больше всего у игрока 1(нас) + pl_resource = am_Players[0].resource_bricks;//кирпичей больше чем др. ресурсов + if ( am_Players[0].resource_gems > am_Players[0].resource_bricks + && am_Players[0].resource_gems > am_Players[0].resource_beasts )//драг.камней больше всего + pl_resource = am_Players[0].resource_gems; + else if ( am_Players[0].resource_beasts > am_Players[0].resource_gems + && am_Players[0].resource_beasts > am_Players[0].resource_bricks )//зверей больше всего + pl_resource = am_Players[0].resource_beasts; + + //проверка какого ресурса больше у игрока 2(врага) + en_resource = am_Players[1].resource_bricks;//кирпичей больше чем др. ресурсов + if ( am_Players[1].resource_gems > am_Players[1].resource_bricks + && am_Players[1].resource_gems > am_Players[1].resource_beasts )//драг.камней больше всего + en_resource = am_Players[1].resource_gems; + else if ( am_Players[1].resource_beasts > am_Players[1].resource_gems + && am_Players[1].resource_beasts > am_Players[1].resource_bricks )//зверей больше всего + en_resource = am_Players[1].resource_beasts; + + //сравнение ресурсов игроков + if ( winner == -1 && victory_type == -1 )//нет победителя по башням { - v5 = am_Players[1].resource_beasts; - if ( am_Players[1].resource_gems > am_Players[1].resource_beasts ) - goto LABEL_33; - goto LABEL_32; - } - v6 = am_Players[1].resource_beasts; - if ( am_Players[1].resource_bricks > am_Players[1].resource_beasts ) -LABEL_32: - v6 = v5; -LABEL_33: - if ( v0 == -1 ) - { - if ( v1 != -1 ) - goto LABEL_49; - if ( v4 < max_resources_amount ) + if ( pl_resource < max_resources_amount && en_resource >= max_resources_amount )//враг набрал нужное количество + { + winner = 2;// враг победил + victory_type = 3;//победа собрав нужное количество ресурсов + } + else if ( pl_resource >= max_resources_amount && en_resource < max_resources_amount )//мы набрали нужное количество { - if ( v6 < max_resources_amount ) - goto LABEL_49; - v0 = 2; + winner = 1;// мы победили + victory_type = 3;//победа собрав нужное количество ресурсов } - else + else if ( pl_resource >= max_resources_amount && en_resource >= max_resources_amount )//и у нас и у врага нужное количество ресурсов { - if ( v6 < max_resources_amount ) - v0 = 1; + if ( pl_resource == en_resource )// ресурсы равны + { + winner = 0;//ресурсы равны + victory_type = 4; //ничья + } else { - if ( v4 == v6 ) - goto LABEL_46; - v0 = (v4 <= v6) + 1; + winner = (pl_resource <= en_resource) + 1;//ресурсы не равны, побеждает тот у кого больше + victory_type = 3;//победа собрав нужное количество ресурсов } } - v1 = 3; } - if ( !v0 && v1 == 4 ) + else if ( winner == 0 && victory_type == 4 )// при ничье по башням и стене { - if ( v4 != v6 ) + if ( pl_resource != en_resource )//ресурсы не равны { - v14 = 5; - v0 = (v4 <= v6) + 1; - goto LABEL_48; + winner = (pl_resource <= en_resource) + 1;//победил тот у кого больше + victory_type = 5;//победа когда при ничье большее количество ресурсов } -LABEL_46: - v0 = 0; - v14 = 4; -LABEL_48: - v1 = v14; + else //ресурсы равны + { + winner = 0;//нет победителя + victory_type = 4; //ничья + } } -LABEL_49: - pArcomageGame->field_B0 = v1; - pArcomageGame->uGameResult = v0; - if ( v0 == 1 ) + + //подведение итогов + pArcomageGame->Victory_type = victory_type; + pArcomageGame->uGameWinner = winner; + if ( winner == 1 )//победитель игрок 1(мы) { - - v8 = (signed int)window_SpeakInHouse->par1C; - if (( v8 >= 108 )&&( v8 <= 120 )) + if (( window_SpeakInHouse->par1C >= 108 ) && ( window_SpeakInHouse->par1C <= 120 ))//таверны { - if ( !pParty->pArcomageWins[v8-108] ) - { - pParty->pArcomageWins[v8-108] = 1; - signed int _a = (signed int)(p2DEvents[ window_SpeakInHouse->par1C - 1].fPriceMultiplier * 100.0); - pParty->PartyFindsGold(_a, 0); - } - + if ( !pParty->pArcomageWins[window_SpeakInHouse->par1C - 108] ) + { + pParty->pArcomageWins[window_SpeakInHouse->par1C - 108] = 1; + pParty->PartyFindsGold(p2DEvents[ window_SpeakInHouse->par1C - 1].fPriceMultiplier * 100.0, 0);//вознаграждение + } } - v10 = 108; - do + //проверка выполнен ли квест по аркомагу + tavern_num = 0; + for ( uint i = 108; i <= 120; ++i ) { - if ( !pParty->pArcomageWins[v10-108] ) + if ( !pParty->pArcomageWins[i - 108] ) break; - ++v10; + tavern_num++; } - while ( v10 <= 120 ); - - if ( v10 == 121 ) - _449B7E_toggle_bit(pParty->_quest_bits, 238, 1); - - for (int i=0; i < 4; ++i ) + if ( tavern_num == 13 ) + _449B7E_toggle_bit(pParty->_quest_bits, 238, 1);// 238 - Won all Arcomage games + + for ( int i = 0; i < 4; ++i )//внесение записи в Заслуги { - v11 = (char *)&pParty->pPlayers[i]._achieved_awards_bits; - if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v11, 1) ) - _449B7E_toggle_bit((unsigned char *)v11, PLAYER_GUILD_BITS__ARCOMAGE_WIN, 1); + if ( !_449B57_test_bit(pParty->pPlayers[i]._achieved_awards_bits, 1) ) + _449B7E_toggle_bit(pParty->pPlayers[i]._achieved_awards_bits, PLAYER_GUILD_BITS__ARCOMAGE_WIN, 1); } ++pParty->uNumArcomageWins; - if ( pParty->uNumArcomageWins > 1000000 ) + if ( pParty->uNumArcomageWins > 1000000 )//ограничение количества побед pParty->uNumArcomageWins = 1000000; } - else + else//проигрыш { - for ( int i = 0; i < 4; ++i ) + for ( int i = 0; i < 4; ++i )//внесение записи в Заслуги { - v12 = (char *)&pParty->pPlayers[i]._achieved_awards_bits; - if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v12, 1) ) - _449B7E_toggle_bit((unsigned char *)v12, PLAYER_GUILD_BITS__ARCOMAGE_LOSE, 1); + if ( !_449B57_test_bit(pParty->pPlayers[i]._achieved_awards_bits, 1) ) + _449B7E_toggle_bit(pParty->pPlayers[i]._achieved_awards_bits, PLAYER_GUILD_BITS__ARCOMAGE_LOSE, 1); } ++pParty->uNumArcomageLoses; - if ( pParty->uNumArcomageLoses > 1000000 ) + if ( pParty->uNumArcomageLoses > 1000000 )//ограничение количества проигрышей pParty->uNumArcomageLoses = 1000000; } } @@ -3671,7 +3656,7 @@ //----- (0040D75D) -------------------------------------------------------- void am_DrawText( int a1, const char *pText, POINT *pXY ) { - pPrimaryWindow->DrawText( pFontComic, pXY->x, pXY->y - ((pFontComic->uFontHeight - 3) >> 1) + 3, 0, pText, 0, 0, 0); + pPrimaryWindow->DrawText( pFontComic, pXY->x, pXY->y - ((pFontComic->uFontHeight - 3) / 2) + 3, 0, pText, 0, 0, 0); } //----- (0040DB27) --------------------------------------------------------
--- a/Arcomage.h Thu Feb 13 17:34:47 2014 +0600 +++ b/Arcomage.h Thu Feb 13 23:02:32 2014 +0600 @@ -169,8 +169,8 @@ RGBTexture pGameBackground; RGBTexture pSprites; int event_timer_time; - int uGameResult; - int field_B0; + int uGameWinner; + int Victory_type; char pPlayer1Name[32]; char pPlayer2Name[32]; char field_F4;
--- a/OSWindow.cpp Thu Feb 13 17:34:47 2014 +0600 +++ b/OSWindow.cpp Thu Feb 13 23:02:32 2014 +0600 @@ -255,8 +255,8 @@ { pArcomageGame->GameOver = 1; pArcomageGame->field_F4 = 1; - pArcomageGame->uGameResult = 2; - pArcomageGame->field_B0 = -2; + pArcomageGame->uGameWinner = 2; + pArcomageGame->Victory_type = -2; return false; } if ( wparam != 114 )
--- a/UI/UIHouses.cpp Thu Feb 13 17:34:47 2014 +0600 +++ b/UI/UIHouses.cpp Thu Feb 13 23:02:32 2014 +0600 @@ -2019,9 +2019,9 @@ { if ( pArcomageGame->bGameInProgress == 1 ) return; - if ( pArcomageGame->uGameResult ) + if ( pArcomageGame->uGameWinner ) { - if ( pArcomageGame->uGameResult == 1 ) + if ( pArcomageGame->uGameWinner == 1 ) pText = pGlobalTXT_LocalizationStrings[640];// You won! else pText = pGlobalTXT_LocalizationStrings[641];// You lost!
--- a/_deleted.cpp Thu Feb 13 17:34:47 2014 +0600 +++ b/_deleted.cpp Thu Feb 13 23:02:32 2014 +0600 @@ -13873,8 +13873,8 @@ { pArcomageGame->GameOver = 1; pArcomageGame->field_F4 = 1; - pArcomageGame->uGameResult = 2; - pArcomageGame->field_B0 = -2; + pArcomageGame->uGameWinner = 2; + pArcomageGame->Victory_type = -2; return DefWindowProcW(hWnd, uMsg, wParam, lParam); } if ( wParam != 114 )