diff --git a/src/Game.c b/src/Game.c index 76dd83326..0cecc9172 100644 --- a/src/Game.c +++ b/src/Game.c @@ -342,6 +342,7 @@ static void LoadPlugins(void) { static const cc_string dir = String_FromConst("plugins"); cc_result res; + Utils_EnsureDirectory("plugins"); res = Directory_Enum(&dir, NULL, LoadPlugin); if (res) Logger_SysWarn(res, "enumerating plugins directory"); } @@ -355,6 +356,7 @@ static void Game_Load(void) { Gfx_Create(); Logger_WarnFunc = Game_WarnFunc; LoadOptions(); + Utils_EnsureDirectory("maps"); Event_Register_(&WorldEvents.NewMap, NULL, HandleOnNewMap); Event_Register_(&WorldEvents.MapLoaded, NULL, HandleOnNewMapLoaded); @@ -362,6 +364,7 @@ static void Game_Load(void) { Event_Register_(&WindowEvents.Resized, NULL, Game_OnResize); Event_Register_(&WindowEvents.Closing, NULL, Game_Free); + Game_AddComponent(&World_Component); Game_AddComponent(&Textures_Component); Game_AddComponent(&Input_Component); Game_AddComponent(&Camera_Component); @@ -372,7 +375,6 @@ static void Game_Load(void) { Game_AddComponent(&Chat_Component); Game_AddComponent(&Particles_Component); Game_AddComponent(&TabList_Component); - Game_AddComponent(&Models_Component); Game_AddComponent(&Entities_Component); Game_AddComponent(&Http_Component); @@ -380,8 +382,6 @@ static void Game_Load(void) { Game_AddComponent(&Animations_Component); Game_AddComponent(&Inventory_Component); - World_Reset(); - Game_AddComponent(&Builder_Component); Game_AddComponent(&MapRenderer_Component); Game_AddComponent(&EnvRenderer_Component); @@ -392,7 +392,6 @@ static void Game_Load(void) { Game_AddComponent(&Selections_Component); Game_AddComponent(&HeldBlockRenderer_Component); /* Gfx_SetDepthWrite(true) */ - Game_AddComponent(&PickedPosRenderer_Component); Game_AddComponent(&Audio_Component); Game_AddComponent(&AxisLinesRenderer_Component); @@ -619,7 +618,6 @@ void Game_Free(void* obj) { Logger_WarnFunc = Logger_DialogWarn; Gfx_Free(); Options_SaveIfChanged(); - World_Reset(); } #define Game_DoFrameBody() \ diff --git a/src/Program.c b/src/Program.c index 36d51ab2e..17979869c 100644 --- a/src/Program.c +++ b/src/Program.c @@ -170,9 +170,6 @@ int main(int argc, char** argv) { #endif Platform_LogConst("Starting " GAME_APP_NAME " .."); String_InitArray(Server.IP, ipBuffer); - - Utils_EnsureDirectory("maps"); - Utils_EnsureDirectory("plugins"); Options_Load(); res = Program_Run(argc, argv); diff --git a/src/World.c b/src/World.c index 6857c79fc..43cf5ea03 100644 --- a/src/World.c +++ b/src/World.c @@ -301,3 +301,8 @@ Vec3 Respawn_FindSpawnPosition(float x, float z, Vec3 modelSize) { } return spawn; } + +struct IGameComponent World_Component = { + World_Reset, /* Init */ + World_Reset /* Free */ +}; diff --git a/src/World.h b/src/World.h index 13d62ee5c..b2d23b2f5 100644 --- a/src/World.h +++ b/src/World.h @@ -7,6 +7,7 @@ Copyright 2014-2021 ClassiCube | Licensed under BSD-3 */ struct AABB; +extern struct IGameComponent World_Component; /* Unpacka an index into x,y,z (slow!) */ #define World_Unpack(idx, x, y, z) x = idx % World.Width; z = (idx / World.Width) % World.Length; y = (idx / World.Width) / World.Length;