Why does this not create my character?

01/06/2016 05:17 denominator#1
Why does this not create my character? Pretty sure it used to work :( It's failing here somewhere it doesn't actually create it?

Code:
            while (true)
            {
                try
                {
                    using (var cmd = new MySqlCommand(MySqlCommandType.INSERT))
                        cmd.Insert("entities").Insert("Name", eC.Name).Insert("Owner", client.Account.Username).Insert("Class", eC.Class).Insert("UID", client.Entity.UID)
                            .Insert("Hitpoints", client.Entity.Hitpoints).Insert("Mana", client.Entity.Mana).Insert("Body", client.Entity.Body)
                            .Insert("Face", client.Entity.Face).Insert("HairStyle", client.Entity.HairStyle).Insert("Strength", client.Entity.Strength)
                            .Insert("WarehousePW", "").Insert("Agility", client.Entity.Agility).Insert("Vitality", client.Entity.Vitality).Insert("Spirit", client.Entity.Spirit)
                            .Execute();
                    Database.MySqlCommand com = new Database.MySqlCommand(MySqlCommandType.INSERT);
                    com.Insert("achievement").Insert("UID", (long)client.Entity.UID).Insert("Owner", client.Account.Username).Insert("Name", client.Entity.Name);
                    message = "ANSWER_OK";
                    break;
                }
                catch
                {
                    client.Entity.UID = Program.EntityUID.Next;
                }
            }

            using (var cmd = new MySqlCommand(MySqlCommandType.UPDATE).Update("configuration").Set("EntityID", client.Entity.UID).Where("Server", Constants.ServerName))
                cmd.Execute();
            client.Account.EntityID = client.Entity.UID;
            client.Account.Save();
            return true;
        }
01/06/2016 06:36 Spirited#2
You effectively wrote both a brute-force algorithm on your database and a race condition when writing to the configuration table. Congrats. This code is massively shit. Will it effect your server's performance, probably not... but you should consider not being shit and sticking to better programming practices. You won't always be this lucky. If you don't understand the problems I mentioned, then you should before you continue programming a server; else, you're going to cause some very bad problems with your server.
01/06/2016 06:50 denominator#3
Not actually my code >.< It's what was in the source.
01/06/2016 07:36 Spirited#4
Quote:
Originally Posted by denominator View Post
Not actually my code >.< It's what was in the source.
How terrifying. Thank god I don't involve myself with those sources. Have you tried debugging it using breakpoints? You can always use a not shit source as well.
01/06/2016 08:36 turk55#5
Why the hell is there a while loop if you want to create a single character.
01/06/2016 09:14 Spirited#6
Quote:
Originally Posted by turk55 View Post
Why the hell is there a while loop if you want to create a single character.
They apparently use brute-force logic to burn through character IDs and query the MySQL server to find the next character ID (instead of allowing MySQL to handle unique key allocation in a thread-safe manor). They then try to save the ID back to the database which can cause a race condition. It really makes me sick reading this tripe.
01/06/2016 17:47 denominator#7
You will be pleased to know that I have deleted the source lol

Quote:
You can always use a not shit source as well.
They are prehistoric >.< I am wondering are there any 6100+ sources out there?
01/06/2016 20:42 turk55#8
Quote:
Originally Posted by denominator View Post
You will be pleased to know that I have deleted the source lol

They are prehistoric >.< I am wondering are there any 6100+ sources out there?
You could grab a public source and upgrade yourself.

Throne should work with patches on and above 6090.
I know that the author also said that the source isn't recommended to use for running a server but you could however use it as reference for packets etc.
01/06/2016 21:57 denominator#9
Yeah I have throne but the loader will not load the client up to it
01/06/2016 21:59 Spirited#10
Absolutely. I have a few members on my board that I'm privately advising doing just that. They're using Redux, but there are many you can chose from. Upgrading a source isn't easy though if you have no programming experience... so I'm not sure how comfortable you'd be doing that (as I don't know your experience in programming). It's not a challenging task, but it will take some dedication (which will be rewarded, of course, when your server isn't a heaping pile of software).
01/06/2016 22:04 denominator#11
I was using ncos 5165 at one stage but lost it due to a hard drive issue, it was fun at the time, recently suffered a stroke so most of what I had learnt is now non existent
01/07/2016 01:03 Spirited#12
Quote:
Originally Posted by denominator View Post
I was using ncos 5165 at one stage but lost it due to a hard drive issue, it was fun at the time, recently suffered a stroke so most of what I had learnt is now non existent
Sorry to hear that. You may want to look into Redux, then. From what I've seen, it's relatively easy to understand. You can also look at Phoenix, since that's documented. The server model in Phoenix is bad, though. I still recommend Chris's Redux source for a good, moderately complete source. It's definitely better organized than most sources I've seen. You can keep at the patch it's at until you feel more comfortable with modifying the source. Then, you can upgrade / downgrade the source as you wish. It's up to you, of course. If you don't think this is worth your time, then you can always use a shitty server. Just don't expect to see it work ideally (as you've seen from this thread), and don't expect to be able to maintain those types of sources without programming experience of some type.
01/07/2016 01:23 denominator#13
I'll look into redux see if I like it, I'm looking for something for personal use so bugs are not a problem because there will only be me using it, as I thought redux is like all the others based on a primitve client. Thanks but no thanks