mirror of
https://github.com/alliedmodders/sourcemod.git
synced 2025-12-07 10:28:34 +00:00
Ensure db conf lookup failures default to ..default
This commit is contained in:
parent
7674d3dae0
commit
03dc703dae
@ -119,9 +119,13 @@ void DBManager::OnHandleDestroy(HandleType_t type, void *object)
|
||||
bool DBManager::Connect(const char *name, IDBDriver **pdr, IDatabase **pdb, bool persistent, char *error, size_t maxlength)
|
||||
{
|
||||
ConfDbInfoList *list = m_Builder.GetConfigList();
|
||||
ke::RefPtr<ConfDbInfo> pInfo = list->GetDatabaseConf(name);
|
||||
|
||||
if (!pInfo)
|
||||
/* First we'll call DBManager::FindDatabaseConf to allow for
|
||||
* default fallback, then once we found our db (default or not)
|
||||
* we'll grab the ConfDbInfo from the list.
|
||||
*/
|
||||
const DatabaseInfo *dbinfo = this->FindDatabaseConf(name);
|
||||
if (!dbinfo)
|
||||
{
|
||||
if (pdr)
|
||||
{
|
||||
@ -132,6 +136,7 @@ bool DBManager::Connect(const char *name, IDBDriver **pdr, IDatabase **pdb, bool
|
||||
return false;
|
||||
}
|
||||
|
||||
ke::RefPtr<ConfDbInfo> pInfo = list->GetDatabaseConf(dbinfo->database);
|
||||
const char *dname = pInfo->info.driver;
|
||||
if (!pInfo->realDriver)
|
||||
{
|
||||
|
||||
@ -56,6 +56,7 @@ public:
|
||||
DatabaseInfo info;
|
||||
};
|
||||
|
||||
// TODO: make this a map to prevent O(n) lookups
|
||||
class ConfDbInfoList : public ke::Vector<ConfDbInfo *>
|
||||
{
|
||||
/* Allow internal usage of ConfDbInfoList */
|
||||
|
||||
@ -315,7 +315,7 @@ public:
|
||||
strncopy(dbname, _dbname, sizeof(dbname));
|
||||
me = scripts->FindPluginByContext(m_pFunction->GetParentContext()->GetContext());
|
||||
|
||||
m_pInfo = g_DBMan.GetDatabaseConf(dbname);
|
||||
m_pInfo = g_DBMan.FindDatabaseConf(dbname);
|
||||
if (!m_pInfo)
|
||||
{
|
||||
g_pSM->Format(error, sizeof(error), "Could not find database config \"%s\"", dbname);
|
||||
@ -333,7 +333,7 @@ public:
|
||||
{
|
||||
if (m_pInfo)
|
||||
{
|
||||
m_pDatabase = m_pDriver->Connect(&m_pInfo->info, false, error, sizeof(error));
|
||||
m_pDatabase = m_pDriver->Connect(m_pInfo, false, error, sizeof(error));
|
||||
}
|
||||
}
|
||||
void CancelThinkPart()
|
||||
@ -384,7 +384,7 @@ public:
|
||||
delete this;
|
||||
}
|
||||
private:
|
||||
ke::RefPtr<ConfDbInfo> m_pInfo;
|
||||
const DatabaseInfo *m_pInfo;
|
||||
IPlugin *me;
|
||||
IPluginFunction *m_pFunction;
|
||||
IDBDriver *m_pDriver;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user