[9169] Move accaptable builds check/list preparing to functions.

Maybe DBCStore.* not best place for its but we not have src/game local file for common functions...
This commit is contained in:
VladimirMangos 2010-01-13 09:02:37 +03:00
parent e246b49e55
commit 10de01c6f7
5 changed files with 29 additions and 21 deletions

View file

@ -159,6 +159,25 @@ DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore(WorldSafeLocsEntryfmt);
typedef std::list<std::string> StoreProblemList; typedef std::list<std::string> StoreProblemList;
bool IsAcceptableClientBuild(uint32 build)
{
int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD;
for(int i = 0; accepted_versions[i]; ++i)
if(build == accepted_versions[i])
return true;
return false;
}
std::string AcceptableClientBuildsListStr()
{
std::ostringstream data;
int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD;
for(int i = 0; accepted_versions[i]; ++i)
data << accepted_versions[i] << " ";
return data.str();
}
static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, const std::string& filename) static bool LoadDBC_assert_print(uint32 fsize,uint32 rsize, const std::string& filename)
{ {
sLog.outError("ERROR: Size of '%s' setted by format string (%u) not equal size of C++ structure (%u).",filename.c_str(),fsize,rsize); sLog.outError("ERROR: Size of '%s' setted by format string (%u) not equal size of C++ structure (%u).",filename.c_str(),fsize,rsize);
@ -513,7 +532,7 @@ void LoadDBCStores(const std::string& dataPath)
!sAreaStore.LookupEntry(2905) || // last area (areaflag) added in 3.1.3 !sAreaStore.LookupEntry(2905) || // last area (areaflag) added in 3.1.3
!sItemStore.LookupEntry(46894) ) // last client known item added in 3.1.3 !sItemStore.LookupEntry(46894) ) // last client known item added in 3.1.3
{ {
sLog.outError("\nYou have _outdated_ DBC files. Please extract correct versions from current using client."); sLog.outError("\nYou have _outdated_ DBC files. Please re-extract DBC files for one from client build: %s",AcceptableClientBuildsListStr().c_str());
exit(1); exit(1);
} }

View file

@ -25,6 +25,9 @@
#include <list> #include <list>
bool IsAcceptableClientBuild(uint32 build);
std::string AcceptableClientBuildsListStr();
typedef std::list<uint32> SimpleFactionsList; typedef std::list<uint32> SimpleFactionsList;
SimpleFactionsList const* GetFactionTeamList(uint32 faction); SimpleFactionsList const* GetFactionTeamList(uint32 faction);

View file

@ -42,6 +42,7 @@
#include "WorldSession.h" #include "WorldSession.h"
#include "WorldSocketMgr.h" #include "WorldSocketMgr.h"
#include "Log.h" #include "Log.h"
#include "DBCStores.h"
#if defined( __GNUC__ ) #if defined( __GNUC__ )
#pragma pack(1) #pragma pack(1)
@ -761,18 +762,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
clientSeed); clientSeed);
// Check the version of client trying to connect // Check the version of client trying to connect
bool valid_version = false; if(!IsAcceptableClientBuild(ClientBuild))
int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD;
for(int i = 0; accepted_versions[i]; ++i)
{
if(ClientBuild == accepted_versions[i])
{
valid_version = true;
break;
}
}
if(!valid_version)
{ {
packet.Initialize (SMSG_AUTH_RESPONSE, 1); packet.Initialize (SMSG_AUTH_RESPONSE, 1);
packet << uint8 (AUTH_VERSION_MISMATCH); packet << uint8 (AUTH_VERSION_MISMATCH);

View file

@ -229,13 +229,9 @@ int Master::Run()
// set realmbuilds depend on mangosd expected builds, and set server online // set realmbuilds depend on mangosd expected builds, and set server online
{ {
std::ostringstream data; std::string builds = AcceptableClientBuildsListStr();
int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD; loginDatabase.escape_string(builds);
for(int i = 0; accepted_versions[i]; ++i) loginDatabase.PExecute("UPDATE realmlist SET color = 0, population = 0, realmbuilds = '%s' WHERE id = '%d'", builds.c_str(), realmID);
{
data << accepted_versions[i] << " ";
}
loginDatabase.PExecute("UPDATE realmlist SET color = 0, population = 0, realmbuilds = '%s' WHERE id = '%d'", data.str().c_str(), realmID);
} }
ACE_Based::Thread* cliThread = NULL; ACE_Based::Thread* cliThread = NULL;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9168" #define REVISION_NR "9169"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__