corrected some issues with smlua_text_utils

This commit is contained in:
Isaac0-dev 2024-12-10 10:58:34 +10:00
parent bdf908ea7e
commit 839fb38ca5
2 changed files with 8 additions and 5 deletions

View file

@ -4,6 +4,8 @@
#include "game/hardcoded.h"
#include "game/object_list_processor.h"
struct ModAudio;
void djui_hud_set_render_behind_hud(bool enable) {
LOG_LUA_LINE_WARNING("[LUA] djui_hud_set_render_behind_hud() is deprecated! Please use HOOK_ON_HUD_RENDER_BEHIND instead.");
if (!gLuaActiveMod) { return; }

View file

@ -79,7 +79,7 @@ static u8* smlua_text_utils_convert(const char* str) {
// Checks the first 3 characters
static bool str_starts_with_spaces(const char* str) {
for (u8 i = 0; i < 4; i++) {
for (u8 i = 0; i < 3; i++) {
if (str[i] != ' ') { return false; }
}
return true;
@ -206,12 +206,13 @@ void smlua_text_utils_dialog_replace(enum DialogId dialogId, UNUSED u32 unused,
void smlua_text_utils_course_acts_replace(s16 courseNum, const char* courseName, const char* act1, const char* act2, const char* act3, const char* act4, const char* act5, const char* act6) {
if (courseNum <= 0 || courseNum > COURSE_RR) { return; }
struct CourseName* courseActNames = gReplacedActNameTable[courseNum];
snprintf(courseActNames->name, 256, "%s", courseName + (3 * str_starts_with_spaces(courseName)));
snprintf(courseActNames->name, 256, "%s", courseName + (3 * (strlen(courseName) > 3)));
courseActNames->modIndex = gLuaActiveMod->index;
#define REPLACE_ACT_NAME(i) \
snprintf(courseActNames->actName[i-1].name, 256, "%s", act##i); \
courseActNames->actName[i-1].modIndex = gLuaActiveMod->index; \
#define REPLACE_ACT_NAME(i) { \
snprintf(courseActNames->actName[i-1].name, 256, "%s", act##i); \
courseActNames->actName[i-1].modIndex = gLuaActiveMod->index; \
}
REPLACE_ACT_NAME(1);
REPLACE_ACT_NAME(2);