summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Noga <Tempus@Spectrum-Song.local>2011-07-20 13:20:11 -0500
committerColin Noga <Tempus@Spectrum-Song.local>2011-07-20 13:20:11 -0500
commitffa9dabc6b535da90b3cd8a7849079c546cacfbd (patch)
treec4d9129b7a64b22caaed31bc968d5c8fcee141a6
parentc2cc0c0d58b09d4e11003ca53e33b38723709bc1 (diff)
downloadkamek-ffa9dabc6b535da90b3cd8a7849079c546cacfbd.tar.gz
kamek-ffa9dabc6b535da90b3cd8a7849079c546cacfbd.zip
Fixed up sprite spawner (probably)
Diffstat (limited to '')
-rwxr-xr-xsrc/spritespawner.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/spritespawner.cpp b/src/spritespawner.cpp
index 911ae8a..1d6a071 100755
--- a/src/spritespawner.cpp
+++ b/src/spritespawner.cpp
@@ -16,7 +16,7 @@ struct SpriteSpawner {
u16 type; // 0x3D4
u32 inheritSet; // 0x3D6
u8 lastEvState; // 0x3DA
- dStageActor_c *createdActor;
+ u32 createdActor;
};
struct EventTable_t {
@@ -33,6 +33,7 @@ struct VEC {
extern EventTable_t *EventTable;
extern "C" dStageActor_c *CreateActor(u16 classID, int settings, VEC pos, char rot, char layer);
+extern "C" dStageActor_c *Actor_SearchByID(u32 actorID);
void SpriteSpawner_Update(SpriteSpawner *self);
@@ -49,8 +50,8 @@ bool SpriteSpawner_Create(SpriteSpawner *self) {
OSReport("Event to activate: %d", eventNum);
self->eventFlag = (u64)1 << (eventNum - 1);
-
- self->type = (self->settings >> 16) & 0xFFF;
+ self->createdActor = 0;
+ self->type = (self->settings >> 16) & 0xFFF;
short tempSet = self->settings & 0xFFFF;
self->inheritSet = (tempSet & 3) | ((tempSet & 0xC) << 2) | ((tempSet & 0x30) << 4) | ((tempSet & 0xC0) << 6) | ((tempSet & 0x300) << 8) | ((tempSet & 0xC00) << 10) | ((tempSet & 0x3000) << 12) | ((tempSet & 0xC000) << 14);
@@ -81,16 +82,22 @@ void SpriteSpawner_Update(SpriteSpawner *self) {
OSReport("Spawning Sprite: %d at %f,%f,%f\n", self->type, pos.x, pos.y, pos.z);
- self->createdActor = CreateActor(self->type, self->inheritSet, pos, 0, 0);
+ dStageActor_c *spawned = CreateActor(self->type, self->inheritSet, pos, 0, 0);
+ self->createdActor = spawned->id;
}
// EventTable->events = EventTable->events & ~self->eventFlag;
}
else
{
- self->x = self->createdActor->pos.x;
- self->y = self->createdActor->pos.y;
- self->z = self->createdActor->pos.z;
- self->createdActor->Delete();
- self->createdActor = 0;
+ if (self->createdActor != 0) {
+ dStageActor_c *spawned = Actor_SearchByID(self->createdActor);
+ if (spawned != 0) {
+ self->x = spawned->pos.x;
+ self->y = spawned->pos.y;
+ self->z = spawned->pos.z;
+ spawned->Delete();
+ }
+ self->createdActor = 0;
+ }
}
}