diff --git a/.github/workflows/build-coop.yaml b/.github/workflows/build-coop.yaml index 88d47db15..166809e60 100644 --- a/.github/workflows/build-coop.yaml +++ b/.github/workflows/build-coop.yaml @@ -26,7 +26,7 @@ jobs: cd tools g++ -std=c++17 -o hash_file hash_file.cpp echo "::notice ::$(./hash_file ../build/us_pc/sm64coopdx)" - + - name: Zip the game run: | cd ./build/us_pc @@ -37,7 +37,7 @@ jobs: with: name: sm64coopdx-linux path: ./build/us_pc/sm64coopdx_Linux.zip - + build-steamos: if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[build]') }} runs-on: ubuntu-22.04 @@ -58,7 +58,7 @@ jobs: cd tools g++ -std=c++17 -o hash_file hash_file.cpp echo "::notice ::$(./hash_file ../build/us_pc/sm64coopdx)" - + - name: Zip the game run: | cd ./build/us_pc @@ -108,7 +108,7 @@ jobs: cd tools g++ -std=c++17 -o hash_file.exe hash_file.cpp echo "::notice ::$(./hash_file.exe ../build/us_pc/sm64coopdx.exe)" - + - name: Zip the game run: | cd ./build/us_pc @@ -158,7 +158,7 @@ jobs: cd tools g++ -std=c++17 -o hash_file.exe hash_file.cpp echo "::notice ::$(./hash_file.exe ../build/us_pc/sm64coopdx.exe)" - + - name: Zip the game run: | cd ./build/us_pc @@ -172,17 +172,36 @@ jobs: build-macos-arm: if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[build]') }} - runs-on: macos-latest + runs-on: macos-26 steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install dependencies run: | - brew install make mingw-w64 sdl2 pkg-config glew glfw3 coreutils + brew install make mingw-w64 pkg-config glfw3 coreutils + + - name: Compile glew + run: | + export MACOSX_DEPLOYMENT_TARGET=11 + curl -L -o glew.tar.gz https://github.com/nigels-com/glew/releases/download/glew-2.2.0/glew-2.2.0.tgz + tar -xzf glew.tar.gz + cd glew-2.2.0 + make SYSTEM=darwin CC="clang -arch arm64 -mmacosx-version-min=11" GLEW_PREFIX=/opt/homebrew GLEW_DEST=/opt/homebrew + make install GLEW_PREFIX=/opt/homebrew GLEW_DEST=/opt/homebrew + + - name: Compile SDL2 + run: | + curl -L -o SDL2.tar.gz https://github.com/libsdl-org/SDL/releases/download/release-2.30.9/SDL2-2.30.9.tar.gz + tar -xzf SDL2.tar.gz + cd SDL2-2.30.9 + ./configure --prefix=/opt/homebrew CC="clang -arch arm64 -mmacosx-version-min=11" + make -j$(sysctl -n hw.ncpu) + make install - name: Build the game run: | + export PKG_CONFIG_PATH=/opt/homebrew/lib/pkgconfig:$PKG_CONFIG_PATH gmake OSX_BUILD=1 -j$(sysctl -n hw.ncpu) - name: Code sign the app (Ad-Hoc) @@ -199,7 +218,7 @@ jobs: run: | cd ./build/us_pc zip -r sm64coopdx_macOS_ARM.zip sm64coopdx.app - + - name: Upload artifact uses: actions/upload-artifact@v4 with: @@ -215,7 +234,25 @@ jobs: - name: Install dependencies run: | - brew install make mingw-w64 gcc@9 sdl2 pkg-config glew glfw3 coreutils + brew install make mingw-w64 gcc@9 pkg-config glfw3 coreutils + + - name: Compile glew + run: | + export MACOSX_DEPLOYMENT_TARGET=10.15 + curl -L -o glew.tar.gz https://github.com/nigels-com/glew/releases/download/glew-2.2.0/glew-2.2.0.tgz + tar -xzf glew.tar.gz + cd glew-2.2.0 + make SYSTEM=darwin CC="clang -arch x86_64 -mmacosx-version-min=10.15" + make install + + - name: Compile SDL2 + run: | + curl -L -o SDL2.tar.gz https://github.com/libsdl-org/SDL/releases/download/release-2.30.9/SDL2-2.30.9.tar.gz + tar -xzf SDL2.tar.gz + cd SDL2-2.30.9 + ./configure --prefix=/usr/local CC="clang -arch x86_64 -mmacosx-version-min=10.15" + make -j$(sysctl -n hw.ncpu) + make install - name: Build the game run: | @@ -235,7 +272,7 @@ jobs: run: | cd ./build/us_pc zip -r sm64coopdx_macOS_Intel.zip sm64coopdx.app - + - name: Upload artifact uses: actions/upload-artifact@v4 with: diff --git a/Makefile b/Makefile index ee630d0a4..bd3ebcf11 100644 --- a/Makefile +++ b/Makefile @@ -64,12 +64,7 @@ ICON ?= 1 # Use .app (for macOS) USE_APP ?= 1 # Minimum macOS Version -# If our arch is arm, set to macOS 14 -ifeq ($(shell arch),arm64) - MIN_MACOS_VERSION ?= 14 -else - MIN_MACOS_VERSION ?= 10.15 -endif +MIN_MACOS_VERSION ?= 11 # Make some small adjustments for handheld devices HANDHELD ?= 0 @@ -1575,15 +1570,15 @@ endif # with no prerequisites, .SECONDARY causes no intermediate target to be removed .SECONDARY: +# Handle end of macOS compilation APP_DIR = ./sm64coopdx.app APP_CONTENTS_DIR = $(APP_DIR)/Contents APP_MACOS_DIR = $(APP_CONTENTS_DIR)/MacOS APP_RESOURCES_DIR = $(APP_CONTENTS_DIR)/Resources - ifeq ($(OSX_BUILD),1) - GLEW_LIB := $(shell find $(BREW_PREFIX)/Cellar/glew | grep libGLEW.2.2.0 | sort -n | uniq) - SDL2_LIB := $(shell find $(BREW_PREFIX)/Cellar/sdl2 | grep libSDL2- | sort -n | uniq) + GLEW_LIB := $(shell find $(BREW_PREFIX)/lib/ | grep libGLEW.2.2.0 | sort -n | uniq) + SDL2_LIB := $(shell find $(BREW_PREFIX)/lib/ | grep libSDL2- | sort -n | uniq) endif all: @@ -1605,14 +1600,20 @@ all: cp build/us_pc/libcoopnet.dylib $(APP_MACOS_DIR); \ cp build/us_pc/libjuice.1.6.2.dylib $(APP_MACOS_DIR); \ cp $(SDL2_LIB) $(APP_MACOS_DIR)/libSDL2.dylib; \ - install_name_tool -change $(BREW_PREFIX)/opt/sdl2/lib/libSDL2-2.0.0.dylib @executable_path/libSDL2.dylib $(APP_MACOS_DIR)/sm64coopdx; > /dev/null 2>&1 \ - install_name_tool -id @executable_path/libSDL2.dylib $(APP_MACOS_DIR)/libSDL2.dylib; > /dev/null 2>&1 \ + install_name_tool -change $(BREW_PREFIX)/lib/libSDL2-2.0.0.dylib @executable_path/libSDL2.dylib $(APP_MACOS_DIR)/sm64coopdx > /dev/null 2>&1; \ + install_name_tool -change $(BREW_PREFIX)/opt/sdl2/lib/libSDL2-2.0.0.dylib @executable_path/libSDL2.dylib $(APP_MACOS_DIR)/sm64coopdx > /dev/null 2>&1; \ + install_name_tool -id @executable_path/libSDL2.dylib $(APP_MACOS_DIR)/libSDL2.dylib > /dev/null 2>&1; \ codesign --force --deep --sign - $(APP_MACOS_DIR)/libSDL2.dylib; \ cp $(GLEW_LIB) $(APP_MACOS_DIR)/libGLEW.dylib; \ - install_name_tool -change $(BREW_PREFIX)/opt/glew/lib/libGLEW.2.2.dylib @executable_path/libGLEW.dylib $(APP_MACOS_DIR)/sm64coopdx; > /dev/null 2>&1 \ - install_name_tool -id @executable_path/libGLEW.dylib $(APP_MACOS_DIR)/libGLEW.dylib; > /dev/null 2>&1 \ + install_name_tool -change $(BREW_PREFIX)/lib/libGLEW.2.2.0.dylib @executable_path/libGLEW.dylib $(APP_MACOS_DIR)/sm64coopdx > /dev/null 2>&1; \ + install_name_tool -change $(BREW_PREFIX)/opt/glew/lib/libGLEW.2.2.0.dylib @executable_path/libGLEW.dylib $(APP_MACOS_DIR)/sm64coopdx > /dev/null 2>&1; \ + install_name_tool -id @executable_path/libGLEW.dylib $(APP_MACOS_DIR)/libGLEW.dylib > /dev/null 2>&1; \ codesign --force --deep --sign - $(APP_MACOS_DIR)/libGLEW.dylib; \ - cp res/icon.icns $(APP_RESOURCES_DIR)/icon.icns; \ + mkdir res/build; \ + xcrun actool res/icon.icon --compile res/build --app-icon icon --output-partial-info-plist res/build/Info.plist --minimum-deployment-target $(MIN_MACOS_VERSION) --platform macosx > /dev/null 2>&1; \ + mv res/build/Assets.car $(APP_RESOURCES_DIR)/; \ + cp res/icon.icns $(APP_RESOURCES_DIR)/; \ + rm -rf res/build; \ echo "APPL????" > $(APP_CONTENTS_DIR)/PkgInfo; \ echo '' > $(APP_CONTENTS_DIR)/Info.plist; \ echo '' >> $(APP_CONTENTS_DIR)/Info.plist; \ @@ -1623,7 +1624,7 @@ all: echo ' CFBundleIconFile' >> $(APP_CONTENTS_DIR)/Info.plist; \ echo ' icon' >> $(APP_CONTENTS_DIR)/Info.plist; \ echo ' CFBundleIconName' >> $(APP_CONTENTS_DIR)/Info.plist; \ - echo ' AppIcon' >> $(APP_CONTENTS_DIR)/Info.plist; \ + echo ' icon' >> $(APP_CONTENTS_DIR)/Info.plist; \ echo ' CFBundleDisplayName' >> $(APP_CONTENTS_DIR)/Info.plist; \ echo ' sm64coopdx' >> $(APP_CONTENTS_DIR)/Info.plist; \ echo ' ' >> $(APP_CONTENTS_DIR)/Info.plist; \ diff --git a/autogen/convert_constants.py b/autogen/convert_constants.py index 46b521710..409cd8427 100644 --- a/autogen/convert_constants.py +++ b/autogen/convert_constants.py @@ -535,6 +535,8 @@ def def_constant(fname, processed_constant, skip_constant): continue if '"' in c[1]: s += '\n--- @type string\n' + elif "." in c[1]: + s += '\n--- @type number\n' else: s += '\n--- @type integer\n' s += '%s = %s\n' % (c[0], c[1]) diff --git a/autogen/convert_functions.py b/autogen/convert_functions.py index 5a12779b7..9a9f7d53a 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -80,6 +80,7 @@ in_files = [ "src/audio/seqplayer.h", "src/engine/lighting_engine.h", "src/pc/network/sync_object.h", + "src/audio/load.h", ] override_allowed_functions = { @@ -99,6 +100,7 @@ override_allowed_functions = { "src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "set_dialog_box_state", "handle_special_dialog_text" ], "src/audio/seqplayer.h": [ "sequence_player_set_tempo", "sequence_player_set_tempo_acc", "sequence_player_set_transposition", "sequence_player_get_tempo", "sequence_player_get_tempo_acc", "sequence_player_get_transposition", "sequence_player_get_volume", "sequence_player_get_fade_volume", "sequence_player_get_mute_volume_scale" ], "src/pc/network/sync_object.h": [ "sync_object_is_initialized", "sync_object_is_owned_locally", "sync_object_get_object" ], + "src/audio/load.h": [ "set_sound_bank_override" ], } override_disallowed_functions = { @@ -120,14 +122,14 @@ override_disallowed_functions = { "src/game/sound_init.h": [ "_loop_", "thread4_", "set_sound_mode" ], "src/pc/network/network_utils.h": [ "network_get_player_text_color[^_]" ], "src/pc/network/network_player.h": [ "_init", "_connected[^_]", "_shutdown", "_disconnected", "_update", "construct_player_popup", "network_player_name_valid" ], - "src/game/object_helpers.c": [ "spawn_obj", "^bhv_", "abs[fi]", "^bit_shift", "_debug$", "^stub_", "_set_model", "cur_obj_set_direction_table", "cur_obj_progress_direction_table" ], - "src/game/obj_behaviors.c": [ "debug_", "turn_obj_away_from_surface" ], + "src/game/object_helpers.c": [ "spawn_obj", "^bhv_", "geo_", "abs[fi]", "^bit_shift", "_debug$", "^stub_", "_set_model", "cur_obj_set_direction_table", "cur_obj_progress_direction_table" ], + "src/game/obj_behaviors.c": [ "debug_", "geo_", "turn_obj_away_from_surface"], "src/game/obj_behaviors_2.c": [ "wiggler_jumped_on_attack_handler", "huge_goomba_weakly_attacked" ], "src/game/spawn_sound.h": [ "exec_anim_sound_state" ], "src/game/level_info.h": [ "_name_table", "convert_string_" ], "src/pc/lua/utils/smlua_obj_utils.h": [ "spawn_object_remember_field" ], - "src/game/camera.h": [ "update_camera", "init_camera", "stub_camera", "^reset_camera", "move_point_along_spline", "romhack_camera_init_settings", "romhack_camera_reset_settings" ], - "src/game/behavior_actions.h": [ "bhv_dust_smoke_loop", "bhv_init_room" ], + "src/game/camera.h": [ "geo_", "update_camera", "init_camera", "stub_camera", "^reset_camera", "move_point_along_spline", "romhack_camera_init_settings", "romhack_camera_reset_settings" ], + "src/game/behavior_actions.h": [ "bhv_dust_smoke_loop", "bhv_init_room", "geo_" ], "src/pc/lua/utils/smlua_audio_utils.h": [ "smlua_audio_utils_override", "audio_custom_shutdown", "smlua_audio_custom_deinit", "audio_sample_destroy_pending_copies", "audio_custom_update_volume" ], "src/pc/lua/utils/smlua_level_utils.h": [ "smlua_level_util_reset" ], "src/pc/lua/utils/smlua_text_utils.h": [ "smlua_text_utils_init", "smlua_text_utils_shutdown", "smlua_text_utils_dialog_get_unmodified"], @@ -825,7 +827,7 @@ def build_param(fid, param, i): lot = translate_type_to_lot(ptype) s = ' %s %s = (%s)smlua_to_cobject(L, %d, %s);' % (ptype, pid, ptype, i, lot) - if '???' in lot or "GRAPHNODE" in lot: + if '???' in lot: s = '//' + s + ' <--- UNIMPLEMENTED' else: s = ' ' + s @@ -949,7 +951,7 @@ def build_function(function, do_extern): sparam = build_param(fid, param, i) param_var, param_value = sparam.split('=') param_type = param_var.replace(pid, '').strip() - s += ' %s = (%s) NULL;\n' % (param_var.strip(), param_type) + s += ' %s = (%s) %s;\n' % (param_var.strip(), param_type, "NULL" if '*' in param_type else "0") s += ' if (top >= %d) {\n' % (i) s += ' %s = %s\n' % (pid, param_value.strip()) s += ' if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %%u for function \'%%s\'", %d, "%s"); return 0; }\n' % (i, fid) @@ -1340,7 +1342,7 @@ def doc_function(fname, function): s += '- None\n' s += '\n### Returns\n' - if rtype != None: + if len(rvalues) > 0: for _, ptype, plink in rvalues: if plink: s += '- [%s](%s)\n' % (ptype, plink) diff --git a/autogen/gen_hooks.py b/autogen/gen_hooks.py index 73d74769f..e2fe453b3 100644 --- a/autogen/gen_hooks.py +++ b/autogen/gen_hooks.py @@ -30,7 +30,7 @@ SMLUA_CALL_EVENT_HOOKS_SET_HOOK_RESULT = """ SMLUA_CALL_EVENT_HOOKS_CALLBACK = """ // call the callback if (0 != smlua_call_hook(L, {n_inputs}, {n_outputs}, 0, hook->mod[i], hook->modFile[i])) {{ - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[{hook_type}]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[{hook_type}], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; }}{set_hook_result} """ diff --git a/autogen/lua_constants/built-in.lua b/autogen/lua_constants/built-in.lua index f60dd6f47..58b436d3a 100644 --- a/autogen/lua_constants/built-in.lua +++ b/autogen/lua_constants/built-in.lua @@ -306,6 +306,49 @@ IN_OUT_BOUNCE = function (x) return x < 0.5 and (1 - OUT_BOUNCE(1 - 2 * x)) / 2 ---@return number OUT_IN_BOUNCE = function (x) return x < 0.5 and 0.5 * OUT_BOUNCE(x * 2) or 0.5 + 0.5 * IN_BOUNCE(2 * x - 1) end +--- @alias EasingFunction +--- | `IN_SINE` +--- | `OUT_SINE` +--- | `IN_OUT_SINE` +--- | `OUT_IN_SINE` +--- | `IN_QUAD` +--- | `OUT_QUAD` +--- | `IN_OUT_QUAD` +--- | `OUT_IN_QUAD` +--- | `IN_CUBIC` +--- | `OUT_CUBIC` +--- | `IN_OUT_CUBIC` +--- | `OUT_IN_CUBIC` +--- | `IN_QUART` +--- | `OUT_QUART` +--- | `IN_OUT_QUART` +--- | `OUT_IN_QUART` +--- | `IN_QUINT` +--- | `OUT_QUINT` +--- | `IN_OUT_QUINT` +--- | `OUT_IN_QUINT` +--- | `IN_EXPO` +--- | `OUT_EXPO` +--- | `IN_OUT_EXPO` +--- | `OUT_IN_EXPO` +--- | `IN_CIRC` +--- | `OUT_CIRC` +--- | `IN_OUT_CIRC` +--- | `OUT_IN_CIRC` +--- | `IN_BACK` +--- | `OUT_BACK` +--- | `IN_OUT_BACK` +--- | `OUT_IN_BACK` +--- | `IN_ELASTIC` +--- | `OUT_ELASTIC` +--- | `IN_OUT_ELASTIC` +--- | `OUT_IN_ELASTIC` +--- | `IN_BOUNCE` +--- | `OUT_BOUNCE` +--- | `IN_OUT_BOUNCE` +--- | `OUT_IN_BOUNCE` +--- | fun(x: number): number + -------------------- -- math functions -- -------------------- @@ -385,7 +428,7 @@ function math.round(x) return x > 0 and __math_floor(x + 0.5) or __math_ceil(x - 0.5) end ---- @param t function | number +--- @param t EasingFunction | number --- @param a number --- @param b number --- @param x number diff --git a/autogen/lua_definitions/constants.lua b/autogen/lua_definitions/constants.lua index f2d30851a..1d7dfb2dc 100644 --- a/autogen/lua_definitions/constants.lua +++ b/autogen/lua_definitions/constants.lua @@ -308,6 +308,49 @@ IN_OUT_BOUNCE = function (x) return x < 0.5 and (1 - OUT_BOUNCE(1 - 2 * x)) / 2 ---@return number OUT_IN_BOUNCE = function (x) return x < 0.5 and 0.5 * OUT_BOUNCE(x * 2) or 0.5 + 0.5 * IN_BOUNCE(2 * x - 1) end +--- @alias EasingFunction +--- | `IN_SINE` +--- | `OUT_SINE` +--- | `IN_OUT_SINE` +--- | `OUT_IN_SINE` +--- | `IN_QUAD` +--- | `OUT_QUAD` +--- | `IN_OUT_QUAD` +--- | `OUT_IN_QUAD` +--- | `IN_CUBIC` +--- | `OUT_CUBIC` +--- | `IN_OUT_CUBIC` +--- | `OUT_IN_CUBIC` +--- | `IN_QUART` +--- | `OUT_QUART` +--- | `IN_OUT_QUART` +--- | `OUT_IN_QUART` +--- | `IN_QUINT` +--- | `OUT_QUINT` +--- | `IN_OUT_QUINT` +--- | `OUT_IN_QUINT` +--- | `IN_EXPO` +--- | `OUT_EXPO` +--- | `IN_OUT_EXPO` +--- | `OUT_IN_EXPO` +--- | `IN_CIRC` +--- | `OUT_CIRC` +--- | `IN_OUT_CIRC` +--- | `OUT_IN_CIRC` +--- | `IN_BACK` +--- | `OUT_BACK` +--- | `IN_OUT_BACK` +--- | `OUT_IN_BACK` +--- | `IN_ELASTIC` +--- | `OUT_ELASTIC` +--- | `IN_OUT_ELASTIC` +--- | `OUT_IN_ELASTIC` +--- | `IN_BOUNCE` +--- | `OUT_BOUNCE` +--- | `IN_OUT_BOUNCE` +--- | `OUT_IN_BOUNCE` +--- | fun(x: number): number + -------------------- -- math functions -- -------------------- @@ -387,7 +430,7 @@ function math.round(x) return x > 0 and __math_floor(x + 0.5) or __math_ceil(x - 0.5) end ---- @param t function | number +--- @param t EasingFunction | number --- @param a number --- @param b number --- @param x number @@ -2717,6 +2760,42 @@ CONSOLE_MESSAGE_ERROR = 2 --- @type ConsoleMessageLevel --- | `CONSOLE_MESSAGE_WARNING` --- | `CONSOLE_MESSAGE_ERROR` +--- @type number +ROTATION_PIVOT_X_LEFT = 0.0 + +--- @type number +ROTATION_PIVOT_X_CENTER = 0.5 + +--- @type number +ROTATION_PIVOT_X_RIGHT = 1.0 + +--- @type number +ROTATION_PIVOT_Y_TOP = 0.0 + +--- @type number +ROTATION_PIVOT_Y_CENTER = 0.5 + +--- @type number +ROTATION_PIVOT_Y_BOTTOM = 1.0 + +--- @type number +TEXT_HALIGN_LEFT = 0.0 + +--- @type number +TEXT_HALIGN_CENTER = 0.5 + +--- @type number +TEXT_HALIGN_RIGHT = 1.0 + +--- @type number +TEXT_VALIGN_TOP = 0.0 + +--- @type number +TEXT_VALIGN_CENTER = 0.5 + +--- @type number +TEXT_VALIGN_BOTTOM = 1.0 + RESOLUTION_DJUI = 0 --- @type HudUtilsResolution RESOLUTION_N64 = 1 --- @type HudUtilsResolution RESOLUTION_COUNT = 2 --- @type HudUtilsResolution @@ -2735,16 +2814,18 @@ FILTER_COUNT = 2 --- @type HudUtilsFilter --- | `FILTER_LINEAR` --- | `FILTER_COUNT` -FONT_NORMAL = 0 --- @type DjuiFontType -FONT_MENU = 1 --- @type DjuiFontType -FONT_HUD = 2 --- @type DjuiFontType -FONT_ALIASED = 3 --- @type DjuiFontType -FONT_CUSTOM_HUD = 4 --- @type DjuiFontType -FONT_RECOLOR_HUD = 5 --- @type DjuiFontType -FONT_SPECIAL = 6 --- @type DjuiFontType -FONT_COUNT = 7 --- @type DjuiFontType +FONT_LEGACY = -1 --- @type DjuiFontType +FONT_NORMAL = 0 --- @type DjuiFontType +FONT_MENU = 1 --- @type DjuiFontType +FONT_HUD = 2 --- @type DjuiFontType +FONT_ALIASED = 3 --- @type DjuiFontType +FONT_CUSTOM_HUD = 4 --- @type DjuiFontType +FONT_RECOLOR_HUD = 5 --- @type DjuiFontType +FONT_SPECIAL = 6 --- @type DjuiFontType +FONT_COUNT = 7 --- @type DjuiFontType --- @alias DjuiFontType +--- | `FONT_LEGACY` --- | `FONT_NORMAL` --- | `FONT_MENU` --- | `FONT_HUD` @@ -3276,7 +3357,7 @@ PVP_ATTACK_KNOCKBACK_TIMER_DEFAULT = 10 PVP_ATTACK_KNOCKBACK_TIMER_OVERRIDE = -5 --- @type integer -PVP_ATTACK_OVERRIDE_VANILLA_INVINCIBILITY = 0x0000FFFF +PVP_ATTACK_KNOCKBACK_ACTION_ARG = 0x10000 --- @type integer INT_STATUS_ATTACK_MASK = 0x000000FF @@ -3635,7 +3716,7 @@ HUD_DISPLAY_DEFAULT = HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_CO --- | `HUD_DISPLAY_DEFAULT` --- @type integer -LE_MAX_LIGHTS = 512 +LE_MAX_LIGHTS = 1024 LE_MODE_AFFECT_ALL_SHADED_AND_COLORED = 0 --- @type LEMode LE_MODE_AFFECT_ALL_SHADED = 1 --- @type LEMode @@ -8126,7 +8207,13 @@ HOOK_MARIO_OVERRIDE_FLOOR_CLASS = 56 --- @type LuaHookedEventType HOOK_ON_ADD_SURFACE = 57 --- @type LuaHookedEventType HOOK_ON_CLEAR_AREAS = 58 --- @type LuaHookedEventType HOOK_ON_PACKET_BYTESTRING_RECEIVE = 59 --- @type LuaHookedEventType -HOOK_MAX = 60 --- @type LuaHookedEventType +HOOK_ON_FIND_WALL_COLLISION = 60 --- @type LuaHookedEventType +HOOK_ON_FIND_CEIL = 61 --- @type LuaHookedEventType +HOOK_ON_FIND_FLOOR = 62 --- @type LuaHookedEventType +HOOK_ON_FIND_WATER_LEVEL = 63 --- @type LuaHookedEventType +HOOK_ON_FIND_POISON_GAS_LEVEL = 64 --- @type LuaHookedEventType +HOOK_ON_FIND_SURFACE_ON_RAY = 65 --- @type LuaHookedEventType +HOOK_MAX = 66 --- @type LuaHookedEventType --- @alias LuaHookedEventType --- | `HOOK_UPDATE` @@ -8189,8 +8276,17 @@ HOOK_MAX = 60 --- @type LuaHookedEventType --- | `HOOK_ON_ADD_SURFACE` --- | `HOOK_ON_CLEAR_AREAS` --- | `HOOK_ON_PACKET_BYTESTRING_RECEIVE` +--- | `HOOK_ON_FIND_WALL_COLLISION` +--- | `HOOK_ON_FIND_CEIL` +--- | `HOOK_ON_FIND_FLOOR` +--- | `HOOK_ON_FIND_WATER_LEVEL` +--- | `HOOK_ON_FIND_POISON_GAS_LEVEL` +--- | `HOOK_ON_FIND_SURFACE_ON_RAY` --- | `HOOK_MAX` +--- @type integer +MAX_HOOKED_BEHAVIORS = 1024 + HUD_DISPLAY_LIVES = 0 --- @type HudDisplayValue HUD_DISPLAY_COINS = 1 --- @type HudDisplayValue HUD_DISPLAY_STARS = 2 --- @type HudDisplayValue @@ -11170,7 +11266,7 @@ COOP_OBJ_FLAG_NON_SYNC = (1 << 2) COOP_OBJ_FLAG_INITIALIZED = (1 << 3) --- @type string -SM64COOPDX_VERSION = "v1.4.1" +SM64COOPDX_VERSION = "v1.4.2" --- @type string VERSION_TEXT = "v" diff --git a/autogen/lua_definitions/functions.lua b/autogen/lua_definitions/functions.lua index 816cc8018..08b0b1587 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -3030,7 +3030,7 @@ end --- @param name string --- @return BehaviorId ---- gets a behavior ID from a behavior name +--- Gets a behavior ID from a behavior name function get_id_from_behavior_name(name) -- ... end @@ -3856,7 +3856,9 @@ function djui_hud_reset_color() -- ... end ---- @return HudUtilsRotation +--- @return integer rotation +--- @return number pivotX +--- @return number pivotY --- Gets the current DJUI HUD rotation function djui_hud_get_rotation() -- ... @@ -3881,6 +3883,29 @@ function djui_hud_set_rotation_interpolated(prevRotation, prevPivotX, prevPivotY -- ... end +--- @return number textHAlign +--- @return number textVAlign +--- Gets the current DJUI HUD text alignment +function djui_hud_get_text_alignment() + -- ... +end + +--- @param textHAlign number +--- @param textVAlign number +--- Sets the current DJUI HUD text alignment +function djui_hud_set_text_alignment(textHAlign, textVAlign) + -- ... +end + +--- @param prevTextHAlign number +--- @param prevTextVAlign number +--- @param textHAlign number +--- @param textVAlign number +--- Sets the current DJUI HUD text alignment interpolated +function djui_hud_set_text_alignment_interpolated(prevTextHAlign, prevTextVAlign, textHAlign, textVAlign) + -- ... +end + --- @return integer --- Gets the screen width in the current DJUI HUD resolution function djui_hud_get_screen_width() @@ -5103,6 +5128,12 @@ function le_set_ambient_color(r, g, b) -- ... end +--- @param count integer +--- Sets the max amount of lights that can affect a vertex +function le_set_max_lights_per_vertex(count) + -- ... +end + --- @param pos Vec3f --- @param out Color --- @param lightIntensityScalar number @@ -5234,6 +5265,12 @@ function le_set_light_use_surface_normals(id, useSurfaceNormals) -- ... end +--- @param bank integer +--- Overrides the soundbank, set to -1 to reset +function set_sound_bank_override(bank) + -- ... +end + --- @param m MarioState --- @return integer --- Checks if Mario's current animation has reached its final frame (i.e., the last valid frame in the animation). Useful for deciding when to transition out of an animation-driven action @@ -10171,6 +10208,12 @@ function smlua_audio_utils_replace_sequence(sequenceId, bankId, defaultVolume, m -- ... end +--- @return integer +--- Allocates a new sequence ID +function smlua_audio_utils_allocate_sequence() + -- ... +end + --- @param filename string --- @return ModAudio --- Loads an `audio` stream by `filename` (with extension) @@ -11516,6 +11559,12 @@ function get_dialog_response() -- ... end +--- @return integer +--- Gets the active time stop flags, used to freeze specific objects during cutscenes +function get_time_stop_flags() + -- ... +end + --- @return string --- Gets the local discord ID if it isn't disabled, otherwise "0" is returned function get_local_discord_id() @@ -11604,6 +11653,14 @@ function get_active_mod() -- ... end +--- @param mod Mod +--- @param subDirectory? string +--- @return table +--- Gets all files a mod contains +function get_mod_files(mod, subDirectory) + -- ... +end + --- @param title string --- Sets the window title to a custom title function set_window_title(title) @@ -11622,35 +11679,42 @@ function get_os_name() end --- @return GraphNodeRoot ---- Gets the current GraphNodeRoot +--- Gets the current root node being processed function geo_get_current_root() -- ... end --- @return GraphNodeMasterList ---- Gets the current GraphNodeMasterList +--- Gets the current master list node being processed function geo_get_current_master_list() -- ... end --- @return GraphNodePerspective ---- Gets the current GraphNodePerspective +--- Gets the current perspective node being processed function geo_get_current_perspective() -- ... end --- @return GraphNodeCamera ---- Gets the current GraphNodeCamera +--- Gets the current camera node being processed function geo_get_current_camera() -- ... end --- @return GraphNodeHeldObject ---- Gets the current GraphNodeHeldObject +--- Gets the current held object node being processed function geo_get_current_held_object() -- ... end +--- @param node GraphNode +--- @param obj GraphNodeObject +--- Skips graph node interpolation for a frame +function geo_skip_interpolation(node, obj) + -- ... +end + --- @param tex Pointer_Texture --- @return table --- Converts a texture's pixels to a Lua table. Returns nil if failed. Otherwise, returns a 1-indexed table of RGBA pixels @@ -12062,6 +12126,18 @@ function set_whirlpools(x, y, z, strength, area, index) -- ... end +--- @param o Object +--- Skips object interpolation for a frame +function obj_skip_interpolation(o) + -- ... +end + +--- @param o Object +--- Skips animation interpolation for a frame +function obj_anim_skip_interpolation(o) + -- ... +end + --- Resets every modified dialog back to vanilla function smlua_text_utils_reset_all() -- ... diff --git a/autogen/lua_definitions/manual.lua b/autogen/lua_definitions/manual.lua index 2ba4a4366..2ce161f8a 100644 --- a/autogen/lua_definitions/manual.lua +++ b/autogen/lua_definitions/manual.lua @@ -127,7 +127,7 @@ function update_chat_command_description(command, description) end --- @param hookEventType LuaHookedEventType When a function should run ---- @param func fun(...: any): any The function to run +--- @param func fun(...: any): any?, any? The function to run --- Different hooks can pass in different parameters and have different return values. Be sure to read the hooks guide for more information. function hook_event(hookEventType, func) -- ... diff --git a/autogen/lua_definitions/structs.lua b/autogen/lua_definitions/structs.lua index dca13a197..dc783a555 100644 --- a/autogen/lua_definitions/structs.lua +++ b/autogen/lua_definitions/structs.lua @@ -955,14 +955,6 @@ --- @field public translation Vec3s --- @field public rotation Vec3s ---- @class HudUtilsRotation ---- @field public rotation number ---- @field public rotationDiff number ---- @field public prevPivotX number ---- @field public prevPivotY number ---- @field public pivotX number ---- @field public pivotY number - --- @class InstantWarp --- @field public id integer --- @field public area integer diff --git a/data/behavior_table.c b/data/behavior_table.c index 6fbdf122b..1312c363f 100644 --- a/data/behavior_table.c +++ b/data/behavior_table.c @@ -597,5 +597,11 @@ enum BehaviorId get_id_from_behavior_name(const char* name) { return i; } } + for (int i = 0; i < gHookedBehaviorsCount; i++) { + struct LuaHookedBehavior *hooked = &gHookedBehaviors[i]; + if (hooked->bhvName && !strcmp(name, hooked->bhvName)) { + return hooked->overrideId; + } + } return id_bhv_max_count; } diff --git a/data/dynos_bin_behavior.cpp b/data/dynos_bin_behavior.cpp index c6150025f..805a31ac8 100644 --- a/data/dynos_bin_behavior.cpp +++ b/data/dynos_bin_behavior.cpp @@ -2449,6 +2449,48 @@ static void ParseBehaviorScriptSymbol(GfxData *aGfxData, DataNode &aCommands) { + u8 bhvCommand = (*aBhv >> 24) & 0xFF; + for (const auto &commandToCheck : aCommands) { + if (bhvCommand == ((commandToCheck >> 24) & 0xFF)) { + return true; + } + } + return false; +} + +static bool DynOS_Bhv_Validate(GfxData *aGfxData, const DataNode *aNode) { + + // 1st command must be BEGIN + if (!DynOS_Bhv_CheckCommands(aNode->mData + 0, { BEGIN(0) })) { + PrintDataError(" ERROR: Validation failed for behavior %s: First command of the script must be BEGIN.", aNode->mName.begin()); + return false; + } + + // 2nd command must be ID + if (!DynOS_Bhv_CheckCommands(aNode->mData + 1, { ID(0) })) { + PrintDataError(" ERROR: Validation failed for behavior %s: Second command of the script must be ID.", aNode->mName.begin()); + return false; + } + + // Last command must be a terminating command + if (!DynOS_Bhv_CheckCommands(aNode->mData + aNode->mSize - 1, { + CALL(0), + RETURN(), + GOTO(0), + END_LOOP(), + BREAK(), + DEACTIVATE(), + CALL_EXT(0), + GOTO_EXT(0), + })) { + PrintDataError(" ERROR: Validation failed for behavior %s: Last command of the script must be one of:\n CALL, RETURN, GOTO, END_LOOP, BREAK, DEACTIVATE", aNode->mName.begin()); + return false; + } + + return true; +} + DataNode *DynOS_Bhv_Parse(GfxData *aGfxData, DataNode *aNode, bool aDisplayPercent) { if (aNode->mData) return aNode; @@ -2460,9 +2502,13 @@ DataNode *DynOS_Bhv_Parse(GfxData *aGfxData, DataNodemErrorCount == 0) { PrintNoNewLine("%3d%%\b\b\b\b", (s32) (_TokenIndex * 100) / aNode->mTokens.Count()); } } - if (aDisplayPercent && aGfxData->mErrorCount == 0) { Print("100%%"); } aNode->mSize = (u32)(_Head - aNode->mData); aNode->mLoadIndex = aGfxData->mLoadIndex++; + + // Validate behavior script + DynOS_Bhv_Validate(aGfxData, aNode); + + if (aDisplayPercent && aGfxData->mErrorCount == 0) { Print("100%%"); } return aNode; } @@ -2592,6 +2638,12 @@ static DataNode *DynOS_Bhv_Load(BinFile *aFile, GfxData *aGfxDat } } + // Validate it + if (!DynOS_Bhv_Validate(aGfxData, _Node)) { + Delete(_Node); + return NULL; + } + // Add it if (aGfxData != NULL) { aGfxData->mBehaviorScripts.Add(_Node); diff --git a/data/dynos_mgr_anim.cpp b/data/dynos_mgr_anim.cpp index af7f319f4..21db5f690 100644 --- a/data/dynos_mgr_anim.cpp +++ b/data/dynos_mgr_anim.cpp @@ -8,7 +8,7 @@ extern "C" { #include "behavior_data.h" #include "pc/lua/smlua_hooks.h" -s8 geo_get_processing_mario_index(void); +s8 geo_get_processing_mario_index(struct Object *obj); } // @@ -77,7 +77,7 @@ void DynOS_Anim_Swap(void *aPtr) { // Animation index s32 _AnimIndex = -1; - s8 index = geo_get_processing_mario_index(); + s8 index = geo_get_processing_mario_index(_Object); if (index != -1) { _AnimIndex = RetrieveCurrentMarioAnimationIndex(index); diff --git a/docs/lua/constants.md b/docs/lua/constants.md index 7632878e6..cf00279f7 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -1149,6 +1149,18 @@
## [djui_hud_utils.h](#djui_hud_utils.h) +- ROTATION_PIVOT_X_LEFT +- ROTATION_PIVOT_X_CENTER +- ROTATION_PIVOT_X_RIGHT +- ROTATION_PIVOT_Y_TOP +- ROTATION_PIVOT_Y_CENTER +- ROTATION_PIVOT_Y_BOTTOM +- TEXT_HALIGN_LEFT +- TEXT_HALIGN_CENTER +- TEXT_HALIGN_RIGHT +- TEXT_VALIGN_TOP +- TEXT_VALIGN_CENTER +- TEXT_VALIGN_BOTTOM ### [enum HudUtilsResolution](#HudUtilsResolution) | Identifier | Value | @@ -1167,6 +1179,7 @@ ### [enum DjuiFontType](#DjuiFontType) | Identifier | Value | | :--------- | :---- | +| FONT_LEGACY | -1 | | FONT_NORMAL | 0 | | FONT_MENU | 1 | | FONT_HUD | 2 | @@ -1459,7 +1472,7 @@ - ATTACK_FROM_BELOW - PVP_ATTACK_KNOCKBACK_TIMER_DEFAULT - PVP_ATTACK_KNOCKBACK_TIMER_OVERRIDE -- PVP_ATTACK_OVERRIDE_VANILLA_INVINCIBILITY +- PVP_ATTACK_KNOCKBACK_ACTION_ARG - INT_STATUS_ATTACK_MASK - INT_STATUS_HOOT_GRABBED_BY_MARIO - INT_STATUS_MARIO_UNK1 @@ -3524,7 +3537,14 @@ | HOOK_ON_ADD_SURFACE | 57 | | HOOK_ON_CLEAR_AREAS | 58 | | HOOK_ON_PACKET_BYTESTRING_RECEIVE | 59 | -| HOOK_MAX | 60 | +| HOOK_ON_FIND_WALL_COLLISION | 60 | +| HOOK_ON_FIND_CEIL | 61 | +| HOOK_ON_FIND_FLOOR | 62 | +| HOOK_ON_FIND_WATER_LEVEL | 63 | +| HOOK_ON_FIND_POISON_GAS_LEVEL | 64 | +| HOOK_ON_FIND_SURFACE_ON_RAY | 65 | +| HOOK_MAX | 66 | +- MAX_HOOKED_BEHAVIORS [:arrow_up_small:](#) diff --git a/docs/lua/functions-3.md b/docs/lua/functions-3.md index 4c256ee21..8e4f8c230 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -261,7 +261,7 @@ Gets a behavior name from a behavior ID (bhvMyGreatMODCustom004) ## [get_id_from_behavior_name](#get_id_from_behavior_name) ### Description -gets a behavior ID from a behavior name +Gets a behavior ID from a behavior name ### Lua Example `local enumValue = get_id_from_behavior_name(name)` @@ -1312,7 +1312,8 @@ Calculates and returns the pitch and yaw angles from one 3D position (`from`) to | to | [Vec3f](structs.md#Vec3f) | ### Returns -- None +- `integer` +- `integer` ### C Prototype `void calculate_angles(Vec3f from, Vec3f to, RET s16 *pitch, RET s16 *yaw);` @@ -1585,7 +1586,7 @@ Applies a roll-based shake effect to the camera. Simulates rotational disturbanc | roll | `integer` | ### Returns -- None +- `integer` ### C Prototype `void shake_camera_roll(INOUT s16 *roll);` @@ -2825,7 +2826,7 @@ Gets the current DJUI HUD font - `integer` ### C Prototype -`u8 djui_hud_get_font(void);` +`s8 djui_hud_get_font(void);` [:arrow_up_small:](#) @@ -2928,16 +2929,18 @@ Resets the current DJUI HUD color Gets the current DJUI HUD rotation ### Lua Example -`local hudUtilsRotationValue = djui_hud_get_rotation()` +`local rotation, pivotX, pivotY = djui_hud_get_rotation()` ### Parameters - None ### Returns -- [HudUtilsRotation](structs.md#HudUtilsRotation) +- `integer` +- `number` +- `number` ### C Prototype -`struct HudUtilsRotation* djui_hud_get_rotation(void);` +`void djui_hud_get_rotation(RET s16 *rotation, RET f32 *pivotX, RET f32 *pivotY);` [:arrow_up_small:](#) @@ -2990,7 +2993,79 @@ Sets the current DJUI HUD rotation interpolated - None ### C Prototype -`void djui_hud_set_rotation_interpolated(s32 prevRotation, f32 prevPivotX, f32 prevPivotY, s32 rotation, f32 pivotX, f32 pivotY);` +`void djui_hud_set_rotation_interpolated(s16 prevRotation, f32 prevPivotX, f32 prevPivotY, s16 rotation, f32 pivotX, f32 pivotY);` + +[:arrow_up_small:](#) + +
+ +## [djui_hud_get_text_alignment](#djui_hud_get_text_alignment) + +### Description +Gets the current DJUI HUD text alignment + +### Lua Example +`local textHAlign, textVAlign = djui_hud_get_text_alignment()` + +### Parameters +- None + +### Returns +- `number` +- `number` + +### C Prototype +`void djui_hud_get_text_alignment(RET f32 *textHAlign, RET f32 *textVAlign);` + +[:arrow_up_small:](#) + +
+ +## [djui_hud_set_text_alignment](#djui_hud_set_text_alignment) + +### Description +Sets the current DJUI HUD text alignment + +### Lua Example +`djui_hud_set_text_alignment(textHAlign, textVAlign)` + +### Parameters +| Field | Type | +| ----- | ---- | +| textHAlign | `number` | +| textVAlign | `number` | + +### Returns +- None + +### C Prototype +`void djui_hud_set_text_alignment(f32 textHAlign, f32 textVAlign);` + +[:arrow_up_small:](#) + +
+ +## [djui_hud_set_text_alignment_interpolated](#djui_hud_set_text_alignment_interpolated) + +### Description +Sets the current DJUI HUD text alignment interpolated + +### Lua Example +`djui_hud_set_text_alignment_interpolated(prevTextHAlign, prevTextVAlign, textHAlign, textVAlign)` + +### Parameters +| Field | Type | +| ----- | ---- | +| prevTextHAlign | `number` | +| prevTextVAlign | `number` | +| textHAlign | `number` | +| textVAlign | `number` | + +### Returns +- None + +### C Prototype +`void djui_hud_set_text_alignment_interpolated(f32 prevTextHAlign, f32 prevTextVAlign, f32 textHAlign, f32 textVAlign);` [:arrow_up_small:](#) diff --git a/docs/lua/functions-4.md b/docs/lua/functions-4.md index 545c0d19f..4bd956272 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -147,6 +147,29 @@ Sets the lighting engine ambient color
+## [le_set_max_lights_per_vertex](#le_set_max_lights_per_vertex) + +### Description +Sets the max amount of lights that can affect a vertex + +### Lua Example +`le_set_max_lights_per_vertex(count)` + +### Parameters +| Field | Type | +| ----- | ---- | +| count | `integer` | + +### Returns +- None + +### C Prototype +`void le_set_max_lights_per_vertex(u8 count);` + +[:arrow_up_small:](#) + +
+ ## [le_calculate_lighting_color](#le_calculate_lighting_color) ### Description @@ -560,6 +583,35 @@ Sets whether a lighting engine point light will use a surface's normals to deter
+--- +# functions from load.h + +
+ + +## [set_sound_bank_override](#set_sound_bank_override) + +### Description +Overrides the soundbank, set to -1 to reset + +### Lua Example +`set_sound_bank_override(bank)` + +### Parameters +| Field | Type | +| ----- | ---- | +| bank | `integer` | + +### Returns +- None + +### C Prototype +`void set_sound_bank_override(s32 bank);` + +[:arrow_up_small:](#) + +
+ --- # functions from mario.h @@ -5082,7 +5134,9 @@ Calculates the distance between two points in 3D space (`from` and `to`), as wel | to | [Vec3f](structs.md#Vec3f) | ### Returns -- None +- `number` +- `integer` +- `integer` ### C Prototype `void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, RET f32 *dist, RET s16 *pitch, RET s16 *yaw);` diff --git a/docs/lua/functions-5.md b/docs/lua/functions-5.md index 507dd7401..91636f399 100644 --- a/docs/lua/functions-5.md +++ b/docs/lua/functions-5.md @@ -2945,7 +2945,7 @@ Determines an object's forward speed multiplier. | floor_nY | `number` | ### Returns -- None +- `number` ### C Prototype `void calc_obj_friction(RET f32 *objFriction, f32 floor_nY);` @@ -4419,7 +4419,7 @@ Begin by increasing the current object's scale by `scaleVel`, and slowly decreas | blinkLength | `integer` | ### Returns -- None +- `integer` ### C Prototype `void obj_update_blinking(INOUT s32 *blinkTimer, s16 baseCycleLength, s16 cycleLengthRange, s16 blinkLength);` @@ -4743,7 +4743,8 @@ Treats far home as Mario. Returns the distance and angle to the nearest player | threshold | `number` | ### Returns -- None +- `integer` +- `integer` ### C Prototype `void treat_far_home_as_mario(f32 threshold, RET s32* distanceToPlayer, RET s32* angleToPlayer);` diff --git a/docs/lua/functions-6.md b/docs/lua/functions-6.md index afd96447e..a639b7db9 100644 --- a/docs/lua/functions-6.md +++ b/docs/lua/functions-6.md @@ -1963,7 +1963,7 @@ Marks an object to be unloaded at the end of the frame | dragStrength | `number` | ### Returns -- None +- `number` ### C Prototype `void apply_drag_to_value(INOUT f32 *value, f32 dragStrength);` @@ -5616,6 +5616,27 @@ Replaces the sequence corresponding to `sequenceId` with one called `m64Name`.m6
+## [smlua_audio_utils_allocate_sequence](#smlua_audio_utils_allocate_sequence) + +### Description +Allocates a new sequence ID + +### Lua Example +`local integerValue = smlua_audio_utils_allocate_sequence()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u8 smlua_audio_utils_allocate_sequence(void);` + +[:arrow_up_small:](#) + +
+ ## [audio_stream_load](#audio_stream_load) ### Description diff --git a/docs/lua/functions-7.md b/docs/lua/functions-7.md index 3373d70ee..1dd27c2d7 100644 --- a/docs/lua/functions-7.md +++ b/docs/lua/functions-7.md @@ -1775,6 +1775,27 @@ Gets the choice selected inside of a dialog box (0-1)
+## [get_time_stop_flags](#get_time_stop_flags) + +### Description +Gets the active time stop flags, used to freeze specific objects during cutscenes + +### Lua Example +`local integerValue = get_time_stop_flags()` + +### Parameters +- None + +### Returns +- `integer` + +### C Prototype +`u32 get_time_stop_flags(void);` + +[:arrow_up_small:](#) + +
+ ## [get_local_discord_id](#get_local_discord_id) ### Description @@ -2086,6 +2107,30 @@ Gets the mod currently being processed
+## [get_mod_files](#get_mod_files) + +### Description +Gets all files a mod contains + +### Lua Example +`local tableValue = get_mod_files(mod, subDirectory)` + +### Parameters +| Field | Type | +| ----- | ---- | +| mod | [Mod](structs.md#Mod) | +| subDirectory | `string` | + +### Returns +- `table` + +### C Prototype +`LuaTable get_mod_files(struct Mod* mod, OPTIONAL const char* subDirectory);` + +[:arrow_up_small:](#) + +
+ ## [set_window_title](#set_window_title) ### Description @@ -2154,7 +2199,7 @@ Gets the name of the operating system the game is running on ## [geo_get_current_root](#geo_get_current_root) ### Description -Gets the current GraphNodeRoot +Gets the current root node being processed ### Lua Example `local graphNodeRootValue = geo_get_current_root()` @@ -2175,7 +2220,7 @@ Gets the current GraphNodeRoot ## [geo_get_current_master_list](#geo_get_current_master_list) ### Description -Gets the current GraphNodeMasterList +Gets the current master list node being processed ### Lua Example `local graphNodeMasterListValue = geo_get_current_master_list()` @@ -2196,7 +2241,7 @@ Gets the current GraphNodeMasterList ## [geo_get_current_perspective](#geo_get_current_perspective) ### Description -Gets the current GraphNodePerspective +Gets the current perspective node being processed ### Lua Example `local graphNodePerspectiveValue = geo_get_current_perspective()` @@ -2217,7 +2262,7 @@ Gets the current GraphNodePerspective ## [geo_get_current_camera](#geo_get_current_camera) ### Description -Gets the current GraphNodeCamera +Gets the current camera node being processed ### Lua Example `local graphNodeCameraValue = geo_get_current_camera()` @@ -2238,7 +2283,7 @@ Gets the current GraphNodeCamera ## [geo_get_current_held_object](#geo_get_current_held_object) ### Description -Gets the current GraphNodeHeldObject +Gets the current held object node being processed ### Lua Example `local graphNodeHeldObjectValue = geo_get_current_held_object()` @@ -2256,6 +2301,30 @@ Gets the current GraphNodeHeldObject
+## [geo_skip_interpolation](#geo_skip_interpolation) + +### Description +Skips graph node interpolation for a frame + +### Lua Example +`geo_skip_interpolation(node, obj)` + +### Parameters +| Field | Type | +| ----- | ---- | +| node | [GraphNode](structs.md#GraphNode) | +| obj | [GraphNodeObject](structs.md#GraphNodeObject) | + +### Returns +- None + +### C Prototype +`void geo_skip_interpolation(struct GraphNode *node, struct GraphNodeObject *obj);` + +[:arrow_up_small:](#) + +
+ ## [texture_to_lua_table](#texture_to_lua_table) ### Description @@ -3531,6 +3600,52 @@ Sets the parameters of one of the two whirlpools (0-indexed) in an area
+## [obj_skip_interpolation](#obj_skip_interpolation) + +### Description +Skips object interpolation for a frame + +### Lua Example +`obj_skip_interpolation(o)` + +### Parameters +| Field | Type | +| ----- | ---- | +| o | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_skip_interpolation(struct Object *o);` + +[:arrow_up_small:](#) + +
+ +## [obj_anim_skip_interpolation](#obj_anim_skip_interpolation) + +### Description +Skips animation interpolation for a frame + +### Lua Example +`obj_anim_skip_interpolation(o)` + +### Parameters +| Field | Type | +| ----- | ---- | +| o | [Object](structs.md#Object) | + +### Returns +- None + +### C Prototype +`void obj_anim_skip_interpolation(struct Object *o);` + +[:arrow_up_small:](#) + +
+ --- # functions from smlua_text_utils.h diff --git a/docs/lua/functions.md b/docs/lua/functions.md index e2cff77bf..b463ac63e 100644 --- a/docs/lua/functions.md +++ b/docs/lua/functions.md @@ -763,6 +763,9 @@ - [djui_hud_get_rotation](functions-3.md#djui_hud_get_rotation) - [djui_hud_set_rotation](functions-3.md#djui_hud_set_rotation) - [djui_hud_set_rotation_interpolated](functions-3.md#djui_hud_set_rotation_interpolated) + - [djui_hud_get_text_alignment](functions-3.md#djui_hud_get_text_alignment) + - [djui_hud_set_text_alignment](functions-3.md#djui_hud_set_text_alignment) + - [djui_hud_set_text_alignment_interpolated](functions-3.md#djui_hud_set_text_alignment_interpolated) - [djui_hud_get_screen_width](functions-3.md#djui_hud_get_screen_width) - [djui_hud_get_screen_height](functions-3.md#djui_hud_get_screen_height) - [djui_hud_get_mouse_x](functions-3.md#djui_hud_get_mouse_x) @@ -976,6 +979,7 @@ - [le_set_tone_mapping](functions-4.md#le_set_tone_mapping) - [le_get_ambient_color](functions-4.md#le_get_ambient_color) - [le_set_ambient_color](functions-4.md#le_set_ambient_color) + - [le_set_max_lights_per_vertex](functions-4.md#le_set_max_lights_per_vertex) - [le_calculate_lighting_color](functions-4.md#le_calculate_lighting_color) - [le_calculate_lighting_color_with_normal](functions-4.md#le_calculate_lighting_color_with_normal) - [le_calculate_lighting_dir](functions-4.md#le_calculate_lighting_dir) @@ -996,6 +1000,11 @@
+- load.h + - [set_sound_bank_override](functions-4.md#set_sound_bank_override) + +
+ - mario.h - [is_anim_at_end](functions-4.md#is_anim_at_end) - [is_anim_past_end](functions-4.md#is_anim_past_end) @@ -1819,6 +1828,7 @@ - smlua_audio_utils.h - [smlua_audio_utils_reset_all](functions-6.md#smlua_audio_utils_reset_all) - [smlua_audio_utils_replace_sequence](functions-6.md#smlua_audio_utils_replace_sequence) + - [smlua_audio_utils_allocate_sequence](functions-6.md#smlua_audio_utils_allocate_sequence) - [audio_stream_load](functions-6.md#audio_stream_load) - [audio_stream_destroy](functions-6.md#audio_stream_destroy) - [audio_stream_play](functions-6.md#audio_stream_play) @@ -2047,6 +2057,7 @@ - [set_override_envfx](functions-7.md#set_override_envfx) - [get_global_timer](functions-7.md#get_global_timer) - [get_dialog_response](functions-7.md#get_dialog_response) + - [get_time_stop_flags](functions-7.md#get_time_stop_flags) - [get_local_discord_id](functions-7.md#get_local_discord_id) - [get_coopnet_id](functions-7.md#get_coopnet_id) - [get_volume_master](functions-7.md#get_volume_master) @@ -2061,6 +2072,7 @@ - [set_environment_region](functions-7.md#set_environment_region) - [mod_file_exists](functions-7.md#mod_file_exists) - [get_active_mod](functions-7.md#get_active_mod) + - [get_mod_files](functions-7.md#get_mod_files) - [set_window_title](functions-7.md#set_window_title) - [reset_window_title](functions-7.md#reset_window_title) - [get_os_name](functions-7.md#get_os_name) @@ -2069,6 +2081,7 @@ - [geo_get_current_perspective](functions-7.md#geo_get_current_perspective) - [geo_get_current_camera](functions-7.md#geo_get_current_camera) - [geo_get_current_held_object](functions-7.md#geo_get_current_held_object) + - [geo_skip_interpolation](functions-7.md#geo_skip_interpolation) - [texture_to_lua_table](functions-7.md#texture_to_lua_table) - [get_texture_name](functions-7.md#get_texture_name) @@ -2130,6 +2143,8 @@ - [obj_set_vel](functions-7.md#obj_set_vel) - [obj_move_xyz](functions-7.md#obj_move_xyz) - [set_whirlpools](functions-7.md#set_whirlpools) + - [obj_skip_interpolation](functions-7.md#obj_skip_interpolation) + - [obj_anim_skip_interpolation](functions-7.md#obj_anim_skip_interpolation)
diff --git a/docs/lua/guides/hooks.md b/docs/lua/guides/hooks.md index af1226bae..07d522650 100644 --- a/docs/lua/guides/hooks.md +++ b/docs/lua/guides/hooks.md @@ -151,6 +151,12 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh | HOOK_MARIO_OVERRIDE_FLOOR_CLASS | Called when Mario's floor class logic updates, return a `SURFACE_CLASS_*` constant to override the type. | [MarioState](../structs.md#MarioState) mario, `integer` surfaceClass | | HOOK_ON_ADD_SURFACE | Called when collision surfaces are added. | [Surface](../structs.md#Surface) surface, `boolean` dynamic | | HOOK_ON_CLEAR_AREAS | Called when a level's areas are unloaded. | None | +| HOOK_ON_FIND_WALL_COLLISION | Called after wall collision detection completes. You can modify the `colData` fields directly. Return a number to override `numCollisions` | `number` posX, `number` posY, `number` posZ, [WallCollisionData](../structs.md#WallCollisionData) colData | +| HOOK_ON_FIND_CEIL | Called after ceiling detection completes. Return `height` to override height, or `height, surface` to override both | `number` posX, `number` posY, `number` posZ, [Surface](../structs.md#Surface) ceil, `number` height | +| HOOK_ON_FIND_FLOOR | Called after floor detection completes. Return `height` to override height, or `height, surface` to override both | `number` posX, `number` posY, `number` posZ, [Surface](../structs.md#Surface) floor, `number` height | +| HOOK_ON_FIND_WATER_LEVEL | Called after water level detection completes. Return a number to override the water level | `number` x, `number` z, `number` waterLevel | +| HOOK_ON_FIND_POISON_GAS_LEVEL | Called after poison gas level detection completes. Return a number to override the gas level | `number` x, `number` z, `number` gasLevel | +| HOOK_ON_FIND_SURFACE_ON_RAY | Called after ray-surface intersection completes. Return `surface` to override the hit surface, or `surface, hitPos` to override both | `Vec3f` orig, `Vec3f` dir, [Surface](../structs.md#Surface) hitSurface, `Vec3f` hitPos | ### Parameters diff --git a/docs/lua/structs.md b/docs/lua/structs.md index d902f0837..d0d65ce9a 100644 --- a/docs/lua/structs.md +++ b/docs/lua/structs.md @@ -53,7 +53,6 @@ - [GraphNodeSwitchCase](#GraphNodeSwitchCase) - [GraphNodeTranslation](#GraphNodeTranslation) - [GraphNodeTranslationRotation](#GraphNodeTranslationRotation) -- [HudUtilsRotation](#HudUtilsRotation) - [InstantWarp](#InstantWarp) - [LakituState](#LakituState) - [LevelValues](#LevelValues) @@ -1427,21 +1426,6 @@
-## [HudUtilsRotation](#HudUtilsRotation) - -| Field | Type | Access | -| ----- | ---- | ------ | -| rotation | `number` | | -| rotationDiff | `number` | | -| prevPivotX | `number` | | -| prevPivotY | `number` | | -| pivotX | `number` | | -| pivotY | `number` | | - -[:arrow_up_small:](#) - -
- ## [InstantWarp](#InstantWarp) | Field | Type | Access | diff --git a/include/behavior_table.h b/include/behavior_table.h index f4cf7146b..b3ab308f2 100644 --- a/include/behavior_table.h +++ b/include/behavior_table.h @@ -557,7 +557,7 @@ enum BehaviorId get_id_from_vanilla_behavior(const BehaviorScript* behavior); const BehaviorScript* get_behavior_from_id(enum BehaviorId id); /* |description|Gets a behavior name from a behavior ID (bhvMyGreatMODCustom004)|descriptionEnd| */ const char* get_behavior_name_from_id(enum BehaviorId id); -/* |description|gets a behavior ID from a behavior name|descriptionEnd| */ +/* |description|Gets a behavior ID from a behavior name|descriptionEnd| */ enum BehaviorId get_id_from_behavior_name(const char* name); #endif diff --git a/lang/German.ini b/lang/German.ini index 46d0bf440..e44e5c718 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -46,10 +46,10 @@ NAMETAGS_MISSING_PARAMETERS = "Fehlende Parameter: [OPTION]" SELF_KICK = "Du kannst dich nicht selbst kicken." SELF_BAN = "Du kannst dich nicht selbst bannen." SELF_MOD = "Du kannst dich nicht selbst zum Moderator machen." -KICK_CONFIRM = "Bist du sicher, dass du '@' vom Server kicken möchtest?\nGib '\\#a0ffa0\\/bestätigen\\#fff982\\' ein, um fortzufahren." -BAN_CONFIRM = "Bist du sicher, dass du '@' vom Server bannen möchtest?\nGib '\\#a0ffa0\\/bestätigen\\#fff982\\' ein, um fortzufahren." -PERM_BAN_CONFIRM = "Bist du sicher, dass du '@' dauerhaft vom Server bannen möchtest?\nGib '\\#a0ffa0\\/bestätigen\\#fff982\\' ein, um fortzufahren." -MOD_CONFIRM = "Bist du sicher, dass du '@' zum Moderator ernennen möchtest?\nGib '\\#a0ffa0\\/bestätigen\\#fff982\\' ein." +KICK_CONFIRM = "Bist du sicher, dass du '@' vom Server kicken möchtest?\nGib '\\#a0ffa0\\/confirm\\#fff982\\' ein, um fortzufahren." +BAN_CONFIRM = "Bist du sicher, dass du '@' vom Server bannen möchtest?\nGib '\\#a0ffa0\\/confirm\\#fff982\\' ein, um fortzufahren." +PERM_BAN_CONFIRM = "Bist du sicher, dass du '@' dauerhaft vom Server bannen möchtest?\nGib '\\#a0ffa0\\/confirm\\#fff982\\' ein, um fortzufahren." +MOD_CONFIRM = "Bist du sicher, dass du '@' zum Moderator ernennen möchtest?\nGib '\\#a0ffa0\\/confirm\\#fff982\\' ein." PLAYERS_DESC = "/players - Zeige alle Spieler und ihre IDs." KICK_DESC = "/kick [NAME|ID] - Kicke einen Spieler vom Server." BAN_DESC = "/ban [NAME|ID] - Banne einen Spieler vom Server." diff --git a/lang/Japanese.ini b/lang/Japanese.ini index 322c449e8..a15f74b3a 100644 --- a/lang/Japanese.ini +++ b/lang/Japanese.ini @@ -1,61 +1,61 @@ [NOTIF] -CONNECTED = "@が接続しました" -DISCONNECTED = "@が切断しました。" -LEFT_THIS_LEVEL = "@がこのコースから出ました。" -ENTERED_THIS_LEVEL = "@がこのコースに入りました。" -ENTERED = "@が\n#に入りました。" -SERVER_CLOSED = "\\#ffa0a0\\切断されました:\\#dcdcdc\\ 部屋が閉じられました。" -DISCORD_ERROR = "Discordエラーが発生しました。\n解決するには、\n1. ゲームを終了し、\n2. Discordを再起動してから、\n3. もう一度ゲームを開いてください。" +CONNECTED = "@ が参加しました" +DISCONNECTED = "@ が退出しました" +LEFT_THIS_LEVEL = "@ がこのコースから出ました" +ENTERED_THIS_LEVEL = "@ がこのコースに入りました" +ENTERED = "@ が \n# に入りました" +SERVER_CLOSED = "\\#ffa0a0\\切断されました:\\#dcdcdc\\ ルームが閉じられました。" +DISCORD_ERROR = "Discordエラーが発生しました。\n解決するには、\n1. ゲームを終了する\n2. Discordを再起動する\n3. もう一度ゲームを開く\nの手順で進めてください。" DISCORD_DETECT = "\\#ffa0a0\\エラー:\\#dcdcdc\\ Discordを検出できませんでした。\n\\#a0a0a0\\ゲームを終了し、Discordを再起動してから、もう一度お試しください。" DISCONNECT_FULL = "\\#ffa0a0\\切断されました:\\#dcdcdc\\ ルームが満員です。" DISCONNECT_KICK = "\\#ffa0a0\\切断されました:\\#dcdcdc\\ キックされました。" DISCONNECT_BAN = "\\#ffa0a0\\切断されました:\\#dcdcdc\\ BANされました。" DISCONNECT_REJOIN = "\\#ffa0a0\\切断されました:\\#dcdcdc\\ 再参加中です…" DISCONNECT_CLOSED = "\\#ffa0a0\\切断されました:\\#dcdcdc\\ ホストが切断しました。" -DISCONNECT_BIG_MOD = "MODの量が多すぎます!\n切断しました。" -DIED = "@がやられた!" -DEBUG_FLY = "@がデバッグ飛行モードに入りました!" -IMPORT_MOD_SUCCESS = "'@'\n\\#a0ffa0\\MODを読み込みました\\#dcdcdc\\" -IMPORT_DYNOS_SUCCESS = "'@'\n\\#a0ffa0\\DynOSのパックを読み込みました\\#dcdcdc\\" -IMPORT_PALETTE_SUCCESS = "'@'\n\\#a0ffa0\\パレットのプリセットを読み込みました\\#dcdcdc\\" -IMPORT_FAIL = "'@'\n\\#ffa0a0\\読み込みに失敗しました。\\#dcdcdc\\" -IMPORT_FAIL_INGAME = "\\#ffa0a0\\ゲーム中はMODを読み込めません" +DISCONNECT_BIG_MOD = "このルームはMODの量が多すぎます。\n切断しました。" +DIED = "@がやられた" +DEBUG_FLY = "@がデバッグ飛行モードに入った" +IMPORT_MOD_SUCCESS = "\\#a0ffa0\\MODをインポートしました:\n\\#dcdcdc\\@" +IMPORT_DYNOS_SUCCESS = "\\#a0ffa0\\DynOSパックをインポートしました:\n\\#dcdcdc\\@" +IMPORT_PALETTE_SUCCESS = "\\#a0ffa0\\パレットプリセットをインポートしました:\n\\#dcdcdc\\@" +IMPORT_FAIL = "\\#ffa0a0\\インポートに失敗しました:\n\\#dcdcdc\\@" +IMPORT_FAIL_INGAME = "\\#ffa0a0\\ゲーム中はMODをインポートできません" COOPNET_CONNECTION_FAILED = "\\#ffa0a0\\CoopNetに接続できませんでした!" -COOPNET_DISCONNECTED = "\\#ffa0a0\\CoopNetとの接続が途絶えました!" +COOPNET_DISCONNECTED = "\\#ffa0a0\\CoopNetとの接続が失われました!" LOBBY_NOT_FOUND = "\\#ffa0a0\\エラー:\\#dcdcdc\\ ルームがすでに閉じられています!" -LOBBY_JOIN_FAILED = "\\#ffa0a0\\ルームに参加できませんでした。" -LOBBY_PASSWORD_INCORRECT = "\\#ffa0a0\\パスワードが間違っています。" -COOPNET_VERSION = "\\#ffa0a0\\あなたのバージョンはCoopNetに対応していません。アップデートしましょう!" -PEER_FAILED = "\\#ffa0a0\\'@'への接続に失敗しました。" +LOBBY_JOIN_FAILED = "\\#ffa0a0\\ルームへの参加に失敗しました!" +LOBBY_PASSWORD_INCORRECT = "\\#ffa0a0\\パスワードが間違っています!" +COOPNET_VERSION = "\\#ffa0a0\\あなたのゲームバージョンはCoopNetに対応していません。アップデートしましょう!" +PEER_FAILED = "\\#ffa0a0\\プレイヤー @ への接続に失敗しました。" UNKNOWN = "未知" -LOBBY_HOST = "部屋主" +LOBBY_HOST = "ルームのホスト" UPDATE_AVAILABLE = "アップデートが利用可能です!" -LATEST_VERSION = "最新バージョン" +LATEST_VERSION = "最新のバージョン" YOUR_VERSION = "あなたのバージョン" [CHAT] -KICKING = "'@'をキックしました!" -BANNING = "'@'をBANしました!" +KICKING = "@ をキックしました!" +BANNING = "@ をBANしました!" SERVER_ONLY = "このコマンドはホストのみが実行できます。" -PERM_BANNING = "'@'を永久BANしました!" -ADD_MODERATOR = "'@'をモデレーターにしました!" -PLAYERS = "プレイヤー" +PERM_BANNING = "@ を永久BANしました!" +ADD_MODERATOR = "@ をモデレーターにしました!" +PLAYERS = "ルーム内のプレイヤー" NO_PERMS = "このコマンドを実行する権限がありません。" PLAYER_NOT_FOUND = "プレイヤーが見つかりませんでした。" -NAMETAGS_MISSING_PARAMETERS = "引数が不足しています: [OPTION]が必要です。" +NAMETAGS_MISSING_PARAMETERS = "引数が不足しています: [OPTION] が必要です。" SELF_KICK = "自分自身はキックできません。" SELF_BAN = "自分自身はBANできません。" SELF_MOD = "自分自身をモデレーターにすることはできません。" -KICK_CONFIRM = "本当に'@'を強制退出させますか?\n実行するには'\\#a0ffa0\\/confirm\\#fff982\\' と入力して確定します。" -BAN_CONFIRM = "本当に'@'をBANしますか?\nBANするには'\\#a0ffa0\\/confirm\\#fff982\\' と入力して確定します。" -PERM_BAN_CONFIRM = "本当に'@'を永久BANしますか?\nBANするには'\\#a0ffa0\\/confirm\\#fff982\\' と入力して確定します。" -MOD_CONFIRM = "本当に'@'をモデレーターにしますか?\n'\\#a0ffa0\\/confirm\\#fff982\\' と入力して確定します。" -PLAYERS_DESC = "/players - プレイヤー名とID一覧を表示します。" -KICK_DESC = "/kick [NAME|ID] - プレイヤーを現在のルームからキックします。" -BAN_DESC = "/ban [NAME|ID] - プレイヤーを現在のルームからBANします。" -PERM_BAN_DESC = "/permban [NAME|ID] - プレイヤーをあなたが今後ホストするすべてのルームからBANします。" -MOD_DESC = "/moderator [NAME|ID] - プレイヤーに/kick、/ban、/permbanのようなコマンドの使用を許可します。" -NAMETAGS_DESC = "/nametags [show-tag|show-health] - あなたの体力やネームタグの表示を変更します。" +KICK_CONFIRM = "本当に @ をキックしますか?\n実行するには'\\#a0ffa0\\/confirm\\#fff982\\' と入力して確定します。" +BAN_CONFIRM = "本当に @ をBANしますか?\nBANするには'\\#a0ffa0\\/confirm\\#fff982\\' と入力して確定します。" +PERM_BAN_CONFIRM = "本当に @ を永久BANしますか?\nBANするには'\\#a0ffa0\\/confirm\\#fff982\\' と入力して確定します。" +MOD_CONFIRM = "本当に @ をモデレーターにしますか?\n'\\#a0ffa0\\/confirm\\#fff982\\' と入力して確定します。" +PLAYERS_DESC = "/players - ルーム内のプレイヤー名とIDの一覧を表示します。" +KICK_DESC = "/kick [プレイヤー名|ID] - 指定したプレイヤーを現在のルームからキックします。" +BAN_DESC = "/ban [プレイヤー名|ID] - 指定したプレイヤーを現在のルームからBANします。" +PERM_BAN_DESC = "/permban [プレイヤー名|ID] - 指定したプレイヤーをあなたが今後ホストするすべてのルームからBANします。" +MOD_DESC = "/moderator [プレイヤー名|ID] - 指定したプレイヤーに/kick、/ban、/permbanのようなコマンドの使用を許可します。" +NAMETAGS_DESC = "/nametags [show-tag|show-health] - あなたのネームタグ/体力の表示を変更します。" UNRECOGNIZED = "未知のコマンドです。" MOD_GRANTED = "\\#fff982\\あなたはモデレーターになりました。" @@ -70,8 +70,8 @@ CAMERA = "CAMERA" FREE_CAMERA = "フリーカメラ" ANALOG_CAMERA = "アナログカメラ" FREE_CAMERA_TITLE = "FREE CAMERA" -FREE_CAMERA_L_CENTERING = "Lセンタリング" -FREE_CAMERA_USE_DPAD = "DPad の動作" +FREE_CAMERA_L_CENTERING = "Lボタンで前を向く" +FREE_CAMERA_USE_DPAD = "十字キー操作" FREE_CAMERA_COLLISION = "カメラの衝突" ROMHACK_CAMERA_TITLE = "ROMHACK\nCAMERA" ROMHACK_CAMERA = "ロムハックカメラ" @@ -79,26 +79,25 @@ ROMHACK_CAMERA_AUTOMATIC = "自動" ROMHACK_CAMERA_ON = "オン" ROMHACK_CAMERA_OFF = "オフ" ROMHACK_CAMERA_IN_BOWSER = "クッパ戦で使用" -ROMHACK_CAMERA_COLLISION = "カメラの衝突" -ROMHACK_CAMERA_L_CENTERING = "Lセンタリング" -ROMHACK_CAMERA_USE_DPAD = "DPad の動作" -ROMHACK_CAMERA_SLOW_FALL = "スローフォール" -CAMERA_TOXIC_GAS = "有毒ガスの調整" +ROMHACK_CAMERA_COLLISION = "カメラの当たり判定" +ROMHACK_CAMERA_L_CENTERING = "Lボタンで前を向く" +ROMHACK_CAMERA_USE_DPAD = "十字キー操作" +ROMHACK_CAMERA_SLOW_FALL = "低速落下" +CAMERA_TOXIC_GAS = "有毒ガス内での調整" MOUSE_LOOK = "マウスでの操作" INVERT_X = "X方向のカメラ反転" INVERT_Y = "Y方向のカメラ反転" X_SENSITIVITY = "X方向の感度" Y_SENSITIVITY = "Y方向の感度" -AGGRESSION = "かたさ" -PAN_LEVEL = "カメラのずれ" -DECELERATION = "カメラ減速" -ROMHACK_CAMERA_OFF = "オフ" +AGGRESSION = "カメラの追従性" +PAN_LEVEL = "カメラの水平速度" +DECELERATION = "カメラ減速の強さ" [CONTROLS] CONTROLS = "CONTROLS" -N64_BINDS = "ニンテンドウ64の入力" -EXTRA_BINDS = "追加の入力" +N64_BINDS = "ニンテンドウ64のボタン割り当て" +EXTRA_BINDS = "追加のボタン割り当て" BACKGROUND_GAMEPAD = "バックグラウンドでのコントローラー認識" DISABLE_GAMEPADS = "コントローラーを無効化" GAMEPAD = "コントローラー" @@ -106,28 +105,28 @@ DEADZONE = "デッドゾーン" RUMBLE_STRENGTH = "振動の強さ" CHAT = "チャット" -PLAYERS = "プレイヤーリストの表示" +PLAYERS = "プレイヤーリスト" D_UP = "十字キー 上" D_DOWN = "十字キー 下" D_LEFT = "十字キー 左" D_RIGHT = "十字キー 右" -X = "X" -Y = "Y" +X = "Xボタン" +Y = "Yボタン" CONSOLE = "コンソール" PREV = "前のページ" NEXT = "次のページ" -DISCONNECT = "切断" +DISCONNECT = "ゲームから切断" -UP = "上" -DOWN = "下" -LEFT = "左" -RIGHT = "右" -A = "A" -B = "B" -START = "スタート" -L = "L" -R = "R" -Z = "Z" +UP = "3Dスティック 上" +DOWN = "3Dスティック 下" +LEFT = "3Dスティック 左" +RIGHT = "3Dスティック 右" +A = "Aボタン" +B = "Bボタン" +START = "STARTボタン" +L = "Lトリガー" +R = "Rトリガー" +Z = "Zトリガー" C_UP = "Cボタン 上" C_DOWN = "Cボタン 下" C_LEFT = "Cボタン 左" @@ -135,7 +134,7 @@ C_RIGHT = "Cボタン 右" ANALOG_STICK_OPTIONS = "アナログスティックのオプション" -ROTATE_LEFT = "左スティックを90度回転させる" +ROTATE_LEFT = "左スティックを90度回転" INVERT_LEFT_X = "左スティックX軸の反転" INVERT_LEFT_Y = "左スティックY軸の反転" ROTATE_RIGHT = "右スティックを90度回転" @@ -153,7 +152,7 @@ AUTO = "自動" MANUAL = "手動" UNCAPPED = "無制限" FRAME_LIMIT = "FPSの制限" -FAST = "速い" +FAST = "高速" ACCURATE = "正確" INTERPOLATION = "補間" NEAREST = "ニアレスト" @@ -196,24 +195,24 @@ LOCAL_PLAYER_MODEL_ONLY = "ローカルのキャラモデルに限定" [HOST_MESSAGE] INFO_TITLE = "INFO" -WARN_DISCORD = "招待したいフレンドを右クリックしてn'\\#d0d0ff\\ゲームに招待\\#dcdcdc\\'.\n\nを押すと招待できます。サーバー内のチャンネルにも、チャット横の\\#d0d0ff\\プラス\\#dcdcdc\\マークから招待メッセージを送信できます。\n\nゲーム アクティビティを\\#ffa0a0\\必ず\\#dcdcdc\\有効にしてください。\n\n\nオフラインに設定していると、招待の送信を\\#ffa0a0\\妨げる\\#dcdcdc\\可能性があります。" -WARN_DISCORD2 = "\\#ffa0a0\\エラー:\\#dcdcdc\\Discordを検出できませんでした。\n\\#a0a0a0\\ゲームを終了し、Discordを再起動してから、もう一度お試しください。" -WARN_SOCKET = "ファイアウォール設定が正しく設定されている事をご確認ください。\n直接接続には、ルータのポート転送でIPv4インバウンド接続を受信するように設定する\\#ffa0a0\\必要\\#dcdcdc\\があります。\n\nUDPポート'%d'番を開放してください。IPv6にも対応しています。" +WARN_DISCORD = "招待したいフレンドを右クリックしてn'\\#d0d0ff\\ゲームに招待\\#dcdcdc\\'.\n\nを押すと招待できます。サーバー内のチャンネルにも、チャット入力欄の横にある\\#d0d0ff\\+\\#dcdcdc\\マークから招待メッセージを送信できます。\n\nDiscordのユーザー設定からゲーム アクティビティを\\#ffa0a0\\必ず\\#dcdcdc\\有効にしてください。\n\n\nステータスをオフラインに設定していると、招待の送信が\\#ffa0a0\\妨げられる\\#dcdcdc\\可能性があります。" +WARN_DISCORD2 = "\\#ffa0a0\\エラー:\\#dcdcdc\\Discordを検出できませんでした。\n\\#a0a0a0\\ゲームを終了してDiscordを再起動してから、もう一度お試しください。" +WARN_SOCKET = "ファイアウォールの設定が正しく完了していることを確認してください。\nダイレクト接続には\\#ffa0a0\\あなた自身が\\#dcdcdc\\ルーターでIPv4の接続を受け入れるようにポートフォワーディング設定を行う必要があります。\n\nUDPポート'\\#d0d0ff\\%d\\#dcdcdc\\'を解放してください。IPv6も使用可能です。" HOST = "ルームを作る" [HOST_MODS] MODS = "MODS" CATEGORIES = "カテゴリ一覧" -WARNING = "\\#ffffa0\\<注意>\\#dcdcdc\\ MOD数が10個以上になっています。ラグや不安定を防ぐため、いくつか無効にしてください" -NO_MODS_FOUND = "MODが見つかりませんでした。" +WARNING = "\\#ffffa0\\<注意>\\#dcdcdc\\ MODの数が10個以上になっています。ラグや不安定を防ぐため、いくつか無効にしてください。" +NO_MODS_FOUND = "MODは見つかりませんでした。" [HOST_MOD_CATEGORIES] ALL = "すべて" MISC = "その他" -ROMHACKS = "ハックロム" -GAMEMODES = "ゲームモード" -MOVESETS = "ムーブセット" -CHARACTER_SELECT = "キャラクター選択" +ROMHACKS = "ロムハック系" +GAMEMODES = "ゲームモード系" +MOVESETS = "ムーブセット系" +CHARACTER_SELECT = "追加キャラクター系" [HOST_SAVE] SAVE_TITLE = "SAVE" @@ -222,7 +221,7 @@ CONFIRM = "本当に消しますか?" ERASE = "消す" EDIT = "編集" EDIT_TITLE = "EDIT" -EDIT_NAME = "ファイル名を変更:" +EDIT_NAME = "マリオ @のおなまえ変更:" [HOST_SETTINGS] SETTINGS = "SETTINGS" @@ -235,7 +234,7 @@ NORMAL = "普通" TOO_MUCH = "最強" KNOCKBACK_STRENGTH = "ノックバックの強さ" CLASSIC_PVP = "クラシック" -REVAMPED_PVP = "改良" +REVAMPED_PVP = "改良型" PVP_MODE = "PvPモード" LEAVE_LEVEL = "コースを出る" STAY_IN_LEVEL = "コースに留まる" @@ -243,14 +242,14 @@ NONSTOP = "ノンストップ" ON_STAR_COLLECTION = "スター取得時の動作" SKIP_INTRO_CUTSCENE = "イントロをスキップ" ENABLE_CHEATS = "チートを有効にする" -BUBBLE_ON_DEATH = "やられた時にシャボンで復活" +BUBBLE_ON_DEATH = "ミス時にシャボンで復活" NAMETAGS = "ネームタグを有効にする" MOD_DEV_MODE = "MOD開発モード" -BOUNCY_BOUNDS_ON_CAP = "オン(制限付き)" +BOUNCY_BOUNDS_ON_CAP = "オン(速度制限)" BOUNCY_BOUNDS_ON = "オン" BOUNCY_BOUNDS_OFF = "オフ" BOUNCY_LEVEL_BOUNDS = "コース境界での跳ね返り" -AMOUNT_OF_PLAYERS = "最大人数" +AMOUNT_OF_PLAYERS = "最大ルーム人数" PAUSE_ANYWHERE = "どこでもポーズ" [HOST] @@ -275,7 +274,7 @@ JOINING = "JOINING" [JOIN] JOIN_TITLE = "JOIN" JOIN_DISCORD = "\\#d0d0ff\\Discord\\#dcdcdc\\ロビーへの参加:\n\nゲームを開いたまま、招待メッセージの参加ボタンを押してください。\n\n「ゲームは終了しました」と表示されている場合は、招待を送信した人の名前をクリックして更新してください。" -JOIN_SOCKET = "\\#d0d0ff\\ダイレクト接続\\#dcdcdc\\のIPとポートを入力してください:" +JOIN_SOCKET = "\\#d0d0ff\\ダイレクト接続先\\#dcdcdc\\のIPアドレスとポート番号を入力してください:" JOIN = "参加する" PUBLIC_LOBBIES = "公開ルーム" PRIVATE_LOBBIES = "非公開ルーム" @@ -283,14 +282,14 @@ DIRECT = "ダイレクト接続" [RULES] RULES_TITLE = "RULES" -RULE_1 = "1. 13歳以上であること。" -RULE_2 = "2. 不快な言葉、中傷、攻撃的な言葉を使わないこと。" -RULE_3 = "3. 非公式ビルドを使わないこと。" -RULE_4 = "4. ゲームをエクスプロイトする外部ツールを使用しないこと。" -RULE_5 = "5. 作者の許可なく、非公開MODを公開しないこと。" -RULE_6 = "6. 全てのNSFWコンテンツは禁止です。" -SUBJECT_TO_CHANGE = "ルールはアップデートで変更される可能性があります。" -NOTICE = "公開ルームではルールをお守りください。" +RULE_1 = "1. CoopNetの利用は13歳以上に限ります。" +RULE_2 = "2. ハラスメント(嫌がらせ)、ヘイトスピーチ、差別用語、その他攻撃的な言動は禁止です。" +RULE_3 = "3. CoopNetでは改造(改ざん)されていない正規のsm64coopdxのみが使用可能です。" +RULE_4 = "4. ゲームの脆弱性を悪用するための外部ツールの使用は禁止です。" +RULE_5 = "5. 作者の許可なく、未公開MODでルームをホストしないでください。" +RULE_6 = "6. ポルノやフェティッシュなコンテンツは一切禁止されています。これにはMOD、キャラクター、成人向けロールプレイなどが含まれますが、これらに限定されません。" +SUBJECT_TO_CHANGE = "これらのルールは今後のアップデートで変更される可能性があります。" +NOTICE = "公開ルームでプレイするためにCoopNetへ接続した時点で、あなたはこれらのルールを遵守することに同意したものとみなされます。" RULES = "ルールを見る" [MAIN] @@ -307,27 +306,27 @@ LEVEL = "コース" STAFF_ROLL = "スタッフロール" MUSIC = "BGM" RANDOM_STAGE = "ランダムなステージ" -PLAY_VANILLA_DEMOS = "バニラゲームのデモを再生" +PLAY_VANILLA_DEMOS = "オリジナルゲームのデモを再生" [MISC] DEBUG_TITLE = "DEBUG" FIXED_COLLISIONS = "修正された当たり判定" LUA_PROFILER = "Luaのプロファイラー" CTX_PROFILER = "Ctxのプロファイラー" -DEBUG_PRINT = "デバッグ情報の表示" -DEBUG_INFO = "デバッグの情報" -DEBUG_ERRORS = "デバッグのエラー" +DEBUG_PRINT = "デバッグログの表示" +DEBUG_INFO = "デバッグ情報の表示" +DEBUG_ERRORS = "デバッグエラーの表示" MISC_TITLE = "MISC" -PAUSE_IN_SINGLEPLAYER = "ソロプレイでの一時停止" +PAUSE_IN_SINGLEPLAYER = "1人プレイ中にポーズで一時停止を有効化" DISABLE_POPUPS = "ポップアップを無効にする" -USE_STANDARD_KEY_BINDINGS_CHAT = "初期のチャット操作" +USE_STANDARD_KEY_BINDINGS_CHAT = "旧式チャット操作" MENU_OPTIONS = "メニューの設定" INFORMATION = "情報" DEBUG = "デバッグ" LANGUAGE = "言語" COOP_COMPATIBILITY = "sm64ex-coopとの互換性を有効にする" R_BUTTON = "Rボタン - 設定" -L_BUTTON = "Lボタン - アクティブなMODを再読み込み" +L_BUTTON = "Lボタン - 有効化されたMODを再読み込み" [INFORMATION] INFORMATION_TITLE = "INFO" @@ -371,7 +370,7 @@ PLAYER_TITLE = "PLAYER" OVERALLS = "オーバーオール" SHIRT = "シャツ" GLOVES = "手袋" -SHOES = "くつ" +SHOES = "クツ" HAIR = "髪" SKIN = "肌" CAP = "帽子" @@ -408,8 +407,8 @@ MASTER_VOLUME = "主音量" MUSIC_VOLUME = "BGM音量" SFX_VOLUME = "SE音量" ENV_VOLUME = "環境音量" -FADEOUT = "遠い音のフェードアウト" -MUTE_FOCUS_LOSS = "非フォーカス時にミュート" +FADEOUT = "音の距離減衰" +MUTE_FOCUS_LOSS = "非フォーカス時に音をミュート" [LANGUAGE] LANGUAGE = "LANGUAGE" @@ -428,12 +427,11 @@ Spanish = "スペイン語 (Español)" [LOBBIES] PUBLIC_LOBBIES = "PUBLIC ROOMS" PRIVATE_LOBBIES = "PRIVATE ROOMS" -REFRESH = "更新" +REFRESH = "更新する" REFRESHING = "更新中…" -ENTER_PASSWORD = "部屋のパスワードを入力してください:" +ENTER_PASSWORD = "ルームのパスワードを入力してください:" SEARCH = "検索" -NONE_FOUND = "部屋が見つかりませんでした" -NO_LOBBIES_FOUND = "ロビーは見つからなかった。" +NO_LOBBIES_FOUND = "ルームが見つかりませんでした。" [CHANGELOG] CHANGELOG_TITLE = "CHANGELOG" diff --git a/lib/lua/mac_arm/liblua53.a b/lib/lua/mac_arm/liblua53.a index 8a3e6558b..505bb1ccd 100644 Binary files a/lib/lua/mac_arm/liblua53.a and b/lib/lua/mac_arm/liblua53.a differ diff --git a/mods/sm74/actors/mad_toad_geo.bin b/mods/sm74/actors/mad_toad_geo.bin new file mode 100644 index 000000000..730e6a916 Binary files /dev/null and b/mods/sm74/actors/mad_toad_geo.bin differ diff --git a/mods/sm74/levels/level_bitfs_entry.lvl b/mods/sm74/levels/level_bitfs_entry.lvl index cdeb03e82..a07142d63 100644 Binary files a/mods/sm74/levels/level_bitfs_entry.lvl and b/mods/sm74/levels/level_bitfs_entry.lvl differ diff --git a/mods/sm74/levels/level_castle_courtyard_entry.lvl b/mods/sm74/levels/level_castle_courtyard_entry.lvl index c3d8685e2..1c4dd2c00 100644 Binary files a/mods/sm74/levels/level_castle_courtyard_entry.lvl and b/mods/sm74/levels/level_castle_courtyard_entry.lvl differ diff --git a/mods/sm74/levels/level_castle_inside_entry.lvl b/mods/sm74/levels/level_castle_inside_entry.lvl index 820240229..851bad051 100644 Binary files a/mods/sm74/levels/level_castle_inside_entry.lvl and b/mods/sm74/levels/level_castle_inside_entry.lvl differ diff --git a/mods/sm74/levels/level_ddd_entry.lvl b/mods/sm74/levels/level_ddd_entry.lvl index fe19d9a1e..ea13c048b 100644 Binary files a/mods/sm74/levels/level_ddd_entry.lvl and b/mods/sm74/levels/level_ddd_entry.lvl differ diff --git a/mods/sm74/levels/level_jrb_entry.lvl b/mods/sm74/levels/level_jrb_entry.lvl index 712df327f..fd757d73e 100644 Binary files a/mods/sm74/levels/level_jrb_entry.lvl and b/mods/sm74/levels/level_jrb_entry.lvl differ diff --git a/mods/star-road/actors/bobomb_buddy_geo.bin b/mods/star-road/actors/bobomb_buddy_geo.bin index f7f376a1a..97619e7b8 100644 Binary files a/mods/star-road/actors/bobomb_buddy_geo.bin and b/mods/star-road/actors/bobomb_buddy_geo.bin differ diff --git a/mods/star-road/helpers.lua b/mods/star-road/helpers.lua index acd6e4578..7c2dd67d7 100644 --- a/mods/star-road/helpers.lua +++ b/mods/star-road/helpers.lua @@ -52,6 +52,9 @@ function check_mario_attacking(obj, mario) if mario.action == ACT_WALL_KICK_AIR then return 2 end + if (mario.action & ACT_FLAG_CUSTOM_ACTION ~= 0) and (mario.action & ACT_FLAG_ATTACKING ~= 0) then + return 2 + end end end @@ -121,4 +124,4 @@ function object_drop_to_floor(obj) local floorHeight = find_floor_height(x, y + 200, z) obj.oPosY = floorHeight obj.oMoveFlags = (obj.oMoveFlags | OBJ_MOVE_ON_GROUND) -end \ No newline at end of file +end diff --git a/mods/star-road/textures/cannon_lid_seg8_texture_08004058.tex b/mods/star-road/textures/cannon_lid_seg8_texture_08004058.tex new file mode 100644 index 000000000..c64a1cbe1 Binary files /dev/null and b/mods/star-road/textures/cannon_lid_seg8_texture_08004058.tex differ diff --git a/res/icon.icns b/res/icon.icns index 1f20f4d2e..af1d170e8 100644 Binary files a/res/icon.icns and b/res/icon.icns differ diff --git a/res/icon.icon/Assets/icon.png b/res/icon.icon/Assets/icon.png new file mode 100644 index 000000000..3846e675a Binary files /dev/null and b/res/icon.icon/Assets/icon.png differ diff --git a/res/icon.icon/icon.json b/res/icon.icon/icon.json new file mode 100644 index 000000000..3a112c289 --- /dev/null +++ b/res/icon.icon/icon.json @@ -0,0 +1,35 @@ +{ + "fill" : "automatic", + "groups" : [ + { + "layers" : [ + { + "image-name" : "icon.png", + "name" : "icon", + "position" : { + "scale" : 3.5, + "translation-in-points" : [ + 0, + 0 + ] + } + } + ], + "shadow" : { + "kind" : "neutral", + "opacity" : 0.5 + }, + "specular" : false, + "translucency" : { + "enabled" : false, + "value" : 0.5 + } + } + ], + "supported-platforms" : { + "circles" : [ + "watchOS" + ], + "squares" : "shared" + } +} \ No newline at end of file diff --git a/src/audio/external.c b/src/audio/external.c index c411aee8b..6cc466ba5 100644 --- a/src/audio/external.c +++ b/src/audio/external.c @@ -1694,6 +1694,9 @@ static void update_game_sound(void) { break; case SOUND_BANK_ACTION: case SOUND_BANK_MARIO_VOICE: + case SOUND_BANK_LUIGI_VOICE: + case SOUND_BANK_WARIO_VOICE: + case SOUND_BANK_TOAD_VOICE: #if defined(VERSION_EU) || defined(VERSION_SH) queue_audio_cmd_s8(AUDIO_CMD_ARGS(AUDIO_CMD_REVERB, SEQ_PLAYER_SFX, channelIndex, 0), get_sound_reverb(bank, soundIndex, channelIndex)); diff --git a/src/audio/load.c b/src/audio/load.c index 14498b196..9ad0a479b 100644 --- a/src/audio/load.c +++ b/src/audio/load.c @@ -1481,6 +1481,13 @@ u8 get_missing_bank(u32 seqId, s32 *nonNullCount, s32 *nullCount) { #endif #ifndef VERSION_SH + +s32 gOverrideBank = -1; + +void set_sound_bank_override(s32 bank) { + gOverrideBank = bank; +} + struct AudioBank *load_banks_immediate(s32 seqId, u8 *arg1) { void *ret = NULL; u32 bankId = 0; @@ -1498,6 +1505,10 @@ struct AudioBank *load_banks_immediate(s32 seqId, u8 *arg1) { bankId = gAlBankSets[offset - 1]; #endif + if (gOverrideBank > 0) { + bankId = gOverrideBank; + } + if (IS_BANK_LOAD_COMPLETE(bankId) == TRUE) { #ifdef VERSION_EU ret = get_bank_or_seq(&gBankLoadedPool, 2, bankId); diff --git a/src/audio/load.h b/src/audio/load.h index 36ad4ecf4..df8bb55aa 100644 --- a/src/audio/load.h +++ b/src/audio/load.h @@ -53,6 +53,7 @@ extern s32 gMinAiBufferLength; extern s16 gTempoInternalToExternal; extern s8 gAudioUpdatesPerFrame; // = 4 extern s8 gSoundMode; +extern s32 gOverrideBank; #ifdef VERSION_SH extern OSMesgQueue gUnkQueue1; @@ -95,6 +96,9 @@ void preload_sequence(u32 seqId, u8 preloadMask); #endif void load_sequence(u32 player, u32 seqId, s32 loadAsync); +/* |description|Overrides the soundbank, set to -1 to reset|descriptionEnd| */ +void set_sound_bank_override(s32 bank); + #ifdef VERSION_SH void func_sh_802f3158(s32 index, s32 arg1, s32 arg2, OSMesgQueue *retQueue); u8 *func_sh_802f3220(u32 index, u32 *a1); diff --git a/src/audio/seqplayer.c b/src/audio/seqplayer.c index 433ca0b1e..ac9884e07 100644 --- a/src/audio/seqplayer.c +++ b/src/audio/seqplayer.c @@ -212,7 +212,7 @@ struct SequenceChannel *allocate_sequence_channel(void) { #endif } } - + LOG_ERROR("RAN OUT OF SEQUENCE CHANNELS FOR ALLOCATION!"); return &gSequenceChannelNone; } @@ -281,7 +281,7 @@ void sequence_player_init_channels_extended(struct SequencePlayer* seqPlayer, u6 if (!seqPlayer) { return; } u64 channelBits = channelBitsLower; LOG_DEBUG("Enabling channels (extended) with corresponding bits %llX", channelBits); - + for (u32 i = 0; i < CHANNELS_MAX; i++) { if (i == sizeof(u64) * 8) { channelBits = channelBitsUpper; @@ -350,9 +350,9 @@ void sequence_player_disable_channels_extended(struct SequencePlayer* seqPlayer, void sequence_player_disable_all_channels(struct SequencePlayer *seqPlayer) { if (!seqPlayer) { return; } - + MUTEX_LOCK(gAudioThread); - + eu_stubbed_printf_0("SUBTRACK DIM\n"); for (u32 i = 0; i < CHANNELS_MAX; i++) { struct SequenceChannel *seqChannel = seqPlayer->channels[i]; @@ -371,16 +371,16 @@ void sequence_player_disable_all_channels(struct SequencePlayer *seqPlayer) { seqPlayer->channels[i] = &gSequenceChannelNone; } } - + MUTEX_UNLOCK(gAudioThread); } void sequence_channel_enable(struct SequencePlayer *seqPlayer, u8 channelIndex, void *script) { if (!seqPlayer) { return; } if (channelIndex >= CHANNELS_MAX) { return; } - + MUTEX_LOCK(gAudioThread); - + struct SequenceChannel *seqChannel = seqPlayer->channels[channelIndex]; s32 i; if (IS_SEQUENCE_CHANNEL_VALID(seqChannel) == FALSE) { @@ -409,19 +409,19 @@ void sequence_channel_enable(struct SequencePlayer *seqPlayer, u8 channelIndex, seq_channel_layer_free(seqChannel, i); } } - + LOG_DEBUG("Enabled sequence channel %d with script entry of %p", channelIndex, script); } - + MUTEX_UNLOCK(gAudioThread); } void sequence_player_disable(struct SequencePlayer *seqPlayer) { if (!seqPlayer) { return; } MUTEX_LOCK(gAudioThread); - + LOG_DEBUG("Disabling sequence player %p", seqPlayer); - + sequence_player_disable_all_channels(seqPlayer); note_pool_clear(&seqPlayer->notePool); seqPlayer->finished = TRUE; @@ -1620,7 +1620,7 @@ u8 get_instrument(struct SequenceChannel *seqChannel, u8 instId, struct Instrume } void set_instrument(struct SequenceChannel *seqChannel, u8 instId) { - if (instId >= 0x80) { + if (instId >= 0x80 && instId <= 0x83) { seqChannel->instOrWave = instId; seqChannel->instrument = NULL; } else if (instId == 0x7f) { diff --git a/src/engine/behavior_script.c b/src/engine/behavior_script.c index 52aedaba1..8af14f249 100644 --- a/src/engine/behavior_script.c +++ b/src/engine/behavior_script.c @@ -797,7 +797,22 @@ static s32 bhv_cmd_load_collision_data(void) { // Command 0x2D: Sets the home position of the object to its current position. // Usage: SET_HOME() static s32 bhv_cmd_set_home(void) { - if (!(gCurrentObject->coopFlags & (COOP_OBJ_FLAG_LUA | COOP_OBJ_FLAG_NETWORK))) { + // COOP: only set home via behavior for the following cases + if ( + // if the object wasn't created via Lua + !(gCurrentObject->coopFlags & COOP_OBJ_FLAG_LUA) + // if the object wasn't created via network + // OR + // the object has never had its home set via behavior AND its home is default (e.g. (0, 0, 0)) + // (this case handles an object that needs its home set via behavior after being spawned by another player) + && ( + !(gCurrentObject->coopFlags & COOP_OBJ_FLAG_NETWORK) + || ( + !gCurrentObject->setHome + && gCurrentObject->oHomeX == 0.0f && gCurrentObject->oHomeY == 0.0f && gCurrentObject->oHomeZ == 0.0f + ) + ) + ) { gCurrentObject->oHomeX = gCurrentObject->oPosX; gCurrentObject->oHomeY = gCurrentObject->oPosY; gCurrentObject->oHomeZ = gCurrentObject->oPosZ; @@ -988,7 +1003,7 @@ static s32 bhv_cmd_call_native_ext(void) { const char *funcStr = dynos_behavior_get_token(behavior, BHV_CMD_GET_U32(1)); if (!funcStr) { - LOG_LUA("Could not retrieve function name from behavior command. Do you have an unclosed behavior script?"); + LOG_LUA("Could not retrieve function name from behavior command."); gCurBhvCommand += 2; return BHV_PROC_CONTINUE; } diff --git a/src/engine/graph_node.c b/src/engine/graph_node.c index c9c0023f6..89d9126cb 100644 --- a/src/engine/graph_node.c +++ b/src/engine/graph_node.c @@ -508,7 +508,7 @@ struct GraphNodeBackground *init_graph_node_background(struct DynamicPool *pool, : (backgroundFunc && background >= BACKGROUND_CUSTOM); if (invalidBackground) { - LOG_ERROR("invalid background id"); + LOG_ERROR("invalid background id %d", background); background = BACKGROUND_HAUNTED; } diff --git a/src/engine/lighting_engine.c b/src/engine/lighting_engine.c deleted file mode 100644 index 7466a5d80..000000000 --- a/src/engine/lighting_engine.c +++ /dev/null @@ -1,382 +0,0 @@ -#include "lighting_engine.h" -#include "math_util.h" - -struct LELight -{ - f32 posX; - f32 posY; - f32 posZ; - u8 colorR; - u8 colorG; - u8 colorB; - f32 radius; - f32 intensity; - bool added; - bool useSurfaceNormals; -}; - -Color gLEAmbientColor = { 127, 127, 127 }; -static struct LELight sLights[LE_MAX_LIGHTS] = { 0 }; -static enum LEMode sMode = LE_MODE_AFFECT_ALL_SHADED_AND_COLORED; -static enum LEToneMapping sToneMapping = LE_TONE_MAPPING_WEIGHTED; -static bool sEnabled = false; - -static inline void color_set(Color color, u8 r, u8 g, u8 b) { - color[0] = r; - color[1] = g; - color[2] = b; -} - -static inline void color_copy(Color dest, Color src) { - dest[0] = src[0]; - dest[1] = src[1]; - dest[2] = src[2]; -} - -bool le_is_enabled(void) { - // this is needed because we don't want to make vanilla darker, - // and we don't want to set the ambient color to { 255, 255, 255 } - // because then no one could see the effect of their lights - return sEnabled; -} - -void le_set_mode(enum LEMode mode) { - sMode = mode; -} - -enum LEMode le_get_mode(void) { - return sMode; -} - -void le_set_tone_mapping(enum LEToneMapping toneMapping) { - sToneMapping = toneMapping; -} - -void le_get_ambient_color(VEC_OUT Color out) { - color_copy(out, gLEAmbientColor); -} - -void le_set_ambient_color(u8 r, u8 g, u8 b) { - color_set(gLEAmbientColor, r, g, b); - sEnabled = true; -} - -static inline void le_tone_map_total_weighted(Color out, Color inAmbient, Vec3f inColor, float weight) { - out[0] = clamp((inAmbient[0] + inColor[0]) / weight, 0, 255); - out[1] = clamp((inAmbient[1] + inColor[1]) / weight, 0, 255); - out[2] = clamp((inAmbient[2] + inColor[2]) / weight, 0, 255); -} - -static inline void le_tone_map_weighted(Color out, Color inAmbient, Vec3f inColor, float weight) { - out[0] = clamp(inAmbient[0] + (inColor[0] / weight), 0, 255); - out[1] = clamp(inAmbient[1] + (inColor[1] / weight), 0, 255); - out[2] = clamp(inAmbient[2] + (inColor[2] / weight), 0, 255); -} - -static inline void le_tone_map_clamp(Color out, Color inAmbient, Vec3f inColor) { - out[0] = clamp(inAmbient[0] + inColor[0], 0, 255); - out[1] = clamp(inAmbient[1] + inColor[1], 0, 255); - out[2] = clamp(inAmbient[2] + inColor[2], 0, 255); -} - -static inline void le_tone_map_reinhard(Color out, Color inAmbient, Vec3f inColor) { - inColor[0] += inAmbient[0]; - inColor[1] += inAmbient[1]; - inColor[2] += inAmbient[2]; - - out[0] = clamp((inColor[0] / (inColor[0] + 255.0f)) * 255.0f, 0, 255); - out[1] = clamp((inColor[1] / (inColor[1] + 255.0f)) * 255.0f, 0, 255); - out[2] = clamp((inColor[2] / (inColor[2] + 255.0f)) * 255.0f, 0, 255); -} - -static inline void le_tone_map(Color out, Color inAmbient, Vec3f inColor, float weight) { - switch (sToneMapping) { - case LE_TONE_MAPPING_TOTAL_WEIGHTED: le_tone_map_total_weighted(out, inAmbient, inColor, weight); break; - case LE_TONE_MAPPING_WEIGHTED: le_tone_map_weighted(out, inAmbient, inColor, weight); break; - case LE_TONE_MAPPING_CLAMP: le_tone_map_clamp(out, inAmbient, inColor); break; - case LE_TONE_MAPPING_REINHARD: le_tone_map_reinhard(out, inAmbient, inColor); break; - } -} - -static inline void le_calculate_light_contribution(struct LELight* light, Vec3f pos, Vec3f normal, f32 lightIntensityScalar, Vec3f out_color, f32* weight) { - // skip 'inactive' lights - if (light->intensity <= 0 || light->radius <= 0) { return; } - - // vector to light - f32 diffX = light->posX - pos[0]; - f32 diffY = light->posY - pos[1]; - f32 diffZ = light->posZ - pos[2]; - - // squared distance check - f32 dist2 = (diffX * diffX) + (diffY * diffY) + (diffZ * diffZ); - f32 radius2 = light->radius * light->radius; - if (dist2 > radius2 || dist2 <= 0) { return; } - - // attenuation & intensity - f32 att = 1.0f - (dist2 / radius2); - f32 brightness = att * light->intensity * lightIntensityScalar; - - // normalize diff - f32 invLen = 1.0f / sqrtf(dist2); - diffX *= invLen; - diffY *= invLen; - diffZ *= invLen; - - if (light->useSurfaceNormals && normal) { - // lambert term - f32 nl = (normal[0] * diffX) + (normal[1] * diffY) + (normal[2] * diffZ); - if (nl <= 0.0f) { return; } - - // modulate by normal - brightness *= nl; - } - - // accumulate - out_color[0] += light->colorR * brightness; - out_color[1] += light->colorG * brightness; - out_color[2] += light->colorB * brightness; - *weight += brightness; -} - -void le_calculate_vertex_lighting(Vtx_t* v, Vec3f pos, Color out) { - // clear color - Vec3f color = { 0 }; - - // accumulate lighting - f32 weight = 1.0f; - for (s16 i = 0; i < LE_MAX_LIGHTS; i++) { - struct LELight* light = &sLights[i]; - if (!light->added) { continue; } - - le_calculate_light_contribution(light, pos, NULL, 1.0f, color, &weight); - } - - // tone map and output - Color vtxAmbient = { - v->cn[0] * (gLEAmbientColor[0] / 255.0f), - v->cn[1] * (gLEAmbientColor[1] / 255.0f), - v->cn[2] * (gLEAmbientColor[2] / 255.0f), - }; - le_tone_map(out, vtxAmbient, color, weight); -} - -void le_calculate_lighting_color(Vec3f pos, Color out, f32 lightIntensityScalar) { - // clear color - Vec3f color = { 0 }; - - // accumulate lighting - f32 weight = 1.0f; - for (s16 i = 0; i < LE_MAX_LIGHTS; i++) { - struct LELight* light = &sLights[i]; - if (!light->added) { continue; } - - le_calculate_light_contribution(light, pos, NULL, lightIntensityScalar, color, &weight); - } - - // tone map and output - le_tone_map(out, gLEAmbientColor, color, weight); -} - -void le_calculate_lighting_color_with_normal(Vec3f pos, Vec3f normal, Color out, f32 lightIntensityScalar) { - // normalize normal - if (normal) { vec3f_normalize(normal); } - - // clear color - Vec3f color = { 0 }; - - // accumulate lighting - f32 weight = 1.0f; - for (s16 i = 0; i < LE_MAX_LIGHTS; i++) { - struct LELight* light = &sLights[i]; - if (!light->added) { continue; } - - le_calculate_light_contribution(light, pos, normal, lightIntensityScalar, color, &weight); - } - - // tone map and output - le_tone_map(out, gLEAmbientColor, color, weight); -} - -void le_calculate_lighting_dir(Vec3f pos, Vec3f out) { - Vec3f lightingDir = { 0, 0, 0 }; - s16 count = 1; - - for (s16 i = 0; i < LE_MAX_LIGHTS; i++) { - struct LELight* light = &sLights[i]; - if (!light->added) { continue; } - - f32 diffX = light->posX - pos[0]; - f32 diffY = light->posY - pos[1]; - f32 diffZ = light->posZ - pos[2]; - f32 dist = (diffX * diffX) + (diffY * diffY) + (diffZ * diffZ); - f32 radius = light->radius * light->radius; - if (dist > radius) { continue; } - - Vec3f dir = { - pos[0] - light->posX, - pos[1] - light->posY, - pos[2] - light->posZ, - }; - vec3f_normalize(dir); - - f32 intensity = (1 - (dist / radius)) * light->intensity; - lightingDir[0] += dir[0] * intensity; - lightingDir[1] += dir[1] * intensity; - lightingDir[2] += dir[2] * intensity; - - count++; - } - - out[0] = lightingDir[0] / (f32)(count); - out[1] = lightingDir[1] / (f32)(count); - out[2] = lightingDir[2] / (f32)(count); - vec3f_normalize(out); -} - -s16 le_add_light(f32 x, f32 y, f32 z, u8 r, u8 g, u8 b, f32 radius, f32 intensity) { - struct LELight* newLight = NULL; - s16 lightID = -1; - - for (s16 i = 0; i < LE_MAX_LIGHTS; i++) { - struct LELight* light = &sLights[i]; - if (!light->added) { - newLight = light; - lightID = i; - break; - } - } - if (newLight == NULL) { return -1; } - - newLight->posX = x; - newLight->posY = y; - newLight->posZ = z; - newLight->colorR = r; - newLight->colorG = g; - newLight->colorB = b; - newLight->radius = radius; - newLight->intensity = intensity; - newLight->added = true; - newLight->useSurfaceNormals = true; - - sEnabled = true; - return lightID; -} - -void le_remove_light(s16 id) { - if (id < 0 || id >= LE_MAX_LIGHTS) { return; } - - memset(&sLights[id], 0, sizeof(struct LELight)); -} - -s16 le_get_light_count(void) { - s16 count = 0; - for (s16 i = 0; i < LE_MAX_LIGHTS; i++) { - if (sLights[i].added) { count++; } - } - - return count; -} - -bool le_light_exists(s16 id) { - if (id < 0 || id >= LE_MAX_LIGHTS) { return false; } - return sLights[id].added; -} - -void le_get_light_pos(s16 id, VEC_OUT Vec3f out) { - if (id < 0 || id >= LE_MAX_LIGHTS) { return; } - - struct LELight* light = &sLights[id]; - if (!light->added) { return; } - vec3f_set(out, light->posX, light->posY, light->posZ); -} - -void le_set_light_pos(s16 id, f32 x, f32 y, f32 z) { - if (id < 0 || id >= LE_MAX_LIGHTS) { return; } - - struct LELight* light = &sLights[id]; - if (!light->added) { return; } - light->posX = x; - light->posY = y; - light->posZ = z; -} - -void le_get_light_color(s16 id, VEC_OUT Color out) { - if (id < 0 || id >= LE_MAX_LIGHTS) { return; } - - struct LELight* light = &sLights[id]; - if (!light->added) { return; } - color_set(out, light->colorR, light->colorG, light->colorB); -} - -void le_set_light_color(s16 id, u8 r, u8 g, u8 b) { - if (id < 0 || id >= LE_MAX_LIGHTS) { return; } - - struct LELight* light = &sLights[id]; - if (!light->added) { return; } - light->colorR = r; - light->colorG = g; - light->colorB = b; -} - -f32 le_get_light_radius(s16 id) { - if (id < 0 || id >= LE_MAX_LIGHTS) { return 0.0f; } - - struct LELight* light = &sLights[id]; - if (!light->added) { return 0.0f; } - return light->radius; -} - -void le_set_light_radius(s16 id, f32 radius) { - if (id < 0 || id >= LE_MAX_LIGHTS) { return; } - - struct LELight* light = &sLights[id]; - if (!light->added) { return; } - light->radius = radius; -} - -f32 le_get_light_intensity(s16 id) { - if (id < 0 || id >= LE_MAX_LIGHTS) { return 0.0f; } - - struct LELight* light = &sLights[id]; - if (!light->added) { return 0.0f; } - return light->intensity; -} - -void le_set_light_intensity(s16 id, f32 intensity) { - if (id < 0 || id >= LE_MAX_LIGHTS) { return; } - - struct LELight* light = &sLights[id]; - if (!light->added) { return; } - light->intensity = intensity; -} - -bool le_get_light_use_surface_normals(s16 id) { - if (id < 0 || id >= LE_MAX_LIGHTS) { return false; } - - struct LELight* light = &sLights[id]; - if (!light->added) { return false; } - return light->useSurfaceNormals; -} - -void le_set_light_use_surface_normals(s16 id, bool useSurfaceNormals) { - if (id < 0 || id >= LE_MAX_LIGHTS) { return; } - - struct LELight* light = &sLights[id]; - if (!light->added) { return; } - light->useSurfaceNormals = useSurfaceNormals; -} - -void le_clear(void) { - memset(&sLights, 0, sizeof(struct LELight) * LE_MAX_LIGHTS); - - gLEAmbientColor[0] = 127; - gLEAmbientColor[1] = 127; - gLEAmbientColor[2] = 127; -} - -void le_shutdown(void) { - sEnabled = false; - sMode = LE_MODE_AFFECT_ALL_SHADED_AND_COLORED; - sToneMapping = LE_TONE_MAPPING_WEIGHTED; - le_clear(); -} diff --git a/src/engine/lighting_engine.cpp b/src/engine/lighting_engine.cpp new file mode 100644 index 000000000..0a12b55d5 --- /dev/null +++ b/src/engine/lighting_engine.cpp @@ -0,0 +1,444 @@ +#include "lighting_engine.h" +extern "C" { +#include "math_util.h" +#include "pc/lua/smlua.h" +} +#undef clamp +#undef min +#undef max +#include +#include +#ifdef __SSE__ +#include +#endif + +#define C_FIELD extern "C" + +struct LELight +{ + s16 id; + Vec3f pos; + Color color; + f32 radius; + f32 intensity; + bool useSurfaceNormals; +}; + +Color gLEAmbientColor = { 127, 127, 127 }; +static std::vector sLightPool; +static std::vector sActiveLights; +static s16 sLightID = -1; +static enum LEMode sMode = LE_MODE_AFFECT_ALL_SHADED_AND_COLORED; +static enum LEToneMapping sToneMapping = LE_TONE_MAPPING_WEIGHTED; +static bool sEnabled = false; +static u8 sMaxLightsPerVertex = 4; + +static inline f32 rsqrt(f32 value) { +#ifdef __SSE__ + return _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(value))); +#else + return 1.0f / sqrtf(value); +#endif +} + +static inline void color_set(Color color, u8 r, u8 g, u8 b) { + color[0] = r; + color[1] = g; + color[2] = b; +} + +static inline void color_copy(Color dest, Color src) { + dest[0] = src[0]; + dest[1] = src[1]; + dest[2] = src[2]; +} + +static inline u8 clamp_u8(f32 value) { + s32 v = (s32)value; + v = v < 0 ? 0 : v; + v = v > 255 ? 255 : v; + return (u8)v; +} + +C_FIELD bool le_is_enabled(void) { + // this is needed because we don't want to make vanilla darker, + // and we don't want to set the ambient color to { 255, 255, 255 } + // because then no one could see the effect of their lights + return sEnabled; +} + +C_FIELD void le_set_mode(enum LEMode mode) { + sMode = mode; +} + +C_FIELD enum LEMode le_get_mode(void) { + return sMode; +} + +C_FIELD void le_set_tone_mapping(enum LEToneMapping toneMapping) { + sToneMapping = toneMapping; +} + +C_FIELD void le_get_ambient_color(VEC_OUT Color out) { + color_copy(out, gLEAmbientColor); +} + +C_FIELD void le_set_ambient_color(u8 r, u8 g, u8 b) { + color_set(gLEAmbientColor, r, g, b); + sEnabled = true; +} + +C_FIELD void le_set_max_lights_per_vertex(u8 count) { + sMaxLightsPerVertex = count; +} + +static inline void le_tone_map_total_weighted(Color out, Color inAmbient, Vec3f inColor, f32 weight) { + out[0] = clamp_u8((inAmbient[0] + inColor[0]) / weight); + out[1] = clamp_u8((inAmbient[1] + inColor[1]) / weight); + out[2] = clamp_u8((inAmbient[2] + inColor[2]) / weight); +} + +static inline void le_tone_map_weighted(Color out, Color inAmbient, Vec3f inColor, f32 weight) { + out[0] = clamp_u8(inAmbient[0] + (inColor[0] / weight)); + out[1] = clamp_u8(inAmbient[1] + (inColor[1] / weight)); + out[2] = clamp_u8(inAmbient[2] + (inColor[2] / weight)); +} + +static inline void le_tone_map_clamp(Color out, Color inAmbient, Vec3f inColor) { + out[0] = clamp_u8(inAmbient[0] + inColor[0]); + out[1] = clamp_u8(inAmbient[1] + inColor[1]); + out[2] = clamp_u8(inAmbient[2] + inColor[2]); +} + +static inline void le_tone_map_reinhard(Color out, Color inAmbient, Vec3f inColor) { + inColor[0] += inAmbient[0]; + inColor[1] += inAmbient[1]; + inColor[2] += inAmbient[2]; + + out[0] = clamp_u8((inColor[0] / (inColor[0] + 255.0f)) * 255.0f); + out[1] = clamp_u8((inColor[1] / (inColor[1] + 255.0f)) * 255.0f); + out[2] = clamp_u8((inColor[2] / (inColor[2] + 255.0f)) * 255.0f); +} + +static void le_tone_map(Color out, Color inAmbient, Vec3f inColor, f32 weight) { + switch (sToneMapping) { + case LE_TONE_MAPPING_TOTAL_WEIGHTED: le_tone_map_total_weighted(out, inAmbient, inColor, weight); break; + case LE_TONE_MAPPING_WEIGHTED: le_tone_map_weighted(out, inAmbient, inColor, weight); break; + case LE_TONE_MAPPING_CLAMP: le_tone_map_clamp(out, inAmbient, inColor); break; + case LE_TONE_MAPPING_REINHARD: le_tone_map_reinhard(out, inAmbient, inColor); break; + } +} + +static void le_update_active_lights() { + sActiveLights.clear(); + for (auto& light : sLightPool) { + if (light.intensity > 0.0f && light.radius > 0.0f) { + sActiveLights.push_back(&light); + } + } +} + +static inline OPTIMIZE_O3 void le_calculate_light_contribution(const LELight& light, Vec3f pos, Vec3f normal, f32 lightIntensityScalar, Vec3f outColor, f32& weight, u8& contribution) { + // vector to light + f32 diffX = light.pos[0] - pos[0]; + f32 diffY = light.pos[1] - pos[1]; + f32 diffZ = light.pos[2] - pos[2]; + + // squared distance check + f32 dist2 = (diffX * diffX) + (diffY * diffY) + (diffZ * diffZ); + f32 radius2 = light.radius * light.radius; + if (dist2 > radius2 || dist2 <= 0) { return; } + + // attenuation & intensity + f32 att = 1.0f - (dist2 / radius2); + f32 brightness = att * light.intensity * lightIntensityScalar; + + if (light.useSurfaceNormals && normal) { + // normalize diff + f32 invLen = rsqrt(dist2); + diffX *= invLen; + diffY *= invLen; + diffZ *= invLen; + + // lambert term + f32 nl = (normal[0] * diffX) + (normal[1] * diffY) + (normal[2] * diffZ); + if (nl <= 0.0f) { return; } + + // modulate by normal + brightness *= nl; + } + + // accumulate + outColor[0] += light.color[0] * brightness; + outColor[1] += light.color[1] * brightness; + outColor[2] += light.color[2] * brightness; + weight += brightness; + contribution++; +} + +C_FIELD OPTIMIZE_O3 void le_calculate_vertex_lighting(const Vtx_t* v, Vec3f pos, VEC_OUT Color out) { + // clear color + Vec3f color = { 0 }; + + // accumulate lighting + f32 weight = 1.0f; + u8 contribution = 0; + for (LELight* light : sActiveLights) { + le_calculate_light_contribution(*light, pos, NULL, 1.0f, color, weight, contribution); + if (contribution == sMaxLightsPerVertex) { break; } + } + + // tone map and output + Color vtxAmbient = { + (u8)(v->cn[0] * (gLEAmbientColor[0] / 255.0f)), + (u8)(v->cn[1] * (gLEAmbientColor[1] / 255.0f)), + (u8)(v->cn[2] * (gLEAmbientColor[2] / 255.0f)), + }; + le_tone_map(out, vtxAmbient, color, weight); +} + +C_FIELD OPTIMIZE_O3 void le_calculate_lighting_color(Vec3f pos, VEC_OUT Color out, f32 lightIntensityScalar) { + // clear color + Vec3f color = { 0 }; + + // accumulate lighting + f32 weight = 1.0f; + u8 contribution = 0; + for (LELight* light : sActiveLights) { + le_calculate_light_contribution(*light, pos, NULL, lightIntensityScalar, color, weight, contribution); + if (contribution == sMaxLightsPerVertex) { break; } + } + + // tone map and output + le_tone_map(out, gLEAmbientColor, color, weight); +} + +C_FIELD OPTIMIZE_O3 void le_calculate_lighting_color_with_normal(Vec3f pos, Vec3f normal, VEC_OUT Color out, f32 lightIntensityScalar) { + // normalize normal + if (normal) { vec3f_normalize(normal); } + + // clear color + Vec3f color = { 0 }; + + // accumulate lighting + f32 weight = 1.0f; + u8 contribution = 0; + for (LELight* light : sActiveLights) { + le_calculate_light_contribution(*light, pos, normal, lightIntensityScalar, color, weight, contribution); + if (contribution == sMaxLightsPerVertex) { break; } + } + + // tone map and output + le_tone_map(out, gLEAmbientColor, color, weight); +} + +C_FIELD void le_calculate_lighting_dir(Vec3f pos, VEC_OUT Vec3f out) { + Vec3f lightingDir = { 0, 0, 0 }; + s16 count = 1; + + for (LELight* light : sActiveLights) { + f32 diffX = light->pos[0] - pos[0]; + f32 diffY = light->pos[1] - pos[1]; + f32 diffZ = light->pos[2] - pos[2]; + f32 dist = (diffX * diffX) + (diffY * diffY) + (diffZ * diffZ); + f32 radius = light->radius * light->radius; + if (dist > radius) { continue; } + + Vec3f dir = { + pos[0] - light->pos[0], + pos[1] - light->pos[1], + pos[2] - light->pos[2], + }; + vec3f_normalize(dir); + + f32 intensity = (1 - (dist / radius)) * light->intensity; + lightingDir[0] += dir[0] * intensity; + lightingDir[1] += dir[1] * intensity; + lightingDir[2] += dir[2] * intensity; + + count++; + } + + out[0] = lightingDir[0] / (f32)(count); + out[1] = lightingDir[1] / (f32)(count); + out[2] = lightingDir[2] / (f32)(count); + vec3f_normalize(out); +} + +C_FIELD s16 le_add_light(f32 x, f32 y, f32 z, u8 r, u8 g, u8 b, f32 radius, f32 intensity) { + if (sLightPool.size() >= LE_MAX_LIGHTS) { + LOG_LUA_LINE("LE light count cannot exceed %d lights!", LE_MAX_LIGHTS); + return -1; + } + + LELight newLight; + newLight.id = ++sLightID; + newLight.pos[0] = x; + newLight.pos[1] = y; + newLight.pos[2] = z; + newLight.color[0] = r; + newLight.color[1] = g; + newLight.color[2] = b; + newLight.radius = radius; + newLight.intensity = intensity; + newLight.useSurfaceNormals = true; + + sLightPool.push_back(newLight); + + le_update_active_lights(); + + sEnabled = true; + return sLightID; +} + +C_FIELD void le_remove_light(s16 id) { + if (id < 0) { return; } + + auto it = std::find_if(sLightPool.begin(), sLightPool.end(), + [id](const LELight& light) { + return light.id == id; + } + ); + + if (it != sLightPool.end()) { + sLightPool.erase(it); + } + + le_update_active_lights(); +} + +C_FIELD s16 le_get_light_count(void) { + return sLightPool.size(); +} + +C_FIELD bool le_light_exists(s16 id) { + if (id < 0) { return false; } + + return std::any_of(sLightPool.begin(), sLightPool.end(), + [id](const LELight& light) { + return light.id == id; + } + ); +} + +static LELight* le_find_light(s16 id) { + if (id < 0) { return nullptr; } + + auto it = std::find_if(sLightPool.begin(), sLightPool.end(), + [id](const LELight& light) { + return light.id == id; + } + ); + + // kinda cursed syntax but it works + return (it != sLightPool.end()) ? &(*it) : nullptr; +} + +C_FIELD void le_get_light_pos(s16 id, VEC_OUT Vec3f out) { + if (id < 0) { return; } + + if (auto* light = le_find_light(id)) { + vec3f_set(out, light->pos[0], light->pos[1], light->pos[2]); + } +} + +C_FIELD void le_set_light_pos(s16 id, f32 x, f32 y, f32 z) { + if (id < 0) { return; } + + if (auto* light = le_find_light(id)) { + light->pos[0] = x; + light->pos[1] = y; + light->pos[2] = z; + } +} + +C_FIELD void le_get_light_color(s16 id, VEC_OUT Color out) { + if (id < 0) { return; } + + if (auto* light = le_find_light(id)) { + color_set(out, light->color[0], light->color[1], light->color[2]); + } +} + +C_FIELD void le_set_light_color(s16 id, u8 r, u8 g, u8 b) { + if (id < 0) { return; } + + if (auto* light = le_find_light(id)) { + light->color[0] = r; + light->color[1] = g; + light->color[2] = b; + } +} + +C_FIELD f32 le_get_light_radius(s16 id) { + if (id < 0) { return 0.0f; } + + if (auto* light = le_find_light(id)) { + return light->radius; + } + + return 0.0f; +} + +C_FIELD void le_set_light_radius(s16 id, f32 radius) { + if (id < 0) { return; } + + if (auto* light = le_find_light(id)) { + light->radius = radius; + } + + le_update_active_lights(); +} + +C_FIELD f32 le_get_light_intensity(s16 id) { + if (id < 0) { return 0.0f; } + + if (auto* light = le_find_light(id)) { + return light->intensity; + } + + return 0.0f; +} + +C_FIELD void le_set_light_intensity(s16 id, f32 intensity) { + if (id < 0) { return; } + + if (auto* light = le_find_light(id)) { + light->intensity = intensity; + } + + le_update_active_lights(); +} + +C_FIELD bool le_get_light_use_surface_normals(s16 id) { + if (id < 0) { return false; } + + if (auto* light = le_find_light(id)) { + return light->useSurfaceNormals; + } + + return false; +} + +C_FIELD void le_set_light_use_surface_normals(s16 id, bool useSurfaceNormals) { + if (id < 0) { return; } + + if (auto* light = le_find_light(id)) { + light->useSurfaceNormals = useSurfaceNormals; + } +} + +void le_clear(void) { + sLightPool.clear(); + sLightID = -1; + + color_set(gLEAmbientColor, 127, 127, 127); +} + +void le_shutdown(void) { + sEnabled = false; + sMode = LE_MODE_AFFECT_ALL_SHADED_AND_COLORED; + sToneMapping = LE_TONE_MAPPING_WEIGHTED; + sMaxLightsPerVertex = 4; + le_clear(); +} diff --git a/src/engine/lighting_engine.h b/src/engine/lighting_engine.h index 669e31d63..cc0d4d725 100644 --- a/src/engine/lighting_engine.h +++ b/src/engine/lighting_engine.h @@ -1,9 +1,12 @@ #ifndef LIGHTING_ENGINE_H #define LIGHTING_ENGINE_H +#ifdef __cplusplus +extern "C" { +#endif #include "types.h" -#define LE_MAX_LIGHTS 512 +#define LE_MAX_LIGHTS 1024 enum LEMode { LE_MODE_AFFECT_ALL_SHADED_AND_COLORED, @@ -32,8 +35,10 @@ void le_set_tone_mapping(enum LEToneMapping toneMapping); void le_get_ambient_color(VEC_OUT Color out); /* |description|Sets the lighting engine ambient color|descriptionEnd| */ void le_set_ambient_color(u8 r, u8 g, u8 b); +/* |description|Sets the max amount of lights that can affect a vertex|descriptionEnd| */ +void le_set_max_lights_per_vertex(u8 count); -void le_calculate_vertex_lighting(Vtx_t* v, Vec3f pos, VEC_OUT Color out); +void le_calculate_vertex_lighting(const Vtx_t* v, Vec3f pos, VEC_OUT Color out); /* |description|Calculates the lighting with `lightIntensityScalar` at a position and outputs the color in `out`|descriptionEnd|*/ void le_calculate_lighting_color(Vec3f pos, VEC_OUT Color out, f32 lightIntensityScalar); /* |description|Calculates the lighting with `lightIntensityScalar` at a position and with a normal and outputs the color in `out`|descriptionEnd|*/ @@ -71,4 +76,8 @@ void le_set_light_use_surface_normals(s16 id, bool useSurfaceNormals); void le_clear(void); void le_shutdown(void); +#ifdef __cplusplus +} +#endif + #endif // LIGHTING_ENGINE_H diff --git a/src/engine/math_util.c b/src/engine/math_util.c index f13dc051f..592968651 100644 --- a/src/engine/math_util.c +++ b/src/engine/math_util.c @@ -827,7 +827,7 @@ OPTIMIZE_O3 bool mtxf_inverse_non_affine(VEC_OUT Mat4 dest, Mat4 src) { if (fabsf(aug[i][k]) > fabsf(aug[piv][k])) { piv = i; } } - if (fabsf(aug[piv][k]) < FLT_EPSILON) { return false; } + if (fabsf(aug[piv][k]) < __FLT_EPSILON__) { return false; } // swap pivot row into place if (piv != k) { diff --git a/src/engine/surface_collision.c b/src/engine/surface_collision.c index 15f6f9a9f..97414235e 100644 --- a/src/engine/surface_collision.c +++ b/src/engine/surface_collision.c @@ -12,6 +12,7 @@ #include "game/hardcoded.h" #include "pc/utils/misc.h" #include "pc/network/network.h" +#include "pc/lua/smlua_hooks.h" Vec3f gFindWallDirection = { 0 }; u8 gFindWallDirectionActive = false; @@ -343,6 +344,9 @@ s32 find_wall_collisions(struct WallCollisionData *colData) { s32 numCollisions = 0; s16 x = colData->x; s16 z = colData->z; + f32 posX = colData->x; + f32 posY = colData->y; + f32 posZ = colData->z; colData->numWalls = 0; @@ -371,6 +375,8 @@ s32 find_wall_collisions(struct WallCollisionData *colData) { // Increment the debug tracker. gNumCalls.wall += 1; + smlua_call_event_hooks(HOOK_ON_FIND_WALL_COLLISION, posX, posY, posZ, colData, &numCollisions); + return numCollisions; } @@ -544,6 +550,8 @@ f32 find_ceil(f32 posX, f32 posY, f32 posZ, RET struct Surface **pceil) { // Increment the debug tracker. gNumCalls.ceil += 1; + smlua_call_event_hooks(HOOK_ON_FIND_CEIL, posX, posY, posZ, pceil, &height); + return height; } @@ -882,6 +890,8 @@ f32 find_floor(f32 xPos, f32 yPos, f32 zPos, RET struct Surface **pfloor) { // Increment the debug tracker. gNumCalls.floor += 1; + smlua_call_event_hooks(HOOK_ON_FIND_FLOOR, xPos, yPos, zPos, pfloor, &height); + return height; } @@ -922,6 +932,8 @@ f32 find_water_level(f32 x, f32 z) { } } + smlua_call_event_hooks(HOOK_ON_FIND_WATER_LEVEL, x, z, &waterLevel); + return waterLevel; } @@ -963,6 +975,8 @@ f32 find_poison_gas_level(f32 x, f32 z) { } } + smlua_call_event_hooks(HOOK_ON_FIND_POISON_GAS_LEVEL, x, z, &gasLevel); + return gasLevel; } @@ -1227,6 +1241,7 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve if (normalized_dir[1] >= 1.0f || normalized_dir[1] <= -1.0f) { find_surface_on_ray_cell(cellX, cellZ, orig, normalized_dir, dir_length, hit_surface, hit_pos, &max_length); + smlua_call_event_hooks(HOOK_ON_FIND_SURFACE_ON_RAY, orig, dir, hit_surface, hit_pos); return; } @@ -1249,4 +1264,6 @@ void find_surface_on_ray(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Ve cellX = (s16)fCellX; cellZ = (s16)fCellZ; } + + smlua_call_event_hooks(HOOK_ON_FIND_SURFACE_ON_RAY, orig, dir, hit_surface, hit_pos); } diff --git a/src/engine/surface_load.c b/src/engine/surface_load.c index e5296490e..345a73202 100644 --- a/src/engine/surface_load.c +++ b/src/engine/surface_load.c @@ -271,6 +271,8 @@ static void add_surface(struct Surface *surface, s32 dynamic) { s16 cellZ, cellX; + smlua_call_event_hooks(HOOK_ON_ADD_SURFACE, surface, dynamic); + minX = min_3(surface->vertex1[0], surface->vertex2[0], surface->vertex3[0]); minZ = min_3(surface->vertex1[2], surface->vertex2[2], surface->vertex3[2]); maxX = max_3(surface->vertex1[0], surface->vertex2[0], surface->vertex3[0]); @@ -287,7 +289,6 @@ static void add_surface(struct Surface *surface, s32 dynamic) { } } - smlua_call_event_hooks(HOOK_ON_ADD_SURFACE, surface, dynamic); } /** @@ -805,7 +806,10 @@ static void load_object_collision_model_internal(bool isSOC) { for (s32 i = 0; i < MAX_PLAYERS; i++) { f32 dist = dist_between_objects(gCurrentObject, gMarioStates[i].marioObj); - if (dist < tangibleDist) { anyPlayerInTangibleRange = TRUE; } + if (dist < tangibleDist) { + anyPlayerInTangibleRange = TRUE; + break; + } } // If the object collision is supposed to be loaded more than the diff --git a/src/game/behaviors/activated_bf_plat.inc.c b/src/game/behaviors/activated_bf_plat.inc.c index 98a40cdf3..003c4ddb5 100644 --- a/src/game/behaviors/activated_bf_plat.inc.c +++ b/src/game/behaviors/activated_bf_plat.inc.c @@ -57,19 +57,19 @@ void bhv_activated_back_and_forth_platform_init(void) { o->oActivatedBackAndForthPlatformStartYaw = o->oFaceAngleYaw; sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); - sync_object_init_field(o, &o->oVelX); - sync_object_init_field(o, &o->oVelY); - sync_object_init_field(o, &o->oVelZ); - sync_object_init_field(o, &o->oActivatedBackAndForthPlatformMaxOffset); - sync_object_init_field(o, &o->oActivatedBackAndForthPlatformOffset); - sync_object_init_field(o, &o->oActivatedBackAndForthPlatformVel); - sync_object_init_field(o, &o->oActivatedBackAndForthPlatformCountdown); - sync_object_init_field(o, &o->oActivatedBackAndForthPlatformStartYaw); - sync_object_init_field(o, &o->oActivatedBackAndForthPlatformVertical); - sync_object_init_field(o, &o->oActivatedBackAndForthPlatformFlipRotation); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); + sync_object_init_field(o, o->oVelX); + sync_object_init_field(o, o->oVelY); + sync_object_init_field(o, o->oVelZ); + sync_object_init_field(o, o->oActivatedBackAndForthPlatformMaxOffset); + sync_object_init_field(o, o->oActivatedBackAndForthPlatformOffset); + sync_object_init_field(o, o->oActivatedBackAndForthPlatformVel); + sync_object_init_field(o, o->oActivatedBackAndForthPlatformCountdown); + sync_object_init_field(o, o->oActivatedBackAndForthPlatformStartYaw); + sync_object_init_field(o, o->oActivatedBackAndForthPlatformVertical); + sync_object_init_field(o, o->oActivatedBackAndForthPlatformFlipRotation); } /** diff --git a/src/game/behaviors/amp.inc.c b/src/game/behaviors/amp.inc.c index c6c7e8b9c..e797f6a69 100644 --- a/src/game/behaviors/amp.inc.c +++ b/src/game/behaviors/amp.inc.c @@ -207,14 +207,14 @@ void bhv_homing_amp_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, 4000.0f); if (so) { - sync_object_init_field(o, &o->oAmpYPhase); - sync_object_init_field(o, &o->oAnimState); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oFaceAngleYaw); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oFriction); - sync_object_init_field(o, &o->oHomingAmpAvgY); - sync_object_init_field(o, &o->oHomingAmpLockedOn); + sync_object_init_field(o, o->oAmpYPhase); + sync_object_init_field(o, o->oAnimState); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oFaceAngleYaw); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oFriction); + sync_object_init_field(o, o->oHomingAmpAvgY); + sync_object_init_field(o, o->oHomingAmpLockedOn); } } @@ -354,12 +354,12 @@ void bhv_circling_amp_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, 4000.0f); if (so) { - sync_object_init_field(o, &o->oAmpYPhase); - sync_object_init_field(o, &o->oAnimState); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oFaceAngleYaw); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oFriction); + sync_object_init_field(o, o->oAmpYPhase); + sync_object_init_field(o, o->oAnimState); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oFaceAngleYaw); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oFriction); } } diff --git a/src/game/behaviors/arrow_lift.inc.c b/src/game/behaviors/arrow_lift.inc.c index fa49985de..86e6e7d72 100644 --- a/src/game/behaviors/arrow_lift.inc.c +++ b/src/game/behaviors/arrow_lift.inc.c @@ -62,9 +62,9 @@ void bhv_arrow_lift_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oAction); } } diff --git a/src/game/behaviors/bbh_haunted_bookshelf.inc.c b/src/game/behaviors/bbh_haunted_bookshelf.inc.c index 359d8c240..9ab34072a 100644 --- a/src/game/behaviors/bbh_haunted_bookshelf.inc.c +++ b/src/game/behaviors/bbh_haunted_bookshelf.inc.c @@ -10,10 +10,10 @@ void bhv_haunted_bookshelf_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oHauntedBookshelfShouldOpen); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oHauntedBookshelfShouldOpen); } // oDistanceToMario is unused by this object. diff --git a/src/game/behaviors/bbh_merry_go_round.inc.c b/src/game/behaviors/bbh_merry_go_round.inc.c index 3f38561c9..6cf25c912 100644 --- a/src/game/behaviors/bbh_merry_go_round.inc.c +++ b/src/game/behaviors/bbh_merry_go_round.inc.c @@ -10,6 +10,9 @@ * in the enclosure nor in the room around it. */ static void handle_merry_go_round_music(void) { + // COOP: raise scope of this variable since floor check is no longer strictly tied to music + u16 marioFloorType = 0; + // If the music should play, play it and check whether it still should. // Otherwise, don't play it and check whether it should. if (o->oMerryGoRoundMusicShouldPlay == FALSE) { @@ -23,7 +26,7 @@ static void handle_merry_go_round_music(void) { // Get Mario's floor and floor surface type struct Surface *marioFloor = NULL; struct Object *marioObject = gMarioObjects[0]; - u16 marioFloorType = 0; + // COOP: `marioFloorType` originally here if (marioObject) { find_floor(marioObject->oPosX, marioObject->oPosY, marioObject->oPosZ, &marioFloor); @@ -37,7 +40,9 @@ static void handle_merry_go_round_music(void) { // The cur_obj_is_mario_on_platform check is redundant since the merry-go-round // has surface type 0x1A, so Mario cannot be on the merry-go-round // without being on a floor with surface type 0x1A (SURFACE_MGR_MUSIC). - gMarioOnMerryGoRound = cur_obj_is_any_player_on_platform(); + + // COOP: `gMarioOnMerryGoRound` is used to determine if the merry-go-round Boos should be active + // for co-op, this means that this check needs to be separated from the music check, since music is client-side. if (cur_obj_is_mario_on_platform() || marioFloorType == SURFACE_MGR_MUSIC) { // If Mario is in the merry-go-round's enclosure, play only the merry-go-round music. play_secondary_music(SEQ_EVENT_MERRY_GO_ROUND, 0, 78, 50); @@ -60,6 +65,28 @@ static void handle_merry_go_round_music(void) { cur_obj_play_sound_1(SOUND_ENV_MERRY_GO_ROUND_CREAKING); } } + + // COOP: floor check happens here + // `marioFloorType` refers to the local player's character + gMarioOnMerryGoRound = marioFloorType == SURFACE_MGR_MUSIC || cur_obj_is_any_player_on_platform(); + if (!gMarioOnMerryGoRound) { + // check the other Marios' floors + // starting at 1 since local player was already checked + for (s32 i = 1; i < MAX_PLAYERS; i++) { + if (!is_player_active(&gMarioStates[i])) { continue; } + + struct Object *marioObject = gMarioStates[i].marioObj; + if (marioObject == NULL) { continue; } + + struct Surface *marioFloor = NULL; + find_floor(marioObject->oPosX, marioObject->oPosY, marioObject->oPosZ, &marioFloor); + + if (marioFloor != NULL && marioFloor->type == SURFACE_MGR_MUSIC) { + gMarioOnMerryGoRound = TRUE; + break; + } + } + } } /** diff --git a/src/game/behaviors/bbh_tilting_trap.inc.c b/src/game/behaviors/bbh_tilting_trap.inc.c index f80b9a65a..3a810522b 100644 --- a/src/game/behaviors/bbh_tilting_trap.inc.c +++ b/src/game/behaviors/bbh_tilting_trap.inc.c @@ -12,8 +12,8 @@ void bhv_bbh_tilting_trap_platform_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 1000.0f); - sync_object_init_field(o, &o->oAngleVelPitch); - sync_object_init_field(o, &o->oFaceAnglePitch); + sync_object_init_field(o, o->oAngleVelPitch); + sync_object_init_field(o, o->oFaceAnglePitch); } f32 x = 0; diff --git a/src/game/behaviors/blue_coin.inc.c b/src/game/behaviors/blue_coin.inc.c index 2aa0225a2..156806de2 100644 --- a/src/game/behaviors/blue_coin.inc.c +++ b/src/game/behaviors/blue_coin.inc.c @@ -120,12 +120,12 @@ void bhv_blue_coin_switch_init(void) { void bhv_blue_coin_switch_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oVelY); - sync_object_init_field(o, &o->oGravity); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oHomeY); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oVelY); + sync_object_init_field(o, o->oGravity); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oHomeY); } // The switch's model is 1/3 size. diff --git a/src/game/behaviors/bobomb.inc.c b/src/game/behaviors/bobomb.inc.c index 762eaabb6..fbf15cb66 100644 --- a/src/game/behaviors/bobomb.inc.c +++ b/src/game/behaviors/bobomb.inc.c @@ -300,9 +300,9 @@ void bhv_bobomb_buddy_init(void) { if (o->oBobombBuddyRole == BOBOMB_BUDDY_ROLE_CANNON) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oBobombBuddyHasTalkedToMario); - sync_object_init_field(o, &o->oBobombBuddyCannonStatus); - sync_object_init_field(o, &forceCannonOpen); + sync_object_init_field(o, o->oBobombBuddyHasTalkedToMario); + sync_object_init_field(o, o->oBobombBuddyCannonStatus); + sync_object_init_field(o, forceCannonOpen); } } diff --git a/src/game/behaviors/boo.inc.c b/src/game/behaviors/boo.inc.c index acdab4961..5561e19c3 100644 --- a/src/game/behaviors/boo.inc.c +++ b/src/game/behaviors/boo.inc.c @@ -27,20 +27,20 @@ struct SyncObject* boo_sync_object_init(void) { struct SyncObject *so = sync_object_init(o, 4000.0f); if (so == NULL) { return NULL; } so->ignore_if_true = boo_ignore_update; - sync_object_init_field(o, &o->oBooBaseScale); - sync_object_init_field(o, &o->oBooNegatedAggressiveness); - sync_object_init_field(o, &o->oBooOscillationTimer); - sync_object_init_field(o, &o->oBooTargetOpacity); - sync_object_init_field(o, &o->oBooTurningSpeed); - sync_object_init_field(o, &o->oFaceAngleRoll); - sync_object_init_field(o, &o->oFaceAngleYaw); - sync_object_init_field(o, &o->oFlags); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oHealth); - sync_object_init_field(o, &o->oInteractStatus); - sync_object_init_field(o, &o->oInteractType); - sync_object_init_field(o, &o->oOpacity); - sync_object_init_field(o, &o->oRoom); + sync_object_init_field(o, o->oBooBaseScale); + sync_object_init_field(o, o->oBooNegatedAggressiveness); + sync_object_init_field(o, o->oBooOscillationTimer); + sync_object_init_field(o, o->oBooTargetOpacity); + sync_object_init_field(o, o->oBooTurningSpeed); + sync_object_init_field(o, o->oFaceAngleRoll); + sync_object_init_field(o, o->oFaceAngleYaw); + sync_object_init_field(o, o->oFlags); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oHealth); + sync_object_init_field(o, o->oInteractStatus); + sync_object_init_field(o, o->oInteractType); + sync_object_init_field(o, o->oOpacity); + sync_object_init_field(o, o->oRoom); return so; } @@ -56,16 +56,11 @@ void bhv_boo_init(void) { static s32 boo_should_be_stopped(void) { if (cur_obj_has_behavior(bhvMerryGoRoundBigBoo) || cur_obj_has_behavior(bhvMerryGoRoundBoo)) { - for (s32 i = 0; i < MAX_PLAYERS; i++) { - if (!is_player_active(&gMarioStates[i])) { continue; } - if (gMarioStates[i].currentRoom != BBH_DYNAMIC_SURFACE_ROOM && gMarioStates[i].currentRoom != BBH_NEAR_MERRY_GO_ROUND_ROOM) { return TRUE; } - } - return FALSE; - /*if (!gMarioOnMerryGoRound) { + if (!gMarioOnMerryGoRound) { return TRUE; } else { return FALSE; - }*/ + } } else { if (o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM) { return TRUE; @@ -384,9 +379,7 @@ static void boo_chase_mario(f32 a0, s16 a1, f32 a2) { if (boo_vanish_or_appear()) { o->oInteractType = 0x8000; - - u8 isMerryGoRoundBoo = (cur_obj_has_behavior(bhvMerryGoRoundBigBoo) || cur_obj_has_behavior(bhvMerryGoRoundBoo)); - if (!isMerryGoRoundBoo && cur_obj_lateral_dist_from_obj_to_home(player) > 1500.0f) { + if (cur_obj_lateral_dist_from_obj_to_home(player) > 1500.0f) { sp1A = cur_obj_angle_to_home(); } else { sp1A = angleToPlayer; @@ -535,7 +528,8 @@ static void (*sBooActions[])(void) = { }; void bhv_boo_loop(void) { - if (o->oAction < 3) { + // COOP: only sync when Boo isn't in a death state + if (o->oAction < 3 || o->oAction == 5) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject* so = boo_sync_object_init(); if (so) { so->syncDeathEvent = FALSE; } @@ -862,8 +856,8 @@ void bhv_boo_with_cage_loop(void) { void bhv_merry_go_round_boo_manager_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oMerryGoRoundBooManagerNumBoosSpawned); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oMerryGoRoundBooManagerNumBoosSpawned); } struct Object* player = nearest_player_to_object(o); diff --git a/src/game/behaviors/boo_cage.inc.c b/src/game/behaviors/boo_cage.inc.c index 5487e6ba4..11c2f6745 100644 --- a/src/game/behaviors/boo_cage.inc.c +++ b/src/game/behaviors/boo_cage.inc.c @@ -32,13 +32,13 @@ void bhv_boo_cage_init(void) { struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so == NULL) { return; } so->on_received_post = bhv_boo_cage_on_received_post; - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); - sync_object_init_field(o, &o->oVelX); - sync_object_init_field(o, &o->oVelY); - sync_object_init_field(o, &o->oVelZ); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); + sync_object_init_field(o, o->oVelX); + sync_object_init_field(o, o->oVelY); + sync_object_init_field(o, o->oVelZ); } /** diff --git a/src/game/behaviors/boulder.inc.c b/src/game/behaviors/boulder.inc.c index 13acba88c..b278b22a4 100644 --- a/src/game/behaviors/boulder.inc.c +++ b/src/game/behaviors/boulder.inc.c @@ -53,7 +53,7 @@ void bhv_big_boulder_loop(void) { void bhv_big_boulder_generator_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oTimer); + sync_object_init_field(o, o->oTimer); } struct Object *sp1C; diff --git a/src/game/behaviors/bowser.inc.c b/src/game/behaviors/bowser.inc.c index 52c474577..1d7dab87d 100644 --- a/src/game/behaviors/bowser.inc.c +++ b/src/game/behaviors/bowser.inc.c @@ -50,14 +50,14 @@ s16 D_8032F520[][3] = { { 1, 10, 40 }, { 0, 0, 74 }, { -1, -10, 114 }, { 1 void bhv_bowser_tail_anchor_init(void) { if (!o->parentObj) { mark_obj_for_deletion(o); return; } - sync_object_init_field(o->parentObj, &o->oAction); - sync_object_init_field(o->parentObj, &o->oPrevAction); - sync_object_init_field(o->parentObj, &o->oTimer); - sync_object_init_field(o->parentObj, &o->oIntangibleTimer); - sync_object_init_field(o->parentObj, &o->oInteractStatus); - sync_object_init_field(o->parentObj, &o->header.gfx.scale[0]); - sync_object_init_field(o->parentObj, &o->header.gfx.scale[1]); - sync_object_init_field(o->parentObj, &o->header.gfx.scale[2]); + sync_object_init_field(o->parentObj, o->oAction); + sync_object_init_field(o->parentObj, o->oPrevAction); + sync_object_init_field(o->parentObj, o->oTimer); + sync_object_init_field(o->parentObj, o->oIntangibleTimer); + sync_object_init_field(o->parentObj, o->oInteractStatus); + sync_object_init_field(o->parentObj, o->header.gfx.scale[0]); + sync_object_init_field(o->parentObj, o->header.gfx.scale[1]); + sync_object_init_field(o->parentObj, o->header.gfx.scale[2]); } void bhv_bowser_tail_anchor_loop(void) { @@ -112,10 +112,10 @@ void bhv_bowser_flame_spawn_loop(void) { void bhv_bowser_body_anchor_init(void) { if (!o->parentObj) { mark_obj_for_deletion(o); return; } - sync_object_init_field(o->parentObj, &o->oInteractType); - sync_object_init_field(o->parentObj, &o->oInteractStatus); - sync_object_init_field(o->parentObj, &o->oIntangibleTimer); - sync_object_init_field(o->parentObj, &o->oDamageOrCoinValue); + sync_object_init_field(o->parentObj, o->oInteractType); + sync_object_init_field(o->parentObj, o->oInteractStatus); + sync_object_init_field(o->parentObj, o->oIntangibleTimer); + sync_object_init_field(o->parentObj, o->oDamageOrCoinValue); } void bhv_bowser_body_anchor_loop(void) { @@ -1077,12 +1077,12 @@ void bowser_act_dead(void) { void bhv_tilting_bowser_lava_platform_init(void) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAngleVelPitch); - sync_object_init_field(o, &o->oAngleVelRoll); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oFaceAngleRoll); - sync_object_init_field(o, &o->oMoveAnglePitch); - sync_object_init_field(o, &o->oMoveAngleRoll); + sync_object_init_field(o, o->oAngleVelPitch); + sync_object_init_field(o, o->oAngleVelRoll); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oFaceAngleRoll); + sync_object_init_field(o, o->oMoveAnglePitch); + sync_object_init_field(o, o->oMoveAngleRoll); } void bowser_tilt_platform(struct Object* platform, s16 a1) { @@ -1445,13 +1445,13 @@ void bhv_bowser_init(void) { so->ignore_if_true = bhv_bowser_ignore_if_true; so->on_received_post = bhv_bowser_on_received_post; so->fullObjectSync = TRUE; - sync_object_init_field_with_size(o, &o->header.gfx.node.flags, 16); - sync_object_init_field_with_size(o, &o->header.gfx.animInfo.animFrame, 16); - sync_object_init_field_with_size(o, &bowserCutsceneGlobalIndex, 8); - sync_object_init_field(o, &networkBowserAnimationIndex); - sync_object_init_field(o, &o->header.gfx.scale[0]); - sync_object_init_field(o, &o->header.gfx.scale[1]); - sync_object_init_field(o, &o->header.gfx.scale[2]); + sync_object_init_field(o, o->header.gfx.node.flags); + sync_object_init_field(o, o->header.gfx.animInfo.animFrame); + sync_object_init_field(o, bowserCutsceneGlobalIndex); + sync_object_init_field(o, networkBowserAnimationIndex); + sync_object_init_field(o, o->header.gfx.scale[0]); + sync_object_init_field(o, o->header.gfx.scale[1]); + sync_object_init_field(o, o->header.gfx.scale[2]); } } } @@ -1692,9 +1692,9 @@ void bhv_falling_bowser_platform_loop(void) { struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { so->ignore_if_true = bhv_falling_bowser_platform_ignore_if_true; - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); } } diff --git a/src/game/behaviors/bowser_bomb.inc.c b/src/game/behaviors/bowser_bomb.inc.c index 5acd83ae4..18427e6c5 100644 --- a/src/game/behaviors/bowser_bomb.inc.c +++ b/src/game/behaviors/bowser_bomb.inc.c @@ -33,7 +33,7 @@ void bhv_bowser_bomb_loop(void) { struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { so->syncDeathEvent = FALSE; - sync_object_init_field(o, &networkBowserBombHit); + sync_object_init_field(o, networkBowserBombHit); } } diff --git a/src/game/behaviors/bowser_puzzle_piece.inc.c b/src/game/behaviors/bowser_puzzle_piece.inc.c index 7d57014f8..85474573b 100644 --- a/src/game/behaviors/bowser_puzzle_piece.inc.c +++ b/src/game/behaviors/bowser_puzzle_piece.inc.c @@ -132,9 +132,9 @@ void bhv_lll_bowser_puzzle_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oBowserPuzzleCompletionFlags); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oBowserPuzzleCompletionFlags); } } diff --git a/src/game/behaviors/breakable_box_small.inc.c b/src/game/behaviors/breakable_box_small.inc.c index bcb132a85..26066e57f 100644 --- a/src/game/behaviors/breakable_box_small.inc.c +++ b/src/game/behaviors/breakable_box_small.inc.c @@ -21,10 +21,10 @@ void bhv_breakable_box_small_init(void) { o->oAnimState = 1; o->activeFlags |= ACTIVE_FLAG_UNK9; sync_object_init(o, 1000.0f); - sync_object_init_field(o, &o->oBreakableBoxSmallReleased); - sync_object_init_field(o, &o->oBreakableBoxSmallFramesSinceReleased); - sync_object_init_field(o, &o->oAnimState); - sync_object_init_field(o, &o->oFlags); + sync_object_init_field(o, o->oBreakableBoxSmallReleased); + sync_object_init_field(o, o->oBreakableBoxSmallFramesSinceReleased); + sync_object_init_field(o, o->oAnimState); + sync_object_init_field(o, o->oFlags); } void small_breakable_box_spawn_dust(void) { diff --git a/src/game/behaviors/breakable_wall.inc.c b/src/game/behaviors/breakable_wall.inc.c index ba116266e..2441d9cd1 100644 --- a/src/game/behaviors/breakable_wall.inc.c +++ b/src/game/behaviors/breakable_wall.inc.c @@ -3,7 +3,7 @@ void bhv_wf_breakable_wall_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oBreakableWallForce); + sync_object_init_field(o, o->oBreakableWallForce); } if (o->oBreakableWallForce || gMarioStates[0].action == ACT_SHOT_FROM_CANNON) { diff --git a/src/game/behaviors/bub.inc.c b/src/game/behaviors/bub.inc.c index 5e165e534..d4875e040 100644 --- a/src/game/behaviors/bub.inc.c +++ b/src/game/behaviors/bub.inc.c @@ -121,11 +121,11 @@ void bhv_bub_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, 4000.0f); if (so) { - sync_object_init_field(o, &o->oCheepCheepUnkF4); - sync_object_init_field(o, &o->oCheepCheepUnkF8); - sync_object_init_field(o, &o->oCheepCheepUnkFC); - sync_object_init_field(o, &o->oCheepCheepUnk104); - sync_object_init_field(o, &o->oCheepCheepUnk108); + sync_object_init_field(o, o->oCheepCheepUnkF4); + sync_object_init_field(o, o->oCheepCheepUnkF8); + sync_object_init_field(o, o->oCheepCheepUnkFC); + sync_object_init_field(o, o->oCheepCheepUnk104); + sync_object_init_field(o, o->oCheepCheepUnk108); } } diff --git a/src/game/behaviors/bubba.inc.c b/src/game/behaviors/bubba.inc.c index 8401ff249..2b2e2f5c2 100644 --- a/src/game/behaviors/bubba.inc.c +++ b/src/game/behaviors/bubba.inc.c @@ -111,17 +111,17 @@ void bubba_act_1(void) { void bhv_bubba_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oBubbaUnkF4); - sync_object_init_field(o, &o->oBubbaUnkF8); - sync_object_init_field(o, &o->oBubbaUnkFC); - sync_object_init_field(o, &o->oBubbaUnk100); - sync_object_init_field(o, &o->oBubbaUnk104); - sync_object_init_field(o, &o->oBubbaUnk108); - sync_object_init_field(o, &o->oBubbaUnk10C); - sync_object_init_field(o, &o->oBubbaUnk1AC); - sync_object_init_field(o, &o->oBubbaUnk1B0); - sync_object_init_field(o, &o->oAnimState); - sync_object_init_field(o, &o->oMoveAnglePitch); + sync_object_init_field(o, o->oBubbaUnkF4); + sync_object_init_field(o, o->oBubbaUnkF8); + sync_object_init_field(o, o->oBubbaUnkFC); + sync_object_init_field(o, o->oBubbaUnk100); + sync_object_init_field(o, o->oBubbaUnk104); + sync_object_init_field(o, o->oBubbaUnk108); + sync_object_init_field(o, o->oBubbaUnk10C); + sync_object_init_field(o, o->oBubbaUnk1AC); + sync_object_init_field(o, o->oBubbaUnk1B0); + sync_object_init_field(o, o->oAnimState); + sync_object_init_field(o, o->oMoveAnglePitch); } struct MarioState* marioState = nearest_mario_state_to_object(o); diff --git a/src/game/behaviors/bullet_bill.inc.c b/src/game/behaviors/bullet_bill.inc.c index 8260f1fa5..767a3e032 100644 --- a/src/game/behaviors/bullet_bill.inc.c +++ b/src/game/behaviors/bullet_bill.inc.c @@ -9,9 +9,9 @@ void bhv_bullet_bill_init(void) { o->oBulletBillInitialMoveYaw = o->oMoveAngleYaw; if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oFaceAngleRoll); - sync_object_init_field(o, &o->oForwardVel); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oFaceAngleRoll); + sync_object_init_field(o, o->oForwardVel); } } diff --git a/src/game/behaviors/bully.inc.c b/src/game/behaviors/bully.inc.c index d174c1d3a..d0f702e9e 100644 --- a/src/game/behaviors/bully.inc.c +++ b/src/game/behaviors/bully.inc.c @@ -40,14 +40,14 @@ static void bhv_bully_override_ownership(u8* shouldOverride, u8* shouldOwn) { static void bhv_bully_network_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { - sync_object_init_field(o, &o->oFlags); - sync_object_init_field(o, &o->oBullyKBTimerAndMinionKOCounter); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oBullyPrevX); - sync_object_init_field(o, &o->oBullyPrevY); - sync_object_init_field(o, &o->oBullyPrevZ); - sync_object_init_field(o, &o->oBullyMarioCollisionAngle); - sync_object_init_field(o, &o->oBullyLastNetworkPlayerIndex); + sync_object_init_field(o, o->oFlags); + sync_object_init_field(o, o->oBullyKBTimerAndMinionKOCounter); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oBullyPrevX); + sync_object_init_field(o, o->oBullyPrevY); + sync_object_init_field(o, o->oBullyPrevZ); + sync_object_init_field(o, o->oBullyMarioCollisionAngle); + sync_object_init_field(o, o->oBullyLastNetworkPlayerIndex); so->syncDeathEvent = FALSE; so->ignore_if_true = bhv_bully_ignore_if_true; so->override_ownership = bhv_bully_override_ownership; diff --git a/src/game/behaviors/camera_lakitu.inc.c b/src/game/behaviors/camera_lakitu.inc.c index 51eea7490..702d36216 100644 --- a/src/game/behaviors/camera_lakitu.inc.c +++ b/src/game/behaviors/camera_lakitu.inc.c @@ -45,15 +45,15 @@ void bhv_camera_lakitu_init(void) { so->ignore_if_true = bhv_camera_lakitu_ignore_if_true; so->override_ownership = bhv_camera_lakitu_override_ownership; so->on_received_post = bhv_camera_lakitu_on_received_post; - sync_object_init_field(o, &o->oAngleVelPitch); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oCameraLakituBlinkTimer); - sync_object_init_field(o, &o->oCameraLakituSpeed); - sync_object_init_field(o, &o->oCameraLakituCircleRadius); - sync_object_init_field(o, &o->oCameraLakituFinishedDialog); - sync_object_init_field(o, &o->oCameraLakituPitchVel); + sync_object_init_field(o, o->oAngleVelPitch); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oCameraLakituBlinkTimer); + sync_object_init_field(o, o->oCameraLakituSpeed); + sync_object_init_field(o, o->oCameraLakituCircleRadius); + sync_object_init_field(o, o->oCameraLakituFinishedDialog); + sync_object_init_field(o, o->oCameraLakituPitchVel); #ifndef VERSION_JP - sync_object_init_field(o, &o->oCameraLakituUnk104); + sync_object_init_field(o, o->oCameraLakituUnk104); #endif } } diff --git a/src/game/behaviors/cannon.inc.c b/src/game/behaviors/cannon.inc.c index 1f147c50f..9450aac0c 100644 --- a/src/game/behaviors/cannon.inc.c +++ b/src/game/behaviors/cannon.inc.c @@ -218,16 +218,16 @@ void bhv_cannon_base_loop(void) { if (so) { so->on_received_post = cannon_on_received_post; so->override_ownership = bhv_cannon_override_ownership; - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); - sync_object_init_field(o, &o->oCannonUnk10C); - sync_object_init_field(o, &o->oCannonUnk10C); - sync_object_init_field(o, &o->oCannonUnkF8); - sync_object_init_field(o, &o->oCannonUnkF4); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); + sync_object_init_field(o, o->oCannonUnk10C); + sync_object_init_field(o, o->oCannonUnk10C); + sync_object_init_field(o, o->oCannonUnkF8); + sync_object_init_field(o, o->oCannonUnkF4); } } diff --git a/src/game/behaviors/capswitch.inc.c b/src/game/behaviors/capswitch.inc.c index ead66868c..9fada0a72 100644 --- a/src/game/behaviors/capswitch.inc.c +++ b/src/game/behaviors/capswitch.inc.c @@ -62,7 +62,7 @@ void (*sCapSwitchActions[])(void) = { cap_switch_act_0, cap_switch_act_1, void bhv_cap_switch_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &capSwitchForcePress); + sync_object_init_field(o, capSwitchForcePress); } CUR_OBJ_CALL_ACTION_FUNCTION(sCapSwitchActions); diff --git a/src/game/behaviors/chain_chomp.inc.c b/src/game/behaviors/chain_chomp.inc.c index ac4ee0fa3..d89b324cf 100644 --- a/src/game/behaviors/chain_chomp.inc.c +++ b/src/game/behaviors/chain_chomp.inc.c @@ -482,8 +482,8 @@ void bhv_chain_chomp_update(void) { struct SyncObject* so = sync_object_init(o, 1000.0f); if (so) { so->syncDeathEvent = FALSE; - sync_object_init_field(o, &o->oChainChompUnk104); - sync_object_init_field_with_size(o, &o->header.gfx.animInfo.animFrame, 16); + sync_object_init_field(o, o->oChainChompUnk104); + sync_object_init_field(o, o->header.gfx.animInfo.animFrame); } } @@ -506,12 +506,12 @@ void bhv_chain_chomp_update(void) { void bhv_wooden_post_update(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oBehParams); - sync_object_init_field(o, &o->oWoodenPostMarioPounding); - sync_object_init_field(o, &o->oWoodenPostOffsetY); - sync_object_init_field(o, &o->oWoodenPostSpeedY); - sync_object_init_field(o, &o->oWoodenPostTotalMarioAngle); - sync_object_init_field(o, &o->oTimer); + sync_object_init_field(o, o->oBehParams); + sync_object_init_field(o, o->oWoodenPostMarioPounding); + sync_object_init_field(o, o->oWoodenPostOffsetY); + sync_object_init_field(o, o->oWoodenPostSpeedY); + sync_object_init_field(o, o->oWoodenPostTotalMarioAngle); + sync_object_init_field(o, o->oTimer); } // When ground pounded by mario, drop by -45 + -20 diff --git a/src/game/behaviors/chuckya.inc.c b/src/game/behaviors/chuckya.inc.c index eb5a91c6c..9b1a25ae8 100644 --- a/src/game/behaviors/chuckya.inc.c +++ b/src/game/behaviors/chuckya.inc.c @@ -227,11 +227,11 @@ void bhv_chuckya_loop(void) { if (so != NULL) { so->override_ownership = bhv_chuckya_override_ownership; so->ignore_if_true = bhv_chuckya_ignore_if_true; - sync_object_init_field(o, &o->oChuckyaUnk88); - sync_object_init_field(o, &o->oChuckyaUnkF8); - sync_object_init_field(o, &o->oChuckyaUnkFC); - sync_object_init_field(o, &o->oChuckyaUnk100); - sync_object_init_field(o, &o->oFaceAnglePitch); + sync_object_init_field(o, o->oChuckyaUnk88); + sync_object_init_field(o, o->oChuckyaUnkF8); + sync_object_init_field(o, o->oChuckyaUnkFC); + sync_object_init_field(o, o->oChuckyaUnk100); + sync_object_init_field(o, o->oFaceAnglePitch); } } diff --git a/src/game/behaviors/clam.inc.c b/src/game/behaviors/clam.inc.c index 297be2237..32f571a28 100644 --- a/src/game/behaviors/clam.inc.c +++ b/src/game/behaviors/clam.inc.c @@ -58,9 +58,9 @@ void clam_act_1(void) { void bhv_clam_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oClamUnkF4); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oClamUnkF4); } o->header.gfx.scale[1] = 1.5f; diff --git a/src/game/behaviors/cloud.inc.c b/src/game/behaviors/cloud.inc.c index fb31ca3e5..f34c63dd0 100644 --- a/src/game/behaviors/cloud.inc.c +++ b/src/game/behaviors/cloud.inc.c @@ -58,12 +58,12 @@ static void cloud_act_fwoosh_hidden(void) { static void cloud_fwoosh_update(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->header.gfx.scale[0]); - sync_object_init_field(o, &o->oCloudCenterX); - sync_object_init_field(o, &o->oCloudCenterY); - sync_object_init_field(o, &o->oCloudBlowing); - sync_object_init_field(o, &o->oCloudGrowSpeed); - sync_object_init_field(o, &o->oCloudFwooshMovementRadius); + sync_object_init_field(o, o->header.gfx.scale[0]); + sync_object_init_field(o, o->oCloudCenterX); + sync_object_init_field(o, o->oCloudCenterY); + sync_object_init_field(o, o->oCloudBlowing); + sync_object_init_field(o, o->oCloudGrowSpeed); + sync_object_init_field(o, o->oCloudFwooshMovementRadius); } struct Object* player = nearest_player_to_object(o); diff --git a/src/game/behaviors/controllable_platform.inc.c b/src/game/behaviors/controllable_platform.inc.c index 11fcc00aa..e1b8583ff 100644 --- a/src/game/behaviors/controllable_platform.inc.c +++ b/src/game/behaviors/controllable_platform.inc.c @@ -85,30 +85,30 @@ void bhv_controllable_platform_init(void) { struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so != NULL) { so->on_received_post = bhv_controllable_platform_on_received_post; - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); - sync_object_init_field(o, &o->oVelX); - sync_object_init_field(o, &o->oVelY); - sync_object_init_field(o, &o->oVelZ); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field_with_size(o, &o->activeFlags, 16); - sync_object_init_field_with_size(o, &D_80331694, 8); - sync_object_init_field_with_size(o, &o->header.gfx.node.flags, 16); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); + sync_object_init_field(o, o->oVelX); + sync_object_init_field(o, o->oVelY); + sync_object_init_field(o, o->oVelZ); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->activeFlags); + sync_object_init_field(o, D_80331694); + sync_object_init_field(o, o->header.gfx.node.flags); - sync_object_init_field(o, &o->oControllablePlatformUnkF8); - sync_object_init_field(o, &o->oControllablePlatformUnkFC); - sync_object_init_field(o, &o->oControllablePlatformUnk100); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oFaceAngleRoll); + sync_object_init_field(o, o->oControllablePlatformUnkF8); + sync_object_init_field(o, o->oControllablePlatformUnkFC); + sync_object_init_field(o, o->oControllablePlatformUnk100); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oFaceAngleRoll); for (s32 i = 0; i < 4; i++) { if (controllablePlatformSubs[i] == NULL) { continue; } - sync_object_init_field(o, &controllablePlatformSubs[i]->oAction); - sync_object_init_field(o, &controllablePlatformSubs[i]->oPrevAction); - sync_object_init_field(o, &controllablePlatformSubs[i]->oTimer); - sync_object_init_field(o, &controllablePlatformSubs[i]->oParentRelativePosY); + sync_object_init_field(o, controllablePlatformSubs[i]->oAction); + sync_object_init_field(o, controllablePlatformSubs[i]->oPrevAction); + sync_object_init_field(o, controllablePlatformSubs[i]->oTimer); + sync_object_init_field(o, controllablePlatformSubs[i]->oParentRelativePosY); } } } diff --git a/src/game/behaviors/donut_platform.inc.c b/src/game/behaviors/donut_platform.inc.c index 7e13bc126..10981196a 100644 --- a/src/game/behaviors/donut_platform.inc.c +++ b/src/game/behaviors/donut_platform.inc.c @@ -31,8 +31,8 @@ void bhv_donut_platform_spawner_update(void) { void bhv_donut_platform_update(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oGravity); - sync_object_init_field(o, &o->oIntangibleTimer); + sync_object_init_field(o, o->oGravity); + sync_object_init_field(o, o->oIntangibleTimer); } struct Object* player = nearest_player_to_object(o); diff --git a/src/game/behaviors/dorrie.inc.c b/src/game/behaviors/dorrie.inc.c index 5b88ff723..3625267db 100644 --- a/src/game/behaviors/dorrie.inc.c +++ b/src/game/behaviors/dorrie.inc.c @@ -167,12 +167,12 @@ void bhv_dorrie_update(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->ignore_if_true = bhv_dorrie_ignore_if_true; - sync_object_init_field(o, &o->oDorrieOffsetY); - sync_object_init_field(o, &o->oDorrieVelY); - sync_object_init_field(o, &o->oDorrieYawVel); - sync_object_init_field(o, &o->oDorrieLiftingMario); - sync_object_init_field(o, &o->oDorrieNeckAngle); - sync_object_init_field(o, &o->oAngleVelYaw); + sync_object_init_field(o, o->oDorrieOffsetY); + sync_object_init_field(o, o->oDorrieVelY); + sync_object_init_field(o, o->oDorrieYawVel); + sync_object_init_field(o, o->oDorrieLiftingMario); + sync_object_init_field(o, o->oDorrieNeckAngle); + sync_object_init_field(o, o->oAngleVelYaw); } } diff --git a/src/game/behaviors/drawbridge.inc.c b/src/game/behaviors/drawbridge.inc.c index 9b62c1beb..61c6019e2 100644 --- a/src/game/behaviors/drawbridge.inc.c +++ b/src/game/behaviors/drawbridge.inc.c @@ -21,10 +21,10 @@ void bhv_lll_drawbridge_spawner_init(void) { sync_object_init(o, 3000.0f); for (s32 i = 0; i < 2; i++) { if (drawbridge[i] == NULL) { continue; } - sync_object_init_field(o, &drawbridge[i]->oFaceAngleRoll); - sync_object_init_field(o, &drawbridge[i]->oAction); - sync_object_init_field(o, &drawbridge[i]->oPrevAction); - sync_object_init_field(o, &drawbridge[i]->oTimer); + sync_object_init_field(o, drawbridge[i]->oFaceAngleRoll); + sync_object_init_field(o, drawbridge[i]->oAction); + sync_object_init_field(o, drawbridge[i]->oPrevAction); + sync_object_init_field(o, drawbridge[i]->oTimer); } } diff --git a/src/game/behaviors/elevator.inc.c b/src/game/behaviors/elevator.inc.c index b0302e6b4..47190e840 100644 --- a/src/game/behaviors/elevator.inc.c +++ b/src/game/behaviors/elevator.inc.c @@ -136,9 +136,9 @@ void bhv_elevator_init(void) { } sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oVelY); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oVelY); } void (*sElevatorActions[])(void) = { elevator_act_0, elevator_act_1, elevator_act_2, elevator_act_3, diff --git a/src/game/behaviors/enemy_lakitu.inc.c b/src/game/behaviors/enemy_lakitu.inc.c index 0a70d676f..cfaf81760 100644 --- a/src/game/behaviors/enemy_lakitu.inc.c +++ b/src/game/behaviors/enemy_lakitu.inc.c @@ -245,9 +245,9 @@ void bhv_enemy_lakitu_update(void) { // PARTIAL_UPDATE if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oEnemyLakituBlinkTimer); - sync_object_init_field(o, &o->oEnemyLakituSpinyCooldown); - sync_object_init_field(o, &o->oEnemyLakituFaceForwardCountdown); + sync_object_init_field(o, o->oEnemyLakituBlinkTimer); + sync_object_init_field(o, o->oEnemyLakituSpinyCooldown); + sync_object_init_field(o, o->oEnemyLakituFaceForwardCountdown); } treat_far_home_as_mario(2000.0f, NULL, NULL); diff --git a/src/game/behaviors/exclamation_box.inc.c b/src/game/behaviors/exclamation_box.inc.c index 2beff18ab..c90bc48a6 100644 --- a/src/game/behaviors/exclamation_box.inc.c +++ b/src/game/behaviors/exclamation_box.inc.c @@ -187,8 +187,8 @@ void bhv_exclamation_box_init(void) { struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { so->syncDeathEvent = FALSE; - sync_object_init_field(o, &o->oExclamationBoxForce); - sync_object_init_field(o, &o->areaTimer); + sync_object_init_field(o, o->oExclamationBoxForce); + sync_object_init_field(o, o->areaTimer); } o->areaTimerType = AREA_TIMER_TYPE_MAXIMUM; diff --git a/src/game/behaviors/express_elevator.inc.c b/src/game/behaviors/express_elevator.inc.c index 406d07175..34268bf68 100644 --- a/src/game/behaviors/express_elevator.inc.c +++ b/src/game/behaviors/express_elevator.inc.c @@ -3,11 +3,11 @@ void bhv_wdw_express_elevator_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oVelY); - sync_object_init_field(o, &o->oPosY); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oVelY); + sync_object_init_field(o, o->oPosY); } o->oVelY = 0.0f; diff --git a/src/game/behaviors/eyerok.inc.c b/src/game/behaviors/eyerok.inc.c index fb3523fbe..60bbb14a1 100644 --- a/src/game/behaviors/eyerok.inc.c +++ b/src/game/behaviors/eyerok.inc.c @@ -79,34 +79,34 @@ void bhv_eyerok_boss_init(void) { so->minUpdateRate = 1.0f; so->maxUpdateRate = 1.0f; so->syncDeathEvent = FALSE; - sync_object_init_field(o, &o->oEyerokBossNumHands); - sync_object_init_field(o, &o->oEyerokBossUnkFC); - sync_object_init_field(o, &o->oEyerokBossActiveHand); - sync_object_init_field(o, &o->oEyerokBossUnk104); - sync_object_init_field(o, &o->oEyerokBossUnk108); - sync_object_init_field(o, &o->oEyerokBossUnk10C); - sync_object_init_field(o, &o->oEyerokBossUnk110); - sync_object_init_field(o, &o->oEyerokBossUnk1AC); + sync_object_init_field(o, o->oEyerokBossNumHands); + sync_object_init_field(o, o->oEyerokBossUnkFC); + sync_object_init_field(o, o->oEyerokBossActiveHand); + sync_object_init_field(o, o->oEyerokBossUnk104); + sync_object_init_field(o, o->oEyerokBossUnk108); + sync_object_init_field(o, o->oEyerokBossUnk10C); + sync_object_init_field(o, o->oEyerokBossUnk110); + sync_object_init_field(o, o->oEyerokBossUnk1AC); for (s32 i = 0; i < 2; i++) { - sync_object_init_field(o, &hands[i]->oPosX); - sync_object_init_field(o, &hands[i]->oPosY); - sync_object_init_field(o, &hands[i]->oPosZ); - sync_object_init_field(o, &hands[i]->oVelX); - sync_object_init_field(o, &hands[i]->oVelY); - sync_object_init_field(o, &hands[i]->oVelZ); - sync_object_init_field(o, &hands[i]->oForwardVel); - sync_object_init_field(o, &hands[i]->oAction); - sync_object_init_field(o, &hands[i]->oPrevAction); - sync_object_init_field(o, &hands[i]->oTimer); - sync_object_init_field(o, &hands[i]->oHealth); - sync_object_init_field(o, &hands[i]->oEyerokHandWakeUpTimer); - sync_object_init_field(o, &hands[i]->oEyerokReceivedAttack); - sync_object_init_field(o, &hands[i]->oEyerokHandUnkFC); - sync_object_init_field(o, &hands[i]->oEyerokHandUnk100); - sync_object_init_field(o, &hands[i]->oFaceAngleYaw); - sync_object_init_field(o, &hands[i]->oMoveAngleYaw); - sync_object_init_field(o, &hands[i]->oGravity); - sync_object_init_field(o, &hands[i]->oAnimState); + sync_object_init_field(o, hands[i]->oPosX); + sync_object_init_field(o, hands[i]->oPosY); + sync_object_init_field(o, hands[i]->oPosZ); + sync_object_init_field(o, hands[i]->oVelX); + sync_object_init_field(o, hands[i]->oVelY); + sync_object_init_field(o, hands[i]->oVelZ); + sync_object_init_field(o, hands[i]->oForwardVel); + sync_object_init_field(o, hands[i]->oAction); + sync_object_init_field(o, hands[i]->oPrevAction); + sync_object_init_field(o, hands[i]->oTimer); + sync_object_init_field(o, hands[i]->oHealth); + sync_object_init_field(o, hands[i]->oEyerokHandWakeUpTimer); + sync_object_init_field(o, hands[i]->oEyerokReceivedAttack); + sync_object_init_field(o, hands[i]->oEyerokHandUnkFC); + sync_object_init_field(o, hands[i]->oEyerokHandUnk100); + sync_object_init_field(o, hands[i]->oFaceAngleYaw); + sync_object_init_field(o, hands[i]->oMoveAngleYaw); + sync_object_init_field(o, hands[i]->oGravity); + sync_object_init_field(o, hands[i]->oAnimState); } } diff --git a/src/game/behaviors/falling_rising_platform.inc.c b/src/game/behaviors/falling_rising_platform.inc.c index eebca7d79..098960145 100644 --- a/src/game/behaviors/falling_rising_platform.inc.c +++ b/src/game/behaviors/falling_rising_platform.inc.c @@ -5,8 +5,8 @@ void bhv_squishable_platform_loop(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oPlatformTimer); - sync_object_init_field(o, &o->header.gfx.scale[1]); + sync_object_init_field(o, o->oPlatformTimer); + sync_object_init_field(o, o->header.gfx.scale[1]); } } @@ -23,7 +23,7 @@ void bhv_bitfs_sinking_platform_loop(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oPlatformTimer); + sync_object_init_field(o, o->oPlatformTimer); } } @@ -43,7 +43,7 @@ void bhv_bitfs_sinking_cage_platform_loop(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oPlatformTimer); + sync_object_init_field(o, o->oPlatformTimer); } } diff --git a/src/game/behaviors/ferris_wheel.inc.c b/src/game/behaviors/ferris_wheel.inc.c index 30928da03..a7b4adb7d 100644 --- a/src/game/behaviors/ferris_wheel.inc.c +++ b/src/game/behaviors/ferris_wheel.inc.c @@ -52,7 +52,7 @@ void bhv_ferris_wheel_axle_init(void) { if (so) { so->hasStandardFields = FALSE; so->maxUpdateRate = 5.0f; - sync_object_init_field(o, &o->oFaceAngleRoll); + sync_object_init_field(o, o->oFaceAngleRoll); } } @@ -61,9 +61,9 @@ void bhv_ferris_wheel_platform_init(void) { if (so) { so->hasStandardFields = FALSE; so->maxUpdateRate = 5.0f; - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); } } diff --git a/src/game/behaviors/fire_piranha_plant.inc.c b/src/game/behaviors/fire_piranha_plant.inc.c index c98ffab89..049667f3e 100644 --- a/src/game/behaviors/fire_piranha_plant.inc.c +++ b/src/game/behaviors/fire_piranha_plant.inc.c @@ -46,8 +46,8 @@ void bhv_fire_piranha_plant_init(void) { sNumActiveFirePiranhaPlants = sNumKilledFirePiranhaPlants = 0; sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &sNumActiveFirePiranhaPlants); - sync_object_init_field(o, &sNumKilledFirePiranhaPlants); + sync_object_init_field(o, sNumActiveFirePiranhaPlants); + sync_object_init_field(o, sNumKilledFirePiranhaPlants); } static void fire_piranha_plant_act_hide(void) { diff --git a/src/game/behaviors/fire_spitter.inc.c b/src/game/behaviors/fire_spitter.inc.c index b6e2ff9fd..1afb63580 100644 --- a/src/game/behaviors/fire_spitter.inc.c +++ b/src/game/behaviors/fire_spitter.inc.c @@ -49,13 +49,13 @@ void bhv_fire_spitter_update(void) { struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { so->on_received_post = bhv_fire_spitter_on_received_post; - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oFireSpitterScaleVel); - sync_object_init_field(o, &o->header.gfx.scale[0]); - sync_object_init_field(o, &o->header.gfx.scale[1]); - sync_object_init_field(o, &o->header.gfx.scale[2]); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oFireSpitterScaleVel); + sync_object_init_field(o, o->header.gfx.scale[0]); + sync_object_init_field(o, o->header.gfx.scale[1]); + sync_object_init_field(o, o->header.gfx.scale[2]); } } diff --git a/src/game/behaviors/flamethrower.inc.c b/src/game/behaviors/flamethrower.inc.c index 7dd48aa59..b69ecb236 100644 --- a/src/game/behaviors/flamethrower.inc.c +++ b/src/game/behaviors/flamethrower.inc.c @@ -36,9 +36,9 @@ void bhv_flamethrower_flame_loop(void) { void bhv_flamethrower_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oFlameThowerUnk110); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oFlameThowerUnk110); } struct MarioState* marioState = nearest_mario_state_to_object(o); struct Object* player = marioState ? marioState->marioObj : NULL; diff --git a/src/game/behaviors/fly_guy.inc.c b/src/game/behaviors/fly_guy.inc.c index aaf336770..537b4c549 100644 --- a/src/game/behaviors/fly_guy.inc.c +++ b/src/game/behaviors/fly_guy.inc.c @@ -207,11 +207,11 @@ void bhv_fly_guy_update(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oFlyGuyOscTimer); - sync_object_init_field(o, &o->oFlyGuyLungeYDecel); - sync_object_init_field(o, &o->oFlyGuyLungeTargetPitch); - sync_object_init_field(o, &o->oFlyGuyTargetRoll); - sync_object_init_field(o, &o->oFlyGuyLungeTargetPitch); + sync_object_init_field(o, o->oFlyGuyOscTimer); + sync_object_init_field(o, o->oFlyGuyLungeYDecel); + sync_object_init_field(o, o->oFlyGuyLungeTargetPitch); + sync_object_init_field(o, o->oFlyGuyTargetRoll); + sync_object_init_field(o, o->oFlyGuyLungeTargetPitch); } if (!(o->activeFlags & ACTIVE_FLAG_IN_DIFFERENT_ROOM)) { diff --git a/src/game/behaviors/flying_bookend_switch.inc.c b/src/game/behaviors/flying_bookend_switch.inc.c index 9815b9ad1..e48acf338 100644 --- a/src/game/behaviors/flying_bookend_switch.inc.c +++ b/src/game/behaviors/flying_bookend_switch.inc.c @@ -279,13 +279,13 @@ void bhv_haunted_bookshelf_manager_loop(void) { so->syncDeathEvent = FALSE; so->override_ownership = bhv_haunted_bookshelf_manager_override_ownership; so->ignore_if_true = bhv_haunted_bookshelf_manager_ignore_if_true; - sync_object_init_field_with_size(o, &o->activeFlags, 16); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oBookSwitchManagerUnkF8); - sync_object_init_field(o, &o->oBookSwitchManagerUnkF4); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oForwardVel); + sync_object_init_field(o, o->activeFlags); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oBookSwitchManagerUnkF8); + sync_object_init_field(o, o->oBookSwitchManagerUnkF4); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oForwardVel); } } @@ -315,12 +315,12 @@ void bhv_book_switch_loop(void) { so->override_ownership = bhv_haunted_bookshelf_manager_override_ownership; so->ignore_if_true = bhv_haunted_bookshelf_manager_ignore_if_true; - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oBookSwitchUnkF4); - sync_object_init_field(o, &o->oIntangibleTimer); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosZ); - sync_object_init_field(o, &o->oTimer); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oBookSwitchUnkF4); + sync_object_init_field(o, o->oIntangibleTimer); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosZ); + sync_object_init_field(o, o->oTimer); } } diff --git a/src/game/behaviors/goomba.inc.c b/src/game/behaviors/goomba.inc.c index 7779f792f..209e1def7 100644 --- a/src/game/behaviors/goomba.inc.c +++ b/src/game/behaviors/goomba.inc.c @@ -117,8 +117,8 @@ void bhv_goomba_init(void) { o->oGravity = -8.0f / 3.0f * o->oGoombaScale; sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oGoombaTargetYaw); - sync_object_init_field(o, &o->oGoombaWalkTimer); + sync_object_init_field(o, o->oGoombaTargetYaw); + sync_object_init_field(o, o->oGoombaWalkTimer); } /** diff --git a/src/game/behaviors/grand_star.inc.c b/src/game/behaviors/grand_star.inc.c index 28ffe18a4..5b7ac0e40 100644 --- a/src/game/behaviors/grand_star.inc.c +++ b/src/game/behaviors/grand_star.inc.c @@ -26,27 +26,27 @@ void bhv_grand_star_init(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, 4000.0f); if (so) { - sync_object_init_field(o, &o->header.gfx.scale[0]); - sync_object_init_field(o, &o->header.gfx.scale[1]); - sync_object_init_field(o, &o->header.gfx.scale[2]); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oSubAction); - sync_object_init_field(o, &o->oInteractStatus); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oHomeX); - sync_object_init_field(o, &o->oHomeY); - sync_object_init_field(o, &o->oHomeZ); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); - sync_object_init_field(o, &o->oGravity); - sync_object_init_field(o, &o->oVelY); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oAngleVelYaw); - sync_object_init_field(o, &o->oMoveAngleYaw); - sync_object_init_field(o, &o->oFaceAngleYaw); - sync_object_init_field(o, &o->oGraphYOffset); + sync_object_init_field(o, o->header.gfx.scale[0]); + sync_object_init_field(o, o->header.gfx.scale[1]); + sync_object_init_field(o, o->header.gfx.scale[2]); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oSubAction); + sync_object_init_field(o, o->oInteractStatus); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oHomeX); + sync_object_init_field(o, o->oHomeY); + sync_object_init_field(o, o->oHomeZ); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); + sync_object_init_field(o, o->oGravity); + sync_object_init_field(o, o->oVelY); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oAngleVelYaw); + sync_object_init_field(o, o->oMoveAngleYaw); + sync_object_init_field(o, o->oFaceAngleYaw); + sync_object_init_field(o, o->oGraphYOffset); } } return; diff --git a/src/game/behaviors/haunted_chair.inc.c b/src/game/behaviors/haunted_chair.inc.c index 2cb77724d..57cc82dcc 100644 --- a/src/game/behaviors/haunted_chair.inc.c +++ b/src/game/behaviors/haunted_chair.inc.c @@ -24,15 +24,15 @@ void bhv_haunted_chair_init(void) { } sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oFaceAngleRoll); - sync_object_init_field(o, &o->oFaceAngleYaw); - sync_object_init_field(o, &o->oHauntedChairUnk104); - sync_object_init_field(o, &o->oHauntedChairUnkF4); - sync_object_init_field(o, &o->oHauntedChairUnkF8); - sync_object_init_field(o, &o->oHauntedChairUnkFC); - sync_object_init_field(o, &o->oMoveAnglePitch); - sync_object_init_field(o, &o->oMoveAngleYaw); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oFaceAngleRoll); + sync_object_init_field(o, o->oFaceAngleYaw); + sync_object_init_field(o, o->oHauntedChairUnk104); + sync_object_init_field(o, o->oHauntedChairUnkF4); + sync_object_init_field(o, o->oHauntedChairUnkF8); + sync_object_init_field(o, o->oHauntedChairUnkFC); + sync_object_init_field(o, o->oMoveAnglePitch); + sync_object_init_field(o, o->oMoveAngleYaw); } void haunted_chair_act_0(void) { diff --git a/src/game/behaviors/heave_ho.inc.c b/src/game/behaviors/heave_ho.inc.c index 62f27e81e..159676e8f 100644 --- a/src/game/behaviors/heave_ho.inc.c +++ b/src/game/behaviors/heave_ho.inc.c @@ -136,11 +136,11 @@ void bhv_heave_ho_loop(void) { if (so != NULL) { so->override_ownership = bhv_heave_ho_override_ownership; so->ignore_if_true = bhv_heave_ho_ignore_if_true; - sync_object_init_field(o, &o->oHeaveHoUnk88); - sync_object_init_field(o, &o->oHeaveHoUnkF4); - sync_object_init_field(o, &o->oInteractStatus); - sync_object_init_field(o, &o->oGraphYOffset); - sync_object_init_field(o, &o->oFaceAngleYaw); + sync_object_init_field(o, o->oHeaveHoUnk88); + sync_object_init_field(o, o->oHeaveHoUnkF4); + sync_object_init_field(o, o->oInteractStatus); + sync_object_init_field(o, o->oGraphYOffset); + sync_object_init_field(o, o->oFaceAngleYaw); } } diff --git a/src/game/behaviors/hidden_star.inc.c b/src/game/behaviors/hidden_star.inc.c index 9cbadffac..61a864436 100644 --- a/src/game/behaviors/hidden_star.inc.c +++ b/src/game/behaviors/hidden_star.inc.c @@ -23,12 +23,12 @@ void bhv_hidden_star_init(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oHiddenStarTriggerCounter); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); - sync_object_init_field(o, &o->oTimer); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oHiddenStarTriggerCounter); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); + sync_object_init_field(o, o->oTimer); } } } diff --git a/src/game/behaviors/hoot.inc.c b/src/game/behaviors/hoot.inc.c index 0e60ff6bb..8285f86b6 100644 --- a/src/game/behaviors/hoot.inc.c +++ b/src/game/behaviors/hoot.inc.c @@ -20,9 +20,9 @@ void bhv_hoot_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->ignore_if_true = bhv_hoot_ignore_if_true; - sync_object_init_field(o, &o->oHootAvailability); - sync_object_init_field(o, &o->oMoveAnglePitch); - sync_object_init_field_with_size(o, &o->header.gfx.animInfo.animFrame, 16); + sync_object_init_field(o, o->oHootAvailability); + sync_object_init_field(o, o->oMoveAnglePitch); + sync_object_init_field(o, o->header.gfx.animInfo.animFrame); } } diff --git a/src/game/behaviors/horizontal_grindel.inc.c b/src/game/behaviors/horizontal_grindel.inc.c index 838d5d758..e2f001de2 100644 --- a/src/game/behaviors/horizontal_grindel.inc.c +++ b/src/game/behaviors/horizontal_grindel.inc.c @@ -3,12 +3,12 @@ void bhv_horizontal_grindel_init(void) { o->oHorizontalGrindelTargetYaw = o->oMoveAngleYaw; sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oHorizontalGrindelOnGround); - sync_object_init_field(o, &o->oHorizontalGrindelTargetYaw); - sync_object_init_field(o, &o->oHorizontalGrindelDistToHome); - sync_object_init_field(o, &o->oMoveFlags); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oGravity); + sync_object_init_field(o, o->oHorizontalGrindelOnGround); + sync_object_init_field(o, o->oHorizontalGrindelTargetYaw); + sync_object_init_field(o, o->oHorizontalGrindelDistToHome); + sync_object_init_field(o, o->oMoveFlags); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oGravity); } void bhv_horizontal_grindel_update(void) { diff --git a/src/game/behaviors/jrb_ship.inc.c b/src/game/behaviors/jrb_ship.inc.c index 5c84b1b96..9500272dc 100644 --- a/src/game/behaviors/jrb_ship.inc.c +++ b/src/game/behaviors/jrb_ship.inc.c @@ -25,9 +25,9 @@ void bhv_ship_part_3_loop(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->maxUpdateRate = 5.0f; - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oFaceAngleRoll); - sync_object_init_field(o, &o->oShipPart3UnkF4); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oFaceAngleRoll); + sync_object_init_field(o, o->oShipPart3UnkF4); } } @@ -49,13 +49,13 @@ void bhv_jrb_sliding_box_loop(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->maxUpdateRate = 5.0f; - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oFaceAngleRoll); - sync_object_init_field(o, &o->oJrbSlidingBoxUnkF8); - sync_object_init_field(o, &o->oJrbSlidingBoxUnkFC); - sync_object_init_field(o, &o->oParentRelativePosX); - sync_object_init_field(o, &o->oParentRelativePosY); - sync_object_init_field(o, &o->oParentRelativePosZ); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oFaceAngleRoll); + sync_object_init_field(o, o->oJrbSlidingBoxUnkF8); + sync_object_init_field(o, o->oJrbSlidingBoxUnkFC); + sync_object_init_field(o, o->oParentRelativePosX); + sync_object_init_field(o, o->oParentRelativePosY); + sync_object_init_field(o, o->oParentRelativePosZ); } } diff --git a/src/game/behaviors/jumping_box.inc.c b/src/game/behaviors/jumping_box.inc.c index cee7b6fd6..4490b3b74 100644 --- a/src/game/behaviors/jumping_box.inc.c +++ b/src/game/behaviors/jumping_box.inc.c @@ -47,7 +47,7 @@ void jumping_box_free_update(void) { void bhv_jumping_box_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 500.0f); - sync_object_init_field(o, &o->oJumpingBoxUnkF4); + sync_object_init_field(o, o->oJumpingBoxUnkF4); } switch (o->oHeldState) { diff --git a/src/game/behaviors/kickable_board.inc.c b/src/game/behaviors/kickable_board.inc.c index 9ab23b777..c9a1812e0 100644 --- a/src/game/behaviors/kickable_board.inc.c +++ b/src/game/behaviors/kickable_board.inc.c @@ -29,14 +29,14 @@ void bhv_kickable_board_loop(void) { struct MarioState* marioState = nearest_mario_state_to_object(o); if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oAngleVelPitch); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oKickableBoardF4); - sync_object_init_field(o, &o->oKickableBoardF8); - sync_object_init_field(o, &o->oMoveAngleYaw); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oTimer); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oAngleVelPitch); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oKickableBoardF4); + sync_object_init_field(o, o->oKickableBoardF8); + sync_object_init_field(o, o->oMoveAngleYaw); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oTimer); } s32 sp24; switch (o->oAction) { diff --git a/src/game/behaviors/king_bobomb.inc.c b/src/game/behaviors/king_bobomb.inc.c index d3074d062..80945aca1 100644 --- a/src/game/behaviors/king_bobomb.inc.c +++ b/src/game/behaviors/king_bobomb.inc.c @@ -391,10 +391,10 @@ void bhv_king_bobomb_loop(void) { if (so) { so->override_ownership = bhv_king_bobomb_override_ownership; so->ignore_if_true = bhv_king_bobomb_ignore_if_true; - sync_object_init_field(o, &o->oKingBobombUnk88); - sync_object_init_field(o, &o->oFlags); - sync_object_init_field(o, &o->oHealth); - sync_object_init_field(o, &o->oInteractStatus); + sync_object_init_field(o, o->oKingBobombUnk88); + sync_object_init_field(o, o->oFlags); + sync_object_init_field(o, o->oHealth); + sync_object_init_field(o, o->oInteractStatus); } } diff --git a/src/game/behaviors/klepto.inc.c b/src/game/behaviors/klepto.inc.c index b99306799..27161e5ba 100644 --- a/src/game/behaviors/klepto.inc.c +++ b/src/game/behaviors/klepto.inc.c @@ -108,22 +108,22 @@ void bhv_klepto_init(void) { if (so) { so->on_received_pre = bhv_klepto_on_received_pre; so->on_received_post = bhv_klepto_on_received_post; - sync_object_init_field(o, &o->oAnimState); - sync_object_init_field(o, &o->oFlags); - sync_object_init_field(o, &o->oKleptoDistanceToTarget); - sync_object_init_field(o, &o->oKleptoUnkF8); - sync_object_init_field(o, &o->oKleptoUnkFC); - sync_object_init_field(o, &o->oKleptoSpeed); - sync_object_init_field(o, &o->oKleptoTimeUntilTargetChange); - sync_object_init_field(o, &o->oKleptoTargetNumber); - sync_object_init_field(o, &o->oKleptoUnk1B0); - sync_object_init_field(o, &o->oSoundStateID); - sync_object_init_field(o, &o->oHomeX); - sync_object_init_field(o, &o->oHomeY); - sync_object_init_field(o, &o->oHomeZ); - sync_object_init_field(o, &o->oMoveAnglePitch); - sync_object_init_field(o, &o->oGravity); - sync_object_init_field_with_size(o, &o->globalPlayerIndex, 8); + sync_object_init_field(o, o->oAnimState); + sync_object_init_field(o, o->oFlags); + sync_object_init_field(o, o->oKleptoDistanceToTarget); + sync_object_init_field(o, o->oKleptoUnkF8); + sync_object_init_field(o, o->oKleptoUnkFC); + sync_object_init_field(o, o->oKleptoSpeed); + sync_object_init_field(o, o->oKleptoTimeUntilTargetChange); + sync_object_init_field(o, o->oKleptoTargetNumber); + sync_object_init_field(o, o->oKleptoUnk1B0); + sync_object_init_field(o, o->oSoundStateID); + sync_object_init_field(o, o->oHomeX); + sync_object_init_field(o, o->oHomeY); + sync_object_init_field(o, o->oHomeZ); + sync_object_init_field(o, o->oMoveAnglePitch); + sync_object_init_field(o, o->oGravity); + sync_object_init_field(o, o->globalPlayerIndex); } } diff --git a/src/game/behaviors/koopa.inc.c b/src/game/behaviors/koopa.inc.c index e7d79b8cc..5b67aeece 100644 --- a/src/game/behaviors/koopa.inc.c +++ b/src/game/behaviors/koopa.inc.c @@ -126,28 +126,28 @@ void bhv_koopa_init(void) { so->on_received_post = bhv_koopa_the_quick_on_received_post; so->on_sent_pre = bhv_koopa_the_quick_on_sent_pre; so->override_ownership = bhv_koopa_the_quick_override_ownership; - sync_object_init_field(o, &koopaPathedStartWaypoint); - sync_object_init_field(o, &koopaPathedPrevWaypoint); - sync_object_init_field(o, &koopaShotFromCannon); - sync_object_init_field(o, &o->oPathedPrevWaypointFlags); - sync_object_init_field(o, &o->oPathedTargetPitch); - sync_object_init_field(o, &o->oPathedTargetYaw); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); - sync_object_init_field(o, &o->oVelX); - sync_object_init_field(o, &o->oVelY); - sync_object_init_field(o, &o->oVelZ); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oSubAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oKoopaAgility); - sync_object_init_field(o, &o->parentObj->oKoopaRaceEndpointRaceBegun); - sync_object_init_field(o, &o->parentObj->oKoopaRaceEndpointRaceStatus); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oMoveAngleYaw); - sync_object_init_field(o, &o->areaTimer); + sync_object_init_field(o, koopaPathedStartWaypoint); + sync_object_init_field(o, koopaPathedPrevWaypoint); + sync_object_init_field(o, koopaShotFromCannon); + sync_object_init_field(o, o->oPathedPrevWaypointFlags); + sync_object_init_field(o, o->oPathedTargetPitch); + sync_object_init_field(o, o->oPathedTargetYaw); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); + sync_object_init_field(o, o->oVelX); + sync_object_init_field(o, o->oVelY); + sync_object_init_field(o, o->oVelZ); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oSubAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oKoopaAgility); + sync_object_init_field(o, o->parentObj->oKoopaRaceEndpointRaceBegun); + sync_object_init_field(o, o->parentObj->oKoopaRaceEndpointRaceStatus); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oMoveAngleYaw); + sync_object_init_field(o, o->areaTimer); } o->areaTimerType = AREA_TIMER_TYPE_MAXIMUM; o->areaTimer = 0; @@ -156,10 +156,10 @@ void bhv_koopa_init(void) { } else { // normal koopa sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oKoopaTargetYaw); - sync_object_init_field(o, &o->oKoopaCountdown); - sync_object_init_field(o, &o->oKoopaMovementType); - sync_object_init_field(o, &o->oKoopaUnshelledTimeUntilTurn); + sync_object_init_field(o, o->oKoopaTargetYaw); + sync_object_init_field(o, o->oKoopaCountdown); + sync_object_init_field(o, o->oKoopaMovementType); + sync_object_init_field(o, o->oKoopaUnshelledTimeUntilTurn); } } diff --git a/src/game/behaviors/lll_floating_wood_piece.inc.c b/src/game/behaviors/lll_floating_wood_piece.inc.c index 95aa742ed..f80abe1aa 100644 --- a/src/game/behaviors/lll_floating_wood_piece.inc.c +++ b/src/game/behaviors/lll_floating_wood_piece.inc.c @@ -3,7 +3,7 @@ void bhv_lll_wood_piece_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 1000.0f); - sync_object_init_field(o, &o->oLllWoodPieceOscillationTimer); + sync_object_init_field(o, o->oLllWoodPieceOscillationTimer); } if (o->oTimer == 0) diff --git a/src/game/behaviors/lll_hexagonal_ring.inc.c b/src/game/behaviors/lll_hexagonal_ring.inc.c index f81abf4ba..4e2d3b968 100644 --- a/src/game/behaviors/lll_hexagonal_ring.inc.c +++ b/src/game/behaviors/lll_hexagonal_ring.inc.c @@ -19,7 +19,7 @@ void hexagonal_ring_spawn_flames(void) { void bhv_lll_rotating_hexagonal_ring_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oAngleVelYaw); + sync_object_init_field(o, o->oAngleVelYaw); } UNUSED s32 unused; o->oCollisionDistance = 4000.0f; diff --git a/src/game/behaviors/lll_octagonal_rotating_mesh.inc.c b/src/game/behaviors/lll_octagonal_rotating_mesh.inc.c index 58afca1d9..2c64ef4ea 100644 --- a/src/game/behaviors/lll_octagonal_rotating_mesh.inc.c +++ b/src/game/behaviors/lll_octagonal_rotating_mesh.inc.c @@ -63,10 +63,10 @@ s32 lll_octagonal_mesh_find_y_offset(s32 *a0, f32 *a1, s32 a2, s32 a3) { void bhv_lll_moving_octagonal_mesh_platform_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oHorizontalMovementUnkF8); - sync_object_init_field(o, &o->oHorizontalMovementUnkF4); - sync_object_init_field(o, &o->oHorizontalMovementUnk100); - sync_object_init_field(o, &o->oForwardVel); + sync_object_init_field(o, o->oHorizontalMovementUnkF8); + sync_object_init_field(o, o->oHorizontalMovementUnkF4); + sync_object_init_field(o, o->oHorizontalMovementUnk100); + sync_object_init_field(o, o->oForwardVel); } if (o->oAction == 0) { o->oHorizontalMovementUnkF8 = 0; diff --git a/src/game/behaviors/lll_rotating_hex_flame.inc.c b/src/game/behaviors/lll_rotating_hex_flame.inc.c index 41c103a85..a99ba269f 100644 --- a/src/game/behaviors/lll_rotating_hex_flame.inc.c +++ b/src/game/behaviors/lll_rotating_hex_flame.inc.c @@ -63,7 +63,7 @@ void (*sRotatingCwFireBarsActions[])(void) = { fire_bar_act_0, fire_bar_act_1, void bhv_lll_rotating_block_fire_bars_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oAngleVelYaw); + sync_object_init_field(o, o->oAngleVelYaw); } CUR_OBJ_CALL_ACTION_FUNCTION(sRotatingCwFireBarsActions); if (o->oBehParams2ndByte == 0) diff --git a/src/game/behaviors/lll_sinking_rectangle.inc.c b/src/game/behaviors/lll_sinking_rectangle.inc.c index 3c3f38a1c..ea7ceea6e 100644 --- a/src/game/behaviors/lll_sinking_rectangle.inc.c +++ b/src/game/behaviors/lll_sinking_rectangle.inc.c @@ -17,8 +17,8 @@ void sinking_rectangular_plat_actions(f32 a0, s32 a1) { void bhv_lll_sinking_rectangular_platform_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 1000.0f); - sync_object_init_field(o, &o->oLllWoodPieceOscillationTimer); - sync_object_init_field(o, &o->oFaceAnglePitch); + sync_object_init_field(o, o->oLllWoodPieceOscillationTimer); + sync_object_init_field(o, o->oFaceAnglePitch); } f32 sp1C = 0.4f; s32 sp18 = 0x100; @@ -33,7 +33,7 @@ void bhv_lll_sinking_rectangular_platform_loop(void) { void bhv_lll_sinking_square_platforms_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 1000.0f); - sync_object_init_field(o, &o->oLllWoodPieceOscillationTimer); + sync_object_init_field(o, o->oLllWoodPieceOscillationTimer); } f32 sp1C = 0.5f; s32 sp18 = 0x100; diff --git a/src/game/behaviors/lll_sinking_rock_block.inc.c b/src/game/behaviors/lll_sinking_rock_block.inc.c index a207c8dda..eacc1461c 100644 --- a/src/game/behaviors/lll_sinking_rock_block.inc.c +++ b/src/game/behaviors/lll_sinking_rock_block.inc.c @@ -3,8 +3,8 @@ void bhv_lll_sinking_rock_block_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 1000.0f); - sync_object_init_field(o, &o->oSinkWhenSteppedOnUnk104); - sync_object_init_field(o, &o->oGraphYOffset); + sync_object_init_field(o, o->oSinkWhenSteppedOnUnk104); + sync_object_init_field(o, o->oGraphYOffset); } lll_octagonal_mesh_find_y_offset(&o->oSinkWhenSteppedOnUnk104, &o->oSinkWhenSteppedOnUnk108, 124, -110); o->oGraphYOffset = 0.0f; diff --git a/src/game/behaviors/manta_ray.inc.c b/src/game/behaviors/manta_ray.inc.c index 1cfbb44ea..3cf3a6675 100644 --- a/src/game/behaviors/manta_ray.inc.c +++ b/src/game/behaviors/manta_ray.inc.c @@ -42,13 +42,13 @@ void bhv_manta_ray_init(void) { cur_obj_scale(2.5f); sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oMantaTargetPitch); - sync_object_init_field(o, &o->oMantaTargetYaw); - sync_object_init_field(o, &o->oWaterRingSpawnerRingsCollected); - sync_object_init_field(o, &o->oMoveAnglePitch); - sync_object_init_field(o, &o->oMoveAngleRoll); + sync_object_init_field(o, o->oMantaTargetPitch); + sync_object_init_field(o, o->oMantaTargetYaw); + sync_object_init_field(o, o->oWaterRingSpawnerRingsCollected); + sync_object_init_field(o, o->oMoveAnglePitch); + sync_object_init_field(o, o->oMoveAngleRoll); if (ringManager != NULL) { - sync_object_init_field(o, &ringManager->oWaterRingMgrNextRingIndex); + sync_object_init_field(o, ringManager->oWaterRingMgrNextRingIndex); } } diff --git a/src/game/behaviors/metal_box.inc.c b/src/game/behaviors/metal_box.inc.c index 48891454a..ddc24ce85 100644 --- a/src/game/behaviors/metal_box.inc.c +++ b/src/game/behaviors/metal_box.inc.c @@ -28,7 +28,7 @@ s32 check_if_moving_over_floor(f32 a0, f32 a1) { void bhv_pushable_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 1000.0f); - sync_object_init_field(o, &o->oMoveAngleYaw); + sync_object_init_field(o, o->oMoveAngleYaw); } struct MarioState* marioState = nearest_mario_state_to_object(o); diff --git a/src/game/behaviors/mips.inc.c b/src/game/behaviors/mips.inc.c index 451d1c8b7..24fcb578c 100644 --- a/src/game/behaviors/mips.inc.c +++ b/src/game/behaviors/mips.inc.c @@ -69,12 +69,12 @@ void bhv_mips_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { - sync_object_init_field(o, &o->oMipsStartWaypointIndex); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oMipsStarStatus); - sync_object_init_field(o, &o->oBehParams2ndByte); - sync_object_init_field(o, &o->oHeldState); - sync_object_init_field(o, &o->oFlags); + sync_object_init_field(o, o->oMipsStartWaypointIndex); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oMipsStarStatus); + sync_object_init_field(o, o->oBehParams2ndByte); + sync_object_init_field(o, o->oHeldState); + sync_object_init_field(o, o->oFlags); so->on_received_pre = bhv_mips_on_received_pre; so->on_received_post = bhv_mips_on_received_post; } diff --git a/src/game/behaviors/moneybag.inc.c b/src/game/behaviors/moneybag.inc.c index fa2d9b4f1..3082c1550 100644 --- a/src/game/behaviors/moneybag.inc.c +++ b/src/game/behaviors/moneybag.inc.c @@ -32,11 +32,11 @@ void bhv_moneybag_init(void) { o->oOpacity = 0; sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oHomeX); - sync_object_init_field(o, &o->oHomeY); - sync_object_init_field(o, &o->oHomeZ); - sync_object_init_field(o, &o->oMoneybagJumpState); - sync_object_init_field(o, &o->oOpacity); + sync_object_init_field(o, o->oHomeX); + sync_object_init_field(o, o->oHomeY); + sync_object_init_field(o, o->oHomeZ); + sync_object_init_field(o, o->oMoneybagJumpState); + sync_object_init_field(o, o->oOpacity); } void moneybag_check_mario_collision(void) { @@ -228,9 +228,9 @@ void bhv_moneybag_hidden_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); } switch (o->oAction) { diff --git a/src/game/behaviors/monty_mole.inc.c b/src/game/behaviors/monty_mole.inc.c index dfe821888..f7821d558 100644 --- a/src/game/behaviors/monty_mole.inc.c +++ b/src/game/behaviors/monty_mole.inc.c @@ -175,15 +175,15 @@ void bhv_monty_mole_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->on_received_post = bhv_monty_mole_on_received_post; - sync_object_init_field(o, &o->oMontyMoleHeightRelativeToFloor); - sync_object_init_field(o, &o->oMontyMoleHoleX); - sync_object_init_field(o, &o->oMontyMoleHoleY); - sync_object_init_field(o, &o->oMontyMoleHoleZ); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oGravity); - sync_object_init_field(o, &o->oIntangibleTimer); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field_with_size(o, &o->header.gfx.node.flags, 16); + sync_object_init_field(o, o->oMontyMoleHeightRelativeToFloor); + sync_object_init_field(o, o->oMontyMoleHoleX); + sync_object_init_field(o, o->oMontyMoleHoleY); + sync_object_init_field(o, o->oMontyMoleHoleZ); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oGravity); + sync_object_init_field(o, o->oIntangibleTimer); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->header.gfx.node.flags); } } diff --git a/src/game/behaviors/mr_blizzard.inc.c b/src/game/behaviors/mr_blizzard.inc.c index a37f78da8..a38c3c2e7 100644 --- a/src/game/behaviors/mr_blizzard.inc.c +++ b/src/game/behaviors/mr_blizzard.inc.c @@ -49,14 +49,14 @@ void bhv_mr_blizzard_init(void) { o->oMrBlizzardTargetMoveYaw = o->oMoveAngleYaw; sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oMrBlizzardTargetMoveYaw); - sync_object_init_field(o, &o->oMrBlizzardTimer); - sync_object_init_field(o, &o->oMrBlizzardDistFromHome); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oVelY); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); + sync_object_init_field(o, o->oMrBlizzardTargetMoveYaw); + sync_object_init_field(o, o->oMrBlizzardTimer); + sync_object_init_field(o, o->oMrBlizzardDistFromHome); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oVelY); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); } else { if (o->oBehParams2ndByte != MR_BLIZZARD_STYPE_NO_CAP) { // Cap wearing Mr. Blizzard from SL. @@ -70,10 +70,10 @@ void bhv_mr_blizzard_init(void) { o->oMrBlizzardHeldObj = NULL; sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oMrBlizzardTargetMoveYaw); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oMrBlizzardGraphYOffset); - sync_object_init_field(o, &o->oMoveAngleYaw); + sync_object_init_field(o, o->oMrBlizzardTargetMoveYaw); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oMrBlizzardGraphYOffset); + sync_object_init_field(o, o->oMoveAngleYaw); } } diff --git a/src/game/behaviors/mushroom_1up.inc.c b/src/game/behaviors/mushroom_1up.inc.c index cab0c2852..1488cbd18 100644 --- a/src/game/behaviors/mushroom_1up.inc.c +++ b/src/game/behaviors/mushroom_1up.inc.c @@ -231,18 +231,18 @@ void bhv_1up_jump_on_approach_loop(void) { void bhv_1up_hidden_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); - sync_object_init_field(o, &o->oVelX); - sync_object_init_field(o, &o->oVelY); - sync_object_init_field(o, &o->oVelZ); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->o1UpHiddenUnkF4); - sync_object_init_field(o, &o->oIntangibleTimer); - sync_object_init_field_with_size(o, &o->activeFlags, 16); - sync_object_init_field_with_size(o, &o->header.gfx.node.flags, 16); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); + sync_object_init_field(o, o->oVelX); + sync_object_init_field(o, o->oVelY); + sync_object_init_field(o, o->oVelZ); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->o1UpHiddenUnkF4); + sync_object_init_field(o, o->oIntangibleTimer); + sync_object_init_field(o, o->activeFlags); + sync_object_init_field(o, o->header.gfx.node.flags); } s16 sp26; @@ -294,7 +294,7 @@ void bhv_1up_hidden_loop(void) { void bhv_1up_hidden_trigger_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field_with_size(o, &o->activeFlags, 16); + sync_object_init_field(o, o->activeFlags); } struct Object* player = nearest_player_to_object(o); @@ -312,15 +312,15 @@ void bhv_1up_hidden_trigger_loop(void) { void bhv_1up_hidden_in_pole_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oVelX); - sync_object_init_field(o, &o->oVelY); - sync_object_init_field(o, &o->oVelZ); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->o1UpHiddenUnkF4); - sync_object_init_field(o, &o->oIntangibleTimer); - sync_object_init_field_with_size(o, &o->activeFlags, 16); - sync_object_init_field_with_size(o, &o->header.gfx.node.flags, 16); + sync_object_init_field(o, o->oVelX); + sync_object_init_field(o, o->oVelY); + sync_object_init_field(o, o->oVelZ); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->o1UpHiddenUnkF4); + sync_object_init_field(o, o->oIntangibleTimer); + sync_object_init_field(o, o->activeFlags); + sync_object_init_field(o, o->header.gfx.node.flags); } UNUSED s16 sp26; @@ -365,7 +365,7 @@ void bhv_1up_hidden_in_pole_loop(void) { void bhv_1up_hidden_in_pole_trigger_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field_with_size(o, &o->activeFlags, 16); + sync_object_init_field(o, o->activeFlags); } struct Object* player = nearest_player_to_object(o); @@ -383,7 +383,7 @@ void bhv_1up_hidden_in_pole_trigger_loop(void) { void bhv_1up_hidden_in_pole_spawner_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field_with_size(o, &o->activeFlags, 16); + sync_object_init_field(o, o->activeFlags); } if (gNetworkAreaSyncing || !gNetworkAreaLoaded) { diff --git a/src/game/behaviors/piranha_plant.inc.c b/src/game/behaviors/piranha_plant.inc.c index 826802f9c..628bfcb01 100644 --- a/src/game/behaviors/piranha_plant.inc.c +++ b/src/game/behaviors/piranha_plant.inc.c @@ -363,13 +363,13 @@ void (*TablePiranhaPlantActions[])(void) = { void bhv_piranha_plant_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 2000.0f); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oInteractStatus); - sync_object_init_field(o, &o->oInteractType); - sync_object_init_field(o, &o->oMoveAngleYaw); - sync_object_init_field(o, &o->oPiranhaPlantScale); - sync_object_init_field(o, &o->oPiranhaPlantSleepMusicState); - sync_object_init_field(o, &o->oTimer); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oInteractStatus); + sync_object_init_field(o, o->oInteractType); + sync_object_init_field(o, o->oMoveAngleYaw); + sync_object_init_field(o, o->oPiranhaPlantScale); + sync_object_init_field(o, o->oPiranhaPlantSleepMusicState); + sync_object_init_field(o, o->oTimer); } CUR_OBJ_CALL_ACTION_FUNCTION(TablePiranhaPlantActions); diff --git a/src/game/behaviors/platform_on_track.inc.c b/src/game/behaviors/platform_on_track.inc.c index 3816cf2e1..6aa588fcc 100644 --- a/src/game/behaviors/platform_on_track.inc.c +++ b/src/game/behaviors/platform_on_track.inc.c @@ -76,14 +76,14 @@ void bhv_platform_on_track_init(void) { so->on_sent_pre = bhv_platform_track_on_sent_pre; so->on_received_post = bhv_platform_track_on_received_post; so->maxUpdateRate = 5.0f; - sync_object_init_field(o, &platformTrackPathedPrevWaypoint); - sync_object_init_field(o, &o->oPlatformOnTrackBaseBallIndex); - sync_object_init_field(o, &o->oPlatformOnTrackDistMovedSinceLastBall); - sync_object_init_field(o, &o->oPlatformOnTrackSkiLiftRollVel); - sync_object_init_field(o, &o->oPlatformOnTrackPrevWaypointFlags); - sync_object_init_field(o, &o->oPlatformOnTrackPitch); - sync_object_init_field(o, &o->oPlatformOnTrackYaw); - sync_object_init_field(o, &o->oPlatformOnTrackOffsetY); + sync_object_init_field(o, platformTrackPathedPrevWaypoint); + sync_object_init_field(o, o->oPlatformOnTrackBaseBallIndex); + sync_object_init_field(o, o->oPlatformOnTrackDistMovedSinceLastBall); + sync_object_init_field(o, o->oPlatformOnTrackSkiLiftRollVel); + sync_object_init_field(o, o->oPlatformOnTrackPrevWaypointFlags); + sync_object_init_field(o, o->oPlatformOnTrackPitch); + sync_object_init_field(o, o->oPlatformOnTrackYaw); + sync_object_init_field(o, o->oPlatformOnTrackOffsetY); } } diff --git a/src/game/behaviors/pokey.inc.c b/src/game/behaviors/pokey.inc.c index 5eb0262af..17181df57 100644 --- a/src/game/behaviors/pokey.inc.c +++ b/src/game/behaviors/pokey.inc.c @@ -197,12 +197,12 @@ static void pokey_act_uninitialized(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { - sync_object_init_field(o, &o->oPokeyAliveBodyPartFlags); - sync_object_init_field(o, &o->oPokeyNumAliveBodyParts); - sync_object_init_field(o, &o->oPokeyHeadWasKilled); - sync_object_init_field(o, &o->oPokeyTargetYaw); - sync_object_init_field(o, &o->oPokeyChangeTargetTimer); - sync_object_init_field(o, &o->oPokeyTurningAwayFromWall); + sync_object_init_field(o, o->oPokeyAliveBodyPartFlags); + sync_object_init_field(o, o->oPokeyNumAliveBodyParts); + sync_object_init_field(o, o->oPokeyHeadWasKilled); + sync_object_init_field(o, o->oPokeyTargetYaw); + sync_object_init_field(o, o->oPokeyChangeTargetTimer); + sync_object_init_field(o, o->oPokeyTurningAwayFromWall); so->on_received_pre = pokey_on_received_pre; so->on_received_post = pokey_on_received_post; } diff --git a/src/game/behaviors/purple_switch.inc.c b/src/game/behaviors/purple_switch.inc.c index 87235feff..b15150ca9 100644 --- a/src/game/behaviors/purple_switch.inc.c +++ b/src/game/behaviors/purple_switch.inc.c @@ -9,8 +9,8 @@ void bhv_purple_switch_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oTimer); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oTimer); } u8 anyPlayerOnPlatform = FALSE; diff --git a/src/game/behaviors/pyramid_elevator.inc.c b/src/game/behaviors/pyramid_elevator.inc.c index 262580574..18a780d36 100644 --- a/src/game/behaviors/pyramid_elevator.inc.c +++ b/src/game/behaviors/pyramid_elevator.inc.c @@ -19,11 +19,11 @@ void bhv_pyramid_elevator_init(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oVelY); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oVelY); } } } diff --git a/src/game/behaviors/pyramid_top.inc.c b/src/game/behaviors/pyramid_top.inc.c index 2a4644473..805194425 100644 --- a/src/game/behaviors/pyramid_top.inc.c +++ b/src/game/behaviors/pyramid_top.inc.c @@ -91,10 +91,10 @@ void bhv_pyramid_top_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field_with_size(o, &o->activeFlags, 16); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); + sync_object_init_field(o, o->activeFlags); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); } } diff --git a/src/game/behaviors/racing_penguin.inc.c b/src/game/behaviors/racing_penguin.inc.c index 28137e7b5..44df93047 100644 --- a/src/game/behaviors/racing_penguin.inc.c +++ b/src/game/behaviors/racing_penguin.inc.c @@ -56,27 +56,27 @@ void bhv_racing_penguin_init(void) { so->on_received_post = bhv_racing_penguin_the_quick_on_received_post; so->on_sent_pre = bhv_racing_penguin_the_quick_on_sent_pre; so->override_ownership = bhv_racing_penguin_the_quick_override_ownership; - sync_object_init_field(o, &penguinPathedStartWaypoint); - sync_object_init_field(o, &penguinPathedPrevWaypoint); - sync_object_init_field(o, &o->oPathedPrevWaypointFlags); - sync_object_init_field(o, &o->oPathedTargetPitch); - sync_object_init_field(o, &o->oPathedTargetYaw); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); - sync_object_init_field(o, &o->oVelX); - sync_object_init_field(o, &o->oVelY); - sync_object_init_field(o, &o->oVelZ); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oSubAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oMoveAngleYaw); - sync_object_init_field(o, &o->oRacingPenguinWeightedNewTargetSpeed); - sync_object_init_field(o, &o->oRacingPenguinMarioWon); - sync_object_init_field(o, &o->oRacingPenguinReachedBottom); - sync_object_init_field(o, &o->areaTimer); + sync_object_init_field(o, penguinPathedStartWaypoint); + sync_object_init_field(o, penguinPathedPrevWaypoint); + sync_object_init_field(o, o->oPathedPrevWaypointFlags); + sync_object_init_field(o, o->oPathedTargetPitch); + sync_object_init_field(o, o->oPathedTargetYaw); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); + sync_object_init_field(o, o->oVelX); + sync_object_init_field(o, o->oVelY); + sync_object_init_field(o, o->oVelZ); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oSubAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oMoveAngleYaw); + sync_object_init_field(o, o->oRacingPenguinWeightedNewTargetSpeed); + sync_object_init_field(o, o->oRacingPenguinMarioWon); + sync_object_init_field(o, o->oRacingPenguinReachedBottom); + sync_object_init_field(o, o->areaTimer); } o->areaTimerType = AREA_TIMER_TYPE_MAXIMUM; o->areaTimer = 0; diff --git a/src/game/behaviors/rolling_log.inc.c b/src/game/behaviors/rolling_log.inc.c index 4ee2d9b12..3cc6c9dfa 100644 --- a/src/game/behaviors/rolling_log.inc.c +++ b/src/game/behaviors/rolling_log.inc.c @@ -10,13 +10,13 @@ static void bhv_rolling_log_network_init(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, 4000.0f); if (so) { - sync_object_init_field(o, &o->oAngleVelPitch); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oMoveAnglePitch); - sync_object_init_field(o, &o->oPitouneUnkF4); - sync_object_init_field(o, &o->oPitouneUnkF8); - sync_object_init_field(o, &o->oPitouneUnkFC); - sync_object_init_field(o, &o->oForwardVel); + sync_object_init_field(o, o->oAngleVelPitch); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oMoveAnglePitch); + sync_object_init_field(o, o->oPitouneUnkF4); + sync_object_init_field(o, o->oPitouneUnkF8); + sync_object_init_field(o, o->oPitouneUnkFC); + sync_object_init_field(o, o->oForwardVel); } } } @@ -149,9 +149,9 @@ void bhv_volcano_trap_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, 2000.0f); if (so) { - sync_object_init_field(o, &o->oRollingLogUnkF4); - sync_object_init_field(o, &o->oAngleVelPitch); - sync_object_init_field(o, &o->oFaceAnglePitch); + sync_object_init_field(o, o->oRollingLogUnkF4); + sync_object_init_field(o, o->oAngleVelPitch); + sync_object_init_field(o, o->oFaceAnglePitch); } } diff --git a/src/game/behaviors/scuttlebug.inc.c b/src/game/behaviors/scuttlebug.inc.c index 0f96a6ac4..4082f05dd 100644 --- a/src/game/behaviors/scuttlebug.inc.c +++ b/src/game/behaviors/scuttlebug.inc.c @@ -28,13 +28,13 @@ void bhv_scuttlebug_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, 4000.0f); if (so) { - sync_object_init_field(o, &o->oFlags); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oHomeX); - sync_object_init_field(o, &o->oHomeY); - sync_object_init_field(o, &o->oHomeZ); - sync_object_init_field(o, &o->oInteractStatus); - sync_object_init_field(o, &o->oScuttlebugUnkF4); + sync_object_init_field(o, o->oFlags); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oHomeX); + sync_object_init_field(o, o->oHomeY); + sync_object_init_field(o, o->oHomeZ); + sync_object_init_field(o, o->oInteractStatus); + sync_object_init_field(o, o->oScuttlebugUnkF4); } } @@ -141,10 +141,10 @@ void bhv_scuttlebug_spawn_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oScuttlebugSpawnerUnkF4); - sync_object_init_field(o, &o->oScuttlebugSpawnerUnk88); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oScuttlebugSpawnerUnkF4); + sync_object_init_field(o, o->oScuttlebugSpawnerUnk88); } } diff --git a/src/game/behaviors/seesaw_platform.inc.c b/src/game/behaviors/seesaw_platform.inc.c index 85c807b56..c603bcf58 100644 --- a/src/game/behaviors/seesaw_platform.inc.c +++ b/src/game/behaviors/seesaw_platform.inc.c @@ -29,8 +29,8 @@ void bhv_seesaw_platform_init(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, 1000.0f); if (so) { - sync_object_init_field(o, &o->oSeesawPlatformPitchVel); - sync_object_init_field(o, &o->oFaceAnglePitch); + sync_object_init_field(o, o->oSeesawPlatformPitchVel); + sync_object_init_field(o, o->oFaceAnglePitch); } } } diff --git a/src/game/behaviors/skeeter.inc.c b/src/game/behaviors/skeeter.inc.c index 344794e31..9a5ecfe0b 100644 --- a/src/game/behaviors/skeeter.inc.c +++ b/src/game/behaviors/skeeter.inc.c @@ -143,14 +143,14 @@ static void skeeter_act_walk(void) { void bhv_skeeter_update(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oSkeeterTargetAngle); - sync_object_init_field(o, &o->oSkeeterUnkF8); - sync_object_init_field(o, &o->oSkeeterUnkFC); - sync_object_init_field(o, &o->oSkeeterWaitTime); - sync_object_init_field(o, &o->oSkeeterUnk1AC); - sync_object_init_field(o, &o->oMoveAngleYaw); - sync_object_init_field(o, &o->oFaceAngleYaw); - sync_object_init_field(o, &o->oFlags); + sync_object_init_field(o, o->oSkeeterTargetAngle); + sync_object_init_field(o, o->oSkeeterUnkF8); + sync_object_init_field(o, o->oSkeeterUnkFC); + sync_object_init_field(o, o->oSkeeterWaitTime); + sync_object_init_field(o, o->oSkeeterUnk1AC); + sync_object_init_field(o, o->oMoveAngleYaw); + sync_object_init_field(o, o->oFaceAngleYaw); + sync_object_init_field(o, o->oFlags); } o->oDeathSound = SOUND_OBJ_SNUFIT_SKEETER_DEATH; diff --git a/src/game/behaviors/sl_snowman_wind.inc.c b/src/game/behaviors/sl_snowman_wind.inc.c index baa7bb9ea..a55c9b1fe 100644 --- a/src/game/behaviors/sl_snowman_wind.inc.c +++ b/src/game/behaviors/sl_snowman_wind.inc.c @@ -6,10 +6,10 @@ void bhv_sl_snowman_wind_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oSubAction); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oSubAction); } } diff --git a/src/game/behaviors/sl_walking_penguin.inc.c b/src/game/behaviors/sl_walking_penguin.inc.c index d23a030c1..6031381b7 100644 --- a/src/game/behaviors/sl_walking_penguin.inc.c +++ b/src/game/behaviors/sl_walking_penguin.inc.c @@ -40,13 +40,13 @@ void bhv_sl_walking_penguin_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, 4000.0f); if (so) { - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oSLWalkingPenguinCurStep); - sync_object_init_field(o, &o->oSLWalkingPenguinCurStepTimer); - sync_object_init_field(o, &o->oSLWalkingPenguinWindCollisionXPos); - sync_object_init_field(o, &o->oSLWalkingPenguinWindCollisionZPos); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oSLWalkingPenguinCurStep); + sync_object_init_field(o, o->oSLWalkingPenguinCurStepTimer); + sync_object_init_field(o, o->oSLWalkingPenguinWindCollisionXPos); + sync_object_init_field(o, o->oSLWalkingPenguinWindCollisionZPos); } } diff --git a/src/game/behaviors/sliding_platform_2.inc.c b/src/game/behaviors/sliding_platform_2.inc.c index b7d3a94f5..1569293e4 100644 --- a/src/game/behaviors/sliding_platform_2.inc.c +++ b/src/game/behaviors/sliding_platform_2.inc.c @@ -38,10 +38,10 @@ void bhv_sliding_plat_2_loop(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oBackAndForthPlatformDirection); - sync_object_init_field(o, &o->oBackAndForthPlatformPathLength); - sync_object_init_field(o, &o->oBackAndForthPlatformDistance); - sync_object_init_field(o, &o->oBackAndForthPlatformVel); + sync_object_init_field(o, o->oBackAndForthPlatformDirection); + sync_object_init_field(o, o->oBackAndForthPlatformPathLength); + sync_object_init_field(o, o->oBackAndForthPlatformDistance); + sync_object_init_field(o, o->oBackAndForthPlatformVel); } } diff --git a/src/game/behaviors/snow_mound.inc.c b/src/game/behaviors/snow_mound.inc.c index 20993d072..849e37adc 100644 --- a/src/game/behaviors/snow_mound.inc.c +++ b/src/game/behaviors/snow_mound.inc.c @@ -37,9 +37,9 @@ void bhv_snow_mound_spawn_loop(void) { struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { so->override_ownership = bhv_snow_mound_spawn_override_ownership; - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); } } diff --git a/src/game/behaviors/snowman.inc.c b/src/game/behaviors/snowman.inc.c index cfea111ae..00eeef110 100644 --- a/src/game/behaviors/snowman.inc.c +++ b/src/game/behaviors/snowman.inc.c @@ -34,8 +34,8 @@ void bhv_snowmans_bottom_init(void) { spawn_object_abs_with_rot(o, 0, MODEL_NONE, bhvSnowmansBodyCheckpoint, -402, 461, -2898, 0, 0, 0); sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oForwardVel); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oForwardVel); } void set_rolling_sphere_hitbox(void) { @@ -198,7 +198,7 @@ void bhv_snowmans_head_init(void) { } sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); + sync_object_init_field(o, o->oAction); } static u8 bhv_snowmans_head_action_0_continue_dialog(void) { diff --git a/src/game/behaviors/snufit.inc.c b/src/game/behaviors/snufit.inc.c index c18825bfe..f78a73186 100644 --- a/src/game/behaviors/snufit.inc.c +++ b/src/game/behaviors/snufit.inc.c @@ -134,16 +134,16 @@ void snufit_act_shoot(void) { void bhv_snufit_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oSnufitBullets); - sync_object_init_field(o, &o->oSnufitRecoil); - sync_object_init_field(o, &o->oSnufitYOffset); - sync_object_init_field(o, &o->oSnufitZOffset); - sync_object_init_field(o, &o->oSnufitScale); - sync_object_init_field(o, &o->oSnufitBodyScale); - sync_object_init_field(o, &o->oMoveAnglePitch); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oGravity); - sync_object_init_field(o, &o->oDeathSound); + sync_object_init_field(o, o->oSnufitBullets); + sync_object_init_field(o, o->oSnufitRecoil); + sync_object_init_field(o, o->oSnufitYOffset); + sync_object_init_field(o, o->oSnufitZOffset); + sync_object_init_field(o, o->oSnufitScale); + sync_object_init_field(o, o->oSnufitBodyScale); + sync_object_init_field(o, o->oMoveAnglePitch); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oGravity); + sync_object_init_field(o, o->oDeathSound); } struct MarioState* marioState = nearest_mario_state_to_object(o); diff --git a/src/game/behaviors/sparkle_spawn_star.inc.c b/src/game/behaviors/sparkle_spawn_star.inc.c index ee36a360b..99a6b8f6a 100644 --- a/src/game/behaviors/sparkle_spawn_star.inc.c +++ b/src/game/behaviors/sparkle_spawn_star.inc.c @@ -84,9 +84,9 @@ void slow_star_rotation(void) { void bhv_spawned_star_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000); - sync_object_init_field(o, &o->oBehParams); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oStarSpawnExtCutsceneFlags); + sync_object_init_field(o, o->oBehParams); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oStarSpawnExtCutsceneFlags); } if (o->oAction == 0) { diff --git a/src/game/behaviors/spawn_star.inc.c b/src/game/behaviors/spawn_star.inc.c index a14022a39..71783e743 100644 --- a/src/game/behaviors/spawn_star.inc.c +++ b/src/game/behaviors/spawn_star.inc.c @@ -108,9 +108,9 @@ void bhv_star_spawn_init(void) { void bhv_star_spawn_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000); - sync_object_init_field(o, &o->oBehParams); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oStarSpawnExtCutsceneFlags); + sync_object_init_field(o, o->oBehParams); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oStarSpawnExtCutsceneFlags); } switch (o->oAction) { @@ -320,11 +320,11 @@ void bhv_hidden_red_coin_star_init(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oHiddenStarTriggerCounter); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oHiddenStarTriggerCounter); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); } } } diff --git a/src/game/behaviors/spindel.inc.c b/src/game/behaviors/spindel.inc.c index c77861ea1..7ee1cd609 100644 --- a/src/game/behaviors/spindel.inc.c +++ b/src/game/behaviors/spindel.inc.c @@ -6,10 +6,10 @@ void bhv_spindel_init(void) { o->oSpindelUnkF8 = 0; sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oSpindelUnkF4); - sync_object_init_field(o, &o->oSpindelUnkF8); - sync_object_init_field(o, &o->oAngleVelPitch); - sync_object_init_field(o, &o->oMoveAnglePitch); + sync_object_init_field(o, o->oSpindelUnkF4); + sync_object_init_field(o, o->oSpindelUnkF8); + sync_object_init_field(o, o->oAngleVelPitch); + sync_object_init_field(o, o->oMoveAnglePitch); } void bhv_spindel_loop(void) { diff --git a/src/game/behaviors/spindrift.inc.c b/src/game/behaviors/spindrift.inc.c index 42a3fcd04..d1354761b 100644 --- a/src/game/behaviors/spindrift.inc.c +++ b/src/game/behaviors/spindrift.inc.c @@ -15,7 +15,7 @@ struct ObjectHitbox sSpindriftHitbox = { void bhv_spindrift_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oFlags); + sync_object_init_field(o, o->oFlags); } struct Object* player = nearest_player_to_object(o); diff --git a/src/game/behaviors/spiny.inc.c b/src/game/behaviors/spiny.inc.c index a35a399a7..7b8559e03 100644 --- a/src/game/behaviors/spiny.inc.c +++ b/src/game/behaviors/spiny.inc.c @@ -241,15 +241,15 @@ void bhv_spiny_update(void) { so->on_sent_pre = bhv_spiny_on_sent_pre; so->override_ownership = bhv_spiny_override_ownership; - sync_object_init_field(o, &o->oGraphYOffset); - sync_object_init_field(o, &o->oFaceAngleYaw); - sync_object_init_field(o, &o->oSpinyTimeUntilTurn); - sync_object_init_field(o, &o->oSpinyTargetYaw); - sync_object_init_field(o, &o->oSpinyTurningAwayFromWall); - sync_object_init_field(o, &o->oMoveFlags); - sync_object_init_field(o, &o->oInteractType); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &spinyAnimCache); + sync_object_init_field(o, o->oGraphYOffset); + sync_object_init_field(o, o->oFaceAngleYaw); + sync_object_init_field(o, o->oSpinyTimeUntilTurn); + sync_object_init_field(o, o->oSpinyTargetYaw); + sync_object_init_field(o, o->oSpinyTurningAwayFromWall); + sync_object_init_field(o, o->oMoveFlags); + sync_object_init_field(o, o->oInteractType); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, spinyAnimCache); } diff --git a/src/game/behaviors/square_platform_cycle.inc.c b/src/game/behaviors/square_platform_cycle.inc.c index 9facd8e06..7af35bf7a 100644 --- a/src/game/behaviors/square_platform_cycle.inc.c +++ b/src/game/behaviors/square_platform_cycle.inc.c @@ -23,17 +23,17 @@ void bhv_squarish_path_parent_init(void) { square->oPosY = o->oPosY; square->oPosZ = o->oPosZ + offset; square->oAction = action; - sync_object_init_field(o, &square->oMoveAngleYaw); - sync_object_init_field(o, &square->oForwardVel); - sync_object_init_field(o, &square->oPosX); - sync_object_init_field(o, &square->oPosY); - sync_object_init_field(o, &square->oPosZ); - sync_object_init_field(o, &square->oVelX); - sync_object_init_field(o, &square->oVelY); - sync_object_init_field(o, &square->oVelZ); - sync_object_init_field(o, &square->oAction); - sync_object_init_field(o, &square->oPrevAction); - sync_object_init_field(o, &square->oTimer); + sync_object_init_field(o, square->oMoveAngleYaw); + sync_object_init_field(o, square->oForwardVel); + sync_object_init_field(o, square->oPosX); + sync_object_init_field(o, square->oPosY); + sync_object_init_field(o, square->oPosZ); + sync_object_init_field(o, square->oVelX); + sync_object_init_field(o, square->oVelY); + sync_object_init_field(o, square->oVelZ); + sync_object_init_field(o, square->oAction); + sync_object_init_field(o, square->oPrevAction); + sync_object_init_field(o, square->oTimer); } } diff --git a/src/game/behaviors/sushi.inc.c b/src/game/behaviors/sushi.inc.c index a6245c35f..af9990529 100644 --- a/src/game/behaviors/sushi.inc.c +++ b/src/game/behaviors/sushi.inc.c @@ -6,7 +6,7 @@ void bhv_sushi_shark_collision_loop(void) { void bhv_sushi_shark_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oSushiSharkUnkF4); + sync_object_init_field(o, o->oSushiSharkUnkF4); } struct Object* player = nearest_player_to_object(o); diff --git a/src/game/behaviors/swing_platform.inc.c b/src/game/behaviors/swing_platform.inc.c index 2b3e311b5..83ba99df7 100644 --- a/src/game/behaviors/swing_platform.inc.c +++ b/src/game/behaviors/swing_platform.inc.c @@ -5,10 +5,10 @@ void bhv_swing_platform_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oSwingPlatformAngle); - sync_object_init_field(o, &o->oFaceAngleRoll); - sync_object_init_field(o, &o->oSwingPlatformSpeed); - sync_object_init_field(o, &o->oAngleVelRoll); + sync_object_init_field(o, o->oSwingPlatformAngle); + sync_object_init_field(o, o->oFaceAngleRoll); + sync_object_init_field(o, o->oSwingPlatformSpeed); + sync_object_init_field(o, o->oAngleVelRoll); } } diff --git a/src/game/behaviors/swoop.inc.c b/src/game/behaviors/swoop.inc.c index 2cebec928..fdaa6af7e 100644 --- a/src/game/behaviors/swoop.inc.c +++ b/src/game/behaviors/swoop.inc.c @@ -107,12 +107,12 @@ static void swoop_act_move(void) { void bhv_swoop_update(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oFaceAngleRoll); - sync_object_init_field(o, &o->header.gfx.scale[0]); - sync_object_init_field(o, &o->oSwoopBonkCountdown); - sync_object_init_field(o, &o->oSwoopTargetPitch); - sync_object_init_field(o, &o->oSwoopTargetYaw); - sync_object_init_field(o, &o->oDeathSound); + sync_object_init_field(o, o->oFaceAngleRoll); + sync_object_init_field(o, o->header.gfx.scale[0]); + sync_object_init_field(o, o->oSwoopBonkCountdown); + sync_object_init_field(o, o->oSwoopTargetPitch); + sync_object_init_field(o, o->oSwoopTargetYaw); + sync_object_init_field(o, o->oDeathSound); } // No partial update (only appears in roomed levels) diff --git a/src/game/behaviors/texscroll.inc.c b/src/game/behaviors/texscroll.inc.c index 5ac1b4b69..6a1256fdc 100644 --- a/src/game/behaviors/texscroll.inc.c +++ b/src/game/behaviors/texscroll.inc.c @@ -70,13 +70,9 @@ static inline void shift_UV_NORMAL(struct ScrollTarget *scroll, u16 vertcount, s verts[0]->n.flag++; } else { if (bhv < SCROLL_UV_X) { - for (i = 0; i < vertcount; i++) { - scroll->prevF32[i] = scroll->interpF32[i]; - } + memcpy(scroll->prevF32, scroll->interpF32, vertcount * sizeof(f32)); } else { - for (i = 0; i < vertcount; i++) { - scroll->prevS16[i] = scroll->interpS16[i]; - } + memcpy(scroll->prevS16, scroll->interpS16, vertcount * sizeof(s16)); } } } @@ -133,19 +129,31 @@ void uv_update_scroll(void) { scroll->hasInterpInit = true; scroll->bhv = bhv; if (bhv < SCROLL_UV_X) { - scroll->interpF32 = calloc(scroll->size, sizeof(f32)); - scroll->prevF32 = calloc(scroll->size, sizeof(f32)); + scroll->interpF32 = malloc(scroll->size * sizeof(f32)); + scroll->prevF32 = malloc(scroll->size * sizeof(f32)); + if (!scroll->interpF32 || !scroll->prevF32) { + free(scroll->interpF32); + free(scroll->prevF32); + scroll->interpF32 = scroll->prevF32 = NULL; + return; + } u8 bhvIndex = MIN(bhv, 2); - for (u16 k = 0; k < scroll->size; k++) { + for (u32 k = 0; k < scroll->size; k++) { scroll->interpF32[k] = verts[k]->n.ob[bhvIndex]; } } else { - scroll->interpS16 = calloc(scroll->size, sizeof(s16)); - scroll->prevS16 = calloc(scroll->size, sizeof(s16)); + scroll->interpS16 = malloc(scroll->size * sizeof(s16)); + scroll->prevS16 = malloc(scroll->size * sizeof(s16)); + if (!scroll->interpS16 || !scroll->prevS16) { + free(scroll->interpS16); + free(scroll->prevS16); + scroll->interpS16 = scroll->prevS16 = NULL; + return; + } u8 bhvIndex = MIN(bhv-SCROLL_UV_X, 1); - for (u16 k = 0; k < scroll->size; k++) { + for (u32 k = 0; k < scroll->size; k++) { scroll->interpS16[k] = verts[k]->n.tc[bhvIndex]; } } @@ -153,15 +161,9 @@ void uv_update_scroll(void) { // Prepare for interpolation if (bhv < SCROLL_UV_X) { - u8 bhvIndex = MIN(bhv, 2); - for (u16 i = 0; i < scroll->size; i++) { - scroll->prevF32[i] = verts[i]->n.ob[bhvIndex]; - } + memcpy(scroll->prevF32, scroll->interpF32, scroll->size * sizeof(f32)); } else { - u8 bhvIndex = MIN(bhv-SCROLL_UV_X, 1); - for (u16 i = 0; i < scroll->size; i++) { - scroll->prevS16[i] = verts[i]->n.tc[bhvIndex]; - } + memcpy(scroll->prevS16, scroll->interpS16, scroll->size * sizeof(s16)); } scroll->needInterp = true; diff --git a/src/game/behaviors/thi_top.inc.c b/src/game/behaviors/thi_top.inc.c index b5e87b14b..e045ab830 100644 --- a/src/game/behaviors/thi_top.inc.c +++ b/src/game/behaviors/thi_top.inc.c @@ -19,10 +19,10 @@ void bhv_thi_huge_island_top_loop(void) { void bhv_thi_tiny_island_top_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field_with_size(o, &o->header.gfx.node.flags, 16); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->header.gfx.node.flags); } struct MarioState* marioState = nearest_mario_state_to_object(o); diff --git a/src/game/behaviors/thwomp.inc.c b/src/game/behaviors/thwomp.inc.c index 51d711508..3c3101090 100644 --- a/src/game/behaviors/thwomp.inc.c +++ b/src/game/behaviors/thwomp.inc.c @@ -57,11 +57,11 @@ void (*sGrindelThwompActions[])(void) = { grindel_thwomp_act_0, grindel_thwomp_a void bhv_grindel_thwomp_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oThwompRandomTimer); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oVelY); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oThwompRandomTimer); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oVelY); } CUR_OBJ_CALL_ACTION_FUNCTION(sGrindelThwompActions); } diff --git a/src/game/behaviors/tower_platform.inc.c b/src/game/behaviors/tower_platform.inc.c index 3fa9f045c..e063d5de4 100644 --- a/src/game/behaviors/tower_platform.inc.c +++ b/src/game/behaviors/tower_platform.inc.c @@ -14,9 +14,9 @@ void bhv_wf_solid_tower_platform_loop(void) { void bhv_wf_elevator_tower_platform_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oTimer); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oTimer); } switch (o->oAction) { diff --git a/src/game/behaviors/tox_box.inc.c b/src/game/behaviors/tox_box.inc.c index e0916f6a6..d6fb61c18 100644 --- a/src/game/behaviors/tox_box.inc.c +++ b/src/game/behaviors/tox_box.inc.c @@ -83,11 +83,11 @@ void bhv_tox_box_loop(void) { struct SyncObject* so = sync_object_init(o, 3000.0f); if (so) { so->maxUpdateRate = 10.0f; - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oUnkC0); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oFaceAngleRoll); - sync_object_init_field(o, &o->oToxBoxMovementStep); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oUnkC0); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oFaceAngleRoll); + sync_object_init_field(o, o->oToxBoxMovementStep); } } CUR_OBJ_CALL_ACTION_FUNCTION(sToxBoxActions); diff --git a/src/game/behaviors/treasure_chest.inc.c b/src/game/behaviors/treasure_chest.inc.c index d1cafc6b4..5dff3770a 100644 --- a/src/game/behaviors/treasure_chest.inc.c +++ b/src/game/behaviors/treasure_chest.inc.c @@ -153,20 +153,20 @@ void bhv_treasure_chest_ship_init(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oTreasureChestCurrentAnswer); - sync_object_init_field(o, &o->oTreasureChestIsLastInteractionIncorrect); - sync_object_init_field(o, &o->oTreasureChestIsAboveWater); - sync_object_init_field(o, &o->oTreasureChestSound); - sync_object_init_field(o, &o->oTreasureChestLastNetworkPlayerIndex); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oTreasureChestCurrentAnswer); + sync_object_init_field(o, o->oTreasureChestIsLastInteractionIncorrect); + sync_object_init_field(o, o->oTreasureChestIsAboveWater); + sync_object_init_field(o, o->oTreasureChestSound); + sync_object_init_field(o, o->oTreasureChestLastNetworkPlayerIndex); for (s32 i = 0; i < 4; i++) { struct Object *chest = chests[i]; - sync_object_init_field(o, &chest->oAction); - sync_object_init_field(o, &chest->oPrevAction); - sync_object_init_field(o, &chest->oTimer); - sync_object_init_field(o, &chest->oIntangibleTimer); + sync_object_init_field(o, chest->oAction); + sync_object_init_field(o, chest->oPrevAction); + sync_object_init_field(o, chest->oTimer); + sync_object_init_field(o, chest->oIntangibleTimer); } } } @@ -223,20 +223,20 @@ void bhv_treasure_chest_jrb_init(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oTreasureChestCurrentAnswer); - sync_object_init_field(o, &o->oTreasureChestIsLastInteractionIncorrect); - sync_object_init_field(o, &o->oTreasureChestIsAboveWater); - sync_object_init_field(o, &o->oTreasureChestSound); - sync_object_init_field(o, &o->oTreasureChestLastNetworkPlayerIndex); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oTreasureChestCurrentAnswer); + sync_object_init_field(o, o->oTreasureChestIsLastInteractionIncorrect); + sync_object_init_field(o, o->oTreasureChestIsAboveWater); + sync_object_init_field(o, o->oTreasureChestSound); + sync_object_init_field(o, o->oTreasureChestLastNetworkPlayerIndex); for (s32 i = 0; i < 4; i++) { struct Object *chest = chests[i]; - sync_object_init_field(o, &chest->oAction); - sync_object_init_field(o, &chest->oPrevAction); - sync_object_init_field(o, &chest->oTimer); - sync_object_init_field(o, &chest->oIntangibleTimer); + sync_object_init_field(o, chest->oAction); + sync_object_init_field(o, chest->oPrevAction); + sync_object_init_field(o, chest->oTimer); + sync_object_init_field(o, chest->oIntangibleTimer); } } } @@ -291,20 +291,20 @@ void bhv_treasure_chest_init(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject *so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oTreasureChestCurrentAnswer); - sync_object_init_field(o, &o->oTreasureChestIsLastInteractionIncorrect); - sync_object_init_field(o, &o->oTreasureChestIsAboveWater); - sync_object_init_field(o, &o->oTreasureChestSound); - sync_object_init_field(o, &o->oTreasureChestLastNetworkPlayerIndex); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oTreasureChestCurrentAnswer); + sync_object_init_field(o, o->oTreasureChestIsLastInteractionIncorrect); + sync_object_init_field(o, o->oTreasureChestIsAboveWater); + sync_object_init_field(o, o->oTreasureChestSound); + sync_object_init_field(o, o->oTreasureChestLastNetworkPlayerIndex); for (s32 i = 0; i < 4; i++) { struct Object *chest = chests[i]; - sync_object_init_field(o, &chest->oAction); - sync_object_init_field(o, &chest->oPrevAction); - sync_object_init_field(o, &chest->oTimer); - sync_object_init_field(o, &chest->oIntangibleTimer); + sync_object_init_field(o, chest->oAction); + sync_object_init_field(o, chest->oPrevAction); + sync_object_init_field(o, chest->oTimer); + sync_object_init_field(o, chest->oIntangibleTimer); } } } diff --git a/src/game/behaviors/ttc_2d_rotator.inc.c b/src/game/behaviors/ttc_2d_rotator.inc.c index c4b04cc17..fa619de4d 100644 --- a/src/game/behaviors/ttc_2d_rotator.inc.c +++ b/src/game/behaviors/ttc_2d_rotator.inc.c @@ -45,12 +45,12 @@ void bhv_ttc_2d_rotator_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oTTC2DRotatorMinTimeUntilNextTurn); - sync_object_init_field(o, &o->oTTC2DRotatorTargetYaw); - sync_object_init_field(o, &o->oTTC2DRotatorIncrement); - sync_object_init_field(o, &o->oTTC2DRotatorRandomDirTimer); - sync_object_init_field(o, &o->oFaceAngleYaw); - sync_object_init_field(o, &o->oAngleVelYaw); + sync_object_init_field(o, o->oTTC2DRotatorMinTimeUntilNextTurn); + sync_object_init_field(o, o->oTTC2DRotatorTargetYaw); + sync_object_init_field(o, o->oTTC2DRotatorIncrement); + sync_object_init_field(o, o->oTTC2DRotatorRandomDirTimer); + sync_object_init_field(o, o->oFaceAngleYaw); + sync_object_init_field(o, o->oAngleVelYaw); } } diff --git a/src/game/behaviors/ttc_cog.inc.c b/src/game/behaviors/ttc_cog.inc.c index 28e8cea9c..8e40d1c60 100644 --- a/src/game/behaviors/ttc_cog.inc.c +++ b/src/game/behaviors/ttc_cog.inc.c @@ -33,10 +33,10 @@ void bhv_ttc_cog_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oTTCCogSpeed); - sync_object_init_field(o, &o->oTTCCogTargetVel); - sync_object_init_field(o, &o->oAngleVelYaw); - sync_object_init_field(o, &o->oFaceAngleYaw); + sync_object_init_field(o, o->oTTCCogSpeed); + sync_object_init_field(o, o->oTTCCogTargetVel); + sync_object_init_field(o, o->oAngleVelYaw); + sync_object_init_field(o, o->oFaceAngleYaw); } } diff --git a/src/game/behaviors/ttc_elevator.inc.c b/src/game/behaviors/ttc_elevator.inc.c index dae353564..622af0649 100644 --- a/src/game/behaviors/ttc_elevator.inc.c +++ b/src/game/behaviors/ttc_elevator.inc.c @@ -27,8 +27,8 @@ void bhv_ttc_elevator_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oTTCElevatorDir); - sync_object_init_field(o, &o->oTTCElevatorMoveTime); + sync_object_init_field(o, o->oTTCElevatorDir); + sync_object_init_field(o, o->oTTCElevatorMoveTime); } } diff --git a/src/game/behaviors/ttc_moving_bar.inc.c b/src/game/behaviors/ttc_moving_bar.inc.c index dbe28ecad..c6583ec23 100644 --- a/src/game/behaviors/ttc_moving_bar.inc.c +++ b/src/game/behaviors/ttc_moving_bar.inc.c @@ -37,11 +37,11 @@ void bhv_ttc_moving_bar_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oTTCMovingBarDelay); - sync_object_init_field(o, &o->oTTCMovingBarStoppedTimer); - sync_object_init_field(o, &o->oTTCMovingBarOffset); - sync_object_init_field(o, &o->oTTCMovingBarSpeed); - sync_object_init_field(o, &o->oTTCMovingBarStartOffset); + sync_object_init_field(o, o->oTTCMovingBarDelay); + sync_object_init_field(o, o->oTTCMovingBarStoppedTimer); + sync_object_init_field(o, o->oTTCMovingBarOffset); + sync_object_init_field(o, o->oTTCMovingBarSpeed); + sync_object_init_field(o, o->oTTCMovingBarStartOffset); } } diff --git a/src/game/behaviors/ttc_pendulum.inc.c b/src/game/behaviors/ttc_pendulum.inc.c index 1fd4e0edc..0f743ae03 100644 --- a/src/game/behaviors/ttc_pendulum.inc.c +++ b/src/game/behaviors/ttc_pendulum.inc.c @@ -28,12 +28,12 @@ void bhv_ttc_pendulum_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oTTCPendulumAccelDir); - sync_object_init_field(o, &o->oTTCPendulumAngle); - sync_object_init_field(o, &o->oTTCPendulumAngleVel); - sync_object_init_field(o, &o->oTTCPendulumAngleAccel); - sync_object_init_field(o, &o->oTTCPendulumDelay); - sync_object_init_field(o, &o->oTTCPendulumSoundTimer); + sync_object_init_field(o, o->oTTCPendulumAccelDir); + sync_object_init_field(o, o->oTTCPendulumAngle); + sync_object_init_field(o, o->oTTCPendulumAngleVel); + sync_object_init_field(o, o->oTTCPendulumAngleAccel); + sync_object_init_field(o, o->oTTCPendulumDelay); + sync_object_init_field(o, o->oTTCPendulumSoundTimer); } } diff --git a/src/game/behaviors/ttc_pit_block.inc.c b/src/game/behaviors/ttc_pit_block.inc.c index 62a902c9c..c0789e6c4 100644 --- a/src/game/behaviors/ttc_pit_block.inc.c +++ b/src/game/behaviors/ttc_pit_block.inc.c @@ -50,8 +50,8 @@ void bhv_ttc_pit_block_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oTTCPitBlockDir); - sync_object_init_field(o, &o->oTTCPitBlockWaitTime); + sync_object_init_field(o, o->oTTCPitBlockDir); + sync_object_init_field(o, o->oTTCPitBlockWaitTime); } } diff --git a/src/game/behaviors/ttc_rotating_solid.inc.c b/src/game/behaviors/ttc_rotating_solid.inc.c index 98673092f..f15a94a85 100644 --- a/src/game/behaviors/ttc_rotating_solid.inc.c +++ b/src/game/behaviors/ttc_rotating_solid.inc.c @@ -37,12 +37,12 @@ void bhv_ttc_rotating_solid_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oTTCRotatingSolidNumTurns); - sync_object_init_field(o, &o->oTTCRotatingSolidRotationDelay); - sync_object_init_field(o, &o->oTTCRotatingSolidVelY); - sync_object_init_field(o, &o->oTTCChangeDirTimer); - sync_object_init_field(o, &o->oAngleVelRoll); - sync_object_init_field(o, &o->oFaceAngleRoll); + sync_object_init_field(o, o->oTTCRotatingSolidNumTurns); + sync_object_init_field(o, o->oTTCRotatingSolidRotationDelay); + sync_object_init_field(o, o->oTTCRotatingSolidVelY); + sync_object_init_field(o, o->oTTCChangeDirTimer); + sync_object_init_field(o, o->oAngleVelRoll); + sync_object_init_field(o, o->oFaceAngleRoll); } } diff --git a/src/game/behaviors/ttc_spinner.inc.c b/src/game/behaviors/ttc_spinner.inc.c index 7840f0a21..70a90132a 100644 --- a/src/game/behaviors/ttc_spinner.inc.c +++ b/src/game/behaviors/ttc_spinner.inc.c @@ -21,10 +21,10 @@ void bhv_ttc_spinner_update(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oAngleVelPitch); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oTTCSpinnerDir); - sync_object_init_field(o, &o->oTTCChangeDirTimer); + sync_object_init_field(o, o->oAngleVelPitch); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oTTCSpinnerDir); + sync_object_init_field(o, o->oTTCChangeDirTimer); } } diff --git a/src/game/behaviors/ttc_treadmill.inc.c b/src/game/behaviors/ttc_treadmill.inc.c index e5fe34446..b504f53f7 100644 --- a/src/game/behaviors/ttc_treadmill.inc.c +++ b/src/game/behaviors/ttc_treadmill.inc.c @@ -37,9 +37,9 @@ void bhv_ttc_treadmill_init(void) { struct SyncObject* so = sync_object_init(o, 4000.0f); if (so) { so->minUpdateRate = 5.0f; - sync_object_init_field(o, &o->oTTCTreadmillSpeed); - sync_object_init_field(o, &o->oTTCTreadmillTargetSpeed); - sync_object_init_field(o, &o->oTTCTreadmillTimeUntilSwitch); + sync_object_init_field(o, o->oTTCTreadmillSpeed); + sync_object_init_field(o, o->oTTCTreadmillTargetSpeed); + sync_object_init_field(o, o->oTTCTreadmillTimeUntilSwitch); } } diff --git a/src/game/behaviors/tumbling_bridge.inc.c b/src/game/behaviors/tumbling_bridge.inc.c index 9c1dd40e6..b90368657 100644 --- a/src/game/behaviors/tumbling_bridge.inc.c +++ b/src/game/behaviors/tumbling_bridge.inc.c @@ -17,17 +17,17 @@ void bhv_tumbling_bridge_platform_loop(void) { if (isLLL && !sync_object_is_initialized(o->oSyncID)) { struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field_with_size(o, &o->activeFlags, 16); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPosX); - sync_object_init_field(o, &o->oPosY); - sync_object_init_field(o, &o->oPosZ); - sync_object_init_field(o, &o->oVelX); - sync_object_init_field(o, &o->oVelY); - sync_object_init_field(o, &o->oVelZ); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oFaceAngleYaw); - sync_object_init_field(o, &o->oFaceAngleRoll); + sync_object_init_field(o, o->activeFlags); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPosX); + sync_object_init_field(o, o->oPosY); + sync_object_init_field(o, o->oPosZ); + sync_object_init_field(o, o->oVelX); + sync_object_init_field(o, o->oVelY); + sync_object_init_field(o, o->oVelZ); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oFaceAngleYaw); + sync_object_init_field(o, o->oFaceAngleRoll); } } @@ -161,7 +161,7 @@ void bhv_tumbling_bridge_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { - sync_object_init_field(o, &o->oIntangibleTimer); + sync_object_init_field(o, o->oIntangibleTimer); } } diff --git a/src/game/behaviors/tuxie.inc.c b/src/game/behaviors/tuxie.inc.c index d7df6d94f..56f2338f8 100644 --- a/src/game/behaviors/tuxie.inc.c +++ b/src/game/behaviors/tuxie.inc.c @@ -155,8 +155,8 @@ void (*sTuxiesMotherActions[])(void) = { tuxies_mother_act_0, tuxies_mother_act_ void bhv_tuxies_mother_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oSubAction); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oSubAction); } o->activeFlags |= ACTIVE_FLAG_UNK10; cur_obj_update_floor_and_walls(); diff --git a/src/game/behaviors/tweester.inc.c b/src/game/behaviors/tweester.inc.c index 854b0d43f..950d48bf6 100644 --- a/src/game/behaviors/tweester.inc.c +++ b/src/game/behaviors/tweester.inc.c @@ -141,11 +141,11 @@ void (*sTweesterActions[])(void) = { tweester_act_idle, tweester_act_chase, twee void bhv_tweester_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oTweesterScaleTimer); - sync_object_init_field(o, &o->header.gfx.scale[0]); - sync_object_init_field(o, &o->header.gfx.scale[1]); - sync_object_init_field(o, &o->header.gfx.scale[2]); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oTweesterScaleTimer); + sync_object_init_field(o, o->header.gfx.scale[0]); + sync_object_init_field(o, o->header.gfx.scale[1]); + sync_object_init_field(o, o->header.gfx.scale[2]); } obj_set_hitbox(o, &sTweesterHitbox); diff --git a/src/game/behaviors/ukiki.inc.c b/src/game/behaviors/ukiki.inc.c index 18db835ef..94124d606 100644 --- a/src/game/behaviors/ukiki.inc.c +++ b/src/game/behaviors/ukiki.inc.c @@ -659,11 +659,11 @@ void bhv_ukiki_init(void) { } sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oUkikiTauntCounter); - sync_object_init_field(o, &o->oUkikiChaseFleeRange); - sync_object_init_field(o, &o->oUkikiCageSpinTimer); - sync_object_init_field(o, &o->oIntangibleTimer); - sync_object_init_field_with_size(o, &o->globalPlayerIndex, 8); + sync_object_init_field(o, o->oUkikiTauntCounter); + sync_object_init_field(o, o->oUkikiChaseFleeRange); + sync_object_init_field(o, o->oUkikiCageSpinTimer); + sync_object_init_field(o, o->oIntangibleTimer); + sync_object_init_field(o, o->globalPlayerIndex); } /** diff --git a/src/game/behaviors/unagi.inc.c b/src/game/behaviors/unagi.inc.c index 4f8db9715..e925f5a98 100644 --- a/src/game/behaviors/unagi.inc.c +++ b/src/game/behaviors/unagi.inc.c @@ -31,21 +31,21 @@ void bhv_unagi_init(void) { o->oPathedPrevWaypoint = o->oPathedStartWaypoint; sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oFaceAngleRoll); - sync_object_init_field(o, &o->oFaceAngleYaw); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oMoveAnglePitch); - sync_object_init_field(o, &o->oPathedPrevWaypointFlags); - sync_object_init_field(o, &o->oPathedTargetPitch); - sync_object_init_field(o, &o->oPathedTargetYaw); - sync_object_init_field(o, &o->oSoundStateID); - sync_object_init_field(o, &o->oUnagiUnk110); - sync_object_init_field(o, &o->oUnagiUnk1AC); - sync_object_init_field(o, &o->oUnagiUnkF4); - sync_object_init_field(o, &o->oUnagiUnkF8); - sync_object_init_field(o, &o->oVelX); - sync_object_init_field(o, &o->oVelZ); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oFaceAngleRoll); + sync_object_init_field(o, o->oFaceAngleYaw); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oMoveAnglePitch); + sync_object_init_field(o, o->oPathedPrevWaypointFlags); + sync_object_init_field(o, o->oPathedTargetPitch); + sync_object_init_field(o, o->oPathedTargetYaw); + sync_object_init_field(o, o->oSoundStateID); + sync_object_init_field(o, o->oUnagiUnk110); + sync_object_init_field(o, o->oUnagiUnk1AC); + sync_object_init_field(o, o->oUnagiUnkF4); + sync_object_init_field(o, o->oUnagiUnkF8); + sync_object_init_field(o, o->oVelX); + sync_object_init_field(o, o->oVelZ); } void unagi_act_0(void) { diff --git a/src/game/behaviors/water_bomb.inc.c b/src/game/behaviors/water_bomb.inc.c index fe6c0488e..18931143f 100644 --- a/src/game/behaviors/water_bomb.inc.c +++ b/src/game/behaviors/water_bomb.inc.c @@ -34,8 +34,8 @@ void bhv_water_bomb_spawner_update(void) { if (so) { so->fullObjectSync = TRUE; so->maxUpdateRate = 5.0f; - sync_object_init_field(o, &o->oWaterBombSpawnerBombActive); - sync_object_init_field(o, &o->oWaterBombSpawnerTimeToSpawn); + sync_object_init_field(o, o->oWaterBombSpawnerBombActive); + sync_object_init_field(o, o->oWaterBombSpawnerTimeToSpawn); } } diff --git a/src/game/behaviors/water_pillar.inc.c b/src/game/behaviors/water_pillar.inc.c index aced8cb05..70d1bf897 100644 --- a/src/game/behaviors/water_pillar.inc.c +++ b/src/game/behaviors/water_pillar.inc.c @@ -69,10 +69,10 @@ void bhv_water_level_pillar_init(void) { struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so) { so->ignore_if_true = bhv_water_level_pillar_ignore_if_true; - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); - sync_object_init_field(o, &o->oWaterLevelPillarDrained); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); + sync_object_init_field(o, o->oWaterLevelPillarDrained); } } diff --git a/src/game/behaviors/water_ring.inc.c b/src/game/behaviors/water_ring.inc.c index 9e9a33680..07e69e8cb 100644 --- a/src/game/behaviors/water_ring.inc.c +++ b/src/game/behaviors/water_ring.inc.c @@ -186,10 +186,10 @@ void water_ring_spawner_act_inactive(void) { void bhv_jet_stream_ring_spawner_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); - sync_object_init_field(o, &o->oWaterRingSpawnerRingsCollected); - sync_object_init_field(o, &o->oAction); - sync_object_init_field(o, &o->oPrevAction); - sync_object_init_field(o, &o->oTimer); + sync_object_init_field(o, o->oWaterRingSpawnerRingsCollected); + sync_object_init_field(o, o->oAction); + sync_object_init_field(o, o->oPrevAction); + sync_object_init_field(o, o->oTimer); } switch (o->oAction) { diff --git a/src/game/behaviors/wdw_water_level.inc.c b/src/game/behaviors/wdw_water_level.inc.c index d3dd7c2f5..95e292afa 100644 --- a/src/game/behaviors/wdw_water_level.inc.c +++ b/src/game/behaviors/wdw_water_level.inc.c @@ -18,7 +18,7 @@ void bhv_init_changing_water_level_loop(void) { struct SyncObject* so = sync_object_init(o, SYNC_DISTANCE_ONLY_EVENTS); if (so != NULL) { so->on_received_post = bhv_init_changing_water_level_on_received_post; - sync_object_init_field(o, &sWaterDiamondPicked); + sync_object_init_field(o, sWaterDiamondPicked); } } diff --git a/src/game/behaviors/whomp.inc.c b/src/game/behaviors/whomp.inc.c index 3c8f89790..ba00e33a2 100644 --- a/src/game/behaviors/whomp.inc.c +++ b/src/game/behaviors/whomp.inc.c @@ -276,11 +276,11 @@ void (*sWhompActions[])(void) = { void bhv_whomp_loop(void) { if (!sync_object_is_initialized(o->oSyncID)) { sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oAngleVelPitch); - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oForwardVel); - sync_object_init_field(o, &o->oHealth); - sync_object_init_field(o, &o->oFaceAnglePitch); + sync_object_init_field(o, o->oAngleVelPitch); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oForwardVel); + sync_object_init_field(o, o->oHealth); + sync_object_init_field(o, o->oFaceAnglePitch); } cur_obj_update_floor_and_walls(); diff --git a/src/game/behaviors/wiggler.inc.c b/src/game/behaviors/wiggler.inc.c index 59a4ac9b1..3a60b91ac 100644 --- a/src/game/behaviors/wiggler.inc.c +++ b/src/game/behaviors/wiggler.inc.c @@ -468,18 +468,18 @@ void bhv_wiggler_update(void) { so->ignore_if_true = bhv_wiggler_ignore_if_true; so->on_received_pre = bhv_wiggler_on_received_pre; so->on_received_post = bhv_wiggler_on_received_post; - sync_object_init_field(o, &o->oFaceAnglePitch); - sync_object_init_field(o, &o->oWigglerFallThroughFloorsHeight); - sync_object_init_field(o, &o->oWigglerWalkAnimSpeed); - sync_object_init_field(o, &o->oWigglerSquishSpeed); - sync_object_init_field(o, &o->oWigglerTimeUntilRandomTurn); - sync_object_init_field(o, &o->oWigglerTargetYaw); - sync_object_init_field(o, &o->oWigglerWalkAwayFromWallTimer); - sync_object_init_field(o, &o->oHealth); - sync_object_init_field(o, &o->header.gfx.scale[0]); - sync_object_init_field(o, &o->header.gfx.scale[1]); - sync_object_init_field(o, &o->header.gfx.scale[2]); - sync_object_init_field(o, &o->oFaceAngleYaw); + sync_object_init_field(o, o->oFaceAnglePitch); + sync_object_init_field(o, o->oWigglerFallThroughFloorsHeight); + sync_object_init_field(o, o->oWigglerWalkAnimSpeed); + sync_object_init_field(o, o->oWigglerSquishSpeed); + sync_object_init_field(o, o->oWigglerTimeUntilRandomTurn); + sync_object_init_field(o, o->oWigglerTargetYaw); + sync_object_init_field(o, o->oWigglerWalkAwayFromWallTimer); + sync_object_init_field(o, o->oHealth); + sync_object_init_field(o, o->header.gfx.scale[0]); + sync_object_init_field(o, o->header.gfx.scale[1]); + sync_object_init_field(o, o->header.gfx.scale[2]); + sync_object_init_field(o, o->oFaceAngleYaw); } } diff --git a/src/game/behaviors/yoshi.inc.c b/src/game/behaviors/yoshi.inc.c index b385e4687..3bcf898c8 100644 --- a/src/game/behaviors/yoshi.inc.c +++ b/src/game/behaviors/yoshi.inc.c @@ -23,12 +23,12 @@ void bhv_yoshi_init(void) { } sync_object_init(o, 4000.0f); - sync_object_init_field(o, &o->oYoshiBlinkTimer); - sync_object_init_field(o, &o->oYoshiChosenHome); - sync_object_init_field(o, &o->oYoshiTargetYaw); - sync_object_init_field(o, &o->oHomeX); - sync_object_init_field(o, &o->oHomeY); - sync_object_init_field(o, &o->oHomeZ); + sync_object_init_field(o, o->oYoshiBlinkTimer); + sync_object_init_field(o, o->oYoshiChosenHome); + sync_object_init_field(o, o->oYoshiTargetYaw); + sync_object_init_field(o, o->oHomeX); + sync_object_init_field(o, o->oHomeY); + sync_object_init_field(o, o->oHomeZ); } void yoshi_walk_loop(void) { diff --git a/src/game/camera.c b/src/game/camera.c index 9983130d9..962e0fb3e 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -1781,7 +1781,7 @@ s32 unused_update_mode_5_camera(UNUSED struct Camera *c, UNUSED Vec3f focus, UNU return 0; } -static void stub_camera_1(UNUSED s32 unused) { +UNUSED static void stub_camera_1(UNUSED s32 unused) { } void mode_boss_fight_camera(struct Camera *c) { @@ -5614,7 +5614,7 @@ void set_focus_rel_mario(struct Camera *c, f32 leftRight, f32 yOff, f32 forwBack * @param forwBack offset to Mario's front/back, relative to his faceAngle * @param yawOff offset to Mario's faceAngle, changes the direction of `leftRight` and `forwBack` */ -static void unused_set_pos_rel_mario(struct Camera *c, f32 leftRight, f32 yOff, f32 forwBack, s16 yawOff) { +UNUSED static void unused_set_pos_rel_mario(struct Camera *c, f32 leftRight, f32 yOff, f32 forwBack, s16 yawOff) { if (!c) { return; } u16 yaw = sMarioCamState->faceAngle[1] + yawOff; @@ -7606,7 +7606,7 @@ void cutscene_unsoften_music(UNUSED struct Camera *c) { seq_player_unlower_volume(SEQ_PLAYER_LEVEL, 60); } -static void stub_camera_5(UNUSED struct Camera *c) { +UNUSED static void stub_camera_5(UNUSED struct Camera *c) { } BAD_RETURN(s32) cutscene_unused_start(UNUSED struct Camera *c) { @@ -8133,7 +8133,7 @@ BAD_RETURN(s32) cutscene_dance_rotate_move_towards_mario(struct Camera *c) { /** * Speculated to be dance-related due to its proximity to the other dance functions */ -static BAD_RETURN(s32) cutscene_dance_unused(UNUSED struct Camera *c) { +UNUSED static BAD_RETURN(s32) cutscene_dance_unused(UNUSED struct Camera *c) { } /** @@ -9089,7 +9089,7 @@ BAD_RETURN(s32) cutscene_death_stomach_goto_mario(struct Camera *c) { /** * Ah, yes */ -static void unused_water_death_move_to_side_of_mario(struct Camera *c) { +UNUSED static void unused_water_death_move_to_side_of_mario(struct Camera *c) { water_death_move_to_mario_side(c); } @@ -9377,7 +9377,7 @@ BAD_RETURN(s32) cutscene_enter_pyramid_top(struct Camera *c) { } } -static void unused_cutscene_goto_cvar(struct Camera *c) { +UNUSED static void unused_cutscene_goto_cvar(struct Camera *c) { if (!c) { return; } f32 dist; @@ -9543,7 +9543,7 @@ BAD_RETURN(s32) cutscene_read_message_start(struct Camera *c) { sCutsceneVars[0].angle[0] = 0; } -static void unused_cam_to_mario(struct Camera *c) { +UNUSED static void unused_cam_to_mario(struct Camera *c) { if (!c) { return; } Vec3s dir; @@ -10972,7 +10972,7 @@ void cutscene_palette_editor(struct Camera *c) { &gDjuiPaletteToggle->base, ( m->action == ACT_IDLE || - m->action == ACT_PALETTE_EDITOR_CAP + m->action == ACT_PALETTE_EDITOR_CAP ) && !capMissing ); } diff --git a/src/game/characters.c b/src/game/characters.c index 9e359ebef..40689a8d0 100644 --- a/src/game/characters.c +++ b/src/game/characters.c @@ -248,7 +248,7 @@ struct Character gCharacters[CT_MAX] = { .animOffsetEnabled = false, // sounds - .soundFreqScale = 0.99f, + .soundFreqScale = 0.88f, .soundYahWahHoo = SOUND_LUIGI_YAH_WAH_HOO, .soundHoohoo = SOUND_LUIGI_HOOHOO, .soundYahoo = SOUND_LUIGI_YAHOO, diff --git a/src/game/interaction.c b/src/game/interaction.c index d81651099..4304a23ae 100644 --- a/src/game/interaction.c +++ b/src/game/interaction.c @@ -643,7 +643,9 @@ static u32 unused_determine_knockback_action(struct MarioState *m) { return bonkAction; } -u32 determine_knockback_action(struct MarioState *m, UNUSED s32 arg) { +u32 determine_knockback_action(struct MarioState *m, RET bool *isPlayerAttack) { + *isPlayerAttack = false; + if (!m) { return 0; } if (m->interactObj == NULL) { return sForwardKnockbackActions[0][0]; @@ -739,6 +741,7 @@ u32 determine_knockback_action(struct MarioState *m, UNUSED s32 arg) { m->knockbackTimer = hasBeenPunched ? PVP_ATTACK_KNOCKBACK_TIMER_OVERRIDE : PVP_ATTACK_KNOCKBACK_TIMER_DEFAULT; #undef IF_REVAMPED_PVP m->faceAngle[1] = m->interactObj->oFaceAngleYaw + (sign == 1.0f ? 0 : 0x8000); + *isPlayerAttack = true; } return bonkAction; @@ -870,7 +873,10 @@ u32 take_damage_and_knock_back(struct MarioState *m, struct Object *o) { } update_mario_sound_and_camera(m); - return drop_and_set_mario_action(m, determine_knockback_action(m, o->oDamageOrCoinValue), damage); + + bool isPlayerAttack = false; + u32 knockbackAction = determine_knockback_action(m, &isPlayerAttack); + return drop_and_set_mario_action(m, knockbackAction, damage | (isPlayerAttack ? PVP_ATTACK_KNOCKBACK_ACTION_ARG : 0)); } return FALSE; @@ -1724,8 +1730,9 @@ u32 interact_snufit_bullet(struct MarioState *m, UNUSED u32 interactType, struct play_character_sound(m, CHAR_SOUND_ATTACKED); update_mario_sound_and_camera(m); - return drop_and_set_mario_action(m, determine_knockback_action(m, o->oDamageOrCoinValue), - o->oDamageOrCoinValue); + bool isPlayerAttack = false; + u32 knockbackAction = determine_knockback_action(m, &isPlayerAttack); + return drop_and_set_mario_action(m, knockbackAction, o->oDamageOrCoinValue | (isPlayerAttack ? PVP_ATTACK_KNOCKBACK_ACTION_ARG : 0)); } } diff --git a/src/game/interaction.h b/src/game/interaction.h index 7dfe20a74..d06e9a795 100644 --- a/src/game/interaction.h +++ b/src/game/interaction.h @@ -101,7 +101,7 @@ enum InteractionFlag { #define PVP_ATTACK_KNOCKBACK_TIMER_DEFAULT 10 #define PVP_ATTACK_KNOCKBACK_TIMER_OVERRIDE -5 -#define PVP_ATTACK_OVERRIDE_VANILLA_INVINCIBILITY 0x0000FFFF +#define PVP_ATTACK_KNOCKBACK_ACTION_ARG 0x10000 #define INT_STATUS_ATTACK_MASK 0x000000FF diff --git a/src/game/level_info.c b/src/game/level_info.c index 0482d4866..b752fdc28 100644 --- a/src/game/level_info.c +++ b/src/game/level_info.c @@ -153,7 +153,7 @@ static const char *ascii_to_sm64_char(u8 *str64, const char *strAscii, bool menu if (menu && !ch->menu) { continue; } - if (memcmp(strAscii, ch->str, ch->len) == 0) { + if (strncmp(strAscii, ch->str, ch->len) == 0) { *str64 = ch->c; return strAscii + ch->len; } diff --git a/src/game/level_update.c b/src/game/level_update.c index 7a69632d3..1ad390601 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -18,6 +18,7 @@ #include "sound_init.h" #include "mario.h" #include "camera.h" +#include "bettercamera.h" #include "object_list_processor.h" #include "ingame_menu.h" #include "obj_behaviors.h" @@ -471,6 +472,14 @@ void init_mario_after_warp(void) { if (gCurrentArea) { reset_camera(gCurrentArea->camera); + if (sWarpDest.type == WARP_TYPE_SAME_AREA && gCurrentArea->camera->mode == CAMERA_MODE_NEWCAM) { + // When we warp to a level in the same area, the camera mode never has the chance + // to reset. This is bad if our camera mode is newcam, since when init cam is called + // our old camera mode will be set to newcam, which causes newcam to not be able to be + // turned off. The fix is setting our mode to newcam's old mode + gCurrentArea->camera->mode = gNewCamera.savedMode; + gCurrentArea->camera->defMode = gNewCamera.savedDefMode; + } } sWarpDest.type = WARP_TYPE_NOT_WARPING; sDelayedWarpOp = WARP_OP_NONE; diff --git a/src/game/mario.c b/src/game/mario.c index 2c1e6c56b..897bbc3fe 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -1043,6 +1043,29 @@ static u32 set_mario_action_airborne(struct MarioState *m, u32 action, u32 actio case ACT_JUMP_KICK: m->vel[1] = 20.0f; break; + + // Set forward vel to a predefined value for non-player knockbacks + case ACT_BACKWARD_AIR_KB: + case ACT_HARD_BACKWARD_AIR_KB: + if (!(actionArg & PVP_ATTACK_KNOCKBACK_ACTION_ARG)) { + mario_set_forward_vel(m, -16.0f); + } + break; + + case ACT_FORWARD_AIR_KB: + case ACT_HARD_FORWARD_AIR_KB: + if (!(actionArg & PVP_ATTACK_KNOCKBACK_ACTION_ARG)) { + mario_set_forward_vel(m, 16.0f); + } + break; + + case ACT_THROWN_BACKWARD: + case ACT_THROWN_FORWARD: + case ACT_SOFT_BONK: + if (!(actionArg & PVP_ATTACK_KNOCKBACK_ACTION_ARG)) { + mario_set_forward_vel(m, m->forwardVel); // needed to update velocities + } + break; } m->peakHeight = m->pos[1]; @@ -2221,6 +2244,7 @@ void init_single_mario(struct MarioState* m) { m->heldObj = NULL; m->heldByObj = NULL; + m->interactObj = NULL; m->riddenObj = NULL; m->usedObj = NULL; m->bubbleObj = NULL; diff --git a/src/game/mario_actions_airborne.c b/src/game/mario_actions_airborne.c index 5bf71f395..00b338447 100644 --- a/src/game/mario_actions_airborne.c +++ b/src/game/mario_actions_airborne.c @@ -57,7 +57,7 @@ depending on whether Mario's forward velocity is high enough to be considered a |descriptionEnd| */ void play_knockback_sound(struct MarioState *m) { if (!m) { return; } - if (m->actionArg == 0 && (m->forwardVel <= -28.0f || m->forwardVel >= 28.0f)) { + if ((m->actionArg & ~PVP_ATTACK_KNOCKBACK_ACTION_ARG) == 0 && (m->forwardVel <= -28.0f || m->forwardVel >= 28.0f)) { play_character_sound_if_no_flag(m, CHAR_SOUND_DOH, MARIO_MARIO_SOUND_PLAYED); } else { play_character_sound_if_no_flag(m, CHAR_SOUND_UH, MARIO_MARIO_SOUND_PLAYED); @@ -1236,13 +1236,8 @@ u32 common_air_knockback_step(struct MarioState *m, u32 landAction, u32 hardFall if (!m) { return 0; } u32 stepResult; - if (m->knockbackTimer == 0) { - if (m->interactObj == NULL || !(m->interactObj->oInteractType & INTERACT_PLAYER)) { - mario_set_forward_vel(m, speed); - } - } else if (m->knockbackTimer < 0) { - // do nothing - } else { + // Refresh knockbackTimer + if (m->knockbackTimer > 0) { m->knockbackTimer = PVP_ATTACK_KNOCKBACK_TIMER_DEFAULT; } @@ -1356,7 +1351,7 @@ s32 act_hard_forward_air_kb(struct MarioState *m) { s32 act_thrown_backward(struct MarioState *m) { if (!m) { return 0; } u32 landAction; - if (m->actionArg != 0) { + if ((m->actionArg & ~PVP_ATTACK_KNOCKBACK_ACTION_ARG) != 0) { landAction = ACT_HARD_BACKWARD_GROUND_KB; } else { landAction = ACT_BACKWARD_GROUND_KB; @@ -1375,7 +1370,7 @@ s32 act_thrown_forward(struct MarioState *m) { s16 pitch; u32 landAction; - if (m->actionArg != 0) { + if ((m->actionArg & ~PVP_ATTACK_KNOCKBACK_ACTION_ARG) != 0) { landAction = ACT_HARD_FORWARD_GROUND_KB; } else { landAction = ACT_FORWARD_GROUND_KB; diff --git a/src/game/mario_actions_cutscene.c b/src/game/mario_actions_cutscene.c index 8d598b313..9162cd84a 100644 --- a/src/game/mario_actions_cutscene.c +++ b/src/game/mario_actions_cutscene.c @@ -1825,11 +1825,17 @@ s32 act_squished(struct MarioState *m) { if (m->actionTimer >= 15) { // 1 unit of health if (m->health < 0x0100) { - //level_trigger_warp(m, WARP_OP_DEATH); - // woosh, he's gone! - //set_mario_action(m, ACT_DISAPPEARED, 0); - drop_and_set_mario_action(m, ACT_DEATH_ON_BACK, 0); - m->squishTimer = 0; + bool allowDeath = true; + smlua_call_event_hooks(HOOK_ON_DEATH, m, &allowDeath); + if (!allowDeath) { return FALSE; } + + if (mario_can_bubble(m)) { + mario_set_bubbled(m); + } else { + level_trigger_warp(m, WARP_OP_DEATH); + // woosh, he's gone! + set_mario_action(m, ACT_DISAPPEARED, 0); + } } else if (m->hurtCounter == 0) { // un-squish animation m->squishTimer = 30; diff --git a/src/game/mario_actions_moving.c b/src/game/mario_actions_moving.c index 6a21d45d5..c502e5f31 100644 --- a/src/game/mario_actions_moving.c +++ b/src/game/mario_actions_moving.c @@ -1775,12 +1775,13 @@ Handles knockback on the ground (getting hit while on the ground) with shared lo s32 common_ground_knockback_action(struct MarioState *m, s32 animation, s32 arg2, s32 arg3, s32 arg4) { if (!m) { return 0; } s32 animFrame; + s32 damage = arg4 & ~PVP_ATTACK_KNOCKBACK_ACTION_ARG; if (arg3) { play_mario_heavy_landing_sound_once(m, SOUND_ACTION_TERRAIN_BODY_HIT_GROUND); } - if (arg4 > 0) { + if (damage > 0) { play_character_sound_if_no_flag(m, CHAR_SOUND_ATTACKED, MARIO_MARIO_SOUND_PLAYED); } else { #ifdef VERSION_JP @@ -1790,18 +1791,18 @@ s32 common_ground_knockback_action(struct MarioState *m, s32 animation, s32 arg2 #endif } - if (m->knockbackTimer == 0) { - if (m->interactObj == NULL || !(m->interactObj->oInteractType & INTERACT_PLAYER)) { - if (m->forwardVel > 32.0f) { - m->forwardVel = 32.0f; - } - if (m->forwardVel < -32.0f) { - m->forwardVel = -32.0f; - } + // Cap speed if it's not a PVP attack + if (!(arg4 & PVP_ATTACK_KNOCKBACK_ACTION_ARG)) { + if (m->forwardVel > 32.0f) { + m->forwardVel = 32.0f; } - } else if (m->knockbackTimer < 0) { - // do nothing - } else { + if (m->forwardVel < -32.0f) { + m->forwardVel = -32.0f; + } + } + + // Refresh knockbackTimer + if (m->knockbackTimer > 0) { m->knockbackTimer = PVP_ATTACK_KNOCKBACK_TIMER_DEFAULT; } @@ -1824,7 +1825,7 @@ s32 common_ground_knockback_action(struct MarioState *m, s32 animation, s32 arg2 if (m->health < 0x100) { set_mario_action(m, ACT_STANDING_DEATH, 0); } else { - if (arg4 > 0) { + if (damage > 0) { m->invincTimer = 30; } set_mario_action(m, ACT_IDLE, 0); diff --git a/src/game/mario_misc.c b/src/game/mario_misc.c index 7cb509211..435863e2f 100644 --- a/src/game/mario_misc.c +++ b/src/game/mario_misc.c @@ -334,13 +334,13 @@ static Gfx *make_gfx_mario_alpha(struct GraphNodeGenerated *node, s16 alpha) { } // Calculates if the processing geo is a mirror mario -static s8 geo_get_processing_mirror_mario_index() { - ptrdiff_t ptrDiff = (struct GraphNodeObject *) gCurGraphNodeProcessingObject - gMirrorMario; +static s8 geo_get_processing_mirror_mario_index(struct Object *obj) { + ptrdiff_t ptrDiff = (struct GraphNodeObject *) obj - gMirrorMario; return (ptrDiff >= 0 && ptrDiff < MAX_PLAYERS) ? ptrDiff : -1; } static u8 geo_get_processing_object_index(void) { - s8 index = geo_get_processing_mirror_mario_index(); + s8 index = geo_get_processing_mirror_mario_index(gCurGraphNodeProcessingObject); if (index != -1) { return index; } @@ -351,19 +351,19 @@ static u8 geo_get_processing_object_index(void) { return (index >= MAX_PLAYERS) ? 0 : index; } -s8 geo_get_processing_mario_index(void) { - if (gCurGraphNodeProcessingObject == NULL) { return -1; } +s8 geo_get_processing_mario_index(struct Object *obj) { + if (obj == NULL) { return -1; } - s8 index = geo_get_processing_mirror_mario_index(); + s8 index = geo_get_processing_mirror_mario_index(obj); if (index != -1) { return index; } - if (gCurGraphNodeProcessingObject->behavior != bhvMario) { + if (obj->behavior != bhvMario) { return -1; } - index = gCurGraphNodeProcessingObject->oBehParams - 1; + index = obj->oBehParams - 1; return (index >= MAX_PLAYERS) ? -1 : index; } diff --git a/src/game/object_helpers.c b/src/game/object_helpers.c index 695a3fbd0..f0bf4d162 100644 --- a/src/game/object_helpers.c +++ b/src/game/object_helpers.c @@ -2942,19 +2942,27 @@ void bhv_init_room(void) { void cur_obj_enable_rendering_if_mario_in_room(void) { if (!o) { return; } if (o->oRoom == -1) { return; } - if (gMarioCurrentRoom == 0) { return; } + // COOP: if any active player character's room is 0, then either: + // 1) There are no rooms in the area + // 2) They are on an object surface with no explicit room + // In vanilla, a room of 0 stops the game from checking if the object shouldn't be rendered + // In coop, this needs to be respected to ensure the object remains active in areas with rooms u8 marioInRoom = FALSE; + // check if any player character can "see" the object's room for (s32 i = 0; i < MAX_PLAYERS; i++) { - if (gMarioStates[i].currentRoom != 0) { + if (is_player_active(&gMarioStates[i])) { + // TODO: separate rendering and activation + if (gMarioStates[i].currentRoom == 0) { return; } s16 currentRoom = gMarioStates[i].currentRoom; - if (currentRoom == o->oRoom) { - marioInRoom = TRUE; - } else if (gDoorAdjacentRooms[currentRoom][0] == o->oRoom) { - marioInRoom = TRUE; - } else if (gDoorAdjacentRooms[currentRoom][1] == o->oRoom) { + if ( + currentRoom == o->oRoom + || gDoorAdjacentRooms[currentRoom][0] == o->oRoom + || gDoorAdjacentRooms[currentRoom][1] == o->oRoom + ) { marioInRoom = TRUE; + break; } } } diff --git a/src/game/rendering_graph_node.c b/src/game/rendering_graph_node.c index e68cb7c66..43c3c1f0e 100644 --- a/src/game/rendering_graph_node.c +++ b/src/game/rendering_graph_node.c @@ -384,16 +384,9 @@ void patch_mtx_interpolated(f32 delta) { * Graph node interpolation */ -struct GraphNodeInterpData { - Vec3s translation; - Vec3s rotation; - Vec3f scale; - u32 timestamp; -}; - static void *sGraphNodeInterpDataMap = NULL; -static struct GraphNodeInterpData *geo_get_interp_data(void *node, struct GraphNodeObject *obj) { +struct GraphNodeInterpData *geo_get_interp_data(void *node, struct GraphNodeObject *obj) { // Map for nodes if (!sGraphNodeInterpDataMap) { diff --git a/src/game/rendering_graph_node.h b/src/game/rendering_graph_node.h index c345c9e34..f30ea4a5d 100644 --- a/src/game/rendering_graph_node.h +++ b/src/game/rendering_graph_node.h @@ -43,6 +43,15 @@ extern f32 gOverrideFar; void geo_process_node_and_siblings(struct GraphNode *firstNode); void geo_process_root(struct GraphNodeRoot *node, Vp *b, Vp *c, s32 clearColor); + +struct GraphNodeInterpData { + Vec3s translation; + Vec3s rotation; + Vec3f scale; + u32 timestamp; +}; + +struct GraphNodeInterpData *geo_get_interp_data(void *node, struct GraphNodeObject *obj); void geo_clear_interp_data(); struct ShadowInterp { diff --git a/src/game/scroll_targets.c b/src/game/scroll_targets.c index ff00cf244..a2af8bc19 100644 --- a/src/game/scroll_targets.c +++ b/src/game/scroll_targets.c @@ -13,19 +13,16 @@ struct ScrollTarget *get_scroll_targets(u32 id, u16 size, u16 offset) { if (scroll) { // If we need to, realloc the block of vertices - if ((!scroll->hasOffset && offset > 0) || size < scroll->size) { - if (scroll->hasOffset) { return NULL; } + if (!scroll->hasOffset && (offset > 0 || size < scroll->size)) { if (size > scroll->size) { size = scroll->size; } // Don't use an invalid size - if (size + offset >= scroll->size) { return NULL; } // If the offset is invalid, Abort. - scroll->hasOffset = true; - Vtx* *newVtx = calloc(size, sizeof(Vtx*)); + if (offset > 0 && size + offset >= scroll->size) { return NULL; } // If the offset is invalid, Abort. + Vtx* *newVtx = malloc(size * sizeof(Vtx*)); if (!newVtx) { return NULL; } - for (u32 i = 0; i < size; i++) { - newVtx[i] = scroll->vertices[i + offset]; - } + memcpy(newVtx, scroll->vertices + offset, size * sizeof(Vtx*)); free(scroll->vertices); scroll->vertices = newVtx; scroll->size = size; + scroll->hasOffset = true; } return scroll; @@ -51,11 +48,18 @@ struct ScrollTarget* find_or_create_scroll_targets(u32 id, bool hasOffset) { } if (scroll == NULL) { - scroll = calloc(1, sizeof(struct ScrollTarget)); + scroll = malloc(sizeof(struct ScrollTarget)); scroll->id = id; scroll->size = 0; scroll->vertices = NULL; scroll->hasOffset = hasOffset; + scroll->hasInterpInit = false; + scroll->needInterp = false; + scroll->interpF32 = NULL; + scroll->prevF32 = NULL; + scroll->interpS16 = NULL; + scroll->prevS16 = NULL; + scroll->bhv = 0; hmap_put(sScrollTargets, id, scroll); } @@ -77,8 +81,11 @@ void add_vtx_scroll_target(u32 id, Vtx *vtx, u32 size, bool hasOffset) { Vtx* *newArray = realloc(scroll->vertices, newSize); if (!newArray) { - newArray = calloc(1, newSize); - memcpy(newArray, scroll->vertices, oldSize); + newArray = malloc(newSize); + if (!newArray) { return; } + if (scroll->vertices && oldSize > 0) { + memcpy(newArray, scroll->vertices, oldSize); + } free(scroll->vertices); } @@ -133,13 +140,13 @@ void patch_scroll_targets_interpolated(f32 delta) { Vtx* *verts = scroll->vertices; if (scroll->bhv < SCROLL_UV_X) { u8 bhvIndex = MIN(scroll->bhv, 2); - for (u16 k = 0; k < scroll->size; k++) { + for (u32 k = 0; k < scroll->size; k++) { f32 diff = wrap_f32(scroll->interpF32[k] - scroll->prevF32[k]); verts[k]->n.ob[bhvIndex] = wrap_f32(scroll->prevF32[k] + diff * delta); } } else { u8 bhvIndex = MIN(scroll->bhv-SCROLL_UV_X, 1); - for (u16 k = 0; k < scroll->size; k++) { + for (u32 k = 0; k < scroll->size; k++) { s32 diff = wrap_s32(scroll->interpS16[k] - scroll->prevS16[k]); verts[k]->n.tc[bhvIndex] = wrap_s32(scroll->prevS16[k] + diff * delta); } diff --git a/src/pc/controller/controller_bind_mapping.c b/src/pc/controller/controller_bind_mapping.c index 8c56299f2..24f81481b 100644 --- a/src/pc/controller/controller_bind_mapping.c +++ b/src/pc/controller/controller_bind_mapping.c @@ -106,11 +106,17 @@ const char* translate_bind_to_name(int bind) { // mouse if (bind >= VK_BASE_SDL_MOUSE) { int mouse_button = (bind - VK_BASE_SDL_MOUSE); - if (mouse_button == 1) { return "L Mouse"; } - if (mouse_button == 2) { return "M Mouse"; } - if (mouse_button == 3) { return "R Mouse"; } - snprintf(name, 8, "Mouse %d", bind - VK_BASE_SDL_MOUSE); - return name; + switch (mouse_button) { + case 1: return "L Mouse"; + case 2: return "M Mouse"; + case 3: return "R Mouse"; + case 6: return "Scroll Up"; + case 7: return "Scroll Down"; + default: { + snprintf(name, 11, "Mouse %d", mouse_button); + return name; + } + } } // gamepad diff --git a/src/pc/controller/controller_mouse.c b/src/pc/controller/controller_mouse.c index 84c10a635..bb047ead5 100644 --- a/src/pc/controller/controller_mouse.c +++ b/src/pc/controller/controller_mouse.c @@ -116,6 +116,11 @@ void controller_mouse_read_relative(void) { #elif defined(CAPI_SDL1) || defined(CAPI_SDL2) mouse_buttons = SDL_GetRelativeMouseState(&mouse_x, &mouse_y); #endif + if (mouse_scroll_y > 0) { + mouse_buttons |= MWHEELUP; + } else if (mouse_scroll_y < 0) { + mouse_buttons |= MWHEELDOWN; + } } void controller_mouse_enter_relative(void) { diff --git a/src/pc/controller/controller_sdl.h b/src/pc/controller/controller_sdl.h index bab54eddc..b6235365d 100644 --- a/src/pc/controller/controller_sdl.h +++ b/src/pc/controller/controller_sdl.h @@ -8,6 +8,8 @@ // mouse buttons are also in the controller namespace, just offset 0x100 #define VK_OFS_SDL_MOUSE 0x0100 #define VK_BASE_SDL_MOUSE (VK_BASE_SDL_GAMEPAD + VK_OFS_SDL_MOUSE) +#define MWHEELUP 0x20 +#define MWHEELDOWN 0x40 extern struct ControllerAPI controller_sdl; diff --git a/src/pc/controller/controller_sdl2.c b/src/pc/controller/controller_sdl2.c index 373065415..251d8a85f 100644 --- a/src/pc/controller/controller_sdl2.c +++ b/src/pc/controller/controller_sdl2.c @@ -60,11 +60,11 @@ static s16 invert_s16(s16 val) { static inline void controller_add_binds(const u32 mask, const u32 *btns) { for (u32 i = 0; i < MAX_BINDS; ++i) { if (btns[i] >= VK_BASE_SDL_GAMEPAD && btns[i] <= VK_BASE_SDL_GAMEPAD + VK_SIZE) { - if (btns[i] >= VK_BASE_SDL_MOUSE && num_joy_binds < MAX_JOYBINDS) { + if (btns[i] >= VK_BASE_SDL_MOUSE && num_mouse_binds < MAX_JOYBINDS) { mouse_binds[num_mouse_binds][0] = btns[i] - VK_BASE_SDL_MOUSE; mouse_binds[num_mouse_binds][1] = mask; ++num_mouse_binds; - } else if (num_mouse_binds < MAX_JOYBINDS) { + } else if (num_joy_binds < MAX_JOYBINDS) { joy_binds[num_joy_binds][0] = btns[i] - VK_BASE_SDL_GAMEPAD; joy_binds[num_joy_binds][1] = mask; ++num_joy_binds; @@ -190,11 +190,13 @@ static void controller_sdl_read(OSContPad *pad) { controller_mouse_read_relative(); u32 mouse = mouse_buttons; + u32 buttons_down = 0; if (!gInteractableOverridePad) { for (u32 i = 0; i < num_mouse_binds; ++i) if (mouse & SDL_BUTTON(mouse_binds[i][0])) - pad->button |= mouse_binds[i][1]; + buttons_down |= mouse_binds[i][1]; } + pad->button |= buttons_down; // remember buttons that changed from 0 to 1 last_mouse = (mouse_prev ^ mouse) & mouse; @@ -282,7 +284,6 @@ static void controller_sdl_read(OSContPad *pad) { update_button(VK_LTRIGGER - VK_BASE_SDL_GAMEPAD, ltrig > AXIS_THRESHOLD); update_button(VK_RTRIGGER - VK_BASE_SDL_GAMEPAD, rtrig > AXIS_THRESHOLD); - u32 buttons_down = 0; for (u32 i = 0; i < num_joy_binds; ++i) if (joy_buttons[joy_binds[i][0]]) buttons_down |= joy_binds[i][1]; diff --git a/src/pc/crash_handler.c b/src/pc/crash_handler.c index 23301f0f2..470f4e2e6 100644 --- a/src/pc/crash_handler.c +++ b/src/pc/crash_handler.c @@ -235,6 +235,8 @@ static void crash_handler_produce_one_frame_callback(void) { // render the line f32 addX = 0; char* c = text->s; + + font->render_begin(); while (*c != '\0') { f32 charWidth = 0.4f; @@ -253,6 +255,7 @@ static void crash_handler_produce_one_frame_callback(void) { create_dl_translation_matrix(DJUI_MTX_NOPUSH, charWidth, 0, 0); c = djui_unicode_next_char(c); } + font->render_end(); // pop gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); diff --git a/src/pc/discord/discord_activity.c b/src/pc/discord/discord_activity.c index 510ac440e..36745701c 100644 --- a/src/pc/discord/discord_activity.c +++ b/src/pc/discord/discord_activity.c @@ -122,11 +122,9 @@ void discord_activity_update(void) { // HACK: give the detail population more space than the Discord details can fit so it gets truncated without cutting off the largest strings char details[512] = { 0 }; - discord_populate_details(details, 512); - char* detailsNoColor = str_remove_color_codes(details); - - snprintf(sCurActivity.details, 128, "%s", detailsNoColor); - free(detailsNoColor); + discord_populate_details(details, ARRAY_COUNT(details)); + djui_text_remove_colors(details); + snprintf(sCurActivity.details, 128, "%s", details); if (!app.activities) { LOG_INFO("no activities"); diff --git a/src/pc/djui/djui.c b/src/pc/djui/djui.c index 5c79ff3c6..3bd9fc8b1 100644 --- a/src/pc/djui/djui.c +++ b/src/pc/djui/djui.c @@ -168,7 +168,8 @@ void djui_lua_error_clear(void) { void djui_reset_hud_params(void) { djui_hud_set_resolution(RESOLUTION_DJUI); djui_hud_set_font(FONT_NORMAL); - djui_hud_set_rotation(0, 0, 0); + djui_hud_set_rotation(0, ROTATION_PIVOT_X_LEFT, ROTATION_PIVOT_Y_TOP); + djui_hud_set_text_alignment(TEXT_HALIGN_LEFT, TEXT_VALIGN_TOP); djui_hud_reset_color(); djui_hud_set_filter(FILTER_NEAREST); djui_hud_reset_viewport(); diff --git a/src/pc/djui/djui_font.c b/src/pc/djui/djui_font.c index f2d88cc88..4b649d784 100644 --- a/src/pc/djui/djui_font.c +++ b/src/pc/djui/djui_font.c @@ -7,7 +7,7 @@ // font 0 (built-in normal font) // /////////////////////////////////// -static void djui_font_normal_render_char(char* c) { +static void djui_font_normal_render_char(const char* c) { // replace undisplayable characters if (*c == ' ') { return; } @@ -18,16 +18,16 @@ static void djui_font_normal_render_char(char* c) { u32 tx = index % 64; u32 ty = index / 64; extern ALIGNED8 const Texture texture_font_jp[]; - djui_gfx_render_texture_tile(texture_font_jp, 512, 1024, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 8, ty * 16, 8, 16, false, true); + djui_gfx_render_texture_tile_font(texture_font_jp, 512, 1024, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 8, ty * 16, 8, 16); } else { u32 tx = index % 32; u32 ty = index / 32; extern ALIGNED8 const Texture texture_font_normal[]; - djui_gfx_render_texture_tile(texture_font_normal, 256, 128, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 8, ty * 16, 8, 16, false, true); + djui_gfx_render_texture_tile_font(texture_font_normal, 256, 128, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 8, ty * 16, 8, 16); } } -static f32 djui_font_normal_char_width(char* c) { +static f32 djui_font_normal_char_width(const char* c) { if (*c == ' ') { return configExCoopTheme ? 6 / 32.0f : 0.30f; } extern const f32 font_normal_widths[]; return djui_unicode_get_sprite_width(c, font_normal_widths, 32.0f); @@ -41,7 +41,9 @@ static const struct DjuiFont sDjuiFontNormal = { .yOffset = 0.0f, .defaultFontScale = 32.0f, .textBeginDisplayList = NULL, + .render_begin = djui_gfx_render_texture_tile_font_begin, .render_char = djui_font_normal_render_char, + .render_end = djui_gfx_render_texture_tile_font_end, .char_width = djui_font_normal_char_width, }; @@ -49,7 +51,7 @@ static const struct DjuiFont sDjuiFontNormal = { // font 1 (custom title font) // //////////////////////////////// -static void djui_font_title_render_char(char* c) { +static void djui_font_title_render_char(const char* c) { // replace undisplayable characters if (*c == ' ') { return; } @@ -64,10 +66,10 @@ static void djui_font_title_render_char(char* c) { u32 ty = index / 16; extern ALIGNED8 const Texture texture_font_title[]; - djui_gfx_render_texture_tile(texture_font_title, 1024, 512, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 64, ty * 64, 64, 64, false, true); + djui_gfx_render_texture_tile_font(texture_font_title, 1024, 512, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 64, ty * 64, 64, 64); } -static f32 djui_font_title_char_width(char* text) { +static f32 djui_font_title_char_width(const char* text) { char c = *text; if (c == ' ') { return 0.30f; } c = djui_unicode_get_base_char(text); @@ -83,7 +85,9 @@ static const struct DjuiFont sDjuiFontTitle = { .yOffset = 0.0f, .defaultFontScale = 64.0f, .textBeginDisplayList = NULL, + .render_begin = djui_gfx_render_texture_tile_font_begin, .render_char = djui_font_title_render_char, + .render_end = djui_gfx_render_texture_tile_font_end, .char_width = djui_font_title_char_width, }; @@ -124,27 +128,29 @@ static u8 djui_font_hud_index(char c) { return c; } -static void djui_font_hud_render_char(char* text) { +static void djui_font_hud_render_char(const char* text) { char c = *text; if (c == ' ') { return; } c = djui_unicode_get_base_char(text); u8 index = djui_font_hud_index(c); - djui_gfx_render_texture(main_hud_lut[index], 16, 16, G_IM_FMT_RGBA, G_IM_SIZ_16b, djui_hud_get_filter()); + djui_gfx_render_texture_font(main_hud_lut[index], 16, 16, G_IM_FMT_RGBA, G_IM_SIZ_16b); } -static f32 djui_font_hud_char_width(UNUSED char* text) { +static f32 djui_font_hud_char_width(UNUSED const char* text) { return 0.75f; } static const struct DjuiFont sDjuiFontHud = { .charWidth = 1.0f, .charHeight = 0.9f, - .lineHeight = 0.7f, + .lineHeight = 1.25f, .xOffset = 0.0f, .yOffset = 0.0f, .defaultFontScale = 16.0f, .textBeginDisplayList = NULL, + .render_begin = djui_gfx_render_texture_font_begin, .render_char = djui_font_hud_render_char, + .render_end = djui_gfx_render_texture_font_end, .char_width = djui_font_hud_char_width, }; @@ -152,7 +158,7 @@ static const struct DjuiFont sDjuiFontHud = { // font 3 (DJ's aliased font) // //////////////////////////////// -static void djui_font_aliased_render_char(char* c) { +static void djui_font_aliased_render_char(const char* c) { // replace undisplayable characters if (*c == ' ') { return; } @@ -163,16 +169,16 @@ static void djui_font_aliased_render_char(char* c) { u32 tx = index % 64; u32 ty = index / 64; extern ALIGNED8 const Texture texture_font_jp_aliased[]; - djui_gfx_render_texture_tile(texture_font_jp_aliased, 1024, 2048, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 16, ty * 32, 16, 32, false, true); + djui_gfx_render_texture_tile_font(texture_font_jp_aliased, 1024, 2048, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 16, ty * 32, 16, 32); } else { u32 tx = index % 32; u32 ty = index / 32; extern ALIGNED8 const Texture texture_font_aliased[]; - djui_gfx_render_texture_tile(texture_font_aliased, 512, 256, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 16, ty * 32, 16, 32, false, true); + djui_gfx_render_texture_tile_font(texture_font_aliased, 512, 256, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 16, ty * 32, 16, 32); } } -static f32 djui_font_aliased_char_width(char* c) { +static f32 djui_font_aliased_char_width(const char* c) { if (*c == ' ') { return 6 / 32.0f; } extern const f32 font_aliased_widths[]; return djui_unicode_get_sprite_width(c, font_aliased_widths, 1.0f) / 32.0f; @@ -186,7 +192,9 @@ static const struct DjuiFont sDjuiFontAliased = { .lineHeight = 0.8125f, .defaultFontScale = 32.0f, .textBeginDisplayList = NULL, + .render_begin = djui_gfx_render_texture_tile_font_begin, .render_char = djui_font_aliased_render_char, + .render_end = djui_gfx_render_texture_tile_font_end, .char_width = djui_font_aliased_char_width, }; @@ -194,7 +202,7 @@ static const struct DjuiFont sDjuiFontAliased = { // font 4/5 (custom hud font/recolor) // //////////////////////////////////////// -static void djui_font_custom_hud_render_char(char* c) { +static void djui_font_custom_hud_render_char(const char* c) { // replace undisplayable characters if (*c == ' ') { return; } @@ -204,10 +212,10 @@ static void djui_font_custom_hud_render_char(char* c) { u32 ty = index / 16; extern ALIGNED8 const Texture texture_font_hud[]; - djui_gfx_render_texture_tile(texture_font_hud, 512, 512, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 32, ty * 32, 32, 32, false, true); + djui_gfx_render_texture_tile_font(texture_font_hud, 512, 512, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 32, ty * 32, 32, 32); } -static void djui_font_custom_hud_recolor_render_char(char* c) { +static void djui_font_custom_hud_recolor_render_char(const char* c) { // replace undisplayable characters if (*c == ' ') { return; } @@ -217,10 +225,10 @@ static void djui_font_custom_hud_recolor_render_char(char* c) { u32 ty = index / 16; extern ALIGNED8 const Texture texture_font_hud_recolor[]; - djui_gfx_render_texture_tile(texture_font_hud_recolor, 512, 512, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 32, ty * 32, 32, 32, false, true); + djui_gfx_render_texture_tile_font(texture_font_hud_recolor, 512, 512, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 32, ty * 32, 32, 32); } -static f32 djui_font_custom_hud_char_width(char* text) { +static f32 djui_font_custom_hud_char_width(const char* text) { char c = *text; if (c == ' ') { return 0.3750f; } c = djui_unicode_get_base_char(text); @@ -236,7 +244,9 @@ static const struct DjuiFont sDjuiFontCustomHud = { .yOffset = -10.25f, .defaultFontScale = 32.0f, .textBeginDisplayList = NULL, + .render_begin = djui_gfx_render_texture_tile_font_begin, .render_char = djui_font_custom_hud_render_char, + .render_end = djui_gfx_render_texture_tile_font_end, .char_width = djui_font_custom_hud_char_width, }; @@ -248,7 +258,9 @@ static const struct DjuiFont sDjuiFontCustomHudRecolor = { .yOffset = -10.25f, .defaultFontScale = 32.0f, .textBeginDisplayList = NULL, + .render_begin = djui_gfx_render_texture_tile_font_begin, .render_char = djui_font_custom_hud_recolor_render_char, + .render_end = djui_gfx_render_texture_tile_font_end, .char_width = djui_font_custom_hud_char_width, }; @@ -256,7 +268,7 @@ static const struct DjuiFont sDjuiFontCustomHudRecolor = { // font 6 (special font) // /////////////////////////// -static void djui_font_special_render_char(char* c) { +static void djui_font_special_render_char(const char* c) { // replace undisplayable characters if (*c == ' ') { return; } @@ -266,17 +278,17 @@ static void djui_font_special_render_char(char* c) { u32 tx = index % 64; u32 ty = index / 64; extern ALIGNED8 const Texture texture_font_jp[]; - djui_gfx_render_texture_tile(texture_font_jp, 512, 1024, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 8, ty * 16, 8, 16, false, true); + djui_gfx_render_texture_tile_font(texture_font_jp, 512, 1024, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 8, ty * 16, 8, 16); } else { u32 tx = index % 32; u32 ty = index / 32; extern ALIGNED8 const Texture texture_font_special[]; - djui_gfx_render_texture_tile(texture_font_special, 256, 128, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 8, ty * 16, 8, 16, false, true); + djui_gfx_render_texture_tile_font(texture_font_special, 256, 128, G_IM_FMT_RGBA, G_IM_SIZ_32b, tx * 8, ty * 16, 8, 16); } } -static f32 djui_font_special_char_width(char* c) { +static f32 djui_font_special_char_width(const char* c) { if (*c == ' ') { return 0.5f; } extern const f32 font_special_widths[]; return djui_unicode_get_sprite_width(c, font_special_widths, 32.0f); @@ -290,7 +302,9 @@ static const struct DjuiFont sDjuiFontSpecial = { .yOffset = 0.0f, .defaultFontScale = 32.0f, .textBeginDisplayList = NULL, + .render_begin = djui_gfx_render_texture_tile_font_begin, .render_char = djui_font_special_render_char, + .render_end = djui_gfx_render_texture_tile_font_end, .char_width = djui_font_special_char_width, }; diff --git a/src/pc/djui/djui_font.h b/src/pc/djui/djui_font.h index 02d3eef8a..7acf72a28 100644 --- a/src/pc/djui/djui_font.h +++ b/src/pc/djui/djui_font.h @@ -9,8 +9,10 @@ struct DjuiFont { f32 yOffset; f32 defaultFontScale; const Gfx* textBeginDisplayList; - void (*render_char)(char*); - f32 (*char_width)(char*); + void (*render_begin)(); + void (*render_char)(const char*); + void (*render_end)(); + f32 (*char_width)(const char*); }; extern const struct DjuiFont* gDjuiFonts[]; diff --git a/src/pc/djui/djui_gfx.c b/src/pc/djui/djui_gfx.c index 8ebd6c488..4319782c3 100644 --- a/src/pc/djui/djui_gfx.c +++ b/src/pc/djui/djui_gfx.c @@ -1,6 +1,7 @@ #include #include "sm64.h" #include "djui.h" +#include "djui_hud_utils.h" #include "game/ingame_menu.h" #include "game/segment2.h" #include "pc/pc_main.h" @@ -118,7 +119,93 @@ void djui_gfx_render_texture(const Texture* texture, u32 w, u32 h, u8 fmt, u8 si gSPDisplayList(gDisplayListHead++, dl_djui_image); } -void djui_gfx_render_texture_tile(const Texture* texture, u32 w, u32 h, u8 fmt, u8 siz, u32 tileX, u32 tileY, u32 tileW, u32 tileH, bool filter, bool font) { +void djui_gfx_render_texture_tile(const Texture* texture, u32 w, u32 h, u8 fmt, u8 siz, u32 tileX, u32 tileY, u32 tileW, u32 tileH, bool filter) { + if (!gDisplayListHead) { + LOG_ERROR("Retrieved a null displaylist head"); + return; + } + + if (!texture) { + LOG_ERROR("Attempted to render null texture"); + return; + } + + Vtx *vtx = alloc_display_list(sizeof(Vtx) * 4); + if (!vtx) { + LOG_ERROR("Failed to allocate vertices"); + return; + } + + f32 aspect = tileH ? ((f32)tileW / (f32)tileH) : 1; + + vtx[0] = (Vtx) {{{ 0, -1, 0 }, 0, { ( tileX * 2048.0f) / (f32)w + 1, ((tileY + tileH) * 2048.0f) / (f32)h + 1 }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[2] = (Vtx) {{{ 1 * aspect, 0, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w + 1, ( tileY * 2048.0f) / (f32)h + 1 }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[1] = (Vtx) {{{ 1 * aspect, -1, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w + 1, ((tileY + tileH) * 2048.0f) / (f32)h + 1 }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[3] = (Vtx) {{{ 0, 0, 0 }, 0, { ( tileX * 2048.0f) / (f32)w + 1, ( tileY * 2048.0f) / (f32)h + 1 }, { 0xff, 0xff, 0xff, 0xff }}}; + + gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BOTH); + gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_FADEA); + gDPSetRenderMode(gDisplayListHead++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetTextureFilter(gDisplayListHead++, filter ? G_TF_BILERP : G_TF_POINT); + + gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); + + gDPSetTextureOverrideDjui(gDisplayListHead++, texture, djui_gfx_power_of_two(w), djui_gfx_power_of_two(h), fmt, siz); + gDPLoadTextureBlockWithoutTexture(gDisplayListHead++, NULL, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 64, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); + + *(gDisplayListHead++) = (Gfx) gsSPExecuteDjui(G_TEXOVERRIDE_DJUI); + + gSPVertexNonGlobal(gDisplayListHead++, vtx, 4, 0); + *(gDisplayListHead++) = (Gfx) gsSPExecuteDjui(G_TEXCLIP_DJUI); + gSP2TrianglesDjui(gDisplayListHead++, 0, 1, 2, 0x0, 0, 2, 3, 0x0); + + gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF); + gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); + gSPSetGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BACK); +} + +void djui_gfx_render_texture_font_begin() { + gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BOTH); + gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_FADEA); + gDPSetRenderMode(gDisplayListHead++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetTextureFilter(gDisplayListHead++, djui_hud_get_filter() ? G_TF_BILERP : G_TF_POINT); + gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); + gDPLoadTextureBlockWithoutTexture(gDisplayListHead++, NULL, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 64, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); +} + +void djui_gfx_render_texture_font(const Texture* texture, u32 w, u32 h, u8 fmt, u8 siz) { + if (!gDisplayListHead) { + LOG_ERROR("Retrieved a null displaylist head"); + return; + } + + if (!texture) { + LOG_ERROR("Attempted to render null texture"); + return; + } + + gDPSetTextureOverrideDjui(gDisplayListHead++, texture, djui_gfx_power_of_two(w), djui_gfx_power_of_two(h), fmt, siz); + *(gDisplayListHead++) = (Gfx) gsSPExecuteDjui(G_TEXOVERRIDE_DJUI); + gSPVertexNonGlobal(gDisplayListHead++, vertex_djui_image, 4, 0); + gSP2Triangles(gDisplayListHead++, 0, 1, 2, 0x0, 0, 2, 3, 0x0); +} + +void djui_gfx_render_texture_font_end() { + gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF); + gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); + gSPSetGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BACK); +} + +void djui_gfx_render_texture_tile_font_begin() { + gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BOTH); + gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_FADEA); + gDPSetRenderMode(gDisplayListHead++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetTextureFilter(gDisplayListHead++, G_TF_POINT); + gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); + gDPLoadTextureBlockWithoutTexture(gDisplayListHead++, NULL, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 64, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); +} + +void djui_gfx_render_texture_tile_font(const Texture* texture, u32 w, u32 h, u8 fmt, u8 siz, u32 tileX, u32 tileY, u32 tileW, u32 tileH) { if (!gDisplayListHead) { LOG_ERROR("Retrieved a null displaylist head"); return; @@ -139,29 +226,21 @@ void djui_gfx_render_texture_tile(const Texture* texture, u32 w, u32 h, u8 fmt, // I don't know why adding 1 to all of the UVs seems to fix rendering, but it does... // this should be tested carefully. it definitely fixes some stuff, but what does it break? - f32 offsetX = (font ? -1024.0f / (f32)w : 0) + 1; - f32 offsetY = (font ? -1024.0f / (f32)h : 0) + 1; + f32 offsetX = (-1024.0f / (f32)w) + 1; + f32 offsetY = (-1024.0f / (f32)h) + 1; vtx[0] = (Vtx) {{{ 0, -1, 0 }, 0, { ( tileX * 2048.0f) / (f32)w + offsetX, ((tileY + tileH) * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}}; vtx[2] = (Vtx) {{{ 1 * aspect, 0, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w + offsetX, ( tileY * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}}; vtx[1] = (Vtx) {{{ 1 * aspect, -1, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w + offsetX, ((tileY + tileH) * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}}; vtx[3] = (Vtx) {{{ 0, 0, 0 }, 0, { ( tileX * 2048.0f) / (f32)w + offsetX, ( tileY * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}}; - gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BOTH); - gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_FADEA); - gDPSetRenderMode(gDisplayListHead++, G_RM_XLU_SURF, G_RM_XLU_SURF2); - gDPSetTextureFilter(gDisplayListHead++, filter ? G_TF_BILERP : G_TF_POINT); - - gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); - gDPSetTextureOverrideDjui(gDisplayListHead++, texture, djui_gfx_power_of_two(w), djui_gfx_power_of_two(h), fmt, siz); - gDPLoadTextureBlockWithoutTexture(gDisplayListHead++, NULL, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 64, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); - *(gDisplayListHead++) = (Gfx) gsSPExecuteDjui(G_TEXOVERRIDE_DJUI); - gSPVertexNonGlobal(gDisplayListHead++, vtx, 4, 0); *(gDisplayListHead++) = (Gfx) gsSPExecuteDjui(G_TEXCLIP_DJUI); gSP2TrianglesDjui(gDisplayListHead++, 0, 1, 2, 0x0, 0, 2, 3, 0x0); +} +void djui_gfx_render_texture_tile_font_end() { gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF); gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); gSPSetGeometryMode(gDisplayListHead++, G_LIGHTING | G_CULL_BACK); diff --git a/src/pc/djui/djui_gfx.h b/src/pc/djui/djui_gfx.h index 8da361e3f..743ca4460 100644 --- a/src/pc/djui/djui_gfx.h +++ b/src/pc/djui/djui_gfx.h @@ -16,7 +16,15 @@ void djui_gfx_displaylist_end(void); f32 djui_gfx_get_scale(void); void djui_gfx_render_texture(const Texture* texture, u32 w, u32 h, u8 fmt, u8 siz, bool filter); -void djui_gfx_render_texture_tile(const Texture* texture, u32 w, u32 h, u8 fmt, u8 siz, u32 tileX, u32 tileY, u32 tileW, u32 tileH, bool filter, bool font); +void djui_gfx_render_texture_tile(const Texture* texture, u32 w, u32 h, u8 fmt, u8 siz, u32 tileX, u32 tileY, u32 tileW, u32 tileH, bool filter); + +void djui_gfx_render_texture_font_begin(); +void djui_gfx_render_texture_font(const Texture* texture, u32 w, u32 h, u8 fmt, u8 siz); +void djui_gfx_render_texture_font_end(); + +void djui_gfx_render_texture_tile_font_begin(); +void djui_gfx_render_texture_tile_font(const Texture* texture, u32 w, u32 h, u8 fmt, u8 siz, u32 tileX, u32 tileY, u32 tileW, u32 tileH); +void djui_gfx_render_texture_tile_font_end(); void gfx_get_dimensions(u32* width, u32* height); diff --git a/src/pc/djui/djui_hud_utils.c b/src/pc/djui/djui_hud_utils.c index 65e1acb31..8ad0a5b15 100644 --- a/src/pc/djui/djui_hud_utils.c +++ b/src/pc/djui/djui_hud_utils.c @@ -24,13 +24,45 @@ #include "engine/math_util.h" -static enum HudUtilsResolution sResolution = RESOLUTION_DJUI; -static enum HudUtilsFilter sFilter = FILTER_NEAREST; -static enum DjuiFontType sFont = FONT_NORMAL; -static struct HudUtilsRotation sRotation = { 0, 0, 0, 0, 0, 0 }; -static struct DjuiColor sColor = { 255, 255, 255, 255 }; +#define INTERP_INIT(v) {v, v} + +typedef struct { + f32 prev, curr; +} InterpFieldF32; + +struct HudUtilsState { + enum HudUtilsResolution resolution; + enum HudUtilsFilter filter; + enum DjuiFontType font; + struct DjuiColor color; + struct { + InterpFieldF32 degrees; + InterpFieldF32 pivotX; + InterpFieldF32 pivotY; + } rotation; + struct { + InterpFieldF32 h; + InterpFieldF32 v; + } textAlignment; +}; + +static struct HudUtilsState sHudUtilsState = { + .resolution = RESOLUTION_DJUI, + .filter = FILTER_NEAREST, + .font = FONT_NORMAL, + .color = { 255, 255, 255, 255 }, + .rotation = { + .degrees = INTERP_INIT(0), + .pivotX = INTERP_INIT(ROTATION_PIVOT_X_LEFT), + .pivotY = INTERP_INIT(ROTATION_PIVOT_Y_TOP), + }, + .textAlignment = { + .h = INTERP_INIT(TEXT_HALIGN_LEFT), + .v = INTERP_INIT(TEXT_VALIGN_TOP), + }, +}; + static struct DjuiColor sRefColor = { 255, 255, 255, 255 }; -static bool sLegacy = false; f32 gDjuiHudUtilsZ = 0; bool gDjuiHudLockMouse = false; @@ -67,8 +99,16 @@ struct GlobalTextures gGlobalTextures = { .wario_head = { .texture = texture_hud_char_wario_head, "texture_hud_char_wario_head", .width = 16, .height = 16, .format = G_IM_FMT_RGBA, .size = G_IM_SIZ_16b } }; +static inline const struct DjuiFont *djui_hud_get_text_font() { + return gDjuiFonts[sHudUtilsState.font < 0 ? FONT_NORMAL : sHudUtilsState.font]; +} + +static inline bool djui_hud_text_font_is_legacy() { + return sHudUtilsState.font < 0; +} + static void djui_hud_position_translate(f32* x, f32* y) { - if (sResolution == RESOLUTION_DJUI) { + if (sHudUtilsState.resolution == RESOLUTION_DJUI) { djui_gfx_position_translate(x, y); } else { *x = GFX_DIMENSIONS_FROM_LEFT_EDGE(0) + *x; @@ -77,7 +117,7 @@ static void djui_hud_position_translate(f32* x, f32* y) { } static void djui_hud_size_translate(f32* size) { - if (sResolution == RESOLUTION_DJUI) { + if (sHudUtilsState.resolution == RESOLUTION_DJUI) { djui_gfx_size_translate(size); } } @@ -90,7 +130,7 @@ static void djui_hud_translate_positions(f32 *outX, f32 *outY, f32 *outW, f32 *o *outY -= SCREEN_HEIGHT; // translate scale - if (sResolution == RESOLUTION_DJUI) { + if (sHudUtilsState.resolution == RESOLUTION_DJUI) { u32 windowWidth, windowHeight; gfx_get_dimensions(&windowWidth, &windowHeight); f32 screenWidth = (f32) windowWidth / djui_gfx_get_scale(); @@ -105,22 +145,31 @@ static void djui_hud_translate_positions(f32 *outX, f32 *outY, f32 *outW, f32 *o //////////// #define MAX_INTERP_HUD 512 -struct InterpHud { - Gfx* headPos; - f32 z; - f32 prevX; - f32 prevY; - f32 x; - f32 y; - f32 prevScaleW; - f32 prevScaleH; - f32 scaleW; - f32 scaleH; - f32 width; - f32 height; - enum HudUtilsResolution resolution; - struct HudUtilsRotation rotation; + +enum InterpHudType { + INTERP_HUD_TRANSLATION, + INTERP_HUD_ROTATION, + INTERP_HUD_SCALE, + INTERP_HUD_HALIGN, + INTERP_HUD_VALIGN, + INTERP_HUD_NEW_LINE, }; + +typedef struct { + enum InterpHudType type; + Gfx *pos; + f32 params[1]; // we don't need more for now +} InterpHudGfx; + +struct InterpHud { + f32 z; + InterpFieldF32 posX, posY; + InterpFieldF32 scaleX, scaleY; + f32 width, height; + struct HudUtilsState state; + struct GrowingArray *gfx; +}; + static struct InterpHud sInterpHuds[MAX_INTERP_HUD] = { 0 }; static u16 sInterpHudCount = 0; static u8 sColorAltered = FALSE; @@ -132,140 +181,211 @@ void patch_djui_hud_before(void) { void patch_djui_hud(f32 delta) { f32 savedZ = gDjuiHudUtilsZ; Gfx* savedHeadPos = gDisplayListHead; - enum HudUtilsResolution savedResolution = sResolution; - struct HudUtilsRotation savedRotation = sRotation; + struct HudUtilsState savedState = sHudUtilsState; + for (u16 i = 0; i < sInterpHudCount; i++) { struct InterpHud* interp = &sInterpHuds[i]; - f32 x = delta_interpolate_f32(interp->prevX, interp->x, delta); - f32 y = delta_interpolate_f32(interp->prevY, interp->y, delta); - f32 scaleW = delta_interpolate_f32(interp->prevScaleW, interp->scaleW, delta); - f32 scaleH = delta_interpolate_f32(interp->prevScaleH, interp->scaleH, delta); - sResolution = interp->resolution; - sRotation = interp->rotation; + f32 x = delta_interpolate_f32(interp->posX.prev, interp->posX.curr, delta); + f32 y = delta_interpolate_f32(interp->posY.prev, interp->posY.curr, delta); + f32 scaleW = delta_interpolate_f32(interp->scaleX.prev, interp->scaleX.curr, delta); + f32 scaleH = delta_interpolate_f32(interp->scaleY.prev, interp->scaleY.curr, delta); + sHudUtilsState = interp->state; gDjuiHudUtilsZ = interp->z; - gDisplayListHead = interp->headPos; - // translate position - f32 translatedX = x; - f32 translatedY = y; - djui_hud_position_translate(&translatedX, &translatedY); - create_dl_translation_matrix(DJUI_MTX_PUSH, translatedX, translatedY, gDjuiHudUtilsZ); + for (u32 j = 0; j != interp->gfx->count; ++j) { + const InterpHudGfx *gfx = interp->gfx->buffer[j]; + gDisplayListHead = gfx->pos; - // rotate - f32 translatedW = scaleW; - f32 translatedH = scaleH; - djui_hud_size_translate(&translatedW); - djui_hud_size_translate(&translatedH); - if (sRotation.rotationDiff != 0 || sRotation.rotation != 0) { - s32 rotation = delta_interpolate_s32(sRotation.rotation - sRotation.rotationDiff, sRotation.rotation, delta); - f32 pivotX = delta_interpolate_f32(sRotation.prevPivotX, sRotation.pivotX, delta); - f32 pivotY = delta_interpolate_f32(sRotation.prevPivotY, sRotation.pivotY, delta); - f32 pivotTranslationX = interp->width * translatedW * pivotX; - f32 pivotTranslationY = interp->height * translatedH * pivotY; - create_dl_translation_matrix(DJUI_MTX_NOPUSH, +pivotTranslationX, -pivotTranslationY, 0); - create_dl_rotation_matrix(DJUI_MTX_NOPUSH, rotation, 0, 0, 1); - create_dl_translation_matrix(DJUI_MTX_NOPUSH, -pivotTranslationX, +pivotTranslationY, 0); + switch (gfx->type) { + case INTERP_HUD_TRANSLATION: { + f32 translatedX = x; + f32 translatedY = y; + djui_hud_position_translate(&translatedX, &translatedY); + create_dl_translation_matrix(DJUI_MTX_PUSH, translatedX, translatedY, gDjuiHudUtilsZ); + } break; + + case INTERP_HUD_ROTATION: { + if (sHudUtilsState.rotation.degrees.prev != 0 || sHudUtilsState.rotation.degrees.curr != 0) { + f32 translatedW = scaleW; + f32 translatedH = scaleH; + djui_hud_size_translate(&translatedW); + djui_hud_size_translate(&translatedH); + s16 rotPrev = degrees_to_sm64(sHudUtilsState.rotation.degrees.prev); + s16 rotCurr = degrees_to_sm64(sHudUtilsState.rotation.degrees.curr); + s32 normalizedDiff = (((s32) rotCurr - (s32) rotPrev + 0x8000) & 0xFFFF) - 0x8000; // Fix modular overflow/underflow + s32 rotation = delta_interpolate_s32(rotCurr - normalizedDiff, rotCurr, delta); + f32 pivotX = delta_interpolate_f32(sHudUtilsState.rotation.pivotX.prev, sHudUtilsState.rotation.pivotX.curr, delta); + f32 pivotY = delta_interpolate_f32(sHudUtilsState.rotation.pivotY.prev, sHudUtilsState.rotation.pivotY.curr, delta); + f32 pivotTranslationX = interp->width * translatedW * pivotX; + f32 pivotTranslationY = interp->height * translatedH * pivotY; + create_dl_translation_matrix(DJUI_MTX_NOPUSH, +pivotTranslationX, -pivotTranslationY, 0); + create_dl_rotation_matrix(DJUI_MTX_NOPUSH, sm64_to_degrees(rotation), 0, 0, 1); + create_dl_translation_matrix(DJUI_MTX_NOPUSH, -pivotTranslationX, +pivotTranslationY, 0); + } + } break; + + case INTERP_HUD_SCALE: { + f32 translatedW = scaleW; + f32 translatedH = scaleH; + djui_hud_size_translate(&translatedW); + djui_hud_size_translate(&translatedH); + create_dl_scale_matrix(DJUI_MTX_NOPUSH, interp->width * translatedW, interp->height * translatedH, 1.0f); + } break; + + case INTERP_HUD_HALIGN: { + f32 textHAlign = delta_interpolate_f32(sHudUtilsState.textAlignment.h.prev, sHudUtilsState.textAlignment.h.curr, delta); + f32 lineWidth = gfx->params[0]; + create_dl_translation_matrix(DJUI_MTX_NOPUSH, -lineWidth * textHAlign, 0, 0); + } break; + + case INTERP_HUD_VALIGN: { + f32 textVAlign = delta_interpolate_f32(sHudUtilsState.textAlignment.v.prev, sHudUtilsState.textAlignment.v.curr, delta); + f32 textHeight = gfx->params[0]; + create_dl_translation_matrix(DJUI_MTX_NOPUSH, 0, textHeight * textVAlign, 0); + } break; + + case INTERP_HUD_NEW_LINE: { + const struct DjuiFont *font = djui_hud_get_text_font(); + f32 textHAlign = delta_interpolate_f32(sHudUtilsState.textAlignment.h.prev, sHudUtilsState.textAlignment.h.curr, delta); + f32 lineWidth = gfx->params[0]; + create_dl_translation_matrix(DJUI_MTX_NOPUSH, -lineWidth * (1.f - textHAlign), -font->lineHeight, 0); + } break; + } } - - // scale - create_dl_scale_matrix(DJUI_MTX_NOPUSH, interp->width * translatedW, interp->height * translatedH, 1.0f); } - sResolution = savedResolution; - sRotation = savedRotation; + + sHudUtilsState = savedState; gDisplayListHead = savedHeadPos; gDjuiHudUtilsZ = savedZ; } +struct InterpHud *djui_hud_create_interp() { + if (sInterpHudCount >= MAX_INTERP_HUD) { return NULL; } + + struct InterpHud *interp = &sInterpHuds[sInterpHudCount++]; + interp->z = gDjuiHudUtilsZ; + interp->state = sHudUtilsState; + if (!interp->gfx) { + interp->gfx = growing_array_init(NULL, 8, malloc, free); + } else { + interp->gfx->count = 0; + } + + return interp; +} + +InterpHudGfx *djui_hud_create_interp_gfx(struct InterpHud *interp, enum InterpHudType type) { + if (!interp) { return NULL; } + + InterpHudGfx *gfx = growing_array_alloc(interp->gfx, sizeof(InterpHudGfx)); + gfx->type = type; + gfx->pos = gDisplayListHead; + return gfx; +} + //////////// // others // //////////// u8 djui_hud_get_resolution(void) { - return sResolution; + return sHudUtilsState.resolution; } void djui_hud_set_resolution(enum HudUtilsResolution resolutionType) { if (resolutionType >= RESOLUTION_COUNT) { return; } - sResolution = resolutionType; + sHudUtilsState.resolution = resolutionType; } u8 djui_hud_get_filter(void) { - return sFilter; + return sHudUtilsState.filter; } void djui_hud_set_filter(enum HudUtilsFilter filterType) { if (filterType >= FILTER_COUNT) { return; } - sFilter = filterType; + sHudUtilsState.filter = filterType; } -u8 djui_hud_get_font(void) { - return sFont; +s8 djui_hud_get_font(void) { + return sHudUtilsState.font; } void djui_hud_set_font(s8 fontType) { if (fontType >= FONT_COUNT || fontType < -1) { return; } - sLegacy = fontType == -1; - if (sLegacy) { fontType = 0; } - sFont = fontType; + sHudUtilsState.font = fontType; } struct DjuiColor* djui_hud_get_color(void) { - sRefColor.r = sColor.r; - sRefColor.g = sColor.g; - sRefColor.b = sColor.b; - sRefColor.a = sColor.a; + sRefColor.r = sHudUtilsState.color.r; + sRefColor.g = sHudUtilsState.color.g; + sRefColor.b = sHudUtilsState.color.b; + sRefColor.a = sHudUtilsState.color.a; return &sRefColor; } void djui_hud_set_color(u8 r, u8 g, u8 b, u8 a) { - sColor.r = r; - sColor.g = g; - sColor.b = b; - sColor.a = a; + sHudUtilsState.color.r = r; + sHudUtilsState.color.g = g; + sHudUtilsState.color.b = b; + sHudUtilsState.color.a = a; sColorAltered = TRUE; gDPSetEnvColor(gDisplayListHead++, r, g, b, a); } void djui_hud_reset_color(void) { if (sColorAltered) { - sColor.r = 255; - sColor.g = 255; - sColor.b = 255; - sColor.a = 255; + sHudUtilsState.color.r = 255; + sHudUtilsState.color.g = 255; + sHudUtilsState.color.b = 255; + sHudUtilsState.color.a = 255; sColorAltered = FALSE; gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255); } } -struct HudUtilsRotation* djui_hud_get_rotation(void) { - return &sRotation; +void djui_hud_get_rotation(RET s16 *rotation, RET f32 *pivotX, RET f32 *pivotY) { + *rotation = degrees_to_sm64(sHudUtilsState.rotation.degrees.curr); + *pivotX = sHudUtilsState.rotation.pivotX.curr; + *pivotY = sHudUtilsState.rotation.pivotY.curr; } void djui_hud_set_rotation(s16 rotation, f32 pivotX, f32 pivotY) { - sRotation.rotationDiff = 0; - sRotation.prevPivotX = pivotX; - sRotation.prevPivotY = pivotY; - sRotation.rotation = (rotation * 180.f) / 0x8000; - sRotation.pivotX = pivotX; - sRotation.pivotY = pivotY; + sHudUtilsState.rotation.degrees.prev = sHudUtilsState.rotation.degrees.curr = sm64_to_degrees(rotation); + sHudUtilsState.rotation.pivotX.prev = sHudUtilsState.rotation.pivotX.curr = pivotX; + sHudUtilsState.rotation.pivotY.prev = sHudUtilsState.rotation.pivotY.curr = pivotY; } -void djui_hud_set_rotation_interpolated(s32 prevRotation, f32 prevPivotX, f32 prevPivotY, s32 rotation, f32 pivotX, f32 pivotY) { - f32 normalizedDiff = ((rotation - prevRotation + 0x8000) & 0xFFFF) - 0x8000; // Fix modular overflow/underflow - sRotation.rotationDiff = (normalizedDiff * 180.f) / 0x8000; - sRotation.prevPivotX = prevPivotX; - sRotation.prevPivotY = prevPivotY; - sRotation.rotation = (rotation * 180.f) / 0x8000; - sRotation.pivotX = pivotX; - sRotation.pivotY = pivotY; +void djui_hud_set_rotation_interpolated(s16 prevRotation, f32 prevPivotX, f32 prevPivotY, s16 rotation, f32 pivotX, f32 pivotY) { + sHudUtilsState.rotation.degrees.prev = sm64_to_degrees(prevRotation); + sHudUtilsState.rotation.degrees.curr = sm64_to_degrees(rotation); + sHudUtilsState.rotation.pivotX.prev = prevPivotX; + sHudUtilsState.rotation.pivotX.curr = pivotX; + sHudUtilsState.rotation.pivotY.prev = prevPivotY; + sHudUtilsState.rotation.pivotY.curr = pivotY; +} + +void djui_hud_get_text_alignment(RET f32 *textHAlign, RET f32 *textVAlign) { + *textHAlign = sHudUtilsState.textAlignment.h.curr; + *textVAlign = sHudUtilsState.textAlignment.v.curr; +} + +void djui_hud_set_text_alignment(f32 textHAlign, f32 textVAlign) { + sHudUtilsState.textAlignment.h.prev = sHudUtilsState.textAlignment.h.curr = textHAlign; + sHudUtilsState.textAlignment.v.prev = sHudUtilsState.textAlignment.v.curr = textVAlign; +} + +void djui_hud_set_text_alignment_interpolated(f32 prevTextHAlign, f32 prevTextVAlign, f32 textHAlign, f32 textVAlign) { + sHudUtilsState.textAlignment.h.prev = prevTextHAlign; + sHudUtilsState.textAlignment.h.curr = textHAlign; + sHudUtilsState.textAlignment.v.prev = prevTextVAlign; + sHudUtilsState.textAlignment.v.curr = textVAlign; } u32 djui_hud_get_screen_width(void) { u32 windowWidth, windowHeight; gfx_get_dimensions(&windowWidth, &windowHeight); - return (sResolution == RESOLUTION_N64) + return (sHudUtilsState.resolution == RESOLUTION_N64) ? GFX_DIMENSIONS_ASPECT_RATIO * SCREEN_HEIGHT : (windowWidth / djui_gfx_get_scale()); } @@ -274,7 +394,7 @@ u32 djui_hud_get_screen_height(void) { u32 windowWidth, windowHeight; gfx_get_dimensions(&windowWidth, &windowHeight); - return (sResolution == RESOLUTION_N64) + return (sHudUtilsState.resolution == RESOLUTION_N64) ? SCREEN_HEIGHT : (windowHeight / djui_gfx_get_scale()); } @@ -364,23 +484,58 @@ void djui_hud_reset_scissor(void) { f32 djui_hud_measure_text(const char* message) { if (message == NULL) { return 0; } - const struct DjuiFont* font = gDjuiFonts[sFont]; - f32 width = 0; - const char* c = message; - while(*c != '\0') { - width += font->char_width((char*)c) * (sLegacy ? 0.5f : 1.0f); - c = djui_unicode_next_char((char*)c); + const struct DjuiFont* font = djui_hud_get_text_font(); + f32 width = 0, maxWidth = 0; + char *c = (char *) message; + const char *end = message + strlen(message); + while (*c != '\0') { + + // check color code + if (djui_text_parse_color(c, end, false, NULL, &c, NULL)) { + continue; + } + + // new line + if (*c == '\n') { + maxWidth = max(width, maxWidth); + width = 0; + } + + // tab: align to the next (4 x space width) + else if (*c == '\t') { + f32 tabWidth = 4 * font->char_width(" ") * (djui_hud_text_font_is_legacy() ? 0.5f : 1.0f); + width += tabWidth - fmodf(width, tabWidth); + } + + // unprintable chars + else if (!djui_text_is_printable(c)) { + // treat them as empty + } + + // regular chars + else { + width += font->char_width(c) * (djui_hud_text_font_is_legacy() ? 0.5f : 1.0f); + } + + c = djui_unicode_next_char(c); } - return width * font->defaultFontScale; + return max(width, maxWidth) * font->defaultFontScale; } -void djui_hud_print_text(const char* message, f32 x, f32 y, f32 scale) { +static Mtx *allocate_dl_translation_matrix() { + Mtx *matrix = (Mtx *) alloc_display_list(sizeof(Mtx)); + if (matrix == NULL) { return NULL; } + gSPMatrix(gDisplayListHead++, matrix, G_MTX_MODELVIEW | G_MTX_MUL | G_MTX_NOPUSH); + return matrix; +} + +static void djui_hud_print_text_internal(const char* message, f32 x, f32 y, f32 scale, struct InterpHud *interp) { if (message == NULL) { return; } - gDjuiHudUtilsZ += 0.01f; + gDjuiHudUtilsZ += 0.001f; - if (sLegacy) { scale *= 0.5f; } + if (djui_hud_text_font_is_legacy()) { scale *= 0.5f; } - const struct DjuiFont* font = gDjuiFonts[sFont]; + const struct DjuiFont* font = djui_hud_get_text_font(); f32 fontScale = font->defaultFontScale * scale; // setup display list @@ -389,117 +544,147 @@ void djui_hud_print_text(const char* message, f32 x, f32 y, f32 scale) { } // translate position + djui_hud_create_interp_gfx(interp, INTERP_HUD_TRANSLATION); f32 translatedX = x + (font->xOffset * scale); f32 translatedY = y + (font->yOffset * scale); djui_hud_position_translate(&translatedX, &translatedY); create_dl_translation_matrix(DJUI_MTX_PUSH, translatedX, translatedY, gDjuiHudUtilsZ); - // compute font size + // rotate f32 translatedFontSize = fontScale; djui_hud_size_translate(&translatedFontSize); + if (sHudUtilsState.rotation.degrees.prev != 0 || sHudUtilsState.rotation.degrees.curr != 0) { + djui_hud_create_interp_gfx(interp, INTERP_HUD_ROTATION); + f32 pivotTranslationX = font->defaultFontScale * translatedFontSize * sHudUtilsState.rotation.pivotX.curr; + f32 pivotTranslationY = font->defaultFontScale * translatedFontSize * sHudUtilsState.rotation.pivotY.curr; + create_dl_translation_matrix(DJUI_MTX_NOPUSH, +pivotTranslationX, -pivotTranslationY, 0); + create_dl_rotation_matrix(DJUI_MTX_NOPUSH, sHudUtilsState.rotation.degrees.curr, 0, 0, 1); + create_dl_translation_matrix(DJUI_MTX_NOPUSH, -pivotTranslationX, +pivotTranslationY, 0); + } + + // compute font size + djui_hud_create_interp_gfx(interp, INTERP_HUD_SCALE); create_dl_scale_matrix(DJUI_MTX_NOPUSH, translatedFontSize, translatedFontSize, 1.0f); - // render the line - f32 addX = 0; - char* c = (char*)message; - while (*c != '\0') { - f32 charWidth = font->char_width(c); + // allocate the translation matrix for the vertical alignment + InterpHudGfx *valignGfx = djui_hud_create_interp_gfx(interp, INTERP_HUD_VALIGN); + Mtx *valignMatrix = allocate_dl_translation_matrix(); + if (valignMatrix == NULL) { return; } - if (*c == '\n' && *c == ' ') { - addX += charWidth; - c++; + // allocate the translation matrix for the horizontal alignment + InterpHudGfx *halignGfx = djui_hud_create_interp_gfx(interp, INTERP_HUD_HALIGN); + Mtx *halignMatrix = allocate_dl_translation_matrix(); + if (halignMatrix == NULL) { return; } + + // render the line + char* c = (char*)message; + const char *end = message + strlen(message); + f32 lineWidth = 0; + f32 textHeight = font->lineHeight; + + font->render_begin(); + while (*c != '\0') { + + // check color code + struct DjuiColor parsedColor; + if (djui_text_parse_color(c, end, false, &sHudUtilsState.color, &c, &parsedColor)) { + gDPSetEnvColor(gDisplayListHead++, parsedColor.r, parsedColor.g, parsedColor.b, parsedColor.a); + continue; + } + + // new line + if (*c == '\n') { + + // compute the horizontal alignment matrix for the current line + guTranslate(halignMatrix, -lineWidth * sHudUtilsState.textAlignment.h.curr, 0, 0); + if (halignGfx) { halignGfx->params[0] = lineWidth; } + + // allocate a new translation matrix for the next line + halignGfx = djui_hud_create_interp_gfx(interp, INTERP_HUD_HALIGN); + halignMatrix = allocate_dl_translation_matrix(); + if (halignMatrix == NULL) { return; } + + // cancel out the line translation and move to the next line + // this is needed because otherwise the text would be rendered in a staircase way + InterpHudGfx *newlineGfx = djui_hud_create_interp_gfx(interp, INTERP_HUD_NEW_LINE); + create_dl_translation_matrix(DJUI_MTX_NOPUSH, -lineWidth * (1.f - sHudUtilsState.textAlignment.h.curr), -font->lineHeight, 0); + if (newlineGfx) { newlineGfx->params[0] = lineWidth; } + lineWidth = 0; + textHeight += font->lineHeight; + c = djui_unicode_next_char(c); + continue; + } + + // tab: align to the next (4 x space width) + else if (*c == '\t') { + f32 tabWidth = 4 * font->char_width(" "); + f32 newLineWidth = lineWidth + tabWidth - fmodf(lineWidth, tabWidth); + create_dl_translation_matrix(DJUI_MTX_NOPUSH, newLineWidth - lineWidth, 0, 0); + lineWidth = newLineWidth; + c = djui_unicode_next_char(c); + continue; + } + + // unprintable chars + if (!djui_text_is_printable(c)) { + c = djui_unicode_next_char(c); continue; } // render + f32 charWidth = font->char_width(c); font->render_char(c); - create_dl_translation_matrix(DJUI_MTX_NOPUSH, charWidth + addX, 0, 0); - addX = 0; + create_dl_translation_matrix(DJUI_MTX_NOPUSH, charWidth, 0, 0); + lineWidth += charWidth; c = djui_unicode_next_char(c); } + font->render_end(); + + // compute the horizontal alignment matrix for the last line + guTranslate(halignMatrix, -lineWidth * sHudUtilsState.textAlignment.h.curr, 0, 0); + if (halignGfx) { halignGfx->params[0] = lineWidth; } + + // compute the vertical alignment matrix + guTranslate(valignMatrix, 0, textHeight * sHudUtilsState.textAlignment.v.curr, 0); + if (valignGfx) { valignGfx->params[0] = textHeight; } // pop gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); } +void djui_hud_print_text(const char* message, f32 x, f32 y, f32 scale) { + djui_hud_print_text_internal(message, x, y, scale, NULL); +} + void djui_hud_print_text_interpolated(const char* message, f32 prevX, f32 prevY, f32 prevScale, f32 x, f32 y, f32 scale) { if (message == NULL) { return; } - f32 savedZ = gDjuiHudUtilsZ; - gDjuiHudUtilsZ += 0.01f; - if (sLegacy) { - prevScale *= 0.5f; - scale *= 0.5f; + if (djui_hud_text_font_is_legacy()) { prevScale *= 0.5f; } + + struct InterpHud *interp = djui_hud_create_interp(); + if (interp) { + const struct DjuiFont* font = djui_hud_get_text_font(); + interp->posX.prev = prevX; + interp->posY.prev = prevY; + interp->posX.curr = x; + interp->posY.curr = y; + interp->scaleX.prev = prevScale; + interp->scaleY.prev = prevScale; + interp->scaleX.curr = scale; + interp->scaleY.curr = scale; + interp->width = font->defaultFontScale; + interp->height = font->defaultFontScale; } - const struct DjuiFont* font = gDjuiFonts[sFont]; - f32 fontScale = font->defaultFontScale * scale; - - // setup display list - if (font->textBeginDisplayList != NULL) { - gSPDisplayList(gDisplayListHead++, font->textBeginDisplayList); - } - - Gfx* savedHeadPos = gDisplayListHead; - - // translate position - f32 translatedX = x + (font->xOffset * scale); - f32 translatedY = y + (font->yOffset * scale); - djui_hud_position_translate(&translatedX, &translatedY); - create_dl_translation_matrix(DJUI_MTX_PUSH, translatedX, translatedY, gDjuiHudUtilsZ); - - // compute font size - f32 translatedFontSize = fontScale; - djui_hud_size_translate(&translatedFontSize); - create_dl_scale_matrix(DJUI_MTX_NOPUSH, translatedFontSize, translatedFontSize, 1.0f); - - // render the line - f32 addX = 0; - char* c = (char*)message; - while (*c != '\0') { - f32 charWidth = font->char_width(c); - - if (*c == '\n' && *c == ' ') { - addX += charWidth; - c++; - continue; - } - - // render - font->render_char(c); - create_dl_translation_matrix(DJUI_MTX_NOPUSH, charWidth + addX, 0, 0); - addX = 0; - - c = djui_unicode_next_char(c); - } - - // pop - gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); - - if (sInterpHudCount >= MAX_INTERP_HUD) { return; } - struct InterpHud* interp = &sInterpHuds[sInterpHudCount++]; - interp->headPos = savedHeadPos; - interp->prevX = prevX; - interp->prevY = prevY; - interp->prevScaleW = prevScale; - interp->prevScaleH = prevScale; - interp->x = x; - interp->y = y; - interp->scaleW = scale; - interp->scaleH = scale; - interp->width = font->defaultFontScale; - interp->height = font->defaultFontScale; - interp->z = savedZ; - interp->resolution = sResolution; - interp->rotation = sRotation; + djui_hud_print_text_internal(message, x, y, scale, interp); } static inline bool is_power_of_two(u32 n) { return (n > 0) && ((n & (n - 1)) == 0); } -static void djui_hud_render_texture_raw(const Texture* texture, u32 width, u32 height, u8 fmt, u8 siz, f32 x, f32 y, f32 scaleW, f32 scaleH) { +static void djui_hud_render_texture_raw(const Texture* texture, u32 width, u32 height, u8 fmt, u8 siz, f32 x, f32 y, f32 scaleW, f32 scaleH, struct InterpHud *interp) { if (!is_power_of_two(width) || !is_power_of_two(height)) { LOG_LUA_LINE("Tried to render DJUI HUD texture with NPOT width or height"); return; @@ -507,9 +692,10 @@ static void djui_hud_render_texture_raw(const Texture* texture, u32 width, u32 h if (!texture) { return; } - gDjuiHudUtilsZ += 0.01f; + gDjuiHudUtilsZ += 0.001f; // translate position + djui_hud_create_interp_gfx(interp, INTERP_HUD_TRANSLATION); f32 translatedX = x; f32 translatedY = y; djui_hud_position_translate(&translatedX, &translatedY); @@ -520,32 +706,35 @@ static void djui_hud_render_texture_raw(const Texture* texture, u32 width, u32 h f32 translatedH = scaleH; djui_hud_size_translate(&translatedW); djui_hud_size_translate(&translatedH); - if (sRotation.rotation != 0) { - f32 pivotTranslationX = width * translatedW * sRotation.pivotX; - f32 pivotTranslationY = height * translatedH * sRotation.pivotY; + if (sHudUtilsState.rotation.degrees.prev != 0 || sHudUtilsState.rotation.degrees.curr != 0) { + djui_hud_create_interp_gfx(interp, INTERP_HUD_ROTATION); + f32 pivotTranslationX = width * translatedW * sHudUtilsState.rotation.pivotX.curr; + f32 pivotTranslationY = height * translatedH * sHudUtilsState.rotation.pivotY.curr; create_dl_translation_matrix(DJUI_MTX_NOPUSH, +pivotTranslationX, -pivotTranslationY, 0); - create_dl_rotation_matrix(DJUI_MTX_NOPUSH, sRotation.rotation, 0, 0, 1); + create_dl_rotation_matrix(DJUI_MTX_NOPUSH, sHudUtilsState.rotation.degrees.curr, 0, 0, 1); create_dl_translation_matrix(DJUI_MTX_NOPUSH, -pivotTranslationX, +pivotTranslationY, 0); } // translate scale + djui_hud_create_interp_gfx(interp, INTERP_HUD_SCALE); create_dl_scale_matrix(DJUI_MTX_NOPUSH, width * translatedW, height * translatedH, 1.0f); // render - djui_gfx_render_texture(texture, width, height, fmt, siz, sFilter); + djui_gfx_render_texture(texture, width, height, fmt, siz, sHudUtilsState.filter); // pop gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); } -static void djui_hud_render_texture_tile_raw(const Texture* texture, u32 width, u32 height, u8 fmt, u8 siz, f32 x, f32 y, f32 scaleW, f32 scaleH, u32 tileX, u32 tileY, u32 tileW, u32 tileH) { +static void djui_hud_render_texture_tile_raw(const Texture* texture, u32 width, u32 height, u8 fmt, u8 siz, f32 x, f32 y, f32 scaleW, f32 scaleH, u32 tileX, u32 tileY, u32 tileW, u32 tileH, struct InterpHud *interp) { if (!texture) { return; } - gDjuiHudUtilsZ += 0.01f; + gDjuiHudUtilsZ += 0.001f; if (width != 0) { scaleW *= (f32) tileW / (f32) width; } if (height != 0) { scaleH *= (f32) tileH / (f32) height; } // translate position + djui_hud_create_interp_gfx(interp, INTERP_HUD_TRANSLATION); f32 translatedX = x; f32 translatedY = y; djui_hud_position_translate(&translatedX, &translatedY); @@ -556,20 +745,22 @@ static void djui_hud_render_texture_tile_raw(const Texture* texture, u32 width, f32 translatedH = scaleH; djui_hud_size_translate(&translatedW); djui_hud_size_translate(&translatedH); - if (sRotation.rotation != 0) { + if (sHudUtilsState.rotation.degrees.prev != 0 || sHudUtilsState.rotation.degrees.curr != 0) { + djui_hud_create_interp_gfx(interp, INTERP_HUD_ROTATION); f32 aspect = tileH ? ((f32) tileW / (f32) tileH) : 1.f; - f32 pivotTranslationX = width * translatedW * aspect * sRotation.pivotX; - f32 pivotTranslationY = height * translatedH * sRotation.pivotY; + f32 pivotTranslationX = width * translatedW * aspect * sHudUtilsState.rotation.pivotX.curr; + f32 pivotTranslationY = height * translatedH * sHudUtilsState.rotation.pivotY.curr; create_dl_translation_matrix(DJUI_MTX_NOPUSH, +pivotTranslationX, -pivotTranslationY, 0); - create_dl_rotation_matrix(DJUI_MTX_NOPUSH, sRotation.rotation, 0, 0, 1); + create_dl_rotation_matrix(DJUI_MTX_NOPUSH, sHudUtilsState.rotation.degrees.curr, 0, 0, 1); create_dl_translation_matrix(DJUI_MTX_NOPUSH, -pivotTranslationX, +pivotTranslationY, 0); } // translate scale + djui_hud_create_interp_gfx(interp, INTERP_HUD_SCALE); create_dl_scale_matrix(DJUI_MTX_NOPUSH, width * translatedW, height * translatedH, 1.0f); // render - djui_gfx_render_texture_tile(texture, width, height, fmt, siz, tileX, tileY, tileW, tileH, sFilter, false); + djui_gfx_render_texture_tile(texture, width, height, fmt, siz, tileX, tileY, tileW, tileH, sHudUtilsState.filter); // pop gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); @@ -577,44 +768,35 @@ static void djui_hud_render_texture_tile_raw(const Texture* texture, u32 width, void djui_hud_render_texture(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH) { if (!texInfo) { return; } - djui_hud_render_texture_raw(texInfo->texture, texInfo->width, texInfo->height, texInfo->format, texInfo->size, x, y, scaleW, scaleH); + djui_hud_render_texture_raw(texInfo->texture, texInfo->width, texInfo->height, texInfo->format, texInfo->size, x, y, scaleW, scaleH, NULL); } void djui_hud_render_texture_tile(struct TextureInfo* texInfo, f32 x, f32 y, f32 scaleW, f32 scaleH, u32 tileX, u32 tileY, u32 tileW, u32 tileH) { if (!texInfo) { return; } - djui_hud_render_texture_tile_raw(texInfo->texture, texInfo->width, texInfo->height, texInfo->format, texInfo->size, x, y, scaleW, scaleH, tileX, tileY, tileW, tileH); + djui_hud_render_texture_tile_raw(texInfo->texture, texInfo->width, texInfo->height, texInfo->format, texInfo->size, x, y, scaleW, scaleH, tileX, tileY, tileW, tileH, NULL); } void djui_hud_render_texture_interpolated(struct TextureInfo* texInfo, f32 prevX, f32 prevY, f32 prevScaleW, f32 prevScaleH, f32 x, f32 y, f32 scaleW, f32 scaleH) { - Gfx* savedHeadPos = gDisplayListHead; - f32 savedZ = gDjuiHudUtilsZ; - if (!texInfo) { return; } - djui_hud_render_texture_raw(texInfo->texture, texInfo->width, texInfo->height, texInfo->format, texInfo->size, prevX, prevY, prevScaleW, prevScaleH); + struct InterpHud *interp = djui_hud_create_interp(); + if (interp) { + interp->posX.prev = prevX; + interp->posY.prev = prevY; + interp->posX.curr = x; + interp->posY.curr = y; + interp->scaleX.prev = prevScaleW; + interp->scaleY.prev = prevScaleH; + interp->scaleX.curr = scaleW; + interp->scaleY.curr = scaleH; + interp->width = texInfo->width; + interp->height = texInfo->height; + } - if (sInterpHudCount >= MAX_INTERP_HUD) { return; } - struct InterpHud* interp = &sInterpHuds[sInterpHudCount++]; - interp->headPos = savedHeadPos; - interp->prevX = prevX; - interp->prevY = prevY; - interp->prevScaleW = prevScaleW; - interp->prevScaleH = prevScaleH; - interp->x = x; - interp->y = y; - interp->scaleW = scaleW; - interp->scaleH = scaleH; - interp->width = texInfo->width; - interp->height = texInfo->height; - interp->z = savedZ; - interp->resolution = sResolution; - interp->rotation = sRotation; + djui_hud_render_texture_raw(texInfo->texture, texInfo->width, texInfo->height, texInfo->format, texInfo->size, prevX, prevY, prevScaleW, prevScaleH, interp); } void djui_hud_render_texture_tile_interpolated(struct TextureInfo* texInfo, f32 prevX, f32 prevY, f32 prevScaleW, f32 prevScaleH, f32 x, f32 y, f32 scaleW, f32 scaleH, u32 tileX, u32 tileY, u32 tileW, u32 tileH) { - Gfx* savedHeadPos = gDisplayListHead; - f32 savedZ = gDjuiHudUtilsZ; - if (!texInfo) { return; } // apply scale correction for tiles @@ -627,30 +809,28 @@ void djui_hud_render_texture_tile_interpolated(struct TextureInfo* texInfo, f32 prevScaleH *= ((f32)tileH / (f32)texInfo->height); } - djui_hud_render_texture_tile_raw(texInfo->texture, texInfo->width, texInfo->height, texInfo->format, texInfo->size, prevX, prevY, prevScaleW, prevScaleH, tileX, tileY, tileW, tileH); + struct InterpHud *interp = djui_hud_create_interp(); + if (interp) { + interp->posX.prev = prevX; + interp->posY.prev = prevY; + interp->posX.curr = x; + interp->posY.curr = y; + interp->scaleX.prev = prevScaleW; + interp->scaleY.prev = prevScaleH; + interp->scaleX.curr = scaleW; + interp->scaleY.curr = scaleH; + interp->width = texInfo->width; + interp->height = texInfo->height; + } - if (sInterpHudCount >= MAX_INTERP_HUD) { return; } - struct InterpHud* interp = &sInterpHuds[sInterpHudCount++]; - interp->headPos = savedHeadPos; - interp->prevX = prevX; - interp->prevY = prevY; - interp->prevScaleW = prevScaleW; - interp->prevScaleH = prevScaleH; - interp->x = x; - interp->y = y; - interp->scaleW = scaleW; - interp->scaleH = scaleH; - interp->width = texInfo->width; - interp->height = texInfo->height; - interp->z = savedZ; - interp->resolution = sResolution; - interp->rotation = sRotation; + djui_hud_render_texture_tile_raw(texInfo->texture, texInfo->width, texInfo->height, texInfo->format, texInfo->size, prevX, prevY, prevScaleW, prevScaleH, tileX, tileY, tileW, tileH, interp); } -void djui_hud_render_rect(f32 x, f32 y, f32 width, f32 height) { - gDjuiHudUtilsZ += 0.01f; +static void djui_hud_render_rect_internal(f32 x, f32 y, f32 width, f32 height, struct InterpHud *interp) { + gDjuiHudUtilsZ += 0.001f; // translate position + djui_hud_create_interp_gfx(interp, INTERP_HUD_TRANSLATION); f32 translatedX = x; f32 translatedY = y; djui_hud_position_translate(&translatedX, &translatedY); @@ -661,15 +841,17 @@ void djui_hud_render_rect(f32 x, f32 y, f32 width, f32 height) { f32 translatedH = height; djui_hud_size_translate(&translatedW); djui_hud_size_translate(&translatedH); - if (sRotation.rotation != 0) { - f32 pivotTranslationX = translatedW * sRotation.pivotX; - f32 pivotTranslationY = translatedH * sRotation.pivotY; + if (sHudUtilsState.rotation.degrees.prev != 0 || sHudUtilsState.rotation.degrees.curr != 0) { + djui_hud_create_interp_gfx(interp, INTERP_HUD_ROTATION); + f32 pivotTranslationX = translatedW * sHudUtilsState.rotation.pivotX.curr; + f32 pivotTranslationY = translatedH * sHudUtilsState.rotation.pivotY.curr; create_dl_translation_matrix(DJUI_MTX_NOPUSH, +pivotTranslationX, -pivotTranslationY, 0); - create_dl_rotation_matrix(DJUI_MTX_NOPUSH, sRotation.rotation, 0, 0, 1); + create_dl_rotation_matrix(DJUI_MTX_NOPUSH, sHudUtilsState.rotation.degrees.curr, 0, 0, 1); create_dl_translation_matrix(DJUI_MTX_NOPUSH, -pivotTranslationX, +pivotTranslationY, 0); } // translate scale + djui_hud_create_interp_gfx(interp, INTERP_HUD_SCALE); create_dl_scale_matrix(DJUI_MTX_NOPUSH, translatedW, translatedH, 1.0f); // render @@ -679,28 +861,26 @@ void djui_hud_render_rect(f32 x, f32 y, f32 width, f32 height) { gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); } +void djui_hud_render_rect(f32 x, f32 y, f32 width, f32 height) { + djui_hud_render_rect_internal(x, y, width, height, NULL); +} + void djui_hud_render_rect_interpolated(f32 prevX, f32 prevY, f32 prevWidth, f32 prevHeight, f32 x, f32 y, f32 width, f32 height) { - Gfx* savedHeadPos = gDisplayListHead; - f32 savedZ = gDjuiHudUtilsZ; + struct InterpHud *interp = djui_hud_create_interp(); + if (interp) { + interp->posX.prev = prevX; + interp->posY.prev = prevY; + interp->posX.curr = x; + interp->posY.curr = y; + interp->scaleX.prev = prevWidth; + interp->scaleY.prev = prevHeight; + interp->scaleX.curr = width; + interp->scaleY.curr = height; + interp->width = 1; + interp->height = 1; + } - djui_hud_render_rect(prevX, prevY, prevWidth, prevHeight); - - if (sInterpHudCount >= MAX_INTERP_HUD) { return; } - struct InterpHud* interp = &sInterpHuds[sInterpHudCount++]; - interp->headPos = savedHeadPos; - interp->prevX = prevX; - interp->prevY = prevY; - interp->prevScaleW = prevWidth; - interp->prevScaleH = prevHeight; - interp->x = x; - interp->y = y; - interp->scaleW = width; - interp->scaleH = height; - interp->width = 1; - interp->height = 1; - interp->z = savedZ; - interp->resolution = sResolution; - interp->rotation = sRotation; + djui_hud_render_rect_internal(prevX, prevY, prevWidth, prevHeight, interp); } void djui_hud_render_line(f32 p1X, f32 p1Y, f32 p2X, f32 p2Y, f32 size) { @@ -752,7 +932,7 @@ bool djui_hud_world_pos_to_screen_pos(Vec3f pos, VEC_OUT Vec3f out) { out[1] *= fovCoeff; f32 screenWidth, screenHeight; - if (sResolution == RESOLUTION_N64) { + if (sHudUtilsState.resolution == RESOLUTION_N64) { screenWidth = GFX_DIMENSIONS_ASPECT_RATIO * SCREEN_HEIGHT; screenHeight = SCREEN_HEIGHT; } else { diff --git a/src/pc/djui/djui_hud_utils.h b/src/pc/djui/djui_hud_utils.h index b4e1b9d08..353ee3511 100644 --- a/src/pc/djui/djui_hud_utils.h +++ b/src/pc/djui/djui_hud_utils.h @@ -1,6 +1,22 @@ #ifndef DJUI_HUD_UTILS_H #define DJUI_HUD_UTILS_H +// Common pivot values for rotation +#define ROTATION_PIVOT_X_LEFT 0.0 +#define ROTATION_PIVOT_X_CENTER 0.5 +#define ROTATION_PIVOT_X_RIGHT 1.0 +#define ROTATION_PIVOT_Y_TOP 0.0 +#define ROTATION_PIVOT_Y_CENTER 0.5 +#define ROTATION_PIVOT_Y_BOTTOM 1.0 + +// Common alignment values for text alignment +#define TEXT_HALIGN_LEFT 0.0 +#define TEXT_HALIGN_CENTER 0.5 +#define TEXT_HALIGN_RIGHT 1.0 +#define TEXT_VALIGN_TOP 0.0 +#define TEXT_VALIGN_CENTER 0.5 +#define TEXT_VALIGN_BOTTOM 1.0 + enum HudUtilsResolution { RESOLUTION_DJUI, RESOLUTION_N64, @@ -14,7 +30,8 @@ enum HudUtilsFilter { }; enum DjuiFontType { - FONT_NORMAL, + FONT_LEGACY = -1, + FONT_NORMAL = 0, FONT_MENU, FONT_HUD, FONT_ALIASED, @@ -24,15 +41,6 @@ enum DjuiFontType { FONT_COUNT, }; -struct HudUtilsRotation { - f32 rotation; - f32 rotationDiff; - f32 prevPivotX; - f32 prevPivotY; - f32 pivotX; - f32 pivotY; -}; - struct GlobalTextures { struct TextureInfo camera; struct TextureInfo lakitu; @@ -63,7 +71,7 @@ u8 djui_hud_get_filter(void); /* |description|Sets the current DJUI HUD texture filter|descriptionEnd| */ void djui_hud_set_filter(enum HudUtilsFilter filterType); /* |description|Gets the current DJUI HUD font|descriptionEnd| */ -u8 djui_hud_get_font(void); +s8 djui_hud_get_font(void); /* |description|Sets the current DJUI HUD font|descriptionEnd| */ void djui_hud_set_font(s8 fontType); /* |description|Gets the current DJUI HUD color|descriptionEnd| */ @@ -73,11 +81,17 @@ void djui_hud_set_color(u8 r, u8 g, u8 b, u8 a); /* |description|Resets the current DJUI HUD color|descriptionEnd| */ void djui_hud_reset_color(void); /* |description|Gets the current DJUI HUD rotation|descriptionEnd| */ -struct HudUtilsRotation* djui_hud_get_rotation(void); +void djui_hud_get_rotation(RET s16 *rotation, RET f32 *pivotX, RET f32 *pivotY); /* |description|Sets the current DJUI HUD rotation|descriptionEnd| */ void djui_hud_set_rotation(s16 rotation, f32 pivotX, f32 pivotY); /* |description|Sets the current DJUI HUD rotation interpolated|descriptionEnd| */ -void djui_hud_set_rotation_interpolated(s32 prevRotation, f32 prevPivotX, f32 prevPivotY, s32 rotation, f32 pivotX, f32 pivotY); +void djui_hud_set_rotation_interpolated(s16 prevRotation, f32 prevPivotX, f32 prevPivotY, s16 rotation, f32 pivotX, f32 pivotY); +/* |description|Gets the current DJUI HUD text alignment|descriptionEnd| */ +void djui_hud_get_text_alignment(RET f32 *textHAlign, RET f32 *textVAlign); +/* |description|Sets the current DJUI HUD text alignment|descriptionEnd| */ +void djui_hud_set_text_alignment(f32 textHAlign, f32 textVAlign); +/* |description|Sets the current DJUI HUD text alignment interpolated|descriptionEnd| */ +void djui_hud_set_text_alignment_interpolated(f32 prevTextHAlign, f32 prevTextVAlign, f32 textHAlign, f32 textVAlign); /* |description|Gets the screen width in the current DJUI HUD resolution|descriptionEnd| */ u32 djui_hud_get_screen_width(void); diff --git a/src/pc/djui/djui_inputbox.c b/src/pc/djui/djui_inputbox.c index 878a3a94d..c0a911130 100644 --- a/src/pc/djui/djui_inputbox.c +++ b/src/pc/djui/djui_inputbox.c @@ -589,6 +589,8 @@ static bool djui_inputbox_render(struct DjuiBase* base) { f32 drawX = inputbox->viewX; f32 additionalShift = 0; bool wasInsideSelection = false; + + font->render_begin(); for (u16 i = 0; i < inputbox->bufferSize; i++) { //render composition text @@ -617,6 +619,7 @@ static bool djui_inputbox_render(struct DjuiBase* base) { djui_inputbox_render_char(inputbox, c, &drawX, &additionalShift); c = djui_unicode_next_char(c); } + font->render_end(); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); gSPDisplayList(gDisplayListHead++, dl_ia_text_end); diff --git a/src/pc/djui/djui_panel_mod_menu.c b/src/pc/djui/djui_panel_mod_menu.c index 782fcddee..36437b2c6 100644 --- a/src/pc/djui/djui_panel_mod_menu.c +++ b/src/pc/djui/djui_panel_mod_menu.c @@ -113,7 +113,8 @@ void djui_panel_mod_menu_mod_create(struct DjuiBase* caller) { } if (mod == NULL) { return; } - struct DjuiThreePanel* panel = djui_panel_menu_create(to_uppercase(mod->name), false); + char *modNameUppercase = to_uppercase(mod->name); + struct DjuiThreePanel* panel = djui_panel_menu_create(modNameUppercase, false); struct DjuiBase* body = djui_three_panel_get_body(panel); { struct DjuiPaginated* paginated = djui_paginated_create(body, 8); @@ -130,6 +131,7 @@ void djui_panel_mod_menu_mod_create(struct DjuiBase* caller) { } djui_panel_add(caller, panel, NULL); + free(modNameUppercase); } void djui_panel_mod_menu_create(struct DjuiBase* caller) { diff --git a/src/pc/djui/djui_text.c b/src/pc/djui/djui_text.c index 48f362aac..26fd4ea9c 100644 --- a/src/pc/djui/djui_text.c +++ b/src/pc/djui/djui_text.c @@ -4,10 +4,146 @@ #include "djui_hud_utils.h" #include "game/segment2.h" -static u8 sSavedR = 0; -static u8 sSavedG = 0; -static u8 sSavedB = 0; -static u8 sSavedA = 0; + /////////// + // color // +/////////// + +static const struct DjuiColor sDjuiTextDefaultColor = { 220, 220, 220, 255 }; +static struct DjuiColor sDjuiTextCurrentColor; + +bool djui_text_parse_color(char *begin, const char *end, bool ignoreAlpha, const struct DjuiColor *baseColor, char **nextChar, struct DjuiColor *parsedColor) { + char *c = begin; + + // Not an escape + if (*c != '\\') { + return false; + } + c = djui_unicode_next_char(c); + + // Not a color + if (*c != '#') { + return false; + } + c = djui_unicode_next_char(c); + + // Parse color + u32 color = 0; + u8 length = 0; + while (c < end) { + if (*c == '\\') { + break; + } + + u8 colorPiece = 0; + if (*c >= '0' && *c <= '9') { colorPiece = *c - '0'; } + else if (*c >= 'a' && *c <= 'f') { colorPiece = 10 + *c - 'a'; } + else if (*c >= 'A' && *c <= 'F') { colorPiece = 10 + *c - 'A'; } + else { // Not a valid color piece + return false; + } + color = (color << 4) | colorPiece; + length++; + + c = djui_unicode_next_char(c); + } + + // Unterminated color code + if (c == end) { + return false; + } + + switch (length) { + + // reset to base color + case 0: { + if (baseColor && parsedColor) { + *parsedColor = *baseColor; + } + } break; + + // #rgb + case 3: { + if (parsedColor) { + u32 r = (color >> 8) & 0xF; + u32 g = (color >> 4) & 0xF; + u32 b = (color >> 0) & 0xF; + parsedColor->r = (r << 4) | r; + parsedColor->g = (g << 4) | g; + parsedColor->b = (b << 4) | b; + parsedColor->a = 0xFF; + } + } break; + + // #rgba + case 4: { + if (parsedColor) { + u32 r = (color >> 12) & 0xF; + u32 g = (color >> 8) & 0xF; + u32 b = (color >> 4) & 0xF; + u32 a = (color >> 0) & 0xF; + parsedColor->r = (r << 4) | r; + parsedColor->g = (g << 4) | g; + parsedColor->b = (b << 4) | b; + parsedColor->a = ignoreAlpha ? 0xFF : ((a << 4) | a); + } + } break; + + // #rrggbb + case 6: { + if (parsedColor) { + parsedColor->r = ((color >> 16) & 0xFF); + parsedColor->g = ((color >> 8) & 0xFF); + parsedColor->b = ((color >> 0) & 0xFF); + parsedColor->a = 0xFF; + } + } break; + + // #rrggbbaa + case 8: { + if (parsedColor) { + parsedColor->r = ((color >> 24) & 0xFF); + parsedColor->g = ((color >> 16) & 0xFF); + parsedColor->b = ((color >> 8) & 0xFF); + parsedColor->a = ignoreAlpha ? 0xFF : ((color >> 0) & 0xFF); + } + } break; + + // Invalid color + default: return false; + } + + if (nextChar) { + *nextChar = djui_unicode_next_char(c); + } + return true; +} + +void djui_text_remove_colors(char *str) { + if (!str) { return; } + char *colorStart = str; + const char *strEnd = str + strlen(str); + while ((colorStart = strstr(colorStart, "\\#"))) { + char *colorEnd; + if (djui_text_parse_color(colorStart, strEnd, false, NULL, &colorEnd, NULL) && colorEnd > colorStart) { + memmove(colorStart, colorEnd, strlen(colorEnd) + 1); + } else { + colorStart++; + } + } +} + +char *djui_text_get_uncolored_string(char *dest, size_t length, const char *str) { + if (!dest) { + dest = malloc(length * sizeof(char)); + if (!dest) { + return NULL; + } + } + strncpy(dest, str, length - 1); + dest[length - 1] = 0; + djui_text_remove_colors(dest); + return dest; +} //////////////// // properties // @@ -59,6 +195,10 @@ static f32 sTextRenderY = 0; static f32 sTextRenderLastX = 0; static f32 sTextRenderLastY = 0; +bool djui_text_is_printable(const char *c) { + return c != NULL && (!iscntrl(*c) || *c == 0x7F); // the star +} + static void djui_text_translate(f32 x, f32 y) { sTextRenderX += x; sTextRenderY += y; @@ -90,7 +230,7 @@ static void djui_text_render_char(struct DjuiText* text, char* c) { sTextRenderY += 1.0f / text->fontScale; gDPSetEnvColor(gDisplayListHead++, text->dropShadow.r, text->dropShadow.g, text->dropShadow.b, text->dropShadow.a); djui_text_render_single_char(text, c); - gDPSetEnvColor(gDisplayListHead++, sSavedR, sSavedG, sSavedB, sSavedA); + gDPSetEnvColor(gDisplayListHead++, sDjuiTextCurrentColor.r, sDjuiTextCurrentColor.g, sDjuiTextCurrentColor.b, sDjuiTextCurrentColor.a); sTextRenderX -= 1.0f / text->fontScale; sTextRenderY -= 1.0f / text->fontScale; } @@ -99,16 +239,21 @@ static void djui_text_render_char(struct DjuiText* text, char* c) { static f32 djui_text_measure_word_width(struct DjuiText* text, char* message) { f32 width = 0; - bool skipping = false; char* c = message; + const char *end = message + strlen(message); while (*c != '\0') { - if (*c == ' ') { return width; } - if (*c == '\n') { return width; } - if (*c == '\0') { return width; } - if (*c == '\\') { skipping = !skipping; } - if (!skipping) { - width += text->font->char_width(c); + + // color code + if (djui_text_parse_color(c, end, true, NULL, &c, NULL)) { + continue; } + + // end of word due to unprintable chars or space + if (!djui_text_is_printable(c) || *c == ' ') { + return width; + } + + width += text->font->char_width(c); c = djui_unicode_next_char(c); } return width; @@ -122,17 +267,18 @@ static void djui_text_read_line(struct DjuiText* text, char** message, f32* line u16 lastSafeEllipsesIndex = *index; u16 lastSafeEllipsesLineWidth = *lineWidth + ellipsesWidth;*/ - bool skipping = false; char* c = *message; + const char *end = *message + strlen(*message); while (*c != '\0') { f32 charWidth = text->font->char_width(c); - // check for special escape sequences - if (*c == '\\') { skipping = !skipping; } - if (skipping || *c == '\\') { + // check for color code + if (*c == '\\') { lastC = c; - c = djui_unicode_next_char(c); - continue; + if (djui_text_parse_color(c, end, true, NULL, &c, NULL)) { + lastC = c; + continue; + } } // check for newline @@ -212,59 +358,6 @@ f32 djui_text_find_width(struct DjuiText* text, u16 maxLines) { return largestWidth * text->fontScale; } -static char* djui_text_render_line_parse_escape(char* c1, char* c2) { - bool parsingColor = (c1[1] == '#'); - char* c = parsingColor ? (c1 + 2) : (c1 + 1); - - u32 color = 0; - u8 colorPieces = 0; - while (c < c2) { - if (*c == '\\') { break; } - if (parsingColor) { - u8 colorPiece = 0; - if (*c >= '0' && *c <= '9') { colorPiece = *c - '0'; } - else if (*c >= 'a' && *c <= 'f') { colorPiece = 10 + *c - 'a'; } - else if (*c >= 'A' && *c <= 'F') { colorPiece = 10 + *c - 'A'; } - color = (color << 4) | colorPiece; - colorPieces++; - } - c = djui_unicode_next_char(c); - } - - if (parsingColor) { - if (colorPieces == 3) { - u32 r = (color >> 8) & 0xF; - u32 g = (color >> 4) & 0xF; - u32 b = (color >> 0) & 0xF; - sSavedR = (r << 4) | r; - sSavedG = (g << 4) | g; - sSavedB = (b << 4) | b; - /*} else if (colorPieces == 4) { - u32 r = (color >> 12) & 0xF; - u32 g = (color >> 8) & 0xF; - u32 b = (color >> 4) & 0xF; - u32 a = (color >> 0) & 0xF; - sSavedR = (r << 4) | r; - sSavedG = (g << 4) | g; - sSavedB = (b << 4) | b; - sSavedA = (a << 4) | a;*/ - } else if (colorPieces == 6) { - sSavedR = ((color >> 16) & 0xFF); - sSavedG = ((color >> 8) & 0xFF); - sSavedB = ((color >> 0) & 0xFF); - }/*else if (colorPieces == 8) { - sSavedR = ((color >> 24) & 0xFF); - sSavedG = ((color >> 16) & 0xFF); - sSavedB = ((color >> 8) & 0xFF); - sSavedA = ((color >> 0) & 0xFF); - }*/ - gDPSetEnvColor(gDisplayListHead++, sSavedR, sSavedG, sSavedB, sSavedA); - } - - c = djui_unicode_next_char(c); - return c; -} - static void djui_text_render_line(struct DjuiText* text, char* c1, char* c2, f32 lineWidth, bool ellipses) { struct DjuiBase* base = &text->base; struct DjuiBaseRect* comp = &base->comp; @@ -284,9 +377,13 @@ static void djui_text_render_line(struct DjuiText* text, char* c1, char* c2, f32 } // render the line + text->font->render_begin(); + for (char* c = c1; c < c2;) { - if (*c == '\\') { - c = djui_text_render_line_parse_escape(c, c2); + struct DjuiColor parsedColor; + if (djui_text_parse_color(c, c2, true, &sDjuiTextDefaultColor, &c, &parsedColor)) { + gDPSetEnvColor(gDisplayListHead++, parsedColor.r, parsedColor.g, parsedColor.b, parsedColor.a); + sDjuiTextCurrentColor = parsedColor; continue; } @@ -312,6 +409,8 @@ static void djui_text_render_line(struct DjuiText* text, char* c1, char* c2, f32 } } + text->font->render_end(); + // reset translation matrix djui_text_translate(-curWidth, text->font->lineHeight); } @@ -352,10 +451,7 @@ static bool djui_text_render(struct DjuiBase* base) { // set color gDPSetEnvColor(gDisplayListHead++, base->color.r, base->color.g, base->color.b, base->color.a); - sSavedR = base->color.r; - sSavedG = base->color.g; - sSavedB = base->color.b; - sSavedA = base->color.a; + sDjuiTextCurrentColor = base->color; // count lines u16 maxLines = comp->height / ((f32)text->font->lineHeight * text->fontScale); diff --git a/src/pc/djui/djui_text.h b/src/pc/djui/djui_text.h index 2d8f84ee5..89e6da0cb 100644 --- a/src/pc/djui/djui_text.h +++ b/src/pc/djui/djui_text.h @@ -11,12 +11,17 @@ struct DjuiText { enum DjuiVAlign textVAlign; }; +bool djui_text_parse_color(char *begin, const char *end, bool ignoreAlpha, const struct DjuiColor *baseColor, char **nextChar, struct DjuiColor *parsedColor); +void djui_text_remove_colors(char *str); +char *djui_text_get_uncolored_string(char *dest, size_t length, const char *str); + void djui_text_set_text(struct DjuiText* text, const char* message); void djui_text_set_font(struct DjuiText* text, const struct DjuiFont* font); void djui_text_set_font_scale(struct DjuiText* text, f32 fontScale); void djui_text_set_drop_shadow(struct DjuiText* text, f32 r, f32 g, f32 b, f32 a); void djui_text_set_alignment(struct DjuiText* text, enum DjuiHAlign hAlign, enum DjuiVAlign vAlign); +bool djui_text_is_printable(const char *c); int djui_text_count_lines(struct DjuiText* text, u16 maxLines); f32 djui_text_find_width(struct DjuiText* text, u16 maxLines); diff --git a/src/pc/djui/djui_unicode.c b/src/pc/djui/djui_unicode.c index e97cd8551..4714be653 100644 --- a/src/pc/djui/djui_unicode.c +++ b/src/pc/djui/djui_unicode.c @@ -204,7 +204,7 @@ struct SmCodeGlyph sSmCodeDuplicateGlyphs[] = { static void* sCharMap = NULL; -static s32 count_bytes_for_char(char* text) { +static s32 count_bytes_for_char(const char* text) { s32 bytes = 0; u8 mask = (1 << 7); while (*text & mask) { @@ -214,7 +214,7 @@ static s32 count_bytes_for_char(char* text) { return bytes ? bytes : 1; } -static u64 convert_unicode_char_to_u64(char* text) { +static u64 convert_unicode_char_to_u64(const char* text) { s32 bytes = count_bytes_for_char(text); u64 value = (u8)*text; @@ -273,7 +273,7 @@ void djui_unicode_init(void) { } } -u32 djui_unicode_get_sprite_index(char* text) { +u32 djui_unicode_get_sprite_index(const char* text) { // check for ASCI if ((u8)*text < 128) { // make sure it's in the valid range @@ -298,7 +298,7 @@ u32 djui_unicode_get_sprite_index(char* text) { return (u8)'?' - SPRITE_INDEX_START_CHAR; } -f32 djui_unicode_get_sprite_width(char* text, const f32 font_widths[], f32 unicodeScale) { +f32 djui_unicode_get_sprite_width(const char* text, const f32 font_widths[], f32 unicodeScale) { if (!text) { return 0; } // check for ASCII @@ -358,7 +358,7 @@ size_t djui_unicode_len(char* text) { return len; } -bool djui_unicode_valid_char(char* text) { +bool djui_unicode_valid_char(const char* text) { if ((u8)*text < 128) { return ((u8)*text >= ' '); } @@ -397,7 +397,7 @@ void djui_unicode_cleanup_end(char* text) { } } -char djui_unicode_get_base_char(char* text) { +char djui_unicode_get_base_char(const char* text) { if ((u8)*text < ' ') { return '?'; } if ((u8)*text < 128) { return *text; } if (!sCharMap) { return '?'; } @@ -406,7 +406,7 @@ char djui_unicode_get_base_char(char* text) { return (glyph == NULL) ? '?' : glyph->base; } -void djui_unicode_get_char(char* text, char* output) { +void djui_unicode_get_char(const char* text, char* output) { s32 bytes = count_bytes_for_char(text); while (bytes-- > 0) { *output = *text; diff --git a/src/pc/djui/djui_unicode.h b/src/pc/djui/djui_unicode.h index 59d138162..f99735e6f 100644 --- a/src/pc/djui/djui_unicode.h +++ b/src/pc/djui/djui_unicode.h @@ -4,12 +4,12 @@ #include void djui_unicode_init(void); -u32 djui_unicode_get_sprite_index(char* text); -f32 djui_unicode_get_sprite_width(char* text, const f32 font_widths[], f32 unicodeScale); +u32 djui_unicode_get_sprite_index(const char* text); +f32 djui_unicode_get_sprite_width(const char* text, const f32 font_widths[], f32 unicodeScale); char* djui_unicode_next_char(char* text); char* djui_unicode_at_index(char* text, s32 index); size_t djui_unicode_len(char* text); -bool djui_unicode_valid_char(char* text); +bool djui_unicode_valid_char(const char* text); void djui_unicode_cleanup_end(char* text); -char djui_unicode_get_base_char(char* text); -void djui_unicode_get_char(char* text, char* output); +char djui_unicode_get_base_char(const char* text); +void djui_unicode_get_char(const char* text, char* output); diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index a89bcac74..1184eaba1 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -892,13 +892,14 @@ static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, cons } // if lighting engine is enabled and either we want to affect all shaded surfaces or the lighting engine geometry mode is on - if (le_is_enabled() && ((le_get_mode() != LE_MODE_AFFECT_ONLY_GEOMETRY_MODE) || (rsp.geometry_mode & G_LIGHTING_ENGINE_EXT))) { + if (le_is_enabled() && luaVertexColor && ((le_get_mode() != LE_MODE_AFFECT_ONLY_GEOMETRY_MODE) || (rsp.geometry_mode & G_LIGHTING_ENGINE_EXT))) { Color color = { gLEAmbientColor[0], gLEAmbientColor[1], gLEAmbientColor[2] }; - CTX_BEGIN(CTX_LIGHTING); Vec3f vpos = { v->ob[0], v->ob[1], v->ob[2] }; Vec3f vnormal = { nx, ny, nz }; + CTX_BEGIN(CTX_LIGHTING); + // transform vpos and vnormal to world space gfx_local_to_world_space(vpos, vnormal); @@ -913,10 +914,11 @@ static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, cons // if lighting engine is enabled and we should affect all vertex colored surfaces or the lighting engine geometry mode is on } else if (le_is_enabled() && !(rsp.geometry_mode & G_LIGHT_MAP_EXT) && (affectAllVertexColored || (rsp.geometry_mode & G_LIGHTING_ENGINE_EXT))) { Color color = { gLEAmbientColor[0], gLEAmbientColor[1], gLEAmbientColor[2] }; - CTX_BEGIN(CTX_LIGHTING); Vec3f vpos = { v->ob[0], v->ob[1], v->ob[2] }; + CTX_BEGIN(CTX_LIGHTING); + // transform vpos to world space gfx_local_to_world_space(vpos, NULL); @@ -927,7 +929,7 @@ static void OPTIMIZE_O3 gfx_sp_vertex(size_t n_vertices, size_t dest_index, cons if (affectAllVertexColored && !(rsp.geometry_mode & G_LIGHTING_ENGINE_EXT)) { le_calculate_lighting_color(vpos, color, 1.0f); } else { - le_calculate_vertex_lighting((Vtx_t*)v, vpos, color); + le_calculate_vertex_lighting(v, vpos, color); } CTX_END(CTX_LIGHTING); diff --git a/src/pc/lua/smlua_cobject.c b/src/pc/lua/smlua_cobject.c index 698141d14..6ce4ecee0 100644 --- a/src/pc/lua/smlua_cobject.c +++ b/src/pc/lua/smlua_cobject.c @@ -344,8 +344,7 @@ struct LuaObjectField* smlua_get_custom_field(lua_State* L, u32 lot, int keyInde lua_rawget(L, -2); u32 lvt = smlua_to_integer(L, -1); lua_pop(L, 1); - bool validLvt = (lvt == LVT_U32 || lvt == LVT_S32 || lvt == LVT_F32); - if (!gSmLuaConvertSuccess || !validLvt) { + if (!gSmLuaConvertSuccess || smlua_get_custom_field_type_name(lvt) == NULL) { lua_pop(L, 1); // pop value table lua_pop(L, 1); // pop _custom_fields LUA_STACK_CHECK_END(L); diff --git a/src/pc/lua/smlua_cobject_autogen.c b/src/pc/lua/smlua_cobject_autogen.c index 442d6a9ba..12e78852a 100644 --- a/src/pc/lua/smlua_cobject_autogen.c +++ b/src/pc/lua/smlua_cobject_autogen.c @@ -1228,16 +1228,6 @@ static struct LuaObjectField sGraphNodeTranslationRotationFields[LUA_GRAPH_NODE_ { "translation", LVT_COBJECT, offsetof(struct GraphNodeTranslationRotation, translation), true, LOT_VEC3S }, }; -#define LUA_HUD_UTILS_ROTATION_FIELD_COUNT 6 -static struct LuaObjectField sHudUtilsRotationFields[LUA_HUD_UTILS_ROTATION_FIELD_COUNT] = { - { "pivotX", LVT_F32, offsetof(struct HudUtilsRotation, pivotX), false, LOT_NONE }, - { "pivotY", LVT_F32, offsetof(struct HudUtilsRotation, pivotY), false, LOT_NONE }, - { "prevPivotX", LVT_F32, offsetof(struct HudUtilsRotation, prevPivotX), false, LOT_NONE }, - { "prevPivotY", LVT_F32, offsetof(struct HudUtilsRotation, prevPivotY), false, LOT_NONE }, - { "rotation", LVT_F32, offsetof(struct HudUtilsRotation, rotation), false, LOT_NONE }, - { "rotationDiff", LVT_F32, offsetof(struct HudUtilsRotation, rotationDiff), false, LOT_NONE }, -}; - #define LUA_INSTANT_WARP_FIELD_COUNT 3 static struct LuaObjectField sInstantWarpFields[LUA_INSTANT_WARP_FIELD_COUNT] = { { "area", LVT_U8, offsetof(struct InstantWarp, area), false, LOT_NONE }, @@ -1484,7 +1474,7 @@ static struct LuaObjectField sModFields[LUA_MOD_FIELD_COUNT] = { { "incompatible", LVT_STRING_P, offsetof(struct Mod, incompatible), true, LOT_NONE }, { "index", LVT_S32, offsetof(struct Mod, index), true, LOT_NONE }, { "isDirectory", LVT_BOOL, offsetof(struct Mod, isDirectory), true, LOT_NONE }, - { "name", LVT_STRING_P, offsetof(struct Mod, name), true, LOT_NONE }, + { "name", LVT_STRING, offsetof(struct Mod, name), true, LOT_NONE }, { "pausable", LVT_BOOL, offsetof(struct Mod, pausable), true, LOT_NONE }, { "relativePath", LVT_STRING, offsetof(struct Mod, relativePath), true, LOT_NONE }, { "renderBehindHud", LVT_BOOL, offsetof(struct Mod, renderBehindHud), true, LOT_NONE }, @@ -2738,7 +2728,6 @@ struct LuaObjectTable sLuaObjectAutogenTable[LOT_AUTOGEN_MAX - LOT_AUTOGEN_MIN] { LOT_GRAPHNODESWITCHCASE, sGraphNodeSwitchCaseFields, LUA_GRAPH_NODE_SWITCH_CASE_FIELD_COUNT }, { LOT_GRAPHNODETRANSLATION, sGraphNodeTranslationFields, LUA_GRAPH_NODE_TRANSLATION_FIELD_COUNT }, { LOT_GRAPHNODETRANSLATIONROTATION, sGraphNodeTranslationRotationFields, LUA_GRAPH_NODE_TRANSLATION_ROTATION_FIELD_COUNT }, - { LOT_HUDUTILSROTATION, sHudUtilsRotationFields, LUA_HUD_UTILS_ROTATION_FIELD_COUNT }, { LOT_INSTANTWARP, sInstantWarpFields, LUA_INSTANT_WARP_FIELD_COUNT }, { LOT_LAKITUSTATE, sLakituStateFields, LUA_LAKITU_STATE_FIELD_COUNT }, { LOT_LEVELVALUES, sLevelValuesFields, LUA_LEVEL_VALUES_FIELD_COUNT }, @@ -2844,7 +2833,6 @@ const char *sLuaLotNames[] = { [LOT_GRAPHNODESWITCHCASE] = "GraphNodeSwitchCase", [LOT_GRAPHNODETRANSLATION] = "GraphNodeTranslation", [LOT_GRAPHNODETRANSLATIONROTATION] = "GraphNodeTranslationRotation", - [LOT_HUDUTILSROTATION] = "HudUtilsRotation", [LOT_INSTANTWARP] = "InstantWarp", [LOT_LAKITUSTATE] = "LakituState", [LOT_LEVELVALUES] = "LevelValues", diff --git a/src/pc/lua/smlua_cobject_autogen.h b/src/pc/lua/smlua_cobject_autogen.h index 291e0f3ee..d034ce9f7 100644 --- a/src/pc/lua/smlua_cobject_autogen.h +++ b/src/pc/lua/smlua_cobject_autogen.h @@ -74,7 +74,6 @@ enum LuaObjectAutogenType { LOT_GRAPHNODESWITCHCASE, LOT_GRAPHNODETRANSLATION, LOT_GRAPHNODETRANSLATIONROTATION, - LOT_HUDUTILSROTATION, LOT_INSTANTWARP, LOT_LAKITUSTATE, LOT_LEVELVALUES, diff --git a/src/pc/lua/smlua_constants_autogen.c b/src/pc/lua/smlua_constants_autogen.c index a55aae378..de7da771c 100644 --- a/src/pc/lua/smlua_constants_autogen.c +++ b/src/pc/lua/smlua_constants_autogen.c @@ -288,6 +288,48 @@ char gSmluaConstants[] = "" "---@param x number\n" "---@return number\n" "OUT_IN_BOUNCE = function (x) return x < 0.5 and 0.5 * OUT_BOUNCE(x * 2) or 0.5 + 0.5 * IN_BOUNCE(2 * x - 1) end\n" +"--- @alias EasingFunction\n" +"--- | `IN_SINE`\n" +"--- | `OUT_SINE`\n" +"--- | `IN_OUT_SINE`\n" +"--- | `OUT_IN_SINE`\n" +"--- | `IN_QUAD`\n" +"--- | `OUT_QUAD`\n" +"--- | `IN_OUT_QUAD`\n" +"--- | `OUT_IN_QUAD`\n" +"--- | `IN_CUBIC`\n" +"--- | `OUT_CUBIC`\n" +"--- | `IN_OUT_CUBIC`\n" +"--- | `OUT_IN_CUBIC`\n" +"--- | `IN_QUART`\n" +"--- | `OUT_QUART`\n" +"--- | `IN_OUT_QUART`\n" +"--- | `OUT_IN_QUART`\n" +"--- | `IN_QUINT`\n" +"--- | `OUT_QUINT`\n" +"--- | `IN_OUT_QUINT`\n" +"--- | `OUT_IN_QUINT`\n" +"--- | `IN_EXPO`\n" +"--- | `OUT_EXPO`\n" +"--- | `IN_OUT_EXPO`\n" +"--- | `OUT_IN_EXPO`\n" +"--- | `IN_CIRC`\n" +"--- | `OUT_CIRC`\n" +"--- | `IN_OUT_CIRC`\n" +"--- | `OUT_IN_CIRC`\n" +"--- | `IN_BACK`\n" +"--- | `OUT_BACK`\n" +"--- | `IN_OUT_BACK`\n" +"--- | `OUT_IN_BACK`\n" +"--- | `IN_ELASTIC`\n" +"--- | `OUT_ELASTIC`\n" +"--- | `IN_OUT_ELASTIC`\n" +"--- | `OUT_IN_ELASTIC`\n" +"--- | `IN_BOUNCE`\n" +"--- | `OUT_BOUNCE`\n" +"--- | `IN_OUT_BOUNCE`\n" +"--- | `OUT_IN_BOUNCE`\n" +"--- | fun(x: number): number\n" "--------------------\n" "-- math functions --\n" "--------------------\n" @@ -357,7 +399,7 @@ char gSmluaConstants[] = "" "function math.round(x)\n" "return x > 0 and __math_floor(x + 0.5) or __math_ceil(x - 0.5)\n" "end\n" -"--- @param t function | number\n" +"--- @param t EasingFunction | number\n" "--- @param a number\n" "--- @param b number\n" "--- @param x number\n" @@ -1446,12 +1488,25 @@ char gSmluaConstants[] = "" "CONSOLE_MESSAGE_INFO=0\n" "CONSOLE_MESSAGE_WARNING=1\n" "CONSOLE_MESSAGE_ERROR=2\n" +"ROTATION_PIVOT_X_LEFT=0.0\n" +"ROTATION_PIVOT_X_CENTER=0.5\n" +"ROTATION_PIVOT_X_RIGHT=1.0\n" +"ROTATION_PIVOT_Y_TOP=0.0\n" +"ROTATION_PIVOT_Y_CENTER=0.5\n" +"ROTATION_PIVOT_Y_BOTTOM=1.0\n" +"TEXT_HALIGN_LEFT=0.0\n" +"TEXT_HALIGN_CENTER=0.5\n" +"TEXT_HALIGN_RIGHT=1.0\n" +"TEXT_VALIGN_TOP=0.0\n" +"TEXT_VALIGN_CENTER=0.5\n" +"TEXT_VALIGN_BOTTOM=1.0\n" "RESOLUTION_DJUI=0\n" "RESOLUTION_N64=1\n" "RESOLUTION_COUNT=2\n" "FILTER_NEAREST=0\n" "FILTER_LINEAR=1\n" "FILTER_COUNT=2\n" +"FONT_LEGACY=-1\n" "FONT_NORMAL=0\n" "FONT_MENU=1\n" "FONT_HUD=2\n" @@ -1653,7 +1708,7 @@ char gSmluaConstants[] = "" "ATTACK_FROM_BELOW=6\n" "PVP_ATTACK_KNOCKBACK_TIMER_DEFAULT=10\n" "PVP_ATTACK_KNOCKBACK_TIMER_OVERRIDE=-5\n" -"PVP_ATTACK_OVERRIDE_VANILLA_INVINCIBILITY=0x0000FFFF\n" +"PVP_ATTACK_KNOCKBACK_ACTION_ARG=0x10000\n" "INT_STATUS_ATTACK_MASK=0x000000FF\n" "INT_STATUS_HOOT_GRABBED_BY_MARIO=(1 << 0)\n" "INT_STATUS_MARIO_UNK1=(1 << 1)\n" @@ -1794,7 +1849,7 @@ char gSmluaConstants[] = "" "HUD_DISPLAY_FLAG_EMPHASIZE_POWER=0x8000\n" "HUD_DISPLAY_NONE=0x0000\n" "HUD_DISPLAY_DEFAULT=HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_COIN_COUNT | HUD_DISPLAY_FLAG_STAR_COUNT | HUD_DISPLAY_FLAG_CAMERA_AND_POWER | HUD_DISPLAY_FLAG_CAMERA | HUD_DISPLAY_FLAG_POWER | HUD_DISPLAY_FLAG_KEYS | HUD_DISPLAY_FLAG_UNKNOWN_0020\n" -"LE_MAX_LIGHTS=512\n" +"LE_MAX_LIGHTS=1024\n" "LE_MODE_AFFECT_ALL_SHADED_AND_COLORED=0\n" "LE_MODE_AFFECT_ALL_SHADED=1\n" "LE_MODE_AFFECT_ONLY_GEOMETRY_MODE=2\n" @@ -3492,7 +3547,14 @@ char gSmluaConstants[] = "" "HOOK_ON_ADD_SURFACE=57\n" "HOOK_ON_CLEAR_AREAS=58\n" "HOOK_ON_PACKET_BYTESTRING_RECEIVE=59\n" -"HOOK_MAX=60\n" +"HOOK_ON_FIND_WALL_COLLISION=60\n" +"HOOK_ON_FIND_CEIL=61\n" +"HOOK_ON_FIND_FLOOR=62\n" +"HOOK_ON_FIND_WATER_LEVEL=63\n" +"HOOK_ON_FIND_POISON_GAS_LEVEL=64\n" +"HOOK_ON_FIND_SURFACE_ON_RAY=65\n" +"HOOK_MAX=66\n" +"MAX_HOOKED_BEHAVIORS=1024\n" "HUD_DISPLAY_LIVES=0\n" "HUD_DISPLAY_COINS=1\n" "HUD_DISPLAY_STARS=2\n" @@ -4625,7 +4687,7 @@ char gSmluaConstants[] = "" "COOP_OBJ_FLAG_LUA=(1 << 1)\n" "COOP_OBJ_FLAG_NON_SYNC=(1 << 2)\n" "COOP_OBJ_FLAG_INITIALIZED=(1 << 3)\n" -"SM64COOPDX_VERSION='v1.4.1'\n" +"SM64COOPDX_VERSION='v1.4.2'\n" "VERSION_TEXT='v'\n" "VERSION_NUMBER=41\n" "MINOR_VERSION_NUMBER=1\n" diff --git a/src/pc/lua/smlua_functions.c b/src/pc/lua/smlua_functions.c index 155fcb1a0..ba79220a8 100644 --- a/src/pc/lua/smlua_functions.c +++ b/src/pc/lua/smlua_functions.c @@ -221,21 +221,32 @@ int smlua_func_network_init_object(lua_State* L) { struct LuaObjectField* data = smlua_get_object_field(LOT_OBJECT, fieldIdentifier); if (data == NULL) { data = smlua_get_custom_field(L, LOT_OBJECT, lua_gettop(L)); + if (data == NULL) { + LOG_LUA_LINE("Unknown field passed to network_init_object(): %s", fieldIdentifier); + lua_pop(L, 1); // pop value + continue; + } } - u8 lvtSize = 0; - if ((data->valueType == LVT_U32) || (data->valueType == LVT_S32) || (data->valueType == LVT_F32)) { lvtSize = 32; } - if ((data->valueType == LVT_U16) || (data->valueType == LVT_S16)) { lvtSize = 16; } - if ((data->valueType == LVT_U8) || (data->valueType == LVT_S8)) { lvtSize = 8; } - - if (data == NULL || lvtSize == 0) { - LOG_LUA_LINE("Invalid field passed to network_init_object(): %s", fieldIdentifier); - lua_pop(L, 1); // pop value - continue; + // These types are the only ones allowed for `network_init_object` + u8 lvtSizeBytes = 0; + switch (data->valueType) { + case LVT_U8: lvtSizeBytes = sizeof(u8); break; + case LVT_U16: lvtSizeBytes = sizeof(u16); break; + case LVT_U32: lvtSizeBytes = sizeof(u32); break; + case LVT_S8: lvtSizeBytes = sizeof(s8); break; + case LVT_S16: lvtSizeBytes = sizeof(s16); break; + case LVT_S32: lvtSizeBytes = sizeof(s32); break; + case LVT_F32: lvtSizeBytes = sizeof(f32); break; + default: { + LOG_LUA_LINE("Invalid field passed to network_init_object(): %s", fieldIdentifier); + lua_pop(L, 1); // pop value + continue; + } } u8* field = ((u8*)(intptr_t)obj) + data->valueOffset; - sync_object_init_field_with_size(obj, field, lvtSize); + sync_object_init_field_with_size(obj, field, lvtSizeBytes); lua_pop(L, 1); // pop value } @@ -804,6 +815,11 @@ int smlua_func_log_to_console(lua_State* L) { //////////////////// int smlua_func_add_scroll_target(lua_State* L) { + if (gLuaLoadingMod == NULL) { + LOG_LUA_LINE("add_scroll_target() can only be called on load."); + return 0; + } + // add_scroll_target used to require offset and size of the vertex buffer to be used if (!smlua_functions_valid_param_range(L, 2, 4)) { return 0; } int paramCount = lua_gettop(L); @@ -934,7 +950,7 @@ int smlua_func_get_uncolored_string(lua_State* L) { const char *str = smlua_to_string(L, 1); if (!gSmLuaConvertSuccess) { LOG_LUA("get_uncolored_string: Failed to convert parameter 1"); return 0; } - char *strNoColor = str_remove_color_codes(str); + char *strNoColor = djui_text_get_uncolored_string(NULL, strlen(str) + 1, str); lua_pushstring(L, strNoColor); free(strNoColor); diff --git a/src/pc/lua/smlua_functions_autogen.c b/src/pc/lua/smlua_functions_autogen.c index 60ced0477..54bb0672b 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -54,6 +54,7 @@ #include "src/audio/seqplayer.h" #include "src/engine/lighting_engine.h" #include "src/pc/network/sync_object.h" +#include "src/audio/load.h" /////////////// @@ -9729,219 +9730,6 @@ int smlua_func_bhv_point_light_loop(UNUSED lua_State* L) { return 1; } -/* -int smlua_func_geo_move_mario_part_from_parent(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_move_mario_part_from_parent", 3, top); - return 0; - } - - s32 run = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_move_mario_part_from_parent"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_move_mario_part_from_parent"); return 0; } - - Mat4 mtx; - smlua_get_mat4(mtx, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_move_mario_part_from_parent"); return 0; } - - smlua_push_object(L, LOT_GFX, geo_move_mario_part_from_parent(run, node, mtx), NULL); - - return 1; -} -*/ - -/* -int smlua_func_geo_bits_bowser_coloring(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_bits_bowser_coloring", 3, top); - return 0; - } - - s32 run = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_bits_bowser_coloring"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_bits_bowser_coloring"); return 0; } - s32 a2 = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_bits_bowser_coloring"); return 0; } - - smlua_push_object(L, LOT_GFX, geo_bits_bowser_coloring(run, node, a2), NULL); - - return 1; -} -*/ - -/* -int smlua_func_geo_update_body_rot_from_parent(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_update_body_rot_from_parent", 3, top); - return 0; - } - - s32 run = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_update_body_rot_from_parent"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_update_body_rot_from_parent"); return 0; } - - Mat4 mtx; - smlua_get_mat4(mtx, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_update_body_rot_from_parent"); return 0; } - - smlua_push_object(L, LOT_GFX, geo_update_body_rot_from_parent(run, node, mtx), NULL); - - return 1; -} -*/ - -/* -int smlua_func_geo_switch_bowser_eyes(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_switch_bowser_eyes", 3, top); - return 0; - } - - s32 run = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_switch_bowser_eyes"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_switch_bowser_eyes"); return 0; } - Mat4 * mtx = (Mat4 *)smlua_to_cobject(L, 3, LOT_MAT4); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_switch_bowser_eyes"); return 0; } - - smlua_push_object(L, LOT_GFX, geo_switch_bowser_eyes(run, node, mtx), NULL); - - return 1; -} -*/ - -/* -int smlua_func_geo_switch_tuxie_mother_eyes(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_switch_tuxie_mother_eyes", 3, top); - return 0; - } - - s32 run = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_switch_tuxie_mother_eyes"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_switch_tuxie_mother_eyes"); return 0; } - Mat4 * mtx = (Mat4 *)smlua_to_cobject(L, 3, LOT_MAT4); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_switch_tuxie_mother_eyes"); return 0; } - - smlua_push_object(L, LOT_GFX, geo_switch_tuxie_mother_eyes(run, node, mtx), NULL); - - return 1; -} -*/ - -/* -int smlua_func_geo_update_held_mario_pos(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_update_held_mario_pos", 3, top); - return 0; - } - - s32 run = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_update_held_mario_pos"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_update_held_mario_pos"); return 0; } - - Mat4 mtx; - smlua_get_mat4(mtx, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_update_held_mario_pos"); return 0; } - - smlua_push_object(L, LOT_GFX, geo_update_held_mario_pos(run, node, mtx), NULL); - - return 1; -} -*/ - -/* -int smlua_func_geo_snufit_move_mask(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_snufit_move_mask", 3, top); - return 0; - } - - s32 callContext = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_snufit_move_mask"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_snufit_move_mask"); return 0; } - Mat4 * c = (Mat4 *)smlua_to_cobject(L, 3, LOT_MAT4); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_snufit_move_mask"); return 0; } - - smlua_push_object(L, LOT_GFX, geo_snufit_move_mask(callContext, node, c), NULL); - - return 1; -} -*/ - -/* -int smlua_func_geo_snufit_scale_body(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_snufit_scale_body", 3, top); - return 0; - } - - s32 callContext = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_snufit_scale_body"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_snufit_scale_body"); return 0; } - Mat4 * c = (Mat4 *)smlua_to_cobject(L, 3, LOT_MAT4); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_snufit_scale_body"); return 0; } - - smlua_push_object(L, LOT_GFX, geo_snufit_scale_body(callContext, node, c), NULL); - - return 1; -} -*/ - -/* -int smlua_func_geo_scale_bowser_key(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_scale_bowser_key", 3, top); - return 0; - } - - s32 run = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_scale_bowser_key"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_scale_bowser_key"); return 0; } - f32 mtx[4][4] = smlua_to_number(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_scale_bowser_key"); return 0; } - - smlua_push_object(L, LOT_GFX, geo_scale_bowser_key(run, node, mtx[4][4]), NULL); - - return 1; -} -*/ - int smlua_func_spawn_default_star(lua_State* L) { if (L == NULL) { return 0; } @@ -10387,29 +10175,6 @@ int smlua_func_select_mario_cam_mode(UNUSED lua_State* L) { return 1; } -/* -int smlua_func_geo_camera_main(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_camera_main", 3, top); - return 0; - } - - s32 callContext = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_camera_main"); return 0; } -// struct GraphNode* g = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_camera_main"); return 0; } -// void * context = (void *)smlua_to_cobject(L, 3, LOT_???); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_camera_main"); return 0; } - - smlua_push_object(L, LOT_GFX, geo_camera_main(callContext, g, context), NULL); - - return 1; -} -*/ - int smlua_func_object_pos_to_vec3f(lua_State* L) { if (L == NULL) { return 0; } @@ -12153,29 +11918,6 @@ int smlua_func_obj_rotate_towards_point(lua_State* L) { return 1; } -/* -int smlua_func_geo_camera_fov(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_camera_fov", 3, top); - return 0; - } - - s32 callContext = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_camera_fov"); return 0; } -// struct GraphNode* g = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_camera_fov"); return 0; } -// void * context = (void *)smlua_to_cobject(L, 3, LOT_???); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_camera_fov"); return 0; } - - smlua_push_object(L, LOT_GFX, geo_camera_fov(callContext, g, context), NULL); - - return 1; -} -*/ - int smlua_func_set_camera_mode_fixed(lua_State* L) { if (L == NULL) { return 0; } @@ -12576,7 +12318,7 @@ int smlua_func_djui_hud_reset_color(UNUSED lua_State* L) { return 1; } -int smlua_func_djui_hud_get_rotation(UNUSED lua_State* L) { +int smlua_func_djui_hud_get_rotation(lua_State* L) { if (L == NULL) { return 0; } int top = lua_gettop(L); @@ -12586,9 +12328,17 @@ int smlua_func_djui_hud_get_rotation(UNUSED lua_State* L) { } - smlua_push_object(L, LOT_HUDUTILSROTATION, djui_hud_get_rotation(), NULL); + s16 rotation; + f32 pivotX; + f32 pivotY; - return 1; + djui_hud_get_rotation(&rotation, &pivotX, &pivotY); + + lua_pushinteger(L, rotation); + lua_pushnumber(L, pivotX); + lua_pushnumber(L, pivotY); + + return 3; } int smlua_func_djui_hud_set_rotation(lua_State* L) { @@ -12621,13 +12371,13 @@ int smlua_func_djui_hud_set_rotation_interpolated(lua_State* L) { return 0; } - s32 prevRotation = smlua_to_integer(L, 1); + s16 prevRotation = smlua_to_integer(L, 1); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_set_rotation_interpolated"); return 0; } f32 prevPivotX = smlua_to_number(L, 2); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "djui_hud_set_rotation_interpolated"); return 0; } f32 prevPivotY = smlua_to_number(L, 3); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "djui_hud_set_rotation_interpolated"); return 0; } - s32 rotation = smlua_to_integer(L, 4); + s16 rotation = smlua_to_integer(L, 4); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "djui_hud_set_rotation_interpolated"); return 0; } f32 pivotX = smlua_to_number(L, 5); if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 5, "djui_hud_set_rotation_interpolated"); return 0; } @@ -12639,6 +12389,69 @@ int smlua_func_djui_hud_set_rotation_interpolated(lua_State* L) { return 1; } +int smlua_func_djui_hud_get_text_alignment(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "djui_hud_get_text_alignment", 0, top); + return 0; + } + + + f32 textHAlign; + f32 textVAlign; + + djui_hud_get_text_alignment(&textHAlign, &textVAlign); + + lua_pushnumber(L, textHAlign); + lua_pushnumber(L, textVAlign); + + return 2; +} + +int smlua_func_djui_hud_set_text_alignment(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "djui_hud_set_text_alignment", 2, top); + return 0; + } + + f32 textHAlign = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_set_text_alignment"); return 0; } + f32 textVAlign = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "djui_hud_set_text_alignment"); return 0; } + + djui_hud_set_text_alignment(textHAlign, textVAlign); + + return 1; +} + +int smlua_func_djui_hud_set_text_alignment_interpolated(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 4) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "djui_hud_set_text_alignment_interpolated", 4, top); + return 0; + } + + f32 prevTextHAlign = smlua_to_number(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "djui_hud_set_text_alignment_interpolated"); return 0; } + f32 prevTextVAlign = smlua_to_number(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "djui_hud_set_text_alignment_interpolated"); return 0; } + f32 textHAlign = smlua_to_number(L, 3); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "djui_hud_set_text_alignment_interpolated"); return 0; } + f32 textVAlign = smlua_to_number(L, 4); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 4, "djui_hud_set_text_alignment_interpolated"); return 0; } + + djui_hud_set_text_alignment_interpolated(prevTextHAlign, prevTextVAlign, textHAlign, textVAlign); + + return 1; +} + int smlua_func_djui_hud_get_screen_width(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -15768,6 +15581,23 @@ int smlua_func_le_set_ambient_color(lua_State* L) { return 1; } +int smlua_func_le_set_max_lights_per_vertex(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "le_set_max_lights_per_vertex", 1, top); + return 0; + } + + u8 count = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "le_set_max_lights_per_vertex"); return 0; } + + le_set_max_lights_per_vertex(count); + + return 1; +} + int smlua_func_le_calculate_lighting_color(lua_State* L) { if (L == NULL) { return 0; } @@ -16131,6 +15961,27 @@ int smlua_func_le_set_light_use_surface_normals(lua_State* L) { return 1; } + //////////// + // load.h // +//////////// + +int smlua_func_set_sound_bank_override(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_sound_bank_override", 1, top); + return 0; + } + + s32 bank = smlua_to_integer(L, 1); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_sound_bank_override"); return 0; } + + set_sound_bank_override(bank); + + return 1; +} + ///////////// // mario.h // ///////////// @@ -23724,30 +23575,6 @@ int smlua_func_set_yoshi_as_not_dead(UNUSED lua_State* L) { return 1; } -/* -int smlua_func_geo_obj_transparency_something(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_obj_transparency_something", 3, top); - return 0; - } - - s32 callContext = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_obj_transparency_something"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_obj_transparency_something"); return 0; } - Mat4 * mtx = (Mat4 *)smlua_to_cobject(L, 3, LOT_MAT4); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_obj_transparency_something"); return 0; } - - extern Gfx UNUSED *geo_obj_transparency_something(s32 callContext, struct GraphNode *node, UNUSED Mat4 *mtx); - smlua_push_object(L, LOT_GFX, geo_obj_transparency_something(callContext, node, mtx), NULL); - - return 1; -} -*/ - int smlua_func_absf_2(lua_State* L) { if (L == NULL) { return 0; } @@ -25474,78 +25301,6 @@ int smlua_func_clear_move_flag(lua_State* L) { return 2; } -/* -int smlua_func_geo_update_projectile_pos_from_parent(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_update_projectile_pos_from_parent", 3, top); - return 0; - } - - s32 callContext = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_update_projectile_pos_from_parent"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_update_projectile_pos_from_parent"); return 0; } - - Mat4 mtx; - smlua_get_mat4(mtx, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_update_projectile_pos_from_parent"); return 0; } - - extern Gfx *geo_update_projectile_pos_from_parent(s32 callContext, UNUSED struct GraphNode *node, Mat4 mtx); - smlua_push_object(L, LOT_GFX, geo_update_projectile_pos_from_parent(callContext, node, mtx), NULL); - - return 1; -} -*/ - -/* -int smlua_func_geo_update_layer_transparency(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_update_layer_transparency", 3, top); - return 0; - } - - s32 callContext = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_update_layer_transparency"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_update_layer_transparency"); return 0; } -// void * context = (void *)smlua_to_cobject(L, 3, LOT_???); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_update_layer_transparency"); return 0; } - - extern Gfx *geo_update_layer_transparency(s32 callContext, struct GraphNode *node, UNUSED void *context); - smlua_push_object(L, LOT_GFX, geo_update_layer_transparency(callContext, node, context), NULL); - - return 1; -} -*/ - -/* -int smlua_func_geo_switch_anim_state(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_switch_anim_state", 2, top); - return 0; - } - - s32 callContext = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_switch_anim_state"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_switch_anim_state"); return 0; } - - extern Gfx *geo_switch_anim_state(s32 callContext, struct GraphNode *node); - smlua_push_object(L, LOT_GFX, geo_switch_anim_state(callContext, node), NULL); - - return 1; -} -*/ - int smlua_func_set_room_override(lua_State* L) { if (L == NULL) { return 0; } @@ -25564,54 +25319,6 @@ int smlua_func_set_room_override(lua_State* L) { return 1; } -/* -int smlua_func_geo_switch_area(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 2) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_switch_area", 2, top); - return 0; - } - - s32 callContext = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_switch_area"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_switch_area"); return 0; } - - extern Gfx *geo_switch_area(s32 callContext, struct GraphNode *node); - smlua_push_object(L, LOT_GFX, geo_switch_area(callContext, node), NULL); - - return 1; -} -*/ - -/* -int smlua_func_geo_choose_area_ext(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_choose_area_ext", 3, top); - return 0; - } - - s32 callContext = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_choose_area_ext"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_choose_area_ext"); return 0; } - - Mat4 mtx; - smlua_get_mat4(mtx, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_choose_area_ext"); return 0; } - - extern Gfx *geo_choose_area_ext(UNUSED s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); - smlua_push_object(L, LOT_GFX, geo_choose_area_ext(callContext, node, mtx), NULL); - - return 1; -} -*/ - int smlua_func_obj_update_pos_from_parent_transformation(lua_State* L) { if (L == NULL) { return 0; } @@ -29354,56 +29061,6 @@ int smlua_func_cur_obj_hide_if_mario_far_away_y(lua_State* L) { return 1; } -/* -int smlua_func_geo_offset_klepto_held_object(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_offset_klepto_held_object", 3, top); - return 0; - } - - s32 callContext = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_offset_klepto_held_object"); return 0; } -// struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_offset_klepto_held_object"); return 0; } - - Mat4 mtx; - smlua_get_mat4(mtx, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_offset_klepto_held_object"); return 0; } - - extern Gfx *geo_offset_klepto_held_object(s32 callContext, struct GraphNode *node, UNUSED Mat4 mtx); - smlua_push_object(L, LOT_GFX, geo_offset_klepto_held_object(callContext, node, mtx), NULL); - - return 1; -} -*/ - -/* -int smlua_func_geo_offset_klepto_debug(lua_State* L) { - if (L == NULL) { return 0; } - - int top = lua_gettop(L); - if (top != 3) { - LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_offset_klepto_debug", 3, top); - return 0; - } - - s32 callContext = smlua_to_integer(L, 1); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_offset_klepto_debug"); return 0; } -// struct GraphNode* a1 = (struct GraphNode*)smlua_to_cobject(L, 2, LOT_GRAPHNODE); <--- UNIMPLEMENTED - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_offset_klepto_debug"); return 0; } - s32 sp8 = smlua_to_integer(L, 3); - if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "geo_offset_klepto_debug"); return 0; } - - extern s32 geo_offset_klepto_debug(s32 callContext, struct GraphNode *a1, UNUSED s32 sp8); - lua_pushinteger(L, geo_offset_klepto_debug(callContext, a1, sp8)); - - return 1; -} -*/ - int smlua_func_obj_is_hidden(lua_State* L) { if (L == NULL) { return 0; } @@ -30767,6 +30424,21 @@ int smlua_func_smlua_audio_utils_replace_sequence(lua_State* L) { return 1; } +int smlua_func_smlua_audio_utils_allocate_sequence(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "smlua_audio_utils_allocate_sequence", 0, top); + return 0; + } + + + lua_pushinteger(L, smlua_audio_utils_allocate_sequence()); + + return 1; +} + int smlua_func_audio_stream_load(lua_State* L) { if (L == NULL) { return 0; } @@ -34401,6 +34073,21 @@ int smlua_func_get_dialog_response(UNUSED lua_State* L) { return 1; } +int smlua_func_get_time_stop_flags(UNUSED lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 0) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_time_stop_flags", 0, top); + return 0; + } + + + lua_pushinteger(L, get_time_stop_flags()); + + return 1; +} + int smlua_func_get_local_discord_id(UNUSED lua_State* L) { if (L == NULL) { return 0; } @@ -34629,6 +34316,28 @@ int smlua_func_get_active_mod(UNUSED lua_State* L) { return 1; } +int smlua_func_get_mod_files(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top < 1 || top > 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected between %u and %u, Received %u", "get_mod_files", 1, 2, top); + return 0; + } + + struct Mod* mod = (struct Mod*)smlua_to_cobject(L, 1, LOT_MOD); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_mod_files"); return 0; } + const char* subDirectory = (const char*) NULL; + if (top >= 2) { + subDirectory = smlua_to_string(L, 2); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "get_mod_files"); return 0; } + } + + smlua_push_lua_table(L, get_mod_files(mod, subDirectory)); + + return 1; +} + int smlua_func_set_window_title(lua_State* L) { if (L == NULL) { return 0; } @@ -34751,6 +34460,25 @@ int smlua_func_geo_get_current_held_object(UNUSED lua_State* L) { return 1; } +int smlua_func_geo_skip_interpolation(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 2) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "geo_skip_interpolation", 2, top); + return 0; + } + + struct GraphNode* node = (struct GraphNode*)smlua_to_cobject(L, 1, LOT_GRAPHNODE); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "geo_skip_interpolation"); return 0; } + struct GraphNodeObject* obj = (struct GraphNodeObject*)smlua_to_cobject(L, 2, LOT_GRAPHNODEOBJECT); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "geo_skip_interpolation"); return 0; } + + geo_skip_interpolation(node, obj); + + return 1; +} + int smlua_func_texture_to_lua_table(lua_State* L) { if (L == NULL) { return 0; } @@ -35760,6 +35488,40 @@ int smlua_func_set_whirlpools(lua_State* L) { return 1; } +int smlua_func_obj_skip_interpolation(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "obj_skip_interpolation", 1, top); + return 0; + } + + struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "obj_skip_interpolation"); return 0; } + + obj_skip_interpolation(o); + + return 1; +} + +int smlua_func_obj_anim_skip_interpolation(lua_State* L) { + if (L == NULL) { return 0; } + + int top = lua_gettop(L); + if (top != 1) { + LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "obj_anim_skip_interpolation", 1, top); + return 0; + } + + struct Object* o = (struct Object*)smlua_to_cobject(L, 1, LOT_OBJECT); + if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "obj_anim_skip_interpolation"); return 0; } + + obj_anim_skip_interpolation(o); + + return 1; +} + //////////////////////// // smlua_text_utils.h // //////////////////////// @@ -37592,15 +37354,6 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "bhv_ambient_light_update", smlua_func_bhv_ambient_light_update); smlua_bind_function(L, "bhv_point_light_init", smlua_func_bhv_point_light_init); smlua_bind_function(L, "bhv_point_light_loop", smlua_func_bhv_point_light_loop); - //smlua_bind_function(L, "geo_move_mario_part_from_parent", smlua_func_geo_move_mario_part_from_parent); <--- UNIMPLEMENTED - //smlua_bind_function(L, "geo_bits_bowser_coloring", smlua_func_geo_bits_bowser_coloring); <--- UNIMPLEMENTED - //smlua_bind_function(L, "geo_update_body_rot_from_parent", smlua_func_geo_update_body_rot_from_parent); <--- UNIMPLEMENTED - //smlua_bind_function(L, "geo_switch_bowser_eyes", smlua_func_geo_switch_bowser_eyes); <--- UNIMPLEMENTED - //smlua_bind_function(L, "geo_switch_tuxie_mother_eyes", smlua_func_geo_switch_tuxie_mother_eyes); <--- UNIMPLEMENTED - //smlua_bind_function(L, "geo_update_held_mario_pos", smlua_func_geo_update_held_mario_pos); <--- UNIMPLEMENTED - //smlua_bind_function(L, "geo_snufit_move_mask", smlua_func_geo_snufit_move_mask); <--- UNIMPLEMENTED - //smlua_bind_function(L, "geo_snufit_scale_body", smlua_func_geo_snufit_scale_body); <--- UNIMPLEMENTED - //smlua_bind_function(L, "geo_scale_bowser_key", smlua_func_geo_scale_bowser_key); <--- UNIMPLEMENTED smlua_bind_function(L, "spawn_default_star", smlua_func_spawn_default_star); smlua_bind_function(L, "spawn_red_coin_cutscene_star", smlua_func_spawn_red_coin_cutscene_star); smlua_bind_function(L, "spawn_no_exit_star", smlua_func_spawn_no_exit_star); @@ -37632,7 +37385,6 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "soft_reset_camera", smlua_func_soft_reset_camera); smlua_bind_function(L, "reset_camera", smlua_func_reset_camera); smlua_bind_function(L, "select_mario_cam_mode", smlua_func_select_mario_cam_mode); - //smlua_bind_function(L, "geo_camera_main", smlua_func_geo_camera_main); <--- UNIMPLEMENTED smlua_bind_function(L, "object_pos_to_vec3f", smlua_func_object_pos_to_vec3f); smlua_bind_function(L, "vec3f_to_object_pos", smlua_func_vec3f_to_object_pos); smlua_bind_function(L, "object_face_angle_to_vec3s", smlua_func_object_face_angle_to_vec3s); @@ -37712,7 +37464,6 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "cutscene_set_fov_shake_preset", smlua_func_cutscene_set_fov_shake_preset); smlua_bind_function(L, "set_fov_shake_from_point_preset", smlua_func_set_fov_shake_from_point_preset); smlua_bind_function(L, "obj_rotate_towards_point", smlua_func_obj_rotate_towards_point); - //smlua_bind_function(L, "geo_camera_fov", smlua_func_geo_camera_fov); <--- UNIMPLEMENTED smlua_bind_function(L, "set_camera_mode_fixed", smlua_func_set_camera_mode_fixed); smlua_bind_function(L, "snap_to_45_degrees", smlua_func_snap_to_45_degrees); smlua_bind_function(L, "camera_set_use_course_specific_settings", smlua_func_camera_set_use_course_specific_settings); @@ -37746,6 +37497,9 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "djui_hud_get_rotation", smlua_func_djui_hud_get_rotation); smlua_bind_function(L, "djui_hud_set_rotation", smlua_func_djui_hud_set_rotation); smlua_bind_function(L, "djui_hud_set_rotation_interpolated", smlua_func_djui_hud_set_rotation_interpolated); + smlua_bind_function(L, "djui_hud_get_text_alignment", smlua_func_djui_hud_get_text_alignment); + smlua_bind_function(L, "djui_hud_set_text_alignment", smlua_func_djui_hud_set_text_alignment); + smlua_bind_function(L, "djui_hud_set_text_alignment_interpolated", smlua_func_djui_hud_set_text_alignment_interpolated); smlua_bind_function(L, "djui_hud_get_screen_width", smlua_func_djui_hud_get_screen_width); smlua_bind_function(L, "djui_hud_get_screen_height", smlua_func_djui_hud_get_screen_height); smlua_bind_function(L, "djui_hud_get_mouse_x", smlua_func_djui_hud_get_mouse_x); @@ -37935,6 +37689,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "le_set_tone_mapping", smlua_func_le_set_tone_mapping); smlua_bind_function(L, "le_get_ambient_color", smlua_func_le_get_ambient_color); smlua_bind_function(L, "le_set_ambient_color", smlua_func_le_set_ambient_color); + smlua_bind_function(L, "le_set_max_lights_per_vertex", smlua_func_le_set_max_lights_per_vertex); smlua_bind_function(L, "le_calculate_lighting_color", smlua_func_le_calculate_lighting_color); smlua_bind_function(L, "le_calculate_lighting_color_with_normal", smlua_func_le_calculate_lighting_color_with_normal); smlua_bind_function(L, "le_calculate_lighting_dir", smlua_func_le_calculate_lighting_dir); @@ -37953,6 +37708,9 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "le_get_light_use_surface_normals", smlua_func_le_get_light_use_surface_normals); smlua_bind_function(L, "le_set_light_use_surface_normals", smlua_func_le_set_light_use_surface_normals); + // load.h + smlua_bind_function(L, "set_sound_bank_override", smlua_func_set_sound_bank_override); + // mario.h smlua_bind_function(L, "is_anim_at_end", smlua_func_is_anim_at_end); smlua_bind_function(L, "is_anim_past_end", smlua_func_is_anim_past_end); @@ -38355,7 +38113,6 @@ void smlua_bind_functions_autogen(void) { // obj_behaviors.c smlua_bind_function(L, "set_yoshi_as_not_dead", smlua_func_set_yoshi_as_not_dead); - //smlua_bind_function(L, "geo_obj_transparency_something", smlua_func_geo_obj_transparency_something); <--- UNIMPLEMENTED smlua_bind_function(L, "absf_2", smlua_func_absf_2); smlua_bind_function(L, "obj_find_wall", smlua_func_obj_find_wall); smlua_bind_function(L, "turn_obj_away_from_steep_floor", smlua_func_turn_obj_away_from_steep_floor); @@ -38443,12 +38200,7 @@ void smlua_bind_functions_autogen(void) { // object_helpers.c smlua_bind_function(L, "clear_move_flag", smlua_func_clear_move_flag); - //smlua_bind_function(L, "geo_update_projectile_pos_from_parent", smlua_func_geo_update_projectile_pos_from_parent); <--- UNIMPLEMENTED - //smlua_bind_function(L, "geo_update_layer_transparency", smlua_func_geo_update_layer_transparency); <--- UNIMPLEMENTED - //smlua_bind_function(L, "geo_switch_anim_state", smlua_func_geo_switch_anim_state); <--- UNIMPLEMENTED smlua_bind_function(L, "set_room_override", smlua_func_set_room_override); - //smlua_bind_function(L, "geo_switch_area", smlua_func_geo_switch_area); <--- UNIMPLEMENTED - //smlua_bind_function(L, "geo_choose_area_ext", smlua_func_geo_choose_area_ext); <--- UNIMPLEMENTED smlua_bind_function(L, "obj_update_pos_from_parent_transformation", smlua_func_obj_update_pos_from_parent_transformation); smlua_bind_function(L, "obj_apply_scale_to_matrix", smlua_func_obj_apply_scale_to_matrix); smlua_bind_function(L, "create_transformation_from_matrices", smlua_func_create_transformation_from_matrices); @@ -38644,8 +38396,6 @@ void smlua_bind_functions_autogen(void) { //smlua_bind_function(L, "obj_set_collision_data", smlua_func_obj_set_collision_data); <--- UNIMPLEMENTED smlua_bind_function(L, "cur_obj_if_hit_wall_bounce_away", smlua_func_cur_obj_if_hit_wall_bounce_away); smlua_bind_function(L, "cur_obj_hide_if_mario_far_away_y", smlua_func_cur_obj_hide_if_mario_far_away_y); - //smlua_bind_function(L, "geo_offset_klepto_held_object", smlua_func_geo_offset_klepto_held_object); <--- UNIMPLEMENTED - //smlua_bind_function(L, "geo_offset_klepto_debug", smlua_func_geo_offset_klepto_debug); <--- UNIMPLEMENTED smlua_bind_function(L, "obj_is_hidden", smlua_func_obj_is_hidden); smlua_bind_function(L, "enable_time_stop", smlua_func_enable_time_stop); smlua_bind_function(L, "enable_time_stop_if_alone", smlua_func_enable_time_stop_if_alone); @@ -38735,6 +38485,7 @@ void smlua_bind_functions_autogen(void) { // smlua_audio_utils.h smlua_bind_function(L, "smlua_audio_utils_reset_all", smlua_func_smlua_audio_utils_reset_all); smlua_bind_function(L, "smlua_audio_utils_replace_sequence", smlua_func_smlua_audio_utils_replace_sequence); + smlua_bind_function(L, "smlua_audio_utils_allocate_sequence", smlua_func_smlua_audio_utils_allocate_sequence); smlua_bind_function(L, "audio_stream_load", smlua_func_audio_stream_load); smlua_bind_function(L, "audio_stream_destroy", smlua_func_audio_stream_destroy); smlua_bind_function(L, "audio_stream_play", smlua_func_audio_stream_play); @@ -38957,6 +38708,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "set_override_envfx", smlua_func_set_override_envfx); smlua_bind_function(L, "get_global_timer", smlua_func_get_global_timer); smlua_bind_function(L, "get_dialog_response", smlua_func_get_dialog_response); + smlua_bind_function(L, "get_time_stop_flags", smlua_func_get_time_stop_flags); smlua_bind_function(L, "get_local_discord_id", smlua_func_get_local_discord_id); smlua_bind_function(L, "get_coopnet_id", smlua_func_get_coopnet_id); smlua_bind_function(L, "get_volume_master", smlua_func_get_volume_master); @@ -38971,6 +38723,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region); smlua_bind_function(L, "mod_file_exists", smlua_func_mod_file_exists); smlua_bind_function(L, "get_active_mod", smlua_func_get_active_mod); + smlua_bind_function(L, "get_mod_files", smlua_func_get_mod_files); smlua_bind_function(L, "set_window_title", smlua_func_set_window_title); smlua_bind_function(L, "reset_window_title", smlua_func_reset_window_title); smlua_bind_function(L, "get_os_name", smlua_func_get_os_name); @@ -38979,6 +38732,7 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "geo_get_current_perspective", smlua_func_geo_get_current_perspective); smlua_bind_function(L, "geo_get_current_camera", smlua_func_geo_get_current_camera); smlua_bind_function(L, "geo_get_current_held_object", smlua_func_geo_get_current_held_object); + smlua_bind_function(L, "geo_skip_interpolation", smlua_func_geo_skip_interpolation); smlua_bind_function(L, "texture_to_lua_table", smlua_func_texture_to_lua_table); smlua_bind_function(L, "get_texture_name", smlua_func_get_texture_name); @@ -39036,6 +38790,8 @@ void smlua_bind_functions_autogen(void) { smlua_bind_function(L, "obj_set_vel", smlua_func_obj_set_vel); smlua_bind_function(L, "obj_move_xyz", smlua_func_obj_move_xyz); smlua_bind_function(L, "set_whirlpools", smlua_func_set_whirlpools); + smlua_bind_function(L, "obj_skip_interpolation", smlua_func_obj_skip_interpolation); + smlua_bind_function(L, "obj_anim_skip_interpolation", smlua_func_obj_anim_skip_interpolation); // smlua_text_utils.h smlua_bind_function(L, "smlua_text_utils_reset_all", smlua_func_smlua_text_utils_reset_all); diff --git a/src/pc/lua/smlua_hook_events.inl b/src/pc/lua/smlua_hook_events.inl index 16bbbaee2..71f4a915c 100644 --- a/src/pc/lua/smlua_hook_events.inl +++ b/src/pc/lua/smlua_hook_events.inl @@ -58,3 +58,9 @@ SMLUA_EVENT_HOOK(HOOK_MARIO_OVERRIDE_FLOOR_CLASS, HOOK_RETURN_ON_OUTPUT_SET, str SMLUA_EVENT_HOOK(HOOK_ON_ADD_SURFACE, HOOK_RETURN_NEVER, struct Surface *surface, bool dynamic) SMLUA_EVENT_HOOK(HOOK_ON_CLEAR_AREAS, HOOK_RETURN_NEVER) SMLUA_EVENT_HOOK(HOOK_ON_PACKET_BYTESTRING_RECEIVE, HOOK_RETURN_NEVER, s32 modIndex, s32 valueIndex) +SMLUA_EVENT_HOOK(HOOK_ON_FIND_WALL_COLLISION, _, f32 posX, f32 posY, f32 posZ, struct WallCollisionData *colData, s32 *numCollisions) // Manually defined hook +SMLUA_EVENT_HOOK(HOOK_ON_FIND_CEIL, _, f32 posX, f32 posY, f32 posZ, struct Surface **pceil, f32 *height) // Manually defined hook +SMLUA_EVENT_HOOK(HOOK_ON_FIND_FLOOR, _, f32 posX, f32 posY, f32 posZ, struct Surface **pfloor, f32 *height) // Manually defined hook +SMLUA_EVENT_HOOK(HOOK_ON_FIND_WATER_LEVEL, _, f32 x, f32 z, f32 *waterLevel) // Manually defined hook +SMLUA_EVENT_HOOK(HOOK_ON_FIND_POISON_GAS_LEVEL, _, f32 x, f32 z, f32 *gasLevel) // Manually defined hook +SMLUA_EVENT_HOOK(HOOK_ON_FIND_SURFACE_ON_RAY, _, Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos) // Manually defined hook diff --git a/src/pc/lua/smlua_hook_events_autogen.inl b/src/pc/lua/smlua_hook_events_autogen.inl index eb2b7647f..8468eb4b8 100644 --- a/src/pc/lua/smlua_hook_events_autogen.inl +++ b/src/pc/lua/smlua_hook_events_autogen.inl @@ -16,7 +16,7 @@ bool smlua_call_event_hooks_HOOK_UPDATE() { // call the callback if (0 != smlua_call_hook(L, 0, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_UPDATE]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_UPDATE], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -46,7 +46,7 @@ bool smlua_call_event_hooks_HOOK_MARIO_UPDATE(struct MarioState *m) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_MARIO_UPDATE]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_MARIO_UPDATE], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -76,7 +76,7 @@ bool smlua_call_event_hooks_HOOK_BEFORE_MARIO_UPDATE(struct MarioState *m) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_BEFORE_MARIO_UPDATE]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_BEFORE_MARIO_UPDATE], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -106,7 +106,7 @@ bool smlua_call_event_hooks_HOOK_ON_SET_MARIO_ACTION(struct MarioState *m) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_SET_MARIO_ACTION]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_SET_MARIO_ACTION], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -141,7 +141,7 @@ bool smlua_call_event_hooks_HOOK_BEFORE_PHYS_STEP(struct MarioState *m, s32 step // call the callback if (0 != smlua_call_hook(L, 3, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_BEFORE_PHYS_STEP]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_BEFORE_PHYS_STEP], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } @@ -186,7 +186,7 @@ bool smlua_call_event_hooks_HOOK_ALLOW_PVP_ATTACK(struct MarioState *attacker, s // call the callback if (0 != smlua_call_hook(L, 3, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ALLOW_PVP_ATTACK]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ALLOW_PVP_ATTACK], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -230,7 +230,7 @@ bool smlua_call_event_hooks_HOOK_ON_PVP_ATTACK(struct MarioState *attacker, stru // call the callback if (0 != smlua_call_hook(L, 3, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_PVP_ATTACK]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_PVP_ATTACK], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -260,7 +260,7 @@ bool smlua_call_event_hooks_HOOK_ON_PLAYER_CONNECTED(struct MarioState *m) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_PLAYER_CONNECTED]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_PLAYER_CONNECTED], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -290,7 +290,7 @@ bool smlua_call_event_hooks_HOOK_ON_PLAYER_DISCONNECTED(struct MarioState *m) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_PLAYER_DISCONNECTED]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_PLAYER_DISCONNECTED], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -326,7 +326,7 @@ bool smlua_call_event_hooks_HOOK_ALLOW_INTERACT(struct MarioState *m, struct Obj // call the callback if (0 != smlua_call_hook(L, 3, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ALLOW_INTERACT]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ALLOW_INTERACT], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -370,7 +370,7 @@ bool smlua_call_event_hooks_HOOK_ON_INTERACT(struct MarioState *m, struct Object // call the callback if (0 != smlua_call_hook(L, 4, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_INTERACT]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_INTERACT], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -409,7 +409,7 @@ bool smlua_call_event_hooks_HOOK_ON_LEVEL_INIT(u8 warpType, s16 levelNum, u8 are // call the callback if (0 != smlua_call_hook(L, 5, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_LEVEL_INIT]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_LEVEL_INIT], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -448,7 +448,7 @@ bool smlua_call_event_hooks_HOOK_ON_WARP(u8 warpType, s16 levelNum, u8 areaIdx, // call the callback if (0 != smlua_call_hook(L, 5, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_WARP]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_WARP], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -472,7 +472,7 @@ bool smlua_call_event_hooks_HOOK_ON_SYNC_VALID() { // call the callback if (0 != smlua_call_hook(L, 0, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_SYNC_VALID]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_SYNC_VALID], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -499,7 +499,7 @@ bool smlua_call_event_hooks_HOOK_ON_OBJECT_UNLOAD(struct Object *obj) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_OBJECT_UNLOAD]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_OBJECT_UNLOAD], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -526,7 +526,7 @@ bool smlua_call_event_hooks_HOOK_ON_SYNC_OBJECT_UNLOAD(struct Object *obj) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_SYNC_OBJECT_UNLOAD]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_SYNC_OBJECT_UNLOAD], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -553,7 +553,7 @@ bool smlua_call_event_hooks_HOOK_ON_PAUSE_EXIT(bool usedExitToCastle, bool *allo // call the callback if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_PAUSE_EXIT]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_PAUSE_EXIT], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -581,7 +581,7 @@ bool smlua_call_event_hooks_HOOK_GET_STAR_COLLECTION_DIALOG(s32 *dialogID) { // call the callback if (0 != smlua_call_hook(L, 0, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_GET_STAR_COLLECTION_DIALOG]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_GET_STAR_COLLECTION_DIALOG], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } @@ -619,7 +619,7 @@ bool smlua_call_event_hooks_HOOK_ON_SET_CAMERA_MODE(struct Camera *c, s16 mode, // call the callback if (0 != smlua_call_hook(L, 3, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_SET_CAMERA_MODE]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_SET_CAMERA_MODE], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -651,7 +651,7 @@ bool smlua_call_event_hooks_HOOK_ON_OBJECT_RENDER(struct Object *obj) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_OBJECT_RENDER]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_OBJECT_RENDER], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -681,7 +681,7 @@ bool smlua_call_event_hooks_HOOK_ON_DEATH(struct MarioState *m, bool *allowDeath // call the callback if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_DEATH]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_DEATH], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -714,7 +714,7 @@ bool smlua_call_event_hooks_HOOK_ON_PACKET_RECEIVE(s32 modIndex, s32 valueIndex) // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_PACKET_RECEIVE]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_PACKET_RECEIVE], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -740,7 +740,7 @@ bool smlua_call_event_hooks_HOOK_USE_ACT_SELECT(s32 levelNum, bool *useActSelect // call the callback if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_USE_ACT_SELECT]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_USE_ACT_SELECT], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } @@ -773,7 +773,7 @@ bool smlua_call_event_hooks_HOOK_ON_CHANGE_CAMERA_ANGLE(s32 camAngleType, bool * // call the callback if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_CHANGE_CAMERA_ANGLE]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_CHANGE_CAMERA_ANGLE], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -805,7 +805,7 @@ bool smlua_call_event_hooks_HOOK_ON_SCREEN_TRANSITION(s32 transitionType, bool * // call the callback if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_SCREEN_TRANSITION]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_SCREEN_TRANSITION], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -843,7 +843,7 @@ bool smlua_call_event_hooks_HOOK_ALLOW_HAZARD_SURFACE(struct MarioState *m, s32 // call the callback if (0 != smlua_call_hook(L, 2, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ALLOW_HAZARD_SURFACE]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ALLOW_HAZARD_SURFACE], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -881,7 +881,7 @@ bool smlua_call_event_hooks_HOOK_ON_CHAT_MESSAGE(struct MarioState *m, const cha // call the callback if (0 != smlua_call_hook(L, 2, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_CHAT_MESSAGE]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_CHAT_MESSAGE], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -919,7 +919,7 @@ bool smlua_call_event_hooks_HOOK_OBJECT_SET_MODEL(struct Object *obj, s32 modelI // call the callback if (0 != smlua_call_hook(L, 3, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_OBJECT_SET_MODEL]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_OBJECT_SET_MODEL], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -951,7 +951,7 @@ bool smlua_call_event_hooks_HOOK_CHARACTER_SOUND(struct MarioState *m, enum Char // call the callback if (0 != smlua_call_hook(L, 2, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_CHARACTER_SOUND]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_CHARACTER_SOUND], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } @@ -993,7 +993,7 @@ bool smlua_call_event_hooks_HOOK_BEFORE_SET_MARIO_ACTION(struct MarioState *m, u // call the callback if (0 != smlua_call_hook(L, 3, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_BEFORE_SET_MARIO_ACTION]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_BEFORE_SET_MARIO_ACTION], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1022,7 +1022,7 @@ bool smlua_call_event_hooks_HOOK_JOINED_GAME() { // call the callback if (0 != smlua_call_hook(L, 0, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_JOINED_GAME]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_JOINED_GAME], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1049,7 +1049,7 @@ bool smlua_call_event_hooks_HOOK_ON_OBJECT_ANIM_UPDATE(struct Object *obj) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_OBJECT_ANIM_UPDATE]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_OBJECT_ANIM_UPDATE], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1076,7 +1076,7 @@ bool smlua_call_event_hooks_HOOK_ON_DIALOG(s32 dialogID, bool *openDialogBox, co // call the callback if (0 != smlua_call_hook(L, 1, 2, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_DIALOG]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_DIALOG], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1110,7 +1110,7 @@ bool smlua_call_event_hooks_HOOK_ON_EXIT() { // call the callback if (0 != smlua_call_hook(L, 0, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_EXIT]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_EXIT], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1136,7 +1136,7 @@ bool smlua_call_event_hooks_HOOK_DIALOG_SOUND(s32 speaker, s32 *speakerOverride) // call the callback if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_DIALOG_SOUND]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_DIALOG_SOUND], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } @@ -1172,7 +1172,7 @@ bool smlua_call_event_hooks_HOOK_ON_COLLIDE_LEVEL_BOUNDS(struct MarioState *m) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_COLLIDE_LEVEL_BOUNDS]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_COLLIDE_LEVEL_BOUNDS], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1202,7 +1202,7 @@ bool smlua_call_event_hooks_HOOK_MIRROR_MARIO_RENDER(struct GraphNodeObject *mir // call the callback if (0 != smlua_call_hook(L, 2, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_MIRROR_MARIO_RENDER]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_MIRROR_MARIO_RENDER], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1231,7 +1231,7 @@ bool smlua_call_event_hooks_HOOK_MARIO_OVERRIDE_PHYS_STEP_DEFACTO_SPEED(struct M // call the callback if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_MARIO_OVERRIDE_PHYS_STEP_DEFACTO_SPEED]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_MARIO_OVERRIDE_PHYS_STEP_DEFACTO_SPEED], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } @@ -1263,7 +1263,7 @@ bool smlua_call_event_hooks_HOOK_ON_OBJECT_LOAD(struct Object *obj) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_OBJECT_LOAD]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_OBJECT_LOAD], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1293,7 +1293,7 @@ bool smlua_call_event_hooks_HOOK_ON_PLAY_SOUND(s32 soundBits, Vec3f pos, s32 *so // call the callback if (0 != smlua_call_hook(L, 2, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_PLAY_SOUND]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_PLAY_SOUND], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } @@ -1331,7 +1331,7 @@ bool smlua_call_event_hooks_HOOK_ON_SEQ_LOAD(u32 seqPlayer, u32 seqId, s32 loadA // call the callback if (0 != smlua_call_hook(L, 3, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_SEQ_LOAD]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_SEQ_LOAD], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } @@ -1373,7 +1373,7 @@ bool smlua_call_event_hooks_HOOK_ON_ATTACK_OBJECT(struct MarioState *m, struct O // call the callback if (0 != smlua_call_hook(L, 3, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_ATTACK_OBJECT]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_ATTACK_OBJECT], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1400,7 +1400,7 @@ bool smlua_call_event_hooks_HOOK_ON_LANGUAGE_CHANGED(const char *langName) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_LANGUAGE_CHANGED]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_LANGUAGE_CHANGED], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1424,7 +1424,7 @@ bool smlua_call_event_hooks_HOOK_ON_MODS_LOADED() { // call the callback if (0 != smlua_call_hook(L, 0, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_MODS_LOADED]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_MODS_LOADED], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1448,7 +1448,7 @@ bool smlua_call_event_hooks_HOOK_ON_DJUI_THEME_CHANGED() { // call the callback if (0 != smlua_call_hook(L, 0, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_DJUI_THEME_CHANGED]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_DJUI_THEME_CHANGED], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1478,7 +1478,7 @@ bool smlua_call_event_hooks_HOOK_ON_GEO_PROCESS(struct GraphNode *node, s32 matS // call the callback if (0 != smlua_call_hook(L, 2, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_GEO_PROCESS]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_GEO_PROCESS], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1508,7 +1508,7 @@ bool smlua_call_event_hooks_HOOK_BEFORE_GEO_PROCESS(struct GraphNode *node, s32 // call the callback if (0 != smlua_call_hook(L, 2, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_BEFORE_GEO_PROCESS]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_BEFORE_GEO_PROCESS], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1538,7 +1538,7 @@ bool smlua_call_event_hooks_HOOK_ON_GEO_PROCESS_CHILDREN(struct GraphNode *paren // call the callback if (0 != smlua_call_hook(L, 2, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_GEO_PROCESS_CHILDREN]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_GEO_PROCESS_CHILDREN], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1568,7 +1568,7 @@ bool smlua_call_event_hooks_HOOK_MARIO_OVERRIDE_GEOMETRY_INPUTS(struct MarioStat // call the callback if (0 != smlua_call_hook(L, 1, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_MARIO_OVERRIDE_GEOMETRY_INPUTS]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_MARIO_OVERRIDE_GEOMETRY_INPUTS], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1603,7 +1603,7 @@ bool smlua_call_event_hooks_HOOK_ON_INTERACTIONS(struct MarioState *m) { // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_INTERACTIONS]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_INTERACTIONS], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1636,7 +1636,7 @@ bool smlua_call_event_hooks_HOOK_ALLOW_FORCE_WATER_ACTION(struct MarioState *m, // call the callback if (0 != smlua_call_hook(L, 2, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ALLOW_FORCE_WATER_ACTION]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ALLOW_FORCE_WATER_ACTION], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1676,7 +1676,7 @@ bool smlua_call_event_hooks_HOOK_BEFORE_WARP(s16 destLevel, s16 destArea, s16 de // call the callback if (0 != smlua_call_hook(L, 4, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_BEFORE_WARP]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_BEFORE_WARP], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } @@ -1734,7 +1734,7 @@ bool smlua_call_event_hooks_HOOK_ON_INSTANT_WARP(u8 areaIdx, u8 nodeId, Vec3s di // call the callback if (0 != smlua_call_hook(L, 3, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_INSTANT_WARP]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_INSTANT_WARP], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1766,7 +1766,7 @@ bool smlua_call_event_hooks_HOOK_MARIO_OVERRIDE_FLOOR_CLASS(struct MarioState *m // call the callback if (0 != smlua_call_hook(L, 2, 1, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_MARIO_OVERRIDE_FLOOR_CLASS]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_MARIO_OVERRIDE_FLOOR_CLASS], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } @@ -1802,7 +1802,7 @@ bool smlua_call_event_hooks_HOOK_ON_ADD_SURFACE(struct Surface *surface, bool dy // call the callback if (0 != smlua_call_hook(L, 2, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_ADD_SURFACE]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_ADD_SURFACE], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1826,7 +1826,7 @@ bool smlua_call_event_hooks_HOOK_ON_CLEAR_AREAS() { // call the callback if (0 != smlua_call_hook(L, 0, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_CLEAR_AREAS]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_CLEAR_AREAS], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; @@ -1854,7 +1854,7 @@ bool smlua_call_event_hooks_HOOK_ON_PACKET_BYTESTRING_RECEIVE(s32 modIndex, s32 // call the callback if (0 != smlua_call_hook(L, 1, 0, 0, hook->mod[i], hook->modFile[i])) { - LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_PACKET_BYTESTRING_RECEIVE]); + LOG_LUA("Failed to call the callback for hook %s - '%s/%s'", sLuaHookedEventTypeName[HOOK_ON_PACKET_BYTESTRING_RECEIVE], hook->mod[i]->relativePath, hook->modFile[i]->relativePath); continue; } hookResult = true; diff --git a/src/pc/lua/smlua_hooks.c b/src/pc/lua/smlua_hooks.c index d487aa2ac..0984c8223 100644 --- a/src/pc/lua/smlua_hooks.c +++ b/src/pc/lua/smlua_hooks.c @@ -26,6 +26,9 @@ #include "game/print.h" #include "gfx_dimensions.h" +extern void smlua_new_vec3f(Vec3f src); +extern void smlua_get_vec3f(Vec3f dest, int index); + #define MAX_HOOKED_REFERENCES 64 #define LUA_BEHAVIOR_FLAG (1 << 15) @@ -172,7 +175,6 @@ bool smlua_call_event_hooks_HOOK_ON_NAMETAGS_RENDER(s32 playerIndex, Vec3f pos, lua_pushinteger(L, playerIndex); // push pos - extern void smlua_new_vec3f(Vec3f src); smlua_new_vec3f(pos); // call the callback @@ -203,7 +205,6 @@ bool smlua_call_event_hooks_HOOK_ON_NAMETAGS_RENDER(s32 playerIndex, Vec3f pos, // pos lua_getfield(L, -1, "pos"); if (lua_type(L, -1) == LUA_TTABLE) { - extern void smlua_get_vec3f(Vec3f dest, int index); smlua_get_vec3f(pos, -1); override = true; } @@ -220,6 +221,306 @@ bool smlua_call_event_hooks_HOOK_ON_NAMETAGS_RENDER(s32 playerIndex, Vec3f pos, return false; } +bool smlua_call_event_hooks_HOOK_ON_FIND_WALL_COLLISION(f32 posX, f32 posY, f32 posZ, struct WallCollisionData *colData, s32 *numCollisions) { + static bool sInHook = false; + lua_State *L = gLuaState; + if (L == NULL || sInHook) { return false; } + sInHook = true; + + struct LuaHookedEvent *hook = &sHookedEvents[HOOK_ON_FIND_WALL_COLLISION]; + for (int i = 0; i < hook->count; i++) { + s32 prevTop = lua_gettop(L); + + // push the callback onto the stack + lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]); + + // push posX, posY, posZ + lua_pushnumber(L, posX); + lua_pushnumber(L, posY); + lua_pushnumber(L, posZ); + + // push colData + smlua_push_object(L, LOT_WALLCOLLISIONDATA, colData, NULL); + + // call the callback (4 args, 1 result) + if (0 != smlua_call_hook(L, 4, 1, 0, hook->mod[i], hook->modFile[i])) { + LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_FIND_WALL_COLLISION]); + lua_settop(L, prevTop); + continue; + } + + // return number overrides numCollisions + if (lua_type(L, -1) == LUA_TNUMBER) { + *numCollisions = smlua_to_integer(L, -1); + lua_settop(L, prevTop); + sInHook = false; + return true; + } + + lua_settop(L, prevTop); + } + sInHook = false; + return false; +} + +bool smlua_call_event_hooks_HOOK_ON_FIND_CEIL(f32 posX, f32 posY, f32 posZ, struct Surface **pceil, f32 *height) { + static bool sInHook = false; + lua_State *L = gLuaState; + if (L == NULL || sInHook) { return false; } + sInHook = true; + + struct LuaHookedEvent *hook = &sHookedEvents[HOOK_ON_FIND_CEIL]; + for (int i = 0; i < hook->count; i++) { + s32 prevTop = lua_gettop(L); + + // push the callback onto the stack + lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]); + + // push posX, posY, posZ + lua_pushnumber(L, posX); + lua_pushnumber(L, posY); + lua_pushnumber(L, posZ); + + // push current ceil surface (or nil) + if (pceil && *pceil) { + smlua_push_object(L, LOT_SURFACE, *pceil, NULL); + } else { + lua_pushnil(L); + } + + // push current height + lua_pushnumber(L, *height); + + // call the callback (5 args, 2 results) + if (0 != smlua_call_hook(L, 5, 2, 0, hook->mod[i], hook->modFile[i])) { + LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_FIND_CEIL]); + lua_settop(L, prevTop); + continue; + } + + bool override = false; + + // first return value: height (number) + if (lua_type(L, -2) == LUA_TNUMBER) { + *height = smlua_to_number(L, -2); + override = true; + } + + // second return value: surface (userdata) + if (lua_type(L, -1) == LUA_TUSERDATA) { + struct Surface *surface = (struct Surface *)smlua_to_cobject(L, -1, LOT_SURFACE); + if (surface && pceil) { + *pceil = surface; + override = true; + } + } + + lua_settop(L, prevTop); + if (override) { sInHook = false; return true; } + } + sInHook = false; + return false; +} + +bool smlua_call_event_hooks_HOOK_ON_FIND_FLOOR(f32 posX, f32 posY, f32 posZ, struct Surface **pfloor, f32 *height) { + static bool sInHook = false; + lua_State *L = gLuaState; + if (L == NULL || sInHook) { return false; } + sInHook = true; + + struct LuaHookedEvent *hook = &sHookedEvents[HOOK_ON_FIND_FLOOR]; + for (int i = 0; i < hook->count; i++) { + s32 prevTop = lua_gettop(L); + + // push the callback onto the stack + lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]); + + // push posX, posY, posZ + lua_pushnumber(L, posX); + lua_pushnumber(L, posY); + lua_pushnumber(L, posZ); + + // push current floor surface (or nil) + if (pfloor && *pfloor) { + smlua_push_object(L, LOT_SURFACE, *pfloor, NULL); + } else { + lua_pushnil(L); + } + + // push current height + lua_pushnumber(L, *height); + + // call the callback (5 args, 2 results) + if (0 != smlua_call_hook(L, 5, 2, 0, hook->mod[i], hook->modFile[i])) { + LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_FIND_FLOOR]); + lua_settop(L, prevTop); + continue; + } + + bool override = false; + + // first return value: height (number) + if (lua_type(L, -2) == LUA_TNUMBER) { + *height = smlua_to_number(L, -2); + override = true; + } + + // second return value: surface (userdata) + if (lua_type(L, -1) == LUA_TUSERDATA) { + struct Surface *surface = (struct Surface *)smlua_to_cobject(L, -1, LOT_SURFACE); + if (surface && pfloor) { + *pfloor = surface; + override = true; + } + } + + lua_settop(L, prevTop); + if (override) { sInHook = false; return true; } + } + sInHook = false; + return false; +} + +bool smlua_call_event_hooks_HOOK_ON_FIND_SURFACE_ON_RAY(Vec3f orig, Vec3f dir, struct Surface **hit_surface, Vec3f hit_pos) { + static bool sInHook = false; + lua_State *L = gLuaState; + if (L == NULL || sInHook) { return false; } + sInHook = true; + + struct LuaHookedEvent *hook = &sHookedEvents[HOOK_ON_FIND_SURFACE_ON_RAY]; + for (int i = 0; i < hook->count; i++) { + s32 prevTop = lua_gettop(L); + + // push the callback onto the stack + lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]); + + // push orig, dir + smlua_new_vec3f(orig); + smlua_new_vec3f(dir); + + // push hit_surface (or nil) + if (hit_surface && *hit_surface) { + smlua_push_object(L, LOT_SURFACE, *hit_surface, NULL); + } else { + lua_pushnil(L); + } + + // push hit_pos + smlua_new_vec3f(hit_pos); + + // call the callback (4 args, 2 results) + if (0 != smlua_call_hook(L, 4, 2, 0, hook->mod[i], hook->modFile[i])) { + LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_FIND_SURFACE_ON_RAY]); + lua_settop(L, prevTop); + continue; + } + + bool override = false; + + // first return value: surface (userdata) + if (lua_type(L, -2) == LUA_TUSERDATA) { + struct Surface *surface = (struct Surface *)smlua_to_cobject(L, -2, LOT_SURFACE); + if (surface && hit_surface) { + *hit_surface = surface; + override = true; + } + } + + // second return value: hitPos (table {x, y, z}) + if (lua_type(L, -1) == LUA_TTABLE) { + smlua_get_vec3f(hit_pos, -1); + override = true; + } + + lua_settop(L, prevTop); + if (override) { sInHook = false; return true; } + } + sInHook = false; + return false; +} + +bool smlua_call_event_hooks_HOOK_ON_FIND_WATER_LEVEL(f32 x, f32 z, f32 *waterLevel) { + static bool sInHook = false; + lua_State *L = gLuaState; + if (L == NULL || sInHook) { return false; } + sInHook = true; + + struct LuaHookedEvent *hook = &sHookedEvents[HOOK_ON_FIND_WATER_LEVEL]; + for (int i = 0; i < hook->count; i++) { + s32 prevTop = lua_gettop(L); + + // push the callback onto the stack + lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]); + + // push x, z + lua_pushnumber(L, x); + lua_pushnumber(L, z); + + // push current water level + lua_pushnumber(L, *waterLevel); + + // call the callback (3 args, 1 result) + if (0 != smlua_call_hook(L, 3, 1, 0, hook->mod[i], hook->modFile[i])) { + LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_FIND_WATER_LEVEL]); + lua_settop(L, prevTop); + continue; + } + + // return number overrides waterLevel + if (lua_type(L, -1) == LUA_TNUMBER) { + *waterLevel = smlua_to_number(L, -1); + lua_settop(L, prevTop); + sInHook = false; + return true; + } + + lua_settop(L, prevTop); + } + sInHook = false; + return false; +} + +bool smlua_call_event_hooks_HOOK_ON_FIND_POISON_GAS_LEVEL(f32 x, f32 z, f32 *gasLevel) { + static bool sInHook = false; + lua_State *L = gLuaState; + if (L == NULL || sInHook) { return false; } + sInHook = true; + + struct LuaHookedEvent *hook = &sHookedEvents[HOOK_ON_FIND_POISON_GAS_LEVEL]; + for (int i = 0; i < hook->count; i++) { + s32 prevTop = lua_gettop(L); + + // push the callback onto the stack + lua_rawgeti(L, LUA_REGISTRYINDEX, hook->reference[i]); + + // push x, z + lua_pushnumber(L, x); + lua_pushnumber(L, z); + + // push current gas level + lua_pushnumber(L, *gasLevel); + + // call the callback (3 args, 1 result) + if (0 != smlua_call_hook(L, 3, 1, 0, hook->mod[i], hook->modFile[i])) { + LOG_LUA("Failed to call the callback for hook %s", sLuaHookedEventTypeName[HOOK_ON_FIND_POISON_GAS_LEVEL]); + lua_settop(L, prevTop); + continue; + } + + // return number overrides gasLevel + if (lua_type(L, -1) == LUA_TNUMBER) { + *gasLevel = smlua_to_number(L, -1); + lua_settop(L, prevTop); + sInHook = false; + return true; + } + + lua_settop(L, prevTop); + } + sInHook = false; + return false; +} + //////////////////// // hooked actions // //////////////////// @@ -398,30 +699,13 @@ u32 smlua_get_action_interaction_type(struct MarioState* m) { // hooked behaviors // ////////////////////// -struct LuaHookedBehavior { - u32 behaviorId; - u32 overrideId; - u32 originalId; - BehaviorScript *behavior; - const BehaviorScript* originalBehavior; - const char* bhvName; - int initReference; - int loopReference; - bool replace; - bool luaBehavior; - struct Mod* mod; - struct ModFile* modFile; -}; - -#define MAX_HOOKED_BEHAVIORS 1024 - -static struct LuaHookedBehavior sHookedBehaviors[MAX_HOOKED_BEHAVIORS] = { 0 }; -static int sHookedBehaviorsCount = 0; +struct LuaHookedBehavior gHookedBehaviors[MAX_HOOKED_BEHAVIORS] = { 0 }; +int gHookedBehaviorsCount = 0; enum BehaviorId smlua_get_original_behavior_id(const BehaviorScript* behavior) { enum BehaviorId id = get_id_from_behavior(behavior); - for (int i = 0; i < sHookedBehaviorsCount; i++) { - struct LuaHookedBehavior* hooked = &sHookedBehaviors[i]; + for (int i = 0; i < gHookedBehaviorsCount; i++) { + struct LuaHookedBehavior* hooked = &gHookedBehaviors[i]; if (hooked->behavior == behavior) { id = hooked->overrideId; } @@ -443,8 +727,8 @@ const BehaviorScript* smlua_get_hooked_behavior_from_id(enum BehaviorId id, bool lua_State *L = gLuaState; if (L == NULL) { return NULL; } - for (int i = 0; i < sHookedBehaviorsCount; i++) { - struct LuaHookedBehavior* hooked = &sHookedBehaviors[i]; + for (int i = 0; i < gHookedBehaviorsCount; i++) { + struct LuaHookedBehavior* hooked = &gHookedBehaviors[i]; if (hooked->behaviorId != id && hooked->overrideId != id) { continue; } if (returnOriginal && !hooked->replace) { return hooked->originalBehavior; } return hooked->behavior; @@ -457,8 +741,8 @@ bool smlua_is_behavior_hooked(const BehaviorScript *behavior) { if (L == NULL) { return false; } enum BehaviorId id = get_id_from_behavior(behavior); - for (int i = 0; i < sHookedBehaviorsCount; i++) { - struct LuaHookedBehavior *hooked = &sHookedBehaviors[i]; + for (int i = 0; i < gHookedBehaviorsCount; i++) { + struct LuaHookedBehavior *hooked = &gHookedBehaviors[i]; if (hooked->behaviorId != id && hooked->overrideId != id) { continue; } return hooked->luaBehavior; } @@ -467,8 +751,8 @@ bool smlua_is_behavior_hooked(const BehaviorScript *behavior) { } const char* smlua_get_name_from_hooked_behavior_id(enum BehaviorId id) { - for (int i = 0; i < sHookedBehaviorsCount; i++) { - struct LuaHookedBehavior *hooked = &sHookedBehaviors[i]; + for (int i = 0; i < gHookedBehaviorsCount; i++) { + struct LuaHookedBehavior *hooked = &gHookedBehaviors[i]; if (hooked->behaviorId != id && hooked->overrideId != id) { continue; } return hooked->bhvName; } @@ -476,7 +760,7 @@ const char* smlua_get_name_from_hooked_behavior_id(enum BehaviorId id) { } int smlua_hook_custom_bhv(BehaviorScript *bhvScript, const char *bhvName) { - if (sHookedBehaviorsCount >= MAX_HOOKED_BEHAVIORS) { + if (gHookedBehaviorsCount >= MAX_HOOKED_BEHAVIORS) { LOG_ERROR("Hooked behaviors exceeded maximum references!"); return 0; } @@ -490,8 +774,8 @@ int smlua_hook_custom_bhv(BehaviorScript *bhvScript, const char *bhvName) { u8 newBehavior = originalBehaviorId >= id_bhv_max_count; - struct LuaHookedBehavior *hooked = &sHookedBehaviors[sHookedBehaviorsCount]; - u16 customBehaviorId = (sHookedBehaviorsCount & 0xFFFF) | LUA_BEHAVIOR_FLAG; + struct LuaHookedBehavior *hooked = &gHookedBehaviors[gHookedBehaviorsCount]; + u16 customBehaviorId = (gHookedBehaviorsCount & 0xFFFF) | LUA_BEHAVIOR_FLAG; hooked->behavior = bhvScript; hooked->behavior[1] = (BehaviorScript)BC_B0H(0x39, customBehaviorId); // This is ID(customBehaviorId) hooked->behaviorId = customBehaviorId; @@ -506,7 +790,7 @@ int smlua_hook_custom_bhv(BehaviorScript *bhvScript, const char *bhvName) { hooked->mod = gLuaActiveMod; hooked->modFile = gLuaActiveModFile; - sHookedBehaviorsCount++; + gHookedBehaviorsCount++; // We want to push the behavior into the global LUA state. So mods can access it. // It's also used for some things that would normally access a LUA behavior instead. @@ -531,7 +815,7 @@ int smlua_hook_behavior(lua_State* L) { int paramCount = lua_gettop(L); - if (sHookedBehaviorsCount >= MAX_HOOKED_BEHAVIORS) { + if (gHookedBehaviorsCount >= MAX_HOOKED_BEHAVIORS) { LOG_LUA_LINE("Hooked behaviors exceeded maximum references!"); return 0; } @@ -634,8 +918,8 @@ int smlua_hook_behavior(lua_State* L) { bhvName = sGenericBhvName; } - struct LuaHookedBehavior* hooked = &sHookedBehaviors[sHookedBehaviorsCount]; - u16 customBehaviorId = (sHookedBehaviorsCount & 0xFFFF) | LUA_BEHAVIOR_FLAG; + struct LuaHookedBehavior* hooked = &gHookedBehaviors[gHookedBehaviorsCount]; + u16 customBehaviorId = (gHookedBehaviorsCount & 0xFFFF) | LUA_BEHAVIOR_FLAG; hooked->behavior = calloc(4, sizeof(BehaviorScript)); hooked->behavior[0] = (BehaviorScript)BC_BB(0x00, objectList); // This is BEGIN(objectList) hooked->behavior[1] = (BehaviorScript)BC_B0H(0x39, customBehaviorId); // This is ID(customBehaviorId) @@ -653,7 +937,7 @@ int smlua_hook_behavior(lua_State* L) { hooked->mod = gLuaActiveMod; hooked->modFile = gLuaActiveModFile; - sHookedBehaviorsCount++; + gHookedBehaviorsCount++; // We want to push the behavior into the global LUA state. So mods can access it. // It's also used for some things that would normally access a LUA behavior instead. @@ -670,8 +954,8 @@ int smlua_hook_behavior(lua_State* L) { bool smlua_call_behavior_hook(const BehaviorScript** behavior, struct Object* object, bool before) { lua_State* L = gLuaState; if (L == NULL) { return false; } - for (int i = 0; i < sHookedBehaviorsCount; i++) { - struct LuaHookedBehavior* hooked = &sHookedBehaviors[i]; + for (int i = 0; i < gHookedBehaviorsCount; i++) { + struct LuaHookedBehavior* hooked = &gHookedBehaviors[i]; // find behavior if (object->behavior != hooked->behavior) { @@ -969,7 +1253,7 @@ char** smlua_get_chat_subcommands_list(const char* maincommand) { for (s32 i = 0; i < sHookedChatCommandsCount; i++) { struct LuaHookedChatCommand* hook = &sHookedChatCommands[i]; if (strcmp(hook->command, maincommand) == 0) { - char* noColorsDesc = str_remove_color_codes(hook->description); + char* noColorsDesc = djui_text_get_uncolored_string(NULL, strlen(hook->description) + 1, hook->description); char* startSubcommands = strstr(noColorsDesc, "["); char* endSubcommands = strstr(noColorsDesc, "]"); @@ -1518,8 +1802,8 @@ void smlua_hook_replace_function_references(lua_State* L, int oldReference, int smlua_hook_replace_function_reference(L, &hooked->reference, oldReference, newReference); } - for (int i = 0; i < sHookedBehaviorsCount; i++) { - struct LuaHookedBehavior* hooked = &sHookedBehaviors[i]; + for (int i = 0; i < gHookedBehaviorsCount; i++) { + struct LuaHookedBehavior* hooked = &gHookedBehaviors[i]; smlua_hook_replace_function_reference(L, &hooked->initReference, oldReference, newReference); smlua_hook_replace_function_reference(L, &hooked->loopReference, oldReference, newReference); } @@ -1574,8 +1858,8 @@ void smlua_clear_hooks(void) { } gHookedModMenuElementsCount = 0; - for (int i = 0; i < sHookedBehaviorsCount; i++) { - struct LuaHookedBehavior* hooked = &sHookedBehaviors[i]; + for (int i = 0; i < gHookedBehaviorsCount; i++) { + struct LuaHookedBehavior* hooked = &gHookedBehaviors[i]; // If this is NULL. We can't do anything with it. if (hooked->behavior != NULL) { @@ -1601,7 +1885,7 @@ void smlua_clear_hooks(void) { hooked->mod = NULL; hooked->modFile = NULL; } - sHookedBehaviorsCount = 0; + gHookedBehaviorsCount = 0; memset(gLuaMarioActionIndex, 0, sizeof(gLuaMarioActionIndex)); } diff --git a/src/pc/lua/smlua_hooks.h b/src/pc/lua/smlua_hooks.h index edfcc975f..c814c73e9 100644 --- a/src/pc/lua/smlua_hooks.h +++ b/src/pc/lua/smlua_hooks.h @@ -11,6 +11,8 @@ // forward declare struct Camera; struct WarpDest; +struct WallCollisionData; +struct Surface; // ! Hooks must be added at the end enum LuaHookedEventType { @@ -74,6 +76,12 @@ enum LuaHookedEventType { HOOK_ON_ADD_SURFACE, HOOK_ON_CLEAR_AREAS, HOOK_ON_PACKET_BYTESTRING_RECEIVE, + HOOK_ON_FIND_WALL_COLLISION, + HOOK_ON_FIND_CEIL, + HOOK_ON_FIND_FLOOR, + HOOK_ON_FIND_WATER_LEVEL, + HOOK_ON_FIND_POISON_GAS_LEVEL, + HOOK_ON_FIND_SURFACE_ON_RAY, HOOK_MAX, }; @@ -127,6 +135,26 @@ extern u32 gLuaMarioActionIndex[]; extern struct LuaHookedModMenuElement gHookedModMenuElements[]; extern int gHookedModMenuElementsCount; +#define MAX_HOOKED_BEHAVIORS 1024 + +struct LuaHookedBehavior { + u32 behaviorId; + u32 overrideId; + u32 originalId; + BehaviorScript *behavior; + const BehaviorScript* originalBehavior; + const char* bhvName; + int initReference; + int loopReference; + bool replace; + bool luaBehavior; + struct Mod* mod; + struct ModFile* modFile; +}; + +extern int gHookedBehaviorsCount; +extern struct LuaHookedBehavior gHookedBehaviors[MAX_HOOKED_BEHAVIORS]; + #define OUTPUT #define SMLUA_EVENT_HOOK(hookEventType, hookReturn, ...) bool smlua_call_event_hooks_##hookEventType(__VA_ARGS__); #include "smlua_hook_events.inl" diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index e692476f4..9b02de52e 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -18,6 +18,7 @@ #include "pc/debuglog.h" #include "pc/pc_main.h" #include "pc/fs/fmem.h" +#include "audio/load.h" struct AudioOverride { bool enabled; @@ -73,6 +74,8 @@ bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData) { struct AudioOverride* override = &sAudioOverrides[sequenceId]; if (!override->enabled) { return false; } + if (gOverrideBank > -1) { override->bank = gOverrideBank; } + if (override->loaded) { *seqData = override->buffer; *bankId = override->bank; @@ -170,6 +173,16 @@ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolu LOG_LUA_LINE("Could not find m64 at path: %s", m64path); } +u8 smlua_audio_utils_allocate_sequence(void) { + for (u8 seqId = SEQ_COUNT + 1; seqId < MAX_AUDIO_OVERRIDE; seqId++) { + if (!sAudioOverrides[seqId].enabled) { + return seqId; + } + } + LOG_ERROR("Cannot allocate more custom sequences."); + return MAX_AUDIO_OVERRIDE; +} + /////////////// // mod audio // /////////////// diff --git a/src/pc/lua/utils/smlua_audio_utils.h b/src/pc/lua/utils/smlua_audio_utils.h index 715ad7a3b..29fa17d45 100644 --- a/src/pc/lua/utils/smlua_audio_utils.h +++ b/src/pc/lua/utils/smlua_audio_utils.h @@ -8,6 +8,8 @@ void smlua_audio_utils_reset_all(void); bool smlua_audio_utils_override(u8 sequenceId, s32* bankId, void** seqData); /* |description|Replaces the sequence corresponding to `sequenceId` with one called `m64Name`.m64 with `bankId` and `defaultVolume`|descriptionEnd| */ void smlua_audio_utils_replace_sequence(u8 sequenceId, u8 bankId, u8 defaultVolume, const char* m64Name); +/* |description|Allocates a new sequence ID|descriptionEnd| */ +u8 smlua_audio_utils_allocate_sequence(void); //////////////// // mod sounds // diff --git a/src/pc/lua/utils/smlua_misc_utils.c b/src/pc/lua/utils/smlua_misc_utils.c index bff36cbbf..9e90a45fb 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -490,6 +490,12 @@ s32 get_dialog_response(void) { /// +u32 get_time_stop_flags(void) { + return gTimeStopState; +} + +/// + const char* get_local_discord_id(void) { #ifdef DISCORD_SDK if (gDiscordInitialized) { @@ -601,6 +607,54 @@ struct Mod* get_active_mod(void) { return gLuaActiveMod; } +LuaTable get_mod_files(struct Mod* mod, OPTIONAL const char* subDirectory) { + if (!mod) { + struct lua_State *L = gLuaState; + if (L) { + lua_newtable(L); + return smlua_to_lua_table(L, -1); + } + return 0; + } + + char normalizedSubDir[SYS_MAX_PATH] = { 0 }; + snprintf(normalizedSubDir, SYS_MAX_PATH, "%s", subDirectory ? subDirectory : ""); + normalize_path(normalizedSubDir); + + size_t subDirLen = strlen(normalizedSubDir); + if (subDirLen > 0 && subDirLen + 1 < SYS_MAX_PATH && normalizedSubDir[subDirLen - 1] != '/') { + strcat(normalizedSubDir, "/"); + subDirLen = strlen(normalizedSubDir); + } + + struct lua_State *L = gLuaState; + if (!L) { return 0; } + + LUA_STACK_CHECK_BEGIN_NUM(L, 1); + + lua_newtable(L); + + int luaTableIndex = 1; + for (int i = 0; i < mod->fileCount; i++) { + struct ModFile* file = &mod->files[i]; + char normalizedPath[SYS_MAX_PATH] = { 0 }; + if (snprintf(normalizedPath, SYS_MAX_PATH, "%s", file->relativePath) < 0) { + LOG_ERROR("Failed to copy relativePath for normalization: %s", file->relativePath); + continue; + } + normalize_path(normalizedPath); + + if (strncmp(normalizedPath, normalizedSubDir, subDirLen) == 0) { + lua_pushstring(L, file->relativePath); + lua_rawseti(L, -2, luaTableIndex++); + } + } + + LUA_STACK_CHECK_END(L); + + return smlua_to_lua_table(L, -1); +} + /// void set_window_title(const char* title) { @@ -651,6 +705,13 @@ struct GraphNodeHeldObject* geo_get_current_held_object(void) { return gCurGraphNodeHeldObject; } +void geo_skip_interpolation(struct GraphNode *node, struct GraphNodeObject *obj) { + struct GraphNodeInterpData *interp = geo_get_interp_data(node, obj); + if (interp) { interp->timestamp = 0; } +} + +/// + LuaTable texture_to_lua_table(const Texture *tex) { lua_State *L = gLuaState; if (!L) { return 0; } diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index 5171af3ee..1b7d929cb 100644 --- a/src/pc/lua/utils/smlua_misc_utils.h +++ b/src/pc/lua/utils/smlua_misc_utils.h @@ -37,7 +37,7 @@ enum ActSelectHudPart { ACT_SELECT_HUD_ACT_NAME = 1 << 3, ACT_SELECT_HUD_STAR_NUM = 1 << 4, ACT_SELECT_HUD_PLAYERS_IN_LEVEL = 1 << 5, - + ACT_SELECT_HUD_NONE = 0, ACT_SELECT_HUD_ALL = ACT_SELECT_HUD_SCORE | ACT_SELECT_HUD_LEVEL_NAME | ACT_SELECT_HUD_COURSE_NUM | ACT_SELECT_HUD_ACT_NAME |ACT_SELECT_HUD_STAR_NUM | ACT_SELECT_HUD_PLAYERS_IN_LEVEL }; @@ -212,6 +212,9 @@ u32 get_global_timer(void); /* |description|Gets the choice selected inside of a dialog box (0-1)|descriptionEnd| */ s32 get_dialog_response(void); +/* |description|Gets the active time stop flags, used to freeze specific objects during cutscenes|descriptionEnd| */ +u32 get_time_stop_flags(void); + /* |description|Gets the local discord ID if it isn't disabled, otherwise "0" is returned|descriptionEnd| */ const char* get_local_discord_id(void); /* |description|Gets the CoopNet ID of a player with `localIndex` if CoopNet is being used and the player is connected, otherwise "-1" is returned|descriptionEnd| */ @@ -243,6 +246,8 @@ void set_environment_region(u8 index, s16 value); bool mod_file_exists(const char* filename); /* |description|Gets the mod currently being processed|descriptionEnd| */ struct Mod* get_active_mod(void); +/* |description|Gets all files a mod contains|descriptionEnd| */ +LuaTable get_mod_files(struct Mod* mod, OPTIONAL const char* subDirectory); /* |description|Sets the window title to a custom title|descriptionEnd| */ void set_window_title(const char* title); @@ -252,24 +257,21 @@ void reset_window_title(void); /* |description|Gets the name of the operating system the game is running on|descriptionEnd| */ const char* get_os_name(void); -/* |description|Gets the current GraphNodeRoot|descriptionEnd|*/ +/* |description|Gets the current root node being processed|descriptionEnd|*/ struct GraphNodeRoot* geo_get_current_root(void); - -/* |description|Gets the current GraphNodeMasterList|descriptionEnd|*/ +/* |description|Gets the current master list node being processed|descriptionEnd|*/ struct GraphNodeMasterList* geo_get_current_master_list(void); - -/* |description|Gets the current GraphNodePerspective|descriptionEnd|*/ +/* |description|Gets the current perspective node being processed|descriptionEnd|*/ struct GraphNodePerspective* geo_get_current_perspective(void); - -/* |description|Gets the current GraphNodeCamera|descriptionEnd|*/ +/* |description|Gets the current camera node being processed|descriptionEnd|*/ struct GraphNodeCamera* geo_get_current_camera(void); - -/* |description|Gets the current GraphNodeHeldObject|descriptionEnd|*/ +/* |description|Gets the current held object node being processed|descriptionEnd|*/ struct GraphNodeHeldObject* geo_get_current_held_object(void); +/* |description|Skips graph node interpolation for a frame|descriptionEnd|*/ +void geo_skip_interpolation(struct GraphNode *node, struct GraphNodeObject *obj); /* |description|Converts a texture's pixels to a Lua table. Returns nil if failed. Otherwise, returns a 1-indexed table of RGBA pixels|descriptionEnd|*/ LuaTable texture_to_lua_table(const Texture *tex); - /* |description|Gets the name of the provided texture pointer `tex`|descriptionEnd|*/ const char *get_texture_name(const Texture *tex); diff --git a/src/pc/lua/utils/smlua_obj_utils.c b/src/pc/lua/utils/smlua_obj_utils.c index 6ddc020f8..aa71c422d 100644 --- a/src/pc/lua/utils/smlua_obj_utils.c +++ b/src/pc/lua/utils/smlua_obj_utils.c @@ -522,6 +522,14 @@ void set_whirlpools(f32 x, f32 y, f32 z, s16 strength, s16 area, s32 index) { gAreas[area].whirlpools[index]->strength = strength; } +void obj_skip_interpolation(struct Object *o) { + if (o) { o->header.gfx.skipInterpolationTimestamp = gGlobalTimer + 1; } +} + +void obj_anim_skip_interpolation(struct Object *o) { + if (o) { o->header.gfx.animInfo.prevAnimFrameTimestamp = 0; } +} + #ifdef DEVELOPMENT void obj_randomize(struct Object* o) { if (!o) { return; } diff --git a/src/pc/lua/utils/smlua_obj_utils.h b/src/pc/lua/utils/smlua_obj_utils.h index b0e75fbb0..518e3b193 100644 --- a/src/pc/lua/utils/smlua_obj_utils.h +++ b/src/pc/lua/utils/smlua_obj_utils.h @@ -155,4 +155,9 @@ void obj_move_xyz(struct Object *o, f32 dx, f32 dy, f32 dz); /* |description|Sets the parameters of one of the two whirlpools (0-indexed) in an area|descriptionEnd| */ void set_whirlpools(f32 x, f32 y, f32 z, s16 strength, s16 area, s32 index); +/* |description|Skips object interpolation for a frame|descriptionEnd|*/ +void obj_skip_interpolation(struct Object *o); +/* |description|Skips animation interpolation for a frame|descriptionEnd| */ +void obj_anim_skip_interpolation(struct Object *o); + #endif diff --git a/src/pc/mods/mod.c b/src/pc/mods/mod.c index aca944c85..03f63ce39 100644 --- a/src/pc/mods/mod.c +++ b/src/pc/mods/mod.c @@ -197,11 +197,6 @@ void mod_clear(struct Mod* mod) { } } - if (mod->name != NULL) { - free(mod->name); - mod->name = NULL; - } - if (mod->incompatible != NULL) { free(mod->incompatible); mod->incompatible = NULL; @@ -449,7 +444,7 @@ static void mod_extract_fields(struct Mod* mod) { fseek(f, 0, SEEK_SET); // default to null - mod->name = NULL; + mod->name[0] = 0; mod->incompatible = NULL; mod->category = NULL; mod->description = NULL; @@ -457,7 +452,7 @@ static void mod_extract_fields(struct Mod* mod) { mod->ignoreScriptWarnings = false; // read line-by-line - #define BUFFER_SIZE MAX(MAX(MOD_NAME_MAX_LENGTH, MOD_INCOMPATIBLE_MAX_LENGTH), MOD_DESCRIPTION_MAX_LENGTH) + #define BUFFER_SIZE MAX(MAX(MOD_NAME_SIZE, MOD_INCOMPATIBLE_SIZE), MOD_DESCRIPTION_SIZE) char buffer[BUFFER_SIZE] = { 0 }; while (!feof(f)) { file_get_line(buffer, BUFFER_SIZE, f); @@ -470,24 +465,23 @@ static void mod_extract_fields(struct Mod* mod) { // extract the field char* extracted = NULL; - if (mod->name == NULL && (extracted = extract_lua_field("-- name:", buffer))) { - mod->name = calloc(MOD_NAME_MAX_LENGTH + 1, sizeof(char)); - if (snprintf(mod->name, MOD_NAME_MAX_LENGTH, "%s", extracted) < 0) { + if (!mod->name[0] && (extracted = extract_lua_field("-- name:", buffer))) { + if (snprintf(mod->name, MOD_NAME_SIZE, "%s", extracted) < 0) { LOG_INFO("Truncated mod name field '%s'", mod->name); } } else if (mod->incompatible == NULL && (extracted = extract_lua_field("-- incompatible:", buffer))) { - mod->incompatible = calloc(MOD_INCOMPATIBLE_MAX_LENGTH + 1, sizeof(char)); - if (snprintf(mod->incompatible, MOD_INCOMPATIBLE_MAX_LENGTH, "%s", extracted) < 0) { + mod->incompatible = calloc(MOD_INCOMPATIBLE_SIZE, sizeof(char)); + if (snprintf(mod->incompatible, MOD_INCOMPATIBLE_SIZE, "%s", extracted) < 0) { LOG_INFO("Truncated mod incompatible field '%s'", mod->incompatible); } } else if (mod->category == NULL && (extracted = extract_lua_field("-- category:", buffer))) { - mod->category = calloc(MOD_CATEGORY_MAX_LENGTH + 1, sizeof(char)); - if (snprintf(mod->category, MOD_CATEGORY_MAX_LENGTH, "%s", extracted) < 0) { + mod->category = calloc(MOD_CATEGORY_SIZE, sizeof(char)); + if (snprintf(mod->category, MOD_CATEGORY_SIZE, "%s", extracted) < 0) { LOG_INFO("Truncated mod category field '%s'", mod->category); } } else if (mod->description == NULL && (extracted = extract_lua_field("-- description:", buffer))) { - mod->description = calloc(MOD_DESCRIPTION_MAX_LENGTH + 1, sizeof(char)); - if (snprintf(mod->description, MOD_DESCRIPTION_MAX_LENGTH, "%s", extracted) < 0) { + mod->description = calloc(MOD_DESCRIPTION_SIZE, sizeof(char)); + if (snprintf(mod->description, MOD_DESCRIPTION_SIZE, "%s", extracted) < 0) { LOG_INFO("Truncated mod description field '%s'", mod->description); } } else if ((extracted = extract_lua_field("-- pausable:", buffer))) { @@ -632,17 +626,19 @@ bool mod_load(struct Mods* mods, char* basePath, char* modName) { mod_extract_fields(mod); // set name - if (mod->name == NULL) { - mod->name = strdup(modName); + if (!mod->name[0]) { + if (snprintf(mod->name, MOD_NAME_SIZE, "%s", modName) < 0) { + LOG_INFO("Truncated mod name field '%s'", mod->name); + } } // set category if (mod->category == NULL) { - char *modNameNoColor = str_remove_color_codes(mod->name); + char modNameNoColor[MOD_NAME_SIZE]; + djui_text_get_uncolored_string(modNameNoColor, MOD_NAME_SIZE, mod->name); if (strstr(modNameNoColor, "[CS]") == modNameNoColor) { mod->category = strdup("cs"); } - free(modNameNoColor); } // print diff --git a/src/pc/mods/mod.h b/src/pc/mods/mod.h index ea1e6c72a..9f14f361e 100644 --- a/src/pc/mods/mod.h +++ b/src/pc/mods/mod.h @@ -10,6 +10,11 @@ #define MOD_CATEGORY_MAX_LENGTH 64 #define MOD_DESCRIPTION_MAX_LENGTH 800 +#define MOD_NAME_SIZE (MOD_NAME_MAX_LENGTH + 1) +#define MOD_INCOMPATIBLE_SIZE (MOD_INCOMPATIBLE_MAX_LENGTH + 1) +#define MOD_CATEGORY_SIZE (MOD_CATEGORY_MAX_LENGTH + 1) +#define MOD_DESCRIPTION_SIZE (MOD_DESCRIPTION_MAX_LENGTH + 1) + struct Mods; struct ModFile { @@ -25,7 +30,7 @@ struct ModFile { }; struct Mod { - char* name; + char name[MOD_NAME_SIZE]; char* incompatible; char* category; char* description; diff --git a/src/pc/mods/mod_storage.h b/src/pc/mods/mod_storage.h index a3762e3f7..ee41af4a4 100644 --- a/src/pc/mods/mod_storage.h +++ b/src/pc/mods/mod_storage.h @@ -1,11 +1,11 @@ #ifndef MOD_STORAGE_H #define MOD_STORAGE_H -#include - #ifdef __cplusplus extern "C" { #endif +#include + #include "pc/lua/smlua_utils.h" #define MAX_KEYS 4096 diff --git a/src/pc/mods/mods.c b/src/pc/mods/mods.c index 9af7ab2b3..84b8fb497 100644 --- a/src/pc/mods/mods.c +++ b/src/pc/mods/mods.c @@ -184,19 +184,20 @@ static void mods_sort(struct Mods* mods) { } // By default, this is the alphabetical order on name + char modNameNoColor_i[MOD_NAME_SIZE]; + char modNameNoColor_j[MOD_NAME_SIZE]; for (s32 i = 1; i < mods->entryCount; ++i) { - struct Mod* mod = mods->entries[i]; + struct Mod* mod_i = mods->entries[i]; + djui_text_get_uncolored_string(modNameNoColor_i, MOD_NAME_SIZE, mod_i->name); for (s32 j = 0; j < i; ++j) { - struct Mod* mod2 = mods->entries[j]; - char* name = str_remove_color_codes(mod->name); - char* name2 = str_remove_color_codes(mod2->name); - if (strcmp(name, name2) < 0) { - mods->entries[i] = mod2; - mods->entries[j] = mod; - mod = mods->entries[i]; + struct Mod* mod_j = mods->entries[j]; + djui_text_get_uncolored_string(modNameNoColor_j, MOD_NAME_SIZE, mod_j->name); + if (strcmp(modNameNoColor_i, modNameNoColor_j) < 0) { + mods->entries[i] = mod_j; + mods->entries[j] = mod_i; + mod_i = mod_j; + memcpy(modNameNoColor_i, modNameNoColor_j, MOD_NAME_SIZE * sizeof(char)); } - free(name); - free(name2); } } } diff --git a/src/pc/network/network.c b/src/pc/network/network.c index d267d7cb8..6bd1d4882 100644 --- a/src/pc/network/network.c +++ b/src/pc/network/network.c @@ -36,6 +36,7 @@ #include "game/mario.h" #include "engine/math_util.h" #include "engine/lighting_engine.h" +#include "src/audio/load.h" #ifdef DISCORD_SDK #include "pc/discord/discord.h" @@ -711,6 +712,7 @@ void network_shutdown(bool sendLeaving, bool exiting, bool popup, bool reconnect gOverrideFar = 0; gOverrideFOV = 0; gRoomOverride = -1; + gOverrideBank = -1; gCurrActStarNum = 0; gCurrActNum = 0; gCurrCreditsEntry = NULL; diff --git a/src/pc/network/packets/packet_download.c b/src/pc/network/packets/packet_download.c index ab5aa4917..3d26a7a30 100644 --- a/src/pc/network/packets/packet_download.c +++ b/src/pc/network/packets/packet_download.c @@ -318,13 +318,13 @@ after_filled:; // Cache any mod that doesn't have "(wip)" or "[wip]" in its name (case-insensitive) static bool should_cache_mod(struct Mod *mod) { - char *modName = sys_strdup(mod->name); - sys_strlwr(modName); + char modNameLowercase[MOD_NAME_SIZE]; + memcpy(modNameLowercase, mod->name, MOD_NAME_SIZE * sizeof(char)); + sys_strlwr(modNameLowercase); bool shouldCache = ( - !strstr(modName, "(wip)") && - !strstr(modName, "[wip]") + !strstr(modNameLowercase, "(wip)") && + !strstr(modNameLowercase, "[wip]") ); - free(modName); return shouldCache; } diff --git a/src/pc/network/packets/packet_mod_list.c b/src/pc/network/packets/packet_mod_list.c index 2a4a7baf8..23a4411d2 100644 --- a/src/pc/network/packets/packet_mod_list.c +++ b/src/pc/network/packets/packet_mod_list.c @@ -197,9 +197,8 @@ void network_receive_mod_list_entry(struct Packet* p) { } // get name - char name[MOD_NAME_MAX_LENGTH + 1] = { 0 }; - packet_read(p, name, nameLength * sizeof(u8)); - mod->name = strdup(name); + packet_read(p, mod->name, nameLength * sizeof(u8)); + mod->name[nameLength] = 0; // get incompatible length u16 incompatibleLength = 0; @@ -211,7 +210,7 @@ void network_receive_mod_list_entry(struct Packet* p) { // get incompatible if (incompatibleLength > 0) { - char incompatible[MOD_INCOMPATIBLE_MAX_LENGTH + 1] = { 0 }; + char incompatible[MOD_INCOMPATIBLE_SIZE] = { 0 }; packet_read(p, incompatible, incompatibleLength * sizeof(u8)); mod->incompatible = strdup(incompatible); } else { diff --git a/src/pc/network/packets/packet_object.c b/src/pc/network/packets/packet_object.c index 7cdb6c460..f6f1b7bbe 100644 --- a/src/pc/network/packets/packet_object.c +++ b/src/pc/network/packets/packet_object.c @@ -220,7 +220,7 @@ static void packet_write_object_extra_fields(struct Packet* p, struct Object* o) // write the extra field for (u8 i = 0; i < so->extraFieldCount; i++) { SOFT_ASSERT(so->extraFields[i] != NULL); - packet_write(p, so->extraFields[i], so->extraFieldsSize[i] / 8); + packet_write(p, so->extraFields[i], so->extraFieldsSizeBytes[i]); } } @@ -240,7 +240,7 @@ static void packet_read_object_extra_fields(struct Packet* p, struct Object* o) // read the extra fields for (u8 i = 0; i < extraFieldsCount; i++) { SOFT_ASSERT(so->extraFields[i] != NULL); - packet_read(p, so->extraFields[i], so->extraFieldsSize[i] / 8); + packet_read(p, so->extraFields[i], so->extraFieldsSizeBytes[i]); } } diff --git a/src/pc/network/sync_object.c b/src/pc/network/sync_object.c index 74e0fd48b..25d6505f9 100644 --- a/src/pc/network/sync_object.c +++ b/src/pc/network/sync_object.c @@ -182,8 +182,8 @@ struct SyncObject* sync_object_init(struct Object *o, float maxSyncDistance) { so->extendedModelId = 0xFFFF; } so->randomSeed = (u16)(o->oSyncID * 7951); - memset(so->extraFields, 0, sizeof(void*) * MAX_SYNC_OBJECT_FIELDS); - memset(so->extraFieldsSize, 0, sizeof(u8) * MAX_SYNC_OBJECT_FIELDS); + memset(so->extraFields, 0, sizeof(so->extraFields)); + memset(so->extraFieldsSizeBytes, 0, sizeof(so->extraFieldsSizeBytes)); so->lastReliablePacket.error = true; o->coopFlags |= COOP_OBJ_FLAG_INITIALIZED; @@ -191,10 +191,12 @@ struct SyncObject* sync_object_init(struct Object *o, float maxSyncDistance) { return so; } -void sync_object_init_field(struct Object *o, void* field) { +void sync_object_init_field_with_size(struct Object *o, void *field, u8 sizeBytes) { if (o->coopFlags & COOP_OBJ_FLAG_NON_SYNC) { return; } if (o->oSyncID == 0) { return; } + SOFT_ASSERT(sizeBytes > 0); + // remember to synchronize this extra field struct SyncObject* so = sync_object_get(o->oSyncID); if (!so) { return; } @@ -205,26 +207,7 @@ void sync_object_init_field(struct Object *o, void* field) { return; } so->extraFields[index] = field; - so->extraFieldsSize[index] = 32; -} - -void sync_object_init_field_with_size(struct Object *o, void* field, u8 size) { - if (o->coopFlags & COOP_OBJ_FLAG_NON_SYNC) { return; } - if (o->oSyncID == 0) { return; } - - SOFT_ASSERT(size == 8 || size == 16 || size == 32 || size == 64); - - // remember to synchronize this extra field - struct SyncObject* so = sync_object_get(o->oSyncID); - if (!so) { return; } - u32 index = so->extraFieldCount++; - if (so->extraFieldCount >= MAX_SYNC_OBJECT_FIELDS) { - so->extraFieldCount = MAX_SYNC_OBJECT_FIELDS - 1; - LOG_ERROR("Sync Object %u tried to set too many extra fields!", o->oSyncID); - return; - } - so->extraFields[index] = field; - so->extraFieldsSize[index] = size; + so->extraFieldsSizeBytes[index] = sizeBytes; } ///////////// diff --git a/src/pc/network/sync_object.h b/src/pc/network/sync_object.h index 203aa9da6..203f62134 100644 --- a/src/pc/network/sync_object.h +++ b/src/pc/network/sync_object.h @@ -30,7 +30,7 @@ struct SyncObject { void (*override_ownership)(u8* shouldOverride, u8* shouldOwn); void (*on_forget)(void); void* extraFields[MAX_SYNC_OBJECT_FIELDS]; - u8 extraFieldsSize[MAX_SYNC_OBJECT_FIELDS]; + u8 extraFieldsSizeBytes[MAX_SYNC_OBJECT_FIELDS]; bool rememberLastReliablePacket; bool lastReliablePacketIsStale; u16 extendedModelId; @@ -43,14 +43,17 @@ struct SyncObject { //////////// // system // //////////// + void sync_objects_init_system(void); void sync_objects_update(void); void sync_objects_clear(void); void sync_object_forget(u32 syncId); void sync_object_forget_last_reliable_packet(u32 syncId); struct SyncObject* sync_object_init(struct Object *o, float maxSyncDistance); -void sync_object_init_field(struct Object *o, void* field); -void sync_object_init_field_with_size(struct Object *o, void* field, u8 size); +void sync_object_init_field_with_size(struct Object *o, void *field, u8 sizeBytes); + +#define sync_object_init_field(o, field) \ + sync_object_init_field_with_size(o, &field, sizeof(field)) ///////////// // getters // diff --git a/src/pc/network/version.h b/src/pc/network/version.h index 473e8fec5..9bda5050c 100644 --- a/src/pc/network/version.h +++ b/src/pc/network/version.h @@ -1,7 +1,7 @@ #ifndef VERSION_H #define VERSION_H -#define SM64COOPDX_VERSION "v1.4.1" +#define SM64COOPDX_VERSION "v1.4.2" // internal version #define VERSION_TEXT "v" diff --git a/src/pc/platform.c b/src/pc/platform.c index 331a7c075..185b85bd9 100644 --- a/src/pc/platform.c +++ b/src/pc/platform.c @@ -411,4 +411,12 @@ static void sys_fatal_impl(const char *msg) { exit(1); } +const char *sys_resource_path(void) { + return "."; +} + +const char *sys_exe_path_dir(void) { + return "."; +} + #endif // platform switch diff --git a/src/pc/utils/misc.c b/src/pc/utils/misc.c index 34e70241a..e358b942d 100644 --- a/src/pc/utils/misc.c +++ b/src/pc/utils/misc.c @@ -594,18 +594,3 @@ void str_seperator_concat(char *output_buffer, int buffer_size, char** strings, } } } - -char *str_remove_color_codes(const char *str) { - char *output = strdup(str); - char *startColor; - while ((startColor = strstr(output, "\\#"))) { - char *endColor = strchr(startColor + 2, '\\'); - if (endColor) { - memmove(startColor, endColor + 1, strlen(endColor + 1) + 1); - } else { - *startColor = 0; - break; - } - } - return output; -} diff --git a/src/pc/utils/misc.h b/src/pc/utils/misc.h index 0efabc869..01d813fa1 100644 --- a/src/pc/utils/misc.h +++ b/src/pc/utils/misc.h @@ -37,6 +37,5 @@ void delta_interpolate_mtx(Mtx* out, Mtx* a, Mtx* b, f32 delta); void detect_and_skip_mtx_interpolation(Mtx** mtxPrev, Mtx** mtx); void str_seperator_concat(char *output_buffer, int buffer_size, char** strings, int num_strings, char* seperator); -char *str_remove_color_codes(const char *str); #endif \ No newline at end of file diff --git a/textures/custom_font/custom_font_hud_recolor.rgba32.png b/textures/custom_font/custom_font_hud_recolor.rgba32.png index 1ad909523..3f1bf60be 100644 Binary files a/textures/custom_font/custom_font_hud_recolor.rgba32.png and b/textures/custom_font/custom_font_hud_recolor.rgba32.png differ