Skip to content

Commit 9341443

Browse files
authored
refactor(logic): move db cleanup to OnMapEnd and simplify Menu_AddColors (#78)
1 parent 03da81d commit 9341443

2 files changed

Lines changed: 23 additions & 29 deletions

File tree

addons/sourcemod/scripting/CustomChatColors.sp

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -277,28 +277,6 @@ public void OnPluginStart()
277277
g_evEngineVersion = GetEngineVersion();
278278
}
279279

280-
public void OnPluginEnd()
281-
{
282-
// Clean up on map end just so we can start a fresh connection when we need it later.
283-
if (g_hDatabase != null)
284-
{
285-
delete g_hDatabase;
286-
g_hDatabase = null;
287-
}
288-
if (g_sColorsArray != null)
289-
delete g_sColorsArray;
290-
if (g_smReplacePendingTriggers != null)
291-
{
292-
delete g_smReplacePendingTriggers;
293-
g_smReplacePendingTriggers = null;
294-
}
295-
296-
g_DatabaseState = DatabaseState_Disconnected;
297-
g_hDatabase = null;
298-
g_hReconnectTimer = null;
299-
g_bDBConnectDelayActive = false;
300-
}
301-
302280
public void OnAllPluginsLoaded()
303281
{
304282
g_bPlugin_SelfMute = LibraryExists("SelfMute");
@@ -399,6 +377,26 @@ public void OnConfigsExecuted()
399377
g_cSmChatColor.GetString(g_sSmChatColor, sizeof(g_sSmChatColor));
400378
}
401379

380+
public void OnMapEnd()
381+
{
382+
// Clean up on map end just so we can start a fresh connection when we need it later.
383+
if (g_hReconnectTimer != null)
384+
{
385+
delete g_hReconnectTimer;
386+
g_hReconnectTimer = null;
387+
}
388+
389+
if (g_hDatabase != null)
390+
{
391+
delete g_hDatabase;
392+
g_hDatabase = null;
393+
}
394+
395+
g_DatabaseState = DatabaseState_Disconnected;
396+
g_iConnectLock = 0;
397+
g_bDBConnectDelayActive = false;
398+
}
399+
402400
public void OnClientDisconnect(int client)
403401
{
404402
g_bClientDataLoaded[client] = false;
@@ -4042,15 +4040,11 @@ public void Menu_TagPrefs(int client)
40424040

40434041
public void Menu_AddColors(Menu ColorsMenu)
40444042
{
4045-
char info[64];
4043+
char key[64];
40464044
for (int i = 0; i < g_sColorsArray.Length; i++)
40474045
{
4048-
char key[64];
40494046
g_sColorsArray.GetString(i, key, sizeof(key));
4050-
4051-
Format(info, sizeof(info), "%s", key);
4052-
4053-
ColorsMenu.AddItem(key, info);
4047+
ColorsMenu.AddItem(key, key);
40544048
}
40554049
}
40564050

addons/sourcemod/scripting/include/ccc.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#define CCC_V_MAJOR "8"
1313
#define CCC_V_MINOR "0"
14-
#define CCC_V_PATCH "3"
14+
#define CCC_V_PATCH "4"
1515

1616
#define CCC_VERSION CCC_V_MAJOR..."."...CCC_V_MINOR..."."...CCC_V_PATCH
1717

0 commit comments

Comments
 (0)