Skip to content

Commit

Permalink
Minor editing.
Browse files Browse the repository at this point in the history
  • Loading branch information
FakelsHub committed Oct 12, 2021
1 parent c4d3f55 commit ce33690
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 12 deletions.
4 changes: 2 additions & 2 deletions sfall/Game/inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ DWORD __stdcall Inventory::adjust_fid() {
return fo::var::i_fid;
}

static void __declspec(naked) adjust_fid_hack() {
static void __declspec(naked) adjust_fid_replacement() {
__asm {
push ecx;
push edx;
Expand All @@ -177,7 +177,7 @@ static void __declspec(naked) adjust_fid_hack() {

void Inventory::init() {
// Replace functions
sf::MakeJump(fo::funcoffs::adjust_fid_, adjust_fid_hack); // 0x4716E8
sf::MakeJump(fo::funcoffs::adjust_fid_, adjust_fid_replacement); // 0x4716E8

//sf::MakeJump(fo::funcoffs::item_weight_, item_weight_hack); // 0x477B88
}
Expand Down
4 changes: 2 additions & 2 deletions sfall/Game/skills.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int __stdcall Skills::trait_adjust_skill(DWORD skillID) {
return result;
}

static void __declspec(naked) trait_adjust_skill_hack() {
static void __declspec(naked) trait_adjust_skill_replacement() {
__asm {
push edx;
push ecx;
Expand All @@ -52,7 +52,7 @@ static void __declspec(naked) trait_adjust_skill_hack() {

void Skills::init() {
// Replace functions
sf::MakeJump(fo::funcoffs::trait_adjust_skill_, trait_adjust_skill_hack); // 0x4B40FC
sf::MakeJump(fo::funcoffs::trait_adjust_skill_, trait_adjust_skill_replacement); // 0x4B40FC
}

}
4 changes: 2 additions & 2 deletions sfall/Game/stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ int __stdcall Stats::trait_adjust_stat(DWORD statID) {
return result;
}

static void __declspec(naked) trait_adjust_stat_hack() {
static void __declspec(naked) trait_adjust_stat_replacement() {
__asm {
push edx;
push ecx;
Expand All @@ -121,7 +121,7 @@ static void __declspec(naked) trait_adjust_stat_hack() {

void Stats::init() {
// Replace functions
sf::MakeJump(fo::funcoffs::trait_adjust_stat_, trait_adjust_stat_hack); // 0x4B3C7C
sf::MakeJump(fo::funcoffs::trait_adjust_stat_, trait_adjust_stat_replacement); // 0x4B3C7C

// Fix the carry weight penalty of the Small Frame trait not being applied to bonus Strength points
smallFrameTraitFix = (sf::IniReader::GetConfigInt("Misc", "SmallFrameFix", 0) > 0);
Expand Down
20 changes: 20 additions & 0 deletions sfall/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,32 @@ namespace sfall
static int DebugTypes = 0;
static std::ofstream Log;

void dlog(const char* a) {
Log << a;
Log.flush();
}

void dlog(const char* a, int type) {
if (isDebug && (type == DL_MAIN || (type & DebugTypes))) {
Log << a;
Log.flush();
}
}

void dlog(const std::string& a, int type) {
if (isDebug && (type == DL_MAIN || (type & DebugTypes))) {
Log << a;
Log.flush();
}
}

void dlogr(const char* a, int type) {
if (isDebug && (type == DL_MAIN || (type & DebugTypes))) {
Log << a << "\n";
Log.flush();
}
}

void dlogr(const std::string& a, int type) {
if (isDebug && (type == DL_MAIN || (type & DebugTypes))) {
Log << a << "\n";
Expand Down Expand Up @@ -83,6 +102,7 @@ void devlog_f(...) {}

void LoggingInit() {
Log.open("sfall-log.txt", std::ios_base::out | std::ios_base::trunc);

if (IniReader::GetIntDefaultConfig("Debugging", "Init", 0)) {
DebugTypes |= DL_INIT;
}
Expand Down
3 changes: 3 additions & 0 deletions sfall/Logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
namespace sfall
{

void dlog(const char*);
void dlog(const char*, int type);
void dlog(const std::string&, int type);
void dlogr(const char*, int type);
void dlogr(const std::string&, int type);
void dlog_f(const char* fmt, int type, ...);
void dlogh(const char* fmt, long, long, long);
Expand Down
2 changes: 1 addition & 1 deletion sfall/Modules/Animations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ static void __declspec(naked) action_get_an_object_hack() {
xor edi, edi;
retn; // request loot container
default:
mov edi, 2;
mov edi, 2; // set current frame
test edi, edi;
retn;
}
Expand Down
8 changes: 3 additions & 5 deletions sfall/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,11 @@ static void SfallInit() {

if (!CRC(filepath)) return;

LoggingInit();
if (!ddraw.dll) dlog("Error: Cannot load the original ddraw.dll library.\n");

// enabling debugging features
isDebug = (IniReader::GetIntDefaultConfig("Debugging", "Enable", 0) != 0);
//if (isDebug) {
LoggingInit();
if (!ddraw.dll) dlog("Error: Cannot load the original ddraw.dll library.\n", DL_MAIN);
//}

if (!isDebug || !IniReader::GetIntDefaultConfig("Debugging", "SkipCompatModeCheck", 0)) {
int is64bit;
typedef int (__stdcall *chk64bitproc)(HANDLE, int*);
Expand Down

0 comments on commit ce33690

Please sign in to comment.