mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-11-16 11:37:40 +01:00
Fixed outstanding UB with -fanalyzer on modern
This commit is contained in:
parent
cd5f997ee3
commit
fc8ee625b6
2
Makefile
2
Makefile
@ -118,7 +118,7 @@ LIBPATH := -L ../../tools/agbcc/lib
|
||||
LIB := $(LIBPATH) -lgcc -lc -L../../libagbsyscall -lagbsyscall
|
||||
else
|
||||
CC1 = $(shell $(PATH_MODERNCC) --print-prog-name=cc1) -quiet
|
||||
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
|
||||
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast -std=gnu17 -fanalyzer
|
||||
ROM := $(MODERN_ROM_NAME)
|
||||
OBJ_DIR := $(MODERN_OBJ_DIR_NAME)
|
||||
LIBPATH := -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libnosys.a))" -L "$(dir $(shell $(PATH_MODERNCC) -mthumb -print-file-name=libc.a))"
|
||||
|
@ -67,7 +67,7 @@ void LoadObjEventTemplatesFromHeader(void);
|
||||
void LoadSaveblockObjEventScripts(void);
|
||||
void SetObjEventTemplateCoords(u8 localId, s16 x, s16 y);
|
||||
void SetObjEventTemplateMovementType(u8 localId, u8 movementType);
|
||||
const struct MapLayout *GetMapLayout(void);
|
||||
const struct MapLayout *GetMapLayout(u16 mapLayoutId);
|
||||
void ApplyCurrentWarp(void);
|
||||
struct MapHeader const *const Overworld_GetMapHeaderByGroupAndId(u16 mapGroup, u16 mapNum);
|
||||
struct MapHeader const *const GetDestinationWarpMapHeader(void);
|
||||
|
@ -1210,8 +1210,11 @@ void AllocateMonSpritesGfx(void)
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
gMonSpritesGfxPtr->frameImages[i][j].data = gMonSpritesGfxPtr->sprites.ptr[i] + (j * MON_PIC_SIZE);
|
||||
gMonSpritesGfxPtr->frameImages[i][j].size = MON_PIC_SIZE;
|
||||
if (gMonSpritesGfxPtr->sprites.ptr[i] + (j * MON_PIC_SIZE))
|
||||
{
|
||||
gMonSpritesGfxPtr->frameImages[i][j].data = gMonSpritesGfxPtr->sprites.ptr[i] + (j * MON_PIC_SIZE);
|
||||
gMonSpritesGfxPtr->frameImages[i][j].size = MON_PIC_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
gMonSpritesGfxPtr->templates[i].images = gMonSpritesGfxPtr->frameImages[i];
|
||||
|
@ -621,8 +621,8 @@ bool32 CanCameraMoveInDirection(int direction)
|
||||
|
||||
static void SetPositionFromConnection(const struct MapConnection *connection, int direction, int x, int y)
|
||||
{
|
||||
struct MapHeader const *mapHeader;
|
||||
mapHeader = GetMapHeaderFromConnection(connection);
|
||||
struct MapHeader const *mapHeader = GetMapHeaderFromConnection(connection);
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case CONNECTION_EAST:
|
||||
@ -641,6 +641,9 @@ static void SetPositionFromConnection(const struct MapConnection *connection, in
|
||||
gSaveBlock1Ptr->pos.x -= connection->offset;
|
||||
gSaveBlock1Ptr->pos.y = mapHeader->mapLayout->height;
|
||||
break;
|
||||
default:
|
||||
DebugPrintfLevel(MGBA_LOG_WARN, "SetPositionFromConnection was passed an invalid direction (%d)!", direction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -663,14 +666,20 @@ bool8 CameraMove(int x, int y)
|
||||
old_x = gSaveBlock1Ptr->pos.x;
|
||||
old_y = gSaveBlock1Ptr->pos.y;
|
||||
connection = GetIncomingConnection(direction, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y);
|
||||
SetPositionFromConnection(connection, direction, x, y);
|
||||
LoadMapFromCameraTransition(connection->mapGroup, connection->mapNum);
|
||||
gCamera.active = TRUE;
|
||||
gCamera.x = old_x - gSaveBlock1Ptr->pos.x;
|
||||
gCamera.y = old_y - gSaveBlock1Ptr->pos.y;
|
||||
gSaveBlock1Ptr->pos.x += x;
|
||||
gSaveBlock1Ptr->pos.y += y;
|
||||
MoveMapViewToBackup(direction);
|
||||
if (connection)
|
||||
{
|
||||
SetPositionFromConnection(connection, direction, x, y);
|
||||
LoadMapFromCameraTransition(connection->mapGroup, connection->mapNum);
|
||||
gCamera.active = TRUE;
|
||||
gCamera.x = old_x - gSaveBlock1Ptr->pos.x;
|
||||
gCamera.y = old_y - gSaveBlock1Ptr->pos.y;
|
||||
gSaveBlock1Ptr->pos.x += x;
|
||||
gSaveBlock1Ptr->pos.y += y;
|
||||
MoveMapViewToBackup(direction);
|
||||
}
|
||||
else
|
||||
DebugPrintfLevel(MGBA_LOG_WARN, "GetIncomingConnection returned an invalid connection inside CameraMove!");
|
||||
|
||||
}
|
||||
return gCamera.active;
|
||||
}
|
||||
|
@ -556,12 +556,9 @@ static void InitMapView(void)
|
||||
InitTilesetAnimations();
|
||||
}
|
||||
|
||||
const struct MapLayout *GetMapLayout(void)
|
||||
const struct MapLayout *GetMapLayout(u16 mapLayoutId)
|
||||
{
|
||||
u16 mapLayoutId = gSaveBlock1Ptr->mapLayoutId;
|
||||
if (mapLayoutId)
|
||||
return gMapLayouts[mapLayoutId - 1];
|
||||
return NULL;
|
||||
return gMapLayouts[mapLayoutId - 1];
|
||||
}
|
||||
|
||||
void ApplyCurrentWarp(void)
|
||||
@ -618,13 +615,13 @@ static void LoadCurrentMapData(void)
|
||||
sLastMapSectionId = gMapHeader.regionMapSectionId;
|
||||
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
|
||||
gSaveBlock1Ptr->mapLayoutId = gMapHeader.mapLayoutId;
|
||||
gMapHeader.mapLayout = GetMapLayout();
|
||||
gMapHeader.mapLayout = GetMapLayout(gMapHeader.mapLayoutId);
|
||||
}
|
||||
|
||||
static void LoadSaveblockMapHeader(void)
|
||||
{
|
||||
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
|
||||
gMapHeader.mapLayout = GetMapLayout();
|
||||
gMapHeader.mapLayout = GetMapLayout(gMapHeader.mapLayoutId);
|
||||
}
|
||||
|
||||
static void SetPlayerCoordsFromWarp(void)
|
||||
@ -1020,7 +1017,7 @@ u8 GetFlashLevel(void)
|
||||
void SetCurrentMapLayout(u16 mapLayoutId)
|
||||
{
|
||||
gSaveBlock1Ptr->mapLayoutId = mapLayoutId;
|
||||
gMapHeader.mapLayout = GetMapLayout();
|
||||
gMapHeader.mapLayout = GetMapLayout(mapLayoutId);
|
||||
}
|
||||
|
||||
void SetObjectEventLoadFlag(u8 flag)
|
||||
|
1112
src/pokemon.c
1112
src/pokemon.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user