Refactoring of BNetServer

This commit is contained in:
hondacrx
2020-07-12 00:06:43 -04:00
parent 4164384b72
commit 581d077acd
318 changed files with 2046 additions and 4694 deletions
+3 -3
View File
@@ -21,7 +21,7 @@ using Framework.Database;
using Game.DataStorage;
using Game.Entities;
using Game.Maps;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -106,7 +106,7 @@ namespace Game.Chat
}
}
public static void GetChannelName(ref string channelName, uint channelId, LocaleConstant locale, AreaTableRecord zoneEntry)
public static void GetChannelName(ref string channelName, uint channelId, Locale locale, AreaTableRecord zoneEntry)
{
if (channelId != 0)
{
@@ -123,7 +123,7 @@ namespace Game.Chat
}
}
public string GetName(LocaleConstant locale = LocaleConstant.enUS)
public string GetName(Locale locale = Locale.enUS)
{
string result = _channelName;
GetChannelName(ref result, _channelId, locale, _zoneEntry);
+20 -20
View File
@@ -17,8 +17,8 @@
using Framework.Constants;
using Game.Entities;
using Game.Network;
using Game.Network.Packets;
using Game.Networking;
using Game.Networking.Packets;
using Game.Cache;
namespace Game.Chat
@@ -38,10 +38,10 @@ namespace Game.Chat
_modifier = modifier;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
// LocalizedPacketDo sends client DBC locale, we need to get available to server locale
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
ChannelNotify data = new ChannelNotify();
data.Type = _modifier.GetNotificationType();
@@ -61,9 +61,9 @@ namespace Game.Chat
_source = source;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
ChannelNotifyJoined notify = new ChannelNotifyJoined();
//notify.ChannelWelcomeMsg = "";
@@ -86,9 +86,9 @@ namespace Game.Chat
_suspended = suspend;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
ChannelNotifyLeft notify = new ChannelNotifyLeft();
notify.Channel = _source.GetName(localeIdx);
@@ -111,9 +111,9 @@ namespace Game.Chat
_guid = guid;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
ChatPkt packet = new ChatPkt();
Player player = Global.ObjAccessor.FindConnectedPlayer(_guid);
@@ -146,17 +146,17 @@ namespace Game.Chat
_guid = guid;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
ChatPkt packet = new ChatPkt();
Player player = Global.ObjAccessor.FindConnectedPlayer(_guid);
if (player)
packet.Initialize(ChatMsg.Channel, _lang, player, player, _what, 0, _source.GetName(localeIdx), LocaleConstant.enUS, _prefix);
packet.Initialize(ChatMsg.Channel, _lang, player, player, _what, 0, _source.GetName(localeIdx), Locale.enUS, _prefix);
else
{
packet.Initialize(ChatMsg.Channel, _lang, null, null, _what, 0, _source.GetName(localeIdx), LocaleConstant.enUS, _prefix);
packet.Initialize(ChatMsg.Channel, _lang, null, null, _what, 0, _source.GetName(localeIdx), Locale.enUS, _prefix);
packet.SenderGUID = _guid;
packet.TargetGUID = _guid;
}
@@ -179,9 +179,9 @@ namespace Game.Chat
_guid = guid;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
UserlistAdd userlistAdd = new UserlistAdd();
userlistAdd.AddedUserGUID = _guid;
@@ -204,9 +204,9 @@ namespace Game.Chat
_guid = guid;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
UserlistUpdate userlistUpdate = new UserlistUpdate();
userlistUpdate.UpdatedUserGUID = _guid;
@@ -229,9 +229,9 @@ namespace Game.Chat
_guid = guid;
}
public override ServerPacket Invoke(LocaleConstant locale = LocaleConstant.enUS)
public override ServerPacket Invoke(Locale locale = Locale.enUS)
{
LocaleConstant localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
Locale localeIdx = Global.WorldMgr.GetAvailableDbcLocale(locale);
UserlistRemove userlistRemove = new UserlistRemove();
userlistRemove.RemovedUserGUID = _guid;
+3 -3
View File
@@ -18,7 +18,7 @@
using Framework.Constants;
using Game.DataStorage;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
@@ -145,7 +145,7 @@ namespace Game.Chat
{
ulong high = 0;
high |= (ulong)HighGuid.ChatChannel << 58;
high |= (ulong)Global.WorldMgr.GetRealmId().Realm << 42;
high |= (ulong)Global.WorldMgr.GetRealmId().Index << 42;
high |= (ulong)(_team == Team.Alliance ? 3 : 5) << 4;
ObjectGuid channelGuid = new ObjectGuid();
@@ -163,7 +163,7 @@ namespace Game.Chat
ulong high = 0;
high |= (ulong)HighGuid.ChatChannel << 58;
high |= (ulong)Global.WorldMgr.GetRealmId().Realm << 42;
high |= (ulong)Global.WorldMgr.GetRealmId().Index << 42;
high |= 1ul << 25; // built-in
if (channelEntry.Flags.HasAnyFlag(ChannelDBCFlags.CityOnly2))
high |= 1ul << 24; // trade
+3 -3
View File
@@ -22,7 +22,7 @@ using Game.DataStorage;
using Game.Entities;
using Game.Groups;
using Game.Maps;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -735,7 +735,7 @@ namespace Game.Chat
return Global.ObjectMgr.GetCypherString(str);
}
public virtual LocaleConstant GetSessionDbcLocale()
public virtual Locale GetSessionDbcLocale()
{
return _session.GetSessionDbcLocale();
}
@@ -864,7 +864,7 @@ namespace Game.Chat
return true;
}
public override LocaleConstant GetSessionDbcLocale()
public override Locale GetSessionDbcLocale()
{
return Global.WorldMgr.GetDefaultDbcLocale();
}
+2 -2
View File
@@ -317,7 +317,7 @@ namespace Game.Chat.Commands
[Command("account", RBACPermissions.CommandBanlistAccount, true)]
static bool HandleBanListAccountCommand(StringArguments args, CommandHandler handler)
{
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.DEL_EXPIRED_IP_BANS);
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.DelExpiredIpBans);
DB.Login.Execute(stmt);
string filterStr = args.NextString();
@@ -433,7 +433,7 @@ namespace Game.Chat.Commands
[Command("ip", RBACPermissions.CommandBanlistIp, true)]
static bool HandleBanListIPCommand(StringArguments args, CommandHandler handler)
{
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.DEL_EXPIRED_IP_BANS);
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.DelExpiredIpBans);
DB.Login.Execute(stmt);
string filterStr = args.NextString();
@@ -40,7 +40,7 @@ namespace Game.Chat
if (!handler.ExtractPlayerTarget(args, out target))
return false;
LocaleConstant loc = handler.GetSessionDbcLocale();
Locale loc = handler.GetSessionDbcLocale();
string targetName = target.GetName();
string knownStr = handler.GetCypherString(CypherStrings.Known);
@@ -405,7 +405,7 @@ namespace Game.Chat
if (!handler.ExtractPlayerTarget(args, out target))
return false;
LocaleConstant loc = handler.GetSessionDbcLocale();
Locale loc = handler.GetSessionDbcLocale();
var targetFSL = target.GetReputationMgr().GetStateList();
foreach (var pair in targetFSL)
+1 -1
View File
@@ -23,7 +23,7 @@ using Game.Combat;
using Game.DataStorage;
using Game.Entities;
using Game.Maps;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
using System.Text;
+1 -1
View File
@@ -170,7 +170,7 @@ namespace Game.Chat
// Get the accounts with GM Level >0
PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_GM_ACCOUNTS);
stmt.AddValue(0, AccountTypes.Moderator);
stmt.AddValue(1, Global.WorldMgr.GetRealm().Id.Realm);
stmt.AddValue(1, Global.WorldMgr.GetRealm().Id.Index);
SQLResult result = DB.Login.Query(stmt);
if (!result.IsEmpty())
+3 -3
View File
@@ -164,7 +164,7 @@ namespace Game.Chat.Commands
skillInfo.CanLink == 0) // only prof with recipes have set
continue;
LocaleConstant locale = handler.GetSessionDbcLocale();
Locale locale = handler.GetSessionDbcLocale();
name = skillInfo.DisplayName[locale];
if (string.IsNullOrEmpty(name))
continue;
@@ -172,7 +172,7 @@ namespace Game.Chat.Commands
if (!name.Like(namePart))
{
locale = 0;
for (; locale < LocaleConstant.Total; ++locale)
for (; locale < Locale.Total; ++locale)
{
if (locale == handler.GetSessionDbcLocale())
continue;
@@ -186,7 +186,7 @@ namespace Game.Chat.Commands
}
}
if (locale < LocaleConstant.Total)
if (locale < Locale.Total)
{
skillId = skillInfo.Id;
break;
+23 -23
View File
@@ -45,7 +45,7 @@ namespace Game.Chat
// Search in AreaTable.dbc
foreach (var areaEntry in CliDB.AreaTableStorage.Values)
{
LocaleConstant locale = handler.GetSessionDbcLocale();
Locale locale = handler.GetSessionDbcLocale();
string name = areaEntry.AreaName[locale];
if (string.IsNullOrEmpty(name))
continue;
@@ -53,7 +53,7 @@ namespace Game.Chat
if (!name.Like(namePart))
{
locale = 0;
for (; locale < LocaleConstant.Total; ++locale)
for (; locale < Locale.Total; ++locale)
{
if (locale == handler.GetSessionDbcLocale())
continue;
@@ -67,7 +67,7 @@ namespace Game.Chat
}
}
if (locale < LocaleConstant.Total)
if (locale < Locale.Total)
{
if (maxlookup != 0 && count++ == maxlookup)
{
@@ -234,7 +234,7 @@ namespace Game.Chat
{
FactionState factionState = target ? target.GetReputationMgr().GetState(factionEntry) : null;
LocaleConstant locale = handler.GetSessionDbcLocale();
Locale locale = handler.GetSessionDbcLocale();
string name = factionEntry.Name[locale];
if (string.IsNullOrEmpty(name))
continue;
@@ -242,7 +242,7 @@ namespace Game.Chat
if (!name.Like(namePart))
{
locale = 0;
for (; locale < LocaleConstant.Total; ++locale)
for (; locale < Locale.Total; ++locale)
{
if (locale == handler.GetSessionDbcLocale())
continue;
@@ -256,7 +256,7 @@ namespace Game.Chat
}
}
if (locale < LocaleConstant.Total)
if (locale < Locale.Total)
{
if (maxlookup != 0 && count++ == maxlookup)
{
@@ -365,7 +365,7 @@ namespace Game.Chat
// Search in ItemSet.dbc
foreach (var set in CliDB.ItemSetStorage.Values)
{
LocaleConstant locale = handler.GetSessionDbcLocale();
Locale locale = handler.GetSessionDbcLocale();
string name = set.Name[locale];
if (name.IsEmpty())
continue;
@@ -373,7 +373,7 @@ namespace Game.Chat
if (!name.Like(namePart))
{
locale = 0;
for (; locale < LocaleConstant.Total; ++locale)
for (; locale < Locale.Total; ++locale)
{
if (locale == handler.GetSessionDbcLocale())
continue;
@@ -387,7 +387,7 @@ namespace Game.Chat
}
}
if (locale < LocaleConstant.Total)
if (locale < Locale.Total)
{
if (maxlookup != 0 && count++ == maxlookup)
{
@@ -629,7 +629,7 @@ namespace Game.Chat
// Search in SkillLine.dbc
foreach (var skillInfo in CliDB.SkillLineStorage.Values)
{
LocaleConstant locale = handler.GetSessionDbcLocale();
Locale locale = handler.GetSessionDbcLocale();
string name = skillInfo.DisplayName[locale];
if (string.IsNullOrEmpty(name))
continue;
@@ -637,7 +637,7 @@ namespace Game.Chat
if (!name.Like(namePart))
{
locale = 0;
for (; locale < LocaleConstant.Total; ++locale)
for (; locale < Locale.Total; ++locale)
{
if (locale == handler.GetSessionDbcLocale())
continue;
@@ -651,7 +651,7 @@ namespace Game.Chat
}
}
if (locale < LocaleConstant.Total)
if (locale < Locale.Total)
{
if (maxlookup != 0 && count++ == maxlookup)
{
@@ -700,7 +700,7 @@ namespace Game.Chat
bool found = false;
uint count = 0;
LocaleConstant locale = handler.GetSessionDbcLocale();
Locale locale = handler.GetSessionDbcLocale();
// Search in TaxiNodes.dbc
foreach (var nodeEntry in CliDB.TaxiNodesStorage.Values)
@@ -802,7 +802,7 @@ namespace Game.Chat
if (target && target.GetGender() != gender)
continue;
LocaleConstant locale = handler.GetSessionDbcLocale();
Locale locale = handler.GetSessionDbcLocale();
string name = gender == Gender.Male ? titleInfo.Name[locale]: titleInfo.Name1[locale];
if (string.IsNullOrEmpty(name))
continue;
@@ -810,7 +810,7 @@ namespace Game.Chat
if (!name.Like(namePart))
{
locale = 0;
for (; locale < LocaleConstant.Total; ++locale)
for (; locale < Locale.Total; ++locale)
{
if (locale == handler.GetSessionDbcLocale())
continue;
@@ -824,7 +824,7 @@ namespace Game.Chat
}
}
if (locale < LocaleConstant.Total)
if (locale < Locale.Total)
{
if (maxlookup != 0 && counter == maxlookup)
{
@@ -869,7 +869,7 @@ namespace Game.Chat
// search in Map.dbc
foreach (var mapInfo in CliDB.MapStorage.Values)
{
LocaleConstant locale = handler.GetSessionDbcLocale();
Locale locale = handler.GetSessionDbcLocale();
string name = mapInfo.MapName[locale];
if (string.IsNullOrEmpty(name))
continue;
@@ -877,7 +877,7 @@ namespace Game.Chat
if (!name.Like(namePart) && handler.GetSession())
{
locale = 0;
for (; locale < LocaleConstant.Total; ++locale)
for (; locale < Locale.Total; ++locale)
{
if (locale == handler.GetSessionDbcLocale())
continue;
@@ -891,7 +891,7 @@ namespace Game.Chat
}
}
if (locale < LocaleConstant.Total)
if (locale < Locale.Total)
{
if (maxlookup != 0 && counter == maxlookup)
{
@@ -1071,7 +1071,7 @@ namespace Game.Chat
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellName.Id, Difficulty.None);
if (spellInfo != null)
{
LocaleConstant locale = handler.GetSessionDbcLocale();
Locale locale = handler.GetSessionDbcLocale();
string name = spellInfo.SpellName[locale];
if (name.IsEmpty())
continue;
@@ -1079,7 +1079,7 @@ namespace Game.Chat
if (!name.Like(namePart))
{
locale = 0;
for (; locale < LocaleConstant.Total; ++locale)
for (; locale < Locale.Total; ++locale)
{
if (locale == handler.GetSessionDbcLocale())
continue;
@@ -1093,7 +1093,7 @@ namespace Game.Chat
}
}
if (locale < LocaleConstant.Total)
if (locale < Locale.Total)
{
if (maxlookup != 0 && count++ == maxlookup)
{
@@ -1167,7 +1167,7 @@ namespace Game.Chat
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(id, Difficulty.None);
if (spellInfo != null)
{
LocaleConstant locale = handler.GetSessionDbcLocale();
Locale locale = handler.GetSessionDbcLocale();
string name = spellInfo.SpellName[locale];
if (string.IsNullOrEmpty(name))
{
+1 -1
View File
@@ -20,7 +20,7 @@ using Framework.Database;
using Framework.IO;
using Game.DataStorage;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
namespace Game.Chat
+4 -4
View File
@@ -24,7 +24,7 @@ using Game.Entities;
using Game.Groups;
using Game.Maps;
using Game.Movement;
using Game.Network.Packets;
using Game.Networking.Packets;
using Game.Spells;
using System;
using System.Collections.Generic;
@@ -263,7 +263,7 @@ namespace Game.Chat
{
var record = CliDB.ItemSparseStorage.Values.FirstOrDefault(itemSparse =>
{
for (LocaleConstant i = 0; i < LocaleConstant.Total; ++i)
for (Locale i = 0; i < Locale.Total; ++i)
if (itemName == itemSparse.Display[i])
return true;
return false;
@@ -1359,7 +1359,7 @@ namespace Game.Chat
Race raceid;
Class classid;
Gender gender;
LocaleConstant locale = handler.GetSessionDbcLocale();
Locale locale = handler.GetSessionDbcLocale();
uint totalPlayerTime;
uint level;
string alive = handler.GetCypherString(CypherStrings.Error);
@@ -1437,7 +1437,7 @@ namespace Game.Chat
// Query the prepared statement for login data
stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_PINFO);
stmt.AddValue(0, Global.WorldMgr.GetRealm().Id.Realm);
stmt.AddValue(0, Global.WorldMgr.GetRealm().Id.Index);
stmt.AddValue(1, accId);
SQLResult result0 = DB.Login.Query(stmt);
+1 -1
View File
@@ -19,7 +19,7 @@ using Framework.Constants;
using Framework.IO;
using Game.DataStorage;
using Game.Entities;
using Game.Network.Packets;
using Game.Networking.Packets;
using System;
using System.Collections.Generic;
+1 -1
View File
@@ -296,7 +296,7 @@ namespace Game.Chat.Commands
if (rdata == null)
{
data.rbac = new RBACData(accountId, accountName, (int)Global.WorldMgr.GetRealm().Id.Realm, (byte)Global.AccountMgr.GetSecurity(accountId, (int)Global.WorldMgr.GetRealm().Id.Realm));
data.rbac = new RBACData(accountId, accountName, (int)Global.WorldMgr.GetRealm().Id.Index, (byte)Global.AccountMgr.GetSecurity(accountId, (int)Global.WorldMgr.GetRealm().Id.Index));
data.rbac.LoadFromDB();
data.needDelete = true;
}
+3 -3
View File
@@ -260,7 +260,7 @@ namespace Game.Chat.Commands
ObjectGuid targetGuid = Global.CharacterCacheStorage.GetCharacterGuidByName(target);
uint accountId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(targetGuid);
// Target must exist and have administrative rights
if (!Global.AccountMgr.HasPermission(accountId, RBACPermissions.CommandsBeAssignedTicket, Global.WorldMgr.GetRealm().Id.Realm))
if (!Global.AccountMgr.HasPermission(accountId, RBACPermissions.CommandsBeAssignedTicket, Global.WorldMgr.GetRealm().Id.Index))
{
handler.SendSysMessage(CypherStrings.CommandTicketassignerrorA);
return true;
@@ -283,7 +283,7 @@ namespace Game.Chat.Commands
}
// Assign ticket
ticket.SetAssignedTo(targetGuid, Global.AccountMgr.IsAdminAccount(Global.AccountMgr.GetSecurity(accountId, (int)Global.WorldMgr.GetRealm().Id.Realm)));
ticket.SetAssignedTo(targetGuid, Global.AccountMgr.IsAdminAccount(Global.AccountMgr.GetSecurity(accountId, (int)Global.WorldMgr.GetRealm().Id.Index)));
ticket.SaveToDB();
string msg = ticket.FormatViewMessageString(handler, null, target, null, null);
@@ -448,7 +448,7 @@ namespace Game.Chat.Commands
{
ObjectGuid guid = ticket.GetAssignedToGUID();
uint accountId = Global.CharacterCacheStorage.GetCharacterAccountIdByGuid(guid);
security = Global.AccountMgr.GetSecurity(accountId, (int)Global.WorldMgr.GetRealm().Id.Realm);
security = Global.AccountMgr.GetSecurity(accountId, (int)Global.WorldMgr.GetRealm().Id.Index);
}
// Check security