mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 17:12:25 -05:00
Defer creating maps/plugins directory until necessary, make World a component
This commit is contained in:
parent
3fd48f49bb
commit
0f36cc9a57
4 changed files with 9 additions and 8 deletions
|
@ -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() \
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue