mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Unset the read-only attribute for party member's .sav proto files
Slightly changed the implementation of previous commit.
This commit is contained in:
@@ -81,8 +81,7 @@ static void _stdcall ResetState(DWORD onLoad) {
|
||||
InventoryReset();
|
||||
RegAnimCombatCheck(1);
|
||||
AfterAttackCleanup();
|
||||
savPrototypes.clear();
|
||||
RemoveSavFiles();
|
||||
ClearSavPrototypes();
|
||||
ResetExplosionRadius();
|
||||
PartyControlReset();
|
||||
}
|
||||
|
||||
+36
-6
@@ -71,7 +71,7 @@ char ini[65] = ".\\";
|
||||
char translationIni[65];
|
||||
DWORD modifiedIni;
|
||||
|
||||
std::vector<int> savPrototypes;
|
||||
static std::vector<int> savPrototypes;
|
||||
|
||||
static char mapName[65];
|
||||
static char configName[65];
|
||||
@@ -537,11 +537,12 @@ end:
|
||||
}
|
||||
}
|
||||
|
||||
#define _F_PATHFILE 0x6143F4
|
||||
static void __declspec(naked) GameMap2Slot_hack() { // save party pids
|
||||
__asm {
|
||||
push ecx;
|
||||
mov edx, 0x6143F4; // path buffer
|
||||
call CheckProtoType; // ecx - party pid
|
||||
mov edx, _F_PATHFILE; // path buffer
|
||||
call CheckProtoType; // ecx - party pid
|
||||
pop ecx;
|
||||
lea eax, [esp + 0x14 + 4];
|
||||
retn 0x14;
|
||||
@@ -551,8 +552,8 @@ static void __declspec(naked) GameMap2Slot_hack() { // save party pids
|
||||
static void __declspec(naked) SlotMap2Game_hack() { // load party pids
|
||||
__asm {
|
||||
push edx;
|
||||
mov ecx, edi; // party pid
|
||||
mov edx, 0x6143F4; // path buffer
|
||||
mov ecx, edi; // party pid
|
||||
mov edx, _F_PATHFILE; // path buffer
|
||||
call CheckProtoType;
|
||||
test eax, eax;
|
||||
jz end;
|
||||
@@ -586,8 +587,36 @@ end:
|
||||
}
|
||||
}
|
||||
|
||||
static void ResetReadOnlyAttr() {
|
||||
DWORD attr = GetFileAttributesA((const char*)_F_PATHFILE);
|
||||
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_READONLY)) {
|
||||
SetFileAttributesA((const char*)_F_PATHFILE, (attr & ~FILE_ATTRIBUTE_READONLY));
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) SlotMap2Game_hack_attr() {
|
||||
__asm {
|
||||
cmp eax, -1;
|
||||
je end;
|
||||
cmp ebx, OBJ_TYPE_CRITTER;
|
||||
jne end;
|
||||
call ResetReadOnlyAttr;
|
||||
or eax, 1; // reset ZF
|
||||
end:
|
||||
retn 0x8;
|
||||
}
|
||||
}
|
||||
|
||||
#define _F_SAV (const char*)0x50A480
|
||||
#define _F_PROTO_CRITTERS (const char*)0x50A490
|
||||
|
||||
void RemoveSavFiles() {
|
||||
MapDirErase((const char*)0x50A490, (const char*)0x50A480);
|
||||
MapDirErase(_F_PROTO_CRITTERS, _F_SAV);
|
||||
}
|
||||
|
||||
void ClearSavPrototypes() {
|
||||
savPrototypes.clear();
|
||||
MapDirErase(_F_PROTO_CRITTERS, _F_SAV);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1311,6 +1340,7 @@ static void DllMain2() {
|
||||
HookCall(0x4A1BEE, proto_save_pid_hook);
|
||||
MakeCall(0x47F5A5, GameMap2Slot_hack); // save game
|
||||
MakeCall(0x47FB80, SlotMap2Game_hack); // load game
|
||||
MakeCall(0x47FBBF, SlotMap2Game_hack_attr, 1);
|
||||
dlogr(" Done", DL_INIT);
|
||||
|
||||
if (GetPrivateProfileInt("Misc", "DisplayKarmaChanges", 0, ini)) {
|
||||
|
||||
+1
-2
@@ -67,8 +67,6 @@ extern char ini[65];
|
||||
extern char translationIni[65];
|
||||
extern DWORD modifiedIni;
|
||||
|
||||
extern std::vector<int> savPrototypes;
|
||||
|
||||
extern char dmModelName[65];
|
||||
extern char dfModelName[65];
|
||||
|
||||
@@ -76,6 +74,7 @@ DWORD GetAddedYears(bool isCheck = true);
|
||||
void SetAddedYears(DWORD years);
|
||||
|
||||
void RemoveSavFiles();
|
||||
void ClearSavPrototypes();
|
||||
|
||||
template<typename T>
|
||||
T SimplePatch(DWORD addr, const char* iniSection, const char* iniKey, T defaultValue, T minValue = 0, T maxValue = INT_MAX)
|
||||
|
||||
Reference in New Issue
Block a user