diff --git a/include/types.h b/include/types.h index 32aed982..b77762e7 100644 --- a/include/types.h +++ b/include/types.h @@ -151,9 +151,11 @@ struct ObjectNode struct PuppyLight { Vec3t pos[2]; //The location of the light. First index is the absolute position, second index are offsets. s16 yaw; //Used by cubes. Allows epic rotating of the volume. + s16 room; //Which room to use. -1 is visible from all rooms. s8 epicentre; //What percentage inside the volume you'll be before maximum light strength is applied. (E.g: 100 will be full strength always, and 0 will be full strength at the centre.) u8 flags; //Some stuff to define how the volume is used. Mostly just shape stuff, but can potentially have other uses. u8 rgba[4]; //Colour. Go on, take even the tiniest guess as to what this entails. + u8 area; //Which section of the level this light is stored in. u8 active:1; //Whether the light will actually work. Mostly intended to be used for objects. }; #endif diff --git a/src/engine/level_script.c b/src/engine/level_script.c index becb9bf5..c1cbae09 100644 --- a/src/engine/level_script.c +++ b/src/engine/level_script.c @@ -830,6 +830,7 @@ static void level_cmd_puppyvolume(void) sPuppyVolumeStack[gPuppyVolumeCount]->shape = CMD_GET(u8, 33); sPuppyVolumeStack[gPuppyVolumeCount]->room = CMD_GET(s16, 34); + sPuppyVolumeStack[gPuppyVolumeCount]->area = sCurrAreaIndex; gPuppyVolumeCount++; #endif @@ -876,6 +877,8 @@ static void level_cmd_puppylight_node(void) gPuppyLights[gNumLights]->epicentre = CMD_GET(u8, 20); gPuppyLights[gNumLights]->flags |= CMD_GET(u8, 21); gPuppyLights[gNumLights]->active = TRUE; + gPuppyLights[gNumLights]->area = sCurrAreaIndex; + gPuppyLights[gNumLights]->room = CMD_GET(s16, 22); gNumLights++; diff --git a/src/game/level_update.c b/src/game/level_update.c index 110c899b..665d6a70 100644 --- a/src/game/level_update.c +++ b/src/game/level_update.c @@ -648,7 +648,7 @@ void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg3) { s32 i = 0; #endif #ifdef PUPPYCAM - if (sWarpDest.type != WARP_TYPE_SAME_AREA) + if (sWarpDest.type == WARP_TYPE_CHANGE_LEVEL) { for (i = 0; i < gPuppyVolumeCount; i++) { @@ -658,7 +658,7 @@ void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg3) { } #endif #ifdef PUPPYLIGHTS - if (sWarpDest.type != WARP_TYPE_SAME_AREA) + if (sWarpDest.type == WARP_TYPE_CHANGE_LEVEL) { for (i = 0; i < gNumLights; i++) { @@ -1128,10 +1128,6 @@ s32 play_mode_change_area(void) { set_play_mode(PLAY_MODE_NORMAL); } -#ifdef PUPPYLIGHTS - puppylights_allocate(); -#endif - return 0; } diff --git a/src/game/puppycam2.h b/src/game/puppycam2.h index e094671c..59a07ac2 100644 --- a/src/game/puppycam2.h +++ b/src/game/puppycam2.h @@ -135,6 +135,7 @@ struct sPuppyVolume u8 flagPersistance; //Decides if adding or removing the flags is temporary or permanent. u8 shape; s16 room; + u8 area; }; enum gPuppyCamBeh diff --git a/src/game/puppylights.c b/src/game/puppylights.c index adac9ec1..e1b587f8 100644 --- a/src/game/puppylights.c +++ b/src/game/puppylights.c @@ -215,7 +215,7 @@ void puppylights_run(Lights1 *src, struct Object *obj, s32 flags, u32 baseColour for (i = 0; i < gNumLights; i++) { - if (gPuppyLights[i]->rgba[3] > 0 && gPuppyLights[i]->active == TRUE) + if (gPuppyLights[i]->rgba[3] > 0 && gPuppyLights[i]->active == TRUE && gPuppyLights[i]->area == gCurrAreaIndex && (gPuppyLights[i]->room == -1 || gPuppyLights[i]->room == gMarioCurrentRoom)) puppylights_iterate(gPuppyLights[i], src, obj); } } @@ -248,6 +248,8 @@ void puppylights_object_emit(struct Object *obj) continue; memcpy(gPuppyLights[i], &obj->puppylight, sizeof(struct PuppyLight)); gPuppyLights[i]->active = TRUE; + gPuppyLights[i]->area = gCurrAreaIndex; + gPuppyLights[i]->room = obj->oRoom; obj->oLightID = i; goto updatepos; } @@ -271,7 +273,7 @@ void puppylights_object_emit(struct Object *obj) //A bit unorthodox, but anything to avoid having to set up data to pass through in the original function. //Objects will completely ignore X, Y, Z and active though. -void set_light_properties(struct PuppyLight *light, s32 x, s32 y, s32 z, s32 offsetX, s32 offsetY, s32 offsetZ, s32 yaw, s32 epicentre, s32 colour, s32 flags, s32 active) +void set_light_properties(struct PuppyLight *light, s32 x, s32 y, s32 z, s32 offsetX, s32 offsetY, s32 offsetZ, s32 yaw, s32 epicentre, s32 colour, s32 flags, s32 active, s32 room) { light->active = active; light->pos[0][0] = x; @@ -285,6 +287,8 @@ void set_light_properties(struct PuppyLight *light, s32 x, s32 y, s32 z, s32 off light->rgba[2] = (colour >> 8) & 0xFF; light->rgba[3] = colour & 0xFF; light->yaw = yaw; + light->area = gCurrAreaIndex; + light->room = room; light->epicentre = epicentre; if (!(flags & PUPPYLIGHT_SHAPE_CYLINDER) && flags & PUPPYLIGHT_SHAPE_CUBE) light->flags |= PUPPYLIGHT_SHAPE_CYLINDER; diff --git a/src/game/puppylights.h b/src/game/puppylights.h index fbab4420..f4bee05b 100644 --- a/src/game/puppylights.h +++ b/src/game/puppylights.h @@ -24,13 +24,13 @@ CMD_BBBB(ambientB, diffuseR, diffuseG, diffuseB), \ CMD_BBBB(diffuseX, diffuseY, diffuseZ, 0x0) -#define PUPPYLIGHT_NODE(r, g, b, a, x, y, z, offsetX, offsetY, offsetZ, yaw, epicentre, flags) \ +#define PUPPYLIGHT_NODE(r, g, b, a, x, y, z, offsetX, offsetY, offsetZ, yaw, epicentre, flags, room) \ CMD_BBBB(0x40, 0x18, r, g), \ CMD_BBH(b, a, x), \ CMD_HH(y, z), \ CMD_HH(offsetX, offsetY), \ CMD_HH(offsetZ, yaw), \ - CMD_BBH(epicentre, flags, 0x0) + CMD_BBH(epicentre, flags, room) //How much RAM is allocated to puppylights #define PUPPYLIGHTS_POOL sizeof(struct PuppyLight) * MAX_LIGHTS @@ -46,7 +46,7 @@ extern void cur_obj_enable_light(void); extern void cur_obj_disable_light(void); extern void obj_enable_light(struct Object *obj); extern void obj_disable_light(struct Object *obj); -extern void set_light_properties(struct PuppyLight *light, s32 x, s32 y, s32 z, s32 offsetX, s32 offsetY, s32 offsetZ, s32 yaw, s32 epicentre, s32 colour, s32 flags, s32 active); +extern void set_light_properties(struct PuppyLight *light, s32 x, s32 y, s32 z, s32 offsetX, s32 offsetY, s32 offsetZ, s32 yaw, s32 epicentre, s32 colour, s32 flags, s32 active, s32 room); extern void puppylights_allocate(void); #endif