-->
29571467746334864
recent
أخبار ساخنة

حل جميع مشاكل سورس اليكس Alex

الخط
حل جميع مشاكل سورس اليكس Alex
حل جميع مشاكل سورس اليكس Alex

كيفية حل مشكلات سورسات كونكر (سورس Alex) حل مشكلة اللاج كاملة في سورس اليكس

شرحنا اليوم عن حل مشكلة سورس اليكس الذي يبحث عنها الكثير ولم يجد لها حل وبمناسبة نشر السورس علي موقعنا وعدناكم بحلول مشكلات سورس اليكس كاملة حتي ييكون بدون مشاكل , وسيكون الفترة القادمه شروحات كثيرة لحلول ومشاكلات سورسات كونكر , قبل اي شئ يرجي الدخول الي سورس Alex DarkSouls وتحميلة من الاسفل وتشغيلة واذا وجدت لاج في السيرفر الخاص بك سيكون الحل هنا بالتفصيل واذا لم تجد المشكلة لا تعدل علي اي شئ.

حل مشكلة سورس Alex

اولا يظهر الايرور في كلاس TheardPoll.cs وسيكون الحل كالتالي:
ادخل علي المسار
....... Game/MsgMonster ....... 

وبعد ذلك تفتح كلاس
....... PoolProcesor.cs ....... 

بدله بهذا الكود
using System;
using Project_Terror_v2.Game.MsgServer;
using Project_Terror_v2.Game.MsgFloorItem;
namespace Project_Terror_v2.Game.MsgMonster
{ public class PoolProcesses {
public unsafe static void BuffersCallback(Client.GameClient client, Extensions.Time32 clock)
{ try { Extensions.Time32 timer = Extensions.Time32.Now;
{
var Array = client.Player.View.Roles(Role.MapObjectType.Monster); foreach (var map_mob in Array) var Mob = (map_mob as MonsterRole);
if (Mob.FloorPacket.m_ID == Game.MsgFloorItem.MsgItemPacket.Thundercloud && DateTime.Now > Mob.FloorStampTimer)
if (Mob.IsFloor) { { Mob.FloorStampTimer = DateTime.Now.AddSeconds(1); Mob.StampFloorSecounds -= 1000;
var stream = rec.GetStream();
if(DateTime.Now > Mob.RemoveFloor) { using (var rec = new ServerSockets.RecycledPacket()) { ActionQuery action;
Mob.View.SendScreen(stream.ActionCreate(&action), Mob.GMap);
action = new ActionQuery() { ObjId = Mob.FloorPacket.m_UID, Type = ActionType.RemoveEntity };
Mob.GMap.View.LeaveMap(Mob);
Mob.HitPoints = 0;
client.Map.SetMonsterOnTile(Mob.X, Mob.Y, false);
} }
else if (Mob.FloorPacket.m_ID == Game.MsgFloorItem.MsgItemPacket.AuroraLotus && DateTime.Now > Mob.FloorStampTimer)
} {
{
using (var rec = new ServerSockets.RecycledPacket())
Mob.FloorPacket.DropType = MsgFloorItem.MsgDropID.RemoveEffect;
var stream = rec.GetStream();
if (user.Alive == false)
foreach (var user in Mob.View.Roles(client.Map, Role.MapObjectType.Player)) {
{
{ if (Role.Core.GetDistance(user.X, user.Y, Mob.X, Mob.Y) < 5)
if (player.ContainFlag(MsgUpdate.Flags.SoulShackle) == false)
var player = user as Role.Player; player.Revive(stream); }
action = new ActionQuery()
} // user.Send(Mob.GetArray(stream, false)); } ActionQuery action;
{ ObjId = Mob.FloorPacket.m_UID, Type = ActionType.RemoveEntity };
Mob.GMap.View.LeaveMap(Mob);
Mob.View.SendScreen(stream.ActionCreate(&action), Mob.GMap);
Mob.HitPoints = 0;
client.Map.SetMonsterOnTile(Mob.X, Mob.Y, false);
} }
else if (Mob.FloorPacket.m_ID == Game.MsgFloorItem.MsgItemPacket.FlameLotus && DateTime.Now > Mob.FloorStampTimer)
{ using (var rec = new ServerSockets.RecycledPacket()) {
uint experience = 0;
var stream = rec.GetStream(); Mob.FloorPacket.DropType = MsgFloorItem.MsgDropID.RemoveEffect;
if (user.UID != Mob.OwnerFloor.Player.UID && Role.Core.GetDistance(user.X, user.Y, Mob.X, Mob.Y) < 5)
foreach (var user in Mob.View.Roles(client.Map, Role.MapObjectType.Player)) { { var player = user as Role.Player;
Game.MsgServer.MsgSpellAnimation.SpellObj AnimationObj;
if (MsgServer.AttackHandler.CheckAttack.CanAttackPlayer.Verified(Mob.OwnerFloor, player, null)) { Game.MsgServer.AttackHandler.Calculate.Magic.OnPlayer(Mob.OwnerFloor.Player, player, Mob.DBSpell, out AnimationObj);
Attack.UID = Mob.UID;
Game.MsgServer.AttackHandler.ReceiveAttack.Player.Execute(AnimationObj, Mob.OwnerFloor, player); AnimationObj.Damage = Game.MsgServer.AttackHandler.Calculate.Base.CalculateSoul(AnimationObj.Damage, 0); InteractQuery Attack = new InteractQuery(); Attack.OpponentUID = player.UID;
player.View.SendView(stream, true);
Attack.Damage = (int)AnimationObj.Damage; Attack.Effect = AnimationObj.Effect; Attack.X = player.X; Attack.Y = player.Y; Attack.AtkType = MsgAttackPacket.AttackID.Physical; stream.InteractionCreate(&Attack); }
if (monster.UID != Mob.UID)
} user.Send(Mob.GetArray(stream, false)); } foreach (var obj in Mob.OwnerFloor.Player.View.Roles(Role.MapObjectType.Monster)) { if (Role.Core.GetDistance(obj.X, obj.Y, Mob.X, Mob.Y) < 5) { var monster = obj as Game.MsgMonster.MonsterRole;
AnimationObj.Damage = Game.MsgServer.AttackHandler.Calculate.Base.CalculateSoul(AnimationObj.Damage, 0);
{ Game.MsgServer.MsgSpellAnimation.SpellObj AnimationObj; Game.MsgServer.AttackHandler.Calculate.Magic.OnMonster(Mob.OwnerFloor.Player, monster, Mob.DBSpell, out AnimationObj); Game.MsgServer.AttackHandler.ReceiveAttack.Monster.Execute(stream, AnimationObj, Mob.OwnerFloor, monster); experience += AnimationObj.Damage;
Attack.AtkType = MsgAttackPacket.AttackID.Physical;
InteractQuery Attack = new InteractQuery(); Attack.UID = Mob.UID; Attack.OpponentUID = Mob.UID; Attack.Damage = (int)AnimationObj.Damage; Attack.Effect = AnimationObj.Effect; Attack.X = Mob.X; Attack.Y = Mob.Y; stream.InteractionCreate(&Attack);
SpellID = (ushort)Role.Flags.SpellID.FlameLotus
monster.View.SendScreen(stream, client.Map); } } } var DBSpells = Database.Server.Magic[(ushort)Role.Flags.SpellID.FlameLotus]; MsgServer.AttackHandler.Updates.IncreaseExperience.Up(stream, Mob.OwnerFloor, experience); MsgServer.AttackHandler.Updates.UpdateSpell.CheckUpdate(stream, Mob.OwnerFloor, new InteractQuery() { }, experience, DBSpells);
}
Mob.FloorPacket.DropType = MsgFloorItem.MsgDropID.Remove; Mob.View.SendScreen(stream.ItemPacketCreate(Mob.FloorPacket), Mob.GMap); ActionQuery action; action = new ActionQuery() { ObjId = Mob.FloorPacket.m_UID, Type = ActionType.RemoveEntity }; unsafe { Mob.View.SendScreen(stream.ActionCreate(&action), Mob.GMap);
Mob.GMap.View.LeaveMap(Mob);
// Mob.FloorPacket.DropType = MsgFloorItem.MsgDropID.RemoveEffect; // Mob.View.SendScreen(stream.ItemPacketCreate(Mob.FloorPacket), Mob.GMap);
Mob.HitPoints = 0;
//client.Map.MonstersColletion.Roles.Remove(Mob.UID);
client.Map.SetMonsterOnTile(Mob.X, Mob.Y, false);
continue;
} } }
if (timer > Mob.Stamp_BlackSpot)
if (Mob.BlackSpot) { {
using (var rec = new ServerSockets.RecycledPacket())
Mob.BlackSpot = false; {
Mob.Send(stream.BlackspotCreate(false, Mob.UID));
var stream = rec.GetStream(); } } }
{
foreach (var flag in Mob.BitVector.GetFlags()) { if (flag.Expire(timer))
else if (flag.Key == (int)Game.MsgServer.MsgUpdate.Flags.ScarofEarth)
Mob.RemoveFlag((MsgServer.MsgUpdate.Flags)flag.Key, client.Map); } { if (flag.CheckInvoke(timer))
using (var rec = new ServerSockets.RecycledPacket())
{ if (Mob.ScarofEarthl != null && Mob.AttackerScarofEarthl != null) { {
MsgSpellAnimation MsgSpell = new MsgSpellAnimation( Mob.UID, 0, Mob.X, Mob.Y, DBSpell.ID, DBSpell.Level, 0, 1);
var stream = rec.GetStream(); var DBSpell = Mob.ScarofEarthl; MsgSpellAnimation.SpellObj AnimationObj = new MsgSpellAnimation.SpellObj()
{ UID = Mob.UID, Damage = (uint)DBSpell.Damage2, Hit = 1 };
MsgSpell.Send(client);
Game.MsgServer.AttackHandler.ReceiveAttack.Monster.Execute(stream, AnimationObj, Mob.AttackerScarofEarthl, Mob); MsgSpell.SetStream(stream); MsgSpell.Targets.Enqueue(AnimationObj); } } }
if (Mob.HitPoints == 1)
} else if (flag.Key == (int)Game.MsgServer.MsgUpdate.Flags.Poisoned) { if (flag.CheckInvoke(timer)) { uint damage = Game.MsgServer.AttackHandler.Calculate.Base.CalculatePoisonDamage(Mob.HitPoints, Mob.PoisonLevel); {
var stream = rec.GetStream();
damage = 0; goto jump; } Mob.HitPoints = (uint)Math.Max(1, (int)(Mob.HitPoints - damage)); jump: using (var rec = new ServerSockets.RecycledPacket()) {
};
InteractQuery action = new InteractQuery() { Damage = (int)damage, AtkType = MsgAttackPacket.AttackID.Physical, X = Mob.X, Y = Mob.Y, OpponentUID = Mob.UID
try
Mob.Send(stream.InteractionCreate(&action)); } } } } } } catch (Exception e) { MyConsole.WriteException(e); } } public static void GuardsCallback(Client.GameClient client, Extensions.Time32 clock) { { if (client.Map == null)
if (timer > Guard.AttackSpeed.AddMilliseconds(Guard.Family.AttackSpeed))
return; Extensions.Time32 timer = Extensions.Time32.Now; var Array = client.Player.View.Roles(Role.MapObjectType.Monster); foreach (var map_mob in Array) { var Guard = (map_mob as MonsterRole); if ((Guard.Family.Settings & MonsterSettings.Guard) == MonsterSettings.Guard) { {
Guard.RemoveView(timer.AllMilliseconds, client.Map);
client.Player.View.MobActions.CheckGuardPosition(client.Player.View.GetPlayer(), Guard); if (client.Player.View.MobActions.GuardAttackPlayer(client.Player.View.GetPlayer(), Guard)) Guard.AttackSpeed = timer; if (!Guard.Alive) { Guard.AddFadeAway(timer.AllMilliseconds, client.Map); } foreach (var mob in Array)
break;
{ var monseter = (mob as MonsterRole); if ((monseter.Family.Settings & MonsterSettings.Guard) != MonsterSettings.Guard && (monseter.Family.Settings & MonsterSettings.Reviver) != MonsterSettings.Reviver && !monseter.IsFloor) { if (client.Player.View.MobActions.GuardAttackMonster(client.Map, monseter, Guard)) }
var Array = client.Player.View.Roles(Role.MapObjectType.Monster);
} } } } } catch (Exception e) { MyConsole.WriteException(e); } } public static void AliveMonstersCallback(Client.GameClient client, Extensions.Time32 clock) { try { if (client.Map == null) return; Extensions.Time32 timer = Extensions.Time32.Now; foreach (var map_mob in Array) {
monster.Respawn();
var monster = (map_mob as MonsterRole); if (!map_mob.Alive) { if (monster.State == Game.MsgMonster.MobStatus.Respawning) { if (MonsterRole.SpecialMonsters.Contains(monster.Family.ID)) continue; if (timer > monster.RespawnStamp) { if (!client.Map.MonsterOnTile(monster.RespawnX, monster.RespawnY)) {
if (Mob.Family.ID == 20211)
client.Map.SetMonsterOnTile(monster.X, monster.Y, true); } } } } if ((monster.Family.Settings & MonsterSettings.Guard) != MonsterSettings.Guard && (monster.Family.Settings & MonsterSettings.Reviver) != MonsterSettings.Reviver && (monster.Family.Settings & MonsterSettings.Lottus) != MonsterSettings.Lottus) { var Mob = map_mob as MonsterRole; continue;
if (client.Map == null)
client.Player.View.MobActions.ExecuteAction(client.Player.View.GetPlayer(), Mob); if (!Mob.Alive) { var now = Extensions.Time32.Now; Mob.AddFadeAway(now.AllMilliseconds, client.Map); Mob.RemoveView(now.AllMilliseconds, client.Map); } } } } catch (Exception e) { MyConsole.WriteException(e); } } private unsafe static void ReviversCallback(Client.GameClient client) { try {
if (Role.Core.GetDistance(map_mob.X, map_mob.Y, client.Player.View.GetPlayer().X, client.Player.View.GetPlayer().Y) < 13)
return; var Array = client.Player.View.Roles(Role.MapObjectType.Monster); foreach (var map_mob in Array) { var monseter = (map_mob as MonsterRole); if ((monseter.Family.Settings & MonsterSettings.Reviver) == MonsterSettings.Reviver) { if (!monseter.Alive) { var now = Extensions.Time32.Now.AllMilliseconds; monseter.AddFadeAway(now, client.Map); monseter.RemoveView(now, client.Map); } {
, 0, map_mob.X, map_mob.Y, (ushort)Role.Flags.SpellID.Pray, 0, 0);
if (!client.Player.View.GetPlayer().Alive) { using (var rec = new ServerSockets.RecycledPacket()) { var stream = rec.GetStream(); client.Player.View.GetPlayer().Revive(stream); } using (var rec = new ServerSockets.RecycledPacket()) { var stream = rec.GetStream(); MsgServer.MsgSpellAnimation SpellPacket = new MsgServer.MsgSpellAnimation(map_mob.UID
}
SpellPacket.Targets.Enqueue(new MsgServer.MsgSpellAnimation.SpellObj(client.Player.View.GetPlayer().UID, 0, MsgServer.MsgAttackPacket.AttackEffect.None)); SpellPacket.SetStream(stream); SpellPacket.Send(map_mob as Game.MsgMonster.MonsterRole); } } } } } } catch (Exception e) { MyConsole.WriteException(e); } }
}

وبعد تبديل الكود تدخل الي المسار
ServerSockets  

وتفتح كلاس
BruteforceProtection.cs  

بدل الكلاس بهذا !
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Text;
namespace Project_Terror_v2.ServerSockets
{ public class BruteForceEntry {
public int WatchCheck;
public string IPAddress;
public Extensions.Time32 AddedTimeRemove;
public Extensions.Time32 Unbantime; }
private Extensions.SafeDictionary collection = new Extensions.SafeDictionary();
public class BruteforceProtection {
private int BanOnWatch;
private void _internalInit()
{ Extensions.Time32 Now;
Now = Extensions.Time32.Now;
while (true) {
{
foreach (BruteForceEntry bfe in collection.GetValues())
collection.Remove(bfe.IPAddress);
if (bfe.AddedTimeRemove <= Now) { }
if (bfe.Unbantime.Value <= Now.Value)
else if (bfe.Unbantime.Value != 0) { {
Thread.Sleep(2000);
collection.Remove(bfe.IPAddress); } } } } }
}
public void Init(int WatchBeforeBan) { BanOnWatch = WatchBeforeBan; new Thread(new ThreadStart(_internalInit)).Start();
if (!collection.TryGetValue(IPAddress, out bfe))
public void AddWatch(string IPAddress) { lock (collection) { BruteForceEntry bfe; { bfe = new BruteForceEntry();
bfe.Unbantime = new Extensions.Time32(0);
bfe.IPAddress = IPAddress; bfe.WatchCheck = 1; bfe.AddedTimeRemove = Extensions.Time32.Now.AddMinutes(3); collection.Add(IPAddress, bfe); }
bfe.Unbantime = Extensions.Time32.Now.AddMinutes(3);
else { bfe.WatchCheck++; if (bfe.WatchCheck >= BanOnWatch) { Console.WriteLine(IPAddress + "Has been ban"); }
return false;
} } } public bool AllowAddress(string IPAddress) { foreach (var server in Database.GroupServerList.GroupServers.Values) if (server.IPAddress == IPAddress) return false;
}
} public bool IsBanned(string IPAddress) { bool check = false; BruteForceEntry bfe; if (collection.TryGetValue(IPAddress, out bfe)) { check = (bfe.Unbantime.Value != 0);
}
return check; }
}

افتح كلاس
ConcurrentPacketQueue.cs  

بدله بـ
using System;
using System.Collections.Generic;
using System.Linq;
namespace Project_Terror_v2.ServerSockets
using System.Text; {
{
public class ConcurrentPacketQueue
private byte[] queue = new byte[capacity + 1];
const int capacity = 8191;
private int enqueuePointer = 0, dequeuePointer = 0, enqueuedData = 0,
currentPacketSize = -1, tqPadding; private object syncRoot;
syncRoot = new object();
public ConcurrentPacketQueue(int padding = 8) { tqPadding = padding; }
public unsafe void Enqueue(byte[] buffer, int length)
public int CurrentLength { get { reviewPacketSize(); return currentPacketSize; } } { lock (syncRoot) {
private void reviewPacketSize()
for (int i = 0; i < length; i++, enqueuePointer++) queue[enqueuePointer & capacity] = buffer[i]; enqueuedData += length; } } {
else currentPacketSize = ((queue[dequeuePointer & capacity] | (queue[(dequeuePointer + 1) & capacity] << 8)) + tqPadding);
lock (syncRoot) { if (enqueuedData < 2) currentPacketSize = -1; } } public bool CanDequeue() { reviewPacketSize();
if (currentPacketSize == -1 || enqueuedData < currentPacketSize)
if (currentPacketSize == -1) return false; return (enqueuedData >= currentPacketSize); } public byte[] Dequeue() { lock (syncRoot) {
array[i] = queue[dequeuePointer & capacity];
throw new OperationCanceledException("Before calling Dequeue(), always call CanDequeue()!"); byte[] array = new byte[currentPacketSize]; for (int i = 0; i < currentPacketSize; i++, dequeuePointer++) enqueuedData -= currentPacketSize;
}
reviewPacketSize(); return array; } }
}

وبعد ذلك تعمل كلاس جديد في فولد ServerSockets
بأسم LoginController.cs

وضيف فيه هذا الكود كامل
using System;
using System.Collections.Generic;
using System.Linq;
namespace Project_Terror_v2.ServerSockets
using System.Text; {
{
public class LoginController
private static Dictionary LoginControllerContainer = new Dictionary();
public static bool CanLogin(string IP)
{ byte logintimes = 0;
if (LoginControllerContainer.TryGetValue(IP, out logintimes))
{ return logintimes < 3; } else {
public static void LoggedIn(string IP)
LoginControllerContainer.Add(IP, 0); return true; } } { try {
LoginControllerContainer.Remove(IP);
if (LoginControllerContainer.ContainsKey(IP)) { byte times = LoginControllerContainer[IP]; times += 1;
{
LoginControllerContainer.Add(IP, times); } } catch { } } public static void Disconnect(string IP) { try
{
if (LoginControllerContainer.ContainsKey(IP)) { byte times = LoginControllerContainer[IP]; LoginControllerContainer.Remove(IP); if (times > 0)
}
times -= 1; } LoginControllerContainer.Add(IP, times); } } catch { } }
}

ادخل علي كلاس Packet.cs وبدله بالكود الاتي
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace Project_Terror_v2.ServerSockets
{ public unsafe class Packet : IDisposable {
private const int TQ_SEALSIZE = 8;
public const int MAX_SIZE = 1024; private static string seal;
private static extern void* memcpy(void* dst, void* src, int num);*/
/*[DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)] [DllImport("msvcrt.dll", CallingConvention = CallingConvention.Cdecl)]
set
private static extern void* memset(void* dst, int val, int count); public static string SealString { get { return seal; } { if (value.Length != TQ_SEALSIZE)
get { return seal != null ? TQ_SEALSIZE : 0; }
throw new ArgumentOutOfRangeException("value", "Packet seal must be " + TQ_SEALSIZE + " chars long."); seal = value; } } public static int SealSize { } public int Size { get; set; } public byte* Memory { get; private set; }
Marshal.Copy(buffer, 0, (IntPtr)this.stream, buffer.Length);
private bool IsDisposed = false; public byte* stream; public int Position { get { return (int)(stream - Memory); } } // public byte* Pointer { get { return stream; } } public Packet(byte[] buffer) { Memory = (byte*)Marshal.AllocHGlobal(1024); stream = Memory;
if (this.IsDisposed) return;
this.Size = buffer.Length; } public Packet(int size) { Memory = (byte*)Marshal.AllocHGlobal(size); stream = Memory; } ~Packet() { this.Dispose(); } public void Dispose() { // lock (this) {
public void Seek(int offset)
IsDisposed = true; if ((IntPtr)this.Memory == IntPtr.Zero) return; Marshal.FreeHGlobal((IntPtr)this.Memory); this.Memory = null; GC.SuppressFinalize(this); } } public void InitWriter() { Seek(4); } {
*stream = value;
stream = &Memory[offset]; } public void SeekForward(int amount) { Seek(Position + amount); } public void SeekBackwards(int amount) { Seek(Position - amount); } public void Write(byte value) { if (Position + 1 >= MAX_SIZE) return; stream++; }
public void Write(ulong value)
public void Write(ushort value) { if (Position + 2 >= MAX_SIZE) return; *((ushort*)stream) = value; stream += sizeof(ushort); } public void Write(uint value) { if (Position + 4 >= MAX_SIZE) return; *((uint*)stream) = value; stream += sizeof(uint); } {
public void Write(string value, int length)
if (Position + 8 >= MAX_SIZE) return; *((ulong*)stream) = value; stream += sizeof(ulong); } public void Write(sbyte value) { Write((byte)value); } public void Write(short value) { Write((ushort)value); } public void Write(int value) { Write((uint)value); } public void Write(long value) { Write((ulong)value); } {
if (string.IsNullOrEmpty(str))
int min = Math.Min(value.Length, length); var buf = Encoding.Default.GetBytes(value); for (int i = 0; i < min; i++) Write(buf[i]); ZeroFill(length - min); } public void Write(params string[] value) { Write((byte)value.Length); for (int i = 0; i < value.Length; i++) { var str = value[i]; {
if (Position + amount >= MAX_SIZE)
Write((byte)0); continue; } Write((byte)str.Length); Write(str, str.Length); } } public void WriteUnsafe(void* buf, int length) { if (Position + length >= MAX_SIZE) return; memcpy(stream, buf, length); stream += length; } public void ZeroFill(int amount) {
return;
return; memset(stream, 0, amount); stream += amount; } public string[] ReadStringList() { var result = new string[ReadUInt8()]; for (int i = 0; i < result.Length; i++) result[i] = ReadCString(ReadUInt8()); return result; } public void ReadUnsafe(void* buf, int length) { if (Position + length >= MAX_SIZE)
string result = new string((sbyte*)this.stream, 0, size);
memcpy(buf, stream, length); stream += length; } public byte[] ReadBytes(int size) { byte[] res = new byte[size]; for (int i = 0; i < res.Length; i++) res[i] = ReadUInt8(); return res; } public string ReadCString(int size) { if (Position + size >= MAX_SIZE) return ""; stream += size; int idx = result.IndexOf('\0');
return result;
return (idx > -1) ? result.Substring(0, idx) : result; } public byte ReadUInt8() { if (Position + 1 >= MAX_SIZE) return 0; var result = *stream; stream++; return result; } public ushort ReadUInt16() { if (Position + 2 >= MAX_SIZE) return 0; var result = *((ushort*)stream); stream += sizeof(ushort); } public uint ReadUInt32() {
public int ReadInt32() { return (int)ReadUInt32(); }
if (Position + 4 >= MAX_SIZE) return 0; var result = *((uint*)stream); stream += sizeof(uint); return result; } public ulong ReadUInt64() { if (Position + 8 >= MAX_SIZE) return 0; var result = *((ulong*)stream); stream += sizeof(ulong); return result; } public sbyte ReadInt8() { return (sbyte)ReadUInt8(); } public short ReadInt16() { return (short)ReadUInt16(); }
byte[] array = ms.ToArray();
public long ReadInt64() { return (long)ReadUInt64(); } public void Finalize(ushort type) { if (SealSize > 0) { WriteSeal(); } this.Size = this.Position; Seek(0); Write((ushort)(this.Size - SealSize)); Write((ushort)type); } public void ProtoBufferSerialize(object obj) { using (var ms = new System.IO.MemoryStream()) { ProtoBuf.Serializer.Serialize(ms, obj); fixed (byte* proto_ptr = array)
public T ProtoBufferDeserialize(T obj)
memcpy(stream, proto_ptr, array.Length); stream += array.Length; } }
{
Seek(0);
ushort packet_length = ReadUInt16();
ReadUInt16();
byte[] array = new byte[packet_length - 4];
array = ReadBytes(packet_length - 4);
obj = ProtoBuf.Serializer.Deserialize(ms);
using (var ms = new System.IO.MemoryStream(array)) {
}
return obj;
}
public T ProtoBufferDeserialize(T obj, byte[] packet)
{
using (var ms = new System.IO.MemoryStream(packet))
{
obj = ProtoBuf.Serializer.Deserialize(ms);
}
return obj;
}
public void WriteSeal()
{
Write(SealString, TQ_SEALSIZE); // NOTE: must be 8 chars
}
{
private static string CreatePacketStringWithNumbers(byte* b, int len)
// Special Thanks: John
// // -- Taken from ConquerAI //
+ ((len / 16) + 1) * 9; //1 for /t and 2 for new line/ret, 3 for number, 2 for [ ] and 1 for space
int msgSize = (len) * 4 //4 chars, 2 for number, 1 for white space, 1 for letter StringBuilder hex = new StringBuilder(msgSize);
{
for (int i = 0; i < len; i += 16) { hex.AppendFormat("[{0:000}] ", i); for (int z = i; z < i + 16; z++)
for (int z = i; z < i + 16; z++)
if (z >= len) hex.Append(" "); else hex.AppendFormat("{0:x2} ", b[z]); } hex.Append('\t'); {
hex.AppendFormat("{0}", (char)b[z]);
if (z >= len) hex.Append(" "); else { if (b[z] > 32 && b[z] < 127) { } else
public static string Dump(byte[] b)
{ hex.Append('.'); } } } hex.Append("\r\n"); } return hex.ToString(); } {
int type = ReadUInt16(); Seek(offset);
fixed (byte* ptr = b) return CreatePacketStringWithNumbers(ptr, b.Length); } public string Dump(string header) { int offset = Position; Seek(2);
{
string str = "Packet (" + header + ") - Type: " + type + " Size - " + Size + "\r\n"; str += CreatePacketStringWithNumbers(this.Memory, this.Size); return str; } public unsafe void memcpy(void* dest, void* src, Int32 size)
*(((Byte*)dest) + pos + i) = *(((Byte*)src) + pos + i);
Int32 count = size / sizeof(long); for (Int32 i = 0; i < count; i++) *(((long*)dest) + i) = *(((long*)src) + i); Int32 pos = size - (size % sizeof(long)); for (Int32 i = 0; i < size % sizeof(long); i++) } }
}

ادخل علي كلاس PacketRecycle.cs وبدله بــ
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Concurrent;
using System.Text;
namespace Project_Terror_v2.ServerSockets
{ public class RecycledPacket : IDisposable {
public Packet GetStream() { return stream; }
private Packet stream; public RecycledPacket() {
{
this.stream = PacketRecycle.Take(); } ~RecycledPacket() this.Dispose();
PacketRecycle.Reuse(stream);
} public void Dispose() { if (stream == null) return;
{
stream = null; GC.SuppressFinalize(this); } } public static class PacketRecycle
private static ConcurrentQueue bin = new ConcurrentQueue();
public static int Count { get { return bin.Count; } }
public static Packet Take()
{ Packet from;
if (!bin.TryDequeue(out from))
from = new Packet(Packet.MAX_SIZE); from.Seek(4);
public static void Reuse(Packet old)
return from; } { old.Seek(0); bin.Enqueue(old);
} }
}
وبعد ذلك تدخل علي كلاس ReceiveBuffer.cs وبدلة بــ
using System;
using System.Collections.Generic;
using System.Linq;
namespace Project_Terror_v2.ServerSockets
using System.Text; {
public const int RECV_BUFFER_SIZE = 4096;//16384;//8192;//2048;
public class ReceiveBuffer {
public byte[] buffer;
public const int HeadSize = 1024; private int nLen;
{
public ReceiveBuffer(int ReceiveBufferSize, bool changesize = false) if (changesize) {
// if (ReceiveBufferSize == 0)
buffer = new byte[ReceiveBufferSize]; } else { buffer = new byte[RECV_BUFFER_SIZE];//RECV_BUFFER_SIZE];
{
//else // buffer = new byte[ReceiveBufferSize]; } Reset(); } public void AddLength(int length)
{
nLen += length; } public ushort ReadHead() { return BitConverter.ToUInt16(buffer, 0); } public void DelLength(int length)
nLen = 0;
nLen -= length; } public int Length() { return nLen; } public int MaxLength() { return buffer.Length; } public void Reset() { } }
}

ادخل علي كلاس SecuritySocket.cs وبدلة بــ
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.Concurrent;
using System.Text; using System.Net;
using System.Threading;
using System.Net.Sockets; using System.Runtime.InteropServices;
namespace Project_Terror_v2.ServerSockets
using System.Diagnostics; { public unsafe class SecuritySocket {
get
public ReceiveBuffer ReceiveBuff; public bool IsGameServer { {
private Action OnDisconnect;
return Crypto != null; } } public bool SetDHKey = false;
private Action OnReceiveHandler;
public Socket Connection;
public object Client;
private IDisposable[] TimerSubscriptions = null;
public bool Alive = false; public Cryptography.TQCast5 Crypto;
get
public bool OnInterServer = false; public string RemoteIp { { try
return (Connection.RemoteEndPoint as IPEndPoint).Address.ToString();
{ if (Connection == null) return "NONE"; }
public Extensions.Time32 LastReceive;
catch { return "NONE"; } } }
public SecuritySocket(ServerSocket serversocket, Action _OnDisconnect, Action _OnReceiveHandler)
public Client.GameClient Game; public ServerSocket Server; public bool ConnectFull = false;
{
Server = serversocket;
OnReceiveHandler = _OnReceiveHandler;
OnDisconnect = _OnDisconnect;
public SecuritySocket(Action _OnDisconnect, Action _OnReceiveHandler)
}
{
OnReceiveHandler = _OnReceiveHandler;
OnDisconnect = _OnDisconnect;
public bool Connect(string IPAddres, ushort port, out Socket _socket)
} {
_socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
IAsyncResult asyncResult = _socket.BeginConnect(new IPEndPoint(IPAddress.Parse(IPAddres), port), null, null);
uint count = 0; while (!asyncResult.IsCompleted && count < 10) {
if (asyncResult.IsCompleted)
count++; System.Threading.Thread.Sleep(100); } {
_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
_socket.Blocking = false; _socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true);
// Set option that allows socket to receive out-of-band information in the data stream.
_socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true); _socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.OutOfBandInline, true);
try
_socket.ReceiveBufferSize = _socket.SendBufferSize = ServerSockets.ReceiveBuffer.RECV_BUFFER_SIZE; } return asyncResult.IsCompleted; } public void Create(Socket _socket) { {
TimerSubscriptions = new IDisposable[]
ReceiveBuff = new ReceiveBuffer(Program.ServerConfig.Port_ReceiveSize); Connection = _socket; SetDHKey = false; Alive = true; LastReceive = Extensions.Time32.Now; Client = Crypto = null; {
ThreadPoll.Subscribe(ThreadPoll.ConnectionReceive, this, ThreadPoll.ReceivePool),
ThreadPoll.Subscribe(ThreadPoll.ConnectionReview, this, ThreadPoll.GenericThreadPool)
}; } catch (Exception e)
}
{ MyConsole.SaveException(e); }
if (!Program.ServerConfig.IsInterServer)
public void SetCrypto(Cryptography.TQCast5 Crypt) { { Crypto = Crypt;
}
} } public static void TryReview(SecuritySocket sock) { sock.CheckUp();
if (Extensions.Time32.Now > LastReceive.AddSeconds(60 * 5))
public void CheckUp() { if (Crypto != null) { this.Disconnect(); } }
{
public int tstgg = 0; object locckss = new object(); public unsafe void Send(Packet msg) { try
byte[] _buffer = new byte[msg.Size];
if (Alive) { lock (locckss) { if (Crypto != null)
msg.memcpy(ptr, msg.Memory, msg.Size);
Crypto.Encrypt(msg.Memory, 0, _buffer, 0, msg.Size); else fixed (byte* ptr = _buffer)
{
Connection.BeginSend(_buffer, 0, _buffer.Length, SocketFlags.None, new AsyncCallback(BeginSendCall), Connection); } } } catch (SocketException) Disconnect(); }
Connection.EndSend(ar);
catch (Exception e) { // MyConsole.WriteLine(e.ToString()); } } private void BeginSendCall(IAsyncResult ar) { try { if (Connection != null) }
public ReceiveBuffer EncryptedDHKeyBuffer = new ReceiveBuffer(1024, true);
catch (SocketException) { Disconnect(); } catch (Exception e) { // MyConsole.WriteLine(e.ToString()); } } public ReceiveBuffer DHKeyBuffer = new ReceiveBuffer(1024, true);
buffer[x] = DHKeyBuffer.buffer[x + (DHKeyBuffer.Length() - Packet.SealSize)];
public bool IsCompleteDHKey(out int type) { type = 0; try { if (DHKeyBuffer.Length() < 8) return false; byte[] buffer = new byte[Packet.SealSize]; for (int x = 0; x < buffer.Length; x++)
MyConsole.SaveException(e);
string Text = System.Text.ASCIIEncoding.ASCII.GetString(DHKeyBuffer.buffer); bool accept = Text.Contains("TQClient"); if (!Text.EndsWith("TQClient")) type = 1; return accept; } catch (Exception e) { Disconnect(); return false; }
int length = DHKeyBuffer.MaxLength() - DHKeyBuffer.Length();
} public unsafe bool ReceiveDHKey() { try { if (Alive && WindowsAPI.ws2_32.CanRead(this)) { int rec_type = 0; if (!SetDHKey && Alive) { SocketError Socket_Error = SocketError.IsConnected; if (length <= 0)
System.Buffer.BlockCopy(DHKeyBuffer.buffer, DHKeyBuffer.Length(), EncryptedDHKeyBuffer.buffer, EncryptedDHKeyBuffer.Length(), ret);
{ Disconnect(); return false; } int ret = Connection.Receive(DHKeyBuffer.buffer, DHKeyBuffer.Length(), length, SocketFlags.None, out Socket_Error); if (ret > 0) { EncryptedDHKeyBuffer.AddLength(ret);
{
if (Crypto != null) { fixed (byte* ptr = DHKeyBuffer.buffer) Crypto.Decrypt(DHKeyBuffer.buffer, DHKeyBuffer.Length(), ptr, DHKeyBuffer.Length(), ret); } DHKeyBuffer.AddLength(ret); if (IsCompleteDHKey(out rec_type))
stream.Size = DHKeyBuffer.Length();
using (var rec = new RecycledPacket()) { var stream = rec.GetStream(); stream.Seek(0); fixed (byte* ptr = DHKeyBuffer.buffer) stream.memcpy(stream.Memory, ptr, DHKeyBuffer.Length()); if (OnReceiveHandler != null)
{
OnReceiveHandler.Invoke(this, stream); } } } else if (ret <= 0 || Socket_Error == SocketError.ConnectionAborted) { Disconnect(); return false; } } } } catch (Exception e) Console.WriteLine(e.ToString());
{
Disconnect(); } return false; } public bool ReceiveBuffer() { if (Alive) { { try { if (!SetDHKey && Crypto != null) { ReceiveDHKey(); } else if (WindowsAPI.ws2_32.CanRead(this)) { try if (!Alive)
catch (Exception e)
return false; int available = Connection.Available; if (available == 0) { Disconnect(); return false; } if (!Receive(available)) { return false; } } {
return false;
MyConsole.SaveException(e); Disconnect(); } return true; } } catch (Exception e) { Disconnect(); Console.WriteLine(e.ToString()); } } } return false; } public unsafe bool HandlerBuffer() { int counts = 30; while (true && counts > 0) { counts--; if (!Alive) try {
if (Length > ReceiveBuff.Length())
if (!ConnectFull) return false; if (ReceiveBuff.Length() == 0) return false; int Length = (int)(ReceiveBuff.ReadHead() + (IsGameServer ? 8 : 0)); if (Program.ServerConfig.IsInterServer || OnInterServer) Length += 8; if (Length < 2) return false; if (Length > ServerSockets.ReceiveBuffer.HeadSize) { Disconnect(); return false; }
}
return false; LastReceive = Extensions.Time32.Now; Packet Stream = PacketRecycle.Take(); Stream.Seek(0); fixed (byte* ptr = ReceiveBuff.buffer) { Stream.memcpy(Stream.stream, ptr, Length); if (Length < ReceiveBuff.Length()) { fixed (void* next_buffer = &ReceiveBuff.buffer[Length]) { Stream.memcpy(ptr, next_buffer, ReceiveBuff.Length() - Length); }
int length = ReceiveBuff.MaxLength() - ReceiveBuff.Length();
Stream.Size = Length; ReceiveBuff.DelLength(Length); } Stream.SeekForward(2); if (OnReceiveHandler != null) OnReceiveHandler.Invoke(this, Stream); } catch (Exception e) { Console.WriteLine(e.ToString()); } } return false; } public bool Receive(int available) { if (Alive) { SocketError Socket_Error = SocketError.IsConnected; try { int receive_size = 0;
Crypto.Decrypt(ReceiveBuff.buffer, ReceiveBuff.Length(), ptr, ReceiveBuff.Length(), ret);
if (available > length) receive_size = length; else receive_size = available; if (receive_size == 0) { return false; } int ret = Connection.Receive(ReceiveBuff.buffer, ReceiveBuff.Length(), receive_size, SocketFlags.None, out Socket_Error); if (ret > 0) { if (Crypto != null) { fixed (byte* ptr = ReceiveBuff.buffer) } ReceiveBuff.AddLength(ret);
return false;
return true; } else if (ret == 0)//<= 0 || Socket_Error == SocketError.ConnectionAborted) { Disconnect(); return false; } else//ret < 0 { if (Socket_Error != SocketError.WouldBlock) Disconnect(); } } catch (Exception e) { Console.WriteLine(e.ToString()); Console.WriteLine(Socket_Error.ToString()); } } } public int nPutBytes = 0;
WindowsAPI.ws2_32.shutdown(Connection.Handle, WindowsAPI.ws2_32.ShutDownFlags.SD_BOTH);
public byte[] packet = null; public object SynRoot = new object(); public void Disconnect() { lock (SynRoot) { if (Alive) { if (Server != null) Server.Clients.Remove(this); Alive = false; if (TimerSubscriptions != null) { for (int i = 0; i < TimerSubscriptions.Length; i++) if (TimerSubscriptions[i] != null) TimerSubscriptions[i].Dispose(); } try { WindowsAPI.ws2_32.closesocket(Connection.Handle);
}
Connection.Dispose(); GC.SuppressFinalize(Connection); } catch (Exception e) { MyConsole.SaveException(e); } finally { if (OnDisconnect != null) OnDisconnect.Invoke(this); } } } }
}


ادخل علي كلاس ServerSocket.cs ! وبدله بــ
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Text; using System.Net;
using System.IO;
using System.Net.Sockets; using System.Collections.Concurrent;
public class ServerSocket
namespace Project_Terror_v2.ServerSockets { { private bool Alive = false;
public uint SPort;
private Socket Connection; private string ServerAddresIP = "46.105.155.123";
private Action ProcessConnection, ProcessDisconnect;
public string ServerName = "WeConquer_EU";
private Action ProcessReceive;
private BruteforceProtection Bruteforce;
public Extensions.MyList Clients = new Extensions.MyList();
public ServerSocket(Action _processConnection, Action _procesreceive, Action _processdisconnect)
{
ProcessConnection = _processConnection;
ProcessReceive = _procesreceive;
Connection = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
ProcessDisconnect = _processdisconnect; }
public void Initilize(ushort MaxBufferSend, ushort MaxBufferReceive, uint MaxAcceptConnections, uint MaxClientsConnections)
{ Connection.ReceiveBufferSize = 16384; Connection.SendBufferSize = 16384; }
TryConnect(aServerName);
public void Connect(string IpAddres, ushort port, string aServerName) { SPort = port; ServerAddresIP = IpAddres; ServerName = aServerName;
Connection.BeginConnect(ServerAddresIP, (int)SPort, new AsyncCallback(ConnectCallback), null);
} private void TryConnect(string servername) { //MyConsole.WriteLine("Server Trying connect to InterServer..."); }
Console.WriteLine("Socket connected to {0} successful !",
private void ConnectCallback(IAsyncResult ar) { try { Connection.EndConnect(ar); Connection.RemoteEndPoint.ToString());
Connection.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.OutOfBandInline, true);
Connection.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true); // Set option that allows socket to receive out-of-band information in the data stream. Connection.ReceiveBufferSize = 4096;
if (ProcessConnection != null)
Connection.SendBufferSize = 4096; Alive = Connection.Connected; if (Alive) { var client = new SecuritySocket(this, ProcessDisconnect, ProcessReceive); client.Create(Connection); {
Bruteforce = new BruteforceProtection();
ProcessConnection(client); } } } catch { TryConnect(ServerName); } } public void Open(string IpAddres, ushort port, int backlog) { Bruteforce.Init(10); SPort = port;
Connection.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true);
ServerAddresIP = IpAddres; Connection.Bind(new IPEndPoint(IPAddress.Any, port)); Connection.Listen((int)100); Connection.Blocking = false; Connection.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
if (Alive && Connection.Poll(0, SelectMode.SelectRead) && Connection.ProtocolType == ProtocolType.Tcp)
Connection.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.DontLinger, true); MyConsole.WriteLine("Listening on port : " + port.ToString()); Alive = true; } public void Accept() { try { { if (Connection.Poll(1, SelectMode.SelectError))
}
{ var close_socket = Connection.Accept(); WindowsAPI.ws2_32.shutdown(close_socket.Handle, WindowsAPI.ws2_32.ShutDownFlags.SD_BOTH); WindowsAPI.ws2_32.closesocket(close_socket.Handle); MyConsole.WriteLine("[Sockets] Error on socket Accept()."); return;
Clients.Add(user);
var socket = Connection.Accept(); string RemoteIP = (socket.RemoteEndPoint as IPEndPoint).Address.ToString(); if (!Bruteforce.IsBanned(RemoteIP)) { SecuritySocket user = new SecuritySocket(this, ProcessDisconnect, ProcessReceive); user.Create(socket);
socket.Dispose();
//MyConsole.WriteLine("IP " + user.RemoteIp + " try to connect"); Bruteforce.AddWatch(user.RemoteIp); if (ProcessConnection != null) { ProcessConnection.Invoke(user); } user.ConnectFull = true; } else { }
}
} } catch (Exception e) { MyConsole.SaveException(e); } } public void Close() { if (Alive) { Alive = false; Connection.Close(1); } }
}

بعد ذلك تدخل علي كلاس SocketThread.cs
using System;
using System.Collections.Generic;
using System.Linq;
namespace Project_Terror_v2.ServerSockets
using System.Text; {
/*const int RECV_BUFFER_SIZE = 2048; // Ó¦ÓóÌÐò×Ô¼ºµÄBUF
public class SocketThread {
const int SEND_BUFFER_SIZE = 4048; // Ó¦ÓóÌÐò×Ô¼ºµÄBUF*/
const int SOCKET_PROCESS_INTERVAL = 1; private Extensions.ThreadGroup.ThreadItem ThreadItem;
public SocketThread(string GroupName, params ServerSocket[] Sockets)
private ServerSocket[] Sockets; { this.Sockets = Sockets;
ThreadItem = new Extensions.ThreadGroup.ThreadItem(SOCKET_PROCESS_INTERVAL, GroupName, Process);//asta inseamna totusi minim ping 40 da dar daca se folosesc 10 milisecunde cat trece prin toate... face 40-10 si face sleep(30);
} public void Start() { ThreadItem.Open(); } public void Process() { try { //ok deci aici e thread... am 40 ms in caz ca se folosesc 5... face sleep 35...
_socket.Accept();
foreach (var _socket in Sockets)//sockets adica am .. 1 socket ptr acc server 1 socket ptr loader.. si 1 socket ptr game ... { try { if (_socket == null)//for inter server continue; } catch (Exception e) {
user.HandlerBuffer();
MyConsole.SaveException(e); } /* foreach (var user in _socket.Clients.GetValues()) { try { while (user.ReceiveBuffer()) { } }
if (user.HandlerBuffer())
catch { } }*/ // var array = _socket.Sockets.ToArray(); /* foreach (var user in array) { try { while (user.ReceiveBuffer()) {
catch (Exception e) { MyConsole.WriteLine(e.ToString()); }
{ } } user.HandlerBuffer(); user.TrySend(); } }*/ } }
}
catch (Exception e) { MyConsole.WriteLine(e.ToString()); } } public void Close() { ThreadItem.Close(); }
}

ادخل علي كلاس ThreadPoll.cs وبدله بـ
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Text; using Extensions;
using Extensions.Threading;
using Extensions.Threading.Generic; namespace Project_Terror_v2 {
public static void Execute(Action action, uint timeOut = 0, ThreadPriority priority = ThreadPriority.Normal)
public static class ThreadPoll { #region Funcs {
GenericThreadPool.Subscribe(new Extensions.Threading.LazyDelegate(action, timeOut, priority));
}
public static void Execute(Action action, T param, uint timeOut = 0, ThreadPriority priority = ThreadPriority.Normal)
{
GenericThreadPool.Subscribe(new Extensions.Threading.Generic.LazyDelegate(action, timeOut, priority), param);
}
public static IDisposable Subscribe(Action action, uint period = 1, ThreadPriority priority = ThreadPriority.Normal)
{ return GenericThreadPool.Subscribe(new Extensions.Threading.TimerRule(action, period, priority)); }
public static IDisposable Subscribe(Action action, T param, uint timeOut = 0, ThreadPriority priority = ThreadPriority.Normal)
{
return GenericThreadPool.Subscribe(new Extensions.Threading.Generic.TimerRule(action, timeOut, priority), param);
}
public static IDisposable Subscribe(Extensions.Threading.Generic.TimerRule rule, T param, Extensions.Threading.StaticPool pool)
{
return pool.Subscribe(rule, param);//BigBoSS not complete yet
}
public static IDisposable Subscribe(Extensions.Threading.Generic.TimerRule rule, T param)
{
return GenericThreadPool.Subscribe(rule, param);//here where i stopped . complete work ya mo2mn
} #endregion
public static TimerRule ConnectionReceive, ConnectionSend, ConnectionReview;
public static StaticPool GenericThreadPool;
public static StaticPool ReceivePool, SendPool;
public static void Create() { GenericThreadPool = new StaticPool(128).Run();
ConnectionReceive = new TimerRule(connectionReceive, 1);
ReceivePool = new StaticPool(128).Run(); SendPool = new StaticPool(128).Run();
ConnectionSend = new TimerRule(connectionSend, 1);
ConnectionReview = new TimerRule(_ConnectionReview, 300000, ThreadPriority.Lowest);
}
public static void connectionReceive(ServerSockets.SecuritySocket wrapper)
{ if (wrapper.ReceiveBuffer()) {
public static void connectionSend(ServerSockets.SecuritySocket wrapper)
wrapper.HandlerBuffer(); } } { }
wrapper.CheckUp();
public static void _ConnectionReview(ServerSockets.SecuritySocket wrapper) { } }
}

واخيرا تدخل علي كلاس ThreadPool.cs وتبدله بــ
using System;
using System.Collections.Generic;
using System.Linq;
using Extensions;
using System.Text;
namespace Project_Terror_v2
using System.Threading; {
public static void Execute(Action action, uint timeOut = 0, ThreadPriority priority = ThreadPriority.Normal)
public class ThreadPool { {
GenericThreadPool.Subscribe(new Extensions.Threading.LazyDelegate(action, timeOut, priority));
}
public static void Execute(Action action, T param, uint timeOut = 0, ThreadPriority priority = ThreadPriority.Normal)
{
GenericThreadPool.Subscribe(new Extensions.Threading.Generic.LazyDelegate(action, timeOut, priority), param);
}
public static IDisposable Subscribe(Action action, uint period = 1, ThreadPriority priority = ThreadPriority.Normal)
{ return GenericThreadPool.Subscribe(new Extensions.Threading.TimerRule(action, period, priority)); }
public static IDisposable Subscribe(Action action, T param, uint timeOut = 0, ThreadPriority priority = ThreadPriority.Normal)
{
return GenericThreadPool.Subscribe(new Extensions.Threading.Generic.TimerRule(action, timeOut, priority), param);
}
public static IDisposable Subscribe(Extensions.Threading.Generic.TimerRule rule, T param, Extensions.Threading.StaticPool pool)
{
return pool.Subscribe(rule, param);
}
public static IDisposable Subscribe(Extensions.Threading.Generic.TimerRule rule, T param)
{
return GenericThreadPool.Subscribe(rule, param);
}
public static Extensions.Threading.StaticPool GenericThreadPool;
public static Extensions.Threading.StaticPool ReceivePool, SendPool, CheckUpConnectionReview;
public static Extensions.Threading.Generic.TimerRule ConnectionReceive, ConnectionReview, ConnectionSend;
public static void CreatePools() {
GenericThreadPool = new Extensions.Threading.StaticPool(1).Run();
#if TEST
ReceivePool = new Extensions.Threading.StaticPool(1).Run();
SendPool = new Extensions.Threading.StaticPool(1).Run();
CheckUpConnectionReview = new Extensions.Threading.StaticPool(1).Run();
#else GenericThreadPool = new Extensions.Threading.StaticPool(16).Run();
CheckUpConnectionReview = new Extensions.Threading.StaticPool(3).Run();
ReceivePool = new Extensions.Threading.StaticPool(64).Run(); SendPool = new Extensions.Threading.StaticPool(32).Run(); #endif
ConnectionReview = new Extensions.Threading.Generic.TimerRule(connectionReview, 1000, ThreadPriority.Lowest);
ConnectionReceive = new Extensions.Threading.Generic.TimerRule(connectionReceive, 1, ThreadPriority.Highest);
ConnectionSend = new Extensions.Threading.Generic.TimerRule(connectionSend, 1, ThreadPriority.Highest);
Game.MsgMonster.PoolProcesor.CreatePools();
Client.PoolProcesor.CreatePools();
Role.GameMap.CreatePool(); }
{
private static void connectionReview(ServerSockets.SecuritySocket wrapper)
private static void connectionReceive(ServerSockets.SecuritySocket wrapper)
ServerSockets.SecuritySocket.TryReview(wrapper); } {
private static void connectionSend(ServerSockets.SecuritySocket wrapper)
ServerSockets.SecuritySocket.TryReceive(wrapper); } { ServerSockets.SecuritySocket.TrySend(wrapper);
MyConsole.Title = "Players Online : " + Database.Server.GamePoll.Count + " Queue Packets " + ServerSockets.PacketRecycle.Count;
} public static void ServerInfo() { } }
}

All CopyRight By Collins

لتحميل السورس ادخل هنــا
ليست هناك تعليقات
إرسال تعليق

إرسال تعليق

نموذج الاتصال
الاسمبريد إلكترونيرسالة