[10792] Fixed warnings and need in redundent char* casts in database access code.

This commit is contained in:
VladimirMangos 2010-11-29 00:36:13 +03:00
parent 7f34658dd2
commit abc6dfca98
9 changed files with 26 additions and 20 deletions

View file

@ -492,7 +492,7 @@ void ObjectMgr::LoadPointOfInterestLocales()
struct SQLCreatureLoader : public SQLStorageLoaderBase<SQLCreatureLoader>
{
template<class D>
void convert_from_str(uint32 /*field_pos*/, char *src, D &dst)
void convert_from_str(uint32 /*field_pos*/, char const *src, D &dst)
{
dst = D(sObjectMgr.GetScriptId(src));
}
@ -1849,7 +1849,7 @@ void ObjectMgr::LoadItemLocales()
struct SQLItemLoader : public SQLStorageLoaderBase<SQLItemLoader>
{
template<class D>
void convert_from_str(uint32 /*field_pos*/, char *src, D &dst)
void convert_from_str(uint32 /*field_pos*/, char const *src, D &dst)
{
dst = D(sObjectMgr.GetScriptId(src));
}
@ -5227,7 +5227,7 @@ void ObjectMgr::LoadPageTextLocales()
struct SQLInstanceLoader : public SQLStorageLoaderBase<SQLInstanceLoader>
{
template<class D>
void convert_from_str(uint32 /*field_pos*/, char *src, D &dst)
void convert_from_str(uint32 /*field_pos*/, char const *src, D &dst)
{
dst = D(sObjectMgr.GetScriptId(src));
}
@ -6516,7 +6516,7 @@ void ObjectMgr::LoadGameObjectLocales()
struct SQLGameObjectLoader : public SQLStorageLoaderBase<SQLGameObjectLoader>
{
template<class D>
void convert_from_str(uint32 /*field_pos*/, char *src, D &dst)
void convert_from_str(uint32 /*field_pos*/, char const *src, D &dst)
{
dst = D(sObjectMgr.GetScriptId(src));
}

View file

@ -249,7 +249,7 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
else
{
sLog.outErrorDb("The table `%s` in your [%s] database is missing its version info.",table_name,db_name);
sLog.outErrorDb("MaNGOS cannot find the version info needed to check that the db is up to date.",table_name,db_name);
sLog.outErrorDb("MaNGOS cannot find the version info needed to check that the db is up to date.");
sLog.outErrorDb();
sLog.outErrorDb("This revision of MaNGOS requires a database updated to:");
sLog.outErrorDb("`%s.sql`",req_sql_update_name);
@ -264,7 +264,7 @@ bool Database::CheckRequiredField( char const* table_name, char const* required_
else
{
sLog.outErrorDb("The table `%s` in your [%s] database is missing or corrupt.",table_name,db_name);
sLog.outErrorDb("MaNGOS cannot find the version info needed to check that the db is up to date.",table_name,db_name);
sLog.outErrorDb("MaNGOS cannot find the version info needed to check that the db is up to date.");
sLog.outErrorDb();
sLog.outErrorDb("This revision of mangos requires a database updated to:");
sLog.outErrorDb("`%s.sql`",req_sql_update_name);

View file

@ -88,7 +88,6 @@ enum Field::DataTypes QueryResultMysql::ConvertNativeType(enum_field_types mysql
case FIELD_TYPE_NULL:
return Field::DB_TYPE_STRING;
case FIELD_TYPE_TINY:
case FIELD_TYPE_SHORT:
case FIELD_TYPE_LONG:
case FIELD_TYPE_INT24:

View file

@ -67,7 +67,7 @@ void SQLStorage::EraseEntry(uint32 id)
else
offset += 4;
reinterpret_cast<void*&>(pIndex[id]) = NULL;
pIndex[id] = NULL;
}
void SQLStorage::Free ()

View file

@ -101,13 +101,20 @@ struct SQLStorageLoaderBase
template<class S>
void convert_to_str(uint32 field_pos, S src, char * & dst);
template<class D>
void convert_from_str(uint32 field_pos, char * src, D& dst);
void convert_str_to_str(uint32 field_pos, char *src, char *&dst);
void convert_from_str(uint32 field_pos, char const* src, D& dst);
void convert_str_to_str(uint32 field_pos, char const* src, char *&dst);
// trap, no body
template<class D>
void convert_from_str(uint32 field_pos, char* src, D& dst);
void convert_str_to_str(uint32 field_pos, char* src, char *&dst);
private:
template<class V>
void storeValue(V value, SQLStorage &store, char *p, int x, uint32 &offset);
void storeValue(char * value, SQLStorage &store, char *p, int x, uint32 &offset);
void storeValue(V value, SQLStorage &store, char *p, uint32 x, uint32 &offset);
void storeValue(char const* value, SQLStorage &store, char *p, uint32 x, uint32 &offset);
// trap, no body
void storeValue(char * value, SQLStorage &store, char *p, uint32 x, uint32 &offset);
};
struct SQLStorageLoader : public SQLStorageLoaderBase<SQLStorageLoader>

View file

@ -28,7 +28,7 @@ void SQLStorageLoaderBase<T>::convert(uint32 /*field_pos*/, S src, D &dst)
}
template<class T>
void SQLStorageLoaderBase<T>::convert_str_to_str(uint32 /*field_pos*/, char *src, char *&dst)
void SQLStorageLoaderBase<T>::convert_str_to_str(uint32 /*field_pos*/, char const *src, char *&dst)
{
if(!src)
{
@ -53,14 +53,14 @@ void SQLStorageLoaderBase<T>::convert_to_str(uint32 /*field_pos*/, S /*src*/, ch
template<class T>
template<class D>
void SQLStorageLoaderBase<T>::convert_from_str(uint32 /*field_pos*/, char * /*src*/, D& dst)
void SQLStorageLoaderBase<T>::convert_from_str(uint32 /*field_pos*/, char const* /*src*/, D& dst)
{
dst = 0;
}
template<class T>
template<class V>
void SQLStorageLoaderBase<T>::storeValue(V value, SQLStorage &store, char *p, int x, uint32 &offset)
void SQLStorageLoaderBase<T>::storeValue(V value, SQLStorage &store, char *p, uint32 x, uint32 &offset)
{
T * subclass = (static_cast<T*>(this));
switch(store.dst_format[x])
@ -89,7 +89,7 @@ void SQLStorageLoaderBase<T>::storeValue(V value, SQLStorage &store, char *p, in
}
template<class T>
void SQLStorageLoaderBase<T>::storeValue(char * value, SQLStorage &store, char *p, int x, uint32 &offset)
void SQLStorageLoaderBase<T>::storeValue(char const* value, SQLStorage &store, char *p, uint32 x, uint32 &offset)
{
T * subclass = (static_cast<T*>(this));
switch(store.dst_format[x])
@ -203,7 +203,7 @@ void SQLStorageLoaderBase<T>::Load(SQLStorage &store)
case FT_FLOAT:
storeValue((float)fields[x].GetFloat(), store, p, x, offset); break;
case FT_STRING:
storeValue((char*)fields[x].GetString(), store, p, x, offset); break;
storeValue((char const*)fields[x].GetString(), store, p, x, offset); break;
}
++count;
}while( result->NextRow() );

View file

@ -41,7 +41,7 @@ void SqlDelayThread::run()
// empty the queue before exiting
ACE_Based::Thread::Sleep(loopSleepms);
SqlOperation* s;
SqlOperation* s = NULL;
while (m_sqlQueue.next(s))
{
s->Execute(m_dbEngine);

View file

@ -71,7 +71,7 @@ void SqlQuery::Execute(Database *db)
void SqlResultQueue::Update()
{
/// execute the callbacks waiting in the synchronization queue
MaNGOS::IQueryCallback* callback;
MaNGOS::IQueryCallback* callback = NULL;
while (next(callback))
{
callback->Execute();

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10791"
#define REVISION_NR "10792"
#endif // __REVISION_NR_H__