diff Arcomage.cpp @ 1197:2b950844f2d6

mostly arcomage structs renaming.
author Gloval
date Sat, 08 Jun 2013 22:41:45 +0400
parents 9baf16113199
children 98a70229c271
line wrap: on
line diff
--- a/Arcomage.cpp	Fri Jun 07 23:46:57 2013 +0100
+++ b/Arcomage.cpp	Sat Jun 08 22:41:45 2013 +0400
@@ -23,39 +23,39 @@
 
 
 
-void sub_409BE8();
-
-
-void am_409FE9();
-void am_40A198();
+void SetStartConditions();
+
+
+void SetStartGameData();
+void FillPlayerDeck();
 void am_40A255();
 void  am_40A283(int a1);
 int  GetEmptyCardSlotIndex(int player_num);
-void am_40A346(int player_num);
+void IncreaseResourcesInTurn(int player_num);
 void __cdecl am_40A383();
-bool  am_40A514();
+bool  IsGameOver();
 char __thiscall am_40A560(unsigned int _this);
-void  am_blts(int a1); // idb
+void  DrawGameUI(int a1); // idb
 void am_40AA4E();
-void __cdecl am_chroma_blts();
-void __cdecl am_DrawUI();
-void am_40B102(int a1, char *text, POINT *pXY); // idb
-void am_40B17E(int a1, char* text, POINT *pXY); // idb
-void am_40B1F3(int a1, char* text, POINT* pXY);
-void am_40B268(int a1, char *text, POINT *pXY); // idb
-void __cdecl am_chroma_and_copy_blts();
-void __cdecl am_chroma_blt();
+void DrawRectanglesForText();
+void DrawPlayersText();
+void DrawPlayerLevels(int a1, char *text, POINT *pXY); // idb
+void DrawBricksCount(int a1, char* text, POINT *pXY); // idb
+void DrawGemsCount(int a1, char* text, POINT* pXY);
+void DrawBeastsCount(int a1, char *text, POINT *pXY); // idb
+void  DrawPlayersTowers();
+void  DrawPlayersWall();
 void __cdecl am_40B4B9();
 void __fastcall am_40B76F(int a1);
 int GetPlayerHandCardCount(int player_num);
 signed int __fastcall am_40BB67(int a1);
 char __fastcall am_40BCFB(int a1, signed int a2);
-bool __fastcall am_40BE0E(int a1, signed int a2);
-bool  am_40BF15(int player_num, int hand_card_indx);
+bool PlayCard(int player_num, signed int card_slot_num);
+bool  CanCardBePlayed(int player_num, int hand_card_indx);
 void __fastcall am_40BF77(int a1, unsigned int uCardID); // idb
 int  am_40D2B4(POINT* a1, int a2); // weak
 int __fastcall am_40D402(int, int); // weak
-int __cdecl am_40D444();
+int __cdecl GameResultsApply();
 
 void pPrimaryWindow_draws_text(int a1, const char *pText, POINT *pXY);
 void __thiscall am_BeginScene(unsigned __int16 *pPcxPixels, int a2, int a3); // idb
@@ -71,22 +71,22 @@
 
 /*  388 */
 #pragma pack(push, 1)
-struct stru348
+struct ArcomageStartConditions
 {
-  __int16 field_0;
-  __int16 field_2;
-  __int16 field_4;
-  __int16 field_6;
-  __int16 field_8;
-  __int16 field_A;
-  __int16 field_C;
-  __int16 field_E;
-  __int16 field_10;
-  __int16 field_12;
+  __int16 max_tower;
+  __int16 max_resources;
+  __int16 tower_height;
+  __int16 wall_height;
+  __int16 quarry_level;
+  __int16 magic_level;
+  __int16 might_level;
+  __int16 bricks_amount;
+  __int16 gems_amount;
+  __int16 beasts_amount;
   int field_14;
 };
 #pragma pack(pop)
-stru348 stru_4E1890[13] =
+ArcomageStartConditions start_conditions[13] =
 {
   { 30, 100, 15,  5,  2,  2,  2, 10, 10, 10,  0},
   { 50, 150, 20,  5,  2,  2,  2,  5,  5,  5,  1},
@@ -149,26 +149,27 @@
 
 char am_byte_4E185D; // weak
 
-int amuint_4E1860; // weak
-int amuint_4E1864; // weak
-int amuint_4E1868; // weak
-int amuint_4E186C; // weak
-int amuint_4E1870; // weak
+int start_tower_height; // weak
+int start_wall_height; // weak
+int start_quarry_level; // weak
+int start_magic_level; // weak
+int start_might_level; // weak
 
 
 int dword_4E1874  = 5; // weak
-int dword_4E1878  = 1; // weak
-int dword_4E187C  = 1; // weak
-int dword_4E1880  = 1; // weak
-int dword_4E1884 = 50; // weak
-int dword_4E1888 = 100 ; // weak
+int quarry_bonus  = 1; // weak
+int magic_bonus  = 1; // weak
+int might_bonus  = 1; // weak
+
+int max_tower_height = 50; // weak
+int max_resources_amount = 100 ; // weak
 
 int dword_4DF3A4; // weak
 
 char byte_4FAA2C; // weak
 char byte_4FAA2D; // weak
 
-int amuint_4FAA6C; // idb
+int current_player_num; // idb
 char am_byte_4FAA77; // weak
 
 signed int dword_4FABBC; // idb
@@ -176,6 +177,10 @@
 
 int dword_4FABC8; // weak
 
+int start_bricks_amount; // weak
+int start_gems_amount; // weak
+int start_beasts_amount; // weak
+
 
 //----- (0040DD2F) --------------------------------------------------------
 bool stru273::_40DD2F()
@@ -1551,20 +1556,20 @@
   stru272 *v3; // esi@17
   __int16 *v4; // esi@23
 
-  while ( !pArcomageGame->field_F5 )
+  while ( !pArcomageGame->GameOver )
   {
     pArcomageGame->field_F6 = 1;
     byte_4FAA24 = 1;
-    am_40A346(amuint_4FAA6C);
+    IncreaseResourcesInTurn(current_player_num);
 LABEL_8:
     while ( byte_4FAA24 )
     {
       amuint_4FABC0 = -1;
-      am_40A283(amuint_4FAA6C);
+      am_40A283(current_player_num);
       while ( 1 )
       {
-        byte_4FAA24 = am_40A560(amuint_4FAA6C);
-        if ( GetPlayerHandCardCount(amuint_4FAA6C) <= dword_4E1874 )
+        byte_4FAA24 = am_40A560(current_player_num);
+        if ( GetPlayerHandCardCount(current_player_num) <= dword_4E1874 )
           break;
         am_byte_4FAA77 = 1;
         if ( pArcomageGame->field_F4 )
@@ -1572,13 +1577,13 @@
       }
       am_byte_4FAA77 = 0;
     }
-    pArcomageGame->field_F5 = am_40A514();
-    if ( !pArcomageGame->field_F5 )
+    pArcomageGame->GameOver = IsGameOver();
+    if ( !pArcomageGame->GameOver )
       am_40A383();
     if ( pArcomageGame->field_F4 )
-      pArcomageGame->field_F5 = 1;
+      pArcomageGame->GameOver = 1;
   }
-  am_40D444();
+  GameResultsApply();
   if ( byte_4FAA2C )
   {
    // v2 = retzero_sub_40DFA7((int)dword_4FAA28);
@@ -1613,7 +1618,7 @@
 
 
 //----- (00409FE9) --------------------------------------------------------
-void am_409FE9()
+void SetStartGameData()
     {
 
   signed int j; // edx@7
@@ -1621,31 +1626,31 @@
   signed int i; // ecx@13
   signed int card_dispenser_counter; // eax@13
 
-  amuint_4FAA6C = dword_505890;
-  sub_409BE8();
+  current_player_num = dword_505890;
+  SetStartConditions();
   for(i=0; i<2; ++i )
   {
     if ( i )
     {
       strcpy(am_Players[1].pPlayerName, pArcomageGame->pPlayer2Name);
       if ( byte_4E185C )
-        am_Players[1].field_20 = 0;
+        am_Players[1].IsHisTurn = 0;
       else
-        am_Players[1].field_20 = 1;
+        am_Players[1].IsHisTurn = 1;
     }
     else
     {
       strcpy(am_Players[0].pPlayerName, pArcomageGame->pPlayer1Name);
-      am_Players[0].field_20 = 1;
+      am_Players[0].IsHisTurn = 1;
     }
-    am_Players[i].field_24 = amuint_4E1860;
-    am_Players[i].field_28 = amuint_4E1864;
-    am_Players[i].field_2C = amuint_4E1868;
-    am_Players[i].field_30 = amuint_4E186C;
-    am_Players[i].field_34 = amuint_4E1870;
-    am_Players[i].field_38 = amuint_505884;
-    am_Players[i].field_3C = amuint_505888;
-    am_Players[i].field_40 = amuint_50588C;
+    am_Players[i].tower_height = start_tower_height;
+    am_Players[i].wall_height  = start_wall_height;
+    am_Players[i].quarry_level = start_quarry_level;
+    am_Players[i].magic_level  = start_magic_level;
+    am_Players[i].might_level  = start_might_level;
+    am_Players[i].resource_bricks = start_bricks_amount;
+    am_Players[i].resource_gems   = start_gems_amount;
+    am_Players[i].resource_beasts = start_beasts_amount;
 
     for (j=0; j<10; ++j )
     {
@@ -1698,11 +1703,11 @@
           }
       }
 
-   am_40A198();
+   FillPlayerDeck();
 }
 
 //----- (0040A198) --------------------------------------------------------
-void am_40A198()
+void FillPlayerDeck()
     {
  
   signed int v3; // eax@4
@@ -1742,7 +1747,7 @@
     }
     while ( v7 == 1 );
     card_taken_flags[v6]=1;
-    playDeck.cards_IDs[i] = deckMaster.cards_IDs[v6];
+    playDeck.cards_IDs[i]  = deckMaster.cards_IDs[v6];
     playDeck.cardsInUse[i] = deckMaster.cardsInUse[v6];
   }
 
@@ -1783,7 +1788,7 @@
   {
     if ( v2 >= DECK_SIZE )
     {
-      am_40A198();
+      FillPlayerDeck();
       v2 = dword_4FABC8;
     }
     if ( !playDeck.cardsInUse[v2] )
@@ -1796,7 +1801,7 @@
   }
   while ( !v5 );
 
-  ArcomageGame::PlaySound(0x15u);
+  ArcomageGame::PlaySound(21);
   result = GetEmptyCardSlotIndex(v4);
   if ( result != -1 )
   {
@@ -1827,11 +1832,11 @@
 }
 
 //----- (0040A346) --------------------------------------------------------
-void am_40A346( int player_num )
+void IncreaseResourcesInTurn( int player_num )
 {
-  am_Players[player_num].field_38 += dword_4E1878 + am_Players[player_num].field_2C;
-  am_Players[player_num].field_3C += dword_4E187C + am_Players[player_num].field_30;
-  am_Players[player_num].field_40 += dword_4E1880 + am_Players[player_num].field_34;
+  am_Players[player_num].resource_bricks += quarry_bonus + am_Players[player_num].quarry_level;
+  am_Players[player_num].resource_gems   += magic_bonus  + am_Players[player_num].magic_level;
+  am_Players[player_num].resource_beasts += might_bonus  + am_Players[player_num].might_level;
 }
 
 
@@ -1851,12 +1856,12 @@
 
   if ( !pArcomageGame->field_F4 )
   {
-    if ( am_Players[0].field_20 != 1 || am_Players[1].field_20 != 1 )
+    if ( am_Players[0].IsHisTurn != 1 || am_Players[1].IsHisTurn != 1 )
     {
-      ++amuint_4FAA6C;
+      ++current_player_num;
       am_byte_4FAA75 = 1;
-      if ( amuint_4FAA6C >= 2 )
-        amuint_4FAA6C = 0;
+      if ( current_player_num >= 2 )
+        current_player_num = 0;
     }
     else
     {
@@ -1869,23 +1874,23 @@
       v11.x = 320 - 12 * v0 / 2;
       pPrimaryWindow_draws_text(-1, Dest, &v11);
       am_byte_4FAA75 = 1;
-      v1 = amuint_4FAA6C + 1;
-      v3 = __OFSUB__(amuint_4FAA6C + 1, 2);
-      v2 = amuint_4FAA6C++ - 1 < 0;
+      v1 = current_player_num + 1;
+      v3 = __OFSUB__(current_player_num + 1, 2);
+      v2 = current_player_num++ - 1 < 0;
       if ( !(v2 ^ v3) )
       {
         v1 = 0;
-        amuint_4FAA6C = 0;
+        current_player_num = 0;
       }
       inv_strcpy(am_Players[v1].pPlayerName, Dest);
       v4 = 0;
       v11.y = 260;
       v11.x = 320 - 12 * v4 / 2;
       pPrimaryWindow_draws_text(-1, Dest, &v11);
-      v6.left = 0;
+     /* v6.left = 0;
       v6.right = 640;
       v6.top = 0;
-      v6.bottom = 480;
+      v6.bottom = 480;*/
       //nullsub_1();
       CallRenderPresent();
       //nullsub_1();
@@ -1912,12 +1917,12 @@
       pArcomageGame->field_F4 = 1;
       byte_4FAA74 = 1;
 LABEL_13:
-      v11.x = 0;
+      /*  v11.x = 0;
       v11.y = 0;
       v6.left = 0;
       v6.right = 640;
       v6.top = 0;
-      v6.bottom = 480;
+      v6.bottom = 480;*/
       //nullsub_1();
       CallRenderPresent();
     }
@@ -1926,20 +1931,20 @@
 
 
 //----- (0040A514) --------------------------------------------------------
-bool am_40A514()
+bool IsGameOver()
     {
   bool result; // eax@1
 
   result = false;
   for(int i=0; i<2; ++i)
   {
-    if ( am_Players[i].field_24 <= 0 )
+    if ( am_Players[i].tower_height <= 0 )
+       result  = true;
+    if ( am_Players[i].tower_height >= max_tower_height )
        result  = true;
-    if ( am_Players[i].field_24 >= dword_4E1884 )
-      result  = true;
-    if (  am_Players[i].field_38 >= dword_4E1888
-      ||  am_Players[i].field_3C >= dword_4E1888
-      ||  am_Players[i].field_40 >= dword_4E1888 )
+    if (  am_Players[i].resource_bricks >= max_resources_amount
+      ||  am_Players[i].resource_gems   >= max_resources_amount
+      ||  am_Players[i].resource_beasts >= max_resources_amount )
       result  = true;
   }
  
@@ -1947,9 +1952,7 @@
     byte_4FAA2C = 1;
   return result;
 }
-// 4E1884: using guessed type int dword_4E1884;
-// 4E1888: using guessed type int dword_4E1888;
-// 4FAA2C: using guessed type char byte_4FAA2C;
+
 
 //----- (0040A560) --------------------------------------------------------
 char am_40A560(unsigned int _this)
@@ -2014,18 +2017,18 @@
         pArcomageGame->field_F4 = 1;
         break;
     }
-    v4 = amuint_4FAA6C;
-    if (am_Players[amuint_4FAA6C].field_20 != 1 && !byte_4FAA00 && !byte_4FAA2E && !byte_4FAA2D )
+    v4 = current_player_num;
+    if (am_Players[current_player_num].IsHisTurn != 1 && !byte_4FAA00 && !byte_4FAA2E && !byte_4FAA2D )
     {
       if ( am_byte_4FAA75 )
         am_byte_4FAA76 = 1;
-      am_408BB4(amuint_4FAA6C);
-      v4 = amuint_4FAA6C;
+      am_408BB4(current_player_num);
+      v4 = current_player_num;
       byte_4FAA2E = 1;
     }
     if ( amuint_4FAA4C != -1 && amuint_4FAA38 > 10 )
       amuint_4FAA38 = 10;
-    if ( byte_4FAA2E || byte_4FAA2D ||am_Players[v4].field_20 != 1 )
+    if ( byte_4FAA2E || byte_4FAA2D ||am_Players[v4].IsHisTurn != 1 )
     {
       pArcomageGame->field_F6 = 1;
       if ( byte_4FAA2D )
@@ -2088,7 +2091,7 @@
       {
         if ( a2.field_0 == 7 )
         {
-          if ( am_40BE0E(a1, dword_4FABBC) )
+          if ( PlayCard(a1, dword_4FABBC) )
           {
             byte_4FAA2E = 1;
             if ( am_byte_4FAA75 )
@@ -2147,7 +2150,7 @@
     }*/
     if ( pArcomageGame->field_F6 )
     {
-      am_blts(v13);
+      DrawGameUI(v13);
       DoBlt_Copy(pArcomageGame->pBackgroundPixels);
       pArcomageGame->field_F6 = 0;
     }
@@ -2162,7 +2165,7 @@
       am_BeginScene(pArcomageGame->pBackgroundPixels, -1, 1);
       Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
       am_EndScene();
-      am_blts(v13);
+      DrawGameUI(v13);
       pRenderer->Present();
       pArcomageGame->field_F9 = 0;
     }
@@ -2173,18 +2176,20 @@
 
 
 //----- (0040A9AF) --------------------------------------------------------
-void am_blts( int a1 )
+void DrawGameUI( int a1 )
     {
 
   am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
-  am_chroma_blts();
+  DrawRectanglesForText();
   am_EndScene();
+
   am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
   am_40B4B9();
-  am_chroma_and_copy_blts();
-  am_chroma_blt();
-  am_DrawUI();
+  DrawPlayersTowers();
+  DrawPlayersWall();
+  DrawPlayersText();
   am_EndScene();
+
   am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
   am_40B76F(a1);
 
@@ -2193,7 +2198,7 @@
       if (array_4FABD0[i].field_0)
           array_4FABD0[i].field_40->_40E133();
       }
-  dword_4FABBC = am_40BB67(amuint_4FAA6C);
+  dword_4FABBC = am_40BB67(current_player_num);
   am_40AA4E();
   am_EndScene();
 }
@@ -2242,12 +2247,12 @@
 }
 
 //----- (0040AB0A) --------------------------------------------------------
-void __cdecl am_chroma_blts()
-{
+void DrawRectanglesForText()
+    {
  
   RECT pSrcRect; // [sp+Ch] [bp-18h]@1
   POINT pTargetXY; // [sp+1Ch] [bp-8h]@1
-
+//resources rectangles
   pSrcRect.top     = 0;
   pSrcRect.left    = 765;
   pSrcRect.right   = 843;
@@ -2261,6 +2266,7 @@
   pTargetXY.y = 56;
   Blt_Copy(&pSrcRect, &pTargetXY, 2);
 
+  //players name rectangle
   pSrcRect.left   = 283;
   pSrcRect.right  = 361;
   pSrcRect.top    = 166;
@@ -2273,6 +2279,7 @@
   pTargetXY.y = 13;
   Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
 
+  //tower heigth rectangle
   pSrcRect.left   = 234;
   pSrcRect.right  = 283;
   pSrcRect.top    = 166;
@@ -2281,12 +2288,11 @@
   pTargetXY.y = 296;
   Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
 
-
   pTargetXY.x = 492;
   pTargetXY.y = 296;
   Blt_Chroma(&pSrcRect, &pTargetXY, pArcomageGame->field_54, 2);
 
-
+  //wall heigth rectangle
   pSrcRect.left   = 192;
   pSrcRect.right  = 234;
   pSrcRect.top    = 166;
@@ -2301,155 +2307,141 @@
 }
 
 //----- (0040AC5F) --------------------------------------------------------
-void __cdecl am_DrawUI()
-{
-  int v0; // ecx@7
-  int v1; // ecx@9
-  int v2; // eax@11
-  int v3; // ecx@12
-  int v4; // eax@14
-  int v5; // ecx@14
-  int v6; // eax@16
-  int v7; // ecx@16
-  int v8; // eax@18
-  int v9; // ecx@18
-  int v10; // eax@20
-  char Dest[32]; // [sp+Ch] [bp-28h]@2
-  POINT v12; // [sp+2Ch] [bp-8h]@2
+void DrawPlayersText()
+    {
+ 
+  int res_value; // ecx@18
+  char text_buff[32]; // [sp+Ch] [bp-28h]@2
+  POINT text_position; // [sp+2Ch] [bp-8h]@2
 
   if ( am_byte_4FAA77 )
   {
-    inv_strcpy(pGlobalTXT_LocalizationStrings[266], Dest);// DISCARD A CARD
-    v12.x = 320 - pArcomageGame->pfntArrus->GetLineWidth(Dest) / 2;
-    v12.y = 306;
-    pPrimaryWindow_draws_text(-1, Dest, &v12);
+    inv_strcpy(pGlobalTXT_LocalizationStrings[266], text_buff);// DISCARD A CARD
+    text_position.x = 320 - pArcomageGame->pfntArrus->GetLineWidth(text_buff) / 2;
+    text_position.y = 306;
+    pPrimaryWindow_draws_text(-1, text_buff, &text_position);
   }
-  inv_strcpy(am_Players[0].pPlayerName, Dest);
-  if ( !amuint_4FAA6C )
-    inv_strcat("***", Dest);
-  v12.x = 47 - pArcomageGame->pfntComic->GetLineWidth(Dest) / 2;
-  v12.y = 21;
-  pPrimaryWindow_draws_text(-1, Dest, &v12);
-
-  inv_strcpy(am_Players[1].pPlayerName, Dest);
-  if ( amuint_4FAA6C == 1 )
-    inv_strcat("***", Dest);
-  v12.x = 595 - pArcomageGame->pfntComic->GetLineWidth(Dest) / 2;
-  v12.y = 21;
-  pPrimaryWindow_draws_text(-1, Dest, &v12);
-
-  intToString(am_Players[0].field_24, Dest);
-  v12.x = 123 - pArcomageGame->pfntComic->GetLineWidth(Dest) / 2;
-  v12.y = 305;
-  pPrimaryWindow_draws_text(-1, Dest, &v12);
-
-  intToString(am_Players[1].field_24, Dest);
-  v12.x = 515 - pArcomageGame->pfntComic->GetLineWidth(Dest) / 2;
-  v12.y = 305;
-  pPrimaryWindow_draws_text(-1, Dest, &v12);
-
-  intToString(am_Players[0].field_28, Dest);
-  v12.x = 188 - pArcomageGame->pfntComic->GetLineWidth(Dest) / 2;
-  v12.y = 305;
-  pPrimaryWindow_draws_text(-1, Dest, &v12);
-
-  intToString(am_Players[1].field_28, Dest);
-  v12.x = 451 - pArcomageGame->pfntComic->GetLineWidth(Dest) / 2;
-  v12.y = 305;
-  pPrimaryWindow_draws_text(-1, Dest, &v12);
-
-  v0 = am_Players[0].field_2C;
+  inv_strcpy(am_Players[0].pPlayerName, text_buff);
+  if ( !current_player_num )
+    inv_strcat("***", text_buff);
+  text_position.x = 47 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2;
+  text_position.y = 21;
+  pPrimaryWindow_draws_text(-1, text_buff, &text_position);
+
+  inv_strcpy(am_Players[1].pPlayerName, text_buff);
+  if ( current_player_num == 1 )
+    inv_strcat("***", text_buff);
+  text_position.x = 595 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2;
+  text_position.y = 21;
+  pPrimaryWindow_draws_text(-1, text_buff, &text_position);
+
+  intToString(am_Players[0].tower_height, text_buff);
+  text_position.x = 123 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2;
+  text_position.y = 305;
+  pPrimaryWindow_draws_text(-1, text_buff, &text_position);
+
+  intToString(am_Players[1].tower_height, text_buff);
+  text_position.x = 515 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2;
+  text_position.y = 305;
+  pPrimaryWindow_draws_text(-1, text_buff, &text_position);
+
+  intToString(am_Players[0].wall_height, text_buff);
+  text_position.x = 188 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2;
+  text_position.y = 305;
+  pPrimaryWindow_draws_text(-1, text_buff, &text_position);
+
+  intToString(am_Players[1].wall_height, text_buff);
+  text_position.x = 451 - pArcomageGame->pfntComic->GetLineWidth(text_buff) / 2;
+  text_position.y = 305;
+  pPrimaryWindow_draws_text(-1, text_buff, &text_position);
+
+  res_value = am_Players[0].quarry_level;
   if ( byte_4E185E )
-    v0 = dword_4E1878 + am_Players[0].field_2C;
-  intToString(v0, Dest);
-  v12.x = 14 - 6 * 0 / 2;
-  v12.y = 92;
-  am_40B102(-1, Dest, &v12);
-
-  v1 = am_Players[1].field_2C;
+    res_value =am_Players[0].quarry_level + quarry_bonus;
+  intToString(res_value, text_buff);
+  text_position.x = 14;// - 6 * 0 / 2;
+  text_position.y = 92;
+  DrawPlayerLevels(-1, text_buff, &text_position);
+
+  res_value = am_Players[1].quarry_level;
   if ( byte_4E185E )
-    v1 = dword_4E1878 + am_Players[1].field_2C;
-  intToString(v1, Dest);
-  v2 = 0;
-  v12.y = 92;
-  v12.x = 561 - 6 * v2 / 2;
-  am_40B102(-1, Dest, &v12);
-
+    res_value = am_Players[1].quarry_level + quarry_bonus;
+  intToString(res_value, text_buff);
+//  v2 = 0;
+  text_position.y = 92;
+  text_position.x = 561; //- 6 * v2 / 2;
+  DrawPlayerLevels(-1, text_buff, &text_position);
+
+  res_value = am_Players[0].magic_level;
   if ( byte_4E185E )
-    v3 = am_Players[0].field_30 + dword_4E187C;
-  else
-    v3 = am_Players[0].field_30;
-  intToString(v3, Dest);
-  v4 = 0;
-  v12.y = 164;
-  v12.x = 14 - 6 * v4 / 2;
-  am_40B102(-1, Dest, &v12);
-
-  v5 = am_Players[1].field_30;
+    res_value = am_Players[0].magic_level + magic_bonus;    
+  intToString(res_value, text_buff);
+ // v4 = 0;
+  text_position.y = 164;
+  text_position.x = 14; //- 6 * v4 / 2;
+  DrawPlayerLevels(-1, text_buff, &text_position);
+
+  res_value = am_Players[1].magic_level;
   if ( byte_4E185E )
-    v5 = dword_4E187C + am_Players[1].field_30;
-  intToString(v5, Dest);
-  v6 = 0;
-  v12.y = 164;
-  v12.x = 561 - 6 * v6 / 2;
-  am_40B102(-1, Dest, &v12);
-
-  v7 = am_Players[0].field_34;
+    res_value = am_Players[1].magic_level+magic_bonus;
+  intToString(res_value, text_buff);
+ // v6 = 0;
+  text_position.y = 164;
+  text_position.x = 561; //- 6 * v6 / 2;
+  DrawPlayerLevels(-1, text_buff, &text_position);
+
+  res_value = am_Players[0].might_level;
   if ( byte_4E185E )
-    v7 = dword_4E1880 + am_Players[0].field_34;
-  intToString(v7, Dest);
-  v8 = 0;
-  v12.y = 236;
-  v12.x = 14 - 6 * v8 / 2;
-  am_40B102(-1, Dest, &v12);
-
-  v9 = am_Players[1].field_34;
+    res_value = am_Players[0].might_level + might_bonus;
+  intToString(res_value, text_buff);
+ // v8 = 0;
+  text_position.y = 236;
+  text_position.x = 14;// - 6 * v8 / 2;
+  DrawPlayerLevels(-1, text_buff, &text_position);
+
+  res_value = am_Players[1].might_level;
   if ( byte_4E185E )
-    v9 = dword_4E1880 + am_Players[1].field_34;
-  intToString(v9, Dest);
-  v10 = 0;
-  v12.y = 236;
-  v12.x = 561 - 6 * v10 / 2;
-  am_40B102(-1, Dest, &v12);
-
-  intToString(am_Players[0].field_38, Dest);
-  v12.y = 114;
-  v12.x = 10;
-  am_40B17E(-1, Dest, &v12);
-
-  intToString(am_Players[1].field_38, Dest);
-  v12.x = 557;
-  v12.y = 114;
-  am_40B17E(-1, Dest, &v12);
-
-  intToString(am_Players[0].field_3C, Dest);
-  v12.x = 10;
-  v12.y = 186;
-  am_40B1F3(-1, Dest, &v12);
-
-  intToString(am_Players[1].field_3C, Dest);
-  v12.x = 557;
-  v12.y = 186;
-  am_40B1F3(-1, Dest, &v12);
-
-  intToString(am_Players[0].field_40, Dest);
-  v12.x = 10;
-  v12.y = 258;
-  am_40B268(-1, Dest, &v12);
-
-  intToString(am_Players[1].field_40, Dest);
-  v12.x = 557;
-  v12.y = 258;
-  am_40B268(-1, Dest, &v12);
+    res_value =  am_Players[1].might_level + might_bonus;
+  intToString(res_value, text_buff);
+ // v10 = 0;
+  text_position.y = 236;
+  text_position.x = 561;// - 6 * v10 / 2;
+  DrawPlayerLevels(-1, text_buff, &text_position);
+
+  intToString(am_Players[0].resource_bricks, text_buff);
+  text_position.y = 114;
+  text_position.x = 10;
+  DrawBricksCount(-1, text_buff, &text_position);
+
+  intToString(am_Players[1].resource_bricks, text_buff);
+  text_position.x = 557;
+  text_position.y = 114;
+  DrawBricksCount(-1, text_buff, &text_position);
+
+  intToString(am_Players[0].resource_gems, text_buff);
+  text_position.x = 10;
+  text_position.y = 186;
+  DrawGemsCount(-1, text_buff, &text_position);
+
+  intToString(am_Players[1].resource_gems, text_buff);
+  text_position.x = 557;
+  text_position.y = 186;
+  DrawGemsCount(-1, text_buff, &text_position);
+
+  intToString(am_Players[0].resource_beasts, text_buff);
+  text_position.x = 10;
+  text_position.y = 258;
+  DrawBeastsCount(-1, text_buff, &text_position);
+
+  intToString(am_Players[1].resource_beasts, text_buff);
+  text_position.x = 557;
+  text_position.y = 258;
+  DrawBeastsCount(-1, text_buff, &text_position);
 }
-// 4E185E: using guessed type char byte_4E185E;
-// 4E1878: using guessed type int dword_4E1878;
-// 4E187C: using guessed type int dword_4E187C;
-// 4E1880: using guessed type int dword_4E1880;
-// 4FAA77: using guessed type char am_byte_4FAA77;
+
 
 //----- (0040B102) --------------------------------------------------------
-void am_40B102( int a1, char *text, POINT *pXY )
+void DrawPlayerLevels( int a1, char *text, POINT *pXY )
     {
   char *v3; // esi@1
   unsigned char test_char; // bl@2
@@ -2481,7 +2473,7 @@
 }
 
 //----- (0040B17E) --------------------------------------------------------
-void am_40B17E( int a1, char* text, POINT *pXY )
+void DrawBricksCount( int a1, char* text, POINT *pXY )
     {
 
     char *v3; // esi@1
@@ -2501,8 +2493,8 @@
         if ( test_char )
             {
             v7 = 13 * test_char;
-            pSrcRect.right = v7 - 370;
-            pSrcRect.left = v7 - 357;
+            pSrcRect.left = v7 - 370;
+            pSrcRect.right = v7 - 357;
             pSrcRect.top = 128;
             pSrcRect.bottom = 138;
             Blt_Copy(&pSrcRect, &pTargetPoint, 2);
@@ -2515,7 +2507,7 @@
 }
 
 //----- (0040B1F3) --------------------------------------------------------
-void am_40B1F3( int a1, char* text, POINT* pXY )
+void DrawGemsCount( int a1, char* text, POINT* pXY )
     {
 
     char *v3; // esi@1
@@ -2535,8 +2527,8 @@
         if ( test_char )
             {
             v7 = 13 * test_char;
-            pSrcRect.right = v7 - 370;
-            pSrcRect.left = v7 - 357;
+            pSrcRect.left = v7 - 370;
+            pSrcRect.right = v7 - 357;
             pSrcRect.top = 138;
             pSrcRect.bottom = 148;
             Blt_Copy(&pSrcRect, &pTargetPoint, 2);
@@ -2549,7 +2541,7 @@
 }
 
 //----- (0040B268) --------------------------------------------------------
-void am_40B268( int a1, char *text, POINT *pXY )
+void DrawBeastsCount( int a1, char *text, POINT *pXY )
     {
 
     char *v3; // esi@1
@@ -2569,8 +2561,8 @@
         if ( test_char )
             {
             v7 = 13 * test_char;
-            pSrcRect.right = v7 - 370;
-            pSrcRect.left = v7 - 357;
+            pSrcRect.left = v7 - 370;
+            pSrcRect.right = v7 - 357;
             pSrcRect.top = 148;
             pSrcRect.bottom = 158;
             Blt_Copy(&pSrcRect, &pTargetPoint, 2);
@@ -2583,64 +2575,62 @@
 }
 
 //----- (0040B2DD) --------------------------------------------------------
-void __cdecl am_chroma_and_copy_blts()
-{
-
-int v0; // eax@1
-int v1; // esi@3
-int v2; // eax@3
-int v3; // eax@3
-int v4; // esi@5
-int v5; // eax@5
+void DrawPlayersTowers()
+    {
+int tower_height; // eax@1
+int tower_top; // esi@3
 RECT pSrcXYZW; // [sp+0h] [bp-18h]@3
 POINT pTargetXY; // [sp+10h] [bp-8h]@3
 
-v0= am_Players[0].field_24;
-if ( am_Players[0].field_24 > dword_4E1884 )
-      v0 = dword_4E1884;
+tower_height= am_Players[0].tower_height;
+if ( am_Players[0].tower_height > max_tower_height )
+      tower_height = max_tower_height;
 pSrcXYZW.top = 0;
 pSrcXYZW.left = 892;
 pSrcXYZW.right = 937;
-v1 = 200 * v0 / dword_4E1884;
-pSrcXYZW.bottom = v1;
+tower_top = 200 * tower_height / max_tower_height;
+pSrcXYZW.bottom = tower_top;
 pTargetXY.x = 102;
-pTargetXY.y = 297 - v1;
+pTargetXY.y = 297 - tower_top;
 Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
 
 pSrcXYZW.top = 0;
 pSrcXYZW.left = 384;
 pSrcXYZW.right = 452;
 pSrcXYZW.bottom = 94;
-pTargetXY.y = 203 - v1;
+pTargetXY.y = 203 - tower_top;
 pTargetXY.x = 91;
 Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
 
-v3 = am_Players[1].field_24;
-if (am_Players[1].field_24  > dword_4E1884 )
-    v3 = dword_4E1884;
-pSrcXYZW.top = 0;
-pSrcXYZW.left = 892;
-pSrcXYZW.right = 937;
-v4 = 200 * v3 / dword_4E1884;
-pSrcXYZW.bottom = v4;
+
+tower_height = am_Players[1].tower_height;
+if (am_Players[1].tower_height  > max_tower_height )
+    tower_height = max_tower_height;
+tower_top = 200 * tower_height / max_tower_height;
+pSrcXYZW.top    = 0;
+pSrcXYZW.left   = 892;
+pSrcXYZW.right  = 937;
+pSrcXYZW.bottom = tower_top;
+
 pTargetXY.x = 494;
-pTargetXY.y = 297 - v4;
+pTargetXY.y = 297 - tower_top;
 Blt_Copy(&pSrcXYZW, &pTargetXY, 2);
-
-pSrcXYZW.left = 384;
-pSrcXYZW.right = 452;
-pSrcXYZW.top = 94;
+//draw tower up cone
+pSrcXYZW.left   = 384;
+pSrcXYZW.right  = 452;
+pSrcXYZW.top    =  94;
 pSrcXYZW.bottom = 188;
+
 pTargetXY.x = 483;
-pTargetXY.y = 203 - v4;
+pTargetXY.y = 203 - tower_top;
 Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
  
 }
 // 4E1884: using guessed type int dword_4E1884;
 
 //----- (0040B400) --------------------------------------------------------
-void __cdecl am_chroma_blt()
-{
+void DrawPlayersWall()
+    {
 int v0; // eax@1
 int v1; // eax@4
 LONG v2; // ecx@4
@@ -2650,10 +2640,10 @@
 RECT pSrcXYZW; // [sp+4h] [bp-18h]@4
 POINT pTargetXY; // [sp+14h] [bp-8h]@4
 
-v0 = am_Players[0].field_28;
-if ( am_Players[0].field_28 <= 100 )
+v0 = am_Players[0].wall_height;
+if ( am_Players[0].wall_height <= 100 )
     {
-    if ( am_Players[0].field_28 <= 0 )
+    if ( am_Players[0].wall_height <= 0 )
         goto LABEL_5;
     }
 else
@@ -2670,10 +2660,10 @@
 Blt_Chroma(&pSrcXYZW, &pTargetXY, pArcomageGame->field_54, 2);
 
 LABEL_5:
-v3 = am_Players[1].field_28;
-if ( am_Players[1].field_28 <= 100 )
+v3 = am_Players[1].wall_height;
+if ( am_Players[1].wall_height <= 100 )
     {
-    if ( am_Players[1].field_28 <= 0 )
+    if ( am_Players[1].wall_height <= 0 )
         return;
     }
 else
@@ -3159,7 +3149,7 @@
 player_num = a1;
 //v4 = LOBYTE(am_Players[a1].field_20) == 0;
 v28 = -1;
-if ( am_Players[a1].field_20 )
+if ( am_Players[a1].IsHisTurn )
     {
     if ( v26._40DD2F() )
         {
@@ -3227,7 +3217,7 @@
                     return v28;
                 }
             v28 = hand_index;
-            v18 = am_40BF15(player_num, hand_index);
+            v18 = CanCardBePlayed(player_num, hand_index);
             if ( v18 )
                 {
                  v20=0x00FFFFFF;
@@ -3418,8 +3408,8 @@
   if ( pCards[am_Players[a1].cards_at_hand[i]].field_2B) 
   {
     ArcomageGame::PlaySound(0x16u);
-    v7 = amuint_4FAA6C;
-    v8 = GetPlayerHandCardCount(amuint_4FAA6C);
+    v7 = current_player_num;
+    v8 = GetPlayerHandCardCount(current_player_num);
     v9 = 188 * v7 + 8 * v3;
 //    v10 = 96 * v3 + *(int *)((char *)am_Players[0].arr_6C[0] + v9) + (640 - 96 * v8) / (v8 + 1);
    // v11 = *(int *)((char *)&am_Players[0].arr_6C[0][1] + v9) + 327;
@@ -3462,8 +3452,8 @@
 // 4FABB8: using guessed type int dword_4FABB8;
 
 //----- (0040BE0E) --------------------------------------------------------
-bool __fastcall am_40BE0E(int a1, signed int a2)
-{
+bool PlayCard( int player_num, signed int card_slot_num )
+    {
   bool result; // eax@0
   int v3; // ebp@1
   int v4; // ecx@2
@@ -3480,9 +3470,9 @@
   int v15; // ecx@8
   int v16; // ecx@8
 
-  v3 = a1;
-  if ( a2 <= -1 )
-    goto LABEL_12;
+  v3 = player_num;
+  if ( card_slot_num <= -1 )
+    return false;
   v4 = 0;
   v5 = &am_Players[v3];
   v6 = 0;
@@ -3491,7 +3481,7 @@
   {
     if ( *(unsigned int *)v7 != -1 )
     {
-      if ( a2 == v4 )
+      if ( card_slot_num == v4 )
         break;
       ++v4;
     }
@@ -3499,12 +3489,12 @@
     v7 += 4;
   }
   while ( v6 < 10 );
-  result = am_40BF15(v3, v6);
+  result = CanCardBePlayed(v3, v6);
   if ( result )
   {
     ArcomageGame::PlaySound(0x17u);
-    v8 = amuint_4FAA6C;
-    v9 = GetPlayerHandCardCount(amuint_4FAA6C);
+    v8 = current_player_num;
+    v9 = GetPlayerHandCardCount(current_player_num);
     v10 = 188 * v8 + 8 * v6;
     v11 = v6 + 47 * v3;
     amuint_4FAA54_blt_xy[1] = -30;
@@ -3515,45 +3505,41 @@
     amuint_4FAA5C_blt_xy[1] = v13;
     amuint_4FAA54_blt_xy[0] = (272 - v12) / 5;
     v14 = &pCards[v5->cards_at_hand[v6]];
-    v5->field_38 -= LOBYTE(v14->field_28);
-    v15 = BYTE1(v14->field_28);
-    v5->field_40 -= BYTE2(v14->field_28);
-    v5->field_3C -= v15;
+    v5->resource_bricks -= v14->needed_bricks;
+    v5->resource_beasts -= v14->needed_beasts;
+    v5->resource_gems   -= v14->needed_gems;
     result = 4 * v11 + 5265228;
     v16 = am_Players[0].cards_at_hand[v11];
     am_Players[0].cards_at_hand[v11] = -1;
     amuint_4FABC0 = v16;
-    LOBYTE(result) = 1;
+    return true;;
   }
   else
-  {
-LABEL_12:
-    LOBYTE(result) = 0;
-  }
-  return result;
+   return false;
+
 }
 
 //----- (0040BF15) --------------------------------------------------------
-bool am_40BF15( int player_num, int hand_card_indx )
+bool CanCardBePlayed( int player_num, int hand_card_indx )
     {
   bool result; // eax@1
-  ArcomageCard *v4; // ecx@1
-  ArcomagePlayer *v2; // esi@1
-
-   v2 = &am_Players[player_num];
+  ArcomageCard *test_card; // ecx@1
+  ArcomagePlayer *pPlayer; // esi@1
+
+  pPlayer = &am_Players[player_num];
   result = true;
-  v4 = &pCards[am_Players[player_num].cards_at_hand[hand_card_indx]];
-  if ( v4->field_25 > v2->field_2C )
+  test_card = &pCards[am_Players[player_num].cards_at_hand[hand_card_indx]];
+  if ( test_card->needed_quarry_level > pPlayer->quarry_level )
     result = false;
-  if ( v4->field_26 > v2->field_30 )
+  if ( test_card->needed_magic_level > pPlayer->magic_level )
     result = false;
-  if ( v4->field_27 > v2->field_34 )
+  if ( test_card->needed_might_level > pPlayer->might_level )
     result = false;
-  if ( v4->field_28 > v2->field_38 )
+  if ( test_card->needed_bricks > pPlayer->resource_bricks )
     result = false;
-  if ( v4->field_29 > v2->field_3C )
+  if ( test_card->needed_gems > pPlayer->resource_gems )
     result = false;
-  if ( v4->field_2A > v2->field_40 )
+  if ( test_card->needed_beasts > pPlayer->resource_beasts )
     result = false;
   return result;
 }
@@ -5600,7 +5586,7 @@
   int result; // eax@3
 
   v2 = &am_Players[a1];
-  v3 = v2->field_28;
+  v3 = v2->wall_height;
   if ( v3 <= 0 )
   {
     result = 0;
@@ -5610,23 +5596,23 @@
     if ( v3 >= -a2 )
     {
       result = a2;
-      v2->field_28 = a2 + v3;
+      v2->wall_height = a2 + v3;
       goto LABEL_7;
     }
     a2 += v3;
     result = -v3;
-    v2->field_28 = 0;
+    v2->wall_height = 0;
   }
-  v2->field_24 += a2;
+  v2->tower_height += a2;
 LABEL_7:
-  if ( v2->field_24 < 0 )
-    v2->field_24 = 0;
+  if ( v2->tower_height < 0 )
+    v2->tower_height = 0;
   return result;
 }
 // 40D402: using guessed type int __fastcall am_40D402(uint, uint);
 
 //----- (0040D444) --------------------------------------------------------
-int __cdecl am_40D444()
+int __cdecl GameResultsApply()
 {
   int v0; // esi@1
   int v1; // edi@1
@@ -5655,59 +5641,59 @@
   xy[1] = 160;
   xy[0] = 320 - 12 * v2 / 2;
 //  pPrimaryWindow_draws_text(-1, pText, xy);
-  if ( am_Players[0].field_24 < dword_4E1884 )
+  if ( am_Players[0].tower_height < max_tower_height )
   {
-    if ( am_Players[1].field_24 < dword_4E1884 )
+    if ( am_Players[1].tower_height < max_tower_height )
       goto LABEL_10;
     v0 = 2;
   }
   else
   {
-    if ( am_Players[1].field_24 < dword_4E1884 )
+    if ( am_Players[1].tower_height < max_tower_height )
     {
       v0 = 1;
     }
     else
     {
-      if ( am_Players[0].field_24 == am_Players[1].field_24 )
+      if ( am_Players[0].tower_height == am_Players[1].tower_height )
       {
         v0 = 0;
         v1 = 4;
         goto LABEL_10;
       }
-      v0 = (am_Players[0].field_24 <= am_Players[1].field_24) + 1;
+      v0 = (am_Players[0].tower_height <= am_Players[1].tower_height) + 1;
     }
   }
   v1 = 0;
 LABEL_10:
-  if ( am_Players[0].field_24 <= 0 )
+  if ( am_Players[0].tower_height <= 0 )
   {
-    if ( am_Players[1].field_24 > 0 )
+    if ( am_Players[1].tower_height > 0 )
     {
       v0 = 2;
     }
     else
     {
-      if ( am_Players[0].field_24 == am_Players[1].field_24 )
+      if ( am_Players[0].tower_height == am_Players[1].tower_height )
       {
 LABEL_20:
-        if ( am_Players[0].field_28 == am_Players[1].field_28 )
+        if ( am_Players[0].wall_height == am_Players[1].wall_height )
         {
           v0 = 0;
           v1 = 4;
         }
         else
         {
-          v0 = (am_Players[0].field_28 <= am_Players[1].field_28) + 1;
+          v0 = (am_Players[0].wall_height <= am_Players[1].wall_height) + 1;
           v1 = 1;
         }
         goto LABEL_23;
       }
-      v0 = (am_Players[0].field_24 <= am_Players[1].field_24) + 1;
+      v0 = (am_Players[0].tower_height <= am_Players[1].tower_height) + 1;
     }
     goto LABEL_17;
   }
-  if ( am_Players[1].field_24 <= 0 )
+  if ( am_Players[1].tower_height <= 0 )
   {
     v0 = 1;
 LABEL_17:
@@ -5716,35 +5702,35 @@
   if ( !v0 && v1 == 4 )
     goto LABEL_20;
 LABEL_23:
-  v3 = am_Players[0].field_38;
-  if ( am_Players[0].field_38 <= am_Players[0].field_3C )
+  v3 = am_Players[0].resource_bricks;
+  if ( am_Players[0].resource_bricks <= am_Players[0].resource_gems )
   {
-    v3 = am_Players[0].field_40;
-    v4 = am_Players[0].field_3C;
-    if ( am_Players[0].field_3C > am_Players[0].field_40 )
+    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].field_38 <= am_Players[0].field_40 )
+    if ( am_Players[0].resource_bricks <= am_Players[0].resource_beasts )
     {
-      v4 = am_Players[0].field_40;
+      v4 = am_Players[0].resource_beasts;
       goto LABEL_28;
     }
   }
   v4 = v3;
 LABEL_28:
-  v5 = am_Players[1].field_38;
-  v6 = am_Players[1].field_3C;
-  if ( am_Players[1].field_38 <= am_Players[1].field_3C )
+  v5 = am_Players[1].resource_bricks;
+  v6 = am_Players[1].resource_gems;
+  if ( am_Players[1].resource_bricks <= am_Players[1].resource_gems )
   {
-    v5 = am_Players[1].field_40;
-    if ( am_Players[1].field_3C > am_Players[1].field_40 )
+    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].field_40;
-  if ( am_Players[1].field_38 > am_Players[1].field_40 )
+  v6 = am_Players[1].resource_beasts;
+  if ( am_Players[1].resource_bricks > am_Players[1].resource_beasts )
 LABEL_32:
     v6 = v5;
 LABEL_33:
@@ -5752,15 +5738,15 @@
   {
     if ( v1 != -1 )
       goto LABEL_49;
-    if ( v4 < dword_4E1888 )
+    if ( v4 < max_resources_amount )
     {
-      if ( v6 < dword_4E1888 )
+      if ( v6 < max_resources_amount )
         goto LABEL_49;
       v0 = 2;
     }
     else
     {
-      if ( v6 < dword_4E1888 )
+      if ( v6 < max_resources_amount )
       {
         v0 = 1;
       }
@@ -5793,7 +5779,7 @@
   if ( v0 == 1 )
   {
     v7 = window_SpeakInHouse;
-    v8 = (signed int)window_SpeakInHouse->ptr_1C;
+    v8 = (signed int)window_SpeakInHouse->par1C;
     if ( v8 >= 108 )
     {
       if ( v8 <= 120 )
@@ -5804,7 +5790,7 @@
           *v9 = 1;
 
           //auto _a = (signed __int64)(p2DEvents_minus1__20[13 * (unsigned int)v7->ptr_1C] * 100.0);
-          auto _a = (signed int)(p2DEvents[(unsigned int)v7->ptr_1C - 1].fPriceMultiplier * 100.0);
+          auto _a = (signed int)(p2DEvents[(unsigned int)v7->par1C - 1].fPriceMultiplier * 100.0);
           party_finds_gold(_a, 0);
         }
       }
@@ -5851,8 +5837,8 @@
 
 
 //----- (00409C8B) --------------------------------------------------------
-void __cdecl PrepareArcomage()
-{
+void PrepareArcomage()
+    {
   signed __int64 v1; // qax@4
   int v2; // esi@4
   int v3; // esi@5
@@ -5911,10 +5897,10 @@
   byte_505880 = 0;
   dword_4FAA70 = 0;
   am_byte_4FAA77 = 0;
-  am_409FE9();
+  SetStartGameData();
   am_40A255();
   //nullsub_1();
-  pArcomageGame->field_F5 = 0;
+  pArcomageGame->GameOver = 0;
   pArcomageGame->pfntComic = pFontComic;
   pArcomageGame->pfntArrus = pFontArrus;
 }
@@ -5936,28 +5922,28 @@
 
 
 //----- (00409BE8) --------------------------------------------------------
-void sub_409BE8()
+void SetStartConditions()
 {
-  stru348 *v1; // eax@1
+  ArcomageStartConditions *v1; // eax@1
     
-  v1 = &stru_4E1890[window_SpeakInHouse->par1C - 108];
-  amuint_4E1860 = v1->field_4;
-  amuint_4E1864 = v1->field_6;
-  amuint_4E1868 = v1->field_8 - 1;
-  amuint_4E186C = v1->field_A - 1;
-  amuint_4E1870 = v1->field_C - 1;
+  v1 = &start_conditions[window_SpeakInHouse->par1C - 108];
+  start_tower_height = v1->tower_height;
+  start_wall_height = v1->wall_height;
+  start_quarry_level = v1->quarry_level - 1;
+  start_magic_level = v1->magic_level - 1;
+  start_might_level = v1->might_level - 1;
   dword_4E1874 = 5;
-  dword_4E1878 = 1;
-  dword_4E187C = 1;
-  dword_4E1880 = 1;
-  dword_4E1884 = v1->field_0;
-  dword_4E1888 = v1->field_2;
+  quarry_bonus = 1;
+  magic_bonus = 1;
+  might_bonus = 1;
+  max_tower_height = v1->max_tower;
+  max_resources_amount = v1->max_resources;
 
   dword_4DF3A4 = v1->field_14;
 
-  amuint_505884 = v1->field_E;
-  amuint_505888 = v1->field_10;
-  amuint_50588C = v1->field_12;
+  start_bricks_amount = v1->bricks_amount;
+  start_gems_amount   = v1->gems_amount;
+  start_beasts_amount = v1->beasts_amount;
   
 }