Allocation fixes

This commit is contained in:
Fazana
2021-09-08 14:54:02 +01:00
parent 00f2afa279
commit f224f845d2
4 changed files with 13 additions and 1 deletions

View File

@@ -1128,6 +1128,10 @@ s32 play_mode_change_area(void) {
set_play_mode(PLAY_MODE_NORMAL);
}
#ifdef PUPPYLIGHTS
puppylights_allocate();
#endif
return 0;
}

View File

@@ -26,6 +26,7 @@
#include "rendering_graph_node.h"
#include "spawn_object.h"
#include "spawn_sound.h"
#include "puppylights.h"
static s8 sBbhStairJiggleOffsets[] = { -8, 8, -4, 4 };
static s16 sPowersOfTwo[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 };
@@ -1057,7 +1058,7 @@ void cur_obj_set_y_vel_and_animation(f32 yVel, s32 animIndex) {
void cur_obj_unrender_set_action_and_anim(s32 animIndex, s32 action) {
cur_obj_become_intangible();
cur_obj_disable_rendering();
// only set animation if non-negative value
if (animIndex >= 0) {
cur_obj_init_animation_with_sound(animIndex);
@@ -1139,6 +1140,7 @@ void obj_mark_for_deletion(struct Object *obj) {
// setting it to 0 could potentially enable unexpected behavior. After an
// object is marked for deletion, it still updates on that frame (I think),
// so this is worth looking into.
obj_disable_light(obj);
obj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}

View File

@@ -300,6 +300,8 @@ void cur_obj_enable_light(void)
void cur_obj_disable_light(void)
{
gCurrentObject->oFlags &= ~OBJ_FLAG_EMIT_LIGHT;
if (gPuppyLights[gCurrentObject->oLightID] && gCurrentObject->oLightID != 0xFFFF)
gPuppyLights[gCurrentObject->oLightID]->active = FALSE;
}
void obj_enable_light(struct Object *obj)
@@ -310,6 +312,8 @@ void obj_enable_light(struct Object *obj)
void obj_disable_light(struct Object *obj)
{
obj->oFlags &= ~OBJ_FLAG_EMIT_LIGHT;
if (gPuppyLights[obj->oLightID] && obj->oLightID != 0xFFFF)
gPuppyLights[obj->oLightID]->active = FALSE;
}
#endif

View File

@@ -12,6 +12,7 @@
#include "object_list_processor.h"
#include "spawn_object.h"
#include "types.h"
#include "puppylights.h"
/**
* An unused linked list struct that seems to have been replaced by ObjectNode.
@@ -356,5 +357,6 @@ struct Object *create_object(const BehaviorScript *bhvScript) {
*/
void mark_obj_for_deletion(struct Object *obj) {
//! Same issue as obj_mark_for_deletion
obj_disable_light(obj);
obj->activeFlags = ACTIVE_FLAG_DEACTIVATED;
}