Fixed bug where player data could persist into new world
Player struct now always resets when world is wiped, not just conitionally in world_load. This fixes player data persisted when entering and exiting a world, leaving the program open, and then creating a new world.
This commit is contained in:
@@ -70,6 +70,13 @@ int World_save (World *world) {
|
||||
* Wipes a world, freeing all data inside of it. This does not save anything.
|
||||
*/
|
||||
void World_wipe (World *world) {
|
||||
// Reset player
|
||||
world->player = (const Player) { 0};
|
||||
world->player.pos.x = 32.5;
|
||||
world->player.pos.y = 20;
|
||||
world->player.pos.z = 32.5;
|
||||
|
||||
// Clear chunks
|
||||
for (int index = 0; index < CHUNKARR_SIZE; index ++) {
|
||||
Chunk *chunk = &world->chunk[index];
|
||||
|
||||
@@ -120,11 +127,6 @@ int World_load (World *world, const char *name) {
|
||||
options.username.buffer);
|
||||
if (data_fileExists(playerPath)) {
|
||||
Player_load(&world->player, playerPath);
|
||||
} else {
|
||||
world->player = (const Player) { 0 };
|
||||
world->player.pos.x = 32.5;
|
||||
world->player.pos.y = 64;
|
||||
world->player.pos.z = 32.5;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user