From a3f32279f6bb3d966d6515d16ec66c50f44ab15f Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 3 Nov 2020 10:01:18 +1100 Subject: [PATCH] Android: Fix singleplayer reusing texture pack from last server (thanks fizzwhiz) --- src/Game.c | 7 +------ src/Server.c | 12 ++++++------ src/TexturePack.c | 10 +++++++++- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Game.c b/src/Game.c index 80cc9e533..5d50010bf 100644 --- a/src/Game.c +++ b/src/Game.c @@ -176,11 +176,6 @@ void Game_Reset(void) { struct IGameComponent* comp; World_NewMap(); - if (TexturePack_Url.length) { - TexturePack_Url.length = 0; - TexturePack_ExtractCurrent(false); - } - for (comp = comps_head; comp; comp = comp->next) { if (comp->Reset) comp->Reset(); } @@ -378,6 +373,7 @@ static void Game_Load(void) { Event_Register_(&WindowEvents.Resized, NULL, Game_OnResize); Event_Register_(&WindowEvents.Closing, NULL, Game_Free); + Game_AddComponent(&Textures_Component); Game_AddComponent(&Input_Component); Game_AddComponent(&Camera_Component); Game_AddComponent(&Gfx_Component); @@ -395,7 +391,6 @@ static void Game_Load(void) { Game_AddComponent(&Animations_Component); Game_AddComponent(&Inventory_Component); - Game_AddComponent(&Textures_Component); World_Reset(); Game_AddComponent(&Builder_Component); diff --git a/src/Server.c b/src/Server.c index 339e8a29d..969ef0961 100644 --- a/src/Server.c +++ b/src/Server.c @@ -502,12 +502,6 @@ static void OnNewMap(void) { } } -static void OnReset(void) { - if (Server.IsSinglePlayer) return; - net_writeFailed = false; - OnClose(); -} - static void OnInit(void) { String_InitArray(Server.Name, nameBuffer); String_InitArray(Server.MOTD, motdBuffer); @@ -523,6 +517,12 @@ static void OnInit(void) { String_AppendConst(&Server.AppName, GAME_APP_NAME); } +static void OnReset(void) { + if (Server.IsSinglePlayer) return; + net_writeFailed = false; + OnClose(); +} + static void OnFree(void) { Server.IP.length = 0; OnClose(); diff --git a/src/TexturePack.c b/src/TexturePack.c index d289a2cff..b90b322e1 100644 --- a/src/TexturePack.c +++ b/src/TexturePack.c @@ -466,12 +466,20 @@ static void OnInit(void) { TextureCache_Init(); } +static void OnReset(void) { + if (!TexturePack_Url.length) return; + TexturePack_Url.length = 0; + TexturePack_ExtractCurrent(false); +} + static void OnFree(void) { OnContextLost(NULL); Atlas2D_Free(); + TexturePack_Url.length = 0; } struct IGameComponent Textures_Component = { OnInit, /* Init */ - OnFree /* Free */ + OnFree, /* Free */ + OnReset /* Reset */ };