Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
84
Server/ManageTool/ManageLibrary/Db/ManageServerDB.cpp
Normal file
84
Server/ManageTool/ManageLibrary/Db/ManageServerDB.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#include "stdafx.h"
|
||||
#include "SQLite.h"
|
||||
|
||||
#include "ManageServerDB.h"
|
||||
#include <Log/ServerLog.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
const char* CManageServerDB::GetDefaultDBFileName()
|
||||
{
|
||||
return "./ManageServerDB.dat";
|
||||
}
|
||||
|
||||
|
||||
CManageServerDB& CManageServerDB::GetInstance()
|
||||
{
|
||||
static CManageServerDB manageServerDB;
|
||||
return manageServerDB;
|
||||
}
|
||||
|
||||
|
||||
CManageServerDB::CManageServerDB()
|
||||
: m_lpSQLite(new CSQLite)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
CManageServerDB::~CManageServerDB()
|
||||
{
|
||||
if(0 != m_lpSQLite)
|
||||
{
|
||||
delete m_lpSQLite;
|
||||
m_lpSQLite = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool CManageServerDB::Initialize(const char* szDBFileName)
|
||||
{
|
||||
if(0 == m_lpSQLite || !m_lpSQLite->Open(szDBFileName))
|
||||
{
|
||||
ERRLOG1(g_Log, "Cannot open database : %s", szDBFileName);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create Tables - <20>̹<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>.
|
||||
const int MAX_QUERY_NUM = 5;
|
||||
const char* szCreateTableQuery[MAX_QUERY_NUM] =
|
||||
{
|
||||
"CREATE TABLE TblManageToolUser (ID char(16) PRIMARY KEY, PASS char(16), "
|
||||
"NAME char(32), IP char(16), LEVEL INTEGER)",
|
||||
|
||||
"CREATE TABLE TblServerInfo (IP INTEGER PRIMARY KEY, ServerName char(64))",
|
||||
"CREATE TABLE TblRunPath (PathID INTEGER PRIMARY KEY, RunPath char(260))",
|
||||
"CREATE TABLE TblRunOptions (OptionID INTEGER PRIMARY KEY, RunOption char(260))",
|
||||
"CREATE TABLE TblRunInfo (RunID INTEGER PRIMARY KEY, PathID INTEGER, OptionID INTEGER, ServerIP INTEGER)"
|
||||
};
|
||||
|
||||
m_lpSQLite->SetErrorLog(false);
|
||||
|
||||
for(int nQuery = 0; nQuery < MAX_QUERY_NUM; ++nQuery)
|
||||
{
|
||||
CSQLite::Dataset createUserTable(*m_lpSQLite, szCreateTableQuery[nQuery]);
|
||||
|
||||
if(!createUserTable.Compile() || !createUserTable.Execute())
|
||||
{
|
||||
if(0 != createUserTable.GetLastError())
|
||||
{
|
||||
// Table create failed. if already create failed?
|
||||
char szTableName[MAX_PATH];
|
||||
int nLength = sscanf(createUserTable.GetLastError(), "table %s already exists", szTableName);
|
||||
if(EOF == nLength || 0 == nLength)
|
||||
{
|
||||
m_lpSQLite->SetErrorLog(true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_lpSQLite->SetErrorLog(true);
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user