Uninline characterSelectorWindowFatalError

This commit is contained in:
Alexander Batalov 2022-09-24 10:28:30 +03:00
parent 9bb053b3ba
commit 79c396c1a0
1 changed files with 33 additions and 29 deletions

View File

@ -83,6 +83,7 @@ static bool characterSelectorWindowRefresh();
static bool characterSelectorWindowRenderFace(); static bool characterSelectorWindowRenderFace();
static bool characterSelectorWindowRenderStats(); static bool characterSelectorWindowRenderStats();
static bool characterSelectorWindowRenderBio(); static bool characterSelectorWindowRenderBio();
static bool characterSelectorWindowFatalError(bool result);
static void premadeCharactersLocalizePath(char* path); static void premadeCharactersLocalizePath(char* path);
@ -318,19 +319,19 @@ static bool characterSelectorWindowInit()
int characterSelectorWindowY = (screenGetHeight() - CS_WINDOW_HEIGHT) / 2; int characterSelectorWindowY = (screenGetHeight() - CS_WINDOW_HEIGHT) / 2;
gCharacterSelectorWindow = windowCreate(characterSelectorWindowX, characterSelectorWindowY, CS_WINDOW_WIDTH, CS_WINDOW_HEIGHT, _colorTable[0], 0); gCharacterSelectorWindow = windowCreate(characterSelectorWindowX, characterSelectorWindowY, CS_WINDOW_WIDTH, CS_WINDOW_HEIGHT, _colorTable[0], 0);
if (gCharacterSelectorWindow == -1) { if (gCharacterSelectorWindow == -1) {
goto err; return characterSelectorWindowFatalError(false);
} }
gCharacterSelectorWindowBuffer = windowGetBuffer(gCharacterSelectorWindow); gCharacterSelectorWindowBuffer = windowGetBuffer(gCharacterSelectorWindow);
if (gCharacterSelectorWindowBuffer == NULL) { if (gCharacterSelectorWindowBuffer == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
CacheEntry* backgroundFrmHandle; CacheEntry* backgroundFrmHandle;
backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 174, 0, 0, 0); backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 174, 0, 0, 0);
backgroundFrmData = artLockFrameData(backgroundFid, 0, 0, &backgroundFrmHandle); backgroundFrmData = artLockFrameData(backgroundFid, 0, 0, &backgroundFrmHandle);
if (backgroundFrmData == NULL) { if (backgroundFrmData == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
blitBufferToBuffer(backgroundFrmData, blitBufferToBuffer(backgroundFrmData,
@ -342,7 +343,7 @@ static bool characterSelectorWindowInit()
gCharacterSelectorBackground = (unsigned char*)internal_malloc(CS_WINDOW_BACKGROUND_WIDTH * CS_WINDOW_BACKGROUND_HEIGHT); gCharacterSelectorBackground = (unsigned char*)internal_malloc(CS_WINDOW_BACKGROUND_WIDTH * CS_WINDOW_BACKGROUND_HEIGHT);
if (gCharacterSelectorBackground == NULL) if (gCharacterSelectorBackground == NULL)
goto err; return characterSelectorWindowFatalError(false);
blitBufferToBuffer(backgroundFrmData + CS_WINDOW_WIDTH * CS_WINDOW_BACKGROUND_Y + CS_WINDOW_BACKGROUND_X, blitBufferToBuffer(backgroundFrmData + CS_WINDOW_WIDTH * CS_WINDOW_BACKGROUND_Y + CS_WINDOW_BACKGROUND_X,
CS_WINDOW_BACKGROUND_WIDTH, CS_WINDOW_BACKGROUND_WIDTH,
@ -359,13 +360,13 @@ static bool characterSelectorWindowInit()
fid = buildFid(OBJ_TYPE_INTERFACE, 122, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 122, 0, 0, 0);
gCharacterSelectorWindowPreviousButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowPreviousButtonUpFrmHandle); gCharacterSelectorWindowPreviousButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowPreviousButtonUpFrmHandle);
if (gCharacterSelectorWindowPreviousButtonUpFrmData == NULL) { if (gCharacterSelectorWindowPreviousButtonUpFrmData == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
fid = buildFid(OBJ_TYPE_INTERFACE, 123, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 123, 0, 0, 0);
gCharacterSelectorWindowPreviousButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowPreviousButtonDownFrmHandle); gCharacterSelectorWindowPreviousButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowPreviousButtonDownFrmHandle);
if (gCharacterSelectorWindowPreviousButtonDownFrmData == NULL) { if (gCharacterSelectorWindowPreviousButtonDownFrmData == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
gCharacterSelectorWindowPreviousButton = buttonCreate(gCharacterSelectorWindow, gCharacterSelectorWindowPreviousButton = buttonCreate(gCharacterSelectorWindow,
@ -382,7 +383,7 @@ static bool characterSelectorWindowInit()
NULL, NULL,
0); 0);
if (gCharacterSelectorWindowPreviousButton == -1) { if (gCharacterSelectorWindowPreviousButton == -1) {
goto err; return characterSelectorWindowFatalError(false);
} }
buttonSetCallbacks(gCharacterSelectorWindowPreviousButton, _gsound_med_butt_press, _gsound_med_butt_release); buttonSetCallbacks(gCharacterSelectorWindowPreviousButton, _gsound_med_butt_press, _gsound_med_butt_release);
@ -391,13 +392,13 @@ static bool characterSelectorWindowInit()
fid = buildFid(OBJ_TYPE_INTERFACE, 124, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 124, 0, 0, 0);
gCharacterSelectorWindowNextButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowNextButtonUpFrmHandle); gCharacterSelectorWindowNextButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowNextButtonUpFrmHandle);
if (gCharacterSelectorWindowNextButtonUpFrmData == NULL) { if (gCharacterSelectorWindowNextButtonUpFrmData == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
fid = buildFid(OBJ_TYPE_INTERFACE, 125, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 125, 0, 0, 0);
gCharacterSelectorWindowNextButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowNextButtonDownFrmHandle); gCharacterSelectorWindowNextButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowNextButtonDownFrmHandle);
if (gCharacterSelectorWindowNextButtonDownFrmData == NULL) { if (gCharacterSelectorWindowNextButtonDownFrmData == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
gCharacterSelectorWindowNextButton = buttonCreate(gCharacterSelectorWindow, gCharacterSelectorWindowNextButton = buttonCreate(gCharacterSelectorWindow,
@ -414,7 +415,7 @@ static bool characterSelectorWindowInit()
NULL, NULL,
0); 0);
if (gCharacterSelectorWindowNextButton == -1) { if (gCharacterSelectorWindowNextButton == -1) {
goto err; return characterSelectorWindowFatalError(false);
} }
buttonSetCallbacks(gCharacterSelectorWindowNextButton, _gsound_med_butt_press, _gsound_med_butt_release); buttonSetCallbacks(gCharacterSelectorWindowNextButton, _gsound_med_butt_press, _gsound_med_butt_release);
@ -423,13 +424,13 @@ static bool characterSelectorWindowInit()
fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0);
gCharacterSelectorWindowTakeButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowTakeButtonUpFrmHandle); gCharacterSelectorWindowTakeButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowTakeButtonUpFrmHandle);
if (gCharacterSelectorWindowTakeButtonUpFrmData == NULL) { if (gCharacterSelectorWindowTakeButtonUpFrmData == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0);
gCharacterSelectorWindowTakeButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowTakeButtonDownFrmHandle); gCharacterSelectorWindowTakeButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowTakeButtonDownFrmHandle);
if (gCharacterSelectorWindowTakeButtonDownFrmData == NULL) { if (gCharacterSelectorWindowTakeButtonDownFrmData == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
gCharacterSelectorWindowTakeButton = buttonCreate(gCharacterSelectorWindow, gCharacterSelectorWindowTakeButton = buttonCreate(gCharacterSelectorWindow,
@ -446,7 +447,7 @@ static bool characterSelectorWindowInit()
NULL, NULL,
BUTTON_FLAG_TRANSPARENT); BUTTON_FLAG_TRANSPARENT);
if (gCharacterSelectorWindowTakeButton == -1) { if (gCharacterSelectorWindowTakeButton == -1) {
goto err; return characterSelectorWindowFatalError(false);
} }
buttonSetCallbacks(gCharacterSelectorWindowTakeButton, _gsound_red_butt_press, _gsound_red_butt_release); buttonSetCallbacks(gCharacterSelectorWindowTakeButton, _gsound_red_butt_press, _gsound_red_butt_release);
@ -455,12 +456,12 @@ static bool characterSelectorWindowInit()
fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0);
gCharacterSelectorWindowModifyButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowModifyButtonUpFrmHandle); gCharacterSelectorWindowModifyButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowModifyButtonUpFrmHandle);
if (gCharacterSelectorWindowModifyButtonUpFrmData == NULL) if (gCharacterSelectorWindowModifyButtonUpFrmData == NULL)
goto err; return characterSelectorWindowFatalError(false);
fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0);
gCharacterSelectorWindowModifyButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowModifyButtonDownFrmHandle); gCharacterSelectorWindowModifyButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowModifyButtonDownFrmHandle);
if (gCharacterSelectorWindowModifyButtonDownFrmData == NULL) { if (gCharacterSelectorWindowModifyButtonDownFrmData == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
gCharacterSelectorWindowModifyButton = buttonCreate(gCharacterSelectorWindow, gCharacterSelectorWindowModifyButton = buttonCreate(gCharacterSelectorWindow,
@ -477,7 +478,7 @@ static bool characterSelectorWindowInit()
NULL, NULL,
BUTTON_FLAG_TRANSPARENT); BUTTON_FLAG_TRANSPARENT);
if (gCharacterSelectorWindowModifyButton == -1) { if (gCharacterSelectorWindowModifyButton == -1) {
goto err; return characterSelectorWindowFatalError(false);
} }
buttonSetCallbacks(gCharacterSelectorWindowModifyButton, _gsound_red_butt_press, _gsound_red_butt_release); buttonSetCallbacks(gCharacterSelectorWindowModifyButton, _gsound_red_butt_press, _gsound_red_butt_release);
@ -486,13 +487,13 @@ static bool characterSelectorWindowInit()
fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0);
gCharacterSelectorWindowCreateButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowCreateButtonUpFrmHandle); gCharacterSelectorWindowCreateButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowCreateButtonUpFrmHandle);
if (gCharacterSelectorWindowCreateButtonUpFrmData == NULL) { if (gCharacterSelectorWindowCreateButtonUpFrmData == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0);
gCharacterSelectorWindowCreateButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowCreateButtonDownFrmHandle); gCharacterSelectorWindowCreateButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowCreateButtonDownFrmHandle);
if (gCharacterSelectorWindowCreateButtonDownFrmData == NULL) { if (gCharacterSelectorWindowCreateButtonDownFrmData == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
gCharacterSelectorWindowCreateButton = buttonCreate(gCharacterSelectorWindow, gCharacterSelectorWindowCreateButton = buttonCreate(gCharacterSelectorWindow,
@ -509,7 +510,7 @@ static bool characterSelectorWindowInit()
NULL, NULL,
BUTTON_FLAG_TRANSPARENT); BUTTON_FLAG_TRANSPARENT);
if (gCharacterSelectorWindowCreateButton == -1) { if (gCharacterSelectorWindowCreateButton == -1) {
goto err; return characterSelectorWindowFatalError(false);
} }
buttonSetCallbacks(gCharacterSelectorWindowCreateButton, _gsound_red_butt_press, _gsound_red_butt_release); buttonSetCallbacks(gCharacterSelectorWindowCreateButton, _gsound_red_butt_press, _gsound_red_butt_release);
@ -518,13 +519,13 @@ static bool characterSelectorWindowInit()
fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 8, 0, 0, 0);
gCharacterSelectorWindowBackButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowBackButtonUpFrmHandle); gCharacterSelectorWindowBackButtonUpFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowBackButtonUpFrmHandle);
if (gCharacterSelectorWindowBackButtonUpFrmData == NULL) { if (gCharacterSelectorWindowBackButtonUpFrmData == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0); fid = buildFid(OBJ_TYPE_INTERFACE, 9, 0, 0, 0);
gCharacterSelectorWindowBackButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowBackButtonDownFrmHandle); gCharacterSelectorWindowBackButtonDownFrmData = artLockFrameData(fid, 0, 0, &gCharacterSelectorWindowBackButtonDownFrmHandle);
if (gCharacterSelectorWindowBackButtonDownFrmData == NULL) { if (gCharacterSelectorWindowBackButtonDownFrmData == NULL) {
goto err; return characterSelectorWindowFatalError(false);
} }
gCharacterSelectorWindowBackButton = buttonCreate(gCharacterSelectorWindow, gCharacterSelectorWindowBackButton = buttonCreate(gCharacterSelectorWindow,
@ -541,7 +542,7 @@ static bool characterSelectorWindowInit()
NULL, NULL,
BUTTON_FLAG_TRANSPARENT); BUTTON_FLAG_TRANSPARENT);
if (gCharacterSelectorWindowBackButton == -1) { if (gCharacterSelectorWindowBackButton == -1) {
goto err; return characterSelectorWindowFatalError(false);
} }
buttonSetCallbacks(gCharacterSelectorWindowBackButton, _gsound_red_butt_press, _gsound_red_butt_release); buttonSetCallbacks(gCharacterSelectorWindowBackButton, _gsound_red_butt_press, _gsound_red_butt_release);
@ -551,16 +552,10 @@ static bool characterSelectorWindowInit()
windowRefresh(gCharacterSelectorWindow); windowRefresh(gCharacterSelectorWindow);
if (!characterSelectorWindowRefresh()) { if (!characterSelectorWindowRefresh()) {
goto err; return characterSelectorWindowFatalError(false);
} }
return true; return true;
err:
characterSelectorWindowFree();
return false;
} }
// 0x4A7AD4 // 0x4A7AD4
@ -1015,6 +1010,15 @@ static bool characterSelectorWindowRenderBio()
return true; return true;
} }
// NOTE: Inlined.
//
// 0x4A8BD0
static bool characterSelectorWindowFatalError(bool result)
{
characterSelectorWindowFree();
return result;
}
void premadeCharactersInit() void premadeCharactersInit()
{ {
char* fileNamesString; char* fileNamesString;