Game saving updates.
This commit is contained in:
parent
55dabbb018
commit
34b97bcc27
|
@ -253,7 +253,14 @@ static void save(cJSON *root)
|
|||
|
||||
i = (Item*)self;
|
||||
|
||||
if (i->type != ET_KEY)
|
||||
{
|
||||
cJSON_AddStringToObject(root, "type", "Item");
|
||||
}
|
||||
else
|
||||
{
|
||||
cJSON_AddStringToObject(root, "type", i->sprite[0]->name);
|
||||
}
|
||||
cJSON_AddNumberToObject(root, "canBeCarried", i->canBeCarried);
|
||||
cJSON_AddNumberToObject(root, "canBePickedUp", i->canBePickedUp);
|
||||
cJSON_AddNumberToObject(root, "isMissionTarget", i->isMissionTarget);
|
||||
|
|
|
@ -213,6 +213,8 @@ void dropCarriedItems(void)
|
|||
/* items can only be collected if they have a thinktime of 0 */
|
||||
item->thinkTime = FPS * 9999;
|
||||
}
|
||||
|
||||
world.bob->items[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ static void saveTriggers(cJSON *root);
|
|||
static void saveBob(cJSON *root);
|
||||
static void saveEntities(cJSON *root);
|
||||
static void saveObjectives(cJSON *root);
|
||||
static int canPersistEntity(void);
|
||||
|
||||
void saveWorld(void)
|
||||
{
|
||||
|
@ -130,7 +131,7 @@ static void saveEntities(cJSON *root)
|
|||
|
||||
for (self = world.entityHead.next ; self != NULL ; self = self->next)
|
||||
{
|
||||
if (self->type != ET_NONE && self->type != ET_BOB && self->health > 0 && self->alive == ALIVE_ALIVE)
|
||||
if (canPersistEntity())
|
||||
{
|
||||
entityJSON = cJSON_CreateObject();
|
||||
|
||||
|
@ -147,6 +148,25 @@ static void saveEntities(cJSON *root)
|
|||
cJSON_AddItemToObject(root, "entities", entitiesJSON);
|
||||
}
|
||||
|
||||
static int canPersistEntity(void)
|
||||
{
|
||||
switch (self->type)
|
||||
{
|
||||
case ET_NONE:
|
||||
case ET_BOB:
|
||||
case ET_DECORATION:
|
||||
case ET_CONSUMABLE:
|
||||
return 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
return self->health > 0 && self->alive == ALIVE_ALIVE;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void saveObjectives(cJSON *root)
|
||||
{
|
||||
Objective *o;
|
||||
|
|
Loading…
Reference in New Issue