summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-10-19 13:16:47 +0800
committerIru Cai <mytbk920423@gmail.com>2018-10-19 13:30:42 +0800
commit2238a765662751843a7416cedb31c6c36e27aae5 (patch)
treed736f0353986ae5075909125bbcb478bb75ea3c3
parent439d0375604873ecc7ba38d0d88197c035ffe833 (diff)
downloadrich4-2238a765662751843a7416cedb31c6c36e27aae5.tar.xz
hlands, blands rewrite
-rw-r--r--csrc/cards.c88
-rw-r--r--csrc/fortune.c1
-rw-r--r--csrc/land.h3
-rw-r--r--csrc/loadsave.c9
4 files changed, 34 insertions, 67 deletions
diff --git a/csrc/cards.c b/csrc/cards.c
index 9f3d03e..cd79741 100644
--- a/csrc/cards.c
+++ b/csrc/cards.c
@@ -6,6 +6,7 @@
#include "player_info.h"
#include "stock.h"
#include "card.h"
+#include "land.h"
rich4_card cards_table[] = {
{ "\xa7\xa1\xb4\x49\xa5\x64", 1, 200, 2, 2 }, /* 均富卡 */
@@ -237,8 +238,7 @@ int buy_land_card()
eax = word [ecx + eax*8 + 0x20] & 0xffff;
if (eax > 2000 && eax < 4000) {
eax -= 2000;
- eax *= 52;
- ebx = dw_498e84 + eax;
+ ebx = &hlands[eax];
cl = byte [ebx + 0x19];
if (cl == 0 || cl == current_player+1) {
if (esi != 0) {
@@ -297,9 +297,7 @@ int buy_land_card()
}
// 4424be
if (eax > 4000 && eax < 6000) {
- eax -= 4000;
- eax *= 56;
- ebx = dw_498e88 + eax;
+ ebx = &blands[eax-4000];
if (byte [ebx + 0x19] != 0) {
eax = byte [ebx + 0x19];
edx = current_player + 1;
@@ -364,9 +362,7 @@ int swap_land_card()
esi = dw_498e80;
esi = word [esi + eax*8 + 0x20] & 0xffff;
if (esi > 2000 && esi < 4000) {
- eax = esi - 2000;
- eax = eax * 0x34;
- edi = dw_498e84 + eax;
+ edi = &hlands[esi - 2000];
if (players[current_player].who_plays == 1) {
eax = fcn.00446ae8(0xe0c0202);
} else {
@@ -378,9 +374,7 @@ int swap_land_card()
}
fcn.00456c0a(dw_474938, 0x2f440, esi, 0xffff);
fcn.00456c0a(dw_474938, 0x2f440, ebx, 0xffff);
- ebx -= 2000;
- ebx = ebx * 0x34;
- esi = dw_498e84 + ebx;
+ esi = &hlands[ebx-2000];
ebx = (uint8_t)byte [edi + 0x19];
eax = (uint8_t)bype [esi + 0x19];
[esp] = eax;
@@ -441,9 +435,7 @@ int swap_land_card()
// 44288c
if (esi > 4000 && esi < 6000) {
- eax = esi - 4000;
- eax *= 56;
- edi = dw_498e88 + eax;
+ edi = &blands[esi-4000];
if (players[current_player].who_plays == 1) {
eax = fcn.00446ae8(0xe0c0204);
} else {
@@ -453,9 +445,7 @@ int swap_land_card()
if (ebx != 0) {
fcn.00456c0a(dw_474938, 0x2f440, esi, 0xffff);
fcn.00456c0a(dw_474938, 0x2f440, ebx, 0xffff);
- eax = ebx - 4000;
- eax *= 56;
- esi = dw_498e88 + eax;
+ esi = &blands[ebx-4000];
ebx = (uint8_t)byte [edi + 0x19];
eax = (u8)byte [esi + 0x19];
[esp] = eax;
@@ -530,9 +520,7 @@ int swap_house_card()
eax = word [edx + eax + 0x20] & 0xffff;
[esp+8] = eax;
if (eax > 2000 && eax < 4000) {
- eax -= 2000;
- eax = eax * 0x34;
- edx = dw_498e84 + eax;
+ edx = &hlands[eax-2000];
[esp+4] = edx;
if (players[current_player].who_plays == 1) {
eax = fcn.00446ae8(0xe0c0202);
@@ -545,9 +533,7 @@ int swap_house_card()
}
fcn.00456c0a(dw_474938, 0x2f440, [esp+8], 0xffff);
fcn.00456c0a(dw_474938, 0x2f440, ebx, 0xffff);
- eax = ebx - 2000;
- eax = eax * 0x34;
- ebp = dw_498e84 + eax;
+ ebp = &hlands[ebx-2000];
edi = [esp+4];
edi = byte [edi + 0x19];
esi = byte [ebp + 0x19];
@@ -604,9 +590,7 @@ int swap_house_card()
//442d3a
ebp = [esp+8];
if (ebp > 4000 && ebp < 6000) {
- eax = ebp - 4000;
- eax *= 56;
- edx = dw_498e88 + eax;
+ edx = &blands[ebp-4000];
[esp] = edx;
if (players[current_player].who_plays == 1) {
eax = fcn.00446ae8(0xe0c0204);
@@ -617,9 +601,7 @@ int swap_house_card()
if (ebx != 0) {
fcn.00456c0a(dw_474938, 0x2f440, [esp+8], 0xffff);
fcn.00456c0a(dw_474938, 0x2f440, ebx, 0xffff);
- eax = ebx - 4000;
- eax *= 56;
- ebp = dw_498e88 + eax;
+ ebp = &blands[ebx-4000];
edi = [esp];
edi = byte [edi + 0x19];
esi = byte [ebp + 0x19];
@@ -733,9 +715,7 @@ int restruct_card()
ebx = dw_498e80 + eax;
eax = word [ebx + eax*8 + 0x20];
if (eax > 2000 && eax < 4000) {
- eax -= 2000;
- eax *= 0x34;
- ebx = dw_498e84 + eax;
+ ebx = &hlands[eax-2000];
if (byte [ebx + 0x1a] == 0) {
if (esi == 0)
return 0;
@@ -759,9 +739,7 @@ int restruct_card()
}
//443147
if (eax > 4000 && eax < 6000) {
- eax -= 4000;
- eax *= 56;
- ebx = dw_498e88 + eax;
+ ebx = &blands[eax-4000];
if ([ebx + 0x1a] != 0) {
edx = players[current_player].character;
eax = edx * 360;
@@ -808,9 +786,7 @@ int auction_card()
eax = edx * 5;
edi = (uint16_t)word [dw_498e80 + eax * 8 + 0x20];
if (edi > 2000 && edi < 4000) {
- eax = edi - 2000;
- eax *= 0x34;
- esi = dw_498e84 + eax;
+ esi = &hlands[edi-2000];
bl = byte [esi + 0x19];
if (ebx != 0) {
eax = word [esi + 0x1c];
@@ -854,9 +830,7 @@ int auction_card()
}
// 443375
if (edi > 4000 && edi < 6000) {
- eax = edi - 4000;
- eax *= 56;
- esi = dw_498e88 + eax;
+ esi = &blands[edi-4000];
ebx = byte [esi + 0x19];
if (ebx != 0) {
eax = word [esi + 0x22] * price_index;
@@ -929,12 +903,9 @@ int angel_card()
edi = dword [eax + 0x48125a];
player_say(current_player, 3, edi);
if (ebp > 2000 && ebp < 4000) {
- eax = ebp - 2000;
- eax *= 0x34;
- ebx = dw_498e84;
- edi = dw_498e84 + eax;
+ edi = &hlands[ebp-2000];
for (esi = 1; ; esi++) {
- ebx += 0x34;
+ ebx = &hlands[esi];
if (esi > dw_498e98)
break;
eax = strcmp(edi + 4, ebx + 4);
@@ -962,9 +933,7 @@ int angel_card()
}
// 0x443621
if (ebp > 4000 && ebp < 6000) {
- eax = ebp - 4000;
- eax *= 56;
- ebx = dw_498e88 + eax;
+ ebx = &blands[ebp-4000];
fcn.00456c0a(dw_474938, 0x2f440, ebp, 0xffff);
if (players[current_player].who_plays != 1) {
move_animation(0, players[current_player].xpos, players[current_player].ypos,
@@ -1002,11 +971,10 @@ int devil_card()
player_say(current_player, 0, card_strings[c][0][9]);
if (ebp > 2000 && ebp < 4000) {
- eax = (ebp - 2000) * 0x34;
- ebx = dw_498e84;
- edi = dw_498e84 + eax;
+ edi = &hlands[ebp-2000];
- for (int i = 1, ebx+=0x34; i <= dw_498e98; i++, ebx+=0x34) {
+ for (int i = 1; i <= dw_498e98; i++) {
+ ebx = &hlands[i];
eax = strcmp(edi + 4, ebx + 4);
if (eax == 0) {
if (byte [ebx + 0x19] != 0) {
@@ -1029,8 +997,7 @@ int devil_card()
}
if (ebp > 4000 && ebp < 6000) {
- eax = (ebp - 4000) * 56;
- ebx = dw_498e88 + eax;
+ ebx = &blands[ebp-4000];
if (byte [ebx + 0x19] != 0) {
edx = byte [ebx + 0x1a] * 2;
eax = edx * 15 * price_index;
@@ -1350,15 +1317,12 @@ int price_up_card()
player_say(current_player, 0, card_strings[c][0][26]);
if (ebp > 2000 && ebp < 4000) {
- edi = ebp - 2000;
- edi *= 0x34;
- edi += dw_498e84;
- ebx = dw_498e84 + 0x34;
+ edi = &hlands[ebp-2000];
for (int i = 1; i <= dw_498e98; i++) {
+ ebx = &hlands[i];
if (strcmp(edi+4, ebx+4) == 0) {
byte [ebx + 0x17] = 0x50;
}
- ebx += 0x34;
}
if (players[current_player].who_plays == 1) {
player_action_2(0, 0, 1);
@@ -1366,9 +1330,7 @@ int price_up_card()
}
move_animation(0, players[current_player].xpos, players[current_player].ypos, word [edi], word [edi + 2], 100);
} else if (ebp > 4000 && ebp < 6000) {
- eax = ebp - 4000;
- eax *= 56;
- ebx = dw_498e88 + eax;
+ ebx = &blands[ebp-4000];
byte [ebx + 0x1c] = 0x50;
if (players[current_player].who_plays == 1) {
player_action_2(0, 0, 1);
diff --git a/csrc/fortune.c b/csrc/fortune.c
index 812e840..e90741c 100644
--- a/csrc/fortune.c
+++ b/csrc/fortune.c
@@ -3,6 +3,7 @@
#include "stock.h"
struct housing_land *hlands; // @0x498e84
+struct business_land *blands; // @0x498e88
typedef void (*fortune_call(int));
fortune_call fortune_call_table[];
diff --git a/csrc/land.h b/csrc/land.h
index 215a414..33dd682 100644
--- a/csrc/land.h
+++ b/csrc/land.h
@@ -22,3 +22,6 @@ struct business_land
uint16_t house_price; // 0x24
uint32_t _; // 0x34
}; /* size is 0x38=56 */
+
+extern struct housing_land *hlands; // @0x498e84
+extern struct business_land *blands; // @0x498e88
diff --git a/csrc/loadsave.c b/csrc/loadsave.c
index 1581890..26f35cb 100644
--- a/csrc/loadsave.c
+++ b/csrc/loadsave.c
@@ -9,6 +9,7 @@
#include "player_info.h"
#include "mkf/mkf.h"
#include "stock.h"
+#include "land.h"
char *dw_47493c;
char *dw_474945;
@@ -119,9 +120,9 @@ void fcn_00407ad2()
dw_498e9c = eax[0];
dw_498e80 = &eax[eax[1]];
dw_498e98 = eax[2];
- dw_498e84 = &eax[eax[3]];
+ hlands = &eax[eax[3]];
dw_498e8c = eax[4];
- dw_498e88 = &eax[eax[5]];
+ blands = &eax[eax[5]];
dw_498e90 = eax[6];
dw_498e7c = &eax[eax[7]];
dw_499074 = eax[8];
@@ -348,12 +349,12 @@ int load_checkpoint(int n)
*(int*)0x498e98 = edx;
edx = *(int*)(eax + 12);
ebx = eax + edx;
- *(int*)0x498e84 = ebx;
+ hlands = ebx;
edx = *(int*)(eax + 16);
*(int*)0x498e8c = edx;
edx = *(int*)(eax + 20);
ebx = eax + edx;
- *(int*)0x498e88 = ebx;
+ blands = ebx;
edx = *(int*)(eax + 24);
*(int*)0x498e90 = edx;
edx = *(int*)(eax + 28);