Consistently use OnInit/OnFree/OnReset everywhere

This commit is contained in:
UnknownShadow200 2020-07-27 18:32:01 +10:00
parent b60cfbb856
commit 8bcbad56f6
20 changed files with 130 additions and 132 deletions

View File

@ -379,19 +379,19 @@ static void OnFileChanged(void* obj, struct Stream* stream, const String* name)
}
}
static void Animations_Init(void) {
static void OnInit(void) {
ScheduledTask_Add(GAME_DEF_TICKS, Animations_Tick);
Event_RegisterVoid(&TextureEvents.PackChanged, NULL, OnPackChanged);
Event_RegisterEntry(&TextureEvents.FileChanged, NULL, OnFileChanged);
}
static void Animations_Free(void) {
static void OnFree(void) {
Animations_Clear();
Event_UnregisterVoid(&TextureEvents.PackChanged, NULL, OnPackChanged);
Event_UnregisterEntry(&TextureEvents.FileChanged, NULL, OnFileChanged);
}
struct IGameComponent Animations_Component = {
Animations_Init, /* Init */
Animations_Free /* Free */
OnInit, /* Init */
OnFree /* Free */
};

View File

@ -954,7 +954,7 @@ static void Audio_FilesCallback(const String* path, void* obj) {
StringsBuffer_Add(&files, &relPath);
}
static void Audio_Init(void) {
static void OnInit(void) {
static const String path = String_FromConst("audio");
int volume;
@ -972,7 +972,7 @@ static void Audio_Init(void) {
Event_RegisterBlock(&UserEvents.BlockChanged, NULL, Audio_PlayBlockSound);
}
static void Audio_Free(void) {
static void OnFree(void) {
Music_Free();
Sounds_Free();
Waitable_Free(music_waitable);
@ -982,6 +982,6 @@ static void Audio_Free(void) {
#endif
struct IGameComponent Audio_Component = {
Audio_Init, /* Init */
Audio_Free /* Free */
OnInit, /* Init */
OnFree /* Free */
};

View File

@ -67,16 +67,16 @@ static void OnContextLost(void* obj) {
Gfx_DeleteDynamicVb(&axisLines_vb);
}
static void AxisLinesRenderer_Init(void) {
static void OnInit(void) {
Event_RegisterVoid(&GfxEvents.ContextLost, NULL, OnContextLost);
}
static void AxisLinesRenderer_Free(void) {
static void OnFree(void) {
OnContextLost(NULL);
Event_UnregisterVoid(&GfxEvents.ContextLost, NULL, OnContextLost);
}
struct IGameComponent AxisLinesRenderer_Component = {
AxisLinesRenderer_Init, /* Init */
AxisLinesRenderer_Free, /* Free */
OnInit, /* Init */
OnFree, /* Free */
};

View File

@ -672,7 +672,7 @@ BlockID AutoRotate_RotateBlock(BlockID block) {
/*########################################################################################################################*
*----------------------------------------------------Blocks component-----------------------------------------------------*
*#########################################################################################################################*/
static void Blocks_Reset(void) {
static void OnReset(void) {
int i, block;
for (i = 0; i < Array_Elems(definedCustomBlocks); i++) {
definedCustomBlocks[i] = 0;
@ -686,7 +686,7 @@ static void Blocks_Reset(void) {
}
static void OnAtlasChanged(void* obj) { Block_RecalculateAllSpriteBB(); }
static void Blocks_Init(void) {
static void OnInit(void) {
int block;
for (block = BLOCK_AIR; block < BLOCK_COUNT; block++) {
Blocks.CanPlace[block] = true;
@ -694,7 +694,7 @@ static void Blocks_Init(void) {
}
AutoRotate_Enabled = true;
Blocks_Reset();
OnReset();
Event_RegisterVoid(&TextureEvents.AtlasChanged, NULL, OnAtlasChanged);
Blocks.CanPlace[BLOCK_AIR] = false; Blocks.CanDelete[BLOCK_AIR] = false;
@ -705,12 +705,12 @@ static void Blocks_Init(void) {
Blocks.CanPlace[BLOCK_BEDROCK] = false; Blocks.CanDelete[BLOCK_BEDROCK] = false;
}
static void Blocks_Free(void) {
static void OnFree(void) {
Event_UnregisterVoid(&TextureEvents.AtlasChanged, NULL, OnAtlasChanged);
}
struct IGameComponent Blocks_Component = {
Blocks_Init, /* Init */
Blocks_Free, /* Free */
Blocks_Reset, /* Reset */
OnInit, /* Init */
OnFree, /* Free */
OnReset, /* Reset */
};

View File

@ -1271,7 +1271,7 @@ void Builder_ApplyActive(void) {
}
}
static void Builder_Init(void) {
static void OnInit(void) {
Builder_Offsets[FACE_XMIN] = -1;
Builder_Offsets[FACE_XMAX] = 1;
Builder_Offsets[FACE_ZMIN] = -EXTCHUNK_SIZE;
@ -1283,15 +1283,15 @@ static void Builder_Init(void) {
Builder_ApplyActive();
}
static void Builder_OnNewMapLoaded(void) {
static void OnNewMapLoaded(void) {
Builder_SidesLevel = max(0, Env_SidesHeight);
Builder_EdgeLevel = max(0, Env.EdgeHeight);
}
struct IGameComponent Builder_Component = {
Builder_Init, /* Init */
OnInit, /* Init */
NULL, /* Free */
NULL, /* Reset */
NULL, /* OnNewMap */
Builder_OnNewMapLoaded /* OnNewMapLoaded */
OnNewMapLoaded /* OnNewMapLoaded */
};

View File

@ -599,7 +599,7 @@ void Chat_Send(const String* text, cc_bool logUsage) {
}
}
static void Chat_Init(void) {
static void OnInit(void) {
Commands_Register(&GpuInfoCommand);
Commands_Register(&HelpCommand);
Commands_Register(&RenderTypeCommand);
@ -614,7 +614,7 @@ static void Chat_Init(void) {
#endif
}
static void Chat_Reset(void) {
static void OnReset(void) {
CloseLogFile();
ResetLogFile();
@ -628,7 +628,7 @@ static void Chat_Reset(void) {
Chat_AddOf(&String_Empty, MSG_TYPE_BOTTOMRIGHT_3);
}
static void Chat_Free(void) {
static void OnFree(void) {
CloseLogFile();
cmds_head = NULL;
@ -641,7 +641,7 @@ static void Chat_Free(void) {
}
struct IGameComponent Chat_Component = {
Chat_Init, /* Init */
Chat_Free, /* Free */
Chat_Reset /* Reset */
OnInit, /* Init */
OnFree, /* Free */
OnReset /* Reset */
};

View File

@ -636,7 +636,7 @@ static void InitHexEncodedCol(int i, int hex, cc_uint8 lo, cc_uint8 hi) {
255);
}
static void Drawer2D_Reset(void) {
static void OnReset(void) {
int i;
for (i = 0; i < DRAWER2D_MAX_COLS; i++) {
Drawer2D_Cols[i] = 0;
@ -666,8 +666,8 @@ static void OnFileChanged(void* obj, struct Stream* src, const String* name) {
}
}
static void Drawer2D_Init(void) {
Drawer2D_Reset();
static void OnInit(void) {
OnReset();
Drawer2D_BitmappedText = Game_ClassicMode || !Options_GetBool(OPT_USE_CHAT_FONT, false);
Drawer2D_BlackTextShadows = Options_GetBool(OPT_BLACK_TEXT, false);
@ -678,16 +678,16 @@ static void Drawer2D_Init(void) {
Event_RegisterEntry(&TextureEvents.FileChanged, NULL, OnFileChanged);
}
static void Drawer2D_Free(void) {
static void OnFree(void) {
FreeFontBitmap();
fontBitmap.scan0 = NULL;
Event_UnregisterEntry(&TextureEvents.FileChanged, NULL, OnFileChanged);
}
struct IGameComponent Drawer2D_Component = {
Drawer2D_Init, /* Init */
Drawer2D_Free, /* Free */
Drawer2D_Reset, /* Reset */
OnInit, /* Init */
OnFree, /* Free */
OnReset, /* Reset */
};

View File

@ -865,7 +865,7 @@ static void OnEnvVariableChanged(void* obj, int envVar) {
/*########################################################################################################################*
*--------------------------------------------------EnvRenderer component--------------------------------------------------*
*#########################################################################################################################*/
static void EnvRenderer_Init(void) {
static void OnInit(void) {
String renderType;
int flags;
Options_UNSAFE_Get(OPT_RENDER_TYPE, &renderType);
@ -887,7 +887,7 @@ static void EnvRenderer_Init(void) {
Game_SetViewDistance(Game_UserViewDistance);
}
static void EnvRenderer_Free(void) {
static void OnFree(void) {
Event_UnregisterEntry(&TextureEvents.FileChanged, NULL, OnFileChanged);
Event_UnregisterVoid(&TextureEvents.PackChanged, NULL, OnTexturePackChanged);
Event_UnregisterVoid(&TextureEvents.AtlasChanged, NULL, OnTerrainAtlasChanged);
@ -902,7 +902,7 @@ static void EnvRenderer_Free(void) {
Weather_Heightmap = NULL;
}
static void EnvRenderer_Reset(void) {
static void OnReset(void) {
Gfx_SetFog(false);
DeleteVbs();
@ -911,12 +911,12 @@ static void EnvRenderer_Reset(void) {
lastPos = IVec3_MaxValue();
}
static void EnvRenderer_OnNewMapLoaded(void) { OnContextRecreated(NULL); }
static void OnNewMapLoaded(void) { OnContextRecreated(NULL); }
struct IGameComponent EnvRenderer_Component = {
EnvRenderer_Init, /* Init */
EnvRenderer_Free, /* Free */
EnvRenderer_Reset, /* Reset */
EnvRenderer_Reset, /* OnNewMap */
EnvRenderer_OnNewMapLoaded /* OnNewMapLoaded */
OnInit, /* Init */
OnFree, /* Free */
OnReset, /* Reset */
OnReset, /* OnNewMap */
OnNewMapLoaded /* OnNewMapLoaded */
};

View File

@ -402,7 +402,7 @@ static void OnContextLost(void* obj) {
Gfx_DeleteTexture(&Gui_IconsTex);
}
static void Gui_Init(void) {
static void OnInit(void) {
Event_RegisterVoid(&ChatEvents.FontChanged, NULL, OnFontChanged);
Event_RegisterEntry(&TextureEvents.FileChanged, NULL, OnFileChanged);
Event_RegisterVoid(&GfxEvents.ContextLost, NULL, OnContextLost);
@ -415,11 +415,11 @@ static void Gui_Init(void) {
Gui_ShowDefault();
}
static void Gui_Reset(void) {
static void OnReset(void) {
/* TODO:Should we reset all screens here.. ? */
}
static void Gui_Free(void) {
static void OnFree(void) {
Event_UnregisterVoid(&ChatEvents.FontChanged, NULL, OnFontChanged);
Event_UnregisterEntry(&TextureEvents.FileChanged, NULL, OnFileChanged);
Event_UnregisterVoid(&GfxEvents.ContextLost, NULL, OnContextLost);
@ -432,13 +432,13 @@ static void Gui_Free(void) {
while (Gui_ScreensCount) Gui_Remove(Gui_Screens[0]);
OnContextLost(NULL);
Gui_Reset();
OnReset();
}
struct IGameComponent Gui_Component = {
Gui_Init, /* Init */
Gui_Free, /* Free */
Gui_Reset, /* Reset */
OnInit, /* Init */
OnFree, /* Free */
OnReset, /* Reset */
NULL, /* OnNewMap */
NULL, /* OnNewMapLoaded */
};

View File

@ -232,7 +232,7 @@ static const struct EntityVTABLE heldEntity_VTABLE = {
NULL, NULL, NULL, HeldBlockRenderer_GetCol,
NULL, NULL
};
static void HeldBlockRenderer_Init(void) {
static void OnInit(void) {
Entity_Init(&held_entity);
held_entity.VTABLE = &heldEntity_VTABLE;
held_entity.NoShade = true;
@ -245,13 +245,13 @@ static void HeldBlockRenderer_Init(void) {
Event_RegisterBlock(&UserEvents.BlockChanged, NULL, HeldBlockRenderer_BlockChanged);
}
static void HeldBlockRenderer_Free(void) {
static void OnFree(void) {
Event_UnregisterVoid(&GfxEvents.ProjectionChanged, NULL, HeldBlockRenderer_ProjectionChanged);
Event_UnregisterVoid(&UserEvents.HeldBlockChanged, NULL, HeldBlockRenderer_DoSwitchBlockAnim);
Event_UnregisterBlock(&UserEvents.BlockChanged, NULL, HeldBlockRenderer_BlockChanged);
}
struct IGameComponent HeldBlockRenderer_Component = {
HeldBlockRenderer_Init, /* Init */
HeldBlockRenderer_Free /* Free */
OnInit, /* Init */
OnFree /* Free */
};

View File

@ -1104,7 +1104,7 @@ void Http_UrlEncodeUtf8(String* dst, const String* src) {
/*########################################################################################################################*
*-----------------------------------------------------Http component------------------------------------------------------*
*#########################################################################################################################*/
static void Http_Init(void) {
static void OnInit(void) {
#ifdef CC_BUILD_ANDROID
if (workerThread) return;
#endif
@ -1122,7 +1122,7 @@ static void Http_Init(void) {
#endif
}
static void Http_Free(void) {
static void OnFree(void) {
http_terminate = true;
Http_ClearPending();
#ifndef CC_BUILD_WEB
@ -1140,7 +1140,7 @@ static void Http_Free(void) {
}
struct IGameComponent Http_Component = {
Http_Init, /* Init */
Http_Free, /* Free */
OnInit, /* Init */
OnFree, /* Free */
Http_ClearPending /* Reset */
};

View File

@ -117,14 +117,14 @@ void Inventory_Remove(BlockID block) {
/*########################################################################################################################*
*--------------------------------------------------Inventory component----------------------------------------------------*
*#########################################################################################################################*/
static void Inventory_Reset(void) {
static void OnReset(void) {
Inventory_ResetMapping();
Inventory.CanChangeSelected = true;
}
static void Inventory_Init(void) {
static void OnInit(void) {
BlockID* inv = Inventory.Table;
Inventory_Reset();
OnReset();
Inventory.BlocksPerRow = Game_ClassicMode ? 9 : 10;
inv[0] = BLOCK_STONE; inv[1] = BLOCK_COBBLE; inv[2] = BLOCK_BRICK;
@ -133,7 +133,7 @@ static void Inventory_Init(void) {
}
struct IGameComponent Inventory_Component = {
Inventory_Init, /* Init */
OnInit, /* Init */
NULL, /* Free */
Inventory_Reset, /* Reset */
OnReset, /* Reset */
};

View File

@ -352,20 +352,20 @@ void Lighting_LightHint(int startX, int startZ) {
/*########################################################################################################################*
*---------------------------------------------------Lighting component----------------------------------------------------*
*#########################################################################################################################*/
static void Lighting_Reset(void) {
static void OnReset(void) {
Mem_Free(Lighting_Heightmap);
Lighting_Heightmap = NULL;
}
static void Lighting_OnNewMapLoaded(void) {
static void OnNewMapLoaded(void) {
Lighting_Heightmap = (cc_int16*)Mem_Alloc(World.Width * World.Length, 2, "lighting heightmap");
Lighting_Refresh();
}
struct IGameComponent Lighting_Component = {
NULL, /* Init */
Lighting_Reset, /* Free */
Lighting_Reset, /* Reset */
Lighting_Reset, /* OnNewMap */
Lighting_OnNewMapLoaded /* OnNewMapLoaded */
OnReset, /* Free */
OnReset, /* Reset */
OnReset, /* OnNewMap */
OnNewMapLoaded /* OnNewMapLoaded */
};

View File

@ -741,10 +741,10 @@ static void OnVisibilityChanged(void* obj) {
lastCamPos = Vec3_BigPos();
CalcViewDists();
}
static void MapRenderer_DeleteChunks_(void* obj) { DeleteChunks(); }
static void MapRenderer_Refresh_(void* obj) { MapRenderer_Refresh(); }
static void DeleteChunks_(void* obj) { DeleteChunks(); }
static void Refresh_(void* obj) { MapRenderer_Refresh(); }
static void MapRenderer_OnNewMap(void) {
static void OnNewMap(void) {
Game.ChunkUpdates = 0;
DeleteChunks();
ResetPartCounts();
@ -754,7 +754,7 @@ static void MapRenderer_OnNewMap(void) {
FreeParts();
}
static void MapRenderer_OnNewMapLoaded(void) {
static void OnNewMapLoaded(void) {
int count;
MapRenderer_ChunksX = (World.Width + CHUNK_MAX) >> CHUNK_SHIFT;
MapRenderer_ChunksY = (World.Height + CHUNK_MAX) >> CHUNK_SHIFT;
@ -774,15 +774,15 @@ static void MapRenderer_OnNewMapLoaded(void) {
lastCamPos = Vec3_BigPos();
}
static void MapRenderer_Init(void) {
static void OnInit(void) {
Event_RegisterVoid(&TextureEvents.AtlasChanged, NULL, OnTerrainAtlasChanged);
Event_RegisterInt(&WorldEvents.EnvVarChanged, NULL, OnEnvVariableChanged);
Event_RegisterVoid(&BlockEvents.BlockDefChanged, NULL, OnBlockDefinitionChanged);
Event_RegisterVoid(&GfxEvents.ViewDistanceChanged, NULL, OnVisibilityChanged);
Event_RegisterVoid(&GfxEvents.ProjectionChanged, NULL, OnVisibilityChanged);
Event_RegisterVoid(&GfxEvents.ContextLost, NULL, MapRenderer_DeleteChunks_);
Event_RegisterVoid(&GfxEvents.ContextRecreated, NULL, MapRenderer_Refresh_);
Event_RegisterVoid(&GfxEvents.ContextLost, NULL, DeleteChunks_);
Event_RegisterVoid(&GfxEvents.ContextRecreated, NULL, Refresh_);
/* This = 87 fixes map being invisible when no textures */
MapRenderer_1DUsedCount = 87; /* Atlas1D_UsedAtlasesCount(); */
@ -791,23 +791,22 @@ static void MapRenderer_Init(void) {
CalcViewDists();
}
static void MapRenderer_Free(void) {
static void OnFree(void) {
Event_UnregisterVoid(&TextureEvents.AtlasChanged, NULL, OnTerrainAtlasChanged);
Event_UnregisterInt(&WorldEvents.EnvVarChanged, NULL, OnEnvVariableChanged);
Event_UnregisterVoid(&BlockEvents.BlockDefChanged, NULL, OnBlockDefinitionChanged);
Event_UnregisterVoid(&GfxEvents.ViewDistanceChanged, NULL, OnVisibilityChanged);
Event_UnregisterVoid(&GfxEvents.ProjectionChanged, NULL, OnVisibilityChanged);
Event_UnregisterVoid(&GfxEvents.ContextLost, NULL, MapRenderer_DeleteChunks_);
Event_UnregisterVoid(&GfxEvents.ContextRecreated, NULL, MapRenderer_Refresh_);
MapRenderer_OnNewMap();
Event_UnregisterVoid(&GfxEvents.ContextLost, NULL, DeleteChunks_);
Event_UnregisterVoid(&GfxEvents.ContextRecreated, NULL, Refresh_);
OnNewMap();
}
struct IGameComponent MapRenderer_Component = {
MapRenderer_Init, /* Init */
MapRenderer_Free, /* Free */
MapRenderer_OnNewMap, /* Reset */
MapRenderer_OnNewMap, /* OnNewMap */
MapRenderer_OnNewMapLoaded /* OnNewMapLoaded */
OnInit, /* Init */
OnFree, /* Free */
OnNewMap, /* Reset */
OnNewMap, /* OnNewMap */
OnNewMapLoaded /* OnNewMapLoaded */
};

View File

@ -2086,8 +2086,7 @@ static struct Model* SkinnedCubeModel_GetInstance(void) {
/*########################################################################################################################*
*-------------------------------------------------------Model component---------------------------------------------------*
*#########################################################################################################################*/
static void Model_RegisterDefaultModels(void) {
static void RegisterDefaultModels(void) {
Model_RegisterTexture(&human_tex);
Model_RegisterTexture(&chicken_tex);
Model_RegisterTexture(&creeper_tex);
@ -2120,11 +2119,11 @@ static void Model_RegisterDefaultModels(void) {
Model_Register(SkinnedCubeModel_GetInstance());
}
static void Models_Init(void) {
static void OnInit(void) {
Models.Vertices = defaultVertices;
Models.MaxVertices = Array_Elems(defaultVertices);
Model_RegisterDefaultModels();
RegisterDefaultModels();
Models_ContextRecreated(NULL);
Models.ClassicArms = Options_GetBool(OPT_CLASSIC_ARM_MODEL, Game_ClassicMode);
@ -2133,7 +2132,7 @@ static void Models_Init(void) {
Event_RegisterVoid(&GfxEvents.ContextRecreated, NULL, Models_ContextRecreated);
}
static void Models_Free(void) {
static void OnFree(void) {
Models_ContextLost(NULL);
CustomModel_FreeAll();
@ -2142,10 +2141,10 @@ static void Models_Free(void) {
Event_UnregisterVoid(&GfxEvents.ContextRecreated, NULL, Models_ContextRecreated);
}
static void Models_Reset(void) { CustomModel_FreeAll(); }
static void OnReset(void) { CustomModel_FreeAll(); }
struct IGameComponent Models_Component = {
Models_Init, /* Init */
Models_Free, /* Free */
Models_Reset, /* Reset */
OnInit, /* Init */
OnFree, /* Free */
OnReset, /* Reset */
};

View File

@ -597,7 +597,7 @@ static void OnFileChanged(void* obj, struct Stream* stream, const String* name)
}
}
static void Particles_Init(void) {
static void OnInit(void) {
ScheduledTask_Add(GAME_DEF_TICKS, Particles_Tick);
Random_SeedFromCurrentTime(&rnd);
OnContextRecreated(NULL);
@ -608,7 +608,7 @@ static void Particles_Init(void) {
Event_RegisterVoid(&GfxEvents.ContextRecreated, NULL, OnContextRecreated);
}
static void Particles_Free(void) {
static void OnFree(void) {
OnContextLost(NULL);
Event_UnregisterBlock(&UserEvents.BlockChanged, NULL, OnBreakBlockEffect_Handler);
@ -617,11 +617,11 @@ static void Particles_Free(void) {
Event_UnregisterVoid(&GfxEvents.ContextRecreated, NULL, OnContextRecreated);
}
static void Particles_Reset(void) { rain_count = 0; terrain_count = 0; custom_count = 0; }
static void OnReset(void) { rain_count = 0; terrain_count = 0; custom_count = 0; }
struct IGameComponent Particles_Component = {
Particles_Init, /* Init */
Particles_Free, /* Free */
Particles_Reset, /* Reset */
Particles_Reset /* OnNewMap */
OnInit, /* Init */
OnFree, /* Free */
OnReset, /* Reset */
OnReset /* OnNewMap */
};

View File

@ -112,19 +112,19 @@ static void OnContextRecreated(void* obj) {
pickedPos_vb = Gfx_CreateDynamicVb(VERTEX_FORMAT_COLOURED, PICKEDPOS_NUM_VERTICES);
}
static void PickedPosRenderer_Init(void) {
static void OnInit(void) {
OnContextRecreated(NULL);
Event_RegisterVoid(&GfxEvents.ContextLost, NULL, OnContextLost);
Event_RegisterVoid(&GfxEvents.ContextRecreated, NULL, OnContextRecreated);
}
static void PickedPosRenderer_Free(void) {
static void OnFree(void) {
OnContextLost(NULL);
Event_UnregisterVoid(&GfxEvents.ContextLost, NULL, OnContextLost);
Event_UnregisterVoid(&GfxEvents.ContextRecreated, NULL, OnContextRecreated);
}
struct IGameComponent PickedPosRenderer_Component = {
PickedPosRenderer_Init, /* Init */
PickedPosRenderer_Free, /* Free */
OnInit, /* Init */
OnFree, /* Free */
};

View File

@ -214,24 +214,24 @@ void Selections_Render(void) {
/*########################################################################################################################*
*--------------------------------------------------Selections component---------------------------------------------------*
*#########################################################################################################################*/
static void Selections_Init(void) {
static void OnInit(void) {
Event_RegisterVoid(&GfxEvents.ContextLost, NULL, Selections_ContextLost);
Event_RegisterVoid(&GfxEvents.ContextRecreated, NULL, Selections_ContextRecreated);
}
static void Selections_Reset(void) {
static void OnReset(void) {
selections_count = 0;
}
static void Selections_Free(void) {
static void OnFree(void) {
Selections_ContextLost(NULL);
Event_UnregisterVoid(&GfxEvents.ContextLost, NULL, Selections_ContextLost);
Event_UnregisterVoid(&GfxEvents.ContextRecreated, NULL, Selections_ContextRecreated);
}
struct IGameComponent Selections_Component = {
Selections_Init, /* Init */
Selections_Free, /* Free */
Selections_Reset, /* Reset */
Selections_Reset /* OnNewMap */
OnInit, /* Init */
OnFree, /* Free */
OnReset, /* Reset */
OnReset /* OnNewMap */
};

View File

@ -242,7 +242,7 @@ static cc_bool net_connecting;
static double net_connectTimeout;
#define NET_TIMEOUT_SECS 15
static void Server_Free(void);
static void OnFree(void);
static void MPConnection_FinishConnect(void) {
net_connecting = false;
Event_RaiseVoid(&NetEvents.Connected);
@ -270,7 +270,7 @@ static void MPConnection_FailConnect(cc_result result) {
String_Format2(&msg, "Failed to connect to %s:%i", &Server.IP, &Server.Port);
Game_Disconnect(&msg, &reason);
Server_Free();
OnFree();
}
static void MPConnection_TickConnect(void) {
@ -491,7 +491,7 @@ static void MPConnection_Init(void) {
}
static void Server_OnNewMap(void) {
static void OnNewMap(void) {
int i;
if (Server.IsSinglePlayer) return;
@ -501,14 +501,14 @@ static void Server_OnNewMap(void) {
}
}
static void Server_Reset(void) {
static void OnReset(void) {
if (Server.IsSinglePlayer) return;
net_writeFailed = false;
Server_Free();
OnFree();
}
static void Server_Init(void) {
static void OnInit(void) {
String_InitArray(Server.Name, nameBuffer);
String_InitArray(Server.MOTD, motdBuffer);
String_InitArray(Server.AppName, appBuffer);
@ -523,7 +523,7 @@ static void Server_Init(void) {
String_AppendConst(&Server.AppName, GAME_APP_NAME);
}
static void Server_Free(void) {
static void OnFree(void) {
if (Server.IsSinglePlayer) {
Physics_Free();
} else {
@ -534,8 +534,8 @@ static void Server_Free(void) {
}
struct IGameComponent Server_Component = {
Server_Init, /* Init */
Server_Free, /* Free */
Server_Reset, /* Reset */
Server_OnNewMap /* OnNewMap */
OnInit, /* Init */
OnFree, /* Free */
OnReset, /* Reset */
OnNewMap /* OnNewMap */
};

View File

@ -443,7 +443,7 @@ static void OnContextRecreated(void* obj) {
if (!Gfx.ManagedTextures) TexturePack_ExtractCurrent(true);
}
static void Textures_Init(void) {
static void OnInit(void) {
Event_RegisterEntry(&TextureEvents.FileChanged, NULL, OnFileChanged);
Event_RegisterVoid(&GfxEvents.ContextLost, NULL, OnContextLost);
Event_RegisterVoid(&GfxEvents.ContextRecreated, NULL, OnContextRecreated);
@ -452,7 +452,7 @@ static void Textures_Init(void) {
TextureCache_Init();
}
static void Textures_Free(void) {
static void OnFree(void) {
Event_UnregisterEntry(&TextureEvents.FileChanged, NULL, OnFileChanged);
Event_UnregisterVoid(&GfxEvents.ContextLost, NULL, OnContextLost);
Event_UnregisterVoid(&GfxEvents.ContextRecreated, NULL, OnContextRecreated);
@ -462,6 +462,6 @@ static void Textures_Free(void) {
}
struct IGameComponent Textures_Component = {
Textures_Init, /* Init */
Textures_Free /* Free */
OnInit, /* Init */
OnFree /* Free */
};