Treat map data as const
This commit is contained in:
+12
-12
@@ -131,9 +131,9 @@ static void SetObjectEventDynamicGraphicsId(struct ObjectEvent *);
|
||||
static void RemoveObjectEventInternal(struct ObjectEvent *);
|
||||
static u16 GetObjectEventFlagIdByObjectEventId(u8);
|
||||
static void UpdateObjectEventVisibility(struct ObjectEvent *, struct Sprite *);
|
||||
static void MakeSpriteTemplateFromObjectEventTemplate(struct ObjectEventTemplate *, struct SpriteTemplate *, const struct SubspriteTable **);
|
||||
static void MakeSpriteTemplateFromObjectEventTemplate(const struct ObjectEventTemplate *, struct SpriteTemplate *, const struct SubspriteTable **);
|
||||
static void GetObjectEventMovingCameraOffset(s16 *, s16 *);
|
||||
static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8);
|
||||
static const struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8);
|
||||
static void LoadObjectEventPalette(u16);
|
||||
static void RemoveObjectEventIfOutsideView(struct ObjectEvent *);
|
||||
static void SpawnObjectEventOnReturnToField(u8, s16, s16);
|
||||
@@ -147,7 +147,7 @@ static void SpriteCB_CameraObject(struct Sprite *);
|
||||
static void CameraObject_0(struct Sprite *);
|
||||
static void CameraObject_1(struct Sprite *);
|
||||
static void CameraObject_2(struct Sprite *);
|
||||
static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8, struct ObjectEventTemplate *, u8);
|
||||
static const struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8, const struct ObjectEventTemplate *, u8);
|
||||
static void ClearObjectEventMovement(struct ObjectEvent *, struct Sprite *);
|
||||
static void ObjectEventSetSingleMovement(struct ObjectEvent *, struct Sprite *, u8);
|
||||
static void SetSpriteDataForNormalStep(struct Sprite *, u8, u8);
|
||||
@@ -1267,7 +1267,7 @@ static u8 GetObjectEventIdByLocalId(u8 localId)
|
||||
return OBJECT_EVENTS_COUNT;
|
||||
}
|
||||
|
||||
static u8 InitObjectEventStateFromTemplate(struct ObjectEventTemplate *template, u8 mapNum, u8 mapGroup)
|
||||
static u8 InitObjectEventStateFromTemplate(const struct ObjectEventTemplate *template, u8 mapNum, u8 mapGroup)
|
||||
{
|
||||
struct ObjectEvent *objectEvent;
|
||||
u8 objectEventId;
|
||||
@@ -1398,7 +1398,7 @@ void RemoveAllObjectEventsExceptPlayer(void)
|
||||
}
|
||||
}
|
||||
|
||||
static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY)
|
||||
static u8 TrySetupObjectEventSprite(const struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY)
|
||||
{
|
||||
u8 spriteId;
|
||||
u8 paletteSlot;
|
||||
@@ -1458,7 +1458,7 @@ static u8 TrySetupObjectEventSprite(struct ObjectEventTemplate *objectEventTempl
|
||||
return objectEventId;
|
||||
}
|
||||
|
||||
static u8 TrySpawnObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY)
|
||||
static u8 TrySpawnObjectEventTemplate(const struct ObjectEventTemplate *objectEventTemplate, u8 mapNum, u8 mapGroup, s16 cameraX, s16 cameraY)
|
||||
{
|
||||
u8 objectEventId;
|
||||
struct SpriteTemplate spriteTemplate;
|
||||
@@ -1512,7 +1512,7 @@ u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 l
|
||||
|
||||
u8 TrySpawnObjectEvent(u8 localId, u8 mapNum, u8 mapGroup)
|
||||
{
|
||||
struct ObjectEventTemplate *objectEventTemplate;
|
||||
const struct ObjectEventTemplate *objectEventTemplate;
|
||||
s16 cameraX, cameraY;
|
||||
|
||||
objectEventTemplate = GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup);
|
||||
@@ -1542,7 +1542,7 @@ static void CopyObjectGraphicsInfoToSpriteTemplate_WithMovementType(u16 graphics
|
||||
CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, sMovementTypeCallbacks[movementType], spriteTemplate, subspriteTables);
|
||||
}
|
||||
|
||||
static void MakeSpriteTemplateFromObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables)
|
||||
static void MakeSpriteTemplateFromObjectEventTemplate(const struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables)
|
||||
{
|
||||
CopyObjectGraphicsInfoToSpriteTemplate_WithMovementType(objectEventTemplate->graphicsId, objectEventTemplate->movementType, spriteTemplate, subspriteTables);
|
||||
}
|
||||
@@ -2374,7 +2374,7 @@ const u8 *GetObjectEventScriptPointerByObjectEventId(u8 objectEventId)
|
||||
|
||||
static u16 GetObjectEventFlagIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
|
||||
{
|
||||
struct ObjectEventTemplate *obj = GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup);
|
||||
const struct ObjectEventTemplate *obj = GetObjectEventTemplateByLocalIdAndMap(localId, mapNum, mapGroup);
|
||||
#ifdef UBFIX
|
||||
// BUG: The function may return NULL, and attempting to read from NULL may freeze the game using modern compilers.
|
||||
if (obj == NULL)
|
||||
@@ -2421,9 +2421,9 @@ u8 GetObjectEventBerryTreeId(u8 objectEventId)
|
||||
return gObjectEvents[objectEventId].trainerRange_berryTreeId;
|
||||
}
|
||||
|
||||
static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
|
||||
static const struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup)
|
||||
{
|
||||
struct ObjectEventTemplate *templates;
|
||||
const struct ObjectEventTemplate *templates;
|
||||
const struct MapHeader *mapHeader;
|
||||
u8 count;
|
||||
|
||||
@@ -2441,7 +2441,7 @@ static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8 loca
|
||||
return FindObjectEventTemplateByLocalId(localId, templates, count);
|
||||
}
|
||||
|
||||
static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId, struct ObjectEventTemplate *templates, u8 count)
|
||||
static const struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId, const struct ObjectEventTemplate *templates, u8 count)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user