I've been wracking my brain over this glitch for too long, I'm willing to wire some of the money my private server has made to someone for a viable solution to this problem. (like 30 bucks)
I know its probably something SO simple I'm just missing it.
The source is tanels 5165 NewestCOServer source (no flaming).
The problem: When you open up multiple clients and type in the info and log them in at the EXACT same time, the server has no way to deal with it and logs in both (or as many as you try) at the same time.
Here is where it handles logging in to a character, and where it prevents logging a character again if it is ALREADY online:
I have tried making a LoginTimes int with LoginTimes++ every time you login and a check to see if you have more that one login.
I have tried thread sleeps to make one client login before another.
I have tried: if (Game.World.H_Chars.Contains(GC.MyChar.EntityID > 1))
No luck.
I'm all out of ideas. Any help would be greatly appreciated.
Thanks ahead of time.
I know its probably something SO simple I'm just missing it.
The source is tanels 5165 NewestCOServer source (no flaming).
The problem: When you open up multiple clients and type in the info and log them in at the EXACT same time, the server has no way to deal with it and logs in both (or as many as you try) at the same time.
Here is where it handles logging in to a character, and where it prevents logging a character again if it is ALREADY online:
Code:
if (PacketID == 1052)
{
try
{
ulong CryptoKey = BitConverter.ToUInt64(Data, 4);
AuthWorker.AuthInfo Info = (AuthWorker.AuthInfo)AuthWorker.KeyedClients[CryptoKey];
GC.AuthInfo = Info;
GC.MessageID = (uint)Rnd.Next(50000);
GC.Soc = StO.Sock;
if (GC.AuthInfo.LogonType == 3)
{
GC.AddSend(Packets.SystemMessage(GC.MessageID, "You have been banned!"));
}
if (GC.AuthInfo.LogonType == 2)
GC.AddSend(Packets.SystemMessage(GC.MessageID, "NEW_ROLE"));
else if (GC.AuthInfo.LogonType == 1)
{
string Acc = "";
GC.MyChar = Database.LoadCharacter(GC.AuthInfo.Character, ref Acc);
while (Game.World.H_Chars.Contains(GC.MyChar.EntityID))
{
GC.MyChar = Database.LoadCharacter(GC.AuthInfo.Character, ref Acc);
Game.Character Old = (Game.Character)Game.World.H_Chars[GC.MyChar.EntityID];
Old.MyClient.Disconnect();
Program.WriteLine(" " + GC.MyChar.Name + " was kicked off a different client.");
new System.Threading.Thread(new ThreadStart(
delegate()
{
System.Threading.Thread.Sleep(200);
Game.World.H_Chars.Remove(Old.EntityID);
System.Threading.Thread.Sleep(200);
GC.LocalMessage(2000, "This account has been logged in from different client! You are advised to change you password immediately!");
}
)).Start();
}
GC.MyChar.MyClient = GC;
GC.MyChar.AccountName = Acc;
GC.AddSend(Packets.SystemMessage(GC.MessageID, "ANSWER_OK"));
GC.AddSend(Packets.CharacterInfo(GC.MyChar));
GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.VIPLevel, GC.MyChar.VipLevel));
GC.AddSend(Packets.Time());
GC.AddSend(Packets.Donators(GC.MyChar));
GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.Effect, 0));
Program.WriteLine(" " + GC.MyChar.Name + " has logged on.");
foreach (Character C in World.H_Chars.Values)
{
if (Game.World.H_Chars.Contains(GC.MyChar.EntityID > 1))
{
GC.Disconnect();
}
}
}
GC.EndSend();
}
catch { }
}
else PacketHandler.Handle(GC, Data);
}
}
else
{
GC.Crypto.Decrypt(Data);
PacketHandler.Handle(GC, Data);
}
}
catch (Exception Exc) { Program.WriteLine(Exc); }
}
I have tried thread sleeps to make one client login before another.
I have tried: if (Game.World.H_Chars.Contains(GC.MyChar.EntityID > 1))
No luck.
I'm all out of ideas. Any help would be greatly appreciated.
Thanks ahead of time.