fixed a few bugs
This commit is contained in:
parent
e38b64ff82
commit
8f06e36d04
|
@ -141,14 +141,17 @@ public:
|
||||||
while (n)
|
while (n)
|
||||||
{
|
{
|
||||||
t = n->next;
|
t = n->next;
|
||||||
if (start == 0 && end == 0)
|
if (n->stamp != 0)
|
||||||
_Remove(b, n);
|
{
|
||||||
else if (start == 0 && n->stamp < end)
|
if (start == 0 && end == 0)
|
||||||
_Remove(b, n);
|
_Remove(b, n);
|
||||||
else if (end == 0 && n->stamp > start)
|
else if (start == 0 && n->stamp < end)
|
||||||
_Remove(b, n);
|
_Remove(b, n);
|
||||||
else if (n->stamp > start && n->stamp < end)
|
else if (end == 0 && n->stamp > start)
|
||||||
_Remove(b, n);
|
_Remove(b, n);
|
||||||
|
else if (n->stamp > start && n->stamp < end)
|
||||||
|
_Remove(b, n);
|
||||||
|
}
|
||||||
n = t;
|
n = t;
|
||||||
}
|
}
|
||||||
if (!m_Size)
|
if (!m_Size)
|
||||||
|
|
|
@ -280,3 +280,4 @@ IVault *VaultMngr::OpenVault(const char *file)
|
||||||
|
|
||||||
return static_cast<IVault *>(pVault);
|
return static_cast<IVault *>(pVault);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ static cell nvault_open(AMX *amx, cell *params)
|
||||||
char *name = MF_GetAmxString(amx, params[1], 0, &len);
|
char *name = MF_GetAmxString(amx, params[1], 0, &len);
|
||||||
char path[255], file[255];
|
char path[255], file[255];
|
||||||
MF_BuildPathnameR(path, sizeof(path)-1, "%s/vault", LOCALINFO("amxx_datadir"));
|
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; i<g_Vaults.size(); i++)
|
for (size_t i=0; i<g_Vaults.size(); i++)
|
||||||
{
|
{
|
||||||
if (strcmp(g_Vaults.at(i)->GetFilename(), file) == 0)
|
if (strcmp(g_Vaults.at(i)->GetFilename(), file) == 0)
|
||||||
|
@ -35,6 +35,11 @@ static cell nvault_open(AMX *amx, cell *params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
NVault *v = new NVault(file);
|
NVault *v = new NVault(file);
|
||||||
|
if (!v->Open())
|
||||||
|
{
|
||||||
|
delete v;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (!g_OldVaults.empty())
|
if (!g_OldVaults.empty())
|
||||||
{
|
{
|
||||||
id = g_OldVaults.front();
|
id = g_OldVaults.front();
|
||||||
|
@ -100,15 +105,15 @@ static cell nvault_lookup(AMX *amx, cell *params)
|
||||||
NVault *pVault = g_Vaults.at(id);
|
NVault *pVault = g_Vaults.at(id);
|
||||||
int len;
|
int len;
|
||||||
time_t stamp;
|
time_t stamp;
|
||||||
char *key = MF_GetAmxString(amx, params[1], 0, &len);
|
char *key = MF_GetAmxString(amx, params[2], 0, &len);
|
||||||
char *buffer = new char[params[3]+1];
|
char *buffer = new char[params[4]+1];
|
||||||
if (!pVault->GetValue(key, stamp, buffer, params[3]))
|
if (!pVault->GetValue(key, stamp, buffer, params[4]))
|
||||||
{
|
{
|
||||||
delete [] buffer;
|
delete [] buffer;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
MF_SetAmxString(amx, params[2], buffer, params[3]);
|
MF_SetAmxString(amx, params[3], buffer, params[4]);
|
||||||
cell *addr = MF_GetAmxAddr(amx, params[4]);
|
cell *addr = MF_GetAmxAddr(amx, params[5]);
|
||||||
addr[0] = (cell)stamp;
|
addr[0] = (cell)stamp;
|
||||||
delete [] buffer;
|
delete [] buffer;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -167,6 +172,21 @@ static cell nvault_close(AMX *amx, cell *params)
|
||||||
return 1;
|
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()
|
IVaultMngr *GetVaultMngr()
|
||||||
{
|
{
|
||||||
return static_cast<IVaultMngr *>(&g_VaultMngr);
|
return static_cast<IVaultMngr *>(&g_VaultMngr);
|
||||||
|
@ -180,6 +200,18 @@ void OnAmxxAttach()
|
||||||
MF_RegisterFunction(GetVaultMngr, "GetVaultMngr");
|
MF_RegisterFunction(GetVaultMngr, "GetVaultMngr");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerDeactivate_Post()
|
||||||
|
{
|
||||||
|
for (size_t i=0; i<g_Vaults.size(); i++)
|
||||||
|
{
|
||||||
|
if (g_Vaults[i])
|
||||||
|
delete g_Vaults[i];
|
||||||
|
}
|
||||||
|
g_Vaults.clear();
|
||||||
|
while (!g_OldVaults.empty())
|
||||||
|
g_OldVaults.pop();
|
||||||
|
}
|
||||||
|
|
||||||
AMX_NATIVE_INFO nVault_natives[] = {
|
AMX_NATIVE_INFO nVault_natives[] = {
|
||||||
{"nvault_open", nvault_open},
|
{"nvault_open", nvault_open},
|
||||||
{"nvault_get", nvault_get},
|
{"nvault_get", nvault_get},
|
||||||
|
@ -187,5 +219,6 @@ AMX_NATIVE_INFO nVault_natives[] = {
|
||||||
{"nvault_set", nvault_set},
|
{"nvault_set", nvault_set},
|
||||||
{"nvault_pset", nvault_pset},
|
{"nvault_pset", nvault_pset},
|
||||||
{"nvault_close", nvault_close},
|
{"nvault_close", nvault_close},
|
||||||
|
{"nvault_prune", nvault_prune},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user