generated from ClaudiuHKS/AdvancedQuakeSounds
-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgeoip_auto_update_databases.sp
56 lines (47 loc) · 1.85 KB
/
geoip_auto_update_databases.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <sourcemod>
#include <GeoResolver>
public Plugin myinfo =
{
name = "GeoResolver: Auto Database Updater" , \
author = "Hattrick HKS (claudiuhks)" , \
description = "Reloads The MaxMind® Databases During Map Change" , \
version = __DATE__ , \
url = "https://forums.alliedmods.net/showthread.php?t=267805" ,
};
public void OnMapEnd()
{
static const char szcDbFileNames[][] =
{
"GeoLite2-City.mmdb", "GeoIP2-City.mmdb",
"GeoLiteCity.dat", "GeoIPCity.dat",
"GeoLiteISP.dat", "GeoIPISP.dat",
};
static char szDataGeoResolverUpdateDirPath[PLATFORM_MAX_PATH] = { 0, ... }, szFileName[PLATFORM_MAX_PATH] = { 0, ... };
static DirectoryListing hDir = null;
static FileType nFileType = FileType_Unknown;
static int nIter = 0;
BuildPath(Path_SM, szDataGeoResolverUpdateDirPath, sizeof (szDataGeoResolverUpdateDirPath), "data/GeoResolver/Update");
if (DirExists(szDataGeoResolverUpdateDirPath))
{
hDir = OpenDirectory(szDataGeoResolverUpdateDirPath);
if (hDir)
{
while (ReadDirEntry(hDir, szFileName, sizeof (szFileName), nFileType))
{
if (nFileType == FileType_File)
{
for (nIter = 0; nIter < sizeof (szcDbFileNames); nIter++)
{
if (0 == strcmp(szFileName, szcDbFileNames[nIter], true))
{
CloseHandle(hDir);
GeoR_Reload();
return;
}
}
}
}
CloseHandle(hDir);
}
}
}