Refactored code in Worldmap module (from Mr.Stalin)

Fixed TimeLimit option and removed the pointless value of -2 (now it's the same as -3).
Fixed the slow mouse cursor on the world map when WorldMapFPSPatch is enabled.
This commit is contained in:
NovaRain
2019-02-03 00:57:00 +08:00
parent 5daebd18d8
commit 89dbbb9238
9 changed files with 250 additions and 187 deletions
+4 -5
View File
@@ -159,8 +159,7 @@ DebugEditorKey=0
;Time limit in years. Must be between -3 and 13
;Set to 0 if you want to die the instant you leave arroyo
;Set to -1 to remove the time limit, and automatically reset the date back to 2241 each time you would have reached it
;Set to -2 to remove the time limit without resetting the date. The game will lock up on 8th of March 2255
;Set to -3 to remove the time limit, automatically reset the date, but override Fallout's GetDate function to return the correct year
;Set to -2 or -3 to remove the time limit, automatically reset the date, but override Fallout's GetDate function to return the correct year
TimeLimit=13
;World map travel time percentage modifier
@@ -168,9 +167,6 @@ TimeLimit=13
;100 is normal speed, 0 stops time from passing
WorldMapTimeMod=100
;Set to 1 to enable functions relating to overriding the file system
UseFileSystemOverride=0
;Set to 1 to use the Fallout 1 code to control world map speed
WorldMapFPSPatch=1
@@ -197,6 +193,9 @@ WorldMapSlots=0
;To use a config file other than fallout2.cfg, uncomment the next line and add the name of your new file
;ConfigFile=
;Set to 1 to enable functions relating to overriding the file system
UseFileSystemOverride=0
;To use a patch file other than patch000.dat, uncomment the next line and add your new file name
;If you want to check for multiple patch files, you can include a %d in the file name (sprintf syntax)
;By default, only the first patch file found will be used.
+6 -1
View File
@@ -631,7 +631,12 @@ enum AttackType : long
#define CRITTER_EYEDAMAGE (0x40)
#define WEAPON_TWO_HANDED (0x200)
#define WEAPON_TWO_HANDED (0x200)
enum TicksTime : unsigned long
{
ONE_GAME_YEAR = 315360000
};
enum RollResult
{
+9
View File
@@ -700,4 +700,13 @@ struct AIcap {
long general_type;
};
#pragma pack(1)
struct Queue {
DWORD time;
long type;
GameObject* object;
long data;
Queue* next;
};
}
+6 -5
View File
@@ -119,13 +119,13 @@ static void _stdcall SaveGame2() {
dlog_f("Saving game: %s\n", DL_MAIN, buf);
DWORD size, unused = 0;
DWORD size, data;
HANDLE h = CreateFileA(buf, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
if (h != INVALID_HANDLE_VALUE) {
SaveGlobals(h);
WriteFile(h, &Objects::uniqueID, 4, &size, 0); // save unique id counter
unused++;
WriteFile(h, &unused, 4, &size, 0);
data = Worldmap::GetAddedYears(false) << 16; // save to high bytes (short)
WriteFile(h, &data, 4, &size, 0);
Perks::save(h);
script::SaveArrays(h);
CloseHandle(h);
@@ -207,12 +207,13 @@ static void _stdcall LoadGame_Before() {
HANDLE h = CreateFileA(buf, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
if (h != INVALID_HANDLE_VALUE) {
DWORD size, unused;
DWORD size, data;
LoadGlobals(h);
long uID = 0;
ReadFile(h, &uID, 4, &size, 0);
if (uID > UniqueID::Start) Objects::uniqueID = uID;
ReadFile(h, &unused, 4, &size, 0);
ReadFile(h, &data, 4, &size, 0);
Worldmap::SetAddedYears(data >> 16);
if (size == 4) {
Perks::load(h);
script::LoadArrays(h);
+5 -26
View File
@@ -31,7 +31,7 @@
#include "..\..\PlayerModel.h"
#include "..\..\ScriptExtender.h"
#include "..\..\Stats.h"
#include "..\..\Worldmap.h"
//#include "..\..\Worldmap.h"
#include "..\Arrays.h"
#include "..\OpcodeContext.h"
@@ -167,36 +167,15 @@ end:
}
}
void __declspec(naked) op_get_year() {
void sf_get_year(OpcodeContext& ctx) {
int year = 0;
__asm {
push ebx;
push ecx;
push edx;
push edi;
mov edi, eax;
sub esp, 4;
xor eax, eax;
xor edx, edx;
mov ebx, esp;
lea ebx, year;
call fo::funcoffs::game_time_date_;
mov edx, [esp];
mov eax, addUnarmedStatToGetYear;
test eax, eax;
jz end;
add edx, ds:[FO_VAR_pc_proto + 0x4C];
end:
mov eax, edi;
call fo::funcoffs::interpretPushLong_;
mov edx, VAR_TYPE_INT;
mov eax, edi;
call fo::funcoffs::interpretPushShort_;
add esp, 4;
pop edi;
pop edx;
pop ecx;
pop ebx;
retn;
}
ctx.setReturn(year);
}
void __declspec(naked) op_game_loaded() {
+1 -1
View File
@@ -37,7 +37,7 @@ void __declspec() op_set_df_model();
void __declspec() op_set_movie_path();
void __declspec() op_get_year();
void sf_get_year(OpcodeContext&);
void __declspec() op_game_loaded();
+2 -2
View File
@@ -63,7 +63,8 @@ typedef std::unordered_map<int, const SfallOpcodeInfo*> OpcodeInfoMapType;
// { argument 1 type, argument 2 type, ...}
// }
static SfallOpcodeInfo opcodeInfoArray[] = {
{0x16c, "key_pressed", sf_key_pressed, 1, true},
{0x163, "get_year", sf_get_year, 0, true},
{0x16c, "key_pressed", sf_key_pressed, 1, true, {ARG_INT}},
{0x19d, "set_sfall_global", sf_set_sfall_global, 2, false, {ARG_INTSTR, ARG_NUMBER}},
{0x19e, "get_sfall_global_int", sf_get_sfall_global_int, 1, true, {ARG_INTSTR}},
@@ -251,7 +252,6 @@ void InitNewOpcodes() {
opcodes[0x160] = op_get_critter_base_stat;
opcodes[0x161] = op_get_critter_extra_stat;
opcodes[0x162] = op_tap_key;
opcodes[0x163] = op_get_year;
opcodes[0x164] = op_game_loaded;
opcodes[0x165] = op_graphics_funcs_available;
opcodes[0x166] = op_load_shader;
+214 -145
View File
File diff suppressed because it is too large Load Diff
+3 -2
View File
@@ -39,8 +39,9 @@ public:
static void SetRestMode(DWORD mode);
static void SetRestMapLevel(int mapId, long elev, bool canRest);
static long __fastcall GetRestMapLevel(long elev, int mapId);
static DWORD GetAddedYears(bool isCheck = true);
static void SetAddedYears(DWORD years);
};
extern DWORD addUnarmedStatToGetYear;
}