Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Development] [C#] RajanMS v111

Status
Not open for further replies.
Experienced Elementalist
Joined
Feb 10, 2008
Messages
249
Reaction score
161
hi all and welcome to my RajanMS dev thread!

intro
hi im rajan im 16 years old and i've been learning c# for about a year now. being a huge maple fan i've decided to test my skills by creating this server. its a AIO server like delphims, i started interoperability shits (check git commit 1-3 (i think ) ) but never followed through with it because its just a pain in the butt. im hoping to finish the game server and start on shop by the end of the summer!

features
-flexible worlds & channels, able to pick and choose how many you like (up to 340 channel servers (if you really want to....) )

goals
-scriptable NPC's using IronPython
-homes for players (instantiate maps)
-special potions (damage & kill mobs, teleport to boss maps)

setting it up
though i am updating my code as often as i can, feel free to try out the source.

1) download c# mongo drivers here
2)install mongo and run mongod
3)create a server.ini file where the executeable is, you can find my settings in Tools.Program.cs
4)run moople
5)??????
6)profit?!1

*note* in LoginHandler.MigrateClient i write the old GMS login ip because i set my loopback to that ip. its so i can connect to my server as host.

screenies
Darter - [Development] [C#] RajanMS v111 - RaGEZONE Forums

Darter - [Development] [C#] RajanMS v111 - RaGEZONE Forums

Update log
Commit 9
-Fixed some bugs (clients not closed on shutdown, accounts not set to loggedoff)-Improved all database queries
-Login sanitary checks
-Started using more extensions
-Inventory will be added next commit

Commit 8
-Fixed silly migration collection iteration error (updated quick so people could use)
Commit 7
!!!! MY CONFIG FILE CAN BE FOUND IN Tools.Program.cs !!!!!
-Tweaked packet processor
-Added register account form
-Added migration system
-Renamed opcodes (names from v95 client)
-Sanitized login handlers

Commit 6
-added most login handlers
-added database components, mongoDB is treating me well

you can view the source at any time at
 
Last edited:
Experienced Elementalist
Joined
Jul 19, 2011
Messages
288
Reaction score
32
Interesting, Good luck, looks promising. Hopefully it won't die like 50% of the developments here.
I think using a little command line program for the server launching instead of the form will use less resources.
If not, then go ahead o-o
Heres some ideas:
Maybe have an auto-restart built in with a little server message (with countdown) saying its gonna restart. Maybe a little textbox and button making server messages.

I sort of suggest a little built-in webpanel (via C#) that allows restarts from trusted GMs which may also lead to exploits/bad things.
 
Joined
Jan 11, 2013
Messages
589
Reaction score
82
Nice ;), i was hoping to also accomplish this, but with C++. Hopefully in a yr i can start developing, although probably will be sloppy.
 
Junior Spellweaver
Joined
Apr 20, 2013
Messages
103
Reaction score
24
I have a few question I was wondering about;
  1. Why v111?
  2. Why MongoDB? Never heard of it and neither could find a reason why to preffer it over MySQL or MSSQL
  3. Why IronPython and not just stick to C# for everything?

Dont get me wrong, I would just like to know your reasoning behind all of it :laugh:
 
Experienced Elementalist
Joined
Feb 10, 2008
Messages
249
Reaction score
161
I have a few question I was wondering about;
  1. Why v111?
  2. Why MongoDB? Never heard of it and neither could find a reason why to preffer it over MySQL or MSSQL
  3. Why IronPython and not just stick to C# for everything?

Dont get me wrong, I would just like to know your reasoning behind all of it :laugh:

1) I chose v111 because they're many sources available to reference. I don't have much knowledge of what's changed with receive packets over the time. I've maintained my custom GMS client from v11x to v135, other than that I really don't know. Also from what I've heard updating from v111 to v117 isn't much of a challenge anyways

2) MongoDB is just really really easy to use and saves so much time, quick ex

my account class
Code:
using MongoDB.Bson;


namespace RajanMS.Game
{
    public sealed class Account
    {
        public ObjectId Id { get; set; }


        public int AccountId { get; set; }


        public string Username { get; set; }
        public string Password { get; set; }
        public string PIC { get; set; }


        public string LastIP { get; set; }


        public byte Gender { get; set; }


        public bool LoggedIn { get; set; }
        public bool GM { get; set; }


        public bool Banned { get; set; }
        public string BanReason  { get; set; }
    }
}

when querying for my desired account it returns a whole account object! very flexible

Code:
        public Account GetAccount(int id)
        {
            var collection = m_database.GetCollection<Account>("accounts");
            var query = new QueryDocument("AccountId", id);
            return collection.Find(query).ElementAtOrDefault(0);
        }

3) i know things like ScriptDotNet exist and such but i don't want to have to compile NPC scripts every time. I want to be able to re-cache them without restarting the server. I want my NPC's to have more of a scripting feel than a hardcode (if that makes any sense lol)

Interesting, Good luck, looks promising. Hopefully it won't die like 50% of the developments here.
I think using a little command line program for the server launching instead of the form will use less resources.
If not, then go ahead o-o
Heres some ideas:
Maybe have an auto-restart built in with a little server message (with countdown) saying its gonna restart. Maybe a little textbox and button making server messages.

I sort of suggest a little built-in webpanel (via C#) that allows restarts from trusted GMs which may also lead to exploits/bad things.

mmm not to worried with forms resources. i took your restart idea and im going to implement it soon after i finish warp_to_map. i added a stop server button aswell. and as far as the webpanel goes, i dont really want to use websockets, the idea seems cool but in the end its really weird. ill make it restart via ingame commands and ill code a custom client to go in and do it for me!
 
Junior Spellweaver
Joined
Apr 20, 2013
Messages
103
Reaction score
24
I am a little worried about the speed and load of MongoDB, does not rly seem like one of the things to use for high-end server software.
And the thing I do with npcs, is to compile them at the runtime and then load it into the memory, thus allowing them to be reloading without any side effects
 
Custom Title Activated
Loyal Member
Joined
Nov 14, 2008
Messages
1,025
Reaction score
641
i know things like ScriptDotNet exist and such but i don't want to have to compile NPC scripts every time. I want to be able to re-cache them without restarting the server.

You can actually use C# as a scripting language. I'm doing this for PokeSharp and basically, you can recompile C# code at runtime using the CSharpCodeProvider. If the code compiles with no error, you can cache the resulting assembly and then invoke methods from there. You just need to have your scripts implement an IScript interface. It's also very fast, and matter of fact, probably just as fast as regular C# code, since your compiled assembly script is pretty much compiled C# code just like your whole game server. (Don't quote me on that though)

I'm gonna send you the two classes (CSScript.cs and IScript.cs) and perhaps you can see how to implement them for your game server.
 
Joined
Apr 10, 2008
Messages
4,087
Reaction score
1,265
Also, to anyone trying to run it, you will need MongoDB and a refference to it's DLLs.

1. Download
2. Run it and install it.
3. In Visual Studio, Project -> Add Refernce.. -> Browse.
4. Navigate to the 2 DLLs in C:\Program Files (x86)\MongoDB\CSharp Driver 1.8.1, choose them both.
5. Save.

Oh and... to run this you will also need the config file. Reading the source, should be a basic one like this:

Code:
[Server]
Worlds=NUM_WORLDS
Channels=NUM_CHANNELS

Save it as "server.ini" and place in the Debug folder. Set 1 and 1 for default (Scania with 1 channel).
Good luck~
 
Last edited:
Newbie Spellweaver
Joined
Jul 1, 2013
Messages
30
Reaction score
6
@Darter
its me sora good luck buddy, looks pretty nice ^_^

hopefully you don't abandon the project
 
Experienced Elementalist
Joined
Feb 10, 2008
Messages
249
Reaction score
161
@Minike i've had no problems with it for now, ive been thinking of storing the whole inventory as dictionary in the db, ill tell you how it goes
@Fraysa thanks for the little setup guide! the great thing about mongodb is that if the db or collection doesnt exist, it creates it!
@quic lol thanks, rip duckies


also inventory in the login server isnt coded yet, sorry for misleading
 
Initiate Mage
Joined
Jun 15, 2013
Messages
4
Reaction score
0
hey darter, mind adding me on skype: Fantasticgamin thanxs mate!
 
Experienced Elementalist
Joined
Jul 19, 2011
Messages
288
Reaction score
32
@Minike i've had no problems with it for now, ive been thinking of storing the whole inventory as dictionary in the db, ill tell you how it goes
@Fraysa thanks for the little setup guide! the great thing about mongodb is that if the db or collection doesnt exist, it creates it!
@quic lol thanks, rip duckies


also inventory in the login server isnt coded yet, sorry for misleading

Maybe have a little selection in the future to use MySQL / MongoDB?

I've been checking out the source to see how C# is, and I'm getting them headaches
 
Custom Title Activated
Loyal Member
Joined
Nov 27, 2009
Messages
1,905
Reaction score
948
i store inventory items by creating a dictionary with the size of the inventory max slots, leaving empty slots with null value. it's pretty gay but this is c# so it's ok right
also i would recommend that you use NHibernate for database management layer, it's a lot cleaner than manually doing MySQL queries, and you can jump to MSSQL with it too.

oh and
anyone who puts a GUI on a server is 420% homosexual
 
Experienced Elementalist
Joined
Feb 10, 2008
Messages
249
Reaction score
161
hey darter, mind adding me on skype: Fantasticgamin thanxs mate!


pm me if you'd like to talk


Maybe have a little selection in the future to use MySQL / MongoDB?


I've been checking out the source to see how C# is, and I'm getting them headaches


i dont ever wanna touch mysql but if anyone wants to change it up, all you need to edit is the database class


i store inventory items by creating a dictionary with the size of the inventory max slots, leaving empty slots with null value. it's pretty gay but this is c# so it's ok right
also i would recommend that you use NHibernate for database management layer, it's a lot cleaner than manually doing MySQL queries, and you can jump to MSSQL with it too.


oh and
anyone who puts a GUI on a server is 420% homosexual


yeah i been peeking at the dwa thing you uploaded and removed in the span of 4 mins, its inventory is pretty clean but not a fan of how you index it with just a number and not a enum like "MapleInventoryType", confusing for nibs (me)
for now character class has a Dictionary<InventoryType,Inventory> and the Inventory class is just KeyedCollection with slot property ( )
 
Newbie Spellweaver
Joined
Jun 30, 2011
Messages
17
Reaction score
1
for now character class has a Dictionary<InventoryType,Inventory> and the Inventory class is just KeyedCollection with slot property ( )
Why not use an array?
 
Joined
Apr 5, 2008
Messages
663
Reaction score
537
Because Dictionaries have a much higher speed?
Ahahhhahha, what?
An array is a constant lookup, often optimized down to a couple instructions.
Meanwhile accessing an element from a dictionary is at best constant lookup through the use of a usually expensive hash function, or worse the dictionary is using a binary tree and a logarithmic lookup must be done.
When accessing an element by its index, an array will always be faster than a dictionary.
 
Junior Spellweaver
Joined
Apr 20, 2013
Messages
103
Reaction score
24
Ahahhhahha, what?
An array is a constant lookup, often optimized down to a couple instructions.
Meanwhile accessing an element from a dictionary is at best constant lookup through the use of a usually expensive hash function, or worse the dictionary is using a binary tree and a logarithmic lookup must be done.
When accessing an element by its index, an array will always be faster than a dictionary.

Asuming you know the index of the array, yes
Anyways this is offtopic and doesnt rly matter
 
Status
Not open for further replies.
Back
Top