- Joined
- Feb 19, 2008
- Messages
- 1,055
- Reaction score
- 492
Keep going, there's no shame in doing niche projects.
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!public interface IDataSeeder
{
IEnumerable<object> Data { get; }
void Seed();
}
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);
}
}
}
foreach (var service in _serviceProvider.GetServices<IDataSeeder>())
{
service.Seed();
}
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.
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.
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;
}
}
I miss oldskool. I guess there is no way to play it on chrome / firefox?
Small update cause it's hot and cause work:
Public rooms work and items too