diff options
author | Iru Cai <mytbk920423@gmail.com> | 2018-08-31 23:31:58 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2018-08-31 23:31:58 +0800 |
commit | 86fed143086a03f4896bb7cf9d0a33faf144359f (patch) | |
tree | 96e0350ff5ddd9203f1c20f1d543959259811eb5 | |
parent | 8aa634186b1e229ae483530d41a2600f220d2311 (diff) | |
download | rich4-86fed143086a03f4896bb7cf9d0a33faf144359f.tar.xz |
use player_info and the known variables
-rw-r--r-- | csrc/loadsave.c | 30 | ||||
-rw-r--r-- | csrc/media_init.c | 40 |
2 files changed, 35 insertions, 35 deletions
diff --git a/csrc/loadsave.c b/csrc/loadsave.c index f9e39a6..3ce2538 100644 --- a/csrc/loadsave.c +++ b/csrc/loadsave.c @@ -1,6 +1,7 @@ #include <stdio.h> #include <stdlib.h> #include "global.h" +#include "player_info.h" char *dw_47493c; char *dw_474945; @@ -131,7 +132,7 @@ void fcn_00407ad2() edx -= eax; dw_498e94 = edx; - for (ebx = 0; ebx < dw_499114; ebx++) { + for (ebx = 0; ebx < nplayers; ebx++) { esi = ebx * 10008; eax = 0x48cb80 + esi; memset(eax, 0, 0x2718); @@ -222,25 +223,31 @@ void fcn_00407ad2() dw_48aea8 = read_mkf(edi, 0x19, 0, 0); memset(0x498ea0, 0, 0x1d4); for (ebx = 0; ebx < 9; ebx++) { - if (ebx >= dw_499114) { + if (ebx >= nplayers) { if (ebx < 4) continue; fcn_0040b93b(ebx); continue; } +#if 0 esi = ebx * 0x68; eax = *(char*)(0x496b7b+esi) + 0x1b; +#endif + uint8_t eax = players[ebx].character + 0x1b; edx = read_mkf(edi, eax, NULL, NULL); eax = ebx * 0x34; *(int32_t*)(0x498eb0+eax) = edx; +#if 0 if (*(char*)(0x496b7d+esi) == 0 && *(char*)(0x496bcc+esi) == 0) { +#endif + if (players[ebx].f21 == 0 && player[ebx].f100 == 0) { eax = *(int32_t*)(0x498eb0+eax); edx = *(int16_t*)(eax + 0xe); /* sign ext */ eax += 0xc; fcn_004553fe(eax, 0, 0, *(int16_t*)eax, edx); } - if (ebx >= dw_499114) { + if (ebx >= nplayers) { if (edx < 4) continue; fcn_0040b93b(ebx); @@ -290,18 +297,13 @@ int load_checkpoint(int n) fread(&global_rich4_cfg.day, 4, 1, fp); // read day,month,year fread(0x4991b8, 2, 1, fp); fread(0x4991b6, 2, 1, fp); - fread(0x499114, 4, 1, fp); - fread(0x496b68, 0x68, 4, fp); + fread(&nplayers, 4, 1, fp); + fread(players, sizeof(player_info), 4, fp); fread(0x499104, 4, 1, fp); - int t = *(int*)0x499114; - for (int i = 0; i < t; i++) { - eax = i * 0x68; - edx = 0; - dl = *(char*)(0x496b7b+eax); - edx *= 0x68; - edx = *(int*)(0x47e80c+edx); - *(int*)(0x496b68+eax) = edx; + for (int i = 0; i < nplayers; i++) { + uint8_t j = players[i].character; + players[i].name_ptr = rich4_characters[j].name_ptr; } fread(0x498e28, 0x10, 5, fp); @@ -388,7 +390,7 @@ int load_checkpoint(int n) eax += edx; *(int*)0x498e78 = eax; - for (int i = 0; i < *(int*)0x499114; i++) { + for (int i = 0; i < nplayers; i++) { eax = i << 3; eax += i; /* eax = i * 9 */ eax <<= 2; /* eax = i * 36 */ diff --git a/csrc/media_init.c b/csrc/media_init.c index 502bd5d..a8911ef 100644 --- a/csrc/media_init.c +++ b/csrc/media_init.c @@ -1,5 +1,6 @@ #include "global.h" #include "data_struct.h" +#include "player_info.h" DDSURFACEDESC sfdesc1; // 0x0048a068 DDSURFACEDESC sfdesc2; // 0x0048a0f8 @@ -180,11 +181,13 @@ LRESULT CALLBACK kbdProc( if (wParam == k && R4_KEY_RELEASED(lParam)) { if (b_46cafe != 0 && dw_46cad8 == 1) { uint32_t ebx = 0; - for (size_t i = 0; i < dw_499114; i++) { - eax = i * 0x68; - if (*(int8_t*)(0x496b7d + eax) == 1) { - if (*(int32_t*)(0x496b9a + eax) == 0) - return 0; + for (size_t i = 0; i < nplayers; i++) { + if (players[i].f21 == 1 && + players[i].days_in_hotel == 0 && + players[i].days_disappearing == 0 && + players[i].days_in_prison == 0 && + players[i].days_in_hospital == 0) { + return 0; } } if (ebx) @@ -234,30 +237,25 @@ LRESULT CALLBACK kbdProc( /* hotkey 0x49717e */ k = R4_KEY(global_rich4_cfg.hotkeys[11]); if (modded_key == k) { - ecx = dw_49910c; - eax = dw_49910c * 0x68; - if (*(char*)(0x496ba0 + eax) == 0) + ecx = current_player; + if (players[current_player].days_stopping == 0) goto L401523; - al = (*(char*)(0x496b79 + eax)); - if (al < 1) goto L401306; - if (al > 1) { - if (al == 2) goto L4012e7; + uint8_t t = players[current_player].traffic_method; + if (t < 1) goto L401306; + if (t > 1) { + if (t == 2) goto L4012e7; goto L401306; } - edx = eax = ecx * 0x68; - *(char*)(0x496b7a + eax)++; - if (*(char*)(0x496b7a + edx) != 3) + players[current_player].ndices++; + if (players[current_player].ndices != 3) goto L401306; - eax = dw_49910c * 0x68; goto L4012ff; L4012e7: - edx = eax = ecx * 0x68; - *(char*)(0x496b7a + eax)++; - if (*(char*)(0x496b7a + edx) != 4) + players[current_player].ndices++; + if (players[current_player].ndices != 4) goto L401306; - eax = ecx * 0x68; L4012ff: - *(char*)(0x496b7a + eax) = 1; + players[current_player].ndices = 1; L401306: fcn_00417191(1); goto L401523; |