Update some code for 322a

--HG--
branch : trunk
This commit is contained in:
n0n4m3
2009-12-17 12:36:55 +01:00
parent fec5aa38cd
commit f20b25d1c9
5 changed files with 118 additions and 60 deletions

View File

@@ -259,6 +259,8 @@ World::AddSession_ (WorldSession* s)
pkt << uint32(sWorld.getConfig(CONFIG_CLIENTCACHE_VERSION));
s->SendPacket(&pkt);
s->SendAccountDataTimes(GLOBAL_CACHE_MASK);
s->SendTutorialsData();
UpdateMaxSessionCounters ();
@@ -269,7 +271,6 @@ World::AddSession_ (WorldSession* s)
float popu = GetActiveSessionCount (); // updated number of users on the server
popu /= pLimit;
popu *= 2;
loginDatabase.PExecute ("UPDATE realmlist SET population = '%f' WHERE id = '%d'", popu, realmID);
sLog.outDetail ("Server Population (%f).", popu);
}
}
@@ -365,6 +366,7 @@ bool World::RemoveQueuedPlayer(WorldSession* sess)
pkt << uint32(sWorld.getConfig(CONFIG_CLIENTCACHE_VERSION));
pop_sess->SendPacket(&pkt);
pop_sess->SendAccountDataTimes(GLOBAL_CACHE_MASK);
pop_sess->SendTutorialsData();
m_QueuedPlayer.pop_front();
@@ -553,41 +555,40 @@ void World::LoadConfigSettings(bool reload)
rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = sConfig.GetFloatDefault("DurabilityLoss.OnDeath", 10.0f);
if (rate_values[RATE_DURABILITY_LOSS_ON_DEATH] < 0.0f)
{
sLog.outError("DurabilityLoss.OnDeath (%f) must be >= 0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_ON_DEATH]);
sLog.outError("DurabilityLoss.OnDeath (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_ON_DEATH]);
rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = 0.0f;
}
if (rate_values[RATE_DURABILITY_LOSS_ON_DEATH] > 100.0f)
{
sLog.outError("DurabilityLoss.OnDeath (%f) must be <= 100. Using 100.0 instead.",rate_values[RATE_DURABILITY_LOSS_ON_DEATH]);
rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = 100.0f;
sLog.outError("DurabilityLoss.OnDeath (%f) must be <=100. Using 100.0 instead.",rate_values[RATE_DURABILITY_LOSS_ON_DEATH]);
rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = 0.0f;
}
rate_values[RATE_DURABILITY_LOSS_ON_DEATH] = rate_values[RATE_DURABILITY_LOSS_ON_DEATH] / 100.0f;
rate_values[RATE_DURABILITY_LOSS_DAMAGE] = sConfig.GetFloatDefault("DurabilityLossChance.Damage",0.5f);
if (rate_values[RATE_DURABILITY_LOSS_DAMAGE] < 0.0f)
{
sLog.outError("DurabilityLossChance.Damage (%f) must be >= 0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_DAMAGE]);
sLog.outError("DurabilityLossChance.Damage (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_DAMAGE]);
rate_values[RATE_DURABILITY_LOSS_DAMAGE] = 0.0f;
}
rate_values[RATE_DURABILITY_LOSS_ABSORB] = sConfig.GetFloatDefault("DurabilityLossChance.Absorb",0.5f);
if (rate_values[RATE_DURABILITY_LOSS_ABSORB] < 0.0f)
{
sLog.outError("DurabilityLossChance.Absorb (%f) must be >= 0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_ABSORB]);
sLog.outError("DurabilityLossChance.Absorb (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_ABSORB]);
rate_values[RATE_DURABILITY_LOSS_ABSORB] = 0.0f;
}
rate_values[RATE_DURABILITY_LOSS_PARRY] = sConfig.GetFloatDefault("DurabilityLossChance.Parry",0.05f);
if (rate_values[RATE_DURABILITY_LOSS_PARRY] < 0.0f)
{
sLog.outError("DurabilityLossChance.Parry (%f) must be >= 0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_PARRY]);
sLog.outError("DurabilityLossChance.Parry (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_PARRY]);
rate_values[RATE_DURABILITY_LOSS_PARRY] = 0.0f;
}
rate_values[RATE_DURABILITY_LOSS_BLOCK] = sConfig.GetFloatDefault("DurabilityLossChance.Block",0.05f);
if (rate_values[RATE_DURABILITY_LOSS_BLOCK] < 0.0f)
{
sLog.outError("DurabilityLossChance.Block (%f) must be >= 0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_BLOCK]);
sLog.outError("DurabilityLossChance.Block (%f) must be >=0. Using 0.0 instead.",rate_values[RATE_DURABILITY_LOSS_BLOCK]);
rate_values[RATE_DURABILITY_LOSS_BLOCK] = 0.0f;
}
///- Read other configuration items from the config file
m_configs[CONFIG_DURABILITY_LOSS_IN_PVP] = sConfig.GetBoolDefault("DurabilityLoss.InPvP", false);
@@ -1193,7 +1194,7 @@ void World::LoadConfigSettings(bool reload)
m_configs[CONFIG_INTERVAL_LOG_UPDATE] = sConfig.GetIntDefault("RecordUpdateTimeDiffInterval", 60000);
m_configs[CONFIG_MIN_LOG_UPDATE] = sConfig.GetIntDefault("MinRecordUpdateTimeDiff", 10);
m_configs[CONFIG_CHECK_DB] = sConfig.GetBoolDefault("CheckDB", true);
m_configs[CONFIG_NUMTHREADS] = sConfig.GetIntDefault("MapUpdate.Threads",1);
m_configs[CONFIG_NUMTHREADS] = sConfig.GetIntDefault("MapUpdate.Threads", 1);
std::string forbiddenmaps = sConfig.GetStringDefault("ForbiddenMaps", "");
char * forbiddenMaps = new char[forbiddenmaps.length() + 1];
@@ -1303,9 +1304,6 @@ void World::SetInitialWorldSettings()
sLog.outString("Loading Page Texts...");
objmgr.LoadPageTexts();
sLog.outString("Loading Player info in cache...");
objmgr.LoadPlayerInfoInCache();
sLog.outString("Loading Game Object Templates..."); // must be after LoadPageTexts
objmgr.LoadGameobjectInfo();
@@ -1477,9 +1475,6 @@ void World::SetInitialWorldSettings()
sLog.outString("Loading Player Corpses...");
objmgr.LoadCorpses();
sLog.outString( "Loading Player level dependent mail rewards..." );
objmgr.LoadMailLevelRewards();
sLog.outString("Loading Disabled Spells...");
objmgr.LoadSpellDisabledEntrys();
@@ -2584,13 +2579,12 @@ void World::LoadDBVersion()
m_CreatureEventAIVersion = "Unknown creature EventAI.";
}
void World::UpdateAreaDependentAuras()
void World::ProcessStartEvent()
{
SessionMap::const_iterator itr;
for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
if (itr->second && itr->second->GetPlayer() && itr->second->GetPlayer()->IsInWorld())
{
itr->second->GetPlayer()->UpdateAreaDependentAuras(itr->second->GetPlayer()->GetAreaId());
itr->second->GetPlayer()->UpdateZoneDependentAuras(itr->second->GetPlayer()->GetZoneId());
}
isEventKillStart = true;
}
void World::ProcessStopEvent()
{
isEventKillStart = false;
}

View File

@@ -45,6 +45,7 @@ struct ScriptInfo;
class SqlResultQueue;
class QueryResult;
class WorldSocket;
class SystemMgr;
// ServerMessages.dbc
enum ServerMessageType
@@ -81,14 +82,8 @@ enum WorldTimers
WUPDATE_EVENTS = 6,
WUPDATE_CLEANDB = 7,
WUPDATE_AUTOBROADCAST = 8,
WUPDATE_COUNT = 9
};
// States than may change after server started
enum WorldStates
{
WORLDSTATE_WINTERGRASP_CONTROLING_FACTION,
WORLDSTATE_VALUE_COUNT,
WUPDATE_MAILBOXQUEUE = 9,
WUPDATE_COUNT = 10
};
/// Configuration elements
@@ -261,6 +256,7 @@ enum WorldConfigs
CONFIG_MIN_LOG_UPDATE,
CONFIG_CHECK_DB,
CONFIG_ENABLE_SINFO_LOGIN,
CONFIG_PLAYER_ALLOW_COMMANDS,
CONFIG_PET_LOS,
CONFIG_NUMTHREADS,
CONFIG_OFFHAND_CHECK_AT_SPELL_UNLEARN,
@@ -561,27 +557,17 @@ class World
/// Set a server configuration element (see #WorldConfigs)
void setConfig(uint32 index,uint32 value)
{
if (index < CONFIG_VALUE_COUNT)
m_configs[index] = value;
if(index<CONFIG_VALUE_COUNT)
m_configs[index]=value;
}
/// Get a server configuration element (see #WorldConfigs)
uint32 getConfig(uint32 index) const
{
return index < CONFIG_VALUE_COUNT ? m_configs[index] : 0;
}
// Set a server state - Those general values that can change after server have been setup
void setState(uint32 index, uint32 value)
{
if (index < WORLDSTATE_VALUE_COUNT)
m_states[index] = value;
}
// Get a server state element
uint32 getState(uint32 index) const
{
return index < WORLDSTATE_VALUE_COUNT ? m_states[index] : 0;
if(index<CONFIG_VALUE_COUNT)
return m_configs[index];
else
return 0;
}
/// Are we on a "Player versus Player" server?
@@ -610,6 +596,19 @@ class World
static float GetVisibleUnitGreyDistance() { return m_VisibleUnitGreyDistance; }
static float GetVisibleObjectGreyDistance() { return m_VisibleObjectGreyDistance; }
void SetWintergrapsTimer(uint32 timer, uint32 state)
{
m_WintergrapsTimer = timer;
m_WintergrapsState = state;
}
uint32 GetWintergrapsTimer() { return m_WintergrapsTimer; }
uint32 GetWintergrapsState() { return m_WintergrapsState; }
uint32 m_WintergrapsTimer;
uint32 m_WintergrapsState;
void ProcessCliCommands();
void QueueCliCommand( CliCommandHolder::Print* zprintf, char const* input ) { cliCmdQueue.add(new CliCommandHolder(input, zprintf)); }
@@ -637,7 +636,11 @@ class World
void LoadAutobroadcasts();
void UpdateAreaDependentAuras();
void ProcessStartEvent();
void ProcessStopEvent();
bool GetEventKill() { return isEventKillStart; }
bool isEventKillStart;
protected:
void _UpdateGameTime();
// callback for UpdateRealmCharacters
@@ -680,7 +683,6 @@ class World
float rate_values[MAX_RATES];
uint32 m_configs[CONFIG_VALUE_COUNT];
uint32 m_states[WORLDSTATE_VALUE_COUNT];
int32 m_playerLimit;
AccountTypes m_allowedSecurityLevel;
LocaleConstant m_defaultDbcLocale; // from config for one from loaded DBC locales
@@ -728,4 +730,3 @@ extern uint32 realmID;
#define sWorld Trinity::Singleton<World>::Instance()
#endif
/// @}

View File

@@ -655,13 +655,15 @@ void WorldSession::SetAccountData(AccountDataType type, time_t time_, std::strin
m_accountData[type].Data = data;
}
void WorldSession::SendAccountDataTimes()
void WorldSession::SendAccountDataTimes(uint32 mask)
{
WorldPacket data( SMSG_ACCOUNT_DATA_TIMES, 4+1+8*4 ); // changed in WotLK
WorldPacket data( SMSG_ACCOUNT_DATA_TIMES, 4+1+4+8*4 ); // changed in WotLK
data << uint32(time(NULL)); // unix time of something
data << uint8(1);
for (int i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
data << uint32(m_accountData[i].Time); // also unix time
data << uint32(mask); // type mask
for(uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
if(mask & (1 << i))
data << uint32(GetAccountData(AccountDataType(i))->Time);// also unix time
SendPacket(&data);
}
@@ -768,6 +770,51 @@ void WorldSession::ReadMovementInfo(WorldPacket &data, MovementInfo *mi)
}
}
void WorldSession::WriteMovementInfo(WorldPacket *data, MovementInfo *mi)
{
data->appendPackGUID(mi->guid);
*data << mi->flags;
*data << mi->unk1;
*data << mi->time;
*data << mi->x;
*data << mi->y;
*data << mi->z;
*data << mi->o;
if(mi->HasMovementFlag(MOVEMENTFLAG_ONTRANSPORT))
{
data->appendPackGUID(mi->t_guid);
*data << mi->t_x;
*data << mi->t_y;
*data << mi->t_z;
*data << mi->t_o;
*data << mi->t_time;
*data << mi->t_seat;
}
if((mi->HasMovementFlag(MovementFlags(MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING))) || (mi->unk1 & 0x20))
{
*data << mi->s_pitch;
}
*data << mi->fallTime;
if(mi->HasMovementFlag(MOVEMENTFLAG_JUMPING))
{
*data << mi->j_zspeed;
*data << mi->j_sinAngle;
*data << mi->j_cosAngle;
*data << mi->j_xyspeed;
}
if(mi->HasMovementFlag(MOVEMENTFLAG_SPLINE))
{
*data << mi->u_unk1;
}
}
void WorldSession::ReadAddonsInfo(WorldPacket &data)
{
if (data.rpos() + 4 > data.size())

View File

@@ -28,6 +28,7 @@
#include "Common.h"
#include "SharedDefines.h"
class MailItemsInfo;
struct ItemPrototype;
struct AuctionEntry;
struct DeclinedName;
@@ -41,6 +42,7 @@ class Unit;
class GameObject;
class WorldPacket;
class WorldSocket;
class WorldSession;
class QueryResult;
class LoginQueryHolder;
class CharacterHandler;
@@ -126,6 +128,7 @@ class TRINITY_DLL_SPEC WorldSession
void SendAddonsInfo();
void ReadMovementInfo(WorldPacket &data, MovementInfo *mi);
void WriteMovementInfo(WorldPacket *data, MovementInfo *mi);
void SendPacket(WorldPacket const* packet);
void SendNotification(const char *format,...) ATTR_PRINTF(2,3);
@@ -203,7 +206,7 @@ class TRINITY_DLL_SPEC WorldSession
// Account Data
AccountData *GetAccountData(AccountDataType type) { return &m_accountData[type]; }
void SetAccountData(AccountDataType type, time_t time_, std::string data);
void SendAccountDataTimes();
void SendAccountDataTimes(uint32 mask);
void LoadGlobalAccountData();
void LoadAccountData(QueryResult* result, uint32 mask);
void LoadTutorialsData();
@@ -222,8 +225,12 @@ class TRINITY_DLL_SPEC WorldSession
m_TutorialsChanged = true;
}
}
//used with item_page table
//mail
//used with item_page table
bool SendItemInfo( uint32 itemid, WorldPacket data );
static void SendReturnToSender(uint8 messageType, uint32 sender_acc, uint32 sender_guid, uint32 receiver_guid, const std::string& subject, uint32 itemTextId, MailItemsInfo *mi, uint32 money, uint16 mailTemplateId = 0);
static void SendMailTo(Player* receiver, uint8 messageType, uint8 stationery, uint32 sender_guidlow_or_entry, uint32 received_guidlow, std::string subject, uint32 itemTextId, MailItemsInfo* mi, uint32 money, uint32 COD, uint32 checked, uint32 deliver_delay = 0, uint16 mailTemplateId = 0);
//auction
void SendAuctionHello( uint64 guid, Creature * unit );
@@ -573,6 +580,7 @@ class TRINITY_DLL_SPEC WorldSession
void HandleReclaimCorpseOpcode( WorldPacket& recvPacket );
void HandleCorpseQueryOpcode( WorldPacket& recvPacket );
void HandleCorpseMapPositionQuery( WorldPacket& recvPacket );
void HandleResurrectResponseOpcode(WorldPacket& recvPacket);
void HandleSummonResponseOpcode(WorldPacket& recv_data);
@@ -647,6 +655,7 @@ class TRINITY_DLL_SPEC WorldSession
void HandleFarSightOpcode(WorldPacket& recv_data);
void HandleSetLfgOpcode(WorldPacket& recv_data);
void HandleSetDungeonDifficultyOpcode(WorldPacket& recv_data);
void HandleSetRaidDifficultyOpcode(WorldPacket& recv_data);
void HandleMoveSetCanFlyAckOpcode(WorldPacket& recv_data);
void HandleLfgSetAutoJoinOpcode(WorldPacket& recv_data);
void HandleLfgClearAutoJoinOpcode(WorldPacket& recv_data);
@@ -686,6 +695,7 @@ class TRINITY_DLL_SPEC WorldSession
void HandleSocketOpcode(WorldPacket& recv_data);
void HandleCancelTempEnchantmentOpcode(WorldPacket& recv_data);
void HandleItemRefundInfoRequest(WorldPacket& recv_data);
void HandleChannelVoiceOnOpcode(WorldPacket & recv_data);
void HandleVoiceSessionEnableOpcode(WorldPacket& recv_data);
@@ -733,6 +743,7 @@ class TRINITY_DLL_SPEC WorldSession
void HandleEquipmentSetSave(WorldPacket& recv_data);
void HandleEquipmentSetDelete(WorldPacket& recv_data);
void HandleEquipmentSetUse(WorldPacket& recv_data);
void HandleWorldStateUITimerUpdate(WorldPacket& recv_data);
void HandleOnPVPKill(Player *killed);
bool HandleOnPlayerChat(const char *text);
uint32 HandleOnGetXP(uint32 amount);
@@ -776,4 +787,3 @@ class TRINITY_DLL_SPEC WorldSession
};
#endif
/// @}

View File

@@ -255,8 +255,13 @@ int WorldSocket::open (void *a)
m_Address = remote_addr.get_host_addr ();
// Send startup packet.
WorldPacket packet (SMSG_AUTH_CHALLENGE, 4);
WorldPacket packet (SMSG_AUTH_CHALLENGE, 24);
packet << uint32(1); // 1...31
packet << m_Seed;
packet << uint32(0xF3539DA3); // random data
packet << uint32(0x6E8547B9); // random data
packet << uint32(0x9A6AA2F8); // random data
packet << uint32(0xA4F170F4); // random data
if (SendPacket (packet) == -1)
return -1;
@@ -690,6 +695,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
uint8 digest[20];
uint32 clientSeed;
uint32 unk2, unk3;
uint64 unk4;
uint32 BuiltNumberClient;
uint32 id, security;
//uint8 expansion = 0;
@@ -717,6 +723,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
recvPacket >> account;
recvPacket >> unk3;
recvPacket >> clientSeed;
recvPacket >> unk4;
recvPacket.read (digest, 20);
DEBUG_LOG ("WorldSocket::HandleAuthSession: client %u, unk2 %u, account %s, unk3 %u, clientseed %u",
@@ -1066,4 +1073,3 @@ bool WorldSocket::iFlushPacketQueue()
return haveone;
}