diff Arcomage.cpp @ 1704:cc1d68c17e19

Слияние
author Ritor1
date Mon, 23 Sep 2013 09:34:23 +0600
parents 4da5644df18f
children 35c1e4ff6ba7
line wrap: on
line diff
--- a/Arcomage.cpp	Mon Sep 23 09:33:13 2013 +0600
+++ b/Arcomage.cpp	Mon Sep 23 09:34:23 2013 +0600
@@ -47,25 +47,25 @@
 void DrawCards();
 void DrawCardAnimation(int a1);
 int GetPlayerHandCardCount(int player_num);
-signed int  DrawCardsRectangles(int player_num);
-bool DiscardCard(int player_num, signed int card_slot_index);
-bool PlayCard(int player_num, signed int card_slot_num);
+int DrawCardsRectangles(int player_num);
+bool DiscardCard(int player_num, int card_slot_index);
+bool PlayCard(int player_num, int card_slot_num);
 bool CanCardBePlayed(int player_num, int hand_card_indx);
 void ApplyCardToPlayer(int player_num, unsigned int uCardID); 
 int  am_40D2B4(POINT* a1, int a2); // weak
 int  ApplyDamageToBuildings(int player_num, int damage); // weak
 void GameResultsApply();
 
-void pPrimaryWindow_draws_text(int a1, const char *pText, POINT *pXY);
+void am_DrawText(int a1, const char *pText, POINT *pXY);
 void  am_BeginScene(unsigned __int16 *pPcxPixels, int a2, int a3); // idb
 void __fastcall Blt_Chroma(RECT  *pSrcXYZW, POINT *pTargetXY, int a3, int a4);
 void  Blt_Copy(RECT *pSrcRect, POINT *pTargetXY, int a3);
 void  am_EndScene();
 void DrawRect(RECT *pXYZW, unsigned __int16 uColor, char bSolidFill);
-void SetPixel2sq( POINT *pTargetXY, unsigned __int16 uColor );
-void SetPixel(POINT *pTargetXY, unsigned __int16 uColor);
+void DrawSquare( POINT *pTargetXY, unsigned __int16 uColor );
+void DrawPixel(POINT *pTargetXY, unsigned __int16 uColor);
 int  rand_interval(int min, int max); // idb
-void __fastcall intToString(int val, char *pOut);
+void __fastcall am_IntToString(int val, char *pOut);
 
 //----- (0040DEDB) --------------------------------------------------------
 unsigned int R8G8B8_to_TargetFormat(int uColor)
@@ -112,17 +112,16 @@
 
 ArcomageGame *pArcomageGame = new ArcomageGame;
 
-ArcomagePlayer am_Players[2];
-Acromage_st1 shown_cards[10]; //amuint_4FAA78; // weak
-stru272 array_4FABD0[10];
-
-
-ArcomageDeck playDeck;
-ArcomageDeck deckMaster;
+ArcomagePlayer am_Players[2]; // 00505708
+AcromageCardOnTable shown_cards[10]; // 004FAA78
+stru272 array_4FABD0[10]; // 4FABD0
+
+
+ArcomageDeck playDeck; // 00505288
+ArcomageDeck deckMaster; // 005054C8
 
 char Player2Name[] = "Enemy";
 char Player1Name[] = "Player";
-char pDeckMaster[] = "Master Deck";
 
 /*  267 */
 #pragma pack(push, 1)
@@ -163,7 +162,7 @@
 int start_zoo_level; 
 
 
-int minimum_cards_at_hand  = 5; 
+int minimum_cards_at_hand  = 5;  // 004E1874
 int quarry_bonus           = 1; 
 int magic_bonus            = 1; 
 int zoo_bonus              = 1; 
@@ -173,17 +172,17 @@
 
 int opponent_mastery = 1 ; // weak
 
-char byte_4FAA2C; // weak
+bool am_gameover; // 004FAA2C
 char byte_4FAA2D; // weak
 
-int current_player_num; // idb
-char need_to_discard_card; // weak
-
-signed int current_card_slot_index; 
-int played_card_id; // idb 4FABC0
-int uCardID; // idb 4FAA50
-
-int deck_walk_index; 
+int current_player_num; // 004FAA6C
+char need_to_discard_card; // 04FAA77
+
+int current_card_slot_index;  // 004FABBC
+int played_card_id; // 4FABC0
+int uCardID; // 4FAA50
+
+int deck_walk_index; // 004FABC8
 
 int start_bricks_amount; 
 int start_gems_amount; 
@@ -242,20 +241,20 @@
 }
 
 //----- (0040DFD1) --------------------------------------------------------
-void stru272_stru0::Ctor(stru272_stru0 **a1)
-    {
-    stru272_stru0 *v2; // eax@1
-    v2 = (stru272_stru0 *)malloc(0x5Cu);
-    *a1 = v2;
+stru272_stru0 *stru272_stru0::New()
+{
+    stru272_stru0 *v2 = (stru272_stru0 *)malloc(0x5Cu);
     v2->signature = SIG_trpg;
     v2->position_in_sparks_arr = 0;
     v2->field_30 = 0.0;
     v2->field_58 = 0;
     v2->field_59 = 0;
-    }
+
+    return v2;
+}
 
 //----- (0040DFFE) --------------------------------------------------------
-int stru272_stru0::Dtor()
+int stru272_stru0::Free()
     {
 
     if ( this->signature == SIG_trpg )
@@ -299,7 +298,7 @@
     }
 
 //----- (0040E0F5) --------------------------------------------------------
-int stru272_stru0::Empty(char a2, char a3)
+int stru272_stru0::Clear(char a2, char a3)
     {
     if ( signature == SIG_trpg)
         {
@@ -982,7 +981,6 @@
 //----- (00408BB4) --------------------------------------------------------
 bool OpponentsAITurn(int player_num)
 {
-
     char result; // al@3
     signed int v2; // ebx@8
     int v3; // esi@8
@@ -1269,7 +1267,7 @@
       pArcomageGame->GameOver = 1;
   }
   GameResultsApply();
-  if ( byte_4FAA2C )
+  if ( am_gameover )
   {
      dword_4FAA70 = 0;
   }
@@ -1277,23 +1275,21 @@
   {
     dword_4FAA70 = -1;
   }
-  pVideoPlayer->BinkUpdatePalette(dword_4FAA28);
 
   for(int i=0; i<10; ++i)
-      {
-      array_4FABD0[i].field_40->Empty(1,1);
-      array_4FABD0[i].field_40->Dtor();
-      }
+  {
+      array_4FABD0[i].field_40->Clear(1, 1);
+      array_4FABD0[i].field_40->Free();
+  }
 
   pArcomageGame->pGameBackground.Release();
   pArcomageGame->pSprites.Release();
-  pArcomageGame->bGameInProgress = 0;
-  viewparams->bRedrawGameUI = 1;
+  pArcomageGame->bGameInProgress = false;
+  viewparams->bRedrawGameUI = true;
   if ( pVideoPlayer->AnyMovieLoaded() )
     pVideoPlayer->_4BF5B2();
   for(int i=0; i<12; ++i)
     pSoundList->UnloadSound(am_sounds[i], 1);
-
 }
 
 
@@ -1301,8 +1297,7 @@
 
 //----- (00409FE9) --------------------------------------------------------
 void SetStartGameData()
-    {
-
+{
   signed int j; // edx@7
   int card_id_counter; // edx@13
   signed int i; // ecx@13
@@ -1349,7 +1344,7 @@
       }
     }  
   }
-  strcpy(deckMaster.name, pDeckMaster);
+  strcpy(deckMaster.name, "Master Deck");
   for (i=0, card_dispenser_counter=-2, card_id_counter=0; i<DECK_SIZE; ++i, ++card_dispenser_counter)
       {
       deckMaster.cardsInUse[i] = 0;
@@ -1503,7 +1498,7 @@
 }
 
 //----- (0040A346) --------------------------------------------------------
-void IncreaseResourcesInTurn( int player_num )
+void IncreaseResourcesInTurn(int player_num)
 {
   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;
@@ -1513,8 +1508,7 @@
 
 //----- (0040A383) --------------------------------------------------------
 void TurnChange()
-    {
-
+{
   char player_name[64]; // [sp+4h] [bp-64h]@4
  // RECT v6; // [sp+44h] [bp-24h]@6
  
@@ -1535,11 +1529,11 @@
       //nullsub_1();
    //   v11.x = 0;
    //   v11.y = 0;
-      strcpy(player_name,"The Next Player is: ");//""
+      strcpy(player_name, "The Next Player is: ");//""
      // v0 = 0;
       v11.y = 200;
       v11.x = 320; // - 12 * v0 / 2;
-      pPrimaryWindow_draws_text(-1, player_name, &v11);
+      am_DrawText(-1, player_name, &v11);
       am_byte_4FAA75 = 1;
       ++current_player_num;
       if ( current_player_num >= 2  )
@@ -1548,13 +1542,13 @@
      // v4 = 0;
       v11.y = 260;
       v11.x = 320;// - 12 * v4 / 2;
-      pPrimaryWindow_draws_text(-1, player_name, &v11);
+      am_DrawText(-1, player_name, &v11);
      /* v6.left = 0;
       v6.right = 640;
       v6.top = 0;
       v6.bottom = 480;*/
       //nullsub_1();
-      CallRenderPresent();
+      pRenderer->Present();
       //nullsub_1();
       while ( 1 )
       {  
@@ -1583,7 +1577,7 @@
       v6.top = 0;
       v6.bottom = 480;*/
       //nullsub_1();
-      CallRenderPresent();
+      pRenderer->Present();
     }
   }
 }
@@ -1591,7 +1585,7 @@
 
 //----- (0040A514) --------------------------------------------------------
 bool IsGameOver()
-    {
+{
   bool result; // eax@1
 
   result = false;
@@ -1606,10 +1600,8 @@
       ||  am_Players[i].resource_beasts >= max_resources_amount )
       result  = true;
   }
- 
-  if ( result )
-    byte_4FAA2C = 1;
-  return result;
+
+  return am_gameover = result;
 }
 
 
@@ -1649,7 +1641,7 @@
       }
       while (v3 < 6);
     
-    pArcomageGame->event_timer_time = (unsigned int )pEventTimer->Time();
+    pArcomageGame->event_timer_time = (unsigned int)pEventTimer->Time();
     if ( pArcomageGame->field_F4 )
       break_loop = 1;
     ArcomageGame::MsgLoop(0, &a2);
@@ -1834,8 +1826,7 @@
 
 //----- (0040A9AF) --------------------------------------------------------
 void DrawGameUI( int animation_stage )
-    {
-
+{
   am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1);
   DrawRectanglesForText();
   am_EndScene();
@@ -1880,9 +1871,9 @@
                  if (array_4FABD0[i].effect_sparks[j].have_spark > 0)
                      {
                       if (j%2)
-                           SetPixel(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color);
+                          DrawPixel(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color);
                       else
-                          SetPixel2sq(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color);
+                          DrawSquare(&array_4FABD0[i].effect_sparks[j].spark_position, pixel_color);
                      }
                  }
             }
@@ -1892,10 +1883,10 @@
 
 //----- (0040AB0A) --------------------------------------------------------
 void DrawRectanglesForText()
-    {
- 
+{ 
   RECT pSrcRect; // [sp+Ch] [bp-18h]@1
   POINT pTargetXY; // [sp+1Ch] [bp-8h]@1
+
 //resources rectangles
   pSrcRect.left    = 765;
   pSrcRect.top     = 0;
@@ -1963,46 +1954,46 @@
     strcpy(text_buff, pGlobalTXT_LocalizationStrings[266]);// 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);
+    am_DrawText(-1, text_buff, &text_position);
   }
   strcpy( text_buff, am_Players[0].pPlayerName);
   if ( !current_player_num )
     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);
+  am_DrawText(-1, text_buff, &text_position);
 
   strcpy(text_buff, am_Players[1].pPlayerName);
   if ( current_player_num == 1 )
     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);
+  am_DrawText(-1, text_buff, &text_position);
+
+  am_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);
+  am_DrawText(-1, text_buff, &text_position);
+
+  am_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);
+  am_DrawText(-1, text_buff, &text_position);
+
+  am_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);
+  am_DrawText(-1, text_buff, &text_position);
+
+  am_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);
+  am_DrawText(-1, text_buff, &text_position);
 
   res_value = am_Players[0].quarry_level;
   if ( use_start_bonus )
     res_value =am_Players[0].quarry_level + quarry_bonus;
-  intToString(res_value, text_buff);
+  am_IntToString(res_value, text_buff);
   text_position.x = 14;// - 6 * 0 / 2;
   text_position.y = 92;
   DrawPlayerLevels(-1, text_buff, &text_position);
@@ -2010,7 +2001,7 @@
   res_value = am_Players[1].quarry_level;
   if ( use_start_bonus )
     res_value = am_Players[1].quarry_level + quarry_bonus;
-  intToString(res_value, text_buff);
+  am_IntToString(res_value, text_buff);
 //  v2 = 0;
   text_position.y = 92;
   text_position.x = 561; //- 6 * v2 / 2;
@@ -2019,7 +2010,7 @@
   res_value = am_Players[0].magic_level;
   if ( use_start_bonus )
     res_value = am_Players[0].magic_level + magic_bonus;    
-  intToString(res_value, text_buff);
+  am_IntToString(res_value, text_buff);
  // v4 = 0;
   text_position.y = 164;
   text_position.x = 14; //- 6 * v4 / 2;
@@ -2028,7 +2019,7 @@
   res_value = am_Players[1].magic_level;
   if ( use_start_bonus )
     res_value = am_Players[1].magic_level + magic_bonus;
-  intToString(res_value, text_buff);
+  am_IntToString(res_value, text_buff);
  // v6 = 0;
   text_position.y = 164;
   text_position.x = 561; //- 6 * v6 / 2;
@@ -2037,7 +2028,7 @@
   res_value = am_Players[0].zoo_level;
   if ( use_start_bonus )
     res_value = am_Players[0].zoo_level + zoo_bonus;
-  intToString(res_value, text_buff);
+  am_IntToString(res_value, text_buff);
  // v8 = 0;
   text_position.y = 236;
   text_position.x = 14;// - 6 * v8 / 2;
@@ -2046,38 +2037,38 @@
   res_value = am_Players[1].zoo_level;
   if ( use_start_bonus )
     res_value =  am_Players[1].zoo_level + zoo_bonus;
-  intToString(res_value, text_buff);
+  am_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);
+  am_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);
+  am_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);
+  am_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);
+  am_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);
+  am_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);
+  am_IntToString(am_Players[1].resource_beasts, text_buff);
   text_position.x = 557;
   text_position.y = 258;
   DrawBeastsCount(-1, text_buff, &text_position);
@@ -2344,7 +2335,7 @@
 int v16; // ecx@25
 POINT *v17; // esi@26
 signed int v18; // eax@29
-Acromage_st1 *v19; // ecx@29
+AcromageCardOnTable *v19; // ecx@29
 int v20; // ecx@31
 int v21; // [sp-4h] [bp-2Ch]@8
 RECT pSrcXYZW; // [sp+Ch] [bp-1Ch]@8
@@ -2475,7 +2466,7 @@
 RECT *v6; // ecx@6
 
 int v8; // eax@15
-Acromage_st1 *v9; // ecx@15
+AcromageCardOnTable *v9; // ecx@15
 int v10; // ecx@19
 int v11; // eax@20
 int v12; // ecx@20
@@ -2702,9 +2693,7 @@
 
 //----- (0040BB67) --------------------------------------------------------
 signed int DrawCardsRectangles( int player_num )
-    {
-//need do fix rectangle not fit to card
-
+{
 //int v1; // esi@1
 signed int result; // eax@1
 int v3; // ebx@1
@@ -2738,6 +2727,7 @@
 char v32; // [sp+45h] [bp-3h]@12
 char v33; // [sp+46h] [bp-2h]@12
 
+__debugbreak(); // need do fix rectangle not fit to card
 
 v30 = 0;
 result = -1;
@@ -2900,9 +2890,8 @@
 
 
 //----- (0040BE0E) --------------------------------------------------------
-bool PlayCard( int player_num, signed int card_slot_num )
-    {
-
+bool PlayCard( int player_num, int card_slot_num )
+{
   int v3; // ebp@1
   int v4; // ecx@2
   ArcomagePlayer *v5; // esi@2
@@ -2962,8 +2951,8 @@
 }
 
 //----- (0040BF15) --------------------------------------------------------
-bool CanCardBePlayed( int player_num, int hand_card_indx )
-    {
+bool CanCardBePlayed(int player_num, int hand_card_indx)
+{
   bool result; // eax@1
   ArcomageCard *test_card; // ecx@1
   ArcomagePlayer *pPlayer; // esi@1
@@ -2975,7 +2964,7 @@
     result = false;
   if ( test_card->needed_magic_level > pPlayer->magic_level )
     result = false;
-  if ( test_card->needed_might_level > pPlayer->zoo_level )
+  if ( test_card->needed_zoo_level > pPlayer->zoo_level )
     result = false;
   if ( test_card->needed_bricks > pPlayer->resource_bricks )
     result = false;
@@ -3766,7 +3755,7 @@
  // v2 = 0;
   xy.y = 160;
   xy.x = 320; //- 12 * v2 / 2;
-//  pPrimaryWindow_draws_text(-1, pText, xy);
+//  am_DrawText(-1, pText, xy);
   if ( am_Players[0].tower_height < max_tower_height )
   {
     if ( am_Players[1].tower_height < max_tower_height )
@@ -4001,20 +3990,20 @@
   am_EndScene();
   pRenderer->Present();
   ArcomageGame::LoadSprites();
-  CallRenderPresent();
+  pRenderer->Present();
 
   v4 = 120;
   for (int i=0; i<12; ++i)
     am_sounds[i] = pSoundList->LoadSound(v4++, 0);
 
   for (int i=0; i<10; ++i)
-     stru272_stru0::Ctor(&array_4FABD0[i].field_40);
+     array_4FABD0[i].field_40 = stru272_stru0::New();
   
   current_card_slot_index = -1;
   amuint_4FAA4C = -1;
   byte_4FAA74 = 0;
   pArcomageGame->field_F4 = 0;
-  byte_4FAA2C = 0;
+  am_gameover = false;
   byte_505880 = 0;
   dword_4FAA70 = 0;
   need_to_discard_card = 0;
@@ -4066,7 +4055,7 @@
 
 
 //----- (0040D75D) --------------------------------------------------------
-void pPrimaryWindow_draws_text( int a1, const char *pText, POINT *pXY )
+void am_DrawText( int a1, const char *pText, POINT *pXY )
     {
     pPrimaryWindow->DrawText( pFontComic, pXY->x, pXY->y - ((pFontComic->uFontHeight - 3) >> 1) + 3, 0, pText, 0, 0, 0);
     }
@@ -4095,7 +4084,7 @@
     pRenderer->EndScene();
     }
 
-void SetPixel2sq( POINT *pTargetXY, unsigned __int16 uColor )
+void DrawSquare( POINT *pTargetXY, unsigned __int16 uColor )
     {
     pRenderer->BeginScene();
     if ( pRenderer->uNumSceneBegins )
@@ -4114,7 +4103,7 @@
     }
 
 //----- (0040DBD3) --------------------------------------------------------
-void SetPixel( POINT *pTargetXY, unsigned __int16 uColor )
+void DrawPixel( POINT *pTargetXY, unsigned __int16 uColor )
     {
     pRenderer->BeginScene();
     if ( pRenderer->uNumSceneBegins )
@@ -4138,9 +4127,9 @@
 
 
 //----- (0040DEC8) --------------------------------------------------------
-void __fastcall intToString(int val, char *pOut)
+void __fastcall am_IntToString(int val, char *pOut)
     {
-    sprintf(pOut, "%d", val);
+    sprintfex(pOut, "%d", val);
     }
 
 void set_stru1_field_8_InArcomage(int inValue)