Skip to content

Commit

Permalink
Patcher - Send updater to the Client if needed
Browse files Browse the repository at this point in the history
+ auth.versions table (accepted build versions)
+ datapath and packetdelay config
  • Loading branch information
Hlkz committed Feb 21, 2015
1 parent c8ce563 commit 82b46e3
Show file tree
Hide file tree
Showing 10 changed files with 486 additions and 135 deletions.
70 changes: 28 additions & 42 deletions src/server/authserver/Authentication/AuthCodes.cpp
Expand Up @@ -16,66 +16,52 @@
*/

#include "AuthCodes.h"
#include "Database/DatabaseEnv.h"
#include <cstddef>
#include <map>

typedef std::map<int, RealmBuildInfo*> RealmBuildContainer;

namespace AuthHelper
{
static RealmBuildInfo const PostBcAcceptedClientBuilds[] =
{
{15595, 4, 3, 4, ' '},
{14545, 4, 2, 2, ' '},
{13623, 4, 0, 6, 'a'},
{13930, 3, 3, 5, 'a'}, // 3.3.5a China Mainland build
{12340, 3, 3, 5, 'a'},
{11723, 3, 3, 3, 'a'},
{11403, 3, 3, 2, ' '},
{11159, 3, 3, 0, 'a'},
{10505, 3, 2, 2, 'a'},
{9947, 3, 1, 3, ' '},
{8606, 2, 4, 3, ' '},
{0, 0, 0, 0, ' '} // terminator
};
RealmBuildContainer AcceptedClientBuilds;

static RealmBuildInfo const PreBcAcceptedClientBuilds[] =
void InitAcceptedClientBuilds()
{
{6141, 1, 12, 3, ' '},
{6005, 1, 12, 2, ' '},
{5875, 1, 12, 1, ' '},
{0, 0, 0, 0, ' '} // terminator
};
AcceptedClientBuilds.clear();

bool IsPreBCAcceptedClientBuild(int build)
{
for (int i = 0; PreBcAcceptedClientBuilds[i].Build; ++i)
if (PreBcAcceptedClientBuilds[i].Build == build)
return true;
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_VERSIONS);
PreparedQueryResult result = LoginDatabase.Query(stmt);

return false;
if (!result)
TC_LOG_ERROR("server.authserver", "Table `versions` is empty. No one will be able to log in.");

do {
Field* fields = result->Fetch();
RealmBuildInfo* newBuild = new RealmBuildInfo;
newBuild->Build = fields[0].GetUInt32();
newBuild->MajorVersion = fields[1].GetUInt32();
newBuild->MinorVersion = fields[2].GetUInt32();
newBuild->BugfixVersion = fields[3].GetUInt32();
newBuild->HotfixVersion = fields[4].GetUInt32();
AcceptedClientBuilds[newBuild->Build] = newBuild;
} while (result->NextRow());
}

bool IsPostBCAcceptedClientBuild(int build)
bool IsAcceptedClientBuild(int build)
{
for (int i = 0; PostBcAcceptedClientBuilds[i].Build; ++i)
if (PostBcAcceptedClientBuilds[i].Build == build)
for (RealmBuildContainer::iterator itr = AcceptedClientBuilds.begin(); itr != AcceptedClientBuilds.end(); itr++)
if (itr->second->Build == build)
return true;

return false;
}

bool IsAcceptedClientBuild(int build)
{
return (IsPostBCAcceptedClientBuild(build) || IsPreBCAcceptedClientBuild(build));
}

RealmBuildInfo const* GetBuildInfo(int build)
{
for (int i = 0; PostBcAcceptedClientBuilds[i].Build; ++i)
if (PostBcAcceptedClientBuilds[i].Build == build)
return &PostBcAcceptedClientBuilds[i];

for (int i = 0; PreBcAcceptedClientBuilds[i].Build; ++i)
if (PreBcAcceptedClientBuilds[i].Build == build)
return &PreBcAcceptedClientBuilds[i];
for (RealmBuildContainer::iterator itr = AcceptedClientBuilds.begin(); itr != AcceptedClientBuilds.end(); itr++)
if (itr->second->Build == build)
return itr->second;

return NULL;
}
Expand Down
3 changes: 1 addition & 2 deletions src/server/authserver/Authentication/AuthCodes.h
Expand Up @@ -88,10 +88,9 @@ struct RealmBuildInfo

namespace AuthHelper
{
void InitAcceptedClientBuilds();
RealmBuildInfo const* GetBuildInfo(int build);
bool IsAcceptedClientBuild(int build);
bool IsPostBCAcceptedClientBuild(int build);
bool IsPreBCAcceptedClientBuild(int build);
}

#endif
9 changes: 8 additions & 1 deletion src/server/authserver/Main.cpp
Expand Up @@ -25,6 +25,7 @@
*/

#include "AuthSocketMgr.h"
#include "AuthCodes.h"
#include "Common.h"
#include "Config.h"
#include "DatabaseEnv.h"
Expand All @@ -42,6 +43,7 @@

using boost::asio::ip::tcp;
using namespace boost::program_options;
using namespace AuthHelper;

#ifndef _TRINITY_REALM_CONFIG
# define _TRINITY_REALM_CONFIG "authserver.conf"
Expand All @@ -58,6 +60,8 @@ boost::asio::deadline_timer _dbPingTimer(_ioService);
uint32 _dbPingInterval;
LoginDatabaseWorkerPool LoginDatabase;

extern Patcher patcher;

int main(int argc, char** argv)
{
std::string configFile = _TRINITY_REALM_CONFIG;
Expand All @@ -79,6 +83,8 @@ int main(int argc, char** argv)
TC_LOG_INFO("server.authserver", "Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
TC_LOG_INFO("server.authserver", "Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);

patcher.Initialize();

// authserver PID file creation
std::string pidFile = sConfigMgr->GetStringDefault("PidFile", "");
if (!pidFile.empty())
Expand All @@ -96,6 +102,8 @@ int main(int argc, char** argv)
if (!StartDB())
return 1;

AuthHelper::InitAcceptedClientBuilds();

// Get the list of realms for the server
sRealmList->Initialize(_ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20));

Expand Down Expand Up @@ -144,7 +152,6 @@ int main(int argc, char** argv)
return 0;
}


/// Initialize connection to the database
bool StartDB()
{
Expand Down

0 comments on commit 82b46e3

Please sign in to comment.