diff --git a/src/entities/structures/teleporter.c b/src/entities/structures/teleporter.c index b43e6d3..13904e0 100644 --- a/src/entities/structures/teleporter.c +++ b/src/entities/structures/teleporter.c @@ -120,10 +120,23 @@ static void activate(int active) static void load(cJSON *root) { - /* nothing to do */ + Structure *s; + + s = (Structure*)self; + + s->active = cJSON_GetObjectItem(root, "active")->valueint; + s->tx = cJSON_GetObjectItem(root, "tx")->valueint; + s->ty = cJSON_GetObjectItem(root, "ty")->valueint; } static void save(cJSON *root) { + Structure *s; + + s = (Structure*)self; + cJSON_AddStringToObject(root, "type", "Teleporter"); + cJSON_AddNumberToObject(root, "active", s->active); + cJSON_AddNumberToObject(root, "tx", s->tx); + cJSON_AddNumberToObject(root, "ty", s->ty); } diff --git a/src/world/entities.c b/src/world/entities.c index e5d31bf..c9f07f7 100644 --- a/src/world/entities.c +++ b/src/world/entities.c @@ -798,6 +798,12 @@ void activateEntities(char *names, int active) void teleportEntity(Entity *e, float tx, float ty) { + e->tx = tx; + e->ty = ty; + + e->flags |= EF_TELEPORTING; + + addTeleportStars(e); } static void handleTeleport(void) @@ -876,6 +882,13 @@ void teleport(Entity *e, float tx, float ty) e->flags |= EF_TELEPORTING; addTeleportStars(e); + + if (e == (Entity*)world.bob) + { + terminateJetpack(); + + world.bob->flags &= ~(EF_WATER_BREATHING | EF_WEIGHTLESS); + } } Entity *findEntity(char *name) diff --git a/src/world/entities.h b/src/world/entities.h index b3a377a..4414bfa 100644 --- a/src/world/entities.h +++ b/src/world/entities.h @@ -37,6 +37,7 @@ extern float limit(float i, float a, float b); extern int isWalkable(int x, int y); extern int isLiquid(int x, int y); extern int isSolid(int x, int y); +extern void terminateJetpack(void); extern Entity *self; extern Camera camera;