Skip to content

Commit b2227c3

Browse files
committed
Added 8 byte integer support for varargs database queries
1 parent f22a5f1 commit b2227c3

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

Server/mods/deathmatch/logic/CDatabaseConnectionSqlite.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ bool CDatabaseConnectionSqlite::QueryInternal ( const SString& strQuery, CRegist
264264
case SQLITE_NULL:
265265
break;
266266
case SQLITE_INTEGER:
267-
cell.nVal = sqlite3_column_int ( pStmt, i );
267+
cell.nVal = sqlite3_column_int64 ( pStmt, i );
268268
break;
269269
case SQLITE_FLOAT:
270270
cell.fVal = (float)sqlite3_column_double ( pStmt, i );
@@ -499,6 +499,13 @@ SString InsertQueryArgumentsSqlite ( const char* szQuery, va_list vl )
499499
}
500500
break;
501501

502+
case SQLITE_INTEGER64:
503+
{
504+
long long int llValue = va_arg( vl, long long int );
505+
strParsedQuery += SString( "%" PRId64, llValue );
506+
}
507+
break;
508+
502509
case SQLITE_FLOAT:
503510
{
504511
double fValue = va_arg( vl, double );

Server/mods/deathmatch/logic/CDatabaseTypeMySql.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,13 @@ SString InsertQueryArgumentsMySql ( const char* szQuery, va_list vl )
390390
}
391391
break;
392392

393+
case SQLITE_INTEGER64:
394+
{
395+
long long int llValue = va_arg( vl, long long int );
396+
strParsedQuery += SString( "%" PRId64, llValue );
397+
}
398+
break;
399+
393400
case SQLITE_FLOAT:
394401
{
395402
double fValue = va_arg( vl, double );

Server/mods/deathmatch/logic/CRegistry.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,13 @@ bool CRegistry::Query ( CRegistryResult* pResult, const char* szQuery, va_list v
450450
}
451451
break;
452452

453+
case SQLITE_INTEGER64:
454+
{
455+
long long int llValue = va_arg( vl, long long int );
456+
strParsedQuery += SString( "%" PRId64, llValue );
457+
}
458+
break;
459+
453460
case SQLITE_FLOAT:
454461
{
455462
double fValue = va_arg( vl, double );

Server/mods/deathmatch/logic/CRegistry.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ typedef CAutoRefedPointer < struct CRegistryResultData > CRegistryResult;
2222
#include <string>
2323
#include "../../../vendor/sqlite/sqlite3.h"
2424

25+
// Only used for identifying 8 byte integers in varargs list
26+
#define SQLITE_INTEGER64 10
27+
2528
class CRegistry
2629
{
2730
friend class CRegistryManager;
@@ -113,6 +116,22 @@ struct CRegistryResultCell
113116
return *this;
114117
}
115118

119+
template< class T >
120+
void GetNumber( T& outValue ) const
121+
{
122+
outValue = GetNumber< T >();
123+
}
124+
125+
template< class T >
126+
T GetNumber( void ) const
127+
{
128+
if ( nType == SQLITE_INTEGER )
129+
return static_cast< T >( nVal );
130+
if ( nType == SQLITE_FLOAT )
131+
return static_cast< T >( fVal );
132+
return 0;
133+
}
134+
116135
int nType; // Type identifier, SQLITE_*
117136
int nLength; // Length in bytes if nType == SQLITE_BLOB or SQLITE_TEXT
118137
// (includes zero terminator if TEXT)

0 commit comments

Comments
 (0)