mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 18:18:18 +00:00
Merge branch 'master' of github.com:btd/DDRace
This commit is contained in:
commit
d7cfa9f440
22
bam.lua
22
bam.lua
|
@ -16,7 +16,7 @@ config:Finalize("config.lua")
|
|||
-- data compiler
|
||||
function Script(name)
|
||||
if family == "windows" then
|
||||
return "C:\\Python27\\python.exe " .. str_replace(name, "/", "\\")
|
||||
return str_replace(name, "/", "\\")
|
||||
end
|
||||
return "python " .. name
|
||||
end
|
||||
|
@ -105,9 +105,12 @@ nethash = CHash("src/game/generated/nethash.c", "src/engine/shared/protocol.h",
|
|||
|
||||
client_link_other = {}
|
||||
client_depends = {}
|
||||
server_depends = {}
|
||||
|
||||
if family == "windows" then
|
||||
table.insert(client_depends, CopyToDirectory(".", "other\\sdl\\vc2005libs\\SDL.dll"))
|
||||
table.insert(server_depends, CopyToDirectory(".", "other\\mysql\\vc2005libs\\mysqlcppconn.dll"))
|
||||
table.insert(server_depends, CopyToDirectory(".", "other\\mysql\\vc2005libs\\libmysql.dll"))
|
||||
end
|
||||
|
||||
|
||||
|
@ -126,7 +129,7 @@ function build(settings)
|
|||
if config.compiler.driver == "cl" then
|
||||
settings.cc.flags:Add("/wd4244")
|
||||
else
|
||||
settings.cc.flags:Add("-Wall", "-fno-exceptions")
|
||||
settings.cc.flags:Add("-Wall")
|
||||
if platform == "macosx" then
|
||||
settings.cc.flags:Add("-mmacosx-version-min=10.4", "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
|
||||
settings.link.flags:Add("-mmacosx-version-min=10.4", "-isysroot /Developer/SDKs/MacOSX10.4u.sdk")
|
||||
|
@ -145,13 +148,26 @@ function build(settings)
|
|||
settings.link.frameworks:Add("AppKit")
|
||||
else
|
||||
settings.link.libs:Add("pthread")
|
||||
settings.cc.includes:Add("other/mysql/include")
|
||||
settings.cc.includes:Add("other/mysql/include/cppconn")
|
||||
if arch == "amd64" then
|
||||
settings.link.libpath:Add("other/mysql/lib64")
|
||||
else
|
||||
settings.link.libpath:Add("other/mysql/lib32")
|
||||
end
|
||||
settings.link.libs:Add("mysqlcppconn-static")
|
||||
settings.link.libs:Add("mysqlclient")
|
||||
end
|
||||
elseif family == "windows" then
|
||||
settings.link.flags:Add("/FORCE:MULTIPLE")
|
||||
settings.link.libs:Add("gdi32")
|
||||
settings.link.libs:Add("user32")
|
||||
settings.link.libs:Add("ws2_32")
|
||||
settings.link.libs:Add("ole32")
|
||||
settings.link.libs:Add("shell32")
|
||||
settings.cc.includes:Add("other/mysql/include")
|
||||
settings.link.libpath:Add("other/mysql/vc2005libs")
|
||||
settings.link.libs:Add("mysqlcppconn")
|
||||
end
|
||||
|
||||
-- compile zlib if needed
|
||||
|
@ -248,7 +264,7 @@ function build(settings)
|
|||
|
||||
-- make targets
|
||||
c = PseudoTarget("client".."_"..settings.config_name, client_exe, client_depends)
|
||||
s = PseudoTarget("server".."_"..settings.config_name, server_exe, serverlaunch)
|
||||
s = PseudoTarget("server".."_"..settings.config_name, server_exe, serverlaunch, server_depends)
|
||||
g = PseudoTarget("game".."_"..settings.config_name, client_exe, server_exe)
|
||||
|
||||
v = PseudoTarget("versionserver".."_"..settings.config_name, versionserver_exe)
|
||||
|
|
36
other/mysql/include/cppconn/build_config.h
Normal file
36
other/mysql/include/cppconn/build_config.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _SQL_BUILD_CONFIG_H_
|
||||
#define _SQL_BUILD_CONFIG_H_
|
||||
|
||||
#ifndef CPPCONN_PUBLIC_FUNC
|
||||
|
||||
#if defined(_WIN32)
|
||||
// mysqlcppconn_EXPORTS is added by cmake and defined for dynamic lib build only
|
||||
#ifdef mysqlcppconn_EXPORTS
|
||||
#define CPPCONN_PUBLIC_FUNC __declspec(dllexport)
|
||||
#else
|
||||
// this is for static build
|
||||
#ifdef CPPCONN_LIB_BUILD
|
||||
#define CPPCONN_PUBLIC_FUNC
|
||||
#else
|
||||
// this is for clients using dynamic lib
|
||||
#define CPPCONN_PUBLIC_FUNC __declspec(dllimport)
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define CPPCONN_PUBLIC_FUNC
|
||||
#endif
|
||||
|
||||
#endif //#ifndef CPPCONN_PUBLIC_FUNC
|
||||
|
||||
#endif //#ifndef _SQL_BUILD_CONFIG_H_
|
90
other/mysql/include/cppconn/config.h
Normal file
90
other/mysql/include/cppconn/config.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
/*
|
||||
Copyright 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
// libmysql defines HAVE_STRTOUL (on win), so we have to follow different pattern in definitions names
|
||||
// to avoid annoying warnings.
|
||||
|
||||
/* #undef HAVE_FUNCTION_STRTOLD */
|
||||
/* #undef HAVE_FUNCTION_STRTOLL */
|
||||
#define HAVE_FUNCTION_STRTOL 1
|
||||
/* #undef HAVE_FUNCTION_STRTOULL */
|
||||
|
||||
#define HAVE_FUNCTION_STRTOUL 1
|
||||
|
||||
/* #undef HAVE_FUNCTION_STRTOIMAX */
|
||||
/* #undef HAVE_FUNCTION_STRTOUMAX */
|
||||
|
||||
/* #undef HAVE_STDINT_H */
|
||||
/* #undef HAVE_INTTYPES_H */
|
||||
|
||||
/* #undef HAVE_INT8_T */
|
||||
/* #undef HAVE_UINT8_T */
|
||||
/* #undef HAVE_INT16_T */
|
||||
/* #undef HAVE_UINT16_T */
|
||||
/* #undef HAVE_INT32_T */
|
||||
/* #undef HAVE_UINT32_T */
|
||||
/* #undef HAVE_INT32_T */
|
||||
/* #undef HAVE_UINT32_T */
|
||||
/* #undef HAVE_INT64_T */
|
||||
/* #undef HAVE_UINT64_T */
|
||||
//#define HAVE_MS_INT8 1
|
||||
#define HAVE_MS_UINT8 1
|
||||
#define HAVE_MS_INT16 1
|
||||
#define HAVE_MS_UINT16 1
|
||||
#define HAVE_MS_INT32 1
|
||||
#define HAVE_MS_UINT32 1
|
||||
#define HAVE_MS_INT64 1
|
||||
#define HAVE_MS_UINT64 1
|
||||
|
||||
|
||||
#ifdef HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_INTTYPES_H
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#ifndef CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES
|
||||
|
||||
#ifdef HAVE_MS_INT8
|
||||
typedef __int8 int8_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MS_UINT8
|
||||
typedef unsigned __int8 uint8_t;
|
||||
#endif
|
||||
#ifdef HAVE_MS_INT16
|
||||
typedef __int16 int16_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MS_UINT16
|
||||
typedef unsigned __int16 uint16_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MS_INT32
|
||||
typedef __int32 int32_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MS_UINT32
|
||||
typedef unsigned __int32 uint32_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MS_INT64
|
||||
typedef __int64 int64_t;
|
||||
#endif
|
||||
#ifdef HAVE_MS_UINT64
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#endif
|
||||
|
||||
#endif // CPPCONN_DONT_TYPEDEF_MS_TYPES_TO_C99_TYPES
|
||||
#endif // _WIN32
|
133
other/mysql/include/cppconn/connection.h
Normal file
133
other/mysql/include/cppconn/connection.h
Normal file
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _SQL_CONNECTION_H_
|
||||
#define _SQL_CONNECTION_H_
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#include "build_config.h"
|
||||
#include "warning.h"
|
||||
|
||||
namespace sql
|
||||
{
|
||||
|
||||
typedef union _ConnectPropertyVal
|
||||
{
|
||||
struct
|
||||
{
|
||||
const char * val;
|
||||
size_t len;
|
||||
} str;
|
||||
double dval;
|
||||
long long lval;
|
||||
bool bval;
|
||||
void * pval;
|
||||
} ConnectPropertyVal;
|
||||
|
||||
|
||||
class DatabaseMetaData;
|
||||
class PreparedStatement;
|
||||
class Statement;
|
||||
|
||||
typedef enum transaction_isolation
|
||||
{
|
||||
TRANSACTION_NONE= 0,
|
||||
TRANSACTION_READ_COMMITTED,
|
||||
TRANSACTION_READ_UNCOMMITTED,
|
||||
TRANSACTION_REPEATABLE_READ,
|
||||
TRANSACTION_SERIALIZABLE
|
||||
} enum_transaction_isolation;
|
||||
|
||||
class Savepoint
|
||||
{
|
||||
/* Prevent use of these */
|
||||
Savepoint(const Savepoint &);
|
||||
void operator=(Savepoint &);
|
||||
public:
|
||||
Savepoint() {};
|
||||
virtual ~Savepoint() {};
|
||||
virtual int getSavepointId() = 0;
|
||||
|
||||
virtual std::string getSavepointName() = 0;
|
||||
};
|
||||
|
||||
|
||||
class CPPCONN_PUBLIC_FUNC Connection
|
||||
{
|
||||
/* Prevent use of these */
|
||||
Connection(const Connection &);
|
||||
void operator=(Connection &);
|
||||
public:
|
||||
|
||||
Connection() {};
|
||||
|
||||
virtual ~Connection() {};
|
||||
|
||||
virtual void clearWarnings() = 0;
|
||||
|
||||
virtual Statement *createStatement() = 0;
|
||||
|
||||
virtual void close() = 0;
|
||||
|
||||
virtual void commit() = 0;
|
||||
|
||||
virtual bool getAutoCommit() = 0;
|
||||
|
||||
virtual std::string getCatalog() = 0;
|
||||
|
||||
virtual std::string getSchema() = 0;
|
||||
|
||||
virtual std::string getClientInfo() = 0;
|
||||
|
||||
virtual void getClientOption(const std::string & optionName, void * optionValue) = 0;
|
||||
|
||||
/* virtual int getHoldability() = 0; */
|
||||
|
||||
/* virtual std::map getTypeMap() = 0; */
|
||||
|
||||
virtual DatabaseMetaData * getMetaData() = 0;
|
||||
|
||||
virtual enum_transaction_isolation getTransactionIsolation() = 0;
|
||||
|
||||
virtual const SQLWarning * getWarnings() = 0;
|
||||
|
||||
virtual bool isClosed() = 0;
|
||||
|
||||
virtual std::string nativeSQL(const std::string& sql) = 0;
|
||||
|
||||
virtual PreparedStatement * prepareStatement(const std::string& sql) = 0;
|
||||
|
||||
virtual void releaseSavepoint(Savepoint * savepoint) = 0;
|
||||
|
||||
virtual void rollback() = 0;
|
||||
|
||||
virtual void rollback(Savepoint * savepoint) = 0;
|
||||
|
||||
virtual void setAutoCommit(bool autoCommit) = 0;
|
||||
|
||||
virtual void setCatalog(const std::string& catalog) = 0;
|
||||
|
||||
virtual void setSchema(const std::string& catalog) = 0;
|
||||
|
||||
virtual sql::Connection * setClientOption(const std::string & optionName, const void * optionValue) = 0;
|
||||
|
||||
virtual Savepoint * setSavepoint(const std::string& name) = 0;
|
||||
|
||||
virtual void setTransactionIsolation(enum_transaction_isolation level) = 0;
|
||||
|
||||
/* virtual void setTypeMap(Map map) = 0; */
|
||||
};
|
||||
|
||||
} /* namespace sql */
|
||||
|
||||
#endif // _SQL_CONNECTION_H_
|
53
other/mysql/include/cppconn/datatype.h
Normal file
53
other/mysql/include/cppconn/datatype.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _SQL_DATATYPE_H_
|
||||
#define _SQL_DATATYPE_H_
|
||||
|
||||
namespace sql
|
||||
{
|
||||
|
||||
class DataType
|
||||
{
|
||||
DataType();
|
||||
public:
|
||||
enum {
|
||||
UNKNOWN = 0,
|
||||
BIT,
|
||||
TINYINT,
|
||||
SMALLINT,
|
||||
MEDIUMINT,
|
||||
INTEGER,
|
||||
BIGINT,
|
||||
REAL,
|
||||
DOUBLE,
|
||||
DECIMAL,
|
||||
NUMERIC,
|
||||
CHAR,
|
||||
BINARY,
|
||||
VARCHAR,
|
||||
VARBINARY,
|
||||
LONGVARCHAR,
|
||||
LONGVARBINARY,
|
||||
TIMESTAMP,
|
||||
DATE,
|
||||
TIME,
|
||||
YEAR,
|
||||
GEOMETRY,
|
||||
ENUM,
|
||||
SET,
|
||||
SQLNULL
|
||||
};
|
||||
};
|
||||
|
||||
} /* namespace */
|
||||
|
||||
#endif /* _SQL_DATATYPE_H_ */
|
50
other/mysql/include/cppconn/driver.h
Normal file
50
other/mysql/include/cppconn/driver.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _SQL_DRIVER_H_
|
||||
#define _SQL_DRIVER_H_
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "connection.h"
|
||||
#include "build_config.h"
|
||||
|
||||
namespace sql
|
||||
{
|
||||
|
||||
class CPPCONN_PUBLIC_FUNC Driver
|
||||
{
|
||||
protected:
|
||||
virtual ~Driver() {}
|
||||
public:
|
||||
// Attempts to make a database connection to the given URL.
|
||||
|
||||
virtual Connection * connect(const std::string& hostName, const std::string& userName, const std::string& password) = 0;
|
||||
|
||||
virtual Connection * connect(std::map< std::string, ConnectPropertyVal > & options) = 0;
|
||||
|
||||
virtual int getMajorVersion() = 0;
|
||||
|
||||
virtual int getMinorVersion() = 0;
|
||||
|
||||
virtual int getPatchVersion() = 0;
|
||||
|
||||
virtual const std::string & getName() = 0;
|
||||
};
|
||||
|
||||
} /* namespace sql */
|
||||
|
||||
extern "C"
|
||||
{
|
||||
CPPCONN_PUBLIC_FUNC sql::Driver *get_driver_instance();
|
||||
}
|
||||
|
||||
#endif /* _SQL_DRIVER_H_ */
|
120
other/mysql/include/cppconn/exception.h
Normal file
120
other/mysql/include/cppconn/exception.h
Normal file
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _SQL_EXCEPTION_H_
|
||||
#define _SQL_EXCEPTION_H_
|
||||
|
||||
#include "build_config.h"
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace sql
|
||||
{
|
||||
|
||||
#define MEMORY_ALLOC_OPERATORS(Class) \
|
||||
void* operator new(size_t size) throw (std::bad_alloc) { return ::operator new(size); } \
|
||||
void* operator new(size_t, void*) throw(); \
|
||||
void* operator new(size_t, const std::nothrow_t&) throw(); \
|
||||
void* operator new[](size_t) throw (std::bad_alloc); \
|
||||
void* operator new[](size_t, void*) throw(); \
|
||||
void* operator new[](size_t, const std::nothrow_t&) throw(); \
|
||||
void* operator new(size_t N, std::allocator<Class>&); \
|
||||
virtual SQLException* copy() { return new Class(*this); }
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning (disable : 4290)
|
||||
//warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable: 4275)
|
||||
#endif
|
||||
class CPPCONN_PUBLIC_FUNC SQLException : public std::runtime_error
|
||||
{
|
||||
#ifdef _WIN32
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
protected:
|
||||
const std::string sql_state;
|
||||
const int errNo;
|
||||
|
||||
public:
|
||||
SQLException(const SQLException& e) : std::runtime_error(e.what()), sql_state(e.sql_state), errNo(e.errNo) {}
|
||||
|
||||
SQLException(const std::string& reason, const std::string& SQLState, int vendorCode) :
|
||||
std::runtime_error (reason ),
|
||||
sql_state (SQLState ),
|
||||
errNo (vendorCode)
|
||||
{}
|
||||
|
||||
SQLException(const std::string& reason, const std::string& SQLState) : std::runtime_error(reason), sql_state(SQLState), errNo(0) {}
|
||||
|
||||
SQLException(const std::string& reason) : std::runtime_error(reason), sql_state("HY000"), errNo(0) {}
|
||||
|
||||
SQLException() : std::runtime_error(""), sql_state("HY000"), errNo(0) {}
|
||||
|
||||
const char * getSQLState() const
|
||||
{
|
||||
return sql_state.c_str();
|
||||
}
|
||||
|
||||
int getErrorCode() const
|
||||
{
|
||||
return errNo;
|
||||
}
|
||||
|
||||
virtual ~SQLException() throw () {};
|
||||
|
||||
protected:
|
||||
MEMORY_ALLOC_OPERATORS(SQLException)
|
||||
};
|
||||
|
||||
struct CPPCONN_PUBLIC_FUNC MethodNotImplementedException : public SQLException
|
||||
{
|
||||
MethodNotImplementedException(const MethodNotImplementedException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
|
||||
MethodNotImplementedException(const std::string& reason) : SQLException(reason, "", 0) {}
|
||||
|
||||
private:
|
||||
virtual SQLException* copy() { return new MethodNotImplementedException(*this); }
|
||||
};
|
||||
|
||||
struct CPPCONN_PUBLIC_FUNC InvalidArgumentException : public SQLException
|
||||
{
|
||||
InvalidArgumentException(const InvalidArgumentException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
|
||||
InvalidArgumentException(const std::string& reason) : SQLException(reason, "", 0) {}
|
||||
|
||||
private:
|
||||
virtual SQLException* copy() { return new InvalidArgumentException(*this); }
|
||||
};
|
||||
|
||||
struct CPPCONN_PUBLIC_FUNC InvalidInstanceException : public SQLException
|
||||
{
|
||||
InvalidInstanceException(const InvalidInstanceException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
|
||||
InvalidInstanceException(const std::string& reason) : SQLException(reason, "", 0) {}
|
||||
|
||||
private:
|
||||
virtual SQLException* copy() { return new InvalidInstanceException(*this); }
|
||||
};
|
||||
|
||||
|
||||
struct CPPCONN_PUBLIC_FUNC NonScrollableException : public SQLException
|
||||
{
|
||||
NonScrollableException(const NonScrollableException& e) : SQLException(e.what(), e.sql_state, e.errNo) { }
|
||||
NonScrollableException(const std::string& reason) : SQLException(reason, "", 0) {}
|
||||
|
||||
private:
|
||||
virtual SQLException* copy() { return new NonScrollableException(*this); }
|
||||
};
|
||||
|
||||
} /* namespace sql */
|
||||
|
||||
#endif /* _SQL_EXCEPTION_H_ */
|
450
other/mysql/include/cppconn/metadata.h
Normal file
450
other/mysql/include/cppconn/metadata.h
Normal file
|
@ -0,0 +1,450 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _SQL_METADATA_H_
|
||||
#define _SQL_METADATA_H_
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include "datatype.h"
|
||||
|
||||
namespace sql
|
||||
{
|
||||
class ResultSet;
|
||||
|
||||
class DatabaseMetaData
|
||||
{
|
||||
protected:
|
||||
virtual ~DatabaseMetaData() {}
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
attributeNoNulls = 0,
|
||||
attributeNullable,
|
||||
attributeNullableUnknown
|
||||
};
|
||||
enum
|
||||
{
|
||||
bestRowTemporary = 0,
|
||||
bestRowTransaction,
|
||||
bestRowSession
|
||||
};
|
||||
enum
|
||||
{
|
||||
bestRowUnknown = 0,
|
||||
bestRowNotPseudo,
|
||||
bestRowPseudo
|
||||
};
|
||||
enum
|
||||
{
|
||||
columnNoNulls = 0,
|
||||
columnNullable,
|
||||
columnNullableUnknown
|
||||
};
|
||||
enum
|
||||
{
|
||||
importedKeyCascade = 0,
|
||||
importedKeyInitiallyDeferred,
|
||||
importedKeyInitiallyImmediate,
|
||||
importedKeyNoAction,
|
||||
importedKeyNotDeferrable,
|
||||
importedKeyRestrict,
|
||||
importedKeySetDefault,
|
||||
importedKeySetNull
|
||||
};
|
||||
enum
|
||||
{
|
||||
procedureColumnIn = 0,
|
||||
procedureColumnInOut,
|
||||
procedureColumnOut,
|
||||
procedureColumnResult,
|
||||
procedureColumnReturn,
|
||||
procedureColumnUnknown,
|
||||
procedureNoNulls,
|
||||
procedureNoResult,
|
||||
procedureNullable,
|
||||
procedureNullableUnknown,
|
||||
procedureResultUnknown,
|
||||
procedureReturnsResult
|
||||
};
|
||||
enum
|
||||
{
|
||||
sqlStateSQL99 = 0,
|
||||
sqlStateXOpen
|
||||
};
|
||||
enum
|
||||
{
|
||||
tableIndexClustered = 0,
|
||||
tableIndexHashed,
|
||||
tableIndexOther,
|
||||
tableIndexStatistic
|
||||
};
|
||||
enum
|
||||
{
|
||||
versionColumnUnknown = 0,
|
||||
versionColumnNotPseudo = 1,
|
||||
versionColumnPseudo = 2
|
||||
};
|
||||
enum
|
||||
{
|
||||
typeNoNulls = 0,
|
||||
typeNullable = 1,
|
||||
typeNullableUnknown = 2
|
||||
};
|
||||
enum
|
||||
{
|
||||
typePredNone = 0,
|
||||
typePredChar = 1,
|
||||
typePredBasic= 2,
|
||||
typeSearchable = 3
|
||||
};
|
||||
|
||||
|
||||
virtual bool allProceduresAreCallable() = 0;
|
||||
|
||||
virtual bool allTablesAreSelectable() = 0;
|
||||
|
||||
virtual bool dataDefinitionCausesTransactionCommit() = 0;
|
||||
|
||||
virtual bool dataDefinitionIgnoredInTransactions() = 0;
|
||||
|
||||
virtual bool deletesAreDetected(int type) = 0;
|
||||
|
||||
virtual bool doesMaxRowSizeIncludeBlobs() = 0;
|
||||
|
||||
virtual ResultSet * getAttributes(const std::string& catalog, const std::string& schemaPattern, const std::string& typeNamePattern, const std::string& attributeNamePattern) = 0;
|
||||
|
||||
virtual ResultSet * getBestRowIdentifier(const std::string& catalog, const std::string& schema, const std::string& table, int scope, bool nullable) = 0;
|
||||
|
||||
virtual ResultSet * getCatalogs() = 0;
|
||||
|
||||
virtual const std::string& getCatalogSeparator() = 0;
|
||||
|
||||
virtual const std::string& getCatalogTerm() = 0;
|
||||
|
||||
virtual ResultSet * getColumnPrivileges(const std::string& catalog, const std::string& schema, const std::string& table, const std::string& columnNamePattern) = 0;
|
||||
|
||||
virtual ResultSet * getColumns(const std::string& catalog, const std::string& schemaPattern, const std::string& tableNamePattern, const std::string& columnNamePattern) = 0;
|
||||
|
||||
virtual Connection * getConnection() = 0;
|
||||
|
||||
virtual ResultSet * getCrossReference(const std::string& primaryCatalog, const std::string& primarySchema, const std::string& primaryTable, const std::string& foreignCatalog, const std::string& foreignSchema, const std::string& foreignTable) = 0;
|
||||
|
||||
virtual unsigned int getDatabaseMajorVersion() = 0;
|
||||
|
||||
virtual unsigned int getDatabaseMinorVersion() = 0;
|
||||
|
||||
virtual unsigned int getDatabasePatchVersion() = 0;
|
||||
|
||||
virtual const std::string& getDatabaseProductName() = 0;
|
||||
|
||||
virtual std::string getDatabaseProductVersion() = 0;
|
||||
|
||||
virtual int getDefaultTransactionIsolation() = 0;
|
||||
|
||||
virtual unsigned int getDriverMajorVersion() = 0;
|
||||
|
||||
virtual unsigned int getDriverMinorVersion() = 0;
|
||||
|
||||
virtual unsigned int getDriverPatchVersion() = 0;
|
||||
|
||||
virtual const std::string& getDriverName() = 0;
|
||||
|
||||
virtual const std::string& getDriverVersion() = 0;
|
||||
|
||||
virtual ResultSet * getExportedKeys(const std::string& catalog, const std::string& schema, const std::string& table) = 0;
|
||||
|
||||
virtual const std::string& getExtraNameCharacters() = 0;
|
||||
|
||||
virtual const std::string& getIdentifierQuoteString() = 0;
|
||||
|
||||
virtual ResultSet * getImportedKeys(const std::string& catalog, const std::string& schema, const std::string& table) = 0;
|
||||
|
||||
virtual ResultSet * getIndexInfo(const std::string& catalog, const std::string& schema, const std::string& table, bool unique, bool approximate) = 0;
|
||||
|
||||
virtual unsigned int getCDBCMajorVersion() = 0;
|
||||
|
||||
virtual unsigned int getCDBCMinorVersion() = 0;
|
||||
|
||||
virtual unsigned int getMaxBinaryLiteralLength() = 0;
|
||||
|
||||
virtual unsigned int getMaxCatalogNameLength() = 0;
|
||||
|
||||
virtual unsigned int getMaxCharLiteralLength() = 0;
|
||||
|
||||
virtual unsigned int getMaxColumnNameLength() = 0;
|
||||
|
||||
virtual unsigned int getMaxColumnsInGroupBy() = 0;
|
||||
|
||||
virtual unsigned int getMaxColumnsInIndex() = 0;
|
||||
|
||||
virtual unsigned int getMaxColumnsInOrderBy() = 0;
|
||||
|
||||
virtual unsigned int getMaxColumnsInSelect() = 0;
|
||||
|
||||
virtual unsigned int getMaxColumnsInTable() = 0;
|
||||
|
||||
virtual unsigned int getMaxConnections() = 0;
|
||||
|
||||
virtual unsigned int getMaxCursorNameLength() = 0;
|
||||
|
||||
virtual unsigned int getMaxIndexLength() = 0;
|
||||
|
||||
virtual unsigned int getMaxProcedureNameLength() = 0;
|
||||
|
||||
virtual unsigned int getMaxRowSize() = 0;
|
||||
|
||||
virtual unsigned int getMaxSchemaNameLength() = 0;
|
||||
|
||||
virtual unsigned int getMaxStatementLength() = 0;
|
||||
|
||||
virtual unsigned int getMaxStatements() = 0;
|
||||
|
||||
virtual unsigned int getMaxTableNameLength() = 0;
|
||||
|
||||
virtual unsigned int getMaxTablesInSelect() = 0;
|
||||
|
||||
virtual unsigned int getMaxUserNameLength() = 0;
|
||||
|
||||
virtual const std::string& getNumericFunctions() = 0;
|
||||
|
||||
virtual ResultSet * getPrimaryKeys(const std::string& catalog, const std::string& schema, const std::string& table) = 0;
|
||||
|
||||
virtual ResultSet * getProcedures(const std::string& catalog, const std::string& schemaPattern, const std::string& procedureNamePattern) = 0;
|
||||
|
||||
virtual const std::string& getProcedureTerm() = 0;
|
||||
|
||||
virtual int getResultSetHoldability() = 0;
|
||||
|
||||
virtual ResultSet * getSchemas() = 0;
|
||||
|
||||
virtual const std::string& getSchemaTerm() = 0;
|
||||
|
||||
virtual const std::string& getSearchStringEscape() = 0;
|
||||
|
||||
virtual const std::string& getSQLKeywords() = 0;
|
||||
|
||||
virtual int getSQLStateType() = 0;
|
||||
|
||||
virtual const std::string& getStringFunctions() = 0;
|
||||
|
||||
virtual ResultSet * getSuperTables(const std::string& catalog, const std::string& schemaPattern, const std::string& tableNamePattern) = 0;
|
||||
|
||||
virtual ResultSet * getSuperTypes(const std::string& catalog, const std::string& schemaPattern, const std::string& typeNamePattern) = 0;
|
||||
|
||||
virtual const std::string& getSystemFunctions() = 0;
|
||||
|
||||
virtual ResultSet * getTablePrivileges(const std::string& catalog, const std::string& schemaPattern, const std::string& tableNamePattern) = 0;
|
||||
|
||||
virtual ResultSet * getTables(const std::string& catalog, const std::string& schemaPattern, const std::string& tableNamePattern, std::list<std::string> &types) = 0;
|
||||
|
||||
virtual ResultSet * getTableTypes() = 0;
|
||||
|
||||
virtual const std::string& getTimeDateFunctions() = 0;
|
||||
|
||||
virtual ResultSet * getTypeInfo() = 0;
|
||||
|
||||
virtual ResultSet * getUDTs(const std::string& catalog, const std::string& schemaPattern, const std::string& typeNamePattern, std::list<int> &types) = 0;
|
||||
|
||||
virtual std::string getUserName() = 0;
|
||||
|
||||
virtual ResultSet * getVersionColumns(const std::string& catalog, const std::string& schema, const std::string& table) = 0;
|
||||
|
||||
virtual bool insertsAreDetected(int type) = 0;
|
||||
|
||||
virtual bool isCatalogAtStart() = 0;
|
||||
|
||||
virtual bool isReadOnly() = 0;
|
||||
|
||||
virtual bool nullPlusNonNullIsNull() = 0;
|
||||
|
||||
virtual bool nullsAreSortedAtEnd() = 0;
|
||||
|
||||
virtual bool nullsAreSortedAtStart() = 0;
|
||||
|
||||
virtual bool nullsAreSortedHigh() = 0;
|
||||
|
||||
virtual bool nullsAreSortedLow() = 0;
|
||||
|
||||
virtual bool othersDeletesAreVisible(int type) = 0;
|
||||
|
||||
virtual bool othersInsertsAreVisible(int type) = 0;
|
||||
|
||||
virtual bool othersUpdatesAreVisible(int type) = 0;
|
||||
|
||||
virtual bool ownDeletesAreVisible(int type) = 0;
|
||||
|
||||
virtual bool ownInsertsAreVisible(int type) = 0;
|
||||
|
||||
virtual bool ownUpdatesAreVisible(int type) = 0;
|
||||
|
||||
virtual bool storesLowerCaseIdentifiers() = 0;
|
||||
|
||||
virtual bool storesLowerCaseQuotedIdentifiers() = 0;
|
||||
|
||||
virtual bool storesMixedCaseIdentifiers() = 0;
|
||||
|
||||
virtual bool storesMixedCaseQuotedIdentifiers() = 0;
|
||||
|
||||
virtual bool storesUpperCaseIdentifiers() = 0;
|
||||
|
||||
virtual bool storesUpperCaseQuotedIdentifiers() = 0;
|
||||
|
||||
virtual bool supportsAlterTableWithAddColumn() = 0;
|
||||
|
||||
virtual bool supportsAlterTableWithDropColumn() = 0;
|
||||
|
||||
virtual bool supportsANSI92EntryLevelSQL() = 0;
|
||||
|
||||
virtual bool supportsANSI92FullSQL() = 0;
|
||||
|
||||
virtual bool supportsANSI92IntermediateSQL() = 0;
|
||||
|
||||
virtual bool supportsBatchUpdates() = 0;
|
||||
|
||||
virtual bool supportsCatalogsInDataManipulation() = 0;
|
||||
|
||||
virtual bool supportsCatalogsInIndexDefinitions() = 0;
|
||||
|
||||
virtual bool supportsCatalogsInPrivilegeDefinitions() = 0;
|
||||
|
||||
virtual bool supportsCatalogsInProcedureCalls() = 0;
|
||||
|
||||
virtual bool supportsCatalogsInTableDefinitions() = 0;
|
||||
|
||||
virtual bool supportsColumnAliasing() = 0;
|
||||
|
||||
virtual bool supportsConvert() = 0;
|
||||
|
||||
virtual bool supportsConvert(int fromType, int toType) = 0;
|
||||
|
||||
virtual bool supportsCoreSQLGrammar() = 0;
|
||||
|
||||
virtual bool supportsCorrelatedSubqueries() = 0;
|
||||
|
||||
virtual bool supportsDataDefinitionAndDataManipulationTransactions() = 0;
|
||||
|
||||
virtual bool supportsDataManipulationTransactionsOnly() = 0;
|
||||
|
||||
virtual bool supportsDifferentTableCorrelationNames() = 0;
|
||||
|
||||
virtual bool supportsExpressionsInOrderBy() = 0;
|
||||
|
||||
virtual bool supportsExtendedSQLGrammar() = 0;
|
||||
|
||||
virtual bool supportsFullOuterJoins() = 0;
|
||||
|
||||
virtual bool supportsGetGeneratedKeys() = 0;
|
||||
|
||||
virtual bool supportsGroupBy() = 0;
|
||||
|
||||
virtual bool supportsGroupByBeyondSelect() = 0;
|
||||
|
||||
virtual bool supportsGroupByUnrelated() = 0;
|
||||
|
||||
virtual bool supportsLikeEscapeClause() = 0;
|
||||
|
||||
virtual bool supportsLimitedOuterJoins() = 0;
|
||||
|
||||
virtual bool supportsMinimumSQLGrammar() = 0;
|
||||
|
||||
virtual bool supportsMixedCaseIdentifiers() = 0;
|
||||
|
||||
virtual bool supportsMixedCaseQuotedIdentifiers() = 0;
|
||||
|
||||
virtual bool supportsMultipleOpenResults() = 0;
|
||||
|
||||
virtual bool supportsMultipleResultSets() = 0;
|
||||
|
||||
virtual bool supportsMultipleTransactions() = 0;
|
||||
|
||||
virtual bool supportsNamedParameters() = 0;
|
||||
|
||||
virtual bool supportsNonNullableColumns() = 0;
|
||||
|
||||
virtual bool supportsOpenCursorsAcrossCommit() = 0;
|
||||
|
||||
virtual bool supportsOpenCursorsAcrossRollback() = 0;
|
||||
|
||||
virtual bool supportsOpenStatementsAcrossCommit() = 0;
|
||||
|
||||
virtual bool supportsOpenStatementsAcrossRollback() = 0;
|
||||
|
||||
virtual bool supportsOrderByUnrelated() = 0;
|
||||
|
||||
virtual bool supportsOuterJoins() = 0;
|
||||
|
||||
virtual bool supportsPositionedDelete() = 0;
|
||||
|
||||
virtual bool supportsPositionedUpdate() = 0;
|
||||
|
||||
virtual bool supportsResultSetHoldability(int holdability) = 0;
|
||||
|
||||
virtual bool supportsResultSetType(int type) = 0;
|
||||
|
||||
virtual bool supportsSavepoints() = 0;
|
||||
|
||||
virtual bool supportsSchemasInDataManipulation() = 0;
|
||||
|
||||
virtual bool supportsSchemasInIndexDefinitions() = 0;
|
||||
|
||||
virtual bool supportsSchemasInPrivilegeDefinitions() = 0;
|
||||
|
||||
virtual bool supportsSchemasInProcedureCalls() = 0;
|
||||
|
||||
virtual bool supportsSchemasInTableDefinitions() = 0;
|
||||
|
||||
virtual bool supportsSelectForUpdate() = 0;
|
||||
|
||||
virtual bool supportsStatementPooling() = 0;
|
||||
|
||||
virtual bool supportsStoredProcedures() = 0;
|
||||
|
||||
virtual bool supportsSubqueriesInComparisons() = 0;
|
||||
|
||||
virtual bool supportsSubqueriesInExists() = 0;
|
||||
|
||||
virtual bool supportsSubqueriesInIns() = 0;
|
||||
|
||||
virtual bool supportsSubqueriesInQuantifieds() = 0;
|
||||
|
||||
virtual bool supportsTableCorrelationNames() = 0;
|
||||
|
||||
virtual bool supportsTransactionIsolationLevel(int level) = 0;
|
||||
|
||||
virtual bool supportsTransactions() = 0;
|
||||
|
||||
virtual bool supportsTypeConversion() = 0; /* SDBC */
|
||||
|
||||
virtual bool supportsUnion() = 0;
|
||||
|
||||
virtual bool supportsUnionAll() = 0;
|
||||
|
||||
virtual bool updatesAreDetected(int type) = 0;
|
||||
|
||||
virtual bool usesLocalFilePerTable() = 0;
|
||||
|
||||
virtual bool usesLocalFiles() = 0;
|
||||
|
||||
virtual ResultSet *getSchemata(const std::string& catalogName = "") = 0;
|
||||
|
||||
virtual ResultSet *getSchemaObjects(const std::string& catalogName = "",
|
||||
const std::string& schemaName = "",
|
||||
const std::string& objectType = "") = 0;
|
||||
|
||||
virtual ResultSet *getSchemaObjectTypes() = 0;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace sql */
|
||||
|
||||
#endif /* _SQL_METADATA_H_ */
|
46
other/mysql/include/cppconn/parameter_metadata.h
Normal file
46
other/mysql/include/cppconn/parameter_metadata.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _SQL_PARAMETER_METADATA_H_
|
||||
#define _SQL_PARAMETER_METADATA_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
namespace sql
|
||||
{
|
||||
|
||||
class ParameterMetaData
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
parameterModeIn,
|
||||
parameterModeInOut,
|
||||
parameterModeOut,
|
||||
parameterModeUnknown
|
||||
};
|
||||
enum
|
||||
{
|
||||
parameterNoNulls,
|
||||
parameterNullable,
|
||||
parameterNullableUnknown
|
||||
};
|
||||
|
||||
virtual int getParameterCount() = 0;
|
||||
protected:
|
||||
virtual ~ParameterMetaData() {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace sql */
|
||||
|
||||
#endif /* _SQL_PARAMETER_METADATA_H_ */
|
76
other/mysql/include/cppconn/prepared_statement.h
Normal file
76
other/mysql/include/cppconn/prepared_statement.h
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SQL_PREPARED_STATEMENT_H_
|
||||
#define _SQL_PREPARED_STATEMENT_H_
|
||||
|
||||
#include <iostream>
|
||||
#include "statement.h"
|
||||
|
||||
|
||||
namespace sql
|
||||
{
|
||||
|
||||
class Connection;
|
||||
class ResultSet;
|
||||
class ResultSetMetaData;
|
||||
class ParameterMetaData;
|
||||
|
||||
class PreparedStatement : public Statement
|
||||
{
|
||||
public:
|
||||
virtual ~PreparedStatement() {}
|
||||
|
||||
virtual void clearParameters() = 0;
|
||||
|
||||
virtual bool execute(const std::string& sql) = 0;
|
||||
virtual bool execute() = 0;
|
||||
|
||||
virtual ResultSet *executeQuery(const std::string& sql) = 0;
|
||||
virtual ResultSet *executeQuery() = 0;
|
||||
|
||||
virtual int executeUpdate(const std::string& sql) = 0;
|
||||
virtual int executeUpdate() = 0;
|
||||
|
||||
virtual ResultSetMetaData * getMetaData() = 0;
|
||||
|
||||
virtual ParameterMetaData * getParameterMetaData() = 0;
|
||||
|
||||
virtual void setBigInt(unsigned int parameterIndex, const std::string& value) = 0;
|
||||
|
||||
virtual void setBlob(unsigned int parameterIndex, std::istream * blob) = 0;
|
||||
|
||||
virtual void setBoolean(unsigned int parameterIndex, bool value) = 0;
|
||||
|
||||
virtual void setDateTime(unsigned int parameterIndex, const std::string& value) = 0;
|
||||
|
||||
virtual void setDouble(unsigned int parameterIndex, double value) = 0;
|
||||
|
||||
virtual void setInt(unsigned int parameterIndex, int32_t value) = 0;
|
||||
|
||||
virtual void setUInt(unsigned int parameterIndex, uint32_t value) = 0;
|
||||
|
||||
virtual void setInt64(unsigned int parameterIndex, int64_t value) = 0;
|
||||
|
||||
virtual void setUInt64(unsigned int parameterIndex, uint64_t value) = 0;
|
||||
|
||||
virtual void setNull(unsigned int parameterIndex, int sqlType) = 0;
|
||||
|
||||
virtual void setString(unsigned int parameterIndex, const std::string& value) = 0;
|
||||
|
||||
virtual PreparedStatement * setResultSetType(sql::ResultSet::enum_type type) = 0;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace sql */
|
||||
|
||||
#endif /* _SQL_PREPARED_STATEMENT_H_ */
|
139
other/mysql/include/cppconn/resultset.h
Normal file
139
other/mysql/include/cppconn/resultset.h
Normal file
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _SQL_RESULTSET_H_
|
||||
#define _SQL_RESULTSET_H_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#if defined(__LINUX__) || defined(__linux__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__GNU__) || defined(__gnu__) || defined(MACOSX) || defined(__APPLE__) || defined(__DARWIN__) || defined(__sun)
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include "resultset_metadata.h"
|
||||
|
||||
|
||||
namespace sql
|
||||
{
|
||||
|
||||
class Statement;
|
||||
|
||||
class RowID
|
||||
{
|
||||
public:
|
||||
virtual ~RowID() {}
|
||||
};
|
||||
|
||||
class ResultSet
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
CLOSE_CURSORS_AT_COMMIT,
|
||||
HOLD_CURSORS_OVER_COMMIT
|
||||
};
|
||||
enum
|
||||
{
|
||||
CONCUR_READ_ONLY,
|
||||
CONCUR_UPDATABLE
|
||||
};
|
||||
enum
|
||||
{
|
||||
FETCH_FORWARD,
|
||||
FETCH_REVERSE,
|
||||
FETCH_UNKNOWN
|
||||
};
|
||||
typedef enum
|
||||
{
|
||||
TYPE_FORWARD_ONLY,
|
||||
TYPE_SCROLL_INSENSITIVE,
|
||||
TYPE_SCROLL_SENSITIVE
|
||||
} enum_type;
|
||||
|
||||
virtual ~ResultSet() {}
|
||||
|
||||
virtual bool absolute(int row) = 0;
|
||||
|
||||
virtual void afterLast() = 0;
|
||||
|
||||
virtual void beforeFirst() = 0;
|
||||
|
||||
virtual void close() = 0;
|
||||
|
||||
virtual uint32_t findColumn(const std::string& columnLabel) const = 0;
|
||||
|
||||
virtual bool first() = 0;
|
||||
|
||||
virtual std::istream * getBlob(uint32_t columnIndex) const = 0;
|
||||
virtual std::istream * getBlob(const std::string& columnLabel) const = 0;
|
||||
|
||||
virtual bool getBoolean(uint32_t columnIndex) const = 0;
|
||||
virtual bool getBoolean(const std::string& columnLabel) const = 0;
|
||||
|
||||
virtual long double getDouble(uint32_t columnIndex) const = 0;
|
||||
virtual long double getDouble(const std::string& columnLabel) const = 0;
|
||||
|
||||
virtual int32_t getInt(uint32_t columnIndex) const = 0;
|
||||
virtual int32_t getInt(const std::string& columnLabel) const = 0;
|
||||
|
||||
virtual uint32_t getUInt(uint32_t columnIndex) const = 0;
|
||||
virtual uint32_t getUInt(const std::string& columnLabel) const = 0;
|
||||
|
||||
virtual int64_t getInt64(uint32_t columnIndex) const = 0;
|
||||
virtual int64_t getInt64(const std::string& columnLabel) const = 0;
|
||||
|
||||
virtual uint64_t getUInt64(uint32_t columnIndex) const = 0;
|
||||
virtual uint64_t getUInt64(const std::string& columnLabel) const = 0;
|
||||
|
||||
virtual ResultSetMetaData * getMetaData() const = 0;
|
||||
|
||||
virtual size_t getRow() const = 0;
|
||||
|
||||
virtual const Statement * getStatement() const = 0;
|
||||
|
||||
virtual std::string getString(uint32_t columnIndex) const = 0;
|
||||
virtual std::string getString(const std::string& columnLabel) const = 0;
|
||||
|
||||
virtual enum_type getType() const = 0;
|
||||
|
||||
virtual bool isAfterLast() const = 0;
|
||||
|
||||
virtual bool isBeforeFirst() const = 0;
|
||||
|
||||
virtual bool isClosed() const = 0;
|
||||
|
||||
virtual bool isFirst() const = 0;
|
||||
|
||||
virtual bool isLast() const = 0;
|
||||
|
||||
virtual bool isNull(uint32_t columnIndex) const = 0;
|
||||
virtual bool isNull(const std::string& columnLabel) const = 0;
|
||||
|
||||
virtual bool last() = 0;
|
||||
|
||||
virtual bool next() = 0;
|
||||
|
||||
virtual bool previous() = 0;
|
||||
|
||||
virtual bool relative(int rows) = 0;
|
||||
|
||||
virtual size_t rowsCount() const = 0;
|
||||
|
||||
virtual bool wasNull() const = 0;
|
||||
};
|
||||
|
||||
} /* namespace sql */
|
||||
|
||||
#endif /* _SQL_RESULTSET_H_ */
|
80
other/mysql/include/cppconn/resultset_metadata.h
Normal file
80
other/mysql/include/cppconn/resultset_metadata.h
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _SQL_RESULTSET_METADATA_H_
|
||||
#define _SQL_RESULTSET_METADATA_H_
|
||||
|
||||
#include <string>
|
||||
#include "datatype.h"
|
||||
|
||||
namespace sql
|
||||
{
|
||||
|
||||
class ResultSetMetaData
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
columnNoNulls,
|
||||
columnNullable,
|
||||
columnNullableUnknown
|
||||
};
|
||||
|
||||
virtual std::string getCatalogName(unsigned int column) = 0;
|
||||
|
||||
virtual unsigned int getColumnCount() = 0;
|
||||
|
||||
virtual unsigned int getColumnDisplaySize(unsigned int column) = 0;
|
||||
|
||||
virtual std::string getColumnLabel(unsigned int column) = 0;
|
||||
|
||||
virtual std::string getColumnName(unsigned int column) = 0;
|
||||
|
||||
virtual int getColumnType(unsigned int column) = 0;
|
||||
|
||||
virtual std::string getColumnTypeName(unsigned int column) = 0;
|
||||
|
||||
virtual unsigned int getPrecision(unsigned int column) = 0;
|
||||
|
||||
virtual unsigned int getScale(unsigned int column) = 0;
|
||||
|
||||
virtual std::string getSchemaName(unsigned int column) = 0;
|
||||
|
||||
virtual std::string getTableName(unsigned int column) = 0;
|
||||
|
||||
virtual bool isAutoIncrement(unsigned int column) = 0;
|
||||
|
||||
virtual bool isCaseSensitive(unsigned int column) = 0;
|
||||
|
||||
virtual bool isCurrency(unsigned int column) = 0;
|
||||
|
||||
virtual bool isDefinitelyWritable(unsigned int column) = 0;
|
||||
|
||||
virtual int isNullable(unsigned int column) = 0;
|
||||
|
||||
virtual bool isReadOnly(unsigned int column) = 0;
|
||||
|
||||
virtual bool isSearchable(unsigned int column) = 0;
|
||||
|
||||
virtual bool isSigned(unsigned int column) = 0;
|
||||
|
||||
virtual bool isWritable(unsigned int column) = 0;
|
||||
|
||||
virtual bool isZerofill(unsigned int column) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~ResultSetMetaData() {}
|
||||
};
|
||||
|
||||
|
||||
} /* namespace sql */
|
||||
|
||||
#endif /* _SQL_RESULTSET_METADATA_H_ */
|
60
other/mysql/include/cppconn/statement.h
Normal file
60
other/mysql/include/cppconn/statement.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _SQL_STATEMENT_H_
|
||||
#define _SQL_STATEMENT_H_
|
||||
|
||||
#include "config.h"
|
||||
#include "resultset.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace sql
|
||||
{
|
||||
|
||||
class ResultSet;
|
||||
class Connection;
|
||||
class SQLWarning;
|
||||
|
||||
|
||||
class Statement
|
||||
{
|
||||
public:
|
||||
virtual ~Statement() {};
|
||||
|
||||
virtual Connection * getConnection() = 0;
|
||||
|
||||
virtual void clearWarnings() = 0;
|
||||
|
||||
virtual void close() = 0;
|
||||
|
||||
virtual bool execute(const std::string& sql) = 0;
|
||||
|
||||
virtual ResultSet * executeQuery(const std::string& sql) = 0;
|
||||
|
||||
virtual int executeUpdate(const std::string& sql) = 0;
|
||||
|
||||
virtual bool getMoreResults() = 0;
|
||||
|
||||
virtual ResultSet * getResultSet() = 0;
|
||||
|
||||
virtual sql::ResultSet::enum_type getResultSetType() = 0;
|
||||
|
||||
virtual uint64_t getUpdateCount() = 0;
|
||||
|
||||
virtual const SQLWarning * getWarnings() = 0;
|
||||
|
||||
virtual Statement * setResultSetType(sql::ResultSet::enum_type type) = 0;
|
||||
};
|
||||
|
||||
} /* namespace sql */
|
||||
|
||||
#endif /* _SQL_STATEMENT_H_ */
|
99
other/mysql/include/cppconn/warning.h
Normal file
99
other/mysql/include/cppconn/warning.h
Normal file
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _SQL_WARNING_H_
|
||||
#define _SQL_WARNING_H_
|
||||
|
||||
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace sql
|
||||
{
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning (disable : 4290)
|
||||
//warning C4290: C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
|
||||
class SQLWarning
|
||||
{
|
||||
protected:
|
||||
|
||||
const std::string sql_state;
|
||||
const int errNo;
|
||||
SQLWarning * next;
|
||||
const std::string descr;
|
||||
|
||||
public:
|
||||
|
||||
SQLWarning(const std::string& reason, const std::string& SQLState, int vendorCode) :sql_state(SQLState), errNo(vendorCode),descr(reason)
|
||||
{
|
||||
}
|
||||
|
||||
SQLWarning(const std::string& reason, const std::string& SQLState) :sql_state (SQLState), errNo(0), descr(reason)
|
||||
{
|
||||
}
|
||||
|
||||
SQLWarning(const std::string& reason) : sql_state ("HY000"), errNo(0), descr(reason)
|
||||
{
|
||||
}
|
||||
|
||||
SQLWarning() : sql_state ("HY000"), errNo(0) {}
|
||||
|
||||
|
||||
const std::string & getMessage() const
|
||||
{
|
||||
return descr;
|
||||
}
|
||||
|
||||
|
||||
const std::string & getSQLState() const
|
||||
{
|
||||
return sql_state;
|
||||
}
|
||||
|
||||
int getErrorCode() const
|
||||
{
|
||||
return errNo;
|
||||
}
|
||||
|
||||
const SQLWarning * getNextWarning() const
|
||||
{
|
||||
return next;
|
||||
}
|
||||
|
||||
void setNextWarning(SQLWarning * _next)
|
||||
{
|
||||
next = _next;
|
||||
}
|
||||
|
||||
virtual ~SQLWarning() throw () {};
|
||||
|
||||
protected:
|
||||
|
||||
SQLWarning(const SQLWarning& e) : sql_state(e.sql_state), errNo(e.errNo), next(e.next), descr(e.descr) {}
|
||||
|
||||
virtual SQLWarning * copy()
|
||||
{
|
||||
return new SQLWarning(*this);
|
||||
}
|
||||
|
||||
private:
|
||||
const SQLWarning & operator = (const SQLWarning & rhs);
|
||||
|
||||
};
|
||||
|
||||
|
||||
} /* namespace sql */
|
||||
|
||||
#endif /* _SQL_WARNING_H_ */
|
133
other/mysql/include/mysql_connection.h
Normal file
133
other/mysql/include/mysql_connection.h
Normal file
|
@ -0,0 +1,133 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _MYSQL_CONNECTION_H_
|
||||
#define _MYSQL_CONNECTION_H_
|
||||
|
||||
#include <cppconn/connection.h>
|
||||
struct st_mysql;
|
||||
|
||||
|
||||
namespace sql
|
||||
{
|
||||
namespace mysql
|
||||
{
|
||||
|
||||
class MySQL_Savepoint : public sql::Savepoint
|
||||
{
|
||||
std::string name;
|
||||
|
||||
public:
|
||||
MySQL_Savepoint(const std::string &savepoint);
|
||||
virtual ~MySQL_Savepoint() {}
|
||||
|
||||
int getSavepointId();
|
||||
|
||||
std::string getSavepointName();
|
||||
|
||||
private:
|
||||
/* Prevent use of these */
|
||||
MySQL_Savepoint(const MySQL_Savepoint &);
|
||||
void operator=(MySQL_Savepoint &);
|
||||
};
|
||||
|
||||
|
||||
class MySQL_DebugLogger;
|
||||
class MySQL_ConnectionData; /* PIMPL */
|
||||
|
||||
class CPPCONN_PUBLIC_FUNC MySQL_Connection : public sql::Connection
|
||||
{
|
||||
public:
|
||||
MySQL_Connection(const std::string& hostName, const std::string& userName, const std::string& password);
|
||||
|
||||
MySQL_Connection(std::map< std::string, sql::ConnectPropertyVal > & options);
|
||||
|
||||
virtual ~MySQL_Connection();
|
||||
|
||||
struct ::st_mysql * getMySQLHandle();
|
||||
|
||||
void clearWarnings();
|
||||
|
||||
void close();
|
||||
|
||||
void commit();
|
||||
|
||||
sql::Statement * createStatement();
|
||||
|
||||
bool getAutoCommit();
|
||||
|
||||
std::string getCatalog();
|
||||
|
||||
std::string getSchema();
|
||||
|
||||
std::string getClientInfo();
|
||||
|
||||
void getClientOption(const std::string & optionName, void * optionValue);
|
||||
|
||||
sql::DatabaseMetaData * getMetaData();
|
||||
|
||||
enum_transaction_isolation getTransactionIsolation();
|
||||
|
||||
const SQLWarning * getWarnings();
|
||||
|
||||
bool isClosed();
|
||||
|
||||
std::string nativeSQL(const std::string& sql);
|
||||
|
||||
sql::PreparedStatement * prepareStatement(const std::string& sql);
|
||||
|
||||
void releaseSavepoint(Savepoint * savepoint) ;
|
||||
|
||||
void rollback();
|
||||
|
||||
void rollback(Savepoint * savepoint);
|
||||
|
||||
void setAutoCommit(bool autoCommit);
|
||||
|
||||
void setCatalog(const std::string& catalog);
|
||||
|
||||
void setSchema(const std::string& catalog);
|
||||
|
||||
sql::Connection * setClientOption(const std::string & optionName, const void * optionValue);
|
||||
|
||||
sql::Savepoint * setSavepoint(const std::string& name);
|
||||
|
||||
void setTransactionIsolation(enum_transaction_isolation level);
|
||||
|
||||
std::string getSessionVariable(const std::string & varname);
|
||||
|
||||
void setSessionVariable(const std::string & varname, const std::string & value);
|
||||
|
||||
protected:
|
||||
void checkClosed();
|
||||
void init(std::map<std::string, sql::ConnectPropertyVal> & properties);
|
||||
|
||||
MySQL_ConnectionData * intern; /* pimpl */
|
||||
|
||||
private:
|
||||
/* Prevent use of these */
|
||||
MySQL_Connection(const MySQL_Connection &);
|
||||
void operator=(MySQL_Connection &);
|
||||
};
|
||||
|
||||
} /* namespace mysql */
|
||||
} /* namespace sql */
|
||||
|
||||
#endif // _MYSQL_CONNECTION_H_
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
68
other/mysql/include/mysql_driver.h
Normal file
68
other/mysql/include/mysql_driver.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
Copyright 2007 - 2008 MySQL AB, 2008 - 2009 Sun Microsystems, Inc. All rights reserved.
|
||||
|
||||
The MySQL Connector/C++ is licensed under the terms of the GPL
|
||||
<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
|
||||
MySQL Connectors. There are special exceptions to the terms and
|
||||
conditions of the GPL as it is applied to this software, see the
|
||||
FLOSS License Exception
|
||||
<http://www.mysql.com/about/legal/licensing/foss-exception.html>.
|
||||
*/
|
||||
|
||||
#ifndef _MYSQL_DRIVER_H_
|
||||
#define _MYSQL_DRIVER_H_
|
||||
|
||||
#include <cppconn/driver.h>
|
||||
|
||||
|
||||
namespace sql
|
||||
{
|
||||
namespace mysql
|
||||
{
|
||||
class Connection;
|
||||
class ConnectProperty;
|
||||
|
||||
class CPPCONN_PUBLIC_FUNC MySQL_Driver : public sql::Driver
|
||||
{
|
||||
public:
|
||||
MySQL_Driver(); /* DON'T CALL THIS, USE Instance() */
|
||||
virtual ~MySQL_Driver();/* DON'T CALL THIS, MEMORY WILL BE AUTOMAGICALLY CLEANED */
|
||||
|
||||
static MySQL_Driver * Instance();
|
||||
|
||||
sql::Connection * connect(const std::string& hostName,
|
||||
const std::string& userName,
|
||||
const std::string& password);
|
||||
|
||||
sql::Connection * connect(std::map<std::string, sql::ConnectPropertyVal> & options);
|
||||
|
||||
int getMajorVersion();
|
||||
|
||||
int getMinorVersion();
|
||||
|
||||
int getPatchVersion();
|
||||
|
||||
const std::string & getName();
|
||||
|
||||
private:
|
||||
/* Prevent use of these */
|
||||
MySQL_Driver(const MySQL_Driver &);
|
||||
void operator=(MySQL_Driver &);
|
||||
};
|
||||
|
||||
CPPCONN_PUBLIC_FUNC MySQL_Driver *get_mysql_driver_instance();
|
||||
|
||||
|
||||
} /* namespace mysql */
|
||||
} /* namespace sql */
|
||||
|
||||
#endif // _MYSQL_DRIVER_H_
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* tab-width: 4
|
||||
* c-basic-offset: 4
|
||||
* End:
|
||||
* vim600: noet sw=4 ts=4 fdm=marker
|
||||
* vim<600: noet sw=4 ts=4
|
||||
*/
|
BIN
other/mysql/lib32/libmysqlclient.a
Normal file
BIN
other/mysql/lib32/libmysqlclient.a
Normal file
Binary file not shown.
BIN
other/mysql/lib32/libmysqlcppconn-static.a
Normal file
BIN
other/mysql/lib32/libmysqlcppconn-static.a
Normal file
Binary file not shown.
BIN
other/mysql/lib64/libmysqlclient.a
Normal file
BIN
other/mysql/lib64/libmysqlclient.a
Normal file
Binary file not shown.
BIN
other/mysql/lib64/libmysqlcppconn-static.a
Normal file
BIN
other/mysql/lib64/libmysqlcppconn-static.a
Normal file
Binary file not shown.
BIN
other/mysql/vc2005libs/libmysql.dll
Normal file
BIN
other/mysql/vc2005libs/libmysql.dll
Normal file
Binary file not shown.
BIN
other/mysql/vc2005libs/mysqlcppconn.dll
Normal file
BIN
other/mysql/vc2005libs/mysqlcppconn.dll
Normal file
Binary file not shown.
BIN
other/mysql/vc2005libs/mysqlcppconn.lib
Normal file
BIN
other/mysql/vc2005libs/mysqlcppconn.lib
Normal file
Binary file not shown.
|
@ -4,10 +4,8 @@
|
|||
|
||||
// TODO: remove this
|
||||
#include "././game/variables.h"
|
||||
|
||||
//===============================
|
||||
/* DDRace */
|
||||
//MACRO_CONFIG_STR(SvEntities, sv_entities, 64, "Latest", CFGFLAG_SERVER, "The type of entities used") still need to think of a way
|
||||
/* DDRace Server*/
|
||||
//===============================
|
||||
MACRO_CONFIG_INT(SvShotgunBulletSound, sv_shotgun_bullet_sound, 0, 0, 1, CFGFLAG_SERVER, "Annoying Shotgun sound on/off")
|
||||
MACRO_CONFIG_INT(SvEndlessSuperHook, sv_endless_super_hook, 0, 0, 1, CFGFLAG_SERVER, "Endless hook for super players on/off")
|
||||
MACRO_CONFIG_INT(SvEmotionalTees, sv_emotional_tees, 1, 0, 1, CFGFLAG_SERVER, "Emotional Tees on/off")
|
||||
|
@ -16,34 +14,28 @@ MACRO_CONFIG_INT(SvReconnectTime,sv_reconnect_time,5,0,9999,CFGFLAG_SERVER,"how
|
|||
MACRO_CONFIG_INT(SvVoteKickTimeDelay,sv_vote_kick_delay,0,0,9999,CFGFLAG_SERVER,"how much time between kick votes")
|
||||
MACRO_CONFIG_INT(SvVoteKickBanTime,sv_vote_kick_bantime, 300, 0, 9999, CFGFLAG_SERVER," ")
|
||||
MACRO_CONFIG_INT(SvVoteMapTimeDelay,sv_vote_map_delay,0,0,9999,CFGFLAG_SERVER,"how much time between map votes")
|
||||
//MACRO_CONFIG_INT(SvMaxConnections,sv_max_connections, 2, 1, 16, CFGFLAG_SERVER, "Maximum count of connection from one IP server can accept") not needed
|
||||
MACRO_CONFIG_INT(SvMaxAfkTime,sv_max_afk_time, 0, 0, 9999, CFGFLAG_SERVER, "How many seconds a player is allowed to be afk, 0=disabled")
|
||||
MACRO_CONFIG_INT(SvMaxAfkTime,sv_max_afk_time, 0, 0, 9999, CFGFLAG_SERVER, "How many seconds a player is allowed to be afk, 0=disabled")
|
||||
MACRO_CONFIG_INT(SvPauseable, sv_pauseable, 1, 0, 1, CFGFLAG_SERVER, "players can pause their char or not")
|
||||
MACRO_CONFIG_INT(SvCheatTime, sv_cheattime, 0, 0, 1, CFGFLAG_SERVER, "players can cheat with time or not")
|
||||
MACRO_CONFIG_INT(SvHit, sv_hit, 1, 0, 1, CFGFLAG_SERVER, "players can hammer/grenade/laser one another")
|
||||
MACRO_CONFIG_INT(SvTunes, sv_tunes, 1, 0, 1, CFGFLAG_SERVER, "Turns Tuning On/Off")
|
||||
MACRO_CONFIG_INT(SvPhook, sv_phook, 1, 0, 1, CFGFLAG_SERVER, "Turns Player On/Off")
|
||||
MACRO_CONFIG_INT(SvNpc, sv_npc, 0, 0, 1, CFGFLAG_SERVER, "Turns NPC (No Player Collision) On/Off")
|
||||
MACRO_CONFIG_INT(SvEndlessDrag, sv_endless_drag, 0, 0, 1, CFGFLAG_SERVER, "Turns Endless hooking On/Off")
|
||||
MACRO_CONFIG_INT(SvCheats, sv_cheats, 0, 0, 1, CFGFLAG_SERVER, "Turns Cheats On/Off")
|
||||
MACRO_CONFIG_INT(SvAllowColorChange, sv_allow_color_change, 1, 0, 1, CFGFLAG_SERVER, "Allow color change (can block rainbowmod)")
|
||||
MACRO_CONFIG_INT(SvRconTries, sv_rcon_tries, 5, 0, 100, CFGFLAG_SERVER, "How Many Password Tries Before ban")
|
||||
MACRO_CONFIG_INT(SvRconTriesBantime, sv_rcon_tries_bantime, 300, 0, 9999, CFGFLAG_SERVER, "How Much time will the brute rcon password attacker will be banned")
|
||||
|
||||
MACRO_CONFIG_INT(SvHit, sv_hit, 1, 0, 1, CFGFLAG_SERVER, "players can hammer/grenade/laser one another")
|
||||
MACRO_CONFIG_INT(SvTunes, sv_tunes, 1, 0, 1, CFGFLAG_SERVER, "Turns Tuning On/Off")
|
||||
MACRO_CONFIG_INT(SvPhook, sv_phook, 1, 0, 1, CFGFLAG_SERVER, "Turns Player On/Off")
|
||||
MACRO_CONFIG_INT(SvNpc, sv_npc, 0, 0, 1, CFGFLAG_SERVER, "Turns NPC (No Player Collision) On/Off")
|
||||
MACRO_CONFIG_INT(SvEndlessDrag, sv_endless_drag, 0, 0, 1, CFGFLAG_SERVER, "Turns Endless hooking On/Off")
|
||||
MACRO_CONFIG_INT(SvCheats, sv_cheats, 0, 0, 1, CFGFLAG_SERVER, "Turns Cheats On/Off")
|
||||
MACRO_CONFIG_INT(SvAllowColorChange, sv_allow_color_change, 1, 0, 1, CFGFLAG_SERVER, "Allow color change (can block rainbowmod)")
|
||||
MACRO_CONFIG_INT(SvRconTries, sv_rcon_tries, 5, 0, 100, CFGFLAG_SERVER, "How Many Password Tries Before ban")
|
||||
MACRO_CONFIG_INT(SvRconTriesBantime, sv_rcon_tries_bantime, 300, 0, 9999, CFGFLAG_SERVER, "How Much time will the brute rcon password attacker will be banned")
|
||||
MACRO_CONFIG_STR(SvBroadcast, sv_broadcast, 64, "DDRace.info", CFGFLAG_SERVER, "broadcasting message")
|
||||
MACRO_CONFIG_STR(SvWelcome, sv_welcome, 64, "", CFGFLAG_SERVER, "message which players see when joining server")
|
||||
MACRO_CONFIG_INT(SvVotes, sv_votes, 1, 0, 1, CFGFLAG_SERVER, "")
|
||||
MACRO_CONFIG_INT(SvHideScore, sv_hide_score, 0, 0, 1, CFGFLAG_SERVER, "")
|
||||
MACRO_CONFIG_STR(SvRconPasswordAdmin, sv_rcon_password_admin, 32, "", CFGFLAG_SERVER, "Remote console administrator password")
|
||||
MACRO_CONFIG_STR(SvRconPasswordModer, sv_rcon_password_moder, 32, "", CFGFLAG_SERVER, "Remote console moderator password")
|
||||
MACRO_CONFIG_STR(SvRconPasswordHelper, sv_rcon_password_helper, 32, "", CFGFLAG_SERVER, "Remote console helper password")
|
||||
|
||||
|
||||
MACRO_CONFIG_STR(SvRconPasswordModer, sv_rcon_password_moder, 32, "", CFGFLAG_SERVER, "Remote console moderator password")
|
||||
MACRO_CONFIG_STR(SvRconPasswordHelper, sv_rcon_password_helper, 32, "", CFGFLAG_SERVER, "Remote console helper password")
|
||||
MACRO_CONFIG_INT(SvNetmsgLimit, sv_netmsg_limit, 0, 0, 100, CFGFLAG_SERVER, "How Many unauthed Command Tries Before ban")
|
||||
MACRO_CONFIG_INT(SvNetmsgBanTime, sv_netmsg_bantime, 300, 0, 9999, CFGFLAG_SERVER, "How Much time will the unauthed rcon command spammer will be banned")
|
||||
|
||||
MACRO_CONFIG_INT(SvTimer, sv_timer, 0, 0, 1, CFGFLAG_SERVER, "Turns command timer On/Off")
|
||||
|
||||
MACRO_CONFIG_INT(SvWarmup, sv_warmup, 0, 0, 30, CFGFLAG_SERVER, "Number of seconds to do warpup before round starts")
|
||||
MACRO_CONFIG_STR(SvMotd, sv_motd, 900, "", CFGFLAG_SERVER, "Message of the day to display for the clients")
|
||||
MACRO_CONFIG_INT(SvTournamentMode, sv_tournament_mode, 0, 0, 1, CFGFLAG_SERVER, "Tournament mode. When enabled, players joins the server as spectator")
|
||||
|
@ -62,14 +54,10 @@ MACRO_CONFIG_INT(SvMaxClients, sv_max_clients, 16, 1, MAX_CLIENTS, CFGFLAG_SERVE
|
|||
MACRO_CONFIG_INT(SvMaxClientsPerIP, sv_max_clients_per_ip, 2, 1, MAX_CLIENTS, CFGFLAG_SERVER, "Maximum number of clients with the same IP that can connect to the server")
|
||||
MACRO_CONFIG_INT(SvHighBandwidth, sv_high_bandwidth, 0, 0, 1, CFGFLAG_SERVER, "Use high bandwidth mode. Doubles the bandwidth required for the server. LAN use only")
|
||||
MACRO_CONFIG_INT(SvRegister, sv_register, 1, 0, 1, CFGFLAG_SERVER, "Register server with master server for public listing")
|
||||
|
||||
|
||||
MACRO_CONFIG_INT(SvScoreIP, sv_score_ip, 1, 0, 1, CFGFLAG_SERVER, "Check score for ip, too")
|
||||
MACRO_CONFIG_INT(SvCheckpointSave, sv_checkpoint_save, 1, 0, 1, CFGFLAG_SERVER, "Save checkpoint times to score file")
|
||||
|
||||
MACRO_CONFIG_STR(SvScoreFolder, sv_score_folder, 32, "records", CFGFLAG_SERVER, "Folder to save score files to")
|
||||
MACRO_CONFIG_INT(SvUseSQL, sv_use_sql, 0, 0, 1, CFGFLAG_SERVER, "Enables SQL DB instead of record file")
|
||||
|
||||
/* SQL */
|
||||
MACRO_CONFIG_STR(SvSqlUser, sv_sql_user, 32, "nameless", CFGFLAG_SERVER, "SQL User")
|
||||
MACRO_CONFIG_STR(SvSqlPw, sv_sql_pw, 32, "tee", CFGFLAG_SERVER, "SQL Password")
|
||||
|
@ -77,8 +65,7 @@ MACRO_CONFIG_STR(SvSqlIp, sv_sql_ip, 32, "127.0.0.1", CFGFLAG_SERVER, "SQL Datab
|
|||
MACRO_CONFIG_INT(SvSqlPort, sv_sql_port, 3306, 0, 65535, CFGFLAG_SERVER, "SQL Database port")
|
||||
MACRO_CONFIG_STR(SvSqlDatabase, sv_sql_database, 16, "teeworlds", CFGFLAG_SERVER, "SQL Database name")
|
||||
MACRO_CONFIG_STR(SvSqlPrefix, sv_sql_prefix, 16, "record", CFGFLAG_SERVER, "SQL Database table prefix")
|
||||
|
||||
//=============================== */
|
||||
//===============================
|
||||
|
||||
MACRO_CONFIG_STR(PlayerName, player_name, 24, "nameless tee", CFGFLAG_SAVE|CFGFLAG_CLIENT, "Name of the player")
|
||||
MACRO_CONFIG_STR(ClanName, clan_name, 32, "", CFGFLAG_SAVE|CFGFLAG_CLIENT, "(not used)")
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "score.h"
|
||||
#include "score/file_score.h"
|
||||
#include "score/sql_score.h"
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -1820,9 +1821,9 @@ void CGameContext::OnInit(/*class IKernel *pKernel*/)
|
|||
delete m_pScore;
|
||||
|
||||
// create score object (add sql later)
|
||||
//if(g_Config.m_SvUseSQL)
|
||||
// m_pScore = new CSqlScore(this);
|
||||
//else
|
||||
if(g_Config.m_SvUseSQL)
|
||||
m_pScore = new CSqlScore(this);
|
||||
else
|
||||
m_pScore = new CFileScore(this);
|
||||
// setup core world
|
||||
//for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
|
|
519
src/game/server/score/sql_score.cpp
Normal file
519
src/game/server/score/sql_score.cpp
Normal file
|
@ -0,0 +1,519 @@
|
|||
/* CSqlScore class by Sushi */
|
||||
#include <string.h>
|
||||
|
||||
#include <engine/shared/config.h>
|
||||
#include "../entities/character.h"
|
||||
#include "../gamemodes/DDRace.h"
|
||||
#include "sql_score.h"
|
||||
|
||||
static LOCK gs_SqlLock = 0;
|
||||
|
||||
CSqlScore::CSqlScore(CGameContext *pGameServer)
|
||||
: m_pGameServer(pGameServer),
|
||||
m_pServer(pGameServer->Server()),
|
||||
m_pDatabase(g_Config.m_SvSqlDatabase),
|
||||
m_pPrefix(g_Config.m_SvSqlPrefix),
|
||||
m_pUser(g_Config.m_SvSqlUser),
|
||||
m_pPass(g_Config.m_SvSqlPw),
|
||||
m_pIp(g_Config.m_SvSqlIp),
|
||||
m_Port(g_Config.m_SvSqlPort)
|
||||
{
|
||||
str_copy(m_aMap, g_Config.m_SvMap, sizeof(m_aMap));
|
||||
ClearString(m_aMap);
|
||||
|
||||
if(gs_SqlLock == 0)
|
||||
gs_SqlLock = lock_create();
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
CSqlScore::~CSqlScore()
|
||||
{
|
||||
lock_wait(gs_SqlLock);
|
||||
lock_release(gs_SqlLock);
|
||||
}
|
||||
|
||||
bool CSqlScore::Connect()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Create connection
|
||||
m_pDriver = get_driver_instance();
|
||||
char aBuf[256];
|
||||
str_format(aBuf, sizeof(aBuf), "tcp://%s:%d", m_pIp, m_Port);
|
||||
m_pConnection = m_pDriver->connect(aBuf, m_pUser, m_pPass);
|
||||
|
||||
// Create Statement
|
||||
m_pStatement = m_pConnection->createStatement();
|
||||
|
||||
// Create database if not exists
|
||||
str_format(aBuf, sizeof(aBuf), "CREATE DATABASE IF NOT EXISTS %s", m_pDatabase);
|
||||
m_pStatement->execute(aBuf);
|
||||
|
||||
// Connect to specific database
|
||||
m_pConnection->setSchema(m_pDatabase);
|
||||
dbg_msg("SQL", "SQL connection established");
|
||||
return true;
|
||||
}
|
||||
catch (sql::SQLException &e)
|
||||
{
|
||||
dbg_msg("SQL", "ERROR: SQL connection failed");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSqlScore::Disconnect()
|
||||
{
|
||||
try
|
||||
{
|
||||
delete m_pConnection;
|
||||
dbg_msg("SQL", "SQL connection disconnected");
|
||||
}
|
||||
catch (sql::SQLException &e)
|
||||
{
|
||||
dbg_msg("SQL", "ERROR: No SQL connection");
|
||||
}
|
||||
}
|
||||
|
||||
// create tables... should be done only once
|
||||
void CSqlScore::Init()
|
||||
{
|
||||
// create connection
|
||||
if(Connect())
|
||||
{
|
||||
try
|
||||
{
|
||||
// create tables
|
||||
char aBuf[768];
|
||||
str_format(aBuf, sizeof(aBuf), "CREATE TABLE IF NOT EXISTS %s_%s_race (Name VARCHAR(31) NOT NULL, Time FLOAT DEFAULT 0, IP VARCHAR(16) DEFAULT '0.0.0.0', cp1 FLOAT DEFAULT 0, cp2 FLOAT DEFAULT 0, cp3 FLOAT DEFAULT 0, cp4 FLOAT DEFAULT 0, cp5 FLOAT DEFAULT 0, cp6 FLOAT DEFAULT 0, cp7 FLOAT DEFAULT 0, cp8 FLOAT DEFAULT 0, cp9 FLOAT DEFAULT 0, cp10 FLOAT DEFAULT 0, cp11 FLOAT DEFAULT 0, cp12 FLOAT DEFAULT 0, cp13 FLOAT DEFAULT 0, cp14 FLOAT DEFAULT 0, cp15 FLOAT DEFAULT 0, cp16 FLOAT DEFAULT 0, cp17 FLOAT DEFAULT 0, cp18 FLOAT DEFAULT 0, cp19 FLOAT DEFAULT 0, cp20 FLOAT DEFAULT 0, cp21 FLOAT DEFAULT 0, cp22 FLOAT DEFAULT 0, cp23 FLOAT DEFAULT 0, cp24 FLOAT DEFAULT 0, cp25 FLOAT DEFAULT 0);", m_pPrefix, m_aMap);
|
||||
m_pStatement->execute(aBuf);
|
||||
dbg_msg("SQL", "Tables were created successfully");
|
||||
|
||||
// get the best time
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT Time FROM %s_%s_race ORDER BY `Time` ASC LIMIT 0, 1;", m_pPrefix, m_aMap);
|
||||
m_pResults = m_pStatement->executeQuery(aBuf);
|
||||
|
||||
if(m_pResults->next())
|
||||
{
|
||||
((CGameControllerDDRace*)GameServer()->m_pController)->m_CurrentRecord = (float)m_pResults->getDouble("Time");
|
||||
|
||||
dbg_msg("SQL", "Getting best time on server done");
|
||||
|
||||
// delete results
|
||||
delete m_pResults;
|
||||
}
|
||||
|
||||
// delete statement
|
||||
delete m_pStatement;
|
||||
}
|
||||
catch (sql::SQLException &e)
|
||||
{
|
||||
dbg_msg("SQL", "ERROR: Tables were NOT created");
|
||||
}
|
||||
|
||||
// disconnect from database
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
// update stuff
|
||||
void CSqlScore::LoadScoreThread(void *pUser)
|
||||
{
|
||||
lock_wait(gs_SqlLock);
|
||||
|
||||
CSqlScoreData *pData = (CSqlScoreData *)pUser;
|
||||
|
||||
// Connect to database
|
||||
if(pData->m_pSqlData->Connect())
|
||||
{
|
||||
try
|
||||
{
|
||||
// check strings
|
||||
pData->m_pSqlData->ClearString(pData->m_aName);
|
||||
|
||||
char aBuf[512];
|
||||
// check if there is an entry with the same ip
|
||||
if(g_Config.m_SvScoreIP)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT * FROM %s_%s_race WHERE IP='%s';", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aIP);
|
||||
pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf);
|
||||
|
||||
if(pData->m_pSqlData->m_pResults->next())
|
||||
{
|
||||
// get the best time
|
||||
pData->m_pSqlData->PlayerData(pData->m_ClientID)->m_BestTime = (float)pData->m_pSqlData->m_pResults->getDouble("Time");
|
||||
char aColumn[8];
|
||||
for(int i = 0; i < NUM_TELEPORT; i++)
|
||||
{
|
||||
str_format(aColumn, sizeof(aColumn), "cp%d", i+1);
|
||||
pData->m_pSqlData->PlayerData(pData->m_ClientID)->m_aBestCpTime[i] = (float)pData->m_pSqlData->m_pResults->getDouble(aColumn);
|
||||
}
|
||||
|
||||
dbg_msg("SQL", "Getting best time done");
|
||||
|
||||
// delete statement and results
|
||||
delete pData->m_pSqlData->m_pStatement;
|
||||
delete pData->m_pSqlData->m_pResults;
|
||||
|
||||
// disconnect from database
|
||||
pData->m_pSqlData->Disconnect();
|
||||
|
||||
delete pData;
|
||||
|
||||
lock_release(gs_SqlLock);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT * FROM %s_%s_race WHERE Name='%s';", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aName);
|
||||
pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf);
|
||||
if(pData->m_pSqlData->m_pResults->next())
|
||||
{
|
||||
// check if IP differs
|
||||
const char* pIP = pData->m_pSqlData->m_pResults->getString("IP").c_str();
|
||||
if(str_comp(pIP, pData->m_aIP) != 0)
|
||||
{
|
||||
// set the new ip
|
||||
str_format(aBuf, sizeof(aBuf), "UPDATE %s_%s_race SET IP='%s' WHERE Name='%s';", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aIP, pData->m_aName);
|
||||
pData->m_pSqlData->m_pStatement->execute(aBuf);
|
||||
}
|
||||
|
||||
// get the best time
|
||||
pData->m_pSqlData->PlayerData(pData->m_ClientID)->m_BestTime = (float)pData->m_pSqlData->m_pResults->getDouble("Time");
|
||||
char aColumn[8];
|
||||
if(g_Config.m_SvCheckpointSave)
|
||||
{
|
||||
for(int i = 0; i < NUM_TELEPORT; i++)
|
||||
{
|
||||
str_format(aColumn, sizeof(aColumn), "cp%d", i+1);
|
||||
pData->m_pSqlData->PlayerData(pData->m_ClientID)->m_aBestCpTime[i] = (float)pData->m_pSqlData->m_pResults->getDouble(aColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dbg_msg("SQL", "Getting best time done");
|
||||
|
||||
// delete statement and results
|
||||
delete pData->m_pSqlData->m_pStatement;
|
||||
delete pData->m_pSqlData->m_pResults;
|
||||
}
|
||||
catch (sql::SQLException &e)
|
||||
{
|
||||
dbg_msg("SQL", "ERROR: Could not update account");
|
||||
}
|
||||
|
||||
// disconnect from database
|
||||
pData->m_pSqlData->Disconnect();
|
||||
}
|
||||
|
||||
delete pData;
|
||||
|
||||
lock_release(gs_SqlLock);
|
||||
}
|
||||
|
||||
void CSqlScore::LoadScore(int ClientID)
|
||||
{
|
||||
CSqlScoreData *Tmp = new CSqlScoreData();
|
||||
Tmp->m_ClientID = ClientID;
|
||||
str_copy(Tmp->m_aName, Server()->ClientName(ClientID), sizeof(Tmp->m_aName));
|
||||
Server()->GetClientIP(ClientID, Tmp->m_aIP, sizeof(Tmp->m_aIP));
|
||||
Tmp->m_pSqlData = this;
|
||||
|
||||
void *LoadThread = thread_create(LoadScoreThread, Tmp);
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
pthread_detach((pthread_t)LoadThread);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CSqlScore::SaveScoreThread(void *pUser)
|
||||
{
|
||||
lock_wait(gs_SqlLock);
|
||||
|
||||
CSqlScoreData *pData = (CSqlScoreData *)pUser;
|
||||
|
||||
// Connect to database
|
||||
if(pData->m_pSqlData->Connect())
|
||||
{
|
||||
try
|
||||
{
|
||||
// check strings
|
||||
pData->m_pSqlData->ClearString(pData->m_aName);
|
||||
|
||||
char aBuf[768];
|
||||
|
||||
// fisrt check for IP
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT * FROM %s_%s_race WHERE IP='%s';", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aIP);
|
||||
pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf);
|
||||
|
||||
// if ip found...
|
||||
if(pData->m_pSqlData->m_pResults->next())
|
||||
{
|
||||
// update time
|
||||
if(g_Config.m_SvCheckpointSave)
|
||||
str_format(aBuf, sizeof(aBuf), "UPDATE %s_%s_race SET Name='%s', Time='%.2f', cp1='%.2f', cp2='%.2f', cp3='%.2f', cp4='%.2f', cp5='%.2f', cp6='%.2f', cp7='%.2f', cp8='%.2f', cp9='%.2f', cp10='%.2f', cp11='%.2f', cp12='%.2f', cp13='%.2f', cp14='%.2f', cp15='%.2f', cp16='%.2f', cp17='%.2f', cp18='%.2f', cp19='%.2f', cp20='%.2f', cp21='%.2f', cp22='%.2f', cp23='%.2f', cp24='%.2f', cp25='%.2f' WHERE IP='%s';", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aName, pData->m_Time, pData->m_aCpCurrent[0], pData->m_aCpCurrent[1], pData->m_aCpCurrent[2], pData->m_aCpCurrent[3], pData->m_aCpCurrent[4], pData->m_aCpCurrent[5], pData->m_aCpCurrent[6], pData->m_aCpCurrent[7], pData->m_aCpCurrent[8], pData->m_aCpCurrent[9], pData->m_aCpCurrent[10], pData->m_aCpCurrent[11], pData->m_aCpCurrent[12], pData->m_aCpCurrent[13], pData->m_aCpCurrent[14], pData->m_aCpCurrent[15], pData->m_aCpCurrent[16], pData->m_aCpCurrent[17], pData->m_aCpCurrent[18], pData->m_aCpCurrent[19], pData->m_aCpCurrent[20], pData->m_aCpCurrent[21], pData->m_aCpCurrent[22], pData->m_aCpCurrent[23], pData->m_aCpCurrent[24], pData->m_aIP);
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "UPDATE %s_%s_race SET Name='%s', Time='%.2f' WHERE IP='%s';", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aName, pData->m_Time, pData->m_aIP);
|
||||
pData->m_pSqlData->m_pStatement->execute(aBuf);
|
||||
|
||||
dbg_msg("SQL", "Updateing time done");
|
||||
|
||||
// delete results statement
|
||||
delete pData->m_pSqlData->m_pResults;
|
||||
delete pData->m_pSqlData->m_pStatement;
|
||||
|
||||
// disconnect from database
|
||||
pData->m_pSqlData->Disconnect();
|
||||
|
||||
delete pData;
|
||||
|
||||
lock_release(gs_SqlLock);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// if no entry found... create a new one
|
||||
str_format(aBuf, sizeof(aBuf), "INSERT IGNORE INTO %s_%s_race(Name, IP, Time, cp1, cp2, cp3, cp4, cp5, cp6, cp7, cp8, cp9, cp10, cp11, cp12, cp13, cp14, cp15, cp16, cp17, cp18, cp19, cp20, cp21, cp22, cp23, cp24, cp25) VALUES ('%s', '%s', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f', '%.2f');", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_aName, pData->m_aIP, pData->m_Time, pData->m_aCpCurrent[0], pData->m_aCpCurrent[1], pData->m_aCpCurrent[2], pData->m_aCpCurrent[3], pData->m_aCpCurrent[4], pData->m_aCpCurrent[5], pData->m_aCpCurrent[6], pData->m_aCpCurrent[7], pData->m_aCpCurrent[8], pData->m_aCpCurrent[9], pData->m_aCpCurrent[10], pData->m_aCpCurrent[11], pData->m_aCpCurrent[12], pData->m_aCpCurrent[13], pData->m_aCpCurrent[14], pData->m_aCpCurrent[15], pData->m_aCpCurrent[16], pData->m_aCpCurrent[17], pData->m_aCpCurrent[18], pData->m_aCpCurrent[19], pData->m_aCpCurrent[20], pData->m_aCpCurrent[21], pData->m_aCpCurrent[22], pData->m_aCpCurrent[23], pData->m_aCpCurrent[24]);
|
||||
pData->m_pSqlData->m_pStatement->execute(aBuf);
|
||||
|
||||
dbg_msg("SQL", "Updateing time done");
|
||||
|
||||
// delete results statement
|
||||
delete pData->m_pSqlData->m_pResults;
|
||||
delete pData->m_pSqlData->m_pStatement;
|
||||
}
|
||||
catch (sql::SQLException &e)
|
||||
{
|
||||
dbg_msg("SQL", "ERROR: Could not update time");
|
||||
}
|
||||
|
||||
// disconnect from database
|
||||
pData->m_pSqlData->Disconnect();
|
||||
}
|
||||
|
||||
delete pData;
|
||||
|
||||
lock_release(gs_SqlLock);
|
||||
}
|
||||
|
||||
void CSqlScore::SaveScore(int ClientID, float Time, CCharacter *pChar)
|
||||
{
|
||||
CSqlScoreData *Tmp = new CSqlScoreData();
|
||||
Tmp->m_ClientID = ClientID;
|
||||
str_copy(Tmp->m_aName, Server()->ClientName(ClientID), sizeof(Tmp->m_aName));
|
||||
Server()->GetClientIP(ClientID, Tmp->m_aIP, sizeof(Tmp->m_aIP));
|
||||
Tmp->m_Time = Time;
|
||||
for(int i = 0; i < NUM_TELEPORT; i++)
|
||||
Tmp->m_aCpCurrent[i] = pChar->m_CpCurrent[i];
|
||||
Tmp->m_pSqlData = this;
|
||||
|
||||
void *SaveThread = thread_create(SaveScoreThread, Tmp);
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
pthread_detach((pthread_t)SaveThread);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CSqlScore::ShowRankThread(void *pUser)
|
||||
{
|
||||
lock_wait(gs_SqlLock);
|
||||
|
||||
CSqlScoreData *pData = (CSqlScoreData *)pUser;
|
||||
|
||||
// Connect to database
|
||||
if(pData->m_pSqlData->Connect())
|
||||
{
|
||||
try
|
||||
{
|
||||
// check strings
|
||||
pData->m_pSqlData->ClearString(pData->m_aName);
|
||||
|
||||
// check sort methode
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT Name, IP, Time FROM %s_%s_race ORDER BY `Time` ASC;", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap);
|
||||
pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf);
|
||||
int RowCount = 0;
|
||||
bool Found = false;
|
||||
while(pData->m_pSqlData->m_pResults->next())
|
||||
{
|
||||
RowCount++;
|
||||
|
||||
if(pData->m_Search)
|
||||
{
|
||||
if(str_find_nocase(pData->m_pSqlData->m_pResults->getString("Name").c_str(), pData->m_aName))
|
||||
{
|
||||
Found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(!str_comp(pData->m_pSqlData->m_pResults->getString("IP").c_str(), pData->m_aIP))
|
||||
{
|
||||
Found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!Found)
|
||||
{
|
||||
str_format(aBuf, sizeof(aBuf), "%s is not ranked", pData->m_aName);
|
||||
pData->m_pSqlData->GameServer()->SendChatTarget(pData->m_ClientID, aBuf);
|
||||
}
|
||||
else
|
||||
{
|
||||
float Time = (float)pData->m_pSqlData->m_pResults->getDouble("Time");
|
||||
if(g_Config.m_SvHideScore)
|
||||
str_format(aBuf, sizeof(aBuf), "Your time: %d minute(s) %5.2f second(s)", (int)(Time/60), Time-((int)Time/60*60));
|
||||
else
|
||||
str_format(aBuf, sizeof(aBuf), "%d. %s Time: %d minute(s) %5.2f second(s)", RowCount, pData->m_pSqlData->m_pResults->getString("Name").c_str(), (int)(Time/60), Time-((int)Time/60*60));
|
||||
|
||||
if(pData->m_Search)
|
||||
strcat(aBuf, pData->m_aRequestingPlayer);
|
||||
|
||||
pData->m_pSqlData->GameServer()->SendChatTarget(-1, aBuf);
|
||||
}
|
||||
|
||||
dbg_msg("SQL", "Showing rank done");
|
||||
|
||||
// delete results and statement
|
||||
delete pData->m_pSqlData->m_pResults;
|
||||
delete pData->m_pSqlData->m_pStatement;
|
||||
}
|
||||
catch (sql::SQLException &e)
|
||||
{
|
||||
dbg_msg("SQL", "ERROR: Could not show rank");
|
||||
}
|
||||
|
||||
// disconnect from database
|
||||
pData->m_pSqlData->Disconnect();
|
||||
}
|
||||
|
||||
delete pData;
|
||||
|
||||
lock_release(gs_SqlLock);
|
||||
}
|
||||
|
||||
void CSqlScore::ShowRank(int ClientID, const char* pName, bool Search)
|
||||
{
|
||||
CSqlScoreData *Tmp = new CSqlScoreData();
|
||||
Tmp->m_ClientID = ClientID;
|
||||
str_copy(Tmp->m_aName, pName, sizeof(Tmp->m_aName));
|
||||
Server()->GetClientIP(ClientID, Tmp->m_aIP, sizeof(Tmp->m_aIP));
|
||||
Tmp->m_Search = Search;
|
||||
str_format(Tmp->m_aRequestingPlayer, sizeof(Tmp->m_aRequestingPlayer), " (%s)", Server()->ClientName(ClientID));
|
||||
Tmp->m_pSqlData = this;
|
||||
|
||||
void *RankThread = thread_create(ShowRankThread, Tmp);
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
pthread_detach((pthread_t)RankThread);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CSqlScore::ShowTop5Thread(void *pUser)
|
||||
{
|
||||
lock_wait(gs_SqlLock);
|
||||
|
||||
CSqlScoreData *pData = (CSqlScoreData *)pUser;
|
||||
|
||||
// Connect to database
|
||||
if(pData->m_pSqlData->Connect())
|
||||
{
|
||||
try
|
||||
{
|
||||
// check sort methode
|
||||
char aBuf[512];
|
||||
str_format(aBuf, sizeof(aBuf), "SELECT Name, Time FROM %s_%s_race ORDER BY `Time` ASC LIMIT %d, 5;", pData->m_pSqlData->m_pPrefix, pData->m_pSqlData->m_aMap, pData->m_Num-1);
|
||||
pData->m_pSqlData->m_pResults = pData->m_pSqlData->m_pStatement->executeQuery(aBuf);
|
||||
|
||||
// show top5
|
||||
pData->m_pSqlData->GameServer()->SendChatTarget(pData->m_ClientID, "----------- Top 5 -----------");
|
||||
|
||||
int Rank = pData->m_Num;
|
||||
float Time = 0;
|
||||
while(pData->m_pSqlData->m_pResults->next())
|
||||
{
|
||||
Time = (float)pData->m_pSqlData->m_pResults->getDouble("Time");
|
||||
str_format(aBuf, sizeof(aBuf), "%d. %s Time: %d minute(s) %.2f second(s)", Rank, pData->m_pSqlData->m_pResults->getString("Name").c_str(), (int)(Time/60), Time-((int)Time/60*60));
|
||||
pData->m_pSqlData->GameServer()->SendChatTarget(pData->m_ClientID, aBuf);
|
||||
Rank++;
|
||||
}
|
||||
pData->m_pSqlData->GameServer()->SendChatTarget(pData->m_ClientID, "------------------------------");
|
||||
|
||||
dbg_msg("SQL", "Showing top5 done");
|
||||
|
||||
// delete results and statement
|
||||
delete pData->m_pSqlData->m_pResults;
|
||||
delete pData->m_pSqlData->m_pStatement;
|
||||
}
|
||||
catch (sql::SQLException &e)
|
||||
{
|
||||
dbg_msg("SQL", "ERROR: Could not show top5");
|
||||
}
|
||||
|
||||
// disconnect from database
|
||||
pData->m_pSqlData->Disconnect();
|
||||
}
|
||||
|
||||
delete pData;
|
||||
|
||||
lock_release(gs_SqlLock);
|
||||
}
|
||||
|
||||
void CSqlScore::ShowTop5(int ClientID, int Debut)
|
||||
{
|
||||
CSqlScoreData *Tmp = new CSqlScoreData();
|
||||
Tmp->m_Num = Debut;
|
||||
Tmp->m_ClientID = ClientID;
|
||||
Tmp->m_pSqlData = this;
|
||||
|
||||
void *Top5Thread = thread_create(ShowTop5Thread, Tmp);
|
||||
#if defined(CONF_FAMILY_UNIX)
|
||||
pthread_detach((pthread_t)Top5Thread);
|
||||
#endif
|
||||
}
|
||||
|
||||
// anti SQL injection
|
||||
void CSqlScore::ClearString(char *pString)
|
||||
{
|
||||
// replace ' ' ' with ' \' ' and remove '\'
|
||||
for(int i = 0; i < str_length(pString); i++)
|
||||
{
|
||||
// replace '-' with '_'
|
||||
if(pString[i] == '-')
|
||||
pString[i] = '_';
|
||||
|
||||
if(pString[i] == '\'')
|
||||
{
|
||||
// count \ before the '
|
||||
int SlashCount = 0;
|
||||
for(int j = i-1; j >= 0; j--)
|
||||
{
|
||||
if(pString[i] != '\\')
|
||||
break;
|
||||
|
||||
SlashCount++;
|
||||
}
|
||||
|
||||
if(SlashCount % 2 == 0)
|
||||
{
|
||||
for(int j = str_length(pString)-1; j > i; j--)
|
||||
{
|
||||
pString[j] = pString[j-1];
|
||||
}
|
||||
pString[i] = '\\';
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// aaand remove spaces and \ at the end xD
|
||||
for(int i = str_length(pString)-1; i >= 0; i--)
|
||||
{
|
||||
if(pString[i] == ' ' || pString[i] == '\\')
|
||||
pString[i] = '\0';
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
73
src/game/server/score/sql_score.h
Normal file
73
src/game/server/score/sql_score.h
Normal file
|
@ -0,0 +1,73 @@
|
|||
/* CSqlScore Class by Sushi */
|
||||
#ifndef GAME_SERVER_SQLSCORE_H
|
||||
#define GAME_SERVER_SQLSCORE_H
|
||||
|
||||
#include <mysql_connection.h>
|
||||
|
||||
#include <cppconn/driver.h>
|
||||
#include <cppconn/exception.h>
|
||||
#include <cppconn/resultset.h>
|
||||
#include <cppconn/statement.h>
|
||||
|
||||
#include "../score.h"
|
||||
|
||||
class CSqlScore : public IScore
|
||||
{
|
||||
CGameContext *m_pGameServer;
|
||||
IServer *m_pServer;
|
||||
|
||||
sql::Driver *m_pDriver;
|
||||
sql::Connection *m_pConnection;
|
||||
sql::Statement *m_pStatement;
|
||||
sql::ResultSet *m_pResults;
|
||||
|
||||
// copy of config vars
|
||||
const char* m_pDatabase;
|
||||
const char* m_pPrefix;
|
||||
const char* m_pUser;
|
||||
const char* m_pPass;
|
||||
const char* m_pIp;
|
||||
char m_aMap[64];
|
||||
int m_Port;
|
||||
|
||||
CGameContext *GameServer() { return m_pGameServer; }
|
||||
IServer *Server() { return m_pServer; }
|
||||
|
||||
static void LoadScoreThread(void *pUser);
|
||||
static void SaveScoreThread(void *pUser);
|
||||
static void ShowRankThread(void *pUser);
|
||||
static void ShowTop5Thread(void *pUser);
|
||||
|
||||
void Init();
|
||||
|
||||
bool Connect();
|
||||
void Disconnect();
|
||||
|
||||
// anti SQL injection
|
||||
void ClearString(char *pString);
|
||||
|
||||
public:
|
||||
|
||||
CSqlScore(CGameContext *pGameServer);
|
||||
~CSqlScore();
|
||||
|
||||
virtual void LoadScore(int ClientID);
|
||||
virtual void SaveScore(int ClientID, float Time, CCharacter *pChar);
|
||||
virtual void ShowRank(int ClientID, const char* pName, bool Search=false);
|
||||
virtual void ShowTop5(int ClientID, int Debut=1);
|
||||
};
|
||||
|
||||
struct CSqlScoreData
|
||||
{
|
||||
CSqlScore *m_pSqlData;
|
||||
int m_ClientID;
|
||||
char m_aName[16];
|
||||
char m_aIP[16];
|
||||
float m_Time;
|
||||
float m_aCpCurrent[NUM_TELEPORT];
|
||||
int m_Num;
|
||||
bool m_Search;
|
||||
char m_aRequestingPlayer[MAX_NAME_LENGTH];
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue