Remove leftover debug feature

This commit is contained in:
Agent X 2024-03-04 17:17:46 -05:00
parent 893c65d927
commit fe75dbfa28
10 changed files with 14 additions and 66 deletions

View file

@ -75,13 +75,10 @@ static void discord_populate_details(char* buffer, int bufferLength) {
bufferLength -= versionLength; bufferLength -= versionLength;
// get mod strings // get mod strings
u8 autoexecMod = mods_has_autoexec_mod(); if (gActiveMods.entryCount <= 0) { return; }
if (gActiveMods.entryCount - autoexecMod <= 0) { return; } char* strings[gActiveMods.entryCount];
char* strings[gActiveMods.entryCount - autoexecMod];
for (int i = 0; i < gActiveMods.entryCount; i++) { for (int i = 0; i < gActiveMods.entryCount; i++) {
struct Mod* mod = gActiveMods.entries[i]; strings[i] = gActiveMods.entries[i]->name;
if (mod_get_is_autoexec(mod)) { continue; }
strings[i] = mod->name;
} }
// add seperator // add seperator
@ -90,7 +87,7 @@ static void discord_populate_details(char* buffer, int bufferLength) {
bufferLength -= 3; bufferLength -= 3;
// concat mod strings // concat mod strings
str_seperator_concat(buffer, bufferLength, strings, gActiveMods.entryCount - autoexecMod, ", "); str_seperator_concat(buffer, bufferLength, strings, gActiveMods.entryCount, ", ");
} }
void discord_activity_update(void) { void discord_activity_update(void) {

View file

@ -138,9 +138,6 @@ void djui_panel_host_mods_create(struct DjuiBase* caller) {
struct DjuiBase* layoutBase = &paginated->layout->base; struct DjuiBase* layoutBase = &paginated->layout->base;
for (int i = 0; i < gLocalMods.entryCount; i++) { for (int i = 0; i < gLocalMods.entryCount; i++) {
struct Mod* mod = gLocalMods.entries[i]; struct Mod* mod = gLocalMods.entries[i];
if (mod_get_is_autoexec(mod)) {
continue;
}
if (isRomHacks != (mod->incompatible && strstr(mod->incompatible, "romhack"))) { if (isRomHacks != (mod->incompatible && strstr(mod->incompatible, "romhack"))) {
continue; continue;
} }

View file

@ -18,12 +18,10 @@ void djui_panel_modlist_create(UNUSED struct DjuiBase* caller) {
gDjuiModList = NULL; gDjuiModList = NULL;
} }
u8 autoexecMod = mods_has_autoexec_mod();
// only create if we have mods // only create if we have mods
if (gActiveMods.entryCount - autoexecMod == 0) { return; } if (gActiveMods.entryCount == 0) { return; }
f32 bodyHeight = ((gActiveMods.entryCount - autoexecMod) * 32) + (gActiveMods.entryCount - 1 - autoexecMod) * 4; f32 bodyHeight = (gActiveMods.entryCount * 32) + (gActiveMods.entryCount - 1) * 4;
struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(MODLIST, MODS)); struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(MODLIST, MODS));
djui_three_panel_set_body_size(panel, bodyHeight); djui_three_panel_set_body_size(panel, bodyHeight);
gDjuiModList = panel; gDjuiModList = panel;
@ -42,7 +40,6 @@ void djui_panel_modlist_create(UNUSED struct DjuiBase* caller) {
for (int i = 0; i < gActiveMods.entryCount; i++) { for (int i = 0; i < gActiveMods.entryCount; i++) {
struct Mod* mod = gActiveMods.entries[i]; struct Mod* mod = gActiveMods.entries[i];
if (mod_get_is_autoexec(mod)) { continue; }
struct DjuiFlowLayout* row = djui_flow_layout_create(body); struct DjuiFlowLayout* row = djui_flow_layout_create(body);
djui_base_set_size_type(&row->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size_type(&row->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);

View file

@ -20,11 +20,6 @@ size_t mod_get_lua_size(struct Mod* mod) {
return size; return size;
} }
bool mod_get_is_autoexec(struct Mod* mod) {
if (!strcmp(mod->name, "autoexec") || !strcmp(mod->name, "autoexec.lua")) { return true; }
return false;
}
static void mod_activate_bin(struct ModFile* file) { static void mod_activate_bin(struct ModFile* file) {
// copy geo name // copy geo name
char geoName[64] = { 0 }; char geoName[64] = { 0 };

View file

@ -40,7 +40,6 @@ struct Mod {
}; };
size_t mod_get_lua_size(struct Mod* mod); size_t mod_get_lua_size(struct Mod* mod);
bool mod_get_is_autoexec(struct Mod* mod);
void mod_activate(struct Mod* mod); void mod_activate(struct Mod* mod);
void mod_clear(struct Mod* mod); void mod_clear(struct Mod* mod);
bool mod_load(struct Mods* mods, char* basePath, char* modName); bool mod_load(struct Mods* mods, char* basePath, char* modName);

View file

@ -27,7 +27,7 @@ void mods_get_main_mod_name(char* destination, u32 maxSize) {
for (u16 i = 0; i < gLocalMods.entryCount; i++) { for (u16 i = 0; i < gLocalMods.entryCount; i++) {
struct Mod* mod = gLocalMods.entries[i]; struct Mod* mod = gLocalMods.entries[i];
if (!mod->enabled || mod_get_is_autoexec(mod)) { continue; } if (!mod->enabled) { continue; }
size_t size = mod_get_lua_size(mod); size_t size = mod_get_lua_size(mod);
if (size > pickedSize) { if (size > pickedSize) {
picked = mod; picked = mod;
@ -61,13 +61,6 @@ u16 mods_get_character_select_count(void) {
return enabled; return enabled;
} }
u8 mods_has_autoexec_mod(void) {
for (u16 i = 0; i < gLocalMods.entryCount; i++) {
if (mod_get_is_autoexec(gLocalMods.entries[i])) { return TRUE; }
}
return FALSE;
}
static void mods_local_store_enabled(void) { static void mods_local_store_enabled(void) {
assert(sLocalEnabledPaths == NULL); assert(sLocalEnabledPaths == NULL);
struct LocalEnabledPath* prev = NULL; struct LocalEnabledPath* prev = NULL;
@ -125,14 +118,6 @@ bool mods_generate_remote_base_path(void) {
return true; return true;
} }
static struct Mod* get_autoexec_mod(void) {
for (u16 i = 0; i < gLocalMods.entryCount; i++) {
if (mod_get_is_autoexec(gLocalMods.entries[i])) {
return gLocalMods.entries[i];
}
}
}
void mods_activate(struct Mods* mods) { void mods_activate(struct Mods* mods) {
mods_clear(&gActiveMods); mods_clear(&gActiveMods);
@ -143,11 +128,8 @@ void mods_activate(struct Mods* mods) {
if (mod->enabled) { enabledCount++; } if (mod->enabled) { enabledCount++; }
} }
// is joining a game and has an autoexec mod
bool autoexec = mods == &gRemoteMods && mods_has_autoexec_mod();
// allocate // allocate
gActiveMods.entries = calloc(enabledCount + autoexec, sizeof(struct Mod*)); gActiveMods.entries = calloc(enabledCount, sizeof(struct Mod*));
if (gActiveMods.entries == NULL) { if (gActiveMods.entries == NULL) {
LOG_ERROR("Failed to allocate active mods table!"); LOG_ERROR("Failed to allocate active mods table!");
return; return;
@ -156,9 +138,8 @@ void mods_activate(struct Mods* mods) {
// copy enabled entries // copy enabled entries
gActiveMods.entryCount = 0; gActiveMods.entryCount = 0;
gActiveMods.size = 0; gActiveMods.size = 0;
for (int i = 0; i < mods->entryCount + autoexec; i++) { for (int i = 0; i < mods->entryCount; i++) {
// checks if the mod is out of the remote mods bounds and if so, use the autoexec mod struct Mod* mod = mods->entries[i];
struct Mod* mod = i == mods->entryCount ? get_autoexec_mod() : mods->entries[i];
if (mod->enabled) { if (mod->enabled) {
mod->index = gActiveMods.entryCount; mod->index = gActiveMods.entryCount;
gActiveMods.entries[gActiveMods.entryCount++] = mod; gActiveMods.entries[gActiveMods.entryCount++] = mod;

View file

@ -25,7 +25,6 @@ extern char gRemoteModsBasePath[];
void mods_get_main_mod_name(char* destination, u32 maxSize); void mods_get_main_mod_name(char* destination, u32 maxSize);
u16 mods_get_enabled_count(void); u16 mods_get_enabled_count(void);
u16 mods_get_character_select_count(void); u16 mods_get_character_select_count(void);
u8 mods_has_autoexec_mod(void);
bool mods_generate_remote_base_path(void); bool mods_generate_remote_base_path(void);
void mods_activate(struct Mods* mods); void mods_activate(struct Mods* mods);
void mods_clear(struct Mods* mods); void mods_clear(struct Mods* mods);

View file

@ -180,12 +180,10 @@ static void coopnet_populate_description(void) {
bufferLength -= versionLength; bufferLength -= versionLength;
// get mod strings // get mod strings
u8 autoexecMod = mods_has_autoexec_mod(); if (gActiveMods.entryCount <= 0) { return; }
if (gActiveMods.entryCount - autoexecMod <= 0) { return; } char* strings[gActiveMods.entryCount];
char* strings[gActiveMods.entryCount - autoexecMod];
for (int i = 0; i < gActiveMods.entryCount; i++) { for (int i = 0; i < gActiveMods.entryCount; i++) {
struct Mod* mod = gActiveMods.entries[i]; struct Mod* mod = gActiveMods.entries[i];
if (mod_get_is_autoexec(mod)) { continue; }
strings[i] = mod->name; strings[i] = mod->name;
} }
@ -196,7 +194,7 @@ static void coopnet_populate_description(void) {
bufferLength -= strlen(sep); bufferLength -= strlen(sep);
// concat mod strings // concat mod strings
str_seperator_concat(buffer, bufferLength, strings, gActiveMods.entryCount - autoexecMod, "\\#dcdcdc\\\n"); str_seperator_concat(buffer, bufferLength, strings, gActiveMods.entryCount, "\\#dcdcdc\\\n");
} }
void ns_coopnet_update(void) { void ns_coopnet_update(void) {

View file

@ -50,13 +50,12 @@ void network_send_mod_list(void) {
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version()); snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
LOG_INFO("sending version: %s", version); LOG_INFO("sending version: %s", version);
packet_write(&p, &version, sizeof(u8) * MAX_VERSION_LENGTH); packet_write(&p, &version, sizeof(u8) * MAX_VERSION_LENGTH);
packet_write(&p, &gActiveMods.entryCount - mods_has_autoexec_mod(), sizeof(u16)); packet_write(&p, &gActiveMods.entryCount, sizeof(u16));
network_send_to(0, &p); network_send_to(0, &p);
LOG_INFO("sent mod list (%u):", gActiveMods.entryCount); LOG_INFO("sent mod list (%u):", gActiveMods.entryCount);
for (u16 i = 0; i < gActiveMods.entryCount; i++) { for (u16 i = 0; i < gActiveMods.entryCount; i++) {
struct Mod* mod = gActiveMods.entries[i]; struct Mod* mod = gActiveMods.entries[i];
if (mod_get_is_autoexec(mod)) { continue; }
u16 nameLength = strlen(mod->name); u16 nameLength = strlen(mod->name);
if (nameLength > MOD_NAME_MAX_LENGTH) { nameLength = MOD_NAME_MAX_LENGTH; } if (nameLength > MOD_NAME_MAX_LENGTH) { nameLength = MOD_NAME_MAX_LENGTH; }

View file

@ -266,19 +266,6 @@ void game_exit(void) {
exit(0); exit(0);
} }
void enable_autoexec_mod(void) {
for (int i = 0; i < gLocalMods.entryCount; i ++) {
struct Mod* mod = gLocalMods.entries[i];
if (mod_get_is_autoexec(mod)) {
#ifdef DEVELOPMENT
mod->enabled = true;
#else
mod->enabled = false;
#endif
}
}
}
void* main_game_init(UNUSED void* arg) { void* main_game_init(UNUSED void* arg) {
const char *gamedir = gCLIOpts.GameDir[0] ? gCLIOpts.GameDir : FS_BASEDIR; const char *gamedir = gCLIOpts.GameDir[0] ? gCLIOpts.GameDir : FS_BASEDIR;
const char *userpath = gCLIOpts.SavePath[0] ? gCLIOpts.SavePath : sys_user_path(); const char *userpath = gCLIOpts.SavePath[0] ? gCLIOpts.SavePath : sys_user_path();
@ -296,7 +283,6 @@ void* main_game_init(UNUSED void* arg) {
mods_init(); mods_init();
enable_queued_mods(); enable_queued_mods();
enable_autoexec_mod();
if (gIsThreaded) { if (gIsThreaded) {
REFRESH_MUTEX( REFRESH_MUTEX(
gCurrLoadingSegment.percentage = 0; gCurrLoadingSegment.percentage = 0;