comparison Arcomage.cpp @ 1204:832f09144726

hopefully correct merge
author Grumpy7
date Sat, 08 Jun 2013 21:47:29 +0200
parents 1eed3e0ab666
children 8c02e6f74b29
comparison
equal deleted inserted replaced
1203:1eed3e0ab666 1204:832f09144726
21 #include "texts.h" 21 #include "texts.h"
22 #include <windef.h> 22 #include <windef.h>
23 23
24 24
25 25
26 void sub_409BE8(); 26 void SetStartConditions();
27 27
28 28
29 void am_409FE9(); 29 void SetStartGameData();
30 void am_40A198(); 30 void FillPlayerDeck();
31 void am_40A255(); 31 void am_40A255();
32 void am_40A283(int a1); 32 void am_40A283(int a1);
33 int GetEmptyCardSlotIndex(int player_num); 33 int GetEmptyCardSlotIndex(int player_num);
34 void am_40A346(int player_num); 34 void IncreaseResourcesInTurn(int player_num);
35 void __cdecl am_40A383(); 35 void __cdecl am_40A383();
36 bool am_40A514(); 36 bool IsGameOver();
37 char __thiscall am_40A560(unsigned int _this); 37 char __thiscall am_40A560(unsigned int _this);
38 void am_blts(int a1); // idb 38 void DrawGameUI(int a1); // idb
39 void am_40AA4E(); 39 void am_40AA4E();
40 void __cdecl am_chroma_blts(); 40 void DrawRectanglesForText();
41 void __cdecl am_DrawUI(); 41 void DrawPlayersText();
42 void am_40B102(int a1, char *text, POINT *pXY); // idb 42 void DrawPlayerLevels(int a1, char *text, POINT *pXY); // idb
43 void am_40B17E(int a1, char* text, POINT *pXY); // idb 43 void DrawBricksCount(int a1, char* text, POINT *pXY); // idb
44 void am_40B1F3(int a1, char* text, POINT* pXY); 44 void DrawGemsCount(int a1, char* text, POINT* pXY);
45 void am_40B268(int a1, char *text, POINT *pXY); // idb 45 void DrawBeastsCount(int a1, char *text, POINT *pXY); // idb
46 void __cdecl am_chroma_and_copy_blts(); 46 void DrawPlayersTowers();
47 void __cdecl am_chroma_blt(); 47 void DrawPlayersWall();
48 void __cdecl am_40B4B9(); 48 void __cdecl am_40B4B9();
49 void __fastcall am_40B76F(int a1); 49 void __fastcall am_40B76F(int a1);
50 int GetPlayerHandCardCount(int player_num); 50 int GetPlayerHandCardCount(int player_num);
51 signed int __fastcall am_40BB67(int a1); 51 signed int __fastcall am_40BB67(int a1);
52 char __fastcall am_40BCFB(int a1, signed int a2); 52 char __fastcall am_40BCFB(int a1, signed int a2);
53 bool __fastcall am_40BE0E(int a1, signed int a2); 53 bool PlayCard(int player_num, signed int card_slot_num);
54 bool am_40BF15(int player_num, int hand_card_indx); 54 bool CanCardBePlayed(int player_num, int hand_card_indx);
55 void __fastcall am_40BF77(int a1, unsigned int uCardID); // idb 55 void __fastcall am_40BF77(int a1, unsigned int uCardID); // idb
56 int am_40D2B4(POINT* a1, int a2); // weak 56 int am_40D2B4(POINT* a1, int a2); // weak
57 int __fastcall am_40D402(int, int); // weak 57 int __fastcall am_40D402(int, int); // weak
58 int __cdecl am_40D444(); 58 int __cdecl GameResultsApply();
59 59
60 void pPrimaryWindow_draws_text(int a1, const char *pText, POINT *pXY); 60 void pPrimaryWindow_draws_text(int a1, const char *pText, POINT *pXY);
61 void __thiscall am_BeginScene(unsigned __int16 *pPcxPixels, int a2, int a3); // idb 61 void __thiscall am_BeginScene(unsigned __int16 *pPcxPixels, int a2, int a3); // idb
62 void __fastcall Blt_Chroma(RECT *pSrcXYZW, POINT *pTargetXY, int a3, int a4); 62 void __fastcall Blt_Chroma(RECT *pSrcXYZW, POINT *pTargetXY, int a3, int a4);
63 void Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3); 63 void Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3);
69 char *__fastcall inv_strcpy(const char *Source, char *Dest); 69 char *__fastcall inv_strcpy(const char *Source, char *Dest);
70 void __fastcall intToString(int val, char *pOut); 70 void __fastcall intToString(int val, char *pOut);
71 71
72 /* 388 */ 72 /* 388 */
73 #pragma pack(push, 1) 73 #pragma pack(push, 1)
74 struct stru348 74 struct ArcomageStartConditions
75 { 75 {
76 __int16 field_0; 76 __int16 max_tower;
77 __int16 field_2; 77 __int16 max_resources;
78 __int16 field_4; 78 __int16 tower_height;
79 __int16 field_6; 79 __int16 wall_height;
80 __int16 field_8; 80 __int16 quarry_level;
81 __int16 field_A; 81 __int16 magic_level;
82 __int16 field_C; 82 __int16 might_level;
83 __int16 field_E; 83 __int16 bricks_amount;
84 __int16 field_10; 84 __int16 gems_amount;
85 __int16 field_12; 85 __int16 beasts_amount;
86 int field_14; 86 int field_14;
87 }; 87 };
88 #pragma pack(pop) 88 #pragma pack(pop)
89 stru348 stru_4E1890[13] = 89 ArcomageStartConditions start_conditions[13] =
90 { 90 {
91 { 30, 100, 15, 5, 2, 2, 2, 10, 10, 10, 0}, 91 { 30, 100, 15, 5, 2, 2, 2, 10, 10, 10, 0},
92 { 50, 150, 20, 5, 2, 2, 2, 5, 5, 5, 1}, 92 { 50, 150, 20, 5, 2, 2, 2, 5, 5, 5, 1},
93 { 50, 150, 20, 5, 2, 2, 2, 5, 5, 5, 2}, 93 { 50, 150, 20, 5, 2, 2, 2, 5, 5, 5, 2},
94 { 75, 200, 25, 10, 3, 3, 3, 5, 5, 5, 2}, 94 { 75, 200, 25, 10, 3, 3, 3, 5, 5, 5, 2},
106 #define SIG_trpg 0x67707274 106 #define SIG_trpg 0x67707274
107 #define SIG_xxxx 0x78787878 107 #define SIG_xxxx 0x78787878
108 108
109 ArcomageGame *pArcomageGame = new ArcomageGame; 109 ArcomageGame *pArcomageGame = new ArcomageGame;
110 110
111 ArcomagePlayer am_Players[2];
111 ArcomageCard pCards[87]; 112 ArcomageCard pCards[87];
112 std::array<ArcomagePlayer, 2> am_Players;
113
114 Acromage_st1 struct_st1[10]; 113 Acromage_st1 struct_st1[10];
115 114
116 stru272 array_4FABD0[10]; 115 stru272 array_4FABD0[10];
117 116
118 ArcomageDeck playDeck; 117 ArcomageDeck playDeck;
148 147
149 148
150 149
151 char am_byte_4E185D; // weak 150 char am_byte_4E185D; // weak
152 151
153 int amuint_4E1860; // weak 152 int start_tower_height; // weak
154 int amuint_4E1864; // weak 153 int start_wall_height; // weak
155 int amuint_4E1868; // weak 154 int start_quarry_level; // weak
156 int amuint_4E186C; // weak 155 int start_magic_level; // weak
157 int amuint_4E1870; // weak 156 int start_might_level; // weak
158 157
159 158
160 int dword_4E1874 = 5; // weak 159 int dword_4E1874 = 5; // weak
161 int dword_4E1878 = 1; // weak 160 int quarry_bonus = 1; // weak
162 int dword_4E187C = 1; // weak 161 int magic_bonus = 1; // weak
163 int dword_4E1880 = 1; // weak 162 int might_bonus = 1; // weak
164 int dword_4E1884 = 50; // weak 163
165 int dword_4E1888 = 100 ; // weak 164 int max_tower_height = 50; // weak
165 int max_resources_amount = 100 ; // weak
166 166
167 int dword_4DF3A4; // weak 167 int dword_4DF3A4; // weak
168 168
169 char byte_4FAA2C; // weak 169 char byte_4FAA2C; // weak
170 char byte_4FAA2D; // weak 170 char byte_4FAA2D; // weak
171 171
172 int amuint_4FAA6C; // idb 172 int current_player_num; // idb
173 char am_byte_4FAA77; // weak 173 char am_byte_4FAA77; // weak
174 174
175 signed int dword_4FABBC; // idb 175 signed int dword_4FABBC; // idb
176 unsigned int amuint_4FABC0; // idb 176 unsigned int amuint_4FABC0; // idb
177 177
178 int dword_4FABC8; // weak 178 int dword_4FABC8; // weak
179
180 int start_bricks_amount; // weak
181 int start_gems_amount; // weak
182 int start_beasts_amount; // weak
179 183
180 184
181 //----- (0040DD2F) -------------------------------------------------------- 185 //----- (0040DD2F) --------------------------------------------------------
182 bool stru273::_40DD2F() 186 bool stru273::_40DD2F()
183 { 187 {
1550 int v1; // ecx@14 1554 int v1; // ecx@14
1551 signed int v2; // eax@15 1555 signed int v2; // eax@15
1552 stru272 *v3; // esi@17 1556 stru272 *v3; // esi@17
1553 __int16 *v4; // esi@23 1557 __int16 *v4; // esi@23
1554 1558
1555 while ( !pArcomageGame->field_F5 ) 1559 while ( !pArcomageGame->GameOver )
1556 { 1560 {
1557 pArcomageGame->field_F6 = 1; 1561 pArcomageGame->field_F6 = 1;
1558 byte_4FAA24 = 1; 1562 byte_4FAA24 = 1;
1559 am_40A346(amuint_4FAA6C); 1563 IncreaseResourcesInTurn(current_player_num);
1560 LABEL_8: 1564 LABEL_8:
1561 while ( byte_4FAA24 ) 1565 while ( byte_4FAA24 )
1562 { 1566 {
1563 amuint_4FABC0 = -1; 1567 amuint_4FABC0 = -1;
1564 am_40A283(amuint_4FAA6C); 1568 am_40A283(current_player_num);
1565 while ( 1 ) 1569 while ( 1 )
1566 { 1570 {
1567 byte_4FAA24 = am_40A560(amuint_4FAA6C); 1571 byte_4FAA24 = am_40A560(current_player_num);
1568 if ( GetPlayerHandCardCount(amuint_4FAA6C) <= dword_4E1874 ) 1572 if ( GetPlayerHandCardCount(current_player_num) <= dword_4E1874 )
1569 break; 1573 break;
1570 am_byte_4FAA77 = 1; 1574 am_byte_4FAA77 = 1;
1571 if ( pArcomageGame->field_F4 ) 1575 if ( pArcomageGame->field_F4 )
1572 goto LABEL_8; 1576 goto LABEL_8;
1573 } 1577 }
1574 am_byte_4FAA77 = 0; 1578 am_byte_4FAA77 = 0;
1575 } 1579 }
1576 pArcomageGame->field_F5 = am_40A514(); 1580 pArcomageGame->GameOver = IsGameOver();
1577 if ( !pArcomageGame->field_F5 ) 1581 if ( !pArcomageGame->GameOver )
1578 am_40A383(); 1582 am_40A383();
1579 if ( pArcomageGame->field_F4 ) 1583 if ( pArcomageGame->field_F4 )
1580 pArcomageGame->field_F5 = 1; 1584 pArcomageGame->GameOver = 1;
1581 } 1585 }
1582 am_40D444(); 1586 GameResultsApply();
1583 if ( byte_4FAA2C ) 1587 if ( byte_4FAA2C )
1584 { 1588 {
1585 // v2 = retzero_sub_40DFA7((int)dword_4FAA28); 1589 // v2 = retzero_sub_40DFA7((int)dword_4FAA28);
1586 // v1 = 1000; 1590 // v1 = 1000;
1587 // dword_4FAA70 = v2 / 1000; 1591 // dword_4FAA70 = v2 / 1000;
1612 1616
1613 1617
1614 1618
1615 1619
1616 //----- (00409FE9) -------------------------------------------------------- 1620 //----- (00409FE9) --------------------------------------------------------
1617 void am_409FE9() 1621 void SetStartGameData()
1618 { 1622 {
1619 1623
1620 signed int j; // edx@7 1624 signed int j; // edx@7
1621 int card_id_counter; // edx@13 1625 int card_id_counter; // edx@13
1622 signed int i; // ecx@13 1626 signed int i; // ecx@13
1623 signed int card_dispenser_counter; // eax@13 1627 signed int card_dispenser_counter; // eax@13
1624 1628
1625 amuint_4FAA6C = dword_505890; 1629 current_player_num = dword_505890;
1626 sub_409BE8(); 1630 SetStartConditions();
1627 for(i=0; i<2; ++i ) 1631 for(i=0; i<2; ++i )
1628 { 1632 {
1629 if ( i ) 1633 if ( i )
1630 { 1634 {
1631 strcpy(am_Players[1].pPlayerName, pArcomageGame->pPlayer2Name); 1635 strcpy(am_Players[1].pPlayerName, pArcomageGame->pPlayer2Name);
1632 if ( byte_4E185C ) 1636 if ( byte_4E185C )
1633 am_Players[1].field_20 = 0; 1637 am_Players[1].IsHisTurn = 0;
1634 else 1638 else
1635 am_Players[1].field_20 = 1; 1639 am_Players[1].IsHisTurn = 1;
1636 } 1640 }
1637 else 1641 else
1638 { 1642 {
1639 strcpy(am_Players[0].pPlayerName, pArcomageGame->pPlayer1Name); 1643 strcpy(am_Players[0].pPlayerName, pArcomageGame->pPlayer1Name);
1640 am_Players[0].field_20 = 1; 1644 am_Players[0].IsHisTurn = 1;
1641 } 1645 }
1642 am_Players[i].field_24 = amuint_4E1860; 1646 am_Players[i].tower_height = start_tower_height;
1643 am_Players[i].field_28 = amuint_4E1864; 1647 am_Players[i].wall_height = start_wall_height;
1644 am_Players[i].field_2C = amuint_4E1868; 1648 am_Players[i].quarry_level = start_quarry_level;
1645 am_Players[i].field_30 = amuint_4E186C; 1649 am_Players[i].magic_level = start_magic_level;
1646 am_Players[i].field_34 = amuint_4E1870; 1650 am_Players[i].might_level = start_might_level;
1647 am_Players[i].field_38 = amuint_505884; 1651 am_Players[i].resource_bricks = start_bricks_amount;
1648 am_Players[i].field_3C = amuint_505888; 1652 am_Players[i].resource_gems = start_gems_amount;
1649 am_Players[i].field_40 = amuint_50588C; 1653 am_Players[i].resource_beasts = start_beasts_amount;
1650 1654
1651 for (j=0; j<10; ++j ) 1655 for (j=0; j<10; ++j )
1652 { 1656 {
1653 am_Players[i].cards_at_hand[j] = -1; 1657 am_Players[i].cards_at_hand[j] = -1;
1654 if ( am_byte_4E185D ) 1658 if ( am_byte_4E185D )
1697 default: 1701 default:
1698 ++card_id_counter; 1702 ++card_id_counter;
1699 } 1703 }
1700 } 1704 }
1701 1705
1702 am_40A198(); 1706 FillPlayerDeck();
1703 } 1707 }
1704 1708
1705 //----- (0040A198) -------------------------------------------------------- 1709 //----- (0040A198) --------------------------------------------------------
1706 void am_40A198() 1710 void FillPlayerDeck()
1707 { 1711 {
1708 1712
1709 signed int v3; // eax@4 1713 signed int v3; // eax@4
1710 int v6; // edx@13 1714 int v6; // edx@13
1711 char v7; // eax@13 1715 char v7; // eax@13
1741 v6 = rand() % DECK_SIZE; 1745 v6 = rand() % DECK_SIZE;
1742 v7 = card_taken_flags[v6]; 1746 v7 = card_taken_flags[v6];
1743 } 1747 }
1744 while ( v7 == 1 ); 1748 while ( v7 == 1 );
1745 card_taken_flags[v6]=1; 1749 card_taken_flags[v6]=1;
1746 playDeck.cards_IDs[i] = deckMaster.cards_IDs[v6]; 1750 playDeck.cards_IDs[i] = deckMaster.cards_IDs[v6];
1747 playDeck.cardsInUse[i] = deckMaster.cardsInUse[v6]; 1751 playDeck.cardsInUse[i] = deckMaster.cardsInUse[v6];
1748 } 1752 }
1749 1753
1750 dword_4FABC8 = 0; 1754 dword_4FABC8 = 0;
1751 amuint_4FABC4 = -1; 1755 amuint_4FABC4 = -1;
1782 v5 = false; 1786 v5 = false;
1783 do 1787 do
1784 { 1788 {
1785 if ( v2 >= DECK_SIZE ) 1789 if ( v2 >= DECK_SIZE )
1786 { 1790 {
1787 am_40A198(); 1791 FillPlayerDeck();
1788 v2 = dword_4FABC8; 1792 v2 = dword_4FABC8;
1789 } 1793 }
1790 if ( !playDeck.cardsInUse[v2] ) 1794 if ( !playDeck.cardsInUse[v2] )
1791 { 1795 {
1792 v3 = playDeck.cards_IDs[v2]; 1796 v3 = playDeck.cards_IDs[v2];
1795 ++v2; 1799 ++v2;
1796 dword_4FABC8 = v2; 1800 dword_4FABC8 = v2;
1797 } 1801 }
1798 while ( !v5 ); 1802 while ( !v5 );
1799 1803
1800 ArcomageGame::PlaySound(0x15u); 1804 ArcomageGame::PlaySound(21);
1801 result = GetEmptyCardSlotIndex(v4); 1805 result = GetEmptyCardSlotIndex(v4);
1802 if ( result != -1 ) 1806 if ( result != -1 )
1803 { 1807 {
1804 amuint_4FAA4C = result; 1808 amuint_4FAA4C = result;
1805 am_Players[a1].cards_at_hand[result] = v3; 1809 am_Players[a1].cards_at_hand[result] = v3;
1826 else 1830 else
1827 return i; 1831 return i;
1828 } 1832 }
1829 1833
1830 //----- (0040A346) -------------------------------------------------------- 1834 //----- (0040A346) --------------------------------------------------------
1831 void am_40A346( int player_num ) 1835 void IncreaseResourcesInTurn( int player_num )
1832 { 1836 {
1833 am_Players[player_num].field_38 += dword_4E1878 + am_Players[player_num].field_2C; 1837 am_Players[player_num].resource_bricks += quarry_bonus + am_Players[player_num].quarry_level;
1834 am_Players[player_num].field_3C += dword_4E187C + am_Players[player_num].field_30; 1838 am_Players[player_num].resource_gems += magic_bonus + am_Players[player_num].magic_level;
1835 am_Players[player_num].field_40 += dword_4E1880 + am_Players[player_num].field_34; 1839 am_Players[player_num].resource_beasts += might_bonus + am_Players[player_num].might_level;
1836 } 1840 }
1837 1841
1838 1842
1839 //----- (0040A383) -------------------------------------------------------- 1843 //----- (0040A383) --------------------------------------------------------
1840 void __cdecl am_40A383() 1844 void __cdecl am_40A383()
1850 ArcomageGame_stru1 v10; // [sp+54h] [bp-14h]@7 1854 ArcomageGame_stru1 v10; // [sp+54h] [bp-14h]@7
1851 POINT v11; // [sp+60h] [bp-8h]@4 1855 POINT v11; // [sp+60h] [bp-8h]@4
1852 1856
1853 if ( !pArcomageGame->field_F4 ) 1857 if ( !pArcomageGame->field_F4 )
1854 { 1858 {
1855 if ( am_Players[0].field_20 != 1 || am_Players[1].field_20 != 1 ) 1859 if ( am_Players[0].IsHisTurn != 1 || am_Players[1].IsHisTurn != 1 )
1856 { 1860 {
1857 ++amuint_4FAA6C; 1861 ++current_player_num;
1858 am_byte_4FAA75 = 1; 1862 am_byte_4FAA75 = 1;
1859 if ( amuint_4FAA6C >= 2 ) 1863 if ( current_player_num >= 2 )
1860 amuint_4FAA6C = 0; 1864 current_player_num = 0;
1861 } 1865 }
1862 else 1866 else
1863 { 1867 {
1864 //nullsub_1(); 1868 //nullsub_1();
1865 v11.x = 0; 1869 v11.x = 0;
1868 v0 = 0; 1872 v0 = 0;
1869 v11.y = 200; 1873 v11.y = 200;
1870 v11.x = 320 - 12 * v0 / 2; 1874 v11.x = 320 - 12 * v0 / 2;
1871 pPrimaryWindow_draws_text(-1, Dest, &v11); 1875 pPrimaryWindow_draws_text(-1, Dest, &v11);
1872 am_byte_4FAA75 = 1; 1876 am_byte_4FAA75 = 1;
1873 v1 = amuint_4FAA6C + 1; 1877 v1 = current_player_num + 1;
1874 v3 = __OFSUB__(amuint_4FAA6C + 1, 2); 1878 v3 = __OFSUB__(current_player_num + 1, 2);
1875 v2 = amuint_4FAA6C++ - 1 < 0; 1879 v2 = current_player_num++ - 1 < 0;
1876 if ( !(v2 ^ v3) ) 1880 if ( !(v2 ^ v3) )
1877 { 1881 {
1878 v1 = 0; 1882 v1 = 0;
1879 amuint_4FAA6C = 0; 1883 current_player_num = 0;
1880 } 1884 }
1881 inv_strcpy(am_Players[v1].pPlayerName, Dest); 1885 inv_strcpy(am_Players[v1].pPlayerName, Dest);
1882 v4 = 0; 1886 v4 = 0;
1883 v11.y = 260; 1887 v11.y = 260;
1884 v11.x = 320 - 12 * v4 / 2; 1888 v11.x = 320 - 12 * v4 / 2;
1885 pPrimaryWindow_draws_text(-1, Dest, &v11); 1889 pPrimaryWindow_draws_text(-1, Dest, &v11);
1886 v6.left = 0; 1890 /* v6.left = 0;
1887 v6.right = 640; 1891 v6.right = 640;
1888 v6.top = 0; 1892 v6.top = 0;
1889 v6.bottom = 480; 1893 v6.bottom = 480;*/
1890 //nullsub_1(); 1894 //nullsub_1();
1891 CallRenderPresent(); 1895 CallRenderPresent();
1892 //nullsub_1(); 1896 //nullsub_1();
1893 while ( 1 ) 1897 while ( 1 )
1894 { 1898 {
1911 } 1915 }
1912 } 1916 }
1913 pArcomageGame->field_F4 = 1; 1917 pArcomageGame->field_F4 = 1;
1914 byte_4FAA74 = 1; 1918 byte_4FAA74 = 1;
1915 LABEL_13: 1919 LABEL_13:
1916 v11.x = 0; 1920 /* v11.x = 0;
1917 v11.y = 0; 1921 v11.y = 0;
1918 v6.left = 0; 1922 v6.left = 0;
1919 v6.right = 640; 1923 v6.right = 640;
1920 v6.top = 0; 1924 v6.top = 0;
1921 v6.bottom = 480; 1925 v6.bottom = 480;*/
1922 //nullsub_1(); 1926 //nullsub_1();
1923 CallRenderPresent(); 1927 CallRenderPresent();
1924 } 1928 }
1925 } 1929 }
1926 } 1930 }
1927 1931
1928 1932
1929 //----- (0040A514) -------------------------------------------------------- 1933 //----- (0040A514) --------------------------------------------------------
1930 bool am_40A514() 1934 bool IsGameOver()
1931 { 1935 {
1932 bool result; // eax@1 1936 bool result; // eax@1
1933 1937
1934 result = false; 1938 result = false;
1935 for(int i=0; i<2; ++i) 1939 for(int i=0; i<2; ++i)
1936 { 1940 {
1937 if ( am_Players[i].field_24 <= 0 ) 1941 if ( am_Players[i].tower_height <= 0 )
1938 result = true; 1942 result = true;
1939 if ( am_Players[i].field_24 >= dword_4E1884 ) 1943 if ( am_Players[i].tower_height >= max_tower_height )
1940 result = true; 1944 result = true;
1941 if ( am_Players[i].field_38 >= dword_4E1888 1945 if ( am_Players[i].resource_bricks >= max_resources_amount
1942 || am_Players[i].field_3C >= dword_4E1888 1946 || am_Players[i].resource_gems >= max_resources_amount
1943 || am_Players[i].field_40 >= dword_4E1888 ) 1947 || am_Players[i].resource_beasts >= max_resources_amount )
1944 result = true; 1948 result = true;
1945 } 1949 }
1946 1950
1947 if ( result ) 1951 if ( result )
1948 byte_4FAA2C = 1; 1952 byte_4FAA2C = 1;
1949 return result; 1953 return result;
1950 } 1954 }
1951 // 4E1884: using guessed type int dword_4E1884; 1955
1952 // 4E1888: using guessed type int dword_4E1888;
1953 // 4FAA2C: using guessed type char byte_4FAA2C;
1954 1956
1955 //----- (0040A560) -------------------------------------------------------- 1957 //----- (0040A560) --------------------------------------------------------
1956 char am_40A560(unsigned int _this) 1958 char am_40A560(unsigned int _this)
1957 { 1959 {
1958 int v1; // ebp@0 1960 int v1; // ebp@0
2013 byte_4FAA74 = 1; 2015 byte_4FAA74 = 1;
2014 v16 = 1; 2016 v16 = 1;
2015 pArcomageGame->field_F4 = 1; 2017 pArcomageGame->field_F4 = 1;
2016 break; 2018 break;
2017 } 2019 }
2018 v4 = amuint_4FAA6C; 2020 v4 = current_player_num;
2019 if (am_Players[amuint_4FAA6C].field_20 != 1 && !byte_4FAA00 && !byte_4FAA2E && !byte_4FAA2D ) 2021 if (am_Players[current_player_num].IsHisTurn != 1 && !byte_4FAA00 && !byte_4FAA2E && !byte_4FAA2D )
2020 { 2022 {
2021 if ( am_byte_4FAA75 ) 2023 if ( am_byte_4FAA75 )
2022 am_byte_4FAA76 = 1; 2024 am_byte_4FAA76 = 1;
2023 am_408BB4(amuint_4FAA6C); 2025 am_408BB4(current_player_num);
2024 v4 = amuint_4FAA6C; 2026 v4 = current_player_num;
2025 byte_4FAA2E = 1; 2027 byte_4FAA2E = 1;
2026 } 2028 }
2027 if ( amuint_4FAA4C != -1 && amuint_4FAA38 > 10 ) 2029 if ( amuint_4FAA4C != -1 && amuint_4FAA38 > 10 )
2028 amuint_4FAA38 = 10; 2030 amuint_4FAA38 = 10;
2029 if ( byte_4FAA2E || byte_4FAA2D ||am_Players[v4].field_20 != 1 ) 2031 if ( byte_4FAA2E || byte_4FAA2D ||am_Players[v4].IsHisTurn != 1 )
2030 { 2032 {
2031 pArcomageGame->field_F6 = 1; 2033 pArcomageGame->field_F6 = 1;
2032 if ( byte_4FAA2D ) 2034 if ( byte_4FAA2D )
2033 { 2035 {
2034 --amuint_4FAA38; 2036 --amuint_4FAA38;
2087 } 2089 }
2088 else 2090 else
2089 { 2091 {
2090 if ( a2.field_0 == 7 ) 2092 if ( a2.field_0 == 7 )
2091 { 2093 {
2092 if ( am_40BE0E(a1, dword_4FABBC) ) 2094 if ( PlayCard(a1, dword_4FABBC) )
2093 { 2095 {
2094 byte_4FAA2E = 1; 2096 byte_4FAA2E = 1;
2095 if ( am_byte_4FAA75 ) 2097 if ( am_byte_4FAA75 )
2096 am_byte_4FAA76 = 1; 2098 am_byte_4FAA76 = 1;
2097 } 2099 }
2146 dword_4FABB8 = am_40BB67(a1); 2148 dword_4FABB8 = am_40BB67(a1);
2147 pArcomageGame->field_F6 = 1; 2149 pArcomageGame->field_F6 = 1;
2148 }*/ 2150 }*/
2149 if ( pArcomageGame->field_F6 ) 2151 if ( pArcomageGame->field_F6 )
2150 { 2152 {
2151 am_blts(v13); 2153 DrawGameUI(v13);
2152 DoBlt_Copy(pArcomageGame->pBackgroundPixels); 2154 DoBlt_Copy(pArcomageGame->pBackgroundPixels);
2153 pArcomageGame->field_F6 = 0; 2155 pArcomageGame->field_F6 = 0;
2154 } 2156 }
2155 if ( pArcomageGame->field_F9 ) 2157 if ( pArcomageGame->field_F9 )
2156 { 2158 {
2161 pSrcXYZW.top = 0; 2163 pSrcXYZW.top = 0;
2162 pSrcXYZW.bottom = 480; 2164 pSrcXYZW.bottom = 480;
2163 am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1); 2165 am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1);
2164 Blt_Copy(&pSrcXYZW, &pTargetXY, 2); 2166 Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
2165 am_EndScene(); 2167 am_EndScene();
2166 am_blts(v13); 2168 DrawGameUI(v13);
2167 pRenderer->Present(); 2169 pRenderer->Present();
2168 pArcomageGame->field_F9 = 0; 2170 pArcomageGame->field_F9 = 0;
2169 } 2171 }
2170 } 2172 }
2171 while ( !v16 ); 2173 while ( !v16 );
2172 return dword_4FAA68 > 0; 2174 return dword_4FAA68 > 0;
2173 } 2175 }
2174 2176
2175 2177
2176 //----- (0040A9AF) -------------------------------------------------------- 2178 //----- (0040A9AF) --------------------------------------------------------
2177 void am_blts( int a1 ) 2179 void DrawGameUI( int a1 )
2178 { 2180 {
2179 2181
2180 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); 2182 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
2181 am_chroma_blts(); 2183 DrawRectanglesForText();
2182 am_EndScene(); 2184 am_EndScene();
2185
2183 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); 2186 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
2184 am_40B4B9(); 2187 am_40B4B9();
2185 am_chroma_and_copy_blts(); 2188 DrawPlayersTowers();
2186 am_chroma_blt(); 2189 DrawPlayersWall();
2187 am_DrawUI(); 2190 DrawPlayersText();
2188 am_EndScene(); 2191 am_EndScene();
2192
2189 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); 2193 am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
2190 am_40B76F(a1); 2194 am_40B76F(a1);
2191 2195
2192 for( int i=0; i<10; ++i) 2196 for( int i=0; i<10; ++i)
2193 { 2197 {
2194 if (array_4FABD0[i].field_0) 2198 if (array_4FABD0[i].field_0)
2195 array_4FABD0[i].field_40->_40E133(); 2199 array_4FABD0[i].field_40->_40E133();
2196 } 2200 }
2197 dword_4FABBC = am_40BB67(amuint_4FAA6C); 2201 dword_4FABBC = am_40BB67(current_player_num);
2198 am_40AA4E(); 2202 am_40AA4E();
2199 am_EndScene(); 2203 am_EndScene();
2200 } 2204 }
2201 2205
2202 //----- (0040AA4E) -------------------------------------------------------- 2206 //----- (0040AA4E) --------------------------------------------------------
2241 } 2245 }
2242 2246
2243 } 2247 }
2244 2248
2245 //----- (0040AB0A) -------------------------------------------------------- 2249 //----- (0040AB0A) --------------------------------------------------------
2246 void __cdecl am_chroma_blts() 2250 void DrawRectanglesForText()
2247 { 2251 {
2248 2252
2249 RECT pSrcRect; // [sp+Ch] [bp-18h]@1 2253 RECT pSrcRect; // [sp+Ch] [bp-18h]@1
2250 POINT pTargetXY; // [sp+1Ch] [bp-8h]@1 2254 POINT pTargetXY; // [sp+1Ch] [bp-8h]@1
2251 2255 //resources rectangles
2252 pSrcRect.top = 0; 2256 pSrcRect.top = 0;
2253 pSrcRect.left = 765; 2257 pSrcRect.left = 765;
2254 pSrcRect.right = 843; 2258 pSrcRect.right = 843;
2255 pSrcRect.bottom = 216; 2259 pSrcRect.bottom = 216;
2256 2260
2260 2264
2261 pTargetXY.x = 555; 2265 pTargetXY.x = 555;
2262 pTargetXY.y = 56; 2266 pTargetXY.y = 56;
2263 Blt_Copy(&pSrcRect, &pTargetXY, 2); 2267 Blt_Copy(&pSrcRect, &pTargetXY, 2);
2264 2268
2269 //players name rectangle
2265 pSrcRect.left = 283; 2270 pSrcRect.left = 283;
2266 pSrcRect.right = 361; 2271 pSrcRect.right = 361;
2267 pSrcRect.top = 166; 2272 pSrcRect.top = 166;
2268 pSrcRect.bottom = 190; 2273 pSrcRect.bottom = 190;
2269 pTargetXY.x = 8; 2274 pTargetXY.x = 8;
2272 2277
2273 pTargetXY.x = 555; 2278 pTargetXY.x = 555;
2274 pTargetXY.y = 13; 2279 pTargetXY.y = 13;
2275 Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); 2280 Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
2276 2281
2282 //tower heigth rectangle
2277 pSrcRect.left = 234; 2283 pSrcRect.left = 234;
2278 pSrcRect.right = 283; 2284 pSrcRect.right = 283;
2279 pSrcRect.top = 166; 2285 pSrcRect.top = 166;
2280 pSrcRect.bottom = 190; 2286 pSrcRect.bottom = 190;
2281 pTargetXY.x = 100; 2287 pTargetXY.x = 100;
2282 pTargetXY.y = 296; 2288 pTargetXY.y = 296;
2283 Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); 2289 Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
2284 2290
2285
2286 pTargetXY.x = 492; 2291 pTargetXY.x = 492;
2287 pTargetXY.y = 296; 2292 pTargetXY.y = 296;
2288 Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); 2293 Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
2289 2294
2290 2295 //wall heigth rectangle
2291 pSrcRect.left = 192; 2296 pSrcRect.left = 192;
2292 pSrcRect.right = 234; 2297 pSrcRect.right = 234;
2293 pSrcRect.top = 166; 2298 pSrcRect.top = 166;
2294 pSrcRect.bottom = 190; 2299 pSrcRect.bottom = 190;
2295 pTargetXY.x = 168; 2300 pTargetXY.x = 168;
2300 pTargetXY.y = 296; 2305 pTargetXY.y = 296;
2301 Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2); 2306 Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
2302 } 2307 }
2303 2308
2304 //----- (0040AC5F) -------------------------------------------------------- 2309 //----- (0040AC5F) --------------------------------------------------------
2305 void __cdecl am_DrawUI() 2310 void DrawPlayersText()
2306 { 2311 {
2307 int v0; // ecx@7 2312
2308 int v1; // ecx@9 2313 int res_value; // ecx@18
2309 int v2; // eax@11 2314 char text_buff[32]; // [sp+Ch] [bp-28h]@2
2310 int v3; // ecx@12 2315 POINT text_position; // [sp+2Ch] [bp-8h]@2
2311 int v4; // eax@14
2312 int v5; // ecx@14
2313 int v6; // eax@16
2314 int v7; // ecx@16
2315 int v8; // eax@18
2316 int v9; // ecx@18
2317 int v10; // eax@20
2318 char Dest[32]; // [sp+Ch] [bp-28h]@2
2319 POINT v12; // [sp+2Ch] [bp-8h]@2
2320 2316
2321 if ( am_byte_4FAA77 ) 2317 if ( am_byte_4FAA77 )
2322 { 2318 {
2323 inv_strcpy(pGlobalTXT_LocalizationStrings[266], Dest);// DISCARD A CARD 2319 inv_strcpy(pGlobalTXT_LocalizationStrings[266], text_buff);// DISCARD A CARD
2324 v12.x = 320 - pArcomageGame->pfntArrus->GetLineWidth(Dest) / 2; 2320 text_position.x = 320 - pArcomageGame->pfntArrus->GetLineWidth(text_buff) / 2;
2325 v12.y = 306; 2321 text_position.y = 306;
2326 pPrimaryWindow_draws_text(-1, Dest, &v12); 2322 pPrimaryWindow_draws_text(-1, text_buff, &text_position);
2327 } 2323 }
2328 inv_strcpy(am_Players[0].pPlayerName, Dest); 2324 inv_strcpy(am_Players[0].pPlayerName, text_buff);
2329 if ( !amuint_4FAA6C ) 2325 if ( !current_player_num )
2330 inv_strcat("***", Dest); 2326 inv_strcat("***", text_buff);
2331 v12.x = 47 - pArcomageGame->pfntComic->GetLineWidth(Dest) / 2; 2327 text_position.x = 47 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2;
2332 v12.y = 21; 2328 text_position.y = 21;
2333 pPrimaryWindow_draws_text(-1, Dest, &v12); 2329 pPrimaryWindow_draws_text(-1, text_buff, &text_position);
2334 2330
2335 inv_strcpy(am_Players[1].pPlayerName, Dest); 2331 inv_strcpy(am_Players[1].pPlayerName, text_buff);
2336 if ( amuint_4FAA6C == 1 ) 2332 if ( current_player_num == 1 )
2337 inv_strcat("***", Dest); 2333 inv_strcat("***", text_buff);
2338 v12.x = 595 - pArcomageGame->pfntComic->GetLineWidth(Dest) / 2; 2334 text_position.x = 595 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2;
2339 v12.y = 21; 2335 text_position.y = 21;
2340 pPrimaryWindow_draws_text(-1, Dest, &v12); 2336 pPrimaryWindow_draws_text(-1, text_buff, &text_position);
2341 2337
2342 intToString(am_Players[0].field_24, Dest); 2338 intToString(am_Players[0].tower_height, text_buff);
2343 v12.x = 123 - pArcomageGame->pfntComic->GetLineWidth(Dest) / 2; 2339 text_position.x = 123 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2;
2344 v12.y = 305; 2340 text_position.y = 305;
2345 pPrimaryWindow_draws_text(-1, Dest, &v12); 2341 pPrimaryWindow_draws_text(-1, text_buff, &text_position);
2346 2342
2347 intToString(am_Players[1].field_24, Dest); 2343 intToString(am_Players[1].tower_height, text_buff);
2348 v12.x = 515 - pArcomageGame->pfntComic->GetLineWidth(Dest) / 2; 2344 text_position.x = 515 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2;
2349 v12.y = 305; 2345 text_position.y = 305;
2350 pPrimaryWindow_draws_text(-1, Dest, &v12); 2346 pPrimaryWindow_draws_text(-1, text_buff, &text_position);
2351 2347
2352 intToString(am_Players[0].field_28, Dest); 2348 intToString(am_Players[0].wall_height, text_buff);
2353 v12.x = 188 - pArcomageGame->pfntComic->GetLineWidth(Dest) / 2; 2349 text_position.x = 188 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2;
2354 v12.y = 305; 2350 text_position.y = 305;
2355 pPrimaryWindow_draws_text(-1, Dest, &v12); 2351 pPrimaryWindow_draws_text(-1, text_buff, &text_position);
2356 2352
2357 intToString(am_Players[1].field_28, Dest); 2353 intToString(am_Players[1].wall_height, text_buff);
2358 v12.x = 451 - pArcomageGame->pfntComic->GetLineWidth(Dest) / 2; 2354 text_position.x = 451 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2;
2359 v12.y = 305; 2355 text_position.y = 305;
2360 pPrimaryWindow_draws_text(-1, Dest, &v12); 2356 pPrimaryWindow_draws_text(-1, text_buff, &text_position);
2361 2357
2362 v0 = am_Players[0].field_2C; 2358 res_value = am_Players[0].quarry_level;
2363 if ( byte_4E185E ) 2359 if ( byte_4E185E )
2364 v0 = dword_4E1878 + am_Players[0].field_2C; 2360 res_value =am_Players[0].quarry_level + quarry_bonus;
2365 intToString(v0, Dest); 2361 intToString(res_value, text_buff);
2366 v12.x = 14 - 6 * 0 / 2; 2362 text_position.x = 14;// - 6 * 0 / 2;
2367 v12.y = 92; 2363 text_position.y = 92;
2368 am_40B102(-1, Dest, &v12); 2364 DrawPlayerLevels(-1, text_buff, &text_position);
2369 2365
2370 v1 = am_Players[1].field_2C; 2366 res_value = am_Players[1].quarry_level;
2371 if ( byte_4E185E ) 2367 if ( byte_4E185E )
2372 v1 = dword_4E1878 + am_Players[1].field_2C; 2368 res_value = am_Players[1].quarry_level + quarry_bonus;
2373 intToString(v1, Dest); 2369 intToString(res_value, text_buff);
2374 v2 = 0; 2370 // v2 = 0;
2375 v12.y = 92; 2371 text_position.y = 92;
2376 v12.x = 561 - 6 * v2 / 2; 2372 text_position.x = 561; //- 6 * v2 / 2;
2377 am_40B102(-1, Dest, &v12); 2373 DrawPlayerLevels(-1, text_buff, &text_position);
2378 2374
2375 res_value = am_Players[0].magic_level;
2379 if ( byte_4E185E ) 2376 if ( byte_4E185E )
2380 v3 = am_Players[0].field_30 + dword_4E187C; 2377 res_value = am_Players[0].magic_level + magic_bonus;
2381 else 2378 intToString(res_value, text_buff);
2382 v3 = am_Players[0].field_30; 2379 // v4 = 0;
2383 intToString(v3, Dest); 2380 text_position.y = 164;
2384 v4 = 0; 2381 text_position.x = 14; //- 6 * v4 / 2;
2385 v12.y = 164; 2382 DrawPlayerLevels(-1, text_buff, &text_position);
2386 v12.x = 14 - 6 * v4 / 2; 2383
2387 am_40B102(-1, Dest, &v12); 2384 res_value = am_Players[1].magic_level;
2388
2389 v5 = am_Players[1].field_30;
2390 if ( byte_4E185E ) 2385 if ( byte_4E185E )
2391 v5 = dword_4E187C + am_Players[1].field_30; 2386 res_value = am_Players[1].magic_level+magic_bonus;
2392 intToString(v5, Dest); 2387 intToString(res_value, text_buff);
2393 v6 = 0; 2388 // v6 = 0;
2394 v12.y = 164; 2389 text_position.y = 164;
2395 v12.x = 561 - 6 * v6 / 2; 2390 text_position.x = 561; //- 6 * v6 / 2;
2396 am_40B102(-1, Dest, &v12); 2391 DrawPlayerLevels(-1, text_buff, &text_position);
2397 2392
2398 v7 = am_Players[0].field_34; 2393 res_value = am_Players[0].might_level;
2399 if ( byte_4E185E ) 2394 if ( byte_4E185E )
2400 v7 = dword_4E1880 + am_Players[0].field_34; 2395 res_value = am_Players[0].might_level + might_bonus;
2401 intToString(v7, Dest); 2396 intToString(res_value, text_buff);
2402 v8 = 0; 2397 // v8 = 0;
2403 v12.y = 236; 2398 text_position.y = 236;
2404 v12.x = 14 - 6 * v8 / 2; 2399 text_position.x = 14;// - 6 * v8 / 2;
2405 am_40B102(-1, Dest, &v12); 2400 DrawPlayerLevels(-1, text_buff, &text_position);
2406 2401
2407 v9 = am_Players[1].field_34; 2402 res_value = am_Players[1].might_level;
2408 if ( byte_4E185E ) 2403 if ( byte_4E185E )
2409 v9 = dword_4E1880 + am_Players[1].field_34; 2404 res_value = am_Players[1].might_level + might_bonus;
2410 intToString(v9, Dest); 2405 intToString(res_value, text_buff);
2411 v10 = 0; 2406 // v10 = 0;
2412 v12.y = 236; 2407 text_position.y = 236;
2413 v12.x = 561 - 6 * v10 / 2; 2408 text_position.x = 561;// - 6 * v10 / 2;
2414 am_40B102(-1, Dest, &v12); 2409 DrawPlayerLevels(-1, text_buff, &text_position);
2415 2410
2416 intToString(am_Players[0].field_38, Dest); 2411 intToString(am_Players[0].resource_bricks, text_buff);
2417 v12.y = 114; 2412 text_position.y = 114;
2418 v12.x = 10; 2413 text_position.x = 10;
2419 am_40B17E(-1, Dest, &v12); 2414 DrawBricksCount(-1, text_buff, &text_position);
2420 2415
2421 intToString(am_Players[1].field_38, Dest); 2416 intToString(am_Players[1].resource_bricks, text_buff);
2422 v12.x = 557; 2417 text_position.x = 557;
2423 v12.y = 114; 2418 text_position.y = 114;
2424 am_40B17E(-1, Dest, &v12); 2419 DrawBricksCount(-1, text_buff, &text_position);
2425 2420
2426 intToString(am_Players[0].field_3C, Dest); 2421 intToString(am_Players[0].resource_gems, text_buff);
2427 v12.x = 10; 2422 text_position.x = 10;
2428 v12.y = 186; 2423 text_position.y = 186;
2429 am_40B1F3(-1, Dest, &v12); 2424 DrawGemsCount(-1, text_buff, &text_position);
2430 2425
2431 intToString(am_Players[1].field_3C, Dest); 2426 intToString(am_Players[1].resource_gems, text_buff);
2432 v12.x = 557; 2427 text_position.x = 557;
2433 v12.y = 186; 2428 text_position.y = 186;
2434 am_40B1F3(-1, Dest, &v12); 2429 DrawGemsCount(-1, text_buff, &text_position);
2435 2430
2436 intToString(am_Players[0].field_40, Dest); 2431 intToString(am_Players[0].resource_beasts, text_buff);
2437 v12.x = 10; 2432 text_position.x = 10;
2438 v12.y = 258; 2433 text_position.y = 258;
2439 am_40B268(-1, Dest, &v12); 2434 DrawBeastsCount(-1, text_buff, &text_position);
2440 2435
2441 intToString(am_Players[1].field_40, Dest); 2436 intToString(am_Players[1].resource_beasts, text_buff);
2442 v12.x = 557; 2437 text_position.x = 557;
2443 v12.y = 258; 2438 text_position.y = 258;
2444 am_40B268(-1, Dest, &v12); 2439 DrawBeastsCount(-1, text_buff, &text_position);
2445 } 2440 }
2446 // 4E185E: using guessed type char byte_4E185E; 2441
2447 // 4E1878: using guessed type int dword_4E1878;
2448 // 4E187C: using guessed type int dword_4E187C;
2449 // 4E1880: using guessed type int dword_4E1880;
2450 // 4FAA77: using guessed type char am_byte_4FAA77;
2451 2442
2452 //----- (0040B102) -------------------------------------------------------- 2443 //----- (0040B102) --------------------------------------------------------
2453 void am_40B102( int a1, char *text, POINT *pXY ) 2444 void DrawPlayerLevels( int a1, char *text, POINT *pXY )
2454 { 2445 {
2455 char *v3; // esi@1 2446 char *v3; // esi@1
2456 unsigned char test_char; // bl@2 2447 unsigned char test_char; // bl@2
2457 int v7; // eax@3 2448 int v7; // eax@3
2458 RECT pSrcRect; 2449 RECT pSrcRect;
2480 while ( test_char!= 0 ); 2471 while ( test_char!= 0 );
2481 am_EndScene(); 2472 am_EndScene();
2482 } 2473 }
2483 2474
2484 //----- (0040B17E) -------------------------------------------------------- 2475 //----- (0040B17E) --------------------------------------------------------
2485 void am_40B17E( int a1, char* text, POINT *pXY ) 2476 void DrawBricksCount( int a1, char* text, POINT *pXY )
2486 { 2477 {
2487 2478
2488 char *v3; // esi@1 2479 char *v3; // esi@1
2489 unsigned char test_char; // bl@2 2480 unsigned char test_char; // bl@2
2490 int v7; // eax@3 2481 int v7; // eax@3
2500 test_char = *v3; 2491 test_char = *v3;
2501 ++v3; 2492 ++v3;
2502 if ( test_char ) 2493 if ( test_char )
2503 { 2494 {
2504 v7 = 13 * test_char; 2495 v7 = 13 * test_char;
2505 pSrcRect.right = v7 - 370; 2496 pSrcRect.left = v7 - 370;
2506 pSrcRect.left = v7 - 357; 2497 pSrcRect.right = v7 - 357;
2507 pSrcRect.top = 128; 2498 pSrcRect.top = 128;
2508 pSrcRect.bottom = 138; 2499 pSrcRect.bottom = 138;
2509 Blt_Copy(&pSrcRect, &pTargetPoint, 2); 2500 Blt_Copy(&pSrcRect, &pTargetPoint, 2);
2510 pTargetPoint.x += 13; 2501 pTargetPoint.x += 13;
2511 } 2502 }
2514 am_EndScene(); 2505 am_EndScene();
2515 2506
2516 } 2507 }
2517 2508
2518 //----- (0040B1F3) -------------------------------------------------------- 2509 //----- (0040B1F3) --------------------------------------------------------
2519 void am_40B1F3( int a1, char* text, POINT* pXY ) 2510 void DrawGemsCount( int a1, char* text, POINT* pXY )
2520 { 2511 {
2521 2512
2522 char *v3; // esi@1 2513 char *v3; // esi@1
2523 unsigned char test_char; // bl@2 2514 unsigned char test_char; // bl@2
2524 int v7; // eax@3 2515 int v7; // eax@3
2534 test_char = *v3; 2525 test_char = *v3;
2535 ++v3; 2526 ++v3;
2536 if ( test_char ) 2527 if ( test_char )
2537 { 2528 {
2538 v7 = 13 * test_char; 2529 v7 = 13 * test_char;
2539 pSrcRect.right = v7 - 370; 2530 pSrcRect.left = v7 - 370;
2540 pSrcRect.left = v7 - 357; 2531 pSrcRect.right = v7 - 357;
2541 pSrcRect.top = 138; 2532 pSrcRect.top = 138;
2542 pSrcRect.bottom = 148; 2533 pSrcRect.bottom = 148;
2543 Blt_Copy(&pSrcRect, &pTargetPoint, 2); 2534 Blt_Copy(&pSrcRect, &pTargetPoint, 2);
2544 pTargetPoint.x += 13; 2535 pTargetPoint.x += 13;
2545 } 2536 }
2548 am_EndScene(); 2539 am_EndScene();
2549 2540
2550 } 2541 }
2551 2542
2552 //----- (0040B268) -------------------------------------------------------- 2543 //----- (0040B268) --------------------------------------------------------
2553 void am_40B268( int a1, char *text, POINT *pXY ) 2544 void DrawBeastsCount( int a1, char *text, POINT *pXY )
2554 { 2545 {
2555 2546
2556 char *v3; // esi@1 2547 char *v3; // esi@1
2557 unsigned char test_char; // bl@2 2548 unsigned char test_char; // bl@2
2558 int v7; // eax@3 2549 int v7; // eax@3
2568 test_char = *v3; 2559 test_char = *v3;
2569 ++v3; 2560 ++v3;
2570 if ( test_char ) 2561 if ( test_char )
2571 { 2562 {
2572 v7 = 13 * test_char; 2563 v7 = 13 * test_char;
2573 pSrcRect.right = v7 - 370; 2564 pSrcRect.left = v7 - 370;
2574 pSrcRect.left = v7 - 357; 2565 pSrcRect.right = v7 - 357;
2575 pSrcRect.top = 148; 2566 pSrcRect.top = 148;
2576 pSrcRect.bottom = 158; 2567 pSrcRect.bottom = 158;
2577 Blt_Copy(&pSrcRect, &pTargetPoint, 2); 2568 Blt_Copy(&pSrcRect, &pTargetPoint, 2);
2578 pTargetPoint.x += 13; 2569 pTargetPoint.x += 13;
2579 } 2570 }
2582 am_EndScene(); 2573 am_EndScene();
2583 2574
2584 } 2575 }
2585 2576
2586 //----- (0040B2DD) -------------------------------------------------------- 2577 //----- (0040B2DD) --------------------------------------------------------
2587 void __cdecl am_chroma_and_copy_blts() 2578 void DrawPlayersTowers()
2588 { 2579 {
2589 2580 int tower_height; // eax@1
2590 int v0; // eax@1 2581 int tower_top; // esi@3
2591 int v1; // esi@3
2592 int v2; // eax@3
2593 int v3; // eax@3
2594 int v4; // esi@5
2595 int v5; // eax@5
2596 RECT pSrcXYZW; // [sp+0h] [bp-18h]@3 2582 RECT pSrcXYZW; // [sp+0h] [bp-18h]@3
2597 POINT pTargetXY; // [sp+10h] [bp-8h]@3 2583 POINT pTargetXY; // [sp+10h] [bp-8h]@3
2598 2584
2599 v0= am_Players[0].field_24; 2585 tower_height= am_Players[0].tower_height;
2600 if ( am_Players[0].field_24 > dword_4E1884 ) 2586 if ( am_Players[0].tower_height > max_tower_height )
2601 v0 = dword_4E1884; 2587 tower_height = max_tower_height;
2602 pSrcXYZW.top = 0; 2588 pSrcXYZW.top = 0;
2603 pSrcXYZW.left = 892; 2589 pSrcXYZW.left = 892;
2604 pSrcXYZW.right = 937; 2590 pSrcXYZW.right = 937;
2605 v1 = 200 * v0 / dword_4E1884; 2591 tower_top = 200 * tower_height / max_tower_height;
2606 pSrcXYZW.bottom = v1; 2592 pSrcXYZW.bottom = tower_top;
2607 pTargetXY.x = 102; 2593 pTargetXY.x = 102;
2608 pTargetXY.y = 297 - v1; 2594 pTargetXY.y = 297 - tower_top;
2609 Blt_Copy(&pSrcXYZW, &pTargetXY, 2); 2595 Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
2610 2596
2611 pSrcXYZW.top = 0; 2597 pSrcXYZW.top = 0;
2612 pSrcXYZW.left = 384; 2598 pSrcXYZW.left = 384;
2613 pSrcXYZW.right = 452; 2599 pSrcXYZW.right = 452;
2614 pSrcXYZW.bottom = 94; 2600 pSrcXYZW.bottom = 94;
2615 pTargetXY.y = 203 - v1; 2601 pTargetXY.y = 203 - tower_top;
2616 pTargetXY.x = 91; 2602 pTargetXY.x = 91;
2617 Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2); 2603 Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
2618 2604
2619 v3 = am_Players[1].field_24; 2605
2620 if (am_Players[1].field_24 > dword_4E1884 ) 2606 tower_height = am_Players[1].tower_height;
2621 v3 = dword_4E1884; 2607 if (am_Players[1].tower_height > max_tower_height )
2622 pSrcXYZW.top = 0; 2608 tower_height = max_tower_height;
2623 pSrcXYZW.left = 892; 2609 tower_top = 200 * tower_height / max_tower_height;
2624 pSrcXYZW.right = 937; 2610 pSrcXYZW.top = 0;
2625 v4 = 200 * v3 / dword_4E1884; 2611 pSrcXYZW.left = 892;
2626 pSrcXYZW.bottom = v4; 2612 pSrcXYZW.right = 937;
2613 pSrcXYZW.bottom = tower_top;
2614
2627 pTargetXY.x = 494; 2615 pTargetXY.x = 494;
2628 pTargetXY.y = 297 - v4; 2616 pTargetXY.y = 297 - tower_top;
2629 Blt_Copy(&pSrcXYZW, &pTargetXY, 2); 2617 Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
2630 2618 //draw tower up cone
2631 pSrcXYZW.left = 384; 2619 pSrcXYZW.left = 384;
2632 pSrcXYZW.right = 452; 2620 pSrcXYZW.right = 452;
2633 pSrcXYZW.top = 94; 2621 pSrcXYZW.top = 94;
2634 pSrcXYZW.bottom = 188; 2622 pSrcXYZW.bottom = 188;
2623
2635 pTargetXY.x = 483; 2624 pTargetXY.x = 483;
2636 pTargetXY.y = 203 - v4; 2625 pTargetXY.y = 203 - tower_top;
2637 Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2); 2626 Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
2638 2627
2639 } 2628 }
2640 // 4E1884: using guessed type int dword_4E1884; 2629 // 4E1884: using guessed type int dword_4E1884;
2641 2630
2642 //----- (0040B400) -------------------------------------------------------- 2631 //----- (0040B400) --------------------------------------------------------
2643 void __cdecl am_chroma_blt() 2632 void DrawPlayersWall()
2644 { 2633 {
2645 int v0; // eax@1 2634 int v0; // eax@1
2646 int v1; // eax@4 2635 int v1; // eax@4
2647 LONG v2; // ecx@4 2636 LONG v2; // ecx@4
2648 int v3; // eax@5 2637 int v3; // eax@5
2649 int v4; // eax@8 2638 int v4; // eax@8
2650 LONG v5; // esi@8 2639 LONG v5; // esi@8
2651 RECT pSrcXYZW; // [sp+4h] [bp-18h]@4 2640 RECT pSrcXYZW; // [sp+4h] [bp-18h]@4
2652 POINT pTargetXY; // [sp+14h] [bp-8h]@4 2641 POINT pTargetXY; // [sp+14h] [bp-8h]@4
2653 2642
2654 v0 = am_Players[0].field_28; 2643 v0 = am_Players[0].wall_height;
2655 if ( am_Players[0].field_28 <= 100 ) 2644 if ( am_Players[0].wall_height <= 100 )
2656 { 2645 {
2657 if ( am_Players[0].field_28 <= 0 ) 2646 if ( am_Players[0].wall_height <= 0 )
2658 goto LABEL_5; 2647 goto LABEL_5;
2659 } 2648 }
2660 else 2649 else
2661 { 2650 {
2662 v0 = 100; 2651 v0 = 100;
2669 pTargetXY.x = 177; 2658 pTargetXY.x = 177;
2670 pTargetXY.y = 297 - v1; 2659 pTargetXY.y = 297 - v1;
2671 Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2); 2660 Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
2672 2661
2673 LABEL_5: 2662 LABEL_5:
2674 v3 = am_Players[1].field_28; 2663 v3 = am_Players[1].wall_height;
2675 if ( am_Players[1].field_28 <= 100 ) 2664 if ( am_Players[1].wall_height <= 100 )
2676 { 2665 {
2677 if ( am_Players[1].field_28 <= 0 ) 2666 if ( am_Players[1].wall_height <= 0 )
2678 return; 2667 return;
2679 } 2668 }
2680 else 2669 else
2681 { 2670 {
2682 v3 = 100; 2671 v3 = 100;
3158 result = -1; 3147 result = -1;
3159 //v3 = 188 * a1; 3148 //v3 = 188 * a1;
3160 player_num = a1; 3149 player_num = a1;
3161 //v4 = LOBYTE(am_Players[a1].field_20) == 0; 3150 //v4 = LOBYTE(am_Players[a1].field_20) == 0;
3162 v28 = -1; 3151 v28 = -1;
3163 if ( am_Players[a1].field_20 ) 3152 if ( am_Players[a1].IsHisTurn )
3164 { 3153 {
3165 if ( v26._40DD2F() ) 3154 if ( v26._40DD2F() )
3166 { 3155 {
3167 v5 = GetPlayerHandCardCount(v1); 3156 v5 = GetPlayerHandCardCount(v1);
3168 hand_index = 0; 3157 hand_index = 0;
3226 ++hand_index; 3215 ++hand_index;
3227 if ( hand_index >= v25 ) 3216 if ( hand_index >= v25 )
3228 return v28; 3217 return v28;
3229 } 3218 }
3230 v28 = hand_index; 3219 v28 = hand_index;
3231 v18 = am_40BF15(player_num, hand_index); 3220 v18 = CanCardBePlayed(player_num, hand_index);
3232 if ( v18 ) 3221 if ( v18 )
3233 { 3222 {
3234 v20=0x00FFFFFF; 3223 v20=0x00FFFFFF;
3235 } 3224 }
3236 else 3225 else
3417 } 3406 }
3418 3407
3419 if ( pCards[am_Players[a1].cards_at_hand[i]].field_2B) 3408 if ( pCards[am_Players[a1].cards_at_hand[i]].field_2B)
3420 { 3409 {
3421 ArcomageGame::PlaySound(0x16u); 3410 ArcomageGame::PlaySound(0x16u);
3422 v7 = amuint_4FAA6C; 3411 v7 = current_player_num;
3423 v8 = GetPlayerHandCardCount(amuint_4FAA6C); 3412 v8 = GetPlayerHandCardCount(current_player_num);
3424 v9 = 188 * v7 + 8 * v3; 3413 v9 = 188 * v7 + 8 * v3;
3425 // v10 = 96 * v3 + *(int *)((char *)am_Players[0].arr_6C[0] + v9) + (640 - 96 * v8) / (v8 + 1); 3414 // v10 = 96 * v3 + *(int *)((char *)am_Players[0].arr_6C[0] + v9) + (640 - 96 * v8) / (v8 + 1);
3426 // v11 = *(int *)((char *)&am_Players[0].arr_6C[0][1] + v9) + 327; 3415 // v11 = *(int *)((char *)&am_Players[0].arr_6C[0][1] + v9) + 327;
3427 amuint_4FAA5C_blt_xy[0] = v10; 3416 amuint_4FAA5C_blt_xy[0] = v10;
3428 amuint_4FAA5C_blt_xy[1] = v11; 3417 amuint_4FAA5C_blt_xy[1] = v11;
3461 // 4FAA80: using guessed type int amuint_4FAA80[]; 3450 // 4FAA80: using guessed type int amuint_4FAA80[];
3462 // 4FAA84: using guessed type int amuint_4FAA84[]; 3451 // 4FAA84: using guessed type int amuint_4FAA84[];
3463 // 4FABB8: using guessed type int dword_4FABB8; 3452 // 4FABB8: using guessed type int dword_4FABB8;
3464 3453
3465 //----- (0040BE0E) -------------------------------------------------------- 3454 //----- (0040BE0E) --------------------------------------------------------
3466 bool __fastcall am_40BE0E(int a1, signed int a2) 3455 bool PlayCard( int player_num, signed int card_slot_num )
3467 { 3456 {
3468 bool result; // eax@0 3457 bool result; // eax@0
3469 int v3; // ebp@1 3458 int v3; // ebp@1
3470 int v4; // ecx@2 3459 int v4; // ecx@2
3471 ArcomagePlayer *v5; // esi@2 3460 ArcomagePlayer *v5; // esi@2
3472 int v6; // edi@2 3461 int v6; // edi@2
3479 int v13; // eax@8 3468 int v13; // eax@8
3480 ArcomageCard *v14; // eax@8 3469 ArcomageCard *v14; // eax@8
3481 int v15; // ecx@8 3470 int v15; // ecx@8
3482 int v16; // ecx@8 3471 int v16; // ecx@8
3483 3472
3484 v3 = a1; 3473 v3 = player_num;
3485 if ( a2 <= -1 ) 3474 if ( card_slot_num <= -1 )
3486 goto LABEL_12; 3475 return false;
3487 v4 = 0; 3476 v4 = 0;
3488 v5 = &am_Players[v3]; 3477 v5 = &am_Players[v3];
3489 v6 = 0; 3478 v6 = 0;
3490 v7 = (int)v5->cards_at_hand; 3479 v7 = (int)v5->cards_at_hand;
3491 do 3480 do
3492 { 3481 {
3493 if ( *(unsigned int *)v7 != -1 ) 3482 if ( *(unsigned int *)v7 != -1 )
3494 { 3483 {
3495 if ( a2 == v4 ) 3484 if ( card_slot_num == v4 )
3496 break; 3485 break;
3497 ++v4; 3486 ++v4;
3498 } 3487 }
3499 ++v6; 3488 ++v6;
3500 v7 += 4; 3489 v7 += 4;
3501 } 3490 }
3502 while ( v6 < 10 ); 3491 while ( v6 < 10 );
3503 result = am_40BF15(v3, v6); 3492 result = CanCardBePlayed(v3, v6);
3504 if ( result ) 3493 if ( result )
3505 { 3494 {
3506 ArcomageGame::PlaySound(0x17u); 3495 ArcomageGame::PlaySound(0x17u);
3507 v8 = amuint_4FAA6C; 3496 v8 = current_player_num;
3508 v9 = GetPlayerHandCardCount(amuint_4FAA6C); 3497 v9 = GetPlayerHandCardCount(current_player_num);
3509 v10 = 188 * v8 + 8 * v6; 3498 v10 = 188 * v8 + 8 * v6;
3510 v11 = v6 + 47 * v3; 3499 v11 = v6 + 47 * v3;
3511 amuint_4FAA54_blt_xy[1] = -30; 3500 amuint_4FAA54_blt_xy[1] = -30;
3512 pArcomageGame->field_F6 = 1; 3501 pArcomageGame->field_F6 = 1;
3513 //v12 = 96 * v6 + *(int *)((char *)am_Players[0].arr_6C[0] + v10) + (640 - 96 * v9) / (v9 + 1); 3502 //v12 = 96 * v6 + *(int *)((char *)am_Players[0].arr_6C[0] + v10) + (640 - 96 * v9) / (v9 + 1);
3514 // v13 = *(int *)((char *)&am_Players[0].arr_6C[0][1] + v10) + 327; 3503 // v13 = *(int *)((char *)&am_Players[0].arr_6C[0][1] + v10) + 327;
3515 amuint_4FAA5C_blt_xy[0] = v12; 3504 amuint_4FAA5C_blt_xy[0] = v12;
3516 amuint_4FAA5C_blt_xy[1] = v13; 3505 amuint_4FAA5C_blt_xy[1] = v13;
3517 amuint_4FAA54_blt_xy[0] = (272 - v12) / 5; 3506 amuint_4FAA54_blt_xy[0] = (272 - v12) / 5;
3518 v14 = &pCards[v5->cards_at_hand[v6]]; 3507 v14 = &pCards[v5->cards_at_hand[v6]];
3519 v5->field_38 -= LOBYTE(v14->field_28); 3508 v5->resource_bricks -= v14->needed_bricks;
3520 v15 = BYTE1(v14->field_28); 3509 v5->resource_beasts -= v14->needed_beasts;
3521 v5->field_40 -= BYTE2(v14->field_28); 3510 v5->resource_gems -= v14->needed_gems;
3522 v5->field_3C -= v15;
3523 result = 4 * v11 + 5265228; 3511 result = 4 * v11 + 5265228;
3524 v16 = am_Players[0].cards_at_hand[v11]; 3512 v16 = am_Players[0].cards_at_hand[v11];
3525 am_Players[0].cards_at_hand[v11] = -1; 3513 am_Players[0].cards_at_hand[v11] = -1;
3526 amuint_4FABC0 = v16; 3514 amuint_4FABC0 = v16;
3527 LOBYTE(result) = 1; 3515 return true;;
3528 } 3516 }
3529 else 3517 else
3530 { 3518 return false;
3531 LABEL_12: 3519
3532 LOBYTE(result) = 0;
3533 }
3534 return result;
3535 } 3520 }
3536 3521
3537 //----- (0040BF15) -------------------------------------------------------- 3522 //----- (0040BF15) --------------------------------------------------------
3538 bool am_40BF15( int player_num, int hand_card_indx ) 3523 bool CanCardBePlayed( int player_num, int hand_card_indx )
3539 { 3524 {
3540 bool result; // eax@1 3525 bool result; // eax@1
3541 ArcomageCard *v4; // ecx@1 3526 ArcomageCard *test_card; // ecx@1
3542 ArcomagePlayer *v2; // esi@1 3527 ArcomagePlayer *pPlayer; // esi@1
3543 3528
3544 v2 = &am_Players[player_num]; 3529 pPlayer = &am_Players[player_num];
3545 result = true; 3530 result = true;
3546 v4 = &pCards[am_Players[player_num].cards_at_hand[hand_card_indx]]; 3531 test_card = &pCards[am_Players[player_num].cards_at_hand[hand_card_indx]];
3547 if ( v4->field_25 > v2->field_2C ) 3532 if ( test_card->needed_quarry_level > pPlayer->quarry_level )
3548 result = false; 3533 result = false;
3549 if ( v4->field_26 > v2->field_30 ) 3534 if ( test_card->needed_magic_level > pPlayer->magic_level )
3550 result = false; 3535 result = false;
3551 if ( v4->field_27 > v2->field_34 ) 3536 if ( test_card->needed_might_level > pPlayer->might_level )
3552 result = false; 3537 result = false;
3553 if ( v4->field_28 > v2->field_38 ) 3538 if ( test_card->needed_bricks > pPlayer->resource_bricks )
3554 result = false; 3539 result = false;
3555 if ( v4->field_29 > v2->field_3C ) 3540 if ( test_card->needed_gems > pPlayer->resource_gems )
3556 result = false; 3541 result = false;
3557 if ( v4->field_2A > v2->field_40 ) 3542 if ( test_card->needed_beasts > pPlayer->resource_beasts )
3558 result = false; 3543 result = false;
3559 return result; 3544 return result;
3560 } 3545 }
3561 3546
3562 3547
5599 ArcomagePlayer *v2; // ecx@1 5584 ArcomagePlayer *v2; // ecx@1
5600 int v3; // esi@1 5585 int v3; // esi@1
5601 int result; // eax@3 5586 int result; // eax@3
5602 5587
5603 v2 = &am_Players[a1]; 5588 v2 = &am_Players[a1];
5604 v3 = v2->field_28; 5589 v3 = v2->wall_height;
5605 if ( v3 <= 0 ) 5590 if ( v3 <= 0 )
5606 { 5591 {
5607 result = 0; 5592 result = 0;
5608 } 5593 }
5609 else 5594 else
5610 { 5595 {
5611 if ( v3 >= -a2 ) 5596 if ( v3 >= -a2 )
5612 { 5597 {
5613 result = a2; 5598 result = a2;
5614 v2->field_28 = a2 + v3; 5599 v2->wall_height = a2 + v3;
5615 goto LABEL_7; 5600 goto LABEL_7;
5616 } 5601 }
5617 a2 += v3; 5602 a2 += v3;
5618 result = -v3; 5603 result = -v3;
5619 v2->field_28 = 0; 5604 v2->wall_height = 0;
5620 } 5605 }
5621 v2->field_24 += a2; 5606 v2->tower_height += a2;
5622 LABEL_7: 5607 LABEL_7:
5623 if ( v2->field_24 < 0 ) 5608 if ( v2->tower_height < 0 )
5624 v2->field_24 = 0; 5609 v2->tower_height = 0;
5625 return result; 5610 return result;
5626 } 5611 }
5627 // 40D402: using guessed type int __fastcall am_40D402(uint, uint); 5612 // 40D402: using guessed type int __fastcall am_40D402(uint, uint);
5628 5613
5629 //----- (0040D444) -------------------------------------------------------- 5614 //----- (0040D444) --------------------------------------------------------
5630 int __cdecl am_40D444() 5615 int __cdecl GameResultsApply()
5631 { 5616 {
5632 int v0; // esi@1 5617 int v0; // esi@1
5633 int v1; // edi@1 5618 int v1; // edi@1
5634 int v2; // eax@1 5619 int v2; // eax@1
5635 int v3; // eax@23 5620 int v3; // eax@23
5654 inv_strcpy("Победи", pText); 5639 inv_strcpy("Победи", pText);
5655 v2 = 0; 5640 v2 = 0;
5656 xy[1] = 160; 5641 xy[1] = 160;
5657 xy[0] = 320 - 12 * v2 / 2; 5642 xy[0] = 320 - 12 * v2 / 2;
5658 // pPrimaryWindow_draws_text(-1, pText, xy); 5643 // pPrimaryWindow_draws_text(-1, pText, xy);
5659 if ( am_Players[0].field_24 < dword_4E1884 ) 5644 if ( am_Players[0].tower_height < max_tower_height )
5660 { 5645 {
5661 if ( am_Players[1].field_24 < dword_4E1884 ) 5646 if ( am_Players[1].tower_height < max_tower_height )
5662 goto LABEL_10; 5647 goto LABEL_10;
5663 v0 = 2; 5648 v0 = 2;
5664 } 5649 }
5665 else 5650 else
5666 { 5651 {
5667 if ( am_Players[1].field_24 < dword_4E1884 ) 5652 if ( am_Players[1].tower_height < max_tower_height )
5668 { 5653 {
5669 v0 = 1; 5654 v0 = 1;
5670 } 5655 }
5671 else 5656 else
5672 { 5657 {
5673 if ( am_Players[0].field_24 == am_Players[1].field_24 ) 5658 if ( am_Players[0].tower_height == am_Players[1].tower_height )
5674 { 5659 {
5675 v0 = 0; 5660 v0 = 0;
5676 v1 = 4; 5661 v1 = 4;
5677 goto LABEL_10; 5662 goto LABEL_10;
5678 } 5663 }
5679 v0 = (am_Players[0].field_24 <= am_Players[1].field_24) + 1; 5664 v0 = (am_Players[0].tower_height <= am_Players[1].tower_height) + 1;
5680 } 5665 }
5681 } 5666 }
5682 v1 = 0; 5667 v1 = 0;
5683 LABEL_10: 5668 LABEL_10:
5684 if ( am_Players[0].field_24 <= 0 ) 5669 if ( am_Players[0].tower_height <= 0 )
5685 { 5670 {
5686 if ( am_Players[1].field_24 > 0 ) 5671 if ( am_Players[1].tower_height > 0 )
5687 { 5672 {
5688 v0 = 2; 5673 v0 = 2;
5689 } 5674 }
5690 else 5675 else
5691 { 5676 {
5692 if ( am_Players[0].field_24 == am_Players[1].field_24 ) 5677 if ( am_Players[0].tower_height == am_Players[1].tower_height )
5693 { 5678 {
5694 LABEL_20: 5679 LABEL_20:
5695 if ( am_Players[0].field_28 == am_Players[1].field_28 ) 5680 if ( am_Players[0].wall_height == am_Players[1].wall_height )
5696 { 5681 {
5697 v0 = 0; 5682 v0 = 0;
5698 v1 = 4; 5683 v1 = 4;
5699 } 5684 }
5700 else 5685 else
5701 { 5686 {
5702 v0 = (am_Players[0].field_28 <= am_Players[1].field_28) + 1; 5687 v0 = (am_Players[0].wall_height <= am_Players[1].wall_height) + 1;
5703 v1 = 1; 5688 v1 = 1;
5704 } 5689 }
5705 goto LABEL_23; 5690 goto LABEL_23;
5706 } 5691 }
5707 v0 = (am_Players[0].field_24 <= am_Players[1].field_24) + 1; 5692 v0 = (am_Players[0].tower_height <= am_Players[1].tower_height) + 1;
5708 } 5693 }
5709 goto LABEL_17; 5694 goto LABEL_17;
5710 } 5695 }
5711 if ( am_Players[1].field_24 <= 0 ) 5696 if ( am_Players[1].tower_height <= 0 )
5712 { 5697 {
5713 v0 = 1; 5698 v0 = 1;
5714 LABEL_17: 5699 LABEL_17:
5715 v1 = 2; 5700 v1 = 2;
5716 } 5701 }
5717 if ( !v0 && v1 == 4 ) 5702 if ( !v0 && v1 == 4 )
5718 goto LABEL_20; 5703 goto LABEL_20;
5719 LABEL_23: 5704 LABEL_23:
5720 v3 = am_Players[0].field_38; 5705 v3 = am_Players[0].resource_bricks;
5721 if ( am_Players[0].field_38 <= am_Players[0].field_3C ) 5706 if ( am_Players[0].resource_bricks <= am_Players[0].resource_gems )
5722 { 5707 {
5723 v3 = am_Players[0].field_40; 5708 v3 = am_Players[0].resource_beasts;
5724 v4 = am_Players[0].field_3C; 5709 v4 = am_Players[0].resource_gems;
5725 if ( am_Players[0].field_3C > am_Players[0].field_40 ) 5710 if ( am_Players[0].resource_gems > am_Players[0].resource_beasts )
5726 goto LABEL_28; 5711 goto LABEL_28;
5727 } 5712 }
5728 else 5713 else
5729 { 5714 {
5730 if ( am_Players[0].field_38 <= am_Players[0].field_40 ) 5715 if ( am_Players[0].resource_bricks <= am_Players[0].resource_beasts )
5731 { 5716 {
5732 v4 = am_Players[0].field_40; 5717 v4 = am_Players[0].resource_beasts;
5733 goto LABEL_28; 5718 goto LABEL_28;
5734 } 5719 }
5735 } 5720 }
5736 v4 = v3; 5721 v4 = v3;
5737 LABEL_28: 5722 LABEL_28:
5738 v5 = am_Players[1].field_38; 5723 v5 = am_Players[1].resource_bricks;
5739 v6 = am_Players[1].field_3C; 5724 v6 = am_Players[1].resource_gems;
5740 if ( am_Players[1].field_38 <= am_Players[1].field_3C ) 5725 if ( am_Players[1].resource_bricks <= am_Players[1].resource_gems )
5741 { 5726 {
5742 v5 = am_Players[1].field_40; 5727 v5 = am_Players[1].resource_beasts;
5743 if ( am_Players[1].field_3C > am_Players[1].field_40 ) 5728 if ( am_Players[1].resource_gems > am_Players[1].resource_beasts )
5744 goto LABEL_33; 5729 goto LABEL_33;
5745 goto LABEL_32; 5730 goto LABEL_32;
5746 } 5731 }
5747 v6 = am_Players[1].field_40; 5732 v6 = am_Players[1].resource_beasts;
5748 if ( am_Players[1].field_38 > am_Players[1].field_40 ) 5733 if ( am_Players[1].resource_bricks > am_Players[1].resource_beasts )
5749 LABEL_32: 5734 LABEL_32:
5750 v6 = v5; 5735 v6 = v5;
5751 LABEL_33: 5736 LABEL_33:
5752 if ( v0 == -1 ) 5737 if ( v0 == -1 )
5753 { 5738 {
5754 if ( v1 != -1 ) 5739 if ( v1 != -1 )
5755 goto LABEL_49; 5740 goto LABEL_49;
5756 if ( v4 < dword_4E1888 ) 5741 if ( v4 < max_resources_amount )
5757 { 5742 {
5758 if ( v6 < dword_4E1888 ) 5743 if ( v6 < max_resources_amount )
5759 goto LABEL_49; 5744 goto LABEL_49;
5760 v0 = 2; 5745 v0 = 2;
5761 } 5746 }
5762 else 5747 else
5763 { 5748 {
5764 if ( v6 < dword_4E1888 ) 5749 if ( v6 < max_resources_amount )
5765 { 5750 {
5766 v0 = 1; 5751 v0 = 1;
5767 } 5752 }
5768 else 5753 else
5769 { 5754 {
5792 pArcomageGame->field_B0 = v1; 5777 pArcomageGame->field_B0 = v1;
5793 pArcomageGame->uGameResult = v0; 5778 pArcomageGame->uGameResult = v0;
5794 if ( v0 == 1 ) 5779 if ( v0 == 1 )
5795 { 5780 {
5796 v7 = window_SpeakInHouse; 5781 v7 = window_SpeakInHouse;
5797 v8 = (signed int)window_SpeakInHouse->ptr_1C; 5782 v8 = (signed int)window_SpeakInHouse->par1C;
5798 if ( v8 >= 108 ) 5783 if ( v8 >= 108 )
5799 { 5784 {
5800 if ( v8 <= 120 ) 5785 if ( v8 <= 120 )
5801 { 5786 {
5802 v9 = (char *)&pParty->uNumGoldInBank + v8 + 1; 5787 v9 = (char *)&pParty->uNumGoldInBank + v8 + 1;
5803 if ( !*v9 ) 5788 if ( !*v9 )
5804 { 5789 {
5805 *v9 = 1; 5790 *v9 = 1;
5806 5791
5807 //auto _a = (signed __int64)(p2DEvents_minus1__20[13 * (unsigned int)v7->ptr_1C] * 100.0); 5792 //auto _a = (signed __int64)(p2DEvents_minus1__20[13 * (unsigned int)v7->ptr_1C] * 100.0);
5808 auto _a = (signed int)(p2DEvents[(unsigned int)v7->ptr_1C - 1].fPriceMultiplier * 100.0); 5793 auto _a = (signed int)(p2DEvents[(unsigned int)v7->par1C - 1].fPriceMultiplier * 100.0);
5809 party_finds_gold(_a, 0); 5794 party_finds_gold(_a, 0);
5810 } 5795 }
5811 } 5796 }
5812 } 5797 }
5813 v10 = 108; 5798 v10 = 108;
5850 } 5835 }
5851 5836
5852 5837
5853 5838
5854 //----- (00409C8B) -------------------------------------------------------- 5839 //----- (00409C8B) --------------------------------------------------------
5855 void __cdecl PrepareArcomage() 5840 void PrepareArcomage()
5856 { 5841 {
5857 signed __int64 v1; // qax@4 5842 signed __int64 v1; // qax@4
5858 int v2; // esi@4 5843 int v2; // esi@4
5859 int v3; // esi@5 5844 int v3; // esi@5
5860 signed int v4; // edi@5 5845 signed int v4; // edi@5
5861 int v6; // edx@9 5846 int v6; // edx@9
5910 pArcomageGame->field_F4 = 0; 5895 pArcomageGame->field_F4 = 0;
5911 byte_4FAA2C = 0; 5896 byte_4FAA2C = 0;
5912 byte_505880 = 0; 5897 byte_505880 = 0;
5913 dword_4FAA70 = 0; 5898 dword_4FAA70 = 0;
5914 am_byte_4FAA77 = 0; 5899 am_byte_4FAA77 = 0;
5915 am_409FE9(); 5900 SetStartGameData();
5916 am_40A255(); 5901 am_40A255();
5917 //nullsub_1(); 5902 //nullsub_1();
5918 pArcomageGame->field_F5 = 0; 5903 pArcomageGame->GameOver = 0;
5919 pArcomageGame->pfntComic = pFontComic; 5904 pArcomageGame->pfntComic = pFontComic;
5920 pArcomageGame->pfntArrus = pFontArrus; 5905 pArcomageGame->pfntArrus = pFontArrus;
5921 } 5906 }
5922 5907
5923 5908
5935 5920
5936 5921
5937 5922
5938 5923
5939 //----- (00409BE8) -------------------------------------------------------- 5924 //----- (00409BE8) --------------------------------------------------------
5940 void sub_409BE8() 5925 void SetStartConditions()
5941 { 5926 {
5942 stru348 *v1; // eax@1 5927 ArcomageStartConditions *v1; // eax@1
5943 5928
5944 v1 = &stru_4E1890[window_SpeakInHouse->par1C - 108]; 5929 v1 = &start_conditions[window_SpeakInHouse->par1C - 108];
5945 amuint_4E1860 = v1->field_4; 5930 start_tower_height = v1->tower_height;
5946 amuint_4E1864 = v1->field_6; 5931 start_wall_height = v1->wall_height;
5947 amuint_4E1868 = v1->field_8 - 1; 5932 start_quarry_level = v1->quarry_level - 1;
5948 amuint_4E186C = v1->field_A - 1; 5933 start_magic_level = v1->magic_level - 1;
5949 amuint_4E1870 = v1->field_C - 1; 5934 start_might_level = v1->might_level - 1;
5950 dword_4E1874 = 5; 5935 dword_4E1874 = 5;
5951 dword_4E1878 = 1; 5936 quarry_bonus = 1;
5952 dword_4E187C = 1; 5937 magic_bonus = 1;
5953 dword_4E1880 = 1; 5938 might_bonus = 1;
5954 dword_4E1884 = v1->field_0; 5939 max_tower_height = v1->max_tower;
5955 dword_4E1888 = v1->field_2; 5940 max_resources_amount = v1->max_resources;
5956 5941
5957 dword_4DF3A4 = v1->field_14; 5942 dword_4DF3A4 = v1->field_14;
5958 5943
5959 amuint_505884 = v1->field_E; 5944 start_bricks_amount = v1->bricks_amount;
5960 amuint_505888 = v1->field_10; 5945 start_gems_amount = v1->gems_amount;
5961 amuint_50588C = v1->field_12; 5946 start_beasts_amount = v1->beasts_amount;
5962 5947
5963 } 5948 }
5964 5949
5965 5950
5966 //----- (0040D75D) -------------------------------------------------------- 5951 //----- (0040D75D) --------------------------------------------------------