attempted some thread improvements[?]
fixed moduleconf bug what
This commit is contained in:
parent
7367f29cb4
commit
34f5b3257d
@ -40,22 +40,27 @@ static cell AMX_NATIVE_CALL SQL_MakeDbTuple(AMX *amx, cell *params)
|
|||||||
SQL_Connection *sql = new SQL_Connection;
|
SQL_Connection *sql = new SQL_Connection;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
char *host = strdup(MF_GetAmxString(amx, params[1], 0, &len));
|
sql->port = 0;
|
||||||
|
sql->host = strdup("");
|
||||||
|
sql->user = strdup("");
|
||||||
|
sql->pass = strdup("");
|
||||||
|
|
||||||
char *p = strchr(host, ':');
|
char *db = MF_GetAmxString(amx, params[4], 0, &len);
|
||||||
if (p)
|
char path[255];
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
MF_BuildPathnameR(path, sizeof(path)-1, "%s", db);
|
||||||
|
if ((fp=fopen(path, "rb")))
|
||||||
{
|
{
|
||||||
sql->port = atoi(p+1);
|
fclose(fp);
|
||||||
*p = '\0';
|
sql->db = strdup(path);
|
||||||
} else {
|
} else {
|
||||||
sql->port = 0;
|
MF_BuildPathnameR(path, sizeof(path)-1, "%s/sqlite3/%s.sq3",
|
||||||
|
MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"),
|
||||||
|
db);
|
||||||
|
sql->db = strdup(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
sql->host = host;
|
|
||||||
sql->user = strdup(MF_GetAmxString(amx, params[2], 0, &len));
|
|
||||||
sql->pass = strdup(MF_GetAmxString(amx, params[3], 0, &len));
|
|
||||||
sql->db = strdup(MF_GetAmxString(amx, params[4], 0, &len));
|
|
||||||
|
|
||||||
unsigned int num = MakeHandle(sql, Handle_Connection, FreeConnection);
|
unsigned int num = MakeHandle(sql, Handle_Connection, FreeConnection);
|
||||||
|
|
||||||
return num;
|
return num;
|
||||||
|
@ -19,6 +19,30 @@ int SetMysqlAffinity(AMX *amx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DirExists(const char *dir)
|
||||||
|
{
|
||||||
|
#if defined WIN32 || defined _WIN32
|
||||||
|
DWORD attr = GetFileAttributes(dir);
|
||||||
|
|
||||||
|
if (attr == INVALID_FILE_ATTRIBUTES)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (attr & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
#else
|
||||||
|
struct stat s;
|
||||||
|
|
||||||
|
if (stat(dir, &s) != 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (S_ISDIR(s.st_mode))
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void OnAmxxAttach()
|
void OnAmxxAttach()
|
||||||
{
|
{
|
||||||
MF_AddNatives(g_BaseSqlNatives);
|
MF_AddNatives(g_BaseSqlNatives);
|
||||||
@ -29,7 +53,18 @@ void OnAmxxAttach()
|
|||||||
|
|
||||||
//override any mysqlx old compat stuff
|
//override any mysqlx old compat stuff
|
||||||
MF_AddNatives(g_OldCompatNatives);
|
MF_AddNatives(g_OldCompatNatives);
|
||||||
MF_OverrideNatives(g_OldCompatNatives);
|
MF_OverrideNatives(g_OldCompatNatives, MODULE_NAME);
|
||||||
|
|
||||||
|
char path[255];
|
||||||
|
MF_BuildPathnameR(path, sizeof(path)-1, "%s/sqlite3", MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"));
|
||||||
|
if (!DirExists(path))
|
||||||
|
{
|
||||||
|
mkdir(path
|
||||||
|
#if defined __linux__
|
||||||
|
, 0775
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnAmxxDetach()
|
void OnAmxxDetach()
|
||||||
|
@ -50,6 +50,7 @@ static cell AMX_NATIVE_CALL dbi_connect(AMX *amx, cell *params)
|
|||||||
int len;
|
int len;
|
||||||
DatabaseInfo info;
|
DatabaseInfo info;
|
||||||
char *name = MF_GetAmxString(amx, params[4], 3, &len);
|
char *name = MF_GetAmxString(amx, params[4], 3, &len);
|
||||||
|
char path[255];
|
||||||
|
|
||||||
info.host = "";
|
info.host = "";
|
||||||
info.user = "";
|
info.user = "";
|
||||||
@ -58,6 +59,19 @@ static cell AMX_NATIVE_CALL dbi_connect(AMX *amx, cell *params)
|
|||||||
|
|
||||||
int err;
|
int err;
|
||||||
char error[512];
|
char error[512];
|
||||||
|
/** if there is an older database, read there instead of the new path */
|
||||||
|
MF_BuildPathnameR(path, sizeof(path)-1, "%s", info.database);
|
||||||
|
FILE *fp = fopen(path, "rb");
|
||||||
|
if (fp)
|
||||||
|
{
|
||||||
|
fclose(fp);
|
||||||
|
info.database = path;
|
||||||
|
} else {
|
||||||
|
MF_BuildPathnameR(path, sizeof(path)-1, "%s/sqlite/%s.sq3",
|
||||||
|
MF_GetLocalInfo("amxx_datadir", "addons/amxmodx/data"),
|
||||||
|
info.database);
|
||||||
|
info.database = path;
|
||||||
|
}
|
||||||
IDatabase *pDatabase = g_Sqlite.Connect(&info, &err, error, sizeof(error)-1);
|
IDatabase *pDatabase = g_Sqlite.Connect(&info, &err, error, sizeof(error)-1);
|
||||||
if (!pDatabase)
|
if (!pDatabase)
|
||||||
{
|
{
|
||||||
|
@ -2779,7 +2779,7 @@ void ValidateMacros_DontCallThis_Smiley()
|
|||||||
MF_FindLibrary(NULL, LibType_Class);
|
MF_FindLibrary(NULL, LibType_Class);
|
||||||
MF_AddLibraries(NULL, LibType_Class, NULL);
|
MF_AddLibraries(NULL, LibType_Class, NULL);
|
||||||
MF_RemoveLibraries(NULL);
|
MF_RemoveLibraries(NULL);
|
||||||
MF_OverrideNatives(NULL);
|
MF_OverrideNatives(NULL, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2179,7 +2179,7 @@ typedef void (*PFN_UNREG_AUTH_FUNC) (AUTHORIZEFUNC);
|
|||||||
typedef int (*PFN_FINDLIBRARY) (const char * /*name*/, LibType /*type*/);
|
typedef int (*PFN_FINDLIBRARY) (const char * /*name*/, LibType /*type*/);
|
||||||
typedef size_t (*PFN_ADDLIBRARIES) (const char * /*name*/, LibType /*type*/, void * /*parent*/);
|
typedef size_t (*PFN_ADDLIBRARIES) (const char * /*name*/, LibType /*type*/, void * /*parent*/);
|
||||||
typedef size_t (*PFN_REMOVELIBRARIES) (void * /*parent*/);
|
typedef size_t (*PFN_REMOVELIBRARIES) (void * /*parent*/);
|
||||||
typedef void (*PFN_OVERRIDENATIVES) (AMX_NATIVE_INFO * /*natives*/);
|
typedef void (*PFN_OVERRIDENATIVES) (AMX_NATIVE_INFO * /*natives*/, const char * /*myname*/);
|
||||||
typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char * /*def*/);
|
typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char * /*def*/);
|
||||||
typedef int (*PFN_AMX_REREGISTER) (AMX * /*amx*/, AMX_NATIVE_INFO * /*list*/, int /*list*/);
|
typedef int (*PFN_AMX_REREGISTER) (AMX * /*amx*/, AMX_NATIVE_INFO * /*list*/, int /*list*/);
|
||||||
typedef void * (*PFN_REGISTERFUNCTIONEX) (void * /*pfn*/, const char * /*desc*/);
|
typedef void * (*PFN_REGISTERFUNCTIONEX) (void * /*pfn*/, const char * /*desc*/);
|
||||||
@ -2324,7 +2324,7 @@ void MF_UnregAuthFunc (AUTHORIZEFUNC fn) { }
|
|||||||
int MF_FindLibrary (const char *name, LibType type) { }
|
int MF_FindLibrary (const char *name, LibType type) { }
|
||||||
size_t MF_AddLibraries (const char *name, LibType type, void *parent) { }
|
size_t MF_AddLibraries (const char *name, LibType type, void *parent) { }
|
||||||
size_t MF_RemoveLibraries (void *parent) { }
|
size_t MF_RemoveLibraries (void *parent) { }
|
||||||
void MF_OverrideNatives (AMX_NATIVE_INFO *natives) { }
|
void MF_OverrideNatives (AMX_NATIVE_INFO *natives, const char *myname) { }
|
||||||
const char * MF_GetLocalInfo (const char *name, const char *def) { }
|
const char * MF_GetLocalInfo (const char *name, const char *def) { }
|
||||||
int MF_AmxReRegister (AMX *amx, AMX_NATIVE_INFO *list, int number) { return 0; }
|
int MF_AmxReRegister (AMX *amx, AMX_NATIVE_INFO *list, int number) { return 0; }
|
||||||
void * MF_RegisterFunctionEx (void *pfn, const char *description) { }
|
void * MF_RegisterFunctionEx (void *pfn, const char *description) { }
|
||||||
|
@ -107,7 +107,7 @@
|
|||||||
// #define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
|
// #define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
|
||||||
// #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
|
// #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
|
||||||
// #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
|
// #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
|
||||||
// #define FN_StartFrame StartFrame /* pfnStartFrame() */
|
#define FN_StartFrame StartFrame /* pfnStartFrame() */
|
||||||
// #define FN_ParmsNewLevel ParmsNewLevel /* pfnParmsNewLevel() */
|
// #define FN_ParmsNewLevel ParmsNewLevel /* pfnParmsNewLevel() */
|
||||||
// #define FN_ParmsChangeLevel ParmsChangeLevel /* pfnParmsChangeLevel() */
|
// #define FN_ParmsChangeLevel ParmsChangeLevel /* pfnParmsChangeLevel() */
|
||||||
// #define FN_GetGameDescription GetGameDescription /* pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2" "Half-Life" */
|
// #define FN_GetGameDescription GetGameDescription /* pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2" "Half-Life" */
|
||||||
|
@ -78,7 +78,6 @@ bool SqliteQuery::ExecuteR(QueryInfo *info, char *error, size_t maxlength)
|
|||||||
data.results = results;
|
data.results = results;
|
||||||
|
|
||||||
SqliteResultSet *pRes = new SqliteResultSet(data);
|
SqliteResultSet *pRes = new SqliteResultSet(data);
|
||||||
m_LastRes = pRes;
|
|
||||||
info->rs = static_cast<IResultSet *>(pRes);
|
info->rs = static_cast<IResultSet *>(pRes);
|
||||||
} else {
|
} else {
|
||||||
info->rs = NULL;
|
info->rs = NULL;
|
||||||
|
@ -97,7 +97,7 @@ IThreadHandle *WinThreader::MakeThread(IThread *pThread, const ThreadParams *par
|
|||||||
|
|
||||||
IEventSignal *WinThreader::MakeEventSignal()
|
IEventSignal *WinThreader::MakeEventSignal()
|
||||||
{
|
{
|
||||||
HANDLE event = CreateEventA(NULL, FALSE, FALSE, NULL);
|
HANDLE event = CreateEventA(NULL, TRUE, TRUE, NULL);
|
||||||
|
|
||||||
if (!event)
|
if (!event)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -275,6 +275,7 @@ WinThreader::WinEvent::~WinEvent()
|
|||||||
void WinThreader::WinEvent::Wait()
|
void WinThreader::WinEvent::Wait()
|
||||||
{
|
{
|
||||||
WaitForSingleObject(m_event, INFINITE);
|
WaitForSingleObject(m_event, INFINITE);
|
||||||
|
ResetEvent(m_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinThreader::WinEvent::Signal()
|
void WinThreader::WinEvent::Signal()
|
||||||
|
Loading…
Reference in New Issue
Block a user