本文整理汇总了C#中DOL.GS.GameClient.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# GameClient.Disconnect方法的具体用法?C# GameClient.Disconnect怎么用?C# GameClient.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOL.GS.GameClient
的用法示例。
在下文中一共展示了GameClient.Disconnect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckCharacterForUpdates
/// <summary>
/// Check if a Character Needs update based to packet data
/// </summary>
/// <param name="pdata">packet data</param>
/// <param name="client">client</param>
/// <param name="character">db character</param>
/// <returns>True if character need refreshment false if no refresh needed.</returns>
private bool CheckCharacterForUpdates(CreationCharacterData pdata, GameClient client, DOLCharacters character)
{
int newModel = character.CurrentModel;
if (pdata.CustomMode == 1 || pdata.CustomMode == 2 || pdata.CustomMode == 3)
{
bool flagChangedStats = false;
if (Properties.ALLOW_CUSTOMIZE_FACE_AFTER_CREATION)
{
character.EyeSize = (byte)pdata.EyeSize;
character.LipSize = (byte)pdata.LipSize;
character.EyeColor = (byte)pdata.EyeColor;
character.HairColor = (byte)pdata.HairColor;
character.FaceType = (byte)pdata.FaceType;
character.HairStyle = (byte)pdata.HairStyle;
character.MoodType = (byte)pdata.MoodType;
}
if (pdata.CustomMode != 3 && client.Version >= GameClient.eClientVersion.Version189)
{
var stats = new Dictionary<eStat, int>();
stats[eStat.STR] = pdata.Strength; // Strength
stats[eStat.DEX] = pdata.Dexterity; // Dexterity
stats[eStat.CON] = pdata.NewConstitution; // New Constitution
stats[eStat.QUI] = pdata.Quickness; // Quickness
stats[eStat.INT] = pdata.Intelligence; // Intelligence
stats[eStat.PIE] = pdata.Piety; // Piety
stats[eStat.EMP] = pdata.Empathy; // Empathy
stats[eStat.CHR] = pdata.Charisma; // Charisma
// check for changed stats.
flagChangedStats |= stats[eStat.STR] != character.Strength;
flagChangedStats |= stats[eStat.CON] != character.Constitution;
flagChangedStats |= stats[eStat.DEX] != character.Dexterity;
flagChangedStats |= stats[eStat.QUI] != character.Quickness;
flagChangedStats |= stats[eStat.INT] != character.Intelligence;
flagChangedStats |= stats[eStat.PIE] != character.Piety;
flagChangedStats |= stats[eStat.EMP] != character.Empathy;
flagChangedStats |= stats[eStat.CHR] != character.Charisma;
if (flagChangedStats)
{
ICharacterClass charClass = ScriptMgr.FindCharacterClass(character.Class);
if (charClass != null)
{
int points;
bool valid = IsCustomPointsDistributionValid(character, stats, out points);
// Hacking attemp ?
if (points > MAX_STARTING_BONUS_POINTS)
{
if ((ePrivLevel)client.Account.PrivLevel == ePrivLevel.Player)
{
if (ServerProperties.Properties.BAN_HACKERS)
client.BanAccount(string.Format("Autoban Hack char update : Wrong allowed points:{0}", points));
client.Disconnect();
return false;
}
}
// Error in setting points
if (!valid)
{
return true;
}
if (Properties.ALLOW_CUSTOMIZE_STATS_AFTER_CREATION)
{
// Set Stats, valid is ok.
character.Strength = stats[eStat.STR];
character.Constitution = stats[eStat.CON];
character.Dexterity = stats[eStat.DEX];
character.Quickness = stats[eStat.QUI];
character.Intelligence = stats[eStat.INT];
character.Piety = stats[eStat.PIE];
character.Empathy = stats[eStat.EMP];
character.Charisma = stats[eStat.CHR];
if (log.IsInfoEnabled)
log.InfoFormat("Character {0} Stats updated in cache!", character.Name);
if (client.Player != null)
{
foreach(var stat in stats.Keys)
client.Player.ChangeBaseStat(stat, (short)(stats[stat] - client.Player.GetBaseStat(stat)));
if (log.IsInfoEnabled)
log.InfoFormat("Character {0} Player Stats updated in cache!", character.Name);
}
}
//.........这里部分代码省略.........
示例2: HandlePacket
public void HandlePacket(GameClient client, GSPacketIn packet)
{
string accountName = packet.ReadString(24);
if (log.IsDebugEnabled)
log.DebugFormat("CharacterCreateRequestHandler for account {0} using version {1}", accountName, client.Version);
if (!accountName.StartsWith(client.Account.Name))// TODO more correctly check, client send accountName as account-S, -N, -H (if it not fit in 20, then only account)
{
if (ServerProperties.Properties.BAN_HACKERS)
client.BanAccount(string.Format("Autoban wrong Account '{0}'", accountName));
client.Disconnect();
return;
}
// Realm
eRealm currentRealm = eRealm.None;
if (accountName.EndsWith("-S")) currentRealm = eRealm.Albion;
else if (accountName.EndsWith("-N")) currentRealm = eRealm.Midgard;
else if (accountName.EndsWith("-H")) currentRealm = eRealm.Hibernia;
// Client character count support
int charsCount = client.Version < GameClient.eClientVersion.Version173 ? 8 : 10;
bool needRefresh = false;
for (int i = 0; i < charsCount; i++)
{
var pakdata = new CreationCharacterData(packet, client);
// Graveen: changed the following to allow GMs to have special chars in their names (_,-, etc..)
var nameCheck = new Regex("^[A-Z][a-zA-Z]");
if (!string.IsNullOrEmpty(pakdata.CharName) && (pakdata.CharName.Length < 3 || !nameCheck.IsMatch(pakdata.CharName)))
{
if ((ePrivLevel)client.Account.PrivLevel == ePrivLevel.Player)
{
if (ServerProperties.Properties.BAN_HACKERS)
client.BanAccount(string.Format("Autoban bad CharName '{0}'", pakdata.CharName));
client.Disconnect();
return;
}
}
switch ((eOperation)pakdata.Operation)
{
case eOperation.Delete:
if (string.IsNullOrEmpty(pakdata.CharName))
{
// Deletion in 1.104+ check for removed character.
needRefresh |= CheckForDeletedCharacter(accountName, client, i);
}
break;
case eOperation.Customize:
if (!string.IsNullOrEmpty(pakdata.CharName))
{
// Candidate for Customizing ?
var character = client.Account.Characters != null ? client.Account.Characters.FirstOrDefault(ch => ch.Name.Equals(pakdata.CharName, StringComparison.OrdinalIgnoreCase)) : null;
if (character != null)
needRefresh |= CheckCharacterForUpdates(pakdata, client, character);
}
break;
case eOperation.Create:
if (!string.IsNullOrEmpty(pakdata.CharName))
{
// Candidate for Creation ?
var character = client.Account.Characters != null ? client.Account.Characters.FirstOrDefault(ch => ch.Name.Equals(pakdata.CharName, StringComparison.OrdinalIgnoreCase)) : null;
if (character == null)
needRefresh |= CreateCharacter(pakdata, client, i);
}
break;
default:
break;
}
}
if(needRefresh)
{
client.Out.SendCharacterOverview(currentRealm);
}
}
示例3: CreateCharacter
private bool CreateCharacter(CreationCharacterData pdata, GameClient client, int accountSlot)
{
Account account = client.Account;
var ch = new DOLCharacters();
ch.AccountName = account.Name;
ch.Name = pdata.CharName;
if (pdata.CustomMode == 0x01)
{
ch.EyeSize = (byte)pdata.EyeSize;
ch.LipSize = (byte)pdata.LipSize;
ch.EyeColor = (byte)pdata.EyeColor;
ch.HairColor = (byte)pdata.HairColor;
ch.FaceType = (byte)pdata.FaceType;
ch.HairStyle = (byte)pdata.HairStyle;
ch.MoodType = (byte)pdata.MoodType;
ch.CustomisationStep = 2; // disable config button
if (log.IsDebugEnabled)
log.Debug("Disable Config Button");
}
ch.Level = 1;
// Set Realm and Class
ch.Realm = pdata.Realm;
ch.Class = pdata.Class;
// Set Account Slot, Gender
ch.AccountSlot = accountSlot + ch.Realm * 100;
ch.Gender = pdata.Gender;
// Set Race
ch.Race = pdata.Race;
ch.CreationModel = pdata.CreationModel;
ch.CurrentModel = ch.CreationModel;
ch.Region = pdata.Region;
ch.Strength = pdata.Strength;
ch.Dexterity = pdata.Dexterity;
ch.Constitution = pdata.Constitution;
ch.Quickness = pdata.Quickness;
ch.Intelligence = pdata.Intelligence;
ch.Piety = pdata.Piety;
ch.Empathy = pdata.Empathy;
ch.Charisma = pdata.Charisma;
// defaults
ch.CreationDate = DateTime.Now;
ch.Endurance = 100;
ch.MaxEndurance = 100;
ch.Concentration = 100;
ch.MaxSpeed = GamePlayer.PLAYER_BASE_SPEED;
if (log.IsDebugEnabled)
log.DebugFormat("Creation {0} character, class:{1}, realm:{2}", client.Version, ch.Class, ch.Realm);
// Is class disabled ?
int occurences = 0;
List<string> disabled_classes = Properties.DISABLED_CLASSES.SplitCSV(true);
occurences = (from j in disabled_classes
where j == ch.Class.ToString()
select j).Count();
if (occurences > 0 && (ePrivLevel)client.Account.PrivLevel == ePrivLevel.Player)
{
if (log.IsDebugEnabled)
log.DebugFormat("Client {0} tried to create a disabled classe: {1}", client.Account.Name, (eCharacterClass)ch.Class);
return true;
}
// check if race disabled
List<string> disabled_races = Properties.DISABLED_RACES.SplitCSV(true);
occurences = (from j in disabled_races
where j == ch.Race.ToString()
select j).Count();
if (occurences > 0 && (ePrivLevel)client.Account.PrivLevel == ePrivLevel.Player)
{
if (log.IsDebugEnabled)
log.DebugFormat("Client {0} tried to create a disabled race: {1}", client.Account.Name, (eRace)ch.Race);
return true;
}
// If sending invalid Class ID
if (!Enum.IsDefined(typeof(eCharacterClass), (eCharacterClass)ch.Class))
{
if (log.IsErrorEnabled)
log.ErrorFormat("{0} tried to create a character with wrong class ID: {1}, realm:{2}", client.Account.Name, ch.Class, ch.Realm);
if (ServerProperties.Properties.BAN_HACKERS)
{
client.BanAccount(string.Format("Autoban character create class: id:{0} realm:{1} name:{2} account:{3}", ch.Class, ch.Realm, ch.Name, account.Name));
client.Disconnect();
return false;
}
//.........这里部分代码省略.........
示例4: HandlePacket
//.........这里部分代码省略.........
b.Type = "B";
b.Reason = string.Format("Autoban MOVEHACK:(CPS:{0}, JT:{1}) on player:{2}", coordsPerSec, jumpDetect, client.Player.Name);
GameServer.Database.AddObject(b);
GameServer.Database.SaveObject(b);
string message = "";
message = "You have been auto kicked and banned due to movement hack detection!";
for (int i = 0; i < 8; i++)
{
client.Out.SendMessage(message, eChatType.CT_Help, eChatLoc.CL_SystemWindow);
client.Out.SendMessage(message, eChatType.CT_Help, eChatLoc.CL_ChatWindow);
}
client.Out.SendPlayerQuit(true);
client.Player.SaveIntoDatabase();
client.Player.Quit(true);
}
else
{
string message = "";
message = "You have been auto kicked due to movement hack detection!";
for (int i = 0; i < 8; i++)
{
client.Out.SendMessage(message, eChatType.CT_Help, eChatLoc.CL_SystemWindow);
client.Out.SendMessage(message, eChatType.CT_Help, eChatLoc.CL_ChatWindow);
}
client.Out.SendPlayerQuit(true);
client.Player.SaveIntoDatabase();
client.Player.Quit(true);
}
client.Disconnect();
return;
}
}
}
client.Player.TempProperties.setProperty(LASTCPSTICK, environmentTick);
}
ushort headingflag = packet.ReadShort();
client.Player.Heading = (ushort)(headingflag & 0xFFF);
ushort flyingflag = packet.ReadShort();
byte flags = (byte)packet.ReadByte();
if (client.Player.X != realX || client.Player.Y != realY)
{
client.Player.TempProperties.setProperty(LASTMOVEMENTTICK, client.Player.CurrentRegion.Time);
}
client.Player.X = realX;
client.Player.Y = realY;
client.Player.Z = realZ;
if (zoneChange)
{
// update client zone information for waterlevel and diving
client.Out.SendPlayerPositionAndObjectID();
}
// used to predict current position, should be before
// any calculation (like fall damage)
client.Player.MovementStartTick = Environment.TickCount;
// Begin ---------- New Area System -----------
示例5: CheckCharacterForUpdates
//.........这里部分代码省略.........
log.Info(string.Format("{0,-2} {1,-3}:{2, 3} {3,3} {4,3} {5,3} {6,2} {7} {8}",
statCategory,
(stat == eStat.STR) ? "STR" : stat.ToString(),
stats[j],
leveledStats[j],
stats[j] - leveledStats[j],
raceStats[j],
result,
pointsUsed,
(validBeginStat) ? "" : "Not Valid"));
points += pointsUsed;
if (!validBeginStat)
{
valid = false;
if (client.Account.PrivLevel == 1)
{
if (ServerProperties.Properties.BAN_HACKERS)
{
DBBannedAccount b = new DBBannedAccount();
b.Author = "SERVER";
b.Ip = client.TcpEndpointAddress;
b.Account = client.Account.Name;
b.DateBan = DateTime.Now;
b.Type = "B";
b.Reason = String.Format("Autoban Hack char update : Wrong {0} point:{1}", (stat == eStat.STR) ? "STR" : stat.ToString(), result);
GameServer.Database.AddObject(b);
GameServer.Database.SaveObject(b);
GameServer.Instance.LogCheatAction(b.Reason + ". Account: " + b.Account);
}
client.Disconnect();
return 1;
}
}
}
if (valid)
{
character.Strength = (byte)stats[0];
character.Constitution = (byte)stats[1];
character.Dexterity = (byte)stats[2];
character.Quickness = (byte)stats[3];
character.Intelligence = (byte)stats[4];
character.Piety = (byte)stats[5];
character.Empathy = (byte)stats[6];
character.Charisma = (byte)stats[7];
DOLCharacters[] chars = client.Account.Characters;
for (int z = 0; z < chars.Length; z++)
{
if (chars[z].Name != character.Name) continue;
//Log.Error(string.Format("found activePlayer:[{0}] {1} {2}", client.ActiveCharIndex, client.Player.Name, character.Name));
if (log.IsInfoEnabled)
log.Info(String.Format("Character {0} updated in cache!\n", charName));
if (client.Player != null)
{
client.Player.DBCharacter.Strength = (byte)stats[0];
client.Player.DBCharacter.Constitution = (byte)stats[1];
client.Player.DBCharacter.Dexterity = (byte)stats[2];
示例6: HandlePacket
public void HandlePacket(GameClient client, GSPacketIn packet)
{
string accountName = packet.ReadString(24);
log.Debug("CharacterCreateRequestHandler for account " + accountName + " using version " + client.Version);
if (!accountName.StartsWith(client.Account.Name))// TODO more correctly check, client send accountName as account-S, -N, -H (if it not fit in 20, then only account)
{
if (ServerProperties.Properties.BAN_HACKERS)
{
DBBannedAccount b = new DBBannedAccount();
b.Author = "SERVER";
b.Ip = client.TcpEndpointAddress;
b.Account = client.Account.Name;
b.DateBan = DateTime.Now;
b.Type = "B";
b.Reason = String.Format("Autoban wrong Account '{0}'", GameServer.Database.Escape(accountName));
GameServer.Database.AddObject(b);
GameServer.Database.SaveObject(b);
GameServer.Instance.LogCheatAction(b.Reason + ". Account: " + b.Account);
}
client.Disconnect();
return;
}
if (client.Version >= GameClient.eClientVersion.Version1104)
{
packet.ReadIntLowEndian(); //unk - probably indicates customize or create
}
int charsCount = client.Version < GameClient.eClientVersion.Version173 ? 8 : 10;
for (int i = 0; i < charsCount; i++)
{
string charName = packet.ReadString(24);
//log.DebugFormat("Character[{0}] = {1}", i, charName);
if (charName.Length == 0)
{
// 1.104+ if character is not in list but is in DB then delete the character
if (client.Version >= GameClient.eClientVersion.Version1104)
{
CheckForDeletedCharacter(accountName, client, i);
}
//If the charname is empty, skip the other bytes
packet.Skip(160);
if (client.Version >= GameClient.eClientVersion.Version199)
{
// skip 4 bytes added in 1.99
packet.Skip(4);
}
}
else
{
// Graveen: changed the following to allow GMs to have special chars in their names (_,-, etc..)
Regex nameCheck = new Regex("^[A-Z][a-zA-Z]");
if (charName.Length < 3 || !nameCheck.IsMatch(charName))
{
if (client.Account.PrivLevel == 1)
{
if (ServerProperties.Properties.BAN_HACKERS)
{
DBBannedAccount b = new DBBannedAccount();
b.Author = "SERVER";
b.Ip = client.TcpEndpointAddress;
b.Account = client.Account.Name;
b.DateBan = DateTime.Now;
b.Type = "B";
b.Reason = String.Format("Autoban bad CharName '{0}'", GameServer.Database.Escape(charName));
GameServer.Database.AddObject(b);
GameServer.Database.SaveObject(b);
GameServer.Instance.LogCheatAction(b.Reason + ". Account: " + b.Account);
}
client.Disconnect();
return;
}
}
String select = String.Format("Name = '{0}'", GameServer.Database.Escape(charName));
DOLCharacters character = GameServer.Database.SelectObject<DOLCharacters>(select);
if (character != null)
{
if (character.AccountName != client.Account.Name)
{
if (Properties.BAN_HACKERS == true)
{
DBBannedAccount b = new DBBannedAccount();
b.Author = "SERVER";
b.Ip = client.TcpEndpointAddress;
b.Account = client.Account.Name;
b.DateBan = DateTime.Now;
b.Type = "B";
b.Reason = String.Format("Autoban CharName '{0}' on wrong Account '{1}'", GameServer.Database.Escape(charName), GameServer.Database.Escape(client.Account.Name));
GameServer.Database.AddObject(b);
GameServer.Database.SaveObject(b);
GameServer.Instance.LogCheatAction(string.Format(b.Reason + ". Client Account: {0}, DB Account: {1}", client.Account.Name, character.AccountName));
}
//.........这里部分代码省略.........
示例7: CreateCharacter
private void CreateCharacter(GameClient client, GSPacketIn packet, string charName, int accountSlot)
{
Account account = client.Account;
DOLCharacters ch = new DOLCharacters();
ch.AccountName = account.Name;
ch.Name = charName;
if (packet.ReadByte() == 0x01)
{
ch.EyeSize = (byte)packet.ReadByte();
ch.LipSize = (byte)packet.ReadByte();
ch.EyeColor = (byte)packet.ReadByte();
ch.HairColor = (byte)packet.ReadByte();
ch.FaceType = (byte)packet.ReadByte();
ch.HairStyle = (byte)packet.ReadByte();
packet.Skip(3);
ch.MoodType = (byte)packet.ReadByte();
ch.CustomisationStep = 2; // disable config button
packet.Skip(13);
log.Debug("Disable Config Button");
}
else
{
packet.Skip(23);
}
packet.Skip(24); //Location String
ch.LastName = "";
ch.GuildID = "";
packet.Skip(24); //Skip class name
packet.Skip(24); //Skip race name
ch.Level = packet.ReadByte(); //not safe!
ch.Level = 1;
ch.Class = packet.ReadByte();
if (ServerProperties.Properties.START_AS_BASE_CLASS)
{
ch.Class = RevertClass(ch);
}
ch.Realm = packet.ReadByte();
if (log.IsDebugEnabled)
log.Debug("Creation " + client.Version + " character, class:" + ch.Class + ", realm:" + ch.Realm);
// Is class disabled ?
int occurences = 0;
List<string> disabled_classes = Properties.DISABLED_CLASSES.SplitCSV(true);
occurences = (from j in disabled_classes
where j == ch.Class.ToString()
select j).Count();
if (occurences > 0 && (ePrivLevel)client.Account.PrivLevel == ePrivLevel.Player)
{
log.Debug("Client " + client.Account.Name + " tried to create a disabled classe: " + (eCharacterClass)ch.Class);
client.Out.SendCharacterOverview((eRealm)ch.Realm);
return;
}
if (client.Version >= GameClient.eClientVersion.Version193)
{
ValidateCharacter.init_post193_tables();
}
else
{
ValidateCharacter.init_pre193_tables();
}
if (!Enum.IsDefined(typeof(eCharacterClass), (eCharacterClass)ch.Class))
{
log.Error(client.Account.Name + " tried to create a character with wrong class ID: " + ch.Class + ", realm:" + ch.Realm);
if (ServerProperties.Properties.BAN_HACKERS)
{
DBBannedAccount b = new DBBannedAccount();
b.Author = "SERVER";
b.Ip = client.TcpEndpointAddress;
b.Account = client.Account.Name;
b.DateBan = DateTime.Now;
b.Type = "B";
b.Reason = string.Format("Autoban character create class: id:{0} realm:{1} name:{2} account:{3}", ch.Class, ch.Realm, ch.Name, account.Name);
GameServer.Database.AddObject(b);
GameServer.Database.SaveObject(b);
GameServer.Instance.LogCheatAction(b.Reason + ". Account: " + b.Account);
client.Disconnect();
}
return;
}
ch.AccountSlot = accountSlot + ch.Realm * 100;
//The following byte contains
//1bit=start location ... in ShroudedIsles you can choose ...
//1bit=first race bit
//1bit=unknown
//1bit=gender (0=male, 1=female)
//4bit=race
byte startRaceGender = (byte)packet.ReadByte();
ch.Race = (startRaceGender & 0x0F) + ((startRaceGender & 0x40) >> 2);
List<string> disabled_races = new List<string>(Properties.DISABLED_RACES.SplitCSV(true));
occurences = (from j in disabled_races
//.........这里部分代码省略.........