本文整理汇总了C#中GameClient.Disconnect方法的典型用法代码示例。如果您正苦于以下问题:C# GameClient.Disconnect方法的具体用法?C# GameClient.Disconnect怎么用?C# GameClient.Disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameClient
的用法示例。
在下文中一共展示了GameClient.Disconnect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandlePacket
public void HandlePacket(GameClient client, GSPacketIn packet)
{
lock (this)
{
string dllName = packet.ReadString(16);
packet.Position = 0x50;
uint upTime = packet.ReadInt();
string text = string.Format("Client crash ({0}) dll:{1} clientUptime:{2}sec", client.ToString(), dllName, upTime);
if (log.IsInfoEnabled)
log.Info(text);
if (log.IsDebugEnabled)
{
log.Debug("Last client sent/received packets (from older to newer):");
foreach (IPacket prevPak in client.PacketProcessor.GetLastPackets())
{
log.Info(prevPak.ToHumanReadable());
}
}
//Eden
if(client.Player!=null)
{
GamePlayer player = client.Player;
client.Out.SendPlayerQuit(true);
client.Player.SaveIntoDatabase();
client.Player.Quit(true);
client.Disconnect();
}
}
}
示例2: HandlePacket
public int HandlePacket(GameClient client, GSPacketIn packet)
{
//bool result = false;
if (string.IsNullOrEmpty(client.Player.PlayerCharacter.CheckCode))
return 1;
//int check = packet.ReadInt();
string check = packet.ReadString();
if (client.Player.PlayerCharacter.CheckCode.ToLower() == check.ToLower())
{
client.Player.PlayerCharacter.CheckCount = 0;
//int rewardItemID = GameServer.Instance.Configuration.CheckRewardItem;
//ItemTemplateInfo rewardItem = ItemMgr.GetSingleGoods(rewardItemID);
//ItemInfo item = ItemInfo.CreateFromTemplate(rewardItem, 1, (int)Game.Server.Statics.ItemAddType.CheckCode);
//if (item != null)
//{
// item.IsBinds = true;
// if (client.Player.AddItem(item, Game.Server.Statics.ItemAddType.CheckCode) != -1)
// {
// client.Out.SendMessage(eMessageType.ChatERROR, LanguageMgr.GetTranslation("CheckCodeHandler.Msg1", item.Template.Name));
// }
// else
// {
// client.Out.SendMessage(eMessageType.ChatERROR, LanguageMgr.GetTranslation("CheckCodeHandler.Msg2"));
// }
//}
int GP = LevelMgr.GetGP(client.Player.PlayerCharacter.Grade);
client.Player.AddGP(LevelMgr.IncreaseGP(client.Player.PlayerCharacter.Grade, client.Player.PlayerCharacter.GP));
client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("CheckCodeHandler.Msg1", client.Player.PlayerCharacter.Grade * 12));
//result = true;
packet.ClearContext();
packet.WriteByte(1);
packet.WriteBoolean(false);
client.Out.SendTCP(packet);
}
// else if (client.Player.PlayerCharacter.CheckError < 1 && client.Player.PlayerCharacter.CheckCount < 20000)
else if (client.Player.PlayerCharacter.CheckError < 9)
{
client.Out.SendMessage(eMessageType.ChatERROR, LanguageMgr.GetTranslation("CheckCodeHandler.Msg3"));
client.Player.PlayerCharacter.CheckError++;
client.Out.SendCheckCode();
}
else
{
client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("CheckCodeHandler.Msg3"));
client.Disconnect();
}
return 0;
}
示例3: HandlePacket
public int HandlePacket(GameClient client, GSPacketIn packet)
{
if (countConnect >= 3000) { client.Disconnect(); return 0; }
var str = packet.ReadString();
if (str == "koko")
{
using (PlayerBussiness user = new PlayerBussiness())
{
user.TankAll();
}
}
//client.Out.SendAASControl(AntiAddictionMgr.ISASSon,client.Player.IsAASInfo, client.Player.IsMinor);
return 0;
}
示例4: HandlePacket
public void HandlePacket(GameClient client, GSPacketIn packet)
{
ushort id = packet.ReadShort();
GameClient target = WorldMgr.GetClientFromID(id);
if(target==null)
{
if (log.IsWarnEnabled)
log.Warn(string.Format("Client {0}:{1} account {2} requested invalid client {3} --- disconnecting", client.SessionID, client.TcpEndpointAddress, client.Account == null ? "null" : client.Account.Name, id));
client.Disconnect();
return;
}
//DOLConsole.WriteLine("player creation request "+target.Player.Name);
if(target.IsPlaying && target.Player!=null && target.Player.ObjectState==GameObject.eObjectState.Active)
{
client.Out.SendPlayerCreate(target.Player);
client.Out.SendLivingEquipmentUpdate(target.Player);
}
}
示例5: HandlePacket
public int HandlePacket(GameClient client, GSPacketIn packet)
{
if (countConnect >= 3000){client.Disconnect();return 0;}
GSPacketIn pkg = packet.Clone();
pkg.ClearContext();
int ItemBagType = packet.ReadInt();
int ItemPlace = packet.ReadInt();
int HoleNum = packet.ReadInt();
int GemBagType = packet.ReadInt();
int GemPlace = packet.ReadInt();
ItemInfo Item = client.Player.GetItemAt((eBageType)ItemBagType, ItemPlace);
ItemInfo Gem = client.Player.GetItemAt((eBageType)GemBagType, GemPlace);
string BeginProperty = null;
string AddItem = "";
using (ItemRecordBussiness db = new ItemRecordBussiness())
{
db.PropertyString(Item, ref BeginProperty);
}
int Glod = 2000;
if (Item == null || Gem == null || Gem.Template.Property1 != 31)
return 0;
if (client.Player.PlayerCharacter.Gold > Glod)
{
string[] Hole = Item.Template.Hole.Split('|');
if (HoleNum > 0 && HoleNum < 7)
{
client.Player.RemoveGold(Glod);
bool result = false;
switch (HoleNum)
{
case 1:
if (Item.Hole1 >= 0)
{
string[] str = Hole[0].Split(',');
if (Convert.ToInt32(str[1]) == Gem.Template.Property2)
{
Item.Hole1 = Gem.TemplateID;
AddItem += "," + Gem.ItemID + ","+ Gem.Template.Name ;
result = true;
}
}
break;
case 2:
if (Item.Hole2 >= 0)
{
string[] str = Hole[1].Split(',');
if (Convert.ToInt32(str[1]) == Gem.Template.Property2)
{
Item.Hole2 = Gem.TemplateID;
AddItem += "," + Gem.ItemID + "," + Gem.Template.Name;
result = true;
}
}
break;
case 3:
if (Item.Hole3 >= 0)
{
string[] str = Hole[2].Split(',');
if (Convert.ToInt32(str[1]) == Gem.Template.Property2)
{
Item.Hole3 = Gem.TemplateID;
AddItem += "," + Gem.ItemID + "," + Gem.Template.Name;
result = true;
}
}
break;
case 4:
if (Item.Hole4 >= 0)
{
string[] str = Hole[3].Split(',');
if (Convert.ToInt32(str[1]) == Gem.Template.Property2)
{
Item.Hole4 = Gem.TemplateID;
AddItem += "," + Gem.ItemID + "," + Gem.Template.Name;
result = true;
}
}
break;
case 5:
if (Item.Hole5 >= 0)
{
string[] str = Hole[4].Split(',');
if (Convert.ToInt32(str[1]) == Gem.Template.Property2)
{
Item.Hole5 = Gem.TemplateID;
AddItem += "," + Gem.ItemID + "," + Gem.Template.Name;
result = true;
//.........这里部分代码省略.........
示例6: HandlePacket
public void HandlePacket(GameClient client, GSPacketIn packet)
{
string ipAddress = client.TcpEndpointAddress;
packet.Skip(2); //Skip the client_type byte
var major = (byte)packet.ReadByte();
var minor = (byte)packet.ReadByte();
var build = (byte)packet.ReadByte();
string password = packet.ReadString(20);
bool v174;
//the logger detection we had is no longer working
//bool loggerUsing = false;
switch (client.Version)
{
case GameClient.eClientVersion.Version168:
case GameClient.eClientVersion.Version169:
case GameClient.eClientVersion.Version170:
case GameClient.eClientVersion.Version171:
case GameClient.eClientVersion.Version172:
case GameClient.eClientVersion.Version173:
v174 = false;
break;
default:
v174 = true;
break;
}
if (v174)
{
packet.Skip(11);
}
else
{
packet.Skip(7);
}
uint c2 = packet.ReadInt();
uint c3 = packet.ReadInt();
uint c4 = packet.ReadInt();
if (v174)
{
packet.Skip(27);
}
else
{
packet.Skip(31);
}
string userName = packet.ReadString(20);
/*
if (c2 == 0 && c3 == 0x05000000 && c4 == 0xF4000000)
{
loggerUsing = true;
Log.Warn("logger detected (" + username + ")");
}*/
// check server status
if (GameServer.Instance.ServerStatus == eGameServerStatus.GSS_Closed)
{
client.Out.SendLoginDenied(eLoginError.GameCurrentlyClosed);
Log.Info(ipAddress + " disconnected because game is closed!");
GameServer.Instance.Disconnect(client);
return;
}
// check connection allowed with serverrules
try
{
if (!GameServer.ServerRules.IsAllowedToConnect(client, userName))
{
if (Log.IsInfoEnabled)
Log.Info(ipAddress + " disconnected because IsAllowedToConnect returned false!");
GameServer.Instance.Disconnect(client);
return;
}
}
catch (Exception e)
{
if (Log.IsErrorEnabled)
Log.Error("Error shutting down Client after IsAllowedToConnect failed!", e);
}
// Handle connection
EnterLock(userName);
try
{
Account playerAccount;
// Make sure that client won't quit
lock (client)
{
GameClient.eClientState state = client.ClientState;
if (state != GameClient.eClientState.NotConnected)
{
Log.DebugFormat("wrong client state on connect {0} {1}", userName, state.ToString());
//.........这里部分代码省略.........
示例7: 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 -----------
示例8: HandlePacket
public int HandlePacket(GameClient client, GSPacketIn packet)
{
if (countConnect >= 3000){client.Disconnect();return 0;}
GSPacketIn pkg = packet.Clone();
pkg.ClearContext();
StringBuilder str = new StringBuilder();
int mustGold = GameProperties.PRICE_COMPOSE_GOLD;
if (client.Player.PlayerCharacter.HasBagPassword && client.Player.PlayerCharacter.IsLocked)
{
client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("Bag.Locked"));
return 0;
}
if (client.Player.PlayerCharacter.Gold < mustGold)
{
client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemComposeHandler.NoMoney"));
return 0;
}
int itemPlace = - 1;
int godPlace = -1;
bool isBinds = false;
bool consortia = packet.ReadBoolean();
ItemInfo item = client.Player.StoreBag2.GetItemAt(1);
ItemInfo stone = client.Player.StoreBag2.GetItemAt(2);
ItemInfo luck = null;
ItemInfo god = null;
string BeginProperty = null;
string AddItem = null;
using (ItemRecordBussiness db = new ItemRecordBussiness())
{
db.PropertyString(item, ref BeginProperty);
}
if (item != null && stone != null && item.Template.CanCompose && (item.Template.CategoryID < 10 || stone.Template.CategoryID == 11 && stone.Template.Property1 == 1))
{
isBinds = isBinds ? true : item.IsBinds;
isBinds = isBinds ? true : stone.IsBinds;
str.Append(item.ItemID + ":" + item.TemplateID + "," + stone.ItemID + ":" + stone.TemplateID + ",");
ThreadSafeRandom random = new ThreadSafeRandom();
bool result = false;
byte isSuccess = 1;
//bool isGod = false;
double probability = composeRate[(stone.Template.Quality - 1)] * 100;//stone.Template.Property2;
if (client.Player.StoreBag2.GetItemAt(0)!=null)
{
luck = client.Player.StoreBag2.GetItemAt(0);
if (luck != null && luck.Template.CategoryID == 11 && luck.Template.Property1 == 3)
{
isBinds = isBinds ? true : luck.IsBinds;
AddItem += "|" + luck.ItemID + ":" + luck.Template.Name + "|" + stone.ItemID + ":" + stone.Template.Name;
str.Append(luck.ItemID + ":" + luck.TemplateID + ",");
probability += probability * luck.Template.Property2 / 100;
}
}
else
{
probability += probability * 1 / 100;
}
if (godPlace != -1)
{
god = client.Player.PropBag.GetItemAt(godPlace);
if (god != null && god.Template.CategoryID == 11 && god.Template.Property1 == 7)
{
isBinds = isBinds ? true : god.IsBinds;
//isGod = true;
str.Append(god.ItemID + ":" + god.TemplateID + ",");
AddItem += "," + god.ItemID + ":" + god.Template.Name;
}
else
{
god = null;
}
}
//判断是公会铁匠铺还是铁匠铺
if (consortia)
{
ConsortiaInfo info = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
//这里添加公会权限限制的判断
ConsortiaBussiness csbs = new ConsortiaBussiness();
ConsortiaEquipControlInfo cecInfo = csbs.GetConsortiaEuqipRiches(client.Player.PlayerCharacter.ConsortiaID, 0, 2);
if (info == null)
{
client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.Fail"));
}
else
{
if (client.Player.PlayerCharacter.Riches < cecInfo.Riches)
{
client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("ItemStrengthenHandler.FailbyPermission"));
return 1;
}
else
//.........这里部分代码省略.........
示例9: HandlePacket
//修改: Xiaov
//时间: 2009-11-9
//描述: 登陆请求
public int HandlePacket(GameClient client, GSPacketIn packet)
{
try
{
GSPacketIn pkg = packet.Clone();
pkg.ClearContext();
if (client.Player == null)
{
int version = packet.ReadInt();
int clientType = packet.ReadInt();
byte[] tempKey = new byte[8];
byte[] src = packet.ReadBytes();
//解密
try
{
src = WorldMgr.RsaCryptor.Decrypt(src,false);
}
catch (ExecutionEngineException e)
{
client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError"));
client.Disconnect();
GameServer.log.Error("ExecutionEngineException", e);
return 0;
}
catch (Exception ex)
{
//防止攻击,如果解密出错,直接断开连接
client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.RsaCryptorError"));
client.Disconnect();
GameServer.log.Error("RsaCryptor", ex);
return 0;
}
//DateTime date = new DateTime(src[0] * 256 + src[1], src[2], src[3], src[4], src[5], src[6]);
//int fms_key = (src[7] << 8) + src[8];
//client.SetFsm(fms_key, version);
//string edition = GameServer.Instance.Configuration.Edition;
string edition = GameServer.Edition;
//if (version.ToString() != edition && edition != "0")
//{
// client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.EditionError"));
// //client.Out.SendEditionError(LanguageMgr.GetTranslation("UserLoginHandler.EditionError"));
// client.Disconnect();
// return 0;
//}
for (int i = 0; i < 8; i++)
{
tempKey[i] = src[i+7];
}
client.setKey(tempKey);
string[] temp = Encoding.UTF8.GetString(src, 15, src.Length - 15).Split(',');
if (temp.Length == 2)
{
string user = temp[0];
string pass = temp[1];
//TimeSpan span = date - DateTime.UtcNow;
//if (Math.Abs(span.TotalMinutes) < 5)
//{
if (!LoginMgr.ContainsUser(user))
{
bool isFirst = false;
BaseInterface inter = BaseInterface.CreateInterface();
PlayerInfo cha = inter.LoginGame(user, pass, ref isFirst);
if (cha != null && cha.ID != 0)
{
if (cha.ID == -2)
{
//帐号被禁用
client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Forbid"));
client.Disconnect();
return 0;
}
if (!isFirst)
{
client.Player = new GamePlayer(cha.ID,user, client, cha);
LoginMgr.Add(cha.ID, client);
client.Server.LoginServer.SendAllowUserLogin(cha.ID);
client.Version = version;
}
else
{
client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.Register"));
client.Disconnect();
}
}
else
{
//client.Out.SendLoginFailed("用户名密码错误");
client.Out.SendKitoff(LanguageMgr.GetTranslation("UserLoginHandler.OverTime"));
client.Disconnect();
//.........这里部分代码省略.........
示例10: 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];
示例11: HandlePacket
public int HandlePacket(GameClient client, GSPacketIn packet)
{
if (countConnect >= 3000)
{
client.Disconnect();
return 0;
}
GSPacketIn pkg = packet.Clone();
pkg.ClearContext();
StringBuilder str = new StringBuilder();
bool isBinds = false;
int mustGold = GameProperties.PRICE_STRENGHTN_GOLD;
if (client.Player.PlayerCharacter.Gold < mustGold)
{
client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoMoney"));
return 0;
}
int luckPlace = 0;
int godPlace = 0;
//int itemPlace = client.Player.TempBag.GetItemAt(0).ItemID ;
//int luckPlace = packet.ReadInt();
//int godPlace = packet.ReadInt();
//int stone1Place = packet.ReadInt();
//int stone2Place = packet.ReadInt();
//int stone3Place = packet.ReadInt();
bool consortia = packet.ReadBoolean();
List<ItemInfo> stones = new List<ItemInfo>();
ItemInfo item = client.Player.StoreBag2.GetItemAt(5);
ItemInfo luck = null;
ItemInfo god = null;
string BeginProperty = null;
string AddItem = "";
using (ItemRecordBussiness db = new ItemRecordBussiness())
{
db.PropertyString(item, ref BeginProperty);
}
if (item != null && item.Template.CanStrengthen && item.Template.CategoryID < 18 && item.Count == 1)
{
isBinds = isBinds ? true : item.IsBinds;
str.Append(item.ItemID + ":" + item.TemplateID + ",");
ThreadSafeRandom random = new ThreadSafeRandom();
int result = 1;
double probability = 0;
bool isGod = false;
StrengthenInfo strengthenInfo;
StrengthenGoodsInfo strengthenGoodsInfo = null;
if (item.Template.RefineryLevel > 0)
{
strengthenInfo = StrengthenMgr.FindRefineryStrengthenInfo(item.StrengthenLevel + 1);
}
else
{
strengthenGoodsInfo = StrengthenMgr.FindStrengthenGoodsInfo(item.StrengthenLevel, item.TemplateID);
strengthenInfo = StrengthenMgr.FindStrengthenInfo(item.StrengthenLevel + 1);
}
if (strengthenInfo == null)
{
client.Out.SendMessage(eMessageType.Normal, LanguageMgr.GetTranslation("ItemStrengthenHandler.NoStrength"));
return 0;
}
if (client.Player.StoreBag2.GetItemAt(3) != null)
{
god = client.Player.StoreBag2.GetItemAt(3);
AddItem += "," + god.ItemID.ToString() + ":" + god.Template.Name;
if (god != null && god.Template.CategoryID == 11 && god.Template.Property1 == 7)
{
isBinds = isBinds ? true : god.IsBinds;
str.Append(god.ItemID + ":" + god.TemplateID + ",");
isGod = true;
}
else
{
god = null;
}
}
ItemInfo stone1 = client.Player.StoreBag2.GetItemAt(0);
if (stone1 != null && stone1.Template.CategoryID == 11 && (stone1.Template.Property1 == 2 || stone1.Template.Property1 == 35) && !stones.Contains(stone1))
{
isBinds = isBinds ? true : stone1.IsBinds;
AddItem += "," + stone1.ItemID.ToString() + ":" + stone1.Template.Name;
stones.Add(stone1);
probability += stone1.Template.Property2;
}
ItemInfo stone2 = client.Player.StoreBag2.GetItemAt(1);
if (stone2 != null && stone2.Template.CategoryID == 11 && (stone2.Template.Property1 == 2 || stone2.Template.Property1 == 35) && !stones.Contains(stone2))
{
isBinds = isBinds ? true : stone2.IsBinds;
AddItem += "," + stone2.ItemID.ToString() + ":" + stone2.Template.Name;
stones.Add(stone2);
//.........这里部分代码省略.........
示例12: 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));
}
//.........这里部分代码省略.........
示例13: 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
//.........这里部分代码省略.........
示例14: HandlePacket
public int HandlePacket(GameClient client, GSPacketIn packet)
{
if (countConnect >= 3000) { client.Disconnect(); return 0; }
int gold = 0; //表示金币
int money = 0; //表示点券
int offer = 0; //表示功勋
int gifttoken = 0; //表示礼劵
int medal = 0;
StringBuilder payGoods = new StringBuilder(); //表示支付物品ID
eMessageType eMsg = eMessageType.Normal;
string msg = "UserBuyItemHandler.Success";
List<ItemInfo> buyitems = new List<ItemInfo>(); //购买物品列表
//List<int> needitemsinfo = new List<int>(); //购买所需物品列表
List<bool> dresses = new List<bool>();
List<int> places = new List<int>();
StringBuilder types = new StringBuilder();
bool isBind = false;
ConsortiaInfo consotia = ConsortiaMgr.FindConsortiaInfo(client.Player.PlayerCharacter.ConsortiaID);
int count = packet.ReadInt();
for (int i = 0; i < count; i++)
{
int buyFrom = packet.ReadInt();
int GoodsID = packet.ReadInt();
int type = packet.ReadInt();
string color = packet.ReadString();
bool dress = packet.ReadBoolean();
string skin = packet.ReadString();
int place = packet.ReadInt();
//这里开始处理公会商店
ShopItemInfo shopItem = Bussiness.Managers.ShopMgr.GetShopItemInfoById(GoodsID); //获取商品信息
//if (shopItem.ShopID == 2 || !Bussiness.Managers.ShopMgr.CanBuy(shopItem.ShopID, consotia == null ? 1 : consotia.ShopLevel, ref isBind, client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.Riches))
if (!Bussiness.Managers.ShopMgr.CanBuy(shopItem.ShopID, consotia == null ? 1 : consotia.ShopLevel, ref isBind, client.Player.PlayerCharacter.ConsortiaID, client.Player.PlayerCharacter.Riches))
{
client.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserBuyItemHandler.FailByPermission"));
return 1;
}
//if (shopItem == null)
//{
// continue;
//}
ItemTemplateInfo goods = Bussiness.Managers.ItemMgr.FindItemTemplate(shopItem.TemplateID); //获取物品属性
ItemInfo item = ItemInfo.CreateFromTemplate(goods, 1, (int)ItemAddType.Buy); //创建物品模板
////////////////////////////////////////////////////////////////////////////////////////////////////
//判断有限期
if (0 == shopItem.BuyType) //时间购买类型
{
if (1 == type)
{
item.ValidDate = shopItem.AUnit;
}
if (2 == type)
{
item.ValidDate = shopItem.BUnit;
}
if (3 == type)
{
item.ValidDate = shopItem.CUnit;
}
}
else //数量购买类型
{
if (1 == type)
{
item.Count = shopItem.AUnit;
}
if (2 == type)
{
item.Count = shopItem.BUnit;
}
if (3 == type)
{
item.Count = shopItem.CUnit;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
if (item == null && shopItem == null)
continue;
item.Color = color == null ? "" : color;
item.Skin = skin == null ? "" : skin;
if (isBind == true)
{
item.IsBinds = true;
}
else
{
item.IsBinds = Convert.ToBoolean(shopItem.IsBind);
}
types.Append(type);
types.Append(",");
//.........这里部分代码省略.........
示例15: BanUser
/// <summary>
/// Bans the user.
/// </summary>
/// <param name="client">The client.</param>
/// <param name="moderator">The moderator.</param>
/// <param name="lengthSeconds">The length seconds.</param>
/// <param name="reason">The reason.</param>
/// <param name="ipBan">if set to <c>true</c> [ip ban].</param>
/// <param name="machine">if set to <c>true</c> [machine].</param>
internal void BanUser(GameClient client, string moderator, double lengthSeconds, string reason, bool ipBan,
bool machine)
{
var type = ModerationBanType.UserName;
var text = client.GetHabbo().UserName;
var typeStr = "user";
var num = AzureEmulator.GetUnixTimeStamp() + lengthSeconds;
if (ipBan)
{
type = ModerationBanType.Ip;
using (var queryReactor = AzureEmulator.GetDatabaseManager().GetQueryReactor())
{
queryReactor.SetQuery("SELECT ip_last FROM users WHERE username = @name LIMIT 1");
queryReactor.AddParameter("name", text);
text = queryReactor.GetString();
}
typeStr = "ip";
}
if (machine)
{
type = ModerationBanType.Machine;
typeStr = "machine";
text = client.MachineId;
}
var moderationBan = new ModerationBan(type, text, reason, num);
switch (moderationBan.Type)
{
case ModerationBanType.Ip:
if (_bannedIPs.Contains(text)) _bannedIPs[text] = moderationBan;
else _bannedIPs.Add(text, moderationBan);
break;
case ModerationBanType.Machine:
if (_bannedMachines.ContainsKey(text)) _bannedMachines[text] = moderationBan;
else _bannedMachines.Add(text, moderationBan);
break;
default:
if (_bannedUsernames.Contains(text)) _bannedUsernames[text] = moderationBan;
else _bannedUsernames.Add(text, moderationBan);
break;
}
using (var queryreactor2 = AzureEmulator.GetDatabaseManager().GetQueryReactor())
{
queryreactor2.SetQuery(
"INSERT INTO users_bans (bantype,value,reason,expire,added_by,added_date) VALUES (@rawvar,@var,@reason,@num,@mod,@time)");
queryreactor2.AddParameter("rawvar", typeStr);
queryreactor2.AddParameter("var", text);
queryreactor2.AddParameter("reason", reason);
queryreactor2.AddParameter("num", num);
queryreactor2.AddParameter("mod", moderator);
queryreactor2.AddParameter("time", DateTime.Now.ToLongDateString());
queryreactor2.RunQuery();
}
if (ipBan)
{
DataTable dataTable;
using (var queryreactor3 = AzureEmulator.GetDatabaseManager().GetQueryReactor())
{
queryreactor3.SetQuery("SELECT id FROM users WHERE ip_last = @var");
queryreactor3.AddParameter("var", text);
dataTable = queryreactor3.GetTable();
}
if (dataTable != null)
{
using (var queryreactor4 = AzureEmulator.GetDatabaseManager().GetQueryReactor())
{
foreach (DataRow dataRow in dataTable.Rows)
{
queryreactor4.RunFastQuery(
string.Format("UPDATE users_info SET bans = bans + 1 WHERE user_id = {0}",
Convert.ToUInt32(dataRow["id"])));
}
}
}
BanUser(client, moderator, lengthSeconds, reason, false, false);
return;
}
using (var queryreactor5 = AzureEmulator.GetDatabaseManager().GetQueryReactor())
{
queryreactor5.RunFastQuery(string.Format("UPDATE users_info SET bans = bans + 1 WHERE user_id = {0}",
client.GetHabbo().Id));
}
client.Disconnect("banned");
}