Skip to content

Commit

Permalink
HelperFunctions: Added PrintDebug functions for different codepages
Browse files Browse the repository at this point in the history
  • Loading branch information
PiKeyAr committed Dec 2, 2024
1 parent 0011007 commit a07a566
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
29 changes: 29 additions & 0 deletions SADXModLoader/HelperFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "MediaFns.hpp"
#include "BasicWeights.h"
#include "InterpolationFixes.h"
#include <TextConv.hpp>

using std::vector;
using std::unordered_map;
Expand Down Expand Up @@ -655,6 +656,31 @@ void UnreplaceFile(const char* file)
sadx_fileMap.unreplaceFile(file);
}

void PrintDebugUnicode(char* utf8)
{
if (utf8)
{
fputs(utf8, stdout);
fflush(stdout);
}
}

void PrintDebugCodepage(char* buf, unsigned int source_cp)
{
char* utf8 = CodepagetoUTF8(buf, source_cp);
if (utf8)
{
fputs(utf8, stdout);
fflush(stdout);
delete utf8;
}
}

void PrintDebugLocal(char* buf)
{
PrintDebugCodepage(buf, CP_ACP);
}

extern LoaderSettings loaderSettings;

HelperFunctions helperFunctions =
Expand Down Expand Up @@ -702,4 +728,7 @@ HelperFunctions helperFunctions =
&RegisterPermanentTexlist,
&ExpandPVMList,
&UnreplaceFile,
&PrintDebugUnicode,
&PrintDebugLocal,
&PrintDebugCodepage
};
14 changes: 13 additions & 1 deletion SADXModLoader/include/SADXModInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "WeightInfo.h"

// SADX Mod Loader API version.
static const int ModLoaderVer = 27;
static const int ModLoaderVer = 28;

// Patch-type codes
struct PatchInfo
Expand Down Expand Up @@ -465,6 +465,18 @@ struct HelperFunctions
// Removes any file replacements for the specified file.
// Requires version >= 22.
void(__cdecl* UnreplaceFile)(const char* file);

// Prints an UTF-8 string to debug console.
// Requires version >= 28.
void(__cdecl* PrintDebugUnicode)(char* utf8);

// Converts a local codepage string to UTF-8 and prints it to debug console.
// Requires version >= 28.
void(__cdecl* PrintDebugLocal)(char* buf);

// Converts a string in a specific codepage to UTF-8 and prints it to debug console.
// Requires version >= 28.
void(__cdecl* PrintDebugCodepage)(char* buf, unsigned int source_cp);
};

//static_assert(std::is_standard_layout<HelperFunctions>::value);
Expand Down
2 changes: 1 addition & 1 deletion mod-loader-common

0 comments on commit a07a566

Please sign in to comment.