1.1 --- a/extensions/clientprefs/natives.cpp Sun Jul 13 07:01:54 2008 +0000
1.2 +++ b/extensions/clientprefs/natives.cpp Tue Jul 15 00:24:08 2008 +0000
1.3 @@ -35,6 +35,11 @@
1.4
1.5 cell_t RegClientPrefCookie(IPluginContext *pContext, const cell_t *params)
1.6 {
1.7 + if (g_ClientPrefs.Database == NULL && !g_ClientPrefs.databaseLoading)
1.8 + {
1.9 + return pContext->ThrowNativeError("Clientprefs is disabled due to a failed database connection");
1.10 + }
1.11 +
1.12 char *name;
1.13 pContext->LocalToString(params[1], &name);
1.14
1.15 @@ -62,6 +67,11 @@
1.16
1.17 cell_t FindClientPrefCookie(IPluginContext *pContext, const cell_t *params)
1.18 {
1.19 + if (g_ClientPrefs.Database == NULL && !g_ClientPrefs.databaseLoading)
1.20 + {
1.21 + return pContext->ThrowNativeError("Clientprefs is disabled due to a failed database connection");
1.22 + }
1.23 +
1.24 char *name;
1.25 pContext->LocalToString(params[1], &name);
1.26
1.27 @@ -81,6 +91,11 @@
1.28
1.29 cell_t SetClientPrefCookie(IPluginContext *pContext, const cell_t *params)
1.30 {
1.31 + if (g_ClientPrefs.Database == NULL && !g_ClientPrefs.databaseLoading)
1.32 + {
1.33 + return pContext->ThrowNativeError("Clientprefs is disabled due to a failed database connection");
1.34 + }
1.35 +
1.36 int client = params[1];
1.37
1.38 if ((client < 1) || (client > playerhelpers->GetMaxClients()))
1.39 @@ -111,6 +126,11 @@
1.40
1.41 cell_t GetClientPrefCookie(IPluginContext *pContext, const cell_t *params)
1.42 {
1.43 + if (g_ClientPrefs.Database == NULL && !g_ClientPrefs.databaseLoading)
1.44 + {
1.45 + return pContext->ThrowNativeError("Clientprefs is disabled due to a failed database connection");
1.46 + }
1.47 +
1.48 int client = params[1];
1.49
1.50 if ((client < 1) || (client > playerhelpers->GetMaxClients()))
1.51 @@ -144,6 +164,11 @@
1.52
1.53 cell_t AreClientCookiesCached(IPluginContext *pContext, const cell_t *params)
1.54 {
1.55 + if (g_ClientPrefs.Database == NULL && !g_ClientPrefs.databaseLoading)
1.56 + {
1.57 + return pContext->ThrowNativeError("Clientprefs is disabled due to a failed database connection");
1.58 + }
1.59 +
1.60 int client = params[1];
1.61
1.62 if ((client < 1) || (client > playerhelpers->GetMaxClients()))
1.63 @@ -156,6 +181,11 @@
1.64
1.65 cell_t GetCookieAccess(IPluginContext *pContext, const cell_t *params)
1.66 {
1.67 + if (g_ClientPrefs.Database == NULL && !g_ClientPrefs.databaseLoading)
1.68 + {
1.69 + return pContext->ThrowNativeError("Clientprefs is disabled due to a failed database connection");
1.70 + }
1.71 +
1.72 Handle_t hndl = static_cast<Handle_t>(params[1]);
1.73 HandleError err;
1.74 HandleSecurity sec;
1.75 @@ -176,6 +206,11 @@
1.76
1.77 static cell_t GetCookieIterator(IPluginContext *pContext, const cell_t *params)
1.78 {
1.79 + if (g_ClientPrefs.Database == NULL && !g_ClientPrefs.databaseLoading)
1.80 + {
1.81 + return pContext->ThrowNativeError("Clientprefs is disabled due to a failed database connection");
1.82 + }
1.83 +
1.84 SourceHook::List<Cookie *>::iterator *iter = new SourceHook::List<Cookie *>::iterator;
1.85 *iter = g_CookieManager.cookieList.begin();
1.86
1.87 @@ -190,6 +225,11 @@
1.88
1.89 static cell_t ReadCookieIterator(IPluginContext *pContext, const cell_t *params)
1.90 {
1.91 + if (g_ClientPrefs.Database == NULL && !g_ClientPrefs.databaseLoading)
1.92 + {
1.93 + return pContext->ThrowNativeError("Clientprefs is disabled due to a failed database connection");
1.94 + }
1.95 +
1.96 SourceHook::List<Cookie *>::iterator *iter;
1.97
1.98 Handle_t hndl = static_cast<Handle_t>(params[1]);
1.99 @@ -226,6 +266,11 @@
1.100
1.101 cell_t ShowSettingsMenu(IPluginContext *pContext, const cell_t *params)
1.102 {
1.103 + if (g_ClientPrefs.Database == NULL && !g_ClientPrefs.databaseLoading)
1.104 + {
1.105 + return pContext->ThrowNativeError("Clientprefs is disabled due to a failed database connection");
1.106 + }
1.107 +
1.108 char message[256];
1.109 Translate(message, sizeof(message), "%T:", 2, NULL, "Client Settings", ¶ms[1]);
1.110
1.111 @@ -237,6 +282,11 @@
1.112
1.113 cell_t AddSettingsMenuItem(IPluginContext *pContext, const cell_t *params)
1.114 {
1.115 + if (g_ClientPrefs.Database == NULL && !g_ClientPrefs.databaseLoading)
1.116 + {
1.117 + return pContext->ThrowNativeError("Clientprefs is disabled due to a failed database connection");
1.118 + }
1.119 +
1.120 char *display;
1.121 pContext->LocalToString(params[3], &display);
1.122
1.123 @@ -278,6 +328,11 @@
1.124
1.125 cell_t AddSettingsPrefabMenuItem(IPluginContext *pContext, const cell_t *params)
1.126 {
1.127 + if (g_ClientPrefs.Database == NULL && !g_ClientPrefs.databaseLoading)
1.128 + {
1.129 + return pContext->ThrowNativeError("Clientprefs is disabled due to a failed database connection");
1.130 + }
1.131 +
1.132 Handle_t hndl = static_cast<Handle_t>(params[1]);
1.133 HandleError err;
1.134 HandleSecurity sec;