Пример #1
0
/**
 * Free player struct
 */
static void cleanup_player(void) {
	int i;

	/* Free the things that are always initialised */
	mem_free(player->obj_k);
	mem_free(player->timed);
	mem_free(player->upkeep->quiver);
	mem_free(player->upkeep->inven);
	mem_free(player->upkeep);
	player->upkeep = NULL;

	/* Free the things that are only there if there is a loaded player -
	 * checking if there are quests will suffice */
	if (player->quests) {
		player_quests_free(player);
		player_spells_free(player);
		object_pile_free(player->gear);
		object_pile_free(player->gear_k);
		for (i = 0; i < player->body.count; i++)
			string_free(player->body.slots[i].name);
		mem_free(player->body.slots);
		string_free(player->body.name);
		mem_free(player->history);
	}
	if (player->cave) {
		cave_free(player->cave);
		player->cave = NULL;
	}

	/* Free the basic player struct */
	mem_free(player);
	player = NULL;
}
Пример #2
0
/**
 * Free player struct
 */
static void cleanup_player(void) {
	int i;

	player_quests_free(player);
	player_spells_free(player);

	mem_free(player->timed);
	mem_free(player->upkeep->quiver);
	mem_free(player->upkeep->inven);
	mem_free(player->upkeep);
	player->upkeep = NULL;
	object_pile_free(player->gear);
	object_pile_free(player->gear_k);
	for (i = 0; i < player->body.count; i++)
		string_free(player->body.slots[i].name);
	mem_free(player->body.slots);
	string_free(player->body.name);
	mem_free(player->history);

	mem_free(player);
	player = NULL;
}