Skip to content

Commit

Permalink
Fixed excessive read/write to database.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stewart-Anubis committed Jul 1, 2021
1 parent 46d7c71 commit 7e5c0d5
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 169 deletions.
Binary file modified plugin compiled (REQUIRED)/zombiereloaded_sounds.smx
Binary file not shown.
2 changes: 1 addition & 1 deletion src/zombiereloaded_sounds.sp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#pragma newdecls required

#define VERSION "3.7.1 Anubis edition"
#define VERSION "3.7.2 Anubis edition"

#include "zr_sounds/zombiereloaded"

Expand Down
46 changes: 0 additions & 46 deletions src/zr_sounds/cookies.inc
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,6 @@ void CookiesSetClientCookieBool(int client, Handle cookie, bool cookievalue)
SetClientCookie(client, cookie, strCookievalue);
}

/**
* Returns a cookie value as a bool.
*
* @param client The client index.
* @param cookie The handle to the cookie.
*/
bool CookiesGetClientCookieBool(int client, Handle cookie)
{
// Get cookie string.
char cookievalue[8];
GetClientCookie(client, cookie, cookievalue, sizeof(cookievalue));

// Return string casted into an int, then to bool.
return view_as<bool>(StringToInt(cookievalue));
}

/**
* Sets a integer value on a cookie.
*
Expand All @@ -84,21 +68,6 @@ void CookiesSetInt(int client, Handle cookie, int value)
SetClientCookie(client, cookie, strValue);
}

/**
* Gets a integer value from a cookie.
*
* @param client The client index.
* @param cookie The handle to the cookie.
*/
int CookiesGetInt(int client, Handle cookie)
{
char strValue[16];
strValue[0] = 0;
GetClientCookie(client, cookie, strValue, sizeof(strValue));

return StringToInt(strValue);
}

/**
* Sets a integer value on a cookie.
*
Expand All @@ -114,19 +83,4 @@ void CookiesSetFloat(int client, Handle cookie, float value)
FloatToString(value, strValue, sizeof(strValue));
// Set string value.
SetClientCookie(client, cookie, strValue);
}

/**
* Gets a integer value from a cookie.
*
* @param client The client index.
* @param cookie The handle to the cookie.
*/
float CookiesGetFloat(int client, Handle cookie)
{
char strValue[16];
strValue[0] = 0;
GetClientCookie(client, cookie, strValue, sizeof(strValue));

return StringToFloat(strValue);
}
16 changes: 2 additions & 14 deletions src/zr_sounds/soundeffects/countdownsounds.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,8 @@ public int ZR_OnContdownWarningTick(int tick)
if (IsClientInGame(i) && !IsFakeClient(i))
{

// Select Voice Client CountDown
int selectedVoice = CookiesGetInt(i, g_CountDownCookie);

// Select Volume Client CountDown
float selectedVolume = CookiesGetFloat(i, g_ZrSoundsCookie);

if(selectedVoice == 1)
{
EmitSoundToClient(i, ContMamPath, SOUND_FROM_PLAYER, SNDCHAN_AUTO, _, _, selectedVolume);
}
if(selectedVoice == 2)
{
EmitSoundToClient(i, ContWomPath, SOUND_FROM_PLAYER, SNDCHAN_AUTO, _, _, selectedVolume);
}
if(g_iCountDownCookie[i] == 1) EmitSoundToClient(i, ContMamPath, SOUND_FROM_PLAYER, SNDCHAN_AUTO, _, _, g_fZrSoundsCookie[i]);
if(g_iCountDownCookie[i] == 2) EmitSoundToClient(i, ContWomPath, SOUND_FROM_PLAYER, SNDCHAN_AUTO, _, _, g_fZrSoundsCookie[i]);
}
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/zr_sounds/soundeffects/roundendsounds.inc
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,7 @@ void RoundEndSoundsSoundFromClient(int client, const char[] soundre, float level
{
if (IsClientInGame(client) && !IsFakeClient(client))
{
// Get Client Zrsounds
bool zrestate = CookiesGetClientCookieBool(client, g_ZRoundEndCookie);
// If client is disabled Sound, then stop.
if (zrestate)
{
// Emit sound from client.
EmitSoundToClient(client, soundre, _, SNDCHAN_AUTO, _, _, level);
}
// Emit sound from client.
if (g_bZRoundEndCookie[client]) EmitSoundToClient(client, soundre, _, SNDCHAN_AUTO, _, _, level);
}
}
12 changes: 1 addition & 11 deletions src/zr_sounds/soundeffects/soundeffects.inc
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,8 @@ void SEffectsEmitSoundFromClient(int client, const char[] sound)
{
if (IsClientInGame(i) && !IsFakeClient(i))
{
// If sound cvar level.
float level = CookiesGetFloat(i, g_ZrSoundsCookie);

// If sound cvar is disabled, then stop.
bool mutezombie = CookiesGetClientCookieBool(i, g_ZombiesECookie);

if (!mutezombie)
{
return;
}
// Emit sound from client.
EmitSoundToClient(i, sound, client, SNDCHAN_AUTO, _, _, level); // Sound Zumbie
if (g_bZombiesECookie[i]) EmitSoundToClient(i, sound, client, SNDCHAN_AUTO, _, _, g_fZrSoundsCookie[i]);
}
}
}
Loading

0 comments on commit 7e5c0d5

Please sign in to comment.