Mercurial > mm7
diff Arcomage.cpp @ 1209:decc0dd6e4ba
more on arcomage
author | Gloval |
---|---|
date | Sun, 09 Jun 2013 13:20:34 +0400 |
parents | 4d90f0591add |
children | 68655becb94b eb687c8529ee |
line wrap: on
line diff
--- a/Arcomage.cpp Sun Jun 09 01:41:55 2013 +0200 +++ b/Arcomage.cpp Sun Jun 09 13:20:34 2013 +0400 @@ -43,9 +43,9 @@ 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 DrawPlayersTowers(); +void DrawPlayersWall(); +void DrawCards(); void __fastcall am_40B76F(int a1); int GetPlayerHandCardCount(int player_num); signed int DrawCardsRectangles(int player_num); @@ -65,8 +65,6 @@ void __fastcall DrawRect(RECT *pXYZW, unsigned __int16 uColor, char bSolidFill); // idb void SetPixel(POINT *pTargetXY, unsigned __int16 uColor); int __fastcall rand_interval(int a, int b); // idb -char *__fastcall inv_strcat(const char *Source, char *Dest); -char *__fastcall inv_strcpy(const char *Source, char *Dest); void __fastcall intToString(int val, char *pOut); /* 388 */ @@ -109,7 +107,7 @@ ArcomageGame *pArcomageGame = new ArcomageGame; ArcomagePlayer am_Players[2]; -Acromage_st1 shown_cards[10]; +Acromage_st1 shown_cards[10]; //amuint_4FAA78; // weak stru272 array_4FABD0[10]; @@ -165,7 +163,8 @@ char am_byte_4FAA77; // weak signed int current_card_slot_index; -unsigned int played_card_id; // idb +int played_card_id; // idb 4FABC0 +int uCardID; // idb 4FAA50 int deck_walk_index; @@ -173,6 +172,15 @@ int start_gems_amount; int start_beasts_amount; +POINT amuint_4FAA3C_blt_xy; +POINT am_uint_4FAA44_blt_xy; +POINT amuint_4FAA54_blt_xy; +POINT amuint_4FAA5C_blt_xy; + + + +int dword_4FABB8; // weak + //----- (0040DD2F) -------------------------------------------------------- bool stru273::_40DD2F() @@ -1660,7 +1668,6 @@ } } - // inv_strcpy(pDeckMaster, byte_5054C8); strcpy(deckMaster.name, pDeckMaster); for (i=0, card_dispenser_counter=-2, card_id_counter=0; i<DECK_SIZE; ++i, ++card_dispenser_counter) { @@ -1855,7 +1862,7 @@ //nullsub_1(); v11.x = 0; v11.y = 0; - inv_strcpy("След", Dest); + // inv_strcpy("След", Dest); v0 = 0; v11.y = 200; v11.x = 320 - 12 * v0 / 2; @@ -1869,7 +1876,7 @@ v1 = 0; current_player_num = 0; } - inv_strcpy(am_Players[v1].pPlayerName, Dest); + strcpy(Dest, am_Players[v1].pPlayerName); v4 = 0; v11.y = 260; v11.x = 320 - 12 * v4 / 2; @@ -2111,8 +2118,8 @@ { //nullsub_1(); //nullsub_1(); - assert(false && "Invalid strcpy params"); - inv_strcpy(nullptr, Dest); + // assert(false && "Invalid strcpy params"); + // inv_strcpy(nullptr, Dest); v5 = 0;//unk::const_0(&unk_4E19FC, 0); //nullsub_1(); if ( v5 == 1 ) @@ -2128,11 +2135,11 @@ v10[3] = 480;*/ //nullsub_1(); } - /* if ( dword_4FABB8 != am_40BB67(a1) ) + if ( dword_4FABB8 != DrawCardsRectangles(player_num) ) { - dword_4FABB8 = am_40BB67(a1); + dword_4FABB8 = DrawCardsRectangles(player_num); pArcomageGame->field_F6 = 1; - }*/ + } if ( pArcomageGame->field_F6 ) { DrawGameUI(v13); @@ -2169,7 +2176,7 @@ am_EndScene(); am_BeginScene(pArcomageGame->pSpritesPixels, -1, 1); - am_40B4B9(); + DrawCards(); DrawPlayersTowers(); DrawPlayersWall(); DrawPlayersText(); @@ -2301,21 +2308,21 @@ if ( am_byte_4FAA77 ) { - inv_strcpy(pGlobalTXT_LocalizationStrings[266], text_buff);// DISCARD A CARD + 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); } - inv_strcpy(am_Players[0].pPlayerName, text_buff); + strcpy( text_buff, am_Players[0].pPlayerName); if ( !current_player_num ) - inv_strcat("***", text_buff); + 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); + strcpy(text_buff, am_Players[1].pPlayerName); if ( current_player_num == 1 ) - inv_strcat("***", text_buff); + 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); @@ -2667,8 +2674,8 @@ } //----- (0040B4B9) -------------------------------------------------------- -void __cdecl am_40B4B9() -{ +void DrawCards() + { int v0; // esi@1 char v1; // bl@1 @@ -2811,6 +2818,234 @@ //----- (0040B76F) -------------------------------------------------------- void __fastcall am_40B76F(int a1) { + +int v1; // eax@3 +int v2; // eax@3 +int v3; // esi@4 +int v4; // eax@4 +POINT *v5; // edx@6 +RECT *v6; // ecx@6 +Acromage_st1 *v7; // ebx@11 +int v8; // eax@15 +Acromage_st1 *v9; // ecx@15 +int v10; // ecx@19 +int v11; // eax@20 +int v12; // ecx@20 +int v13; // eax@20 +unsigned int v14; // ecx@21 +double v15; // st7@22 +POINT *v16; // edx@23 +int v17; // eax@32 +char v18; // zf@37 +int v19; // eax@41 +int v20; // eax@46 +int v21; // ecx@46 +int v22; // eax@46 +int v23; // [sp-4h] [bp-2Ch]@28 +RECT pSrcXYZW; // [sp+Ch] [bp-1Ch]@6 +POINT pTargetXY; // [sp+1Ch] [bp-Ch]@20 +int v26; // [sp+24h] [bp-4h]@1 + +v26 = a1; +if ( amuint_4FAA4C != -1 ) + { + if ( amuint_4FAA38 >= 9 ) + { + am_uint_4FAA44_blt_xy.y = 18; + am_uint_4FAA44_blt_xy.x = 120; + v1 = GetPlayerHandCardCount(current_player_num); + v2 = (640 - 96 * v1) / v1 + 96; + if ( am_byte_4E185D ) + { + // v3 = 188 * current_player_num + 8 * amuint_4FAA4C; + // amuint_4FAA3C_blt_xy.x = (amuint_4FAA4C * v2 + *(am_Players[0].arr_6C[0] + v3) - 120) / 10; + amuint_4FAA3C_blt_xy.x=(amuint_4FAA4C * v2 + am_Players[current_player_num].arr_6C[amuint_4FAA4C].field_0-120)/10; + v4 = (am_Players[current_player_num].arr_6C[amuint_4FAA4C].field_4+309) /10;//(*(&am_Players[0].arr_6C[0][1] + v3) + 309) / 10; + } + else + { + amuint_4FAA3C_blt_xy.x = (amuint_4FAA4C * v2 - 120) / 10; + v4 = 30; + } + am_uint_4FAA44_blt_xy.y += v4; + am_uint_4FAA44_blt_xy.x += amuint_4FAA3C_blt_xy.x; + pSrcXYZW.top = 0; + amuint_4FAA3C_blt_xy.y = v4; + pSrcXYZW.left = 192; + pSrcXYZW.right = 288; + pSrcXYZW.bottom = 128; + v5 = &am_uint_4FAA44_blt_xy; + v6 = &pSrcXYZW; + Blt_Copy(v6, v5, 2); + goto LABEL_11; + } + pSrcXYZW.top = 0; + v6 = &pSrcXYZW; + v5 = &am_uint_4FAA44_blt_xy; + pSrcXYZW.bottom = 128; + pSrcXYZW.right = 288; + pSrcXYZW.left = 192; + if ( amuint_4FAA38 ) + { + am_uint_4FAA44_blt_xy.x += amuint_4FAA3C_blt_xy.x; + am_uint_4FAA44_blt_xy.y += amuint_4FAA3C_blt_xy.y; + Blt_Copy(v6, v5, 2); + goto LABEL_11; + } + am_uint_4FAA44_blt_xy.x += amuint_4FAA3C_blt_xy.x; + am_uint_4FAA44_blt_xy.y += amuint_4FAA3C_blt_xy.y; + Blt_Copy(&pSrcXYZW, &am_uint_4FAA44_blt_xy, 2); + amuint_4FAA4C = -1; + } +LABEL_11: +v7 = shown_cards; +if ( uCardID != -1 ) + { + if ( v26 <= 10 ) + { + if ( v26 == 10 ) + { + pArcomageGame->GetCardRect(uCardID, &pSrcXYZW); + // v8 = 0; + for (v8=0; v8<10; ++v8) + { + if (shown_cards[v8].uCardId==-1) + { + shown_cards[v8].uCardId = uCardID; + shown_cards[v8].field_4 = 1; + break; + } + } + /* v9 = shown_cards; + while ( v9->uCardId != -1 ) + { + ++v9; + ++v8; + if ( v9 >= &dword_4FABB8 ) + goto LABEL_20; + } + + v10 = v8; + shown_cards[v10].uCardId = uCardID; + shown_cards[v10].field_4 = 1;*/ +//LABEL_20: + pTargetXY.x = shown_cards[v8].field_8.x; + pTargetXY.y = shown_cards[v8].field_8.y; + Blt_Copy(&pSrcXYZW, &pTargetXY, 0); + uCardID = -1; + } + } + else + { + pArcomageGame->GetCardRect(uCardID, &pSrcXYZW); + amuint_4FAA5C_blt_xy.x += amuint_4FAA54_blt_xy.x; + amuint_4FAA5C_blt_xy.y += amuint_4FAA54_blt_xy.y; + Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 0); + } + } +v14 = played_card_id; +if ( played_card_id != -1 ) + { + v15 = v26; + if ( v15 > 15.0 ) + { + pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); + v16 = &amuint_4FAA5C_blt_xy; + amuint_4FAA5C_blt_xy.x += amuint_4FAA54_blt_xy.x; + amuint_4FAA5C_blt_xy.y += amuint_4FAA54_blt_xy.y; + Blt_Copy(&pSrcXYZW, v16, 2); + return; + } + if ( v15 == 15.0 ) + { + am_40BF77(current_player_num, played_card_id); + pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); + pTargetXY.x = 272; + pTargetXY.y = 173; + Blt_Copy(&pSrcXYZW, &pTargetXY, 2); + return; + } + if ( v15 == 5.0 ) + { + amuint_4FAA5C_blt_xy.x = 272; + amuint_4FAA5C_blt_xy.y = 173; + for (v17=0; v17<10; ++v17) + { + if (shown_cards[v17].uCardId==-1) + break; + } + /* v17 = 0; + do + { + if ( v7->uCardId == -1 ) + break; + ++v7; + ++v17; + } + while ( v7 < &dword_4FABB8 );*/ + // v26 = 32 * v17; + + amuint_4FAA54_blt_xy.x = (shown_cards[v17].field_8.x - 272) / 5; + amuint_4FAA54_blt_xy.y = (shown_cards[v17].field_8.y - 173) / 5; + pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); + pTargetXY.x = 272; + pTargetXY.y = 173; + Blt_Copy(&pSrcXYZW, &pTargetXY, 2); + return; + } + if ( v15 >= 5.0 ) + { + v18 = v26 == 0; + } + else + { + v18 = v26 == 0; + if ( v26 > 0 ) + { + pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); + amuint_4FAA5C_blt_xy.x += amuint_4FAA54_blt_xy.x; + amuint_4FAA5C_blt_xy.y += amuint_4FAA54_blt_xy.y; + Blt_Copy(&pSrcXYZW, &amuint_4FAA5C_blt_xy, 0); + return; + } + } + if ( !v18 ) + { + + pArcomageGame->GetCardRect(v14, &pSrcXYZW); + pTargetXY.x = 272; + pTargetXY.y = 173; + Blt_Copy(&pSrcXYZW, &pTargetXY, 2); + return; + } + pArcomageGame->GetCardRect(played_card_id, &pSrcXYZW); + for (v19=0; v19<10; ++v19) + { + if (shown_cards[v19].uCardId==-1) + { + shown_cards[v19].uCardId = played_card_id; + break; + } + + } + /* v19 = 0; + while ( v7->uCardId != -1 ) + { + ++v7; + ++v19; + if ( v7 >= &dword_4FABB8 ) + goto LABEL_46; + } + shown_cards[v19].uCardId = played_card_id; + LABEL_46:*/ + + pTargetXY.x = shown_cards[v19].field_8.x; + pTargetXY.y = shown_cards[v19].field_8.y; + Blt_Copy(&pSrcXYZW, &pTargetXY, 0); + played_card_id = -1; + } + + // int v1; // eax@3 // int v2; // eax@3 // int v3; // esi@4 @@ -3342,9 +3577,8 @@ int i; if ( card_slot_index <= -1 ) - return 0; + return false; v2 = 0; - v3 = 0; for(i=0; i<10; ++i) { @@ -3358,42 +3592,32 @@ if ( pCards[am_Players[player_num].cards_at_hand[i]].field_2B) { - ArcomageGame::PlaySound(0x16u); - v7 = current_player_num; + ArcomageGame::PlaySound(22); 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; - amuint_4FAA5C_blt_xy[0] = v10; - amuint_4FAA5C_blt_xy[1] = v11; + v10=am_Players[player_num].arr_6C[i].field_0 + (640 - 96 * v8) / (v8 + 1); + amuint_4FAA5C_blt_xy.x = v10; + amuint_4FAA5C_blt_xy.y = am_Players[player_num].arr_6C[i].field_4 + 327;//v11; v12 = 0; + if ( !am_byte_4FAA75 ) { - v13 = (signed int)amuint_4FAA78.data(); - do - { - if ( *(unsigned int *)v13 == -1 ) - break; - v13 += 32; - ++v12; - } - while ( v13 < (signed int)&dword_4FABB8 ); + for (v12=0; v12<10; ++v12) + { + if (shown_cards[v12].uCardId== -1) + break; + } } pArcomageGame->field_F6 = 1; - amuint_4FAA54_blt_xy[0] = (amuint_4FAA80[8 * v12] - v10) / 10; - amuint_4FAA54_blt_xy[1] = (amuint_4FAA84[8 * v12] - 327) / 10; - v14 = *(unsigned int *)v6; - *(unsigned int *)v6 = -1; + amuint_4FAA54_blt_xy.x = (shown_cards[v12].field_8.x - v10) / 10; + amuint_4FAA54_blt_xy.y = (shown_cards[v12].field_8.y - 327) / 10; + + uCardID = am_Players[player_num].cards_at_hand[i]; + am_Players[player_num].cards_at_hand[i] = -1; am_byte_4FAA77 = 0; - uCardID = v14; - result = 1; + return true; } else - { - - result = 0; - } - return result; + return false; } // 4FAA75: using guessed type char am_byte_4FAA75; // 4FAA77: using guessed type char am_byte_4FAA77; @@ -3421,42 +3645,35 @@ int v15; // ecx@8 int v16; // ecx@8 - v3 = player_num; if ( card_slot_num <= -1 ) return false; v4 = 0; - v5 = &am_Players[v3]; - v6 = 0; - v7 = (int)v5->cards_at_hand; - do + + for (v6=0; v6<10; ++v6) { - if ( *(unsigned int *)v7 != -1 ) + if ( am_Players[player_num].cards_at_hand[v6] != -1 ) { if ( card_slot_num == v4 ) break; ++v4; } - ++v6; - v7 += 4; } - while ( v6 < 10 ); + result = CanCardBePlayed(player_num, v6); if ( result ) { - ArcomageGame::PlaySound(0x17u); - v8 = current_player_num; + ArcomageGame::PlaySound(23); v9 = GetPlayerHandCardCount(current_player_num); - v10 = 188 * v8 + 8 * v6; - v11 = v6 + 47 * v3; - + // v10 = 188 * v8 + 8 * v6; + // v11 = v6 + 47 * v3; pArcomageGame->field_F6 = 1; //v12 = 96 * v6 + *(int *)((char *)am_Players[0].arr_6C[0] + v10) + (640 - 96 * v9) / (v9 + 1); // v13 = *(int *)((char *)&am_Players[0].arr_6C[0][1] + v10) + 327; - amuint_4FAA5C_blt_xy[0] = v12; - amuint_4FAA5C_blt_xy[1] = v13; - - amuint_4FAA54_blt_xy[0] = (272 - v12) / 5; - amuint_4FAA54_blt_xy[1] = -30; + amuint_4FAA5C_blt_xy.x = am_Players[player_num].arr_6C[v6].field_0 + (640 - 96 * v9) / (v9 + 1);//v12; + amuint_4FAA5C_blt_xy.y = am_Players[player_num].arr_6C[v6].field_4 + 327;//v13; + + amuint_4FAA54_blt_xy.x = (272 - v12) / 5; + amuint_4FAA54_blt_xy.y = -30; v14 = &pCards[v5->cards_at_hand[v6]]; v5->resource_bricks -= v14->needed_bricks; @@ -5549,14 +5766,17 @@ { result = a2; v2->wall_height = a2 + v3; - goto LABEL_7; + } + else + { a2 += v3; result = -v3; v2->wall_height = 0; + v2->tower_height += a2; + } } - v2->tower_height += a2; -LABEL_7: + if ( v2->tower_height < 0 ) v2->tower_height = 0; return result; @@ -5588,7 +5808,7 @@ //nullsub_1(); xy[0] = 0; xy[1] = 0; - inv_strcpy("Победи", pText); + // inv_strcpy("Победи", pText); v2 = 0; xy[1] = 160; xy[0] = 320 - 12 * v2 / 2; @@ -5956,17 +6176,6 @@ return a + rand() % (b - a + 1); } -//----- (0040DEB4) -------------------------------------------------------- -char *__fastcall inv_strcat(const char *Source, char *Dest) - { - return strcat(Dest, Source); - } - -//----- (0040DEBE) -------------------------------------------------------- -char *__fastcall inv_strcpy(const char *Source, char *Dest) - { - return strcpy(Dest, Source); - } //----- (0040DEC8) -------------------------------------------------------- void __fastcall intToString(int val, char *pOut)