Some code refactoring

This commit is contained in:
NovaRain
2019-12-01 12:10:33 +08:00
parent 66c237d297
commit eeb97a4299
6 changed files with 247 additions and 249 deletions
+6 -6
View File
@@ -674,25 +674,25 @@ CreditsAtBottom=0
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
;To change the path and filename of the critical table file, uncomment the next line
;OverrideCriticalFile=CriticalOverrides.ini
;OverrideCriticalFile=sfall\CriticalOverrides.ini
;To change the relationship between SPECIAL stats and derived stats, uncomment the next line
;See the Stats.ini in the modders pack for an example file
;DerivedStats=Stats.ini
;DerivedStats=sfall\Stats.ini
;Allows you to edit the skill tables
;Point the next line to an ini file containing the replacement skill data
;SkillsFile=Skills.ini
;SkillsFile=sfall\Skills.ini
;To add additional perks to the game, uncomment the next line and set it to point to a file containing perk information
;PerksFile=Perks.ini
;PerksFile=sfall\Perks.ini
;To add additional books to the game, uncomment the next line and point to a file containing book information
;See the Books.ini in the modders pack for an example file
;BooksFile=Books.ini
;BooksFile=sfall\Books.ini
;Point to an ini file containing elevator data
;ElevatorsFile=Elevators.ini
;ElevatorsFile=sfall\Elevators.ini
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[Debugging]
+5 -6
View File
@@ -302,19 +302,18 @@ hide:
}
}
static char* artDbgMsg = "\nError: file not found: %s\n";
static char* artDbgMsg = "\nERROR: File not found: %s\n";
static void __declspec(naked) art_data_size_hook() {
__asm {
test edi, edi;
jz artNotExist;
retn;
artNotExist:
mov eax, [esp + 0x124 - 0x1C + 4]; // filename
push eax;
mov edx, [esp + 0x124 - 0x1C + 4]; // filename
push edx;
push artDbgMsg;
call debug_printf_;
mov eax, [esp + 0x124 - 0x1C + 12]; // filename
push eax;
push edx; // filename
push artDbgMsg;
lea eax, [esp + 0x124 - 0x124 + 20]; // buf
push eax;
@@ -360,7 +359,7 @@ static void DebugModePatch() {
if (iniGetInt("Debugging", "HideObjIsNullMsg", 0, ddrawIniDef)) {
MakeJump(0x453FD2, dbg_error_hack);
}
// prints a debug message about missing art file for critters to debug.log and the message window
// prints a debug message about missing art file for critters to both debug.log and the message window
HookCall(0x419B65, art_data_size_hook);
dlogr(" Done", DL_INIT);
+1 -1
View File
@@ -472,7 +472,7 @@ end:
static void __declspec(naked) DialogHook() {
__asm {
test inLoop, DIALOG; // check bit flag
test inLoop, DIALOG; // check byte flag
jz changeMode;
jmp gdProcess_;
changeMode:
+5 -2
View File
@@ -42,6 +42,11 @@ static void sf_get_sfall_arg_at();
static void sf_add_g_timer_event();
static void sf_remove_timer_event();
static char gTextBuffer[5120]; // used as global temp text buffer for script functions
// returns the size of the global text buffer
inline static const long GlblTextBufferSize() { return sizeof(gTextBuffer); }
// variables for new opcodes
#define OP_MAX_ARGUMENTS (8)
@@ -740,12 +745,10 @@ static DWORD _stdcall GetSfallArgs2() {
static void __declspec(naked) GetSfallArgs() {
__asm {
push ecx;
push edx;
call GetSfallArgs2;
mov edx, eax;
mov eax, ebx;
_RET_VAL_INT2;
pop edx;
pop ecx;
retn;
}
+6 -7
View File
@@ -32,7 +32,7 @@
* Misc operators
*/
const char* stringTooLong = "%s() - the string length exceeds maximum of 64 characters.";
const char* stringTooLong = "%s() - the string exceeds maximum length of 64 characters.";
static void _stdcall SetDMModel2() {
const ScriptValue &modelArg = opHandler.arg(0);
@@ -549,7 +549,6 @@ static int ParseIniSetting(const char* iniString, const char* &key, char section
return 1;
}
static char IniStrBuffer[256];
static DWORD _stdcall GetIniSetting2(const char* str, DWORD isString) {
const char* key;
char section[33], file[67];
@@ -558,9 +557,9 @@ static DWORD _stdcall GetIniSetting2(const char* str, DWORD isString) {
return -1;
}
if (isString) {
IniStrBuffer[0] = 0;
iniGetString(section, key, "", IniStrBuffer, 256, file);
return (DWORD)&IniStrBuffer[0];
gTextBuffer[0] = 0;
iniGetString(section, key, "", gTextBuffer, 256, file);
return (DWORD)&gTextBuffer[0];
} else {
return iniGetInt(section, key, -1, file);
}
@@ -1316,8 +1315,8 @@ static void sf_set_ini_setting() {
const char* saveValue;
if (argVal.isInt()) {
_itoa_s(argVal.rawValue(), IniStrBuffer, 10);
saveValue = IniStrBuffer;
_itoa_s(argVal.rawValue(), gTextBuffer, 10);
saveValue = gTextBuffer;
} else {
saveValue = argVal.strValue();
}
File diff suppressed because it is too large Load Diff