Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 20:43

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Offering a reward for double-login fix [5165]

Discussion on Offering a reward for double-login fix [5165] within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
~Templar~'s Avatar
 
elite*gold: 0
Join Date: Jul 2005
Posts: 28
Received Thanks: 8
Offering a reward for double-login fix [5165]

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:
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 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.
~Templar~ is offline  
Old 01/17/2014, 00:36   #2
 
elite*gold: 0
Join Date: Jan 2014
Posts: 23
Received Thanks: 2

lock the list of online accounts

other could correct me if im wrong, 2 clients with 2 connections invokes the same method subscribed in the socket event at the same time, each of them pass the check before the list is updated which cause this exploit
so to solve it you could lock the list of online accounts so the second connection should wait until the first lock is released which will guarantee that the list is updated and the check will disconnect the first account

please someone correct me if i am wrong, good luck and next time look at better source before you give away money
asdfghjklwertyuiopzxcvbnm is offline  
Old 01/17/2014, 01:25   #3
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,211
Received Thanks: 4,114
I'm pretty sure I released a fix for this a while back when I worked on this source. Looking back, the best thing to do would be to replace that collection with a ConcurrentDictionary. A concurrent dictionary has the "TryAdd" method, where it checks if the dictionary already contains the key, and if it does not, it adds the object to the collection and returns true.
Spirited is offline  
Old 01/17/2014, 04:21   #4
 
~Templar~'s Avatar
 
elite*gold: 0
Join Date: Jul 2005
Posts: 28
Received Thanks: 8
I figured this was another simple fix but the methods of fixing it seems rather complicated.
I was hoping someone would have a fixed line of code laying around somewhere. :S

I have checked how other sources deal with packet 1052 and the one's I have looked at deal with the entire packet in just a few lines and are done with it and I see nothing involving checks for multiple logging.

I will look into both of those solutions. They sound simple in theory but putting them into practice might be above my skill level...
~Templar~ is offline  
Old 01/17/2014, 06:33   #5
 
elite*gold: 0
Join Date: Jan 2014
Posts: 23
Received Thanks: 2
just first make sure you add logged in chars to the H_Chars (couldn't find that at snippit)

and i guess their is a syntax/logical error right their
at
if (Game.World.H_Chars.Contains(GC.MyChar.EntityID > 1))

it should rather be
if (Game.World.H_Chars.Contains(GC.MyChar.EntityID) > 1)

as for right now you are invoking the list contains method with bool value of (GC.MyChar.EntityID > 1) where infact you want to compare the return value with 1

but yeah go for what fang said it's an easy fix, you will only replace the list with ConcurrentDictionary(uint, Game.Character) or something like that, and replace all add/remove methods with tryadd and tryremove, couple of checks on the returned value and you are good to go
asdfghjklwertyuiopzxcvbnm is offline  
Old 01/17/2014, 07:10   #6
 
~Templar~'s Avatar
 
elite*gold: 0
Join Date: Jul 2005
Posts: 28
Received Thanks: 8
I dropped the whole
if (Game.World.H_Chars.Contains(GC.MyChar.EntityID > 1))
thing, I forgot that was in there.

I actually found an easy fix different than any of the suggested ones by recording the name of the last player to login with
public static string LastLogin;
and checking to see if LastLogin matches the character trying to login
if (LastLogin != GC.MyChar.Name)
allow login
else throw message

after some time LastLogin goes back to null.

This essentially puts a delay time on logging in the same character.

And now it works! Thanks for the advice!
~Templar~ is offline  
Old 01/17/2014, 12:33   #7
 
elite*gold: 0
Join Date: Feb 2006
Posts: 726
Received Thanks: 271
Quote:
Originally Posted by ~Templar~ View Post
I dropped the whole
if (Game.World.H_Chars.Contains(GC.MyChar.EntityID > 1))
thing, I forgot that was in there.

I actually found an easy fix different than any of the suggested ones by recording the name of the last player to login with
public static string LastLogin;
and checking to see if LastLogin matches the character trying to login
if (LastLogin != GC.MyChar.Name)
allow login
else throw message

after some time LastLogin goes back to null.

This essentially puts a delay time on logging in the same character.

And now it works! Thanks for the advice!
What if a third person is attempting to login at the same time as the other person with 2 characters? And it ends up like this:

Player 1 First Char Login
Player 2 Login
Player 1 Second Char Login

All within ms of each other, then your check would likely fail
Aceking is offline  
Old 01/17/2014, 12:51   #8
 
elite*gold: 0
Join Date: May 2011
Posts: 648
Received Thanks: 413
30$?

Easy money. Skype me I need more pizza and coke!
Y u k i is offline  
Old 01/17/2014, 19:22   #9
 
Spirited's Avatar
 
elite*gold: 12
Join Date: Jul 2011
Posts: 8,211
Received Thanks: 4,114
$30 is way too much for something like this. I'll do it for free. Here you are.


Cleaned. No more whining from certain members. I'm quite done with it. Nobody here is privileged. You all follow the same rules, no exceptions. Now, let's get back on topic, yes?
Spirited is offline  
Thanks
2 Users
Reply


Similar Threads Similar Threads
5165 Login Freeze
01/21/2011 - CO2 Private Server - 15 Replies
I'm using a 5165 source on Windows 7 and I set everything up right and got the Console running thanks to Korvacs guide, but when I try to log in the client freezes at "Logging into the game server..." Any reasons why this might happen?
Domain name offering ($50 Reward)
10/05/2010 - Off Topic - 11 Replies
Hello all, i am looking for a domain name. The person offering that name i like he/she will get $50 reward from me. Payment will be send via paypal or moneybookers. Rules : 1. Name extension must be com. (org, net and others will not be accepted) 2. Name must be a global name and should cover all games like elitepvpers... 3. Name must be short and meaningful. Thats all, sorry for my bad english.
5165 Login Bug.
07/30/2010 - CO2 Private Server - 5 Replies
alright so I got a new dumbass bug...in my source when I make a new acc and try to login it gives me "Error! disconnected from gameserver, please re-login later!"...and in da console it gives me dis: SystemArguementException: Item has already been added. key in dictionary "0" Key being added "0" at ...\Database.cs line 1331 in da LoadCharacter void...and all I have there is dis C.Skills.Add(S.ID, S); and I really dont get wat it's tryin to tel me here...call me a nub or noob but I...
Double pvp daily honor reward
03/11/2008 - WoW Exploits, Hacks, Tools & Macros - 5 Replies
Here we go; I personally use this exploit to gain my daily 800 honor point, so all you have to do is to take your Daily Pvp Quest,complete it and then rejoin the same BG of the daily quest. At this point when you join for the second time the bg you start it with the 400 point of the quest plus 400 point for an unfixed bug. For example: the daily pvp quest is to win alterac valley however, i will do the quest and then join arathi .......-after 5 minutes-.... Nice one, av won at the first...
[Warsong]Double Reward
10/04/2005 - WoW Exploits, Hacks, Tools & Macros - 17 Replies
If you cast a spell which has channeling bar, shortly before the last flag is capped (so the spell ends at the end of the battle ground) you get 2 rewards items (which can be given to the NPC outside für 2500XP). Its basicly the same exploit old exploit to get double bonus honor, which was fixed... at least the double honor but not the rewarditems. for non-casting classes like warriors: you can still use this exploit, but it gets harder to time and not always possible. If you loot an...



All times are GMT +2. The time now is 20:43.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.