diff options
| author | Anghelo Carvajal <angheloalf95@gmail.com> | 2023-11-14 08:46:22 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-14 22:46:22 +1100 |
| commit | 3d150f3e1d84259b05f2831be35fa6fd38e43232 (patch) | |
| tree | e737c09137a04cdac7b15d0e190d6ca3b3fd0503 /src/code | |
| parent | 60ddc5891e1cdef2e32f695c96e60344d7a51c26 (diff) | |
Misc fixes 1 (#1491)
* Some low-hanging UB
* document bug on z_file_nameset_NES.c
* ALIGNED on audio data
* document bug on decode
* document bugs on Message_Decode
* Format
* More ALIGNED
* Put the ALIGNED macro at the right like the other uses in the repo
* review
* fix Message Decode
(cherry picked from commit abfbc7068816756f7ea3fa4a36ee0fe664c54c72)
Co-authored-by: engineer124 <engineer124engineer124@gmail.com>
* remove comments
* Update src/overlays/gamestates/ovl_file_choose/z_file_choose_NES.c
Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
* format
---------
Co-authored-by: engineer124 <engineer124engineer124@gmail.com>
Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
Diffstat (limited to 'src/code')
| -rw-r--r-- | src/code/z_common_data.c | 10 | ||||
| -rw-r--r-- | src/code/z_message.c | 24 | ||||
| -rw-r--r-- | src/code/z_parameter.c | 2 | ||||
| -rw-r--r-- | src/code/z_player_lib.c | 2 |
4 files changed, 22 insertions, 16 deletions
diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index f0805c46b..e6d291831 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -1,6 +1,12 @@ -#include "global.h" +#include "z64save.h" -SaveContext gSaveContext; +#include "alignment.h" +#include "sequence.h" +#include "libc/stdbool.h" +#include "z64environment.h" +#include "z64transition.h" + +SaveContext gSaveContext ALIGNED(16); void SaveContext_Init(void) { bzero(&gSaveContext, sizeof(SaveContext)); diff --git a/src/code/z_message.c b/src/code/z_message.c index f3bf144a6..2044077db 100644 --- a/src/code/z_message.c +++ b/src/code/z_message.c @@ -1921,7 +1921,7 @@ void func_8014CCB4(PlayState* play, s16* decodedBufPos, s32* offset, f32* arg3) * every digit will be added 0x824F to get an actual S-JIS * printable character. */ -void Message_GetTimerDigits(OSTime time, s16* digits) { +void Message_GetTimerDigits(OSTime time, s16 digits[8]) { OSTime t = time; // 6 minutes @@ -2160,20 +2160,20 @@ void Message_Decode(PlayState* play) { u32 timeToMoonCrash; s16 var_v0; s16 numLines; - u8* fontBuf; - s16 digits[4]; + s16 value; + s16 digits[5]; s16 spD2; f32 timeInSeconds; s32 charTexIndex; - f32 var_fs0; + u8* fontBuf; f32 spC0; s16 index; - s16 value; s16 playerNameLen; + s16 spAC[8]; + f32 var_fs0; s16 i; - u16 index2 = 0; - s16 spAC[4]; u16 curChar; + u8 index2 = 0; msgCtx->textDelayTimer = 0; msgCtx->textDelay = msgCtx->textDelayTimer; @@ -2212,7 +2212,7 @@ void Message_Decode(PlayState* play) { } } } else { - s32 requiredScopeTemp; + s8 requiredScopeTemp; if ((msgCtx->textBoxType != TEXTBOX_TYPE_3) && (msgCtx->textBoxType != TEXTBOX_TYPE_4)) { if (numLines == 0) { @@ -2289,7 +2289,7 @@ void Message_Decode(PlayState* play) { Message_GetTimerDigits(((void)0, gSaveContext.timerCurTimes[curChar - 0x204]), spAC); loadChar = false; - for (i = 0; i < 5; i++) { + for (i = 0; i < ARRAY_COUNT(spAC) - 3; i++) { if ((i == 1) || (spAC[i + 3] != 0)) { loadChar = true; } @@ -2304,7 +2304,7 @@ void Message_Decode(PlayState* play) { Message_GetTimerDigits(((void)0, gSaveContext.timerCurTimes[curChar - 0x204]), spAC); loadChar = false; - for (i = 0; i < 8; i++) { + for (i = 0; i < ARRAY_COUNT(spAC); i++) { if ((i == 4) || ((i != 2) && (i != 5) && (spAC[i] != '\0'))) { loadChar = true; } @@ -2722,7 +2722,7 @@ void Message_Decode(PlayState* play) { } func_8014CCB4(play, &decodedBufPos, &charTexIndex, &spC0); } else if (curChar == 0x22F) { - for (i = 0; i < 5; i++) { + for (i = 0; i < ARRAY_COUNT(gSaveContext.save.saveInfo.bomberCode); i++) { digits[i] = gSaveContext.save.saveInfo.bomberCode[i]; Font_LoadChar(play, digits[i] + 0x824F, charTexIndex); charTexIndex += FONT_CHAR_TEX_SIZE; @@ -2827,7 +2827,7 @@ void Message_Decode(PlayState* play) { } loadChar = false; - for (i = 0; i < 8; i++) { + for (i = 0; i < ARRAY_COUNT(spAC); i++) { if ((i == 4) || ((i != 2) && (i != 5) && (spAC[i] != '\0'))) { loadChar = true; } diff --git a/src/code/z_parameter.c b/src/code/z_parameter.c index cf3b93b7d..cf7fbd1e3 100644 --- a/src/code/z_parameter.c +++ b/src/code/z_parameter.c @@ -5441,7 +5441,7 @@ void Interface_StartMoonCrash(PlayState* play) { play->transitionType = TRANS_TYPE_FADE_WHITE; } -void Interface_GetTimerDigits(OSTime time, s16* timerArr) { +void Interface_GetTimerDigits(OSTime time, s16 timerArr[8]) { OSTime t = time; // 6 minutes diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 749096a06..6d056dd58 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -2036,7 +2036,7 @@ s32 Player_OverrideLimbDrawGameplayCommon(PlayState* play, s32 limbIndex, Gfx** // Note: The increment would not be done for the root limb, even if it had a non-NULL `dList`. // So if the root limb had a non-NULL `dList` (which is not the case in vanilla), // an out-of-bounds write to `bodyPartsPos` would occur. - sPlayerCurBodyPartPos = &player->bodyPartsPos[-1]; + sPlayerCurBodyPartPos = &player->bodyPartsPos[0] - 1; if (player->transformation != PLAYER_FORM_FIERCE_DEITY) { if (!(player->skelAnime.moveFlags & ANIM_FLAG_4) || (player->skelAnime.moveFlags & ANIM_FLAG_1)) { |
