Fix warnings/compile errors on Linux

This commit is contained in:
MysterD 2022-03-13 18:45:42 -07:00
parent 013edccfed
commit 11f532b9e0
11 changed files with 107 additions and 38 deletions

View file

@ -406,22 +406,14 @@ endif
# Luigi and wario sounds don't work on 32-bit right now # Luigi and wario sounds don't work on 32-bit right now
# And the audio code is so terrible I don't care enough to figure it out at the moment # And the audio code is so terrible I don't care enough to figure it out at the moment
ifeq ($(TARGET_BITS), 32) ifeq ($(TARGET_BITS), 32)
$(shell rm -rf sound/samples/sfx_custom_luigi/*.aiff) _ := $(shell rm -rf sound/samples/sfx_custom_luigi/*.aiff)
$(shell rm -rf sound/samples/sfx_custom_luigi_peach/*.aiff) _ := $(shell rm -rf sound/samples/sfx_custom_luigi_peach/*.aiff)
$(shell rm -rf sound/samples/sfx_custom_wario/*.aiff) _ := $(shell rm -rf sound/samples/sfx_custom_wario/*.aiff)
$(shell rm -rf sound/samples/sfx_custom_wario_peach/*.aiff) _ := $(shell rm -rf sound/samples/sfx_custom_wario_peach/*.aiff)
endif endif
# Copy missing luigi sounds from mario sound banks # Copy missing character sounds from mario sound banks
#$(shell mkdir -p sound/samples/sfx_custom_luigi sound/samples/sfx_custom_luigi_peach ) _ := $(shell $(PYTHON) $(TOOLS_DIR)/copy_mario_sounds.py)
#$(shell cp -n sound/samples/sfx_mario/*.aiff sound/samples/sfx_custom_luigi/ )
#$(shell cp -n sound/samples/sfx_mario_peach/*.aiff sound/samples/sfx_custom_luigi_peach/ )
# Copy missing wario sounds from mario sound banks
#$(shell mkdir -p sound/samples/sfx_custom_wario sound/samples/sfx_custom_wario_peach )
#$(shell cp -n sound/samples/sfx_mario/*.aiff sound/samples/sfx_custom_wario/ )
#$(shell cp -n sound/samples/sfx_mario_peach/*.aiff sound/samples/sfx_custom_wario_peach/ )
#==============================================================================# #==============================================================================#
# Target Executable and Sources # # Target Executable and Sources #

View file

@ -26,7 +26,16 @@ void DynOS_Opt_LoadConfig(DynosOption *aMenu) {
// Option values // Option values
switch (_Opt->mType) { switch (_Opt->mType) {
#ifdef COOP
case DOPT_TOGGLE: {
unsigned char boolValue = 0;
sscanf(_DataBegin, "%hhu\n", &boolValue);
_Opt->mToggle.mTog[0] = boolValue;
break;
}
#else
case DOPT_TOGGLE: sscanf(_DataBegin, "%hhu\n", &_Opt->mToggle.mTog[0]); break; case DOPT_TOGGLE: sscanf(_DataBegin, "%hhu\n", &_Opt->mToggle.mTog[0]); break;
#endif
case DOPT_CHOICE: sscanf(_DataBegin, "%d\n", &_Opt->mChoice.mIndex[0]); break; case DOPT_CHOICE: sscanf(_DataBegin, "%d\n", &_Opt->mChoice.mIndex[0]); break;
case DOPT_SCROLL: sscanf(_DataBegin, "%d\n", &_Opt->mScroll.mValue[0]); break; case DOPT_SCROLL: sscanf(_DataBegin, "%d\n", &_Opt->mScroll.mValue[0]); break;
case DOPT_BIND: sscanf(_DataBegin, "%04X;%04X;%04X\n", &_Opt->mBind.mBinds[0], &_Opt->mBind.mBinds[1], &_Opt->mBind.mBinds[2]); break; case DOPT_BIND: sscanf(_DataBegin, "%04X;%04X;%04X\n", &_Opt->mBind.mBinds[0], &_Opt->mBind.mBinds[1], &_Opt->mBind.mBinds[2]); break;

View file

@ -402,9 +402,13 @@ void print_act_selector_strings(void) {
if (playersInAct > 0) { if (playersInAct > 0) {
char message[16] = { 0 }; char message[16] = { 0 };
if (playersInAct == 1) { if (playersInAct == 1) {
snprintf(message, 16, "join"); if (snprintf(message, 16, "join") < 0) {
// do nothing
}
} else { } else {
snprintf(message, 16, "%d players", playersInAct); if (snprintf(message, 16, "%d players", playersInAct) < 0) {
// do nothing
}
} }
gSPDisplayList(gDisplayListHead++, dl_ia_text_begin); gSPDisplayList(gDisplayListHead++, dl_ia_text_begin);

View file

@ -20,7 +20,9 @@ static struct NetworkPlayer* chat_get_network_player(char* name) {
for (int i = 0; i < MAX_PLAYERS; i++) { for (int i = 0; i < MAX_PLAYERS; i++) {
if (!gNetworkPlayers[i].connected) { continue; } if (!gNetworkPlayers[i].connected) { continue; }
char id[16] = { 0 }; char id[16] = { 0 };
snprintf(id, 16, "%d", i); if (snprintf(id, 16, "%d", i) < 0) {
// do nothing
}
if (strcmp(id, name) == 0) { if (strcmp(id, name) == 0) {
return &gNetworkPlayers[i]; return &gNetworkPlayers[i];
} }

View file

@ -3,6 +3,7 @@
#include "src/pc/network/network.h" #include "src/pc/network/network.h"
#include "src/pc/utils/misc.h" #include "src/pc/utils/misc.h"
#include "src/pc/configfile.h" #include "src/pc/configfile.h"
#include "src/pc/debuglog.h"
#ifdef DISCORD_SDK #ifdef DISCORD_SDK
static char* sJoiningDiscord = "\ static char* sJoiningDiscord = "\
@ -89,7 +90,9 @@ static bool djui_panel_join_ip_valid(char* buffer) {
static void djui_panel_join_ip_text_set_new(void) { static void djui_panel_join_ip_text_set_new(void) {
char buffer[256] = { 0 }; char buffer[256] = { 0 };
snprintf(buffer, 256, "%s", sInputboxIp->buffer); if (snprintf(buffer, 256, "%s", sInputboxIp->buffer) < 0) {
LOG_INFO("truncating IP");
}
bool afterSpacer = false; bool afterSpacer = false;
int port = 0; int port = 0;
@ -105,7 +108,9 @@ static void djui_panel_join_ip_text_set_new(void) {
} }
} }
snprintf(configJoinIp, MAX_CONFIG_STRING, "%s", buffer); if (snprintf(configJoinIp, MAX_CONFIG_STRING, "%s", buffer) < 0) {
LOG_INFO("truncating IP");
}
if (port >= 1 && port <= 65535) { if (port >= 1 && port <= 65535) {
configJoinPort = port; configJoinPort = port;
} else { } else {
@ -116,11 +121,11 @@ static void djui_panel_join_ip_text_set_new(void) {
static void djui_panel_join_ip_text_set(struct DjuiInputbox* inputbox1) { static void djui_panel_join_ip_text_set(struct DjuiInputbox* inputbox1) {
char buffer[256] = { 0 }; char buffer[256] = { 0 };
if (strlen(configJoinIp) > 0 && configJoinPort != DEFAULT_PORT) { if (strlen(configJoinIp) > 0 && configJoinPort != DEFAULT_PORT) {
snprintf(buffer, 256, "%s:%d", configJoinIp, configJoinPort); if (snprintf(buffer, 256, "%s:%d", configJoinIp, configJoinPort) < 0) { LOG_INFO("truncating IP"); }
} else if (strlen(configJoinIp) > 0) { } else if (strlen(configJoinIp) > 0) {
snprintf(buffer, 256, "%s", configJoinIp); if (snprintf(buffer, 256, "%s", configJoinIp) < 0) { LOG_INFO("truncating IP"); }
} else { } else {
snprintf(buffer, 256, "127.0.0.1"); if (snprintf(buffer, 256, "127.0.0.1") < 0) { LOG_INFO("truncating IP"); }
} }
djui_inputbox_set_text(inputbox1, buffer); djui_inputbox_set_text(inputbox1, buffer);

View file

@ -358,14 +358,18 @@ void *fs_load_file(const char *vpath, uint64_t *outsize) {
const char *fs_get_write_path(const char *vpath) { const char *fs_get_write_path(const char *vpath) {
static char path[SYS_MAX_PATH]; static char path[SYS_MAX_PATH];
snprintf(path, sizeof(path), "%s/%s", fs_writepath, vpath); if (snprintf(path, sizeof(path), "%s/%s", fs_writepath, vpath) < 0) {
return NULL;
}
return path; return path;
} }
const char *fs_convert_path(char *buf, const size_t bufsiz, const char *path) { const char *fs_convert_path(char *buf, const size_t bufsiz, const char *path) {
// ! means "executable directory" // ! means "executable directory"
if (path[0] == '!') { if (path[0] == '!') {
snprintf(buf, bufsiz, "%s%s", sys_exe_path(), path + 1); if (snprintf(buf, bufsiz, "%s%s", sys_exe_path(), path + 1) < 0) {
return NULL;
}
} else { } else {
strncpy(buf, path, bufsiz); strncpy(buf, path, bufsiz);
buf[bufsiz-1] = 0; buf[bufsiz-1] = 0;
@ -407,7 +411,9 @@ bool fs_sys_walk(const char *base, walk_fn_t walk, void *user, const bool recur)
while ((ent = readdir(dir)) != NULL) { while ((ent = readdir(dir)) != NULL) {
if (ent->d_name[0] == 0 || ent->d_name[0] == '.') continue; // skip ./.. and hidden files if (ent->d_name[0] == 0 || ent->d_name[0] == '.') continue; // skip ./.. and hidden files
snprintf(fullpath, sizeof(fullpath), "%s/%s", base, ent->d_name); if (snprintf(fullpath, sizeof(fullpath), "%s/%s", base, ent->d_name) < 0) {
continue;
}
if (fs_sys_dir_exists(fullpath)) { if (fs_sys_dir_exists(fullpath)) {
if (recur) { if (recur) {
if (!fs_sys_walk(fullpath, walk, user, recur)) { if (!fs_sys_walk(fullpath, walk, user, recur)) {

View file

@ -29,7 +29,7 @@ static void mod_list_delete_tmp(void) {
static char path[SYS_MAX_PATH] = { 0 }; static char path[SYS_MAX_PATH] = { 0 };
while ((dir = readdir(d)) != NULL) { while ((dir = readdir(d)) != NULL) {
snprintf(path, SYS_MAX_PATH - 1, "%s/%s", sTmpPath, dir->d_name); if (snprintf(path, SYS_MAX_PATH - 1, "%s/%s", sTmpPath, dir->d_name) < 0) { continue; }
if (!fs_sys_file_exists(path)) { continue; } if (!fs_sys_file_exists(path)) { continue; }
#if defined(_WIN32) #if defined(_WIN32)
@ -81,8 +81,11 @@ void mod_list_add_tmp(u16 index, u16 remoteIndex, char* name, size_t size) {
n++; n++;
} }
snprintf(entry->path, SYS_MAX_PATH - 1, "%s/%s-%u-%s", sTmpPath, sTmpSession, index, sanitizedName); if (snprintf(entry->path, SYS_MAX_PATH - 1, "%s/%s-%u-%s", sTmpPath, sTmpSession, index, sanitizedName) >= 0) {
entry->fp = fopen(entry->path, "wb"); entry->fp = fopen(entry->path, "wb");
} else {
entry->fp = NULL;
}
entry->remoteIndex = remoteIndex; entry->remoteIndex = remoteIndex;
entry->complete = false; entry->complete = false;
@ -122,13 +125,13 @@ void mod_list_extract_lua_fields(struct ModListEntry* entry) {
char* extracted = NULL; char* extracted = NULL;
if (entry->displayName == NULL && (extracted = extract_lua_field("-- name:", buffer))) { if (entry->displayName == NULL && (extracted = extract_lua_field("-- name:", buffer))) {
entry->displayName = calloc(33, sizeof(char)); entry->displayName = calloc(33, sizeof(char));
snprintf(entry->displayName, 32, "%s", extracted); if (snprintf(entry->displayName, 32, "%s", extracted) < 0) {}
} else if (entry->incompatible == NULL && (extracted = extract_lua_field("-- incompatible:", buffer))) { } else if (entry->incompatible == NULL && (extracted = extract_lua_field("-- incompatible:", buffer))) {
entry->incompatible = calloc(257, sizeof(char)); entry->incompatible = calloc(257, sizeof(char));
snprintf(entry->incompatible, 256, "%s", extracted); if (snprintf(entry->incompatible, 256, "%s", extracted) < 0) {}
} else if (entry->description == NULL && (extracted = extract_lua_field("-- description:", buffer))) { } else if (entry->description == NULL && (extracted = extract_lua_field("-- description:", buffer))) {
entry->description = calloc(513, sizeof(char)); entry->description = calloc(513, sizeof(char));
snprintf(entry->description, 512, "%s", extracted); if (snprintf(entry->description, 512, "%s", extracted) < 0) {}
} }
} }

View file

@ -28,7 +28,9 @@ static void on_activity_join_callback(UNUSED void* data, enum EDiscordResult res
network_init(NT_CLIENT); network_init(NT_CLIENT);
gCurActivity.type = DiscordActivityType_Playing; gCurActivity.type = DiscordActivityType_Playing;
snprintf(gCurActivity.party.id, 128, DISCORD_ID_FORMAT, lobby->id); if (snprintf(gCurActivity.party.id, 128, DISCORD_ID_FORMAT, lobby->id) < 0) {
LOGFILE_ERROR(LFT_DISCORD, "Truncating party id");
}
gCurActivity.party.size.current_size = 2; gCurActivity.party.size.current_size = 2;
gCurActivity.party.size.max_size = lobby->capacity; gCurActivity.party.size.max_size = lobby->capacity;
@ -130,7 +132,9 @@ void discord_activity_update(bool hosting) {
discord_populate_details(details, true); discord_populate_details(details, true);
} }
snprintf(gCurActivity.details, 125, "%s", details); if (snprintf(gCurActivity.details, 125, "%s", details) < 0) {
LOGFILE_INFO(LFT_DISCORD, "truncating details");
}
app.activities->update_activity(app.activities, &gCurActivity, NULL, on_activity_update_callback); app.activities->update_activity(app.activities, &gCurActivity, NULL, on_activity_update_callback);
LOGFILE_INFO(LFT_DISCORD, "set activity"); LOGFILE_INFO(LFT_DISCORD, "set activity");

View file

@ -44,12 +44,16 @@ static void on_lobby_create_callback(UNUSED void* data, enum EDiscordResult resu
LOGFILE_INFO(LFT_DISCORD, "Lobby locked: %d", lobby->locked); LOGFILE_INFO(LFT_DISCORD, "Lobby locked: %d", lobby->locked);
gCurActivity.type = DiscordActivityType_Playing; gCurActivity.type = DiscordActivityType_Playing;
snprintf(gCurActivity.party.id, 128, DISCORD_ID_FORMAT, lobby->id); if (snprintf(gCurActivity.party.id, 128, DISCORD_ID_FORMAT, lobby->id) < 0) {
LOGFILE_ERROR(LFT_DISCORD, "truncating party id");
}
gCurActivity.party.size.current_size = 1; gCurActivity.party.size.current_size = 1;
gCurActivity.party.size.max_size = configAmountofPlayers; gCurActivity.party.size.max_size = configAmountofPlayers;
char secretJoin[128] = ""; char secretJoin[128] = "";
snprintf(secretJoin, 128, DISCORD_ID_FORMAT ":%s", lobby->id, lobby->secret); if (snprintf(secretJoin, 128, DISCORD_ID_FORMAT ":%s", lobby->id, lobby->secret) < 0) {
LOGFILE_ERROR(LFT_DISCORD, "truncating secret");
}
strcpy(gCurActivity.secrets.join, secretJoin); strcpy(gCurActivity.secrets.join, secretJoin);
isHosting = true; isHosting = true;

View file

@ -4,7 +4,9 @@
void network_send_player_settings(void) { void network_send_player_settings(void) {
char playerName[MAX_PLAYER_STRING+1] = { 0 }; char playerName[MAX_PLAYER_STRING+1] = { 0 };
snprintf(playerName, MAX_PLAYER_STRING, "%s", configPlayerName); if (snprintf(playerName, MAX_PLAYER_STRING, "%s", configPlayerName) < 0) {
LOG_INFO("truncating player name");
}
struct Packet p = { 0 }; struct Packet p = { 0 };
packet_init(&p, PACKET_PLAYER_SETTINGS, true, PLMT_NONE); packet_init(&p, PACKET_PLAYER_SETTINGS, true, PLMT_NONE);
@ -14,7 +16,9 @@ void network_send_player_settings(void) {
packet_write(&p, &configPlayerPalette, sizeof(u8)); packet_write(&p, &configPlayerPalette, sizeof(u8));
if (gNetworkPlayerLocal != NULL) { if (gNetworkPlayerLocal != NULL) {
snprintf(gNetworkPlayerLocal->name, MAX_PLAYER_STRING, "%s", playerName); if (snprintf(gNetworkPlayerLocal->name, MAX_PLAYER_STRING, "%s", playerName) < 0) {
LOG_INFO("truncating player name");
}
} }
network_send(&p); network_send(&p);
@ -47,7 +51,9 @@ void network_receive_player_settings(struct Packet* p) {
if (playerPalette >= PALETTE_MAX) { playerPalette = 0; } if (playerPalette >= PALETTE_MAX) { playerPalette = 0; }
struct NetworkPlayer* np = network_player_from_global_index(globalId); struct NetworkPlayer* np = network_player_from_global_index(globalId);
snprintf(np->name, MAX_PLAYER_STRING, "%s", playerName); if (snprintf(np->name, MAX_PLAYER_STRING, "%s", playerName) < 0) {
LOG_INFO("truncating player name");
}
if (np->modelIndex == np->overrideModelIndex) { np->overrideModelIndex = playerModel; } if (np->modelIndex == np->overrideModelIndex) { np->overrideModelIndex = playerModel; }
if (np->paletteIndex == np->overridePaletteIndex) { np->overridePaletteIndex = playerPalette; } if (np->paletteIndex == np->overridePaletteIndex) { np->overridePaletteIndex = playerPalette; }

View file

@ -0,0 +1,34 @@
#!/usr/bin/env python3
import os
copy_directories = {
'sound/samples/sfx_mario/': [
'sound/samples/sfx_custom_luigi/',
'sound/samples/sfx_custom_wario/',
],
'sound/samples/sfx_mario_peach/': [
'sound/samples/sfx_custom_luigi_peach/',
'sound/samples/sfx_custom_wario_peach/',
],
}
def copy_dir(source, destinations):
for filename in os.listdir(source):
if not filename.endswith('.aiff'):
continue
src = source + filename
shortened_name = filename.split('_')[0] + '.aiff'
for destination in destinations:
dst = destination + shortened_name
if os.path.exists(dst):
continue
print('Copying mario sounds to character sounds: ' + src + ' -> ' + dst)
os.system('cp ' + src + ' ' + dst)
def main():
for source in copy_directories:
copy_dir(source, copy_directories[source])
if __name__ == "__main__":
main()