From 8f06e36d04e1a5963e68c36455830424f6df3a6d Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 1 Aug 2005 20:54:41 +0000 Subject: [PATCH] fixed a few bugs --- dlls/nvault/NHash.h | 19 ++++++++++------- dlls/nvault/NVault.cpp | 1 + dlls/nvault/amxxapi.cpp | 47 +++++++++++++++++++++++++++++++++++------ 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/dlls/nvault/NHash.h b/dlls/nvault/NHash.h index c164c273..428559c1 100755 --- a/dlls/nvault/NHash.h +++ b/dlls/nvault/NHash.h @@ -141,14 +141,17 @@ public: while (n) { t = n->next; - if (start == 0 && end == 0) - _Remove(b, n); - else if (start == 0 && n->stamp < end) - _Remove(b, n); - else if (end == 0 && n->stamp > start) - _Remove(b, n); - else if (n->stamp > start && n->stamp < end) - _Remove(b, n); + if (n->stamp != 0) + { + if (start == 0 && end == 0) + _Remove(b, n); + else if (start == 0 && n->stamp < end) + _Remove(b, n); + else if (end == 0 && n->stamp > start) + _Remove(b, n); + else if (n->stamp > start && n->stamp < end) + _Remove(b, n); + } n = t; } if (!m_Size) diff --git a/dlls/nvault/NVault.cpp b/dlls/nvault/NVault.cpp index f726eda9..0f2a85e3 100755 --- a/dlls/nvault/NVault.cpp +++ b/dlls/nvault/NVault.cpp @@ -280,3 +280,4 @@ IVault *VaultMngr::OpenVault(const char *file) return static_cast(pVault); } + diff --git a/dlls/nvault/amxxapi.cpp b/dlls/nvault/amxxapi.cpp index 808215c3..7eb639de 100755 --- a/dlls/nvault/amxxapi.cpp +++ b/dlls/nvault/amxxapi.cpp @@ -26,7 +26,7 @@ static cell nvault_open(AMX *amx, cell *params) char *name = MF_GetAmxString(amx, params[1], 0, &len); char path[255], file[255]; MF_BuildPathnameR(path, sizeof(path)-1, "%s/vault", LOCALINFO("amxx_datadir")); - sprintf(file, "%s/%s.vault", path, file); + sprintf(file, "%s/%s.vault", path, name); for (size_t i=0; iGetFilename(), file) == 0) @@ -35,6 +35,11 @@ static cell nvault_open(AMX *amx, cell *params) } } NVault *v = new NVault(file); + if (!v->Open()) + { + delete v; + return -1; + } if (!g_OldVaults.empty()) { id = g_OldVaults.front(); @@ -100,15 +105,15 @@ static cell nvault_lookup(AMX *amx, cell *params) NVault *pVault = g_Vaults.at(id); int len; time_t stamp; - char *key = MF_GetAmxString(amx, params[1], 0, &len); - char *buffer = new char[params[3]+1]; - if (!pVault->GetValue(key, stamp, buffer, params[3])) + char *key = MF_GetAmxString(amx, params[2], 0, &len); + char *buffer = new char[params[4]+1]; + if (!pVault->GetValue(key, stamp, buffer, params[4])) { delete [] buffer; return 0; } - MF_SetAmxString(amx, params[2], buffer, params[3]); - cell *addr = MF_GetAmxAddr(amx, params[4]); + MF_SetAmxString(amx, params[3], buffer, params[4]); + cell *addr = MF_GetAmxAddr(amx, params[5]); addr[0] = (cell)stamp; delete [] buffer; return 1; @@ -167,6 +172,21 @@ static cell nvault_close(AMX *amx, cell *params) return 1; } +static cell AMX_NATIVE_CALL nvault_prune(AMX *amx, cell *params) +{ + unsigned int id = params[1]; + if (id >= g_Vaults.size() || !g_Vaults.at(id)) + { + MF_LogError(amx, AMX_ERR_NATIVE, "Invalid vault id: %d\n", id); + return 0; + } + NVault *pVault = g_Vaults.at(id); + time_t start = (time_t )params[2]; + time_t end = (time_t )params[3]; + + return pVault->Prune(start, end); +} + IVaultMngr *GetVaultMngr() { return static_cast(&g_VaultMngr); @@ -180,6 +200,18 @@ void OnAmxxAttach() MF_RegisterFunction(GetVaultMngr, "GetVaultMngr"); } +void ServerDeactivate_Post() +{ + for (size_t i=0; i