mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 17:27:36 +01:00
*Add some missing contents in previous commits.
--HG-- branch : trunk
This commit is contained in:
@@ -162,6 +162,8 @@ bool GameObject::Create(uint32 guidlow, uint32 name_id, Map *map, float x, float
|
||||
|
||||
SetGoAnimProgress(animprogress);
|
||||
|
||||
SetByteValue(GAMEOBJECT_BYTES_1, 2, ArtKit);
|
||||
|
||||
// Spell charges for GAMEOBJECT_TYPE_SPELLCASTER (22)
|
||||
if (goinfo->type == GAMEOBJECT_TYPE_SPELLCASTER)
|
||||
m_charges = goinfo->spellcaster.charges;
|
||||
@@ -539,6 +541,7 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask)
|
||||
data.animprogress = GetGoAnimProgress();
|
||||
data.go_state = GetGoState();
|
||||
data.spawnMask = spawnMask;
|
||||
data.ArtKit = GetGoArtKit();
|
||||
|
||||
// updated in DB
|
||||
std::ostringstream ss;
|
||||
@@ -589,11 +592,12 @@ bool GameObject::LoadFromDB(uint32 guid, Map *map)
|
||||
|
||||
uint32 animprogress = data->animprogress;
|
||||
uint32 go_state = data->go_state;
|
||||
uint32 ArtKit = data->ArtKit;
|
||||
|
||||
m_DBTableGuid = guid;
|
||||
if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT);
|
||||
|
||||
if (!Create(guid,entry, map, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state) )
|
||||
if (!Create(guid,entry, map, x, y, z, ang, rotation0, rotation1, rotation2, rotation3, animprogress, go_state, ArtKit) )
|
||||
return false;
|
||||
|
||||
switch(GetGOInfo()->type)
|
||||
@@ -858,6 +862,14 @@ void GameObject::UseDoorOrButton(uint32 time_to_restore)
|
||||
|
||||
}
|
||||
|
||||
void GameObject::SetGoArtKit(uint8 kit)
|
||||
{
|
||||
SetByteValue(GAMEOBJECT_BYTES_1, 2, kit);
|
||||
GameObjectData *data = const_cast<GameObjectData*>(objmgr.GetGOData(m_DBTableGuid));
|
||||
if(data)
|
||||
data->ArtKit = kit;
|
||||
}
|
||||
|
||||
void GameObject::SwitchDoorOrButton(bool activate)
|
||||
{
|
||||
if(activate)
|
||||
|
||||
@@ -516,7 +516,7 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
|
||||
uint8 GetGoState() const { return GetByteValue(GAMEOBJECT_BYTES_1, 0); }
|
||||
void SetGoState(uint8 state) { SetByteValue(GAMEOBJECT_BYTES_1, 0, state); }
|
||||
uint8 GetGoArtKit() const { return GetByteValue(GAMEOBJECT_BYTES_1, 2); }
|
||||
void SetGoArtKit(uint8 artkit) { SetByteValue(GAMEOBJECT_BYTES_1, 2, artkit); }
|
||||
void SetGoArtKit(uint8 artkit);
|
||||
uint8 GetGoAnimProgress() const { return GetByteValue(GAMEOBJECT_BYTES_1, 3); }
|
||||
void SetGoAnimProgress(uint8 animprogress) { SetByteValue(GAMEOBJECT_BYTES_1, 3, animprogress); }
|
||||
|
||||
|
||||
@@ -570,6 +570,8 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer * data, UpdateMask
|
||||
IsActivateToQuest = true;
|
||||
updateMask->SetBit(GAMEOBJECT_DYNAMIC);
|
||||
}
|
||||
if (((GameObject*)this)->GetGoArtKit())
|
||||
updateMask->SetBit(GAMEOBJECT_BYTES_1);
|
||||
}
|
||||
}
|
||||
else //case UPDATETYPE_VALUES
|
||||
|
||||
@@ -194,7 +194,7 @@ bool ChatHandler::HandleAccountOnlineListCommand(const char* args)
|
||||
///- Get the username, last IP and GM level of each account
|
||||
// No SQL injection. account is uint32.
|
||||
// 0 1 2 3
|
||||
QueryResult *resultLogin = loginDatabase.PQuery("SELECT username, last_ip, gmlevel, expansion FROM account WHERE id = '%u'",account);
|
||||
QueryResult *resultLogin = LoginDatabase.PQuery("SELECT username, last_ip, gmlevel, expansion FROM account WHERE id = '%u'",account);
|
||||
|
||||
if(resultLogin)
|
||||
{
|
||||
|
||||
@@ -54,7 +54,7 @@ int m_ServiceStatus = -1;
|
||||
|
||||
DatabaseType WorldDatabase; ///< Accessor to the world database
|
||||
DatabaseType CharacterDatabase; ///< Accessor to the character database
|
||||
DatabaseType loginDatabase; ///< Accessor to the realm/login database
|
||||
DatabaseType LoginDatabase; ///< Accessor to the realm/login database
|
||||
|
||||
uint32 realmID; ///< Id of the realm
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
loopCounter = 0;
|
||||
sLog.outDetail ("Ping MySQL to keep connection alive");
|
||||
delete WorldDatabase.Query ("SELECT 1 FROM command LIMIT 1");
|
||||
delete loginDatabase.Query ("SELECT 1 FROM realmlist LIMIT 1");
|
||||
delete LoginDatabase.Query ("SELECT 1 FROM realmlist LIMIT 1");
|
||||
delete CharacterDatabase.Query ("SELECT 1 FROM bugreport LIMIT 1");
|
||||
}
|
||||
}
|
||||
@@ -239,7 +239,7 @@ int Master::Run()
|
||||
t.setPriority ((ZThread::Priority )2);
|
||||
|
||||
// set server online
|
||||
loginDatabase.PExecute("UPDATE realmlist SET color = 0, population = 0 WHERE id = '%d'",realmID);
|
||||
LoginDatabase.PExecute("UPDATE realmlist SET color = 0, population = 0 WHERE id = '%d'",realmID);
|
||||
|
||||
#ifdef WIN32
|
||||
if (sConfig.GetBoolDefault("Console.Enable", true) && (m_ServiceStatus == -1)/* need disable console in service mode*/)
|
||||
@@ -330,7 +330,7 @@ int Master::Run()
|
||||
sWorldSocketMgr->Wait ();
|
||||
|
||||
// set server offline
|
||||
loginDatabase.PExecute("UPDATE realmlist SET color = 2 WHERE id = '%d'",realmID);
|
||||
LoginDatabase.PExecute("UPDATE realmlist SET color = 2 WHERE id = '%d'",realmID);
|
||||
|
||||
///- Remove signal handling before leaving
|
||||
_UnhookSignals();
|
||||
@@ -346,7 +346,7 @@ int Master::Run()
|
||||
///- Wait for delay threads to end
|
||||
CharacterDatabase.HaltDelayThread();
|
||||
WorldDatabase.HaltDelayThread();
|
||||
loginDatabase.HaltDelayThread();
|
||||
LoginDatabase.HaltDelayThread();
|
||||
|
||||
sLog.outString( "Halting process..." );
|
||||
|
||||
@@ -440,7 +440,7 @@ bool Master::_StartDB()
|
||||
|
||||
///- Initialise the login database
|
||||
sLog.outString("Login Database: %s", dbstring.c_str() );
|
||||
if(!loginDatabase.Initialize(dbstring.c_str()))
|
||||
if(!LoginDatabase.Initialize(dbstring.c_str()))
|
||||
{
|
||||
sLog.outError("Cannot connect to login database %s",dbstring.c_str());
|
||||
return false;
|
||||
@@ -469,7 +469,7 @@ void Master::clearOnlineAccounts()
|
||||
{
|
||||
// Cleanup online status for characters hosted at current realm
|
||||
/// \todo Only accounts with characters logged on *this* realm should have online status reset. Move the online column from 'account' to 'realmcharacters'?
|
||||
loginDatabase.PExecute(
|
||||
LoginDatabase.PExecute(
|
||||
"UPDATE account SET online = 0 WHERE online > 0 "
|
||||
"AND id IN (SELECT acctid FROM realmcharacters WHERE realmid = '%d')",realmID);
|
||||
|
||||
|
||||
@@ -152,9 +152,9 @@ void RASocket::OnRead()
|
||||
AccountMgr::normilizeString(login);
|
||||
|
||||
///- Escape the Login to allow quotes in names
|
||||
loginDatabase.escape_string(login);
|
||||
LoginDatabase.escape_string(login);
|
||||
|
||||
QueryResult* result = loginDatabase.PQuery("SELECT gmlevel FROM account WHERE username = '%s'",login.c_str());
|
||||
QueryResult* result = LoginDatabase.PQuery("SELECT gmlevel FROM account WHERE username = '%s'",login.c_str());
|
||||
|
||||
///- If the user is not found, deny access
|
||||
if(!result)
|
||||
@@ -193,10 +193,10 @@ void RASocket::OnRead()
|
||||
|
||||
AccountMgr::normilizeString(login);
|
||||
AccountMgr::normilizeString(pw);
|
||||
loginDatabase.escape_string(login);
|
||||
loginDatabase.escape_string(pw);
|
||||
LoginDatabase.escape_string(login);
|
||||
LoginDatabase.escape_string(pw);
|
||||
|
||||
QueryResult *check = loginDatabase.PQuery(
|
||||
QueryResult *check = LoginDatabase.PQuery(
|
||||
"SELECT 1 FROM account WHERE username = '%s' AND sha_pass_hash=SHA1(CONCAT(username,':','%s'))",
|
||||
login.c_str(), pw.c_str());
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
extern RealmList m_realmList;
|
||||
|
||||
extern DatabaseType dbRealmServer;
|
||||
extern DatabaseType LoginDatabase;
|
||||
|
||||
#define ChunkSize 2048
|
||||
|
||||
@@ -324,7 +324,7 @@ void AuthSocket::_SetVSFields(const std::string& rI)
|
||||
const char *v_hex, *s_hex;
|
||||
v_hex = v.AsHexStr();
|
||||
s_hex = s.AsHexStr();
|
||||
dbRealmServer.PExecute("UPDATE account SET v = '%s', s = '%s' WHERE username = '%s'",v_hex,s_hex, _safelogin.c_str() );
|
||||
LoginDatabase.PExecute("UPDATE account SET v = '%s', s = '%s' WHERE username = '%s'",v_hex,s_hex, _safelogin.c_str() );
|
||||
OPENSSL_free((void*)v_hex);
|
||||
OPENSSL_free((void*)s_hex);
|
||||
}
|
||||
@@ -380,18 +380,18 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
//Escape the user login to avoid further SQL injection
|
||||
//Memory will be freed on AuthSocket object destruction
|
||||
_safelogin=_login;
|
||||
dbRealmServer.escape_string(_safelogin);
|
||||
LoginDatabase.escape_string(_safelogin);
|
||||
|
||||
pkt << (uint8) AUTH_LOGON_CHALLENGE;
|
||||
pkt << (uint8) 0x00;
|
||||
|
||||
///- Verify that this IP is not in the ip_banned table
|
||||
// No SQL injection possible (paste the IP address as passed by the socket)
|
||||
dbRealmServer.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
LoginDatabase.Execute("DELETE FROM ip_banned WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
|
||||
std::string address = GetRemoteAddress();
|
||||
dbRealmServer.escape_string(address);
|
||||
QueryResult *result = dbRealmServer.PQuery( "SELECT * FROM ip_banned WHERE ip = '%s'",address.c_str());
|
||||
LoginDatabase.escape_string(address);
|
||||
QueryResult *result = LoginDatabase.PQuery( "SELECT * FROM ip_banned WHERE ip = '%s'",address.c_str());
|
||||
if(result)
|
||||
{
|
||||
pkt << (uint8)REALM_AUTH_ACCOUNT_BANNED;
|
||||
@@ -403,7 +403,7 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
///- Get the account details from the account table
|
||||
// No SQL injection (escaped user name)
|
||||
|
||||
result = dbRealmServer.PQuery("SELECT sha_pass_hash,id,locked,last_ip,gmlevel FROM account WHERE username = '%s'",_safelogin.c_str ());
|
||||
result = LoginDatabase.PQuery("SELECT sha_pass_hash,id,locked,last_ip,gmlevel FROM account WHERE username = '%s'",_safelogin.c_str ());
|
||||
if( result )
|
||||
{
|
||||
///- If the IP is 'locked', check that the player comes indeed from the correct IP address
|
||||
@@ -431,9 +431,9 @@ bool AuthSocket::_HandleLogonChallenge()
|
||||
if (!locked)
|
||||
{
|
||||
//set expired bans to inactive
|
||||
dbRealmServer.Execute("UPDATE account_banned SET active = 0 WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
LoginDatabase.Execute("UPDATE account_banned SET active = 0 WHERE unbandate<=UNIX_TIMESTAMP() AND unbandate<>bandate");
|
||||
///- If the account is banned, reject the logon attempt
|
||||
QueryResult *banresult = dbRealmServer.PQuery("SELECT bandate,unbandate FROM account_banned WHERE id = %u AND active = 1", (*result)[1].GetUInt32());
|
||||
QueryResult *banresult = LoginDatabase.PQuery("SELECT bandate,unbandate FROM account_banned WHERE id = %u AND active = 1", (*result)[1].GetUInt32());
|
||||
if(banresult)
|
||||
{
|
||||
if((*banresult)[0].GetUInt64() == (*banresult)[1].GetUInt64())
|
||||
@@ -652,7 +652,7 @@ bool AuthSocket::_HandleLogonProof()
|
||||
///- Update the sessionkey, last_ip, last login time and reset number of failed logins in the account table for this account
|
||||
// No SQL injection (escaped user name) and IP address as received by socket
|
||||
const char* K_hex = K.AsHexStr();
|
||||
dbRealmServer.PExecute("UPDATE account SET sessionkey = '%s', last_ip = '%s', last_login = NOW(), locale = '%u', failed_logins = 0 WHERE username = '%s'", K_hex, GetRemoteAddress().c_str(), GetLocaleByName(_localizationName), _safelogin.c_str() );
|
||||
LoginDatabase.PExecute("UPDATE account SET sessionkey = '%s', last_ip = '%s', last_login = NOW(), locale = '%u', failed_logins = 0 WHERE username = '%s'", K_hex, GetRemoteAddress().c_str(), GetLocaleByName(_localizationName), _safelogin.c_str() );
|
||||
OPENSSL_free((void*)K_hex);
|
||||
|
||||
///- Finish SRP6 and send the final result to the client
|
||||
@@ -683,9 +683,9 @@ bool AuthSocket::_HandleLogonProof()
|
||||
if(MaxWrongPassCount > 0)
|
||||
{
|
||||
//Increment number of failed logins by one and if it reaches the limit temporarily ban that account or IP
|
||||
dbRealmServer.PExecute("UPDATE account SET failed_logins = failed_logins + 1 WHERE username = '%s'",_safelogin.c_str());
|
||||
LoginDatabase.PExecute("UPDATE account SET failed_logins = failed_logins + 1 WHERE username = '%s'",_safelogin.c_str());
|
||||
|
||||
if(QueryResult *loginfail = dbRealmServer.PQuery("SELECT id, failed_logins FROM account WHERE username = '%s'", _safelogin.c_str()))
|
||||
if(QueryResult *loginfail = LoginDatabase.PQuery("SELECT id, failed_logins FROM account WHERE username = '%s'", _safelogin.c_str()))
|
||||
{
|
||||
Field* fields = loginfail->Fetch();
|
||||
uint32 failed_logins = fields[1].GetUInt32();
|
||||
@@ -698,7 +698,7 @@ bool AuthSocket::_HandleLogonProof()
|
||||
if(WrongPassBanType)
|
||||
{
|
||||
uint32 acc_id = fields[0].GetUInt32();
|
||||
dbRealmServer.PExecute("INSERT INTO account_banned VALUES ('%u',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','Trinity realmd','Failed login autoban',1)",
|
||||
LoginDatabase.PExecute("INSERT INTO account_banned VALUES ('%u',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','Trinity realmd','Failed login autoban',1)",
|
||||
acc_id, WrongPassBanTime);
|
||||
sLog.outBasic("[AuthChallenge] account %s got banned for '%u' seconds because it failed to authenticate '%u' times",
|
||||
_login.c_str(), WrongPassBanTime, failed_logins);
|
||||
@@ -706,8 +706,8 @@ bool AuthSocket::_HandleLogonProof()
|
||||
else
|
||||
{
|
||||
std::string current_ip = GetRemoteAddress();
|
||||
dbRealmServer.escape_string(current_ip);
|
||||
dbRealmServer.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','Trinity realmd','Failed login autoban')",
|
||||
LoginDatabase.escape_string(current_ip);
|
||||
LoginDatabase.PExecute("INSERT INTO ip_banned VALUES ('%s',UNIX_TIMESTAMP(),UNIX_TIMESTAMP()+'%u','Trinity realmd','Failed login autoban')",
|
||||
current_ip.c_str(), WrongPassBanTime);
|
||||
sLog.outBasic("[AuthChallenge] IP %s got banned for '%u' seconds because account %s failed to authenticate '%u' times",
|
||||
current_ip.c_str(), WrongPassBanTime, _login.c_str(), failed_logins);
|
||||
@@ -753,7 +753,7 @@ bool AuthSocket::_HandleReconnectChallenge()
|
||||
_login = (const char*)ch->I;
|
||||
_safelogin = _login;
|
||||
|
||||
QueryResult *result = dbRealmServer.PQuery ("SELECT sessionkey FROM account WHERE username = '%s'", _safelogin.c_str ());
|
||||
QueryResult *result = LoginDatabase.PQuery ("SELECT sessionkey FROM account WHERE username = '%s'", _safelogin.c_str ());
|
||||
|
||||
// Stop if the account is not found
|
||||
if (!result)
|
||||
@@ -833,7 +833,7 @@ bool AuthSocket::_HandleRealmList()
|
||||
///- Get the user id (else close the connection)
|
||||
// No SQL injection (escaped user name)
|
||||
|
||||
QueryResult *result = dbRealmServer.PQuery("SELECT id,sha_pass_hash FROM account WHERE username = '%s'",_safelogin.c_str());
|
||||
QueryResult *result = LoginDatabase.PQuery("SELECT id,sha_pass_hash FROM account WHERE username = '%s'",_safelogin.c_str());
|
||||
if(!result)
|
||||
{
|
||||
sLog.outError("[ERROR] user %s tried to login and we cannot find him in the database.",_login.c_str());
|
||||
@@ -858,7 +858,7 @@ bool AuthSocket::_HandleRealmList()
|
||||
uint8 AmountOfCharacters;
|
||||
|
||||
// No SQL injection. id of realm is controlled by the database.
|
||||
result = dbRealmServer.PQuery( "SELECT numchars FROM realmcharacters WHERE realmid = '%d' AND acctid='%u'",i->second.m_ID,id);
|
||||
result = LoginDatabase.PQuery( "SELECT numchars FROM realmcharacters WHERE realmid = '%d' AND acctid='%u'",i->second.m_ID,id);
|
||||
if( result )
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
@@ -64,7 +64,7 @@ void HookSignals();
|
||||
bool stopEvent = false; ///< Setting it to true stops the server
|
||||
RealmList m_realmList; ///< Holds the list of realms for this server
|
||||
|
||||
DatabaseType dbRealmServer; ///< Accessor to the realm server database
|
||||
DatabaseType LoginDatabase; ///< Accessor to the realm server database
|
||||
|
||||
/// Print out the usage string for this program on the console.
|
||||
void usage(const char *prog)
|
||||
@@ -265,7 +265,7 @@ extern int main(int argc, char **argv)
|
||||
{
|
||||
loopCounter = 0;
|
||||
sLog.outDetail("Ping MySQL to keep connection alive");
|
||||
delete dbRealmServer.Query("SELECT 1 FROM realmlist LIMIT 1");
|
||||
delete LoginDatabase.Query("SELECT 1 FROM realmlist LIMIT 1");
|
||||
}
|
||||
#ifdef WIN32
|
||||
if (m_ServiceStatus == 0) stopEvent = true;
|
||||
@@ -274,7 +274,7 @@ extern int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
///- Wait for the delay thread to exit
|
||||
dbRealmServer.HaltDelayThread();
|
||||
LoginDatabase.HaltDelayThread();
|
||||
|
||||
///- Remove signal handling before leaving
|
||||
UnhookSignals();
|
||||
@@ -313,7 +313,7 @@ bool StartDB(std::string &dbstring)
|
||||
}
|
||||
|
||||
sLog.outString("Database: %s", dbstring.c_str() );
|
||||
if(!dbRealmServer.Initialize(dbstring.c_str()))
|
||||
if(!LoginDatabase.Initialize(dbstring.c_str()))
|
||||
{
|
||||
sLog.outError("Cannot connect to database");
|
||||
return false;
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
INSTANTIATE_SINGLETON_1( RealmList );
|
||||
|
||||
extern DatabaseType dbRealmServer;
|
||||
extern DatabaseType LoginDatabase;
|
||||
|
||||
RealmList::RealmList( ) : m_UpdateInterval(0), m_NextUpdateTime(time(NULL))
|
||||
{
|
||||
@@ -82,7 +82,7 @@ void RealmList::UpdateRealms(bool init)
|
||||
{
|
||||
sLog.outDetail("Updating Realm List...");
|
||||
|
||||
QueryResult *result = dbRealmServer.Query( "SELECT id, name, address, port, icon, color, timezone, allowedSecurityLevel, population FROM realmlist WHERE color <> 3 ORDER BY name" );
|
||||
QueryResult *result = LoginDatabase.Query( "SELECT id, name, address, port, icon, color, timezone, allowedSecurityLevel, population FROM realmlist WHERE color <> 3 ORDER BY name" );
|
||||
|
||||
///- Circle through results and add them to the realm map
|
||||
if(result)
|
||||
|
||||
Reference in New Issue
Block a user