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!

[C#/ASP .NET/DotNet Core] Project Aurora Pro [v7/R38]

Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
I agree, I'll keep continuing this as I definitely enjoy it.

VJatqcI - [C#/ASP .NET/DotNet Core] Project Aurora Pro [v7/R38] - RaGEZONE Forums

iFnw6Nv - [C#/ASP .NET/DotNet Core] Project Aurora Pro [v7/R38] - RaGEZONE Forums

OdjsLOq - [C#/ASP .NET/DotNet Core] Project Aurora Pro [v7/R38] - RaGEZONE Forums

HxW2uH1 - [C#/ASP .NET/DotNet Core] Project Aurora Pro [v7/R38] - RaGEZONE Forums


A few updates. It doesn't look spectacular, but in theory the navigator node packet took me hours to figure out as it works slightly different than v9 would. For people who are interested, I played around in Ion trying to get it working and I documented my foundings on the packet, this is 100% my discovery (with thanks to the people who made it possible for me to look into the Lingo scripts):

The "my rooms" section is as easy as v9 but still a nice thing. All data is fetched from the database and thus not static placeholder data. My plan for today is to get room entry working - both public rooms and private rooms - and maybe a start on walking and talking.

Also due to how extremely "buggy" EF Core is (EF Core won't work with async method and I had to make everything sync in order for it to work properly, don't take buggy too serious but this is definitely something that annoyed me), I decided to switch back to Fluent NHibernate. This doesn't mean getting data is harder, it only means database seeding is a bit... different.

Basically, I got an interface which is the contract for the seeder classes:

PHP:
public interface IDataSeeder
    {
        IEnumerable<object> Data { get; }

        void Seed();
    }

(I still have to port this to C# 8.0 since C# 8.0 allows default implementation in interfaces)

This is an example of a DataSeeder class:

PHP:
public class RoleDataSeeder : IDataSeeder
    {
        public IEnumerable<object> Data => new[]
        {
            new Role() {Id = 1, Name = "Player"},
        };

        private readonly DbSessionFactory _dbSessionFactory;

        public RoleDataSeeder(DbSessionFactory dbSessionFactory)
        {
            _dbSessionFactory = dbSessionFactory;
        }

        public void Seed()
        {
            var session = _dbSessionFactory.OpenSession();

            if (!session.Query<Role>().IsEmpty()) return;
            
            foreach (var obj in Data)
            {
                session.Save(obj);
            }
        }
    }

When starting the server, after NHibernate is configured (and the database is created/updated if necessary), it executes the following code:

PHP:
foreach (var service in _serviceProvider.GetServices<IDataSeeder>())
            {
                service.Seed();
            }

For every implementation of IDataSeeder it'll call the Seed function (and execute whatever code is in it). There are no migrations, but NHibernate will keep the database up to date with the code, meaning whenever a new column is added, it'll automatically add it on boot. Boot time will be a bit longer but it shouldn't be too bad.
 

Attachments

You must be registered for see attachments list
Joined
Jun 23, 2010
Messages
2,318
Reaction score
2,195
Also due to how extremely "buggy" EF Core is (EF Core won't work with async method and I had to make everything sync in order for it to work properly, don't take buggy too serious but this is definitely something that annoyed me), I decided to switch back to Fluent NHibernate. This doesn't mean getting data is harder, it only means database seeding is a bit... different.

(...)

For every implementation of IDataSeeder it'll call the Seed function (and execute whatever code is in it). There are no migrations, but NHibernate will keep the database up to date with the code, meaning whenever a new column is added, it'll automatically add it on boot. Boot time will be a bit longer but it shouldn't be too bad.

I find it strange to believe EF Core is buggy. And when you said you can't make the async methods to work, I think it's a problem on your side of the code. Like I said before, async all the way. You can't call a async method in a sync one. It can cause strange side effects and even deadlocks doing so. When doing it right it should work just like the sync methods.

I also suggest you use some sort of migration tool. Again EF Core has this build in, and I do not know about Hibernation. A big downside, depending on how Hibernate choses how to do so, is that it can wipe or fuckup your database. At first, and while developing on your own, it might be fine. But remember the long terms. Pushing a update will be, just, bad.

Edit: Some questions:
1. Why do you want to use default implementations for that? I don't see how a default implementation would be beneficial.
2. Why is the property Data in your interface? Seems, as far as I can see, that Seed() is enough.
 
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
I find it strange to believe EF Core is buggy. And when you said you can't make the async methods to work, I think it's a problem on your side of the code. Like I said before, async all the way. You can't call a async method in a sync one. It can cause strange side effects and even deadlocks doing so. When doing it right it should work just like the sync methods.

I also suggest you use some sort of migration tool. Again EF Core has this build in, and I do not know about Hibernation. A big downside, depending on how Hibernate choses how to do so, is that it can wipe or fuckup your database. At first, and while developing on your own, it might be fine. But remember the long terms. Pushing a update will be, just, bad.

Edit: Some questions:
1. Why do you want to use default implementations for that? I don't see how a default implementation would be beneficial.
2. Why is the property Data in your interface? Seems, as far as I can see, that Seed() is enough.

As a matter of fact, I did have everything on async (excluding COMPOSER.Compose functions which basically only return a ServerMessage object). IIRC I did read about EF Core not working well with it and several problems relating to it on the internet. It started giving errors on the NAVIGATE packet IIRC for some reason. I could try it again and post the original error but I'm pretty sure it didn't work well.

I'm not sure if there's something to use but I would say there is so I'll look into the migrations thing. I agree that migrations is the way to go (as most frameworks like that uses migrations).

1. I don't know either forget I said it I wasn't thinking straight (I don't even know why I said it)
2. I think more of a leftover from how I wanted to do it first; use a base class where the seed function and DI would be done and you could override the data in the classes and the Seed function would've been always the same (less of the same code). Though I changed it (probably because I had some issues with it, not sure) and I didn't think of removing the data. I agree it isn't necessary though.
 
Developer
Developer
Joined
Dec 11, 2010
Messages
2,955
Reaction score
2,685
Fair warning, not sure if you know but the mod tool is completely borked in the R38 beta Flash client. The tool will display, but the button to view room chat logs doesn't send any request to the server. You could possibly patch it in the AS3 (if Sulake accidentally broke it) I haven't investigated that far however.
 
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
Fair warning, not sure if you know but the mod tool is completely borked in the R38 beta Flash client. The tool will display, but the button to view room chat logs doesn't send any request to the server. You could possibly patch it in the AS3 (if Sulake accidentally broke it) I haven't investigated that far however.

Not sure, I'm not sure if I've tried it before, but you could be right. I however don't want to make it priority for a while though. First I've to get better and then I can finish room entry and move on to some other stuff. Technically room logs aren't too important for a while. Thanks for the heads up though.
 
Joined
Oct 26, 2012
Messages
2,357
Reaction score
1,086
Added room entry including walls which weren't so default in v7 (walls/stairs defined as world objects):

8zusFos - [C#/ASP .NET/DotNet Core] Project Aurora Pro [v7/R38] - RaGEZONE Forums


Big thanks to Blunk for the world object sprite definition example and names.

PHP:
public class OBJECTS
    {
        public static ServerMessage Compose(IEnumerable<WorldObject> worldObjects)
        {
            var composer = new ServerMessage(Outgoing.OBJECTS);
            
            foreach (var worldObject in worldObjects)
            {
                composer.AppendArgument(worldObject.Id.ToString(), ' ', true);
                composer.AppendArgument(worldObject.Definition.Name, ' ', true);
                composer.AppendArgument(worldObject.X.ToString(), ' ', true);
                composer.AppendArgument(worldObject.Y.ToString(), ' ', true);
                composer.AppendArgument(worldObject.Z.ToString(), ' ', true);
                composer.AppendNewArgument(worldObject.Rotation.ToString(), true);
            }

            return composer;
        }
    }

Yo9Y11o - [C#/ASP .NET/DotNet Core] Project Aurora Pro [v7/R38] - RaGEZONE Forums

1gETWUD - [C#/ASP .NET/DotNet Core] Project Aurora Pro [v7/R38] - RaGEZONE Forums
 

Attachments

You must be registered for see attachments list
Back
Top