Misc updates/fixes

This commit is contained in:
hondacrx
2022-01-27 12:36:56 -05:00
parent 169abc1531
commit 6c0e21b4de
36 changed files with 415 additions and 354 deletions
+8 -9
View File
@@ -182,7 +182,7 @@ namespace Game
if (session.PlayerLoading())
return false;
session.KickPlayer();
session.KickPlayer("World::RemoveSession");
}
return true;
@@ -208,7 +208,7 @@ namespace Game
// if player is in loading and want to load again, return
if (!RemoveSession(s.GetAccountId()))
{
s.KickPlayer();
s.KickPlayer("World::AddSession_ Couldn't remove the other session while on loading screen");
return;
}
@@ -1243,18 +1243,17 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, @"VMap data directory is: {0}\vmaps", GetDataPath());
}
void SetForcedWarModeFactionBalanceState(int team, int reward)
public void SetForcedWarModeFactionBalanceState(int team, int reward = 0)
{
_warModeDominantFaction = team;
_warModeOutnumberedFactionReward = reward;
}
void DisableForcedWarModeFactionBalanceState()
public void DisableForcedWarModeFactionBalanceState()
{
UpdateWarModeRewardValues();
}
public void LoadAutobroadcasts()
{
uint oldMSTime = Time.GetMSTime();
@@ -1597,7 +1596,7 @@ namespace Game
// session not removed at kick and will removed in next update tick
foreach (var session in m_sessions.Values)
session.KickPlayer();
session.KickPlayer("World::KickAll");
}
void KickAllLess(AccountTypes sec)
@@ -1605,7 +1604,7 @@ namespace Game
// session not removed at kick and will removed in next update tick
foreach (var session in m_sessions.Values)
if (session.GetSecurity() < sec)
session.KickPlayer();
session.KickPlayer("World::KickAllLess");
}
/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban
@@ -1689,7 +1688,7 @@ namespace Game
if (sess)
{
if (sess.GetPlayerName() != author)
sess.KickPlayer();
sess.KickPlayer("World::BanAccount Banning account");
}
} while (resultAccounts.NextRow());
@@ -1762,7 +1761,7 @@ namespace Game
DB.Characters.CommitTransaction(trans);
if (pBanned)
pBanned.GetSession().KickPlayer();
pBanned.GetSession().KickPlayer("World::BanCharacter Banning character");
return BanReturn.Success;
}
+18 -2
View File
@@ -34,6 +34,7 @@ using System.IO;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using Game.Chat;
namespace Game
{
@@ -419,8 +420,10 @@ namespace Game
public void AddInstanceConnection(WorldSocket sock) { m_Socket[(int)ConnectionType.Instance] = sock; }
public void KickPlayer()
public void KickPlayer(string reason)
{
Log.outInfo(LogFilter.Network, $"Account: {GetAccountId()} Character: '{(_player ? _player.GetName() : "<none>")}' {(_player ? _player.GetGUID() : "")} kicked with reason: {reason}");
for (byte i = 0; i < 2; ++i)
{
if (m_Socket[i] != null)
@@ -588,6 +591,19 @@ namespace Game
return m_muteTime <= GameTime.GetGameTime();
}
bool ValidateHyperlinksAndMaybeKick(string str)
{
if (Hyperlink.CheckAllLinks(str))
return true;
Log.outError(LogFilter.Network, $"Player {GetPlayer().GetName()} {GetPlayer().GetGUID()} sent a message with an invalid link:\n{str}");
if (WorldConfig.GetIntValue(WorldCfg.ChatStrictLinkCheckingKick) != 0)
KickPlayer("WorldSession::ValidateHyperlinksAndMaybeKick Invalid chat link");
return false;
}
public bool DisallowHyperlinksAndMaybeKick(string str)
{
if (!str.Contains('|'))
@@ -596,7 +612,7 @@ namespace Game
Log.outError(LogFilter.Network, $"Player {GetPlayer().GetName()} ({GetPlayer().GetGUID()}) sent a message which illegally contained a hyperlink:\n{str}");
if (WorldConfig.GetIntValue(WorldCfg.ChatStrictLinkCheckingKick) != 0)
KickPlayer();
KickPlayer("WorldSession::DisallowHyperlinksAndMaybeKick Illegal chat link");
return false;
}