mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[0062] Send SMSG_DEFENSE_MESSAGE, SMSG_ZONE_UNDER_ATTACK only to players outside of instances
Also remove team argument from SendDefenseMessage as all texts are sent to all teams, use seperate function to send zone attack message, cleanup some send message functions and remove deprecated send text functions
This commit is contained in:
parent
a004c7b50c
commit
27fefb1e96
4 changed files with 44 additions and 78 deletions
|
|
@ -1994,14 +1994,10 @@ bool Creature::LoadCreatureAddon(bool reload)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a message to LocalDefense channel for players opposition team in the zone
|
/// Sends a message to LocalDefense and WorldDefense channels for players of the other team
|
||||||
void Creature::SendZoneUnderAttackMessage(Player* attacker)
|
void Creature::SendZoneUnderAttackMessage(Player* attacker)
|
||||||
{
|
{
|
||||||
Team enemy_team = attacker->GetTeam();
|
sWorld.SendZoneUnderAttackMessage(GetZoneId(), attacker->GetTeam() == ALLIANCE ? HORDE : ALLIANCE);
|
||||||
|
|
||||||
WorldPacket data(SMSG_ZONE_UNDER_ATTACK, 4);
|
|
||||||
data << uint32(GetZoneId());
|
|
||||||
sWorld.SendGlobalMessage(&data, NULL, (enemy_team == ALLIANCE ? HORDE : ALLIANCE));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::SetInCombatWithZone()
|
void Creature::SetInCombatWithZone()
|
||||||
|
|
|
||||||
|
|
@ -1596,23 +1596,6 @@ void World::Update(uint32 diff)
|
||||||
sTerrainMgr.Update(diff);
|
sTerrainMgr.Update(diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a packet to all players (except self if mentioned)
|
|
||||||
void World::SendGlobalMessage(WorldPacket* packet, WorldSession* self /*= NULL*/, Team team /*= TEAM_NONE*/)
|
|
||||||
{
|
|
||||||
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 != self &&
|
|
||||||
(team == TEAM_NONE || itr->second->GetPlayer()->GetTeam() == team))
|
|
||||||
{
|
|
||||||
itr->second->SendPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace MaNGOS
|
namespace MaNGOS
|
||||||
{
|
{
|
||||||
class WorldWorldTextBuilder
|
class WorldWorldTextBuilder
|
||||||
|
|
@ -1670,7 +1653,7 @@ namespace MaNGOS
|
||||||
};
|
};
|
||||||
} // namespace MaNGOS
|
} // namespace MaNGOS
|
||||||
|
|
||||||
/// Send a System Message to all players (except self if mentioned)
|
/// Sends a system message to all players
|
||||||
void World::SendWorldText(int32 string_id, ...)
|
void World::SendWorldText(int32 string_id, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
@ -1689,59 +1672,61 @@ void World::SendWorldText(int32 string_id, ...)
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// DEPRICATED, only for debug purpose. Send a System Message to all players (except self if mentioned)
|
/// Sends a packet to all players with optional team and instance restrictions
|
||||||
void World::SendGlobalText(const char* text, WorldSession* self)
|
void World::SendGlobalMessage(WorldPacket* packet)
|
||||||
{
|
{
|
||||||
WorldPacket data;
|
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
|
||||||
|
|
||||||
// need copy to prevent corruption by strtok call in LineFromMessage original string
|
|
||||||
char* buf = mangos_strdup(text);
|
|
||||||
char* pos = buf;
|
|
||||||
|
|
||||||
while (char* line = ChatHandler::LineFromMessage(pos))
|
|
||||||
{
|
|
||||||
ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, line);
|
|
||||||
SendGlobalMessage(&data, self);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete[] buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send a packet to all players (or players selected team) in the zone (except self if mentioned)
|
|
||||||
void World::SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self /*= NULL*/, Team team /*= TEAM_NONE*/)
|
|
||||||
{
|
|
||||||
SessionMap::const_iterator itr;
|
|
||||||
for (itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
|
|
||||||
{
|
{
|
||||||
if (itr->second &&
|
if (itr->second &&
|
||||||
itr->second->GetPlayer() &&
|
itr->second->GetPlayer() &&
|
||||||
itr->second->GetPlayer()->IsInWorld() &&
|
itr->second->GetPlayer()->IsInWorld())
|
||||||
itr->second->GetPlayer()->GetZoneId() == zone &&
|
|
||||||
itr->second != self &&
|
|
||||||
(team == TEAM_NONE || itr->second->GetPlayer()->GetTeam() == team))
|
|
||||||
{
|
{
|
||||||
itr->second->SendPacket(packet);
|
itr->second->SendPacket(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a System Message to all players in the zone (except self if mentioned)
|
/// Sends a server message to the specified or all players
|
||||||
void World::SendZoneText(uint32 zone, const char* text, WorldSession* self /*= NULL*/, Team team /*= TEAM_NONE*/)
|
void World::SendServerMessage(ServerMessageType type, const char* text /*=""*/, Player* player /*= NULL*/)
|
||||||
{
|
{
|
||||||
WorldPacket data;
|
WorldPacket data(SMSG_SERVER_MESSAGE, 50); // guess size
|
||||||
ChatHandler::FillMessageData(&data, NULL, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, text);
|
data << uint32(type);
|
||||||
SendZoneMessage(zone, &data, self, team);
|
data << text;
|
||||||
|
|
||||||
|
if (player)
|
||||||
|
player->GetSession()->SendPacket(&data);
|
||||||
|
else
|
||||||
|
SendGlobalMessage(&data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a server wide defense message to all players (or players of the specified team)
|
/// Sends a zone under attack message to all players not in an instance
|
||||||
void World::SendDefenseMessage(uint32 zoneId, int32 textId, Team team /*= TEAM_NONE*/)
|
void World::SendZoneUnderAttackMessage(uint32 zoneId, Team team)
|
||||||
|
{
|
||||||
|
WorldPacket data(SMSG_ZONE_UNDER_ATTACK, 4);
|
||||||
|
data << uint32(zoneId);
|
||||||
|
|
||||||
|
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
|
||||||
|
{
|
||||||
|
if (itr->second &&
|
||||||
|
itr->second->GetPlayer() &&
|
||||||
|
itr->second->GetPlayer()->IsInWorld() &&
|
||||||
|
itr->second->GetPlayer()->GetTeam() == team &&
|
||||||
|
!itr->second->GetPlayer()->GetMap()->Instanceable())
|
||||||
|
{
|
||||||
|
itr->second->SendPacket(&data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sends a world defense message to all players not in an instance
|
||||||
|
void World::SendDefenseMessage(uint32 zoneId, int32 textId)
|
||||||
{
|
{
|
||||||
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
|
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (itr->second &&
|
if (itr->second &&
|
||||||
itr->second->GetPlayer() &&
|
itr->second->GetPlayer() &&
|
||||||
itr->second->GetPlayer()->IsInWorld() &&
|
itr->second->GetPlayer()->IsInWorld() &&
|
||||||
(team == TEAM_NONE || itr->second->GetPlayer()->GetTeam() == team))
|
!itr->second->GetPlayer()->GetMap()->Instanceable())
|
||||||
{
|
{
|
||||||
char const* message = itr->second->GetMangosString(textId);
|
char const* message = itr->second->GetMangosString(textId);
|
||||||
uint32 messageLength = strlen(message) + 1;
|
uint32 messageLength = strlen(message) + 1;
|
||||||
|
|
@ -1916,7 +1901,7 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Display a shutdown message to the user(s)
|
/// Display a shutdown message to the user(s)
|
||||||
void World::ShutdownMsg(bool show, Player* player)
|
void World::ShutdownMsg(bool show /*= false*/, Player* player /*= NULL*/)
|
||||||
{
|
{
|
||||||
// not show messages for idle shutdown mode
|
// not show messages for idle shutdown mode
|
||||||
if (m_ShutdownMask & SHUTDOWN_MASK_IDLE)
|
if (m_ShutdownMask & SHUTDOWN_MASK_IDLE)
|
||||||
|
|
@ -1956,19 +1941,6 @@ void World::ShutdownCancel()
|
||||||
DEBUG_LOG("Server %s cancelled.", (m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shutdown"));
|
DEBUG_LOG("Server %s cancelled.", (m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shutdown"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send a server message to the user(s)
|
|
||||||
void World::SendServerMessage(ServerMessageType type, const char* text /*=""*/, Player* player /*= NULL*/)
|
|
||||||
{
|
|
||||||
WorldPacket data(SMSG_SERVER_MESSAGE, 50); // guess size
|
|
||||||
data << uint32(type);
|
|
||||||
data << text;
|
|
||||||
|
|
||||||
if (player)
|
|
||||||
player->GetSession()->SendPacket(&data);
|
|
||||||
else
|
|
||||||
SendGlobalMessage(&data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void World::UpdateSessions(uint32 diff)
|
void World::UpdateSessions(uint32 diff)
|
||||||
{
|
{
|
||||||
///- Add new sessions
|
///- Add new sessions
|
||||||
|
|
|
||||||
|
|
@ -507,12 +507,10 @@ class World
|
||||||
void LoadConfigSettings(bool reload = false);
|
void LoadConfigSettings(bool reload = false);
|
||||||
|
|
||||||
void SendWorldText(int32 string_id, ...);
|
void SendWorldText(int32 string_id, ...);
|
||||||
void SendGlobalText(const char* text, WorldSession* self);
|
void SendGlobalMessage(WorldPacket* packet);
|
||||||
void SendGlobalMessage(WorldPacket* packet, WorldSession* self = NULL, Team team = TEAM_NONE);
|
|
||||||
void SendZoneMessage(uint32 zone, WorldPacket* packet, WorldSession* self = NULL, Team team = TEAM_NONE);
|
|
||||||
void SendZoneText(uint32 zone, const char* text, WorldSession* self = NULL, Team team = TEAM_NONE);
|
|
||||||
void SendDefenseMessage(uint32 zoneId, int32 textId, Team team = TEAM_NONE);
|
|
||||||
void SendServerMessage(ServerMessageType type, const char* text = "", Player* player = NULL);
|
void SendServerMessage(ServerMessageType type, const char* text = "", Player* player = NULL);
|
||||||
|
void SendZoneUnderAttackMessage(uint32 zoneId, Team team);
|
||||||
|
void SendDefenseMessage(uint32 zoneId, int32 textId);
|
||||||
|
|
||||||
/// Are we in the middle of a shutdown?
|
/// Are we in the middle of a shutdown?
|
||||||
bool IsShutdowning() const { return m_ShutdownTimer > 0; }
|
bool IsShutdowning() const { return m_ShutdownTimer > 0; }
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "0061"
|
#define REVISION_NR "0062"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue