[Proposal] Auto-Registering DataTable Object in GSS

Discussions on various DOL development features

Moderator: Support Team

[Proposal] Auto-Registering DataTable Object in GSS

Postby Leodagan » Fri Aug 29, 2014 5:35 am

Hello

I made this kind of update when working around a new keep manager :
Code: Select all
Index: GameServer.cs =================================================================== --- GameServer.cs (revision 3336) +++ GameServer.cs (working copy) @@ -858,6 +858,45 @@ try { //--------------------------------------------------------------- + //Register Script Tables + if (log.IsInfoEnabled) + log.Info("GameServerScripts Tables Initializing..."); + + try + { + // Walk through each assembly in scripts + foreach (Assembly asm in ScriptMgr.Scripts) + { + // Walk through each type in the assembly + foreach (Type type in asm.GetTypes()) + { + if (type.IsClass != true || !typeof(DataObject).IsAssignableFrom(type)) + continue; + + object[] attrib = type.GetCustomAttributes(typeof(DataTable), false); + if (attrib.Length > 0) + { + if (log.IsInfoEnabled) + log.Info("Registering Scripts table: " + type.FullName); + + GameServer.Database.RegisterDataObject(type); + } + } + } + } + catch (DatabaseException dbex) + { + if (log.IsErrorEnabled) + log.Error("Error while registering Script Tables", dbex); + + return false; + } + + if (log.IsInfoEnabled) + log.Info("GameServerScripts Database Tables Initialization: true"); + + + //--------------------------------------------------------------- //Create the server rules m_serverRules = ScriptMgr.CreateServerRules(Configuration.ServerType); m_serverRules.Initialize();
It's a "Second Round" of DataObject Registering, it only walk through GameServerScripts and Assembly handled by ScriptMgr, and auto create/update tables.

This should start registering missed tables from compiled assemblies before we send the "ScriptLoadedEvent" to these scripts, so during these event all database and table should be "available".

This will allow to remove ALL manual : GameServer.Database.RegisterDataObject()

Any comments ? :)
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon

Re: [Proposal] Auto-Registering DataTable Object in GSS

Postby Leodagan » Fri Aug 29, 2014 6:15 am

I committed this to DOL SVN : 3337 and Storm SVN : 1363

I need to make atomic commit to allow reverting, I still have a lot of work to get going around Darwin/Eden Merge and need to move on other topics :D
User avatar
Leodagan
Developer
 
Posts: 1350
Joined: Tue May 01, 2012 9:30 am
Website: https://daoc.freyad.net
Location: Lyon


Return to “%s” DOL Development Discussion

Who is online

Users browsing this forum: No registered users and 1 guest