diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-09-14 16:56:32 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-09-14 16:56:32 +0800 |
commit | 72ce5c9c93b1bfa98ee8ea9affad7f607f9fa5c4 (patch) | |
tree | c7b7f7fe0f1a80654317591fa3ec3f8ce91a3451 | |
parent | 3fd7b4b87999ef752ca3b2fd1c5b9d045a1df449 (diff) | |
download | rich4-72ce5c9c93b1bfa98ee8ea9affad7f607f9fa5c4.tar.xz |
consume_a_card, rename more variables
-rw-r--r-- | csrc/cards.c | 58 | ||||
-rw-r--r-- | csrc/cards_ui.c | 4 | ||||
-rw-r--r-- | csrc/game_init.c | 7 | ||||
-rw-r--r-- | csrc/global.h | 3 | ||||
-rw-r--r-- | csrc/loadsave.c | 4 |
5 files changed, 50 insertions, 26 deletions
diff --git a/csrc/cards.c b/csrc/cards.c index f58a9eb..f05b831 100644 --- a/csrc/cards.c +++ b/csrc/cards.c @@ -9,7 +9,7 @@ card_func card_functions[] = { // 0x475d5c buy_land_card, swap_land_card, swap_house_card, - turn_back_card, + turn_back_card, 0x0044309bU, 0x00443225U, 0x004434c0U, 0x004436e0U, 0x00443917U, 0x00443b0fU, 0x00443e3dU, 0x00443f80U, 0x004440eaU, 0x004441dcU, 0x004444bfU, 0x004420d5U, 0x004420d5U, @@ -19,13 +19,35 @@ card_func card_functions[] = { // 0x475d5c }; +uint8_t card_amount[30]; /* 0x499198 */ + +void consume_a_card(int p, int c) +{ + int i = 0; + + while (1) { + int card = player_cards[p*15+i]; + if (card != c) { + i++; + if (i >= 15) + return; + } else { + break; + } + } + + memcpy(&player_cards[p*15+i], &player_cards[p*15+i+1], 14-i); + player_cards[p * 15 + 14] = 0; + card_amount[c-1]++; +} + // 0x4420d8 int average_cash_card() { int sum = 0; int player_count = 0; - fcn.00441343(current_player, 1); + consume_a_card(current_player, 1); eax = (int)players[current_player].character * 360; mov ebx, dword [eax + 0x48123a] ; fcn.0044ef41(current_player, 3, ebx); @@ -65,7 +87,7 @@ int average_cash_card2() if (result == 0) return 0; - fcn.00441343(current_player, 2); + consume_a_card(current_player, 2); eax = players[current_player].character * 360; edi = dword [eax + 0x48123e]; fcn.0044ef41(current_player, 3, edi); @@ -111,7 +133,7 @@ int buy_land_card() cl = byte [ebx + 0x19]; if (cl == 0 || cl == current_player+1) { if (esi != 0) { - fcn.00441343(current_player, 3); + consume_a_card(current_player, 3); } return esi; } @@ -124,7 +146,7 @@ int buy_land_card() if (edi > players[current_player].cash) { fcn.00440cac(0x46530c, 1500); if (esi != 0) { - fcn.00441343(current_player, 3); + consume_a_card(current_player, 3); } return esi; } @@ -161,7 +183,7 @@ int buy_land_card() edx = dword [eax + 0x481332]; fcn.0044ef41(esi, 1, edx); fcn_41d546(); - fcn.00441343(current_player, 3); + consume_a_card(current_player, 3); return 1; } // 4424be @@ -212,7 +234,7 @@ int buy_land_card() edx = dword [eax + 0x481332]; fcn.0044ef41(esi, 1, edx); fcn_41d546(); - fcn.00441343(current_player, 3); + consume_a_card(current_player, 3); return 1; } fcn.00440cac(0x46530c, 1500); @@ -220,7 +242,7 @@ int buy_land_card() } } if (esi != 0) { - fcn.00441343(current_player, 3); + consume_a_card(current_player, 3); } return esi; } @@ -304,7 +326,7 @@ int swap_land_card() fcn.0044ef41(edx, 2, ecx); } } - fcn.00441343(current_player, 4); + consume_a_card(current_player, 4); fcn_41d546(); return 1; } @@ -367,7 +389,7 @@ int swap_land_card() eax = edx * 360; ebx = dword [eax + 0x481336]; fcn.0044ef41(ecx, 2, ebx); - fcn.00441343(current_player, 4); + consume_a_card(current_player, 4); fcn_41d546(); return 1; } else { @@ -379,7 +401,7 @@ int swap_land_card() ecx = dword [eax + 0x481336]; fcn.0044ef41(ebx, 2, ecx); } - fcn.00441343(current_player, 4); + consume_a_card(current_player, 4); fcn_41d546(); return 1; } @@ -387,7 +409,7 @@ int swap_land_card() } // 442ade if (ebx != 0) { - fcn.00441343(current_player, 4); + consume_a_card(current_player, 4); fcn_41d546(); } return ebx; @@ -469,7 +491,7 @@ int swap_house_card() } } } - fcn.00441343(current_player, 5); + consume_a_card(current_player, 5); fcn_41d546(); return 1; } @@ -526,13 +548,13 @@ int swap_house_card() eax = players[esi].character * 360; edi = dword [eax + 0x48133a]; fcn.0044ef41(esi, 2, edi); - fcn.00441343(current_player, 5); + consume_a_card(current_player, 5); fcn_41d546(); return 1; } eax = current_player + 1; if (edi == eax || edi == 0 || esi != eax) { - fcn.00441343(current_player, 5); + consume_a_card(current_player, 5); fcn_41d546(); return 1; } @@ -545,14 +567,14 @@ int swap_house_card() esi = dword [eax + 0x48133a]; fcn.0044ef41(edi , 2, esi); } - fcn.00441343(current_player, 5); + consume_a_card(current_player, 5); fcn_41d546(); return 1; } } // 442f29 if (ebx != 0) { - fcn.00441343(current_player, 5); + consume_a_card(current_player, 5); fcn_41d546(); } return ebx; @@ -567,7 +589,7 @@ int turn_back_card() } ebx = eax; if (ebx != 0) { - fcn.00441343(current_player, 6); + consume_a_card(current_player, 6); esi = players[current_player].character; eax = esi * 360; edi = dword [eax + 0x48124e]; diff --git a/csrc/cards_ui.c b/csrc/cards_ui.c index 354db72..cedcac2 100644 --- a/csrc/cards_ui.c +++ b/csrc/cards_ui.c @@ -9,7 +9,7 @@ const char str_use[] = "\xa8\xcf\xa5\xce%s"; // 使用%s typedef struct { const char *name_ptr; - uint8_t f4; + uint8_t init_amount; uint8_t price; uint8_t f6; uint8_t f7; @@ -198,7 +198,7 @@ void cards_ui() eax = current_player * 15; edx = esi; esi++; - al = [edx + eax + 0x499120]; + al = player_cards[edx + eax]; mem[ebx] = al; if (edi <= 8 || esi != edi) continue; diff --git a/csrc/game_init.c b/csrc/game_init.c index bb19c7d..27767cc 100644 --- a/csrc/game_init.c +++ b/csrc/game_init.c @@ -123,11 +123,10 @@ int init_new_game(int a0) nplayers = dw_46cb3c + 2; dw_499104 = current_player = 0; game_initial_fund = initial_fund[dw_46cb40]; - memset(0x499120, 0, 60); + memset(player_cards, 0, 60); memset(tool_amount, 0, 60); - for (ebx = 0; ebx < 30; ebx++) { - al = byte [ebx*8 + 0x47fdf6]; - byte [ebx + 0x499198] = al; + for (int i = 0; i < 30; i++) { + card_amount[i] = cards_table[i+1].init_amount; } for (ebx = 0; ebx < 8; ebx++) { al = byte [ebx*8 + 0x47fee6]; diff --git a/csrc/global.h b/csrc/global.h index 7f71d02..52ebe5f 100644 --- a/csrc/global.h +++ b/csrc/global.h @@ -25,3 +25,6 @@ extern HWND gwindowHandle; // 48a0d4 extern RECT g_rect; /* struct tagRECT { left, top, right, bottom } @ 0x46cadc */ typedef LRESULT (CALLBACK *wProc)(HWND, UINT, WPARAM, LPARAM); extern wProc windowCallbacks[100]; // 48a010 + +/* card.c */ +extern uint8_t card_amount[30]; diff --git a/csrc/loadsave.c b/csrc/loadsave.c index 1aa2b7a..af143ea 100644 --- a/csrc/loadsave.c +++ b/csrc/loadsave.c @@ -308,9 +308,9 @@ int load_checkpoint(int n) fread(0x498e28, 0x10, 5, fp); fread(0x496d08, 0x18, 0x2e, fp); - fread(0x499120, 1, 0x3c, fp); + fread(player_cards, 1, 0x3c, fp); fread(tool_amount, 1, 0x3c, fp); - fread(0x499198, 1, 0x1e, fp); + fread(card_amount, 1, 30, fp); fread(0x497320, 1, 8, fp); fread(0x499100, 4, 1, fp); fread(0x497328, 4, 0x6c0, fp); |