Skip to content

Commit

Permalink
Fixed some linker errors on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
HumanGamer committed Mar 9, 2024
1 parent 44a85a3 commit b082ace
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 5 deletions.
6 changes: 3 additions & 3 deletions engine/source/discord/DiscordGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ DiscordGame::DiscordGame()
mPartyId = nullptr;

DiscordEventHandlers handlers;
memset(&handlers, 0, sizeof(handlers));
dMemset(&handlers, 0, sizeof(handlers));
handlers.ready = onReady;
handlers.errored = onError;
handlers.disconnected = onDisconnected;
Expand Down Expand Up @@ -154,7 +154,7 @@ void DiscordGame::update()
mStatus = "";

DiscordRichPresence discordPresence;
memset(&discordPresence, 0, sizeof(discordPresence));
dMemset(&discordPresence, 0, sizeof(discordPresence));
discordPresence.state = mStatus;


Expand All @@ -174,7 +174,7 @@ void DiscordGame::update()

if (mGUID != nullptr) {
//Con::printf("DiscordGameSDK::Info: %s", "Setting Large Image Key", mGUID);
if (strcmp(mGUID, "MainMenu") == 0) {
if (dStrcmp(mGUID, "MainMenu") == 0) {
mLargeImageKey = "mbu_logo";
}
else {
Expand Down
110 changes: 110 additions & 0 deletions engine/source/platformX86UNIX/x86UNIXStrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,3 +407,113 @@ void dQsort(void *base, U32 nelem, U32 width, S32 (QSORT_CALLBACK *fcmp)(const v
{
qsort(base, nelem, width, fcmp);
}

/// Safe form of dStrcmp: checks both strings for NULL before comparing
bool dStrEqual(const char* str1, const char* str2)
{
if (!str1 || !str2)
return false;
else
return (dStrcmp(str1, str2) == 0);
}

/// Check if one string starts with another
bool dStrStartsWith(const char* str1, const char* str2)
{
return !dStrnicmp(str1, str2, dStrlen(str2));
}

/// Check if one string ends with another
bool dStrEndsWith(const char* str1, const char* str2)
{
const char* p = str1 + dStrlen(str1) - dStrlen(str2);
return ((p >= str1) && !dStricmp(p, str2));
}

/// Strip the path from the input filename
char* dStripPath(const char* filename)
{
const char* itr = filename + dStrlen(filename);
while (--itr != filename) {
if (*itr == '/' || *itr == '\\') {
itr++;
break;
}
}
return dStrdup(itr);
}

char* dChopTrailingNumber(const char* name, S32& number)
{
// Set default return value
number = 2;

// Check for trivial strings
if (!name || !name[0])
return 0;

// Find the number at the end of the string
char* buffer = dStrdup(name);
char* p = buffer + strlen(buffer) - 1;

// Ignore trailing whitespace
while ((p != buffer) && dIsspace(*p))
p--;

// Need at least one digit!
if (!isdigit(*p))
return buffer;

// Back up to the first non-digit character
while ((p != buffer) && isdigit(*p))
p--;

// Convert number => allow negative numbers, treat '_' as '-' for Maya
if ((*p == '-') || (*p == '_'))
number = -dAtoi(p + 1);
else
number = ((p == buffer) ? dAtoi(p) : dAtoi(++p));

// Remove space between the name and the number
while ((p > buffer) && dIsspace(*(p - 1)))
p--;
*p = '\0';

return buffer;
}

char* dGetTrailingNumber(const char* name, S32& number)
{
// Check for trivial strings
if (!name || !name[0])
return 0;

// Find the number at the end of the string
char* buffer = dStrdup(name);
char* p = buffer + strlen(buffer) - 1;

// Ignore trailing whitespace
while ((p != buffer) && dIsspace(*p))
p--;

// Need at least one digit!
if (!isdigit(*p))
return buffer;

// Back up to the first non-digit character
while ((p != buffer) && isdigit(*p))
p--;

// Convert number => allow negative numbers, treat '_' as '-' for Maya
if ((*p == '-') || (*p == '_'))
number = -dAtoi(p + 1);
else
number = ((p == buffer) ? dAtoi(p) : dAtoi(++p));

// Remove space between the name and the number
while ((p > buffer) && dIsspace(*(p - 1)))
p--;
*p = '\0';

return buffer;
}
4 changes: 2 additions & 2 deletions tools/cmake/marbleblast.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ addPath("${srcDir}/autosplitter")
addPath("${srcDir}/collision")
addPath("${srcDir}/console")
addPath("${srcDir}/core")
if(WIN32)
#if(WIN32)
addPath("${srcDir}/discord")
endif()
#endif()
addPath("${srcDir}/editor")
#addPath("${srcDir}/editor/terrain")
#addPathRec("${srcDir}/atlas")
Expand Down

0 comments on commit b082ace

Please sign in to comment.