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 66b02100f..e1549b294 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 0be400b61..5ee259ff2 100644 --- a/autogen/convert_constants.py +++ b/autogen/convert_constants.py @@ -536,6 +536,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 8846db56f..9a9f7d53a 100644 --- a/autogen/convert_functions.py +++ b/autogen/convert_functions.py @@ -951,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) @@ -1342,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/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 44e32d421..840e031e0 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` @@ -8147,7 +8228,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` @@ -8210,6 +8297,12 @@ 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 @@ -11194,7 +11287,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 7f10487d2..0be2b8ee4 100644 --- a/autogen/lua_definitions/functions.lua +++ b/autogen/lua_definitions/functions.lua @@ -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() @@ -10183,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) @@ -11647,6 +11678,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) 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 c971ce2ff..5441e7424 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/docs/lua/constants.md b/docs/lua/constants.md index 6c5400f60..848b915fa 100644 --- a/docs/lua/constants.md +++ b/docs/lua/constants.md @@ -1151,6 +1151,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 | @@ -1169,6 +1181,7 @@ ### [enum DjuiFontType](#DjuiFontType) | Identifier | Value | | :--------- | :---- | +| FONT_LEGACY | -1 | | FONT_NORMAL | 0 | | FONT_MENU | 1 | | FONT_HUD | 2 | @@ -3545,7 +3558,13 @@ | 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 7b1704e71..8e4f8c230 100644 --- a/docs/lua/functions-3.md +++ b/docs/lua/functions-3.md @@ -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 6c8cb8c8b..4bd956272 100644 --- a/docs/lua/functions-4.md +++ b/docs/lua/functions-4.md @@ -5134,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 6985067f9..bb7099730 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 207edbb6f..1dd27c2d7 100644 --- a/docs/lua/functions-7.md +++ b/docs/lua/functions-7.md @@ -2107,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 diff --git a/docs/lua/functions.md b/docs/lua/functions.md index 8eb9ca8d8..d9c5f28e0 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) @@ -1825,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) @@ -2072,6 +2076,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) 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 f189b286d..79c6d19ff 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/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 index 5ad7d0303..730e6a916 100644 Binary files a/mods/sm74/actors/mad_toad_geo.bin and b/mods/sm74/actors/mad_toad_geo.bin 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/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/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 bd6218775..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; 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/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_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/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/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..95dafbed1 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,10 +190,11 @@ 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]; } // remember buttons that changed from 0 to 1 last_mouse = (mouse_prev ^ mouse) & mouse; @@ -282,7 +283,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 5d7a06d5b..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.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.001f; - 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; @@ -510,6 +695,7 @@ static void djui_hud_render_texture_raw(const Texture* texture, u32 width, u32 h 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,25 +706,27 @@ 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.001f; @@ -546,6 +734,7 @@ static void djui_hud_render_texture_tile_raw(const Texture* texture, u32 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) { +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/lua/smlua_cobject.c b/src/pc/lua/smlua_cobject.c index 104c02074..83f3e1542 100644 --- a/src/pc/lua/smlua_cobject.c +++ b/src/pc/lua/smlua_cobject.c @@ -343,8 +343,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 e2cbf87ea..35a3ce52d 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, 1, sizeof(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, 1, sizeof(f32) }, - { "pivotY", LVT_F32, offsetof(struct HudUtilsRotation, pivotY), false, LOT_NONE, 1, sizeof(f32) }, - { "prevPivotX", LVT_F32, offsetof(struct HudUtilsRotation, prevPivotX), false, LOT_NONE, 1, sizeof(f32) }, - { "prevPivotY", LVT_F32, offsetof(struct HudUtilsRotation, prevPivotY), false, LOT_NONE, 1, sizeof(f32) }, - { "rotation", LVT_F32, offsetof(struct HudUtilsRotation, rotation), false, LOT_NONE, 1, sizeof(f32) }, - { "rotationDiff", LVT_F32, offsetof(struct HudUtilsRotation, rotationDiff), false, LOT_NONE, 1, sizeof(f32) }, -}; - #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, 1, sizeof(u8) }, @@ -1484,7 +1474,7 @@ static struct LuaObjectField sModFields[LUA_MOD_FIELD_COUNT] = { { "incompatible", LVT_STRING_P, offsetof(struct Mod, incompatible), true, LOT_NONE, 1, sizeof(char*) }, { "index", LVT_S32, offsetof(struct Mod, index), true, LOT_NONE, 1, sizeof(s32) }, { "isDirectory", LVT_BOOL, offsetof(struct Mod, isDirectory), true, LOT_NONE, 1, sizeof(bool) }, - { "name", LVT_STRING_P, offsetof(struct Mod, name), true, LOT_NONE, 1, sizeof(char*) }, + { "name", LVT_STRING, offsetof(struct Mod, name), true, LOT_NONE, 1, sizeof(char) }, { "pausable", LVT_BOOL, offsetof(struct Mod, pausable), true, LOT_NONE, 1, sizeof(bool) }, { "relativePath", LVT_STRING, offsetof(struct Mod, relativePath), true, LOT_NONE, 1, sizeof(char) }, { "renderBehindHud", LVT_BOOL, offsetof(struct Mod, renderBehindHud), true, LOT_NONE, 1, sizeof(bool) }, @@ -2734,7 +2724,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 }, @@ -2840,7 +2829,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 1f75d03c1..5e48e92aa 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" @@ -3501,7 +3556,13 @@ 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" @@ -4635,7 +4696,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 1c8c14b97..ecfc612a8 100644 --- a/src/pc/lua/smlua_functions_autogen.c +++ b/src/pc/lua/smlua_functions_autogen.c @@ -12318,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); @@ -12328,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) { @@ -12363,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; } @@ -12381,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; } @@ -30353,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; } @@ -34300,6 +34386,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; } @@ -37459,6 +37567,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); @@ -38444,6 +38555,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); @@ -38685,6 +38797,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); 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_hooks.c b/src/pc/lua/smlua_hooks.c index 9bfc6dceb..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 // //////////////////// @@ -952,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, "]"); diff --git a/src/pc/lua/smlua_hooks.h b/src/pc/lua/smlua_hooks.h index a857bbad3..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, }; diff --git a/src/pc/lua/utils/smlua_audio_utils.c b/src/pc/lua/utils/smlua_audio_utils.c index 80aeca7fc..9b02de52e 100644 --- a/src/pc/lua/utils/smlua_audio_utils.c +++ b/src/pc/lua/utils/smlua_audio_utils.c @@ -173,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 deca8b0d0..93696c80d 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 de447b3d1..9e90a45fb 100644 --- a/src/pc/lua/utils/smlua_misc_utils.c +++ b/src/pc/lua/utils/smlua_misc_utils.c @@ -607,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) { diff --git a/src/pc/lua/utils/smlua_misc_utils.h b/src/pc/lua/utils/smlua_misc_utils.h index e4bb3c1eb..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 }; @@ -246,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); 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/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/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