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>
This commit is contained in:
Anghelo Carvajal
2023-11-14 08:46:22 -03:00
committed by GitHub
parent 60ddc5891e
commit 3d150f3e1d
14 changed files with 54 additions and 41 deletions
+8 -2
View File
@@ -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));
+12 -12
View File
@@ -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;
}
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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)) {