Jump to content

Recommended Posts

Posted

MadJack it wont work :).

The problem on unix is that scripts are compiled as shared library and mangos is linked against them.

Which means that the scripts library cant be unloaded and cant be loaded ,its added to mangos at mangos startup ( NOT at the call to dlopen() ) and cant be unloaded.

Basicly if you want unload on linux you need to build mangos as libtool module.

  • 38 years later...
Posted

Please bear with me as I haven't programmed in years... Yes... Years (~10).

Anyway. I find it quite annoying to have to rename my MaNGOSScript.dll each and every time I build a new version of SD2 etc, so I made a little mod that will look up a new entry in the mangosd.conf called AltLib and will try to load the .dll/.so attached to that tag.

I'm thinking this could be very useful for other mods/DBs/scripting used with MaNGOS.

It's actually very simple... Feel free to bash my head in if you feel like it or see an easier way to do it! ;)

@@ -1131,13 +1131,29 @@ void World::SetInitialWorldSettings()
    objmgr.LoadSpellScripts();                              // must be after load Creature/Gameobject(Template/Data)
    objmgr.LoadGameObjectScripts();                         // must be after load Creature/Gameobject(Template/Data)
    objmgr.LoadEventScripts();                              // must be after load Creature/Gameobject(Template/Data)

    sLog.outString( "Initializing Scripts..." );
-    if(!LoadScriptingModule())
-        exit(1);
-
+    // Alternate script engine library loading
+    std::string AltLib = sConfig.GetStringDefault("AltLib", "");
+    char const* sAltName = AltLib.c_str();
+
+    if(strlen(sAltName))
+    {
+        // Load alternate library
+        sLog.outString( "Loading script engine library: %s", sAltName );
+        if(!LoadScriptingModule(sAltName))
+            exit(1);
+    }
+    else
+    {
+        // bailout w/ default lib
+        sLog.outString( "Loading default MaNGOS script engine.");
+        if(!LoadScriptingModule())
+            exit(1);
+    }
+    
    ///- Initialize game time and timers
    sLog.outString( "DEBUG:: Initialize game time and timers" );
    m_gameTime = time(NULL);
    m_startTime=m_gameTime;

PS: Before it is to be committed we should talk to SD2's people and kindly ask them to change their library name output to something like: scriptdev2.dll/.so instead of MaNGOSScript...

Anyway, that's that. :)

Thank you for your time! ;) LoL

Posted

Forgot to add the conf.dist.in mods.


# PERFORMANCE SETINGS
#
#     AltLib
#         Used to load a different scripting engine than the default MaNGOSSCripts library
#         Default: ""
#                  "scripting_library_file_name" DO NOT PUT LIBRARY EXTENTION!!! (.dll/.so)
#

AltLib = ""

I think that's all.

Posted

Looks interesting and useful, its easier to disable a part of the Scripts with that solution or simply to add custom scripts beside SD2.

I personally think something like a "Script" folder would be useful, it should load ALL .dll files from this folder so we could make things like "InstanceScripts.dll, GossipScripts.dll..." to have it better sorted / easier to overwrite or disable a part / need to compile only a part of the Scripts to test something.

Posted

I thought about it as a plugin connector, but IMO I'm not sure it would be relevant to have an entire "plugin" directory dedicated. From what I could see, I haven't spend a lot of time looking at that specifically but, wouldn't using two libs clash? Even if they do different things? If not then pardon my ignorance. :)

Posted

I juggled with the idea to load the default script engine if the AltLib failed to load but opted to leave it as is because it would be easier to "fix" the spelling in the conf file after it exited than to wait for the whole thing to load with the default lib then exit.

The alternative would be to stop and query the user if they wanted to continue loading using the default lib...

Posted

Short answer: Yes. It would work with Linux.

Long answer: This has no bearing whether it's Linux or Windows actually. It uses the same function as it was already using, all I did was add an entry in the config. If that entry (AltLib) is empty, it uses the default dll/so if not, it uses the one you defined in the .conf.

;)

Posted

For those interested in that patch, if any, you can use the followings:

Commit e0deeef2cad92ecfb794a5cad538b99388a60b84 <-- world.cpp changes

and

Commit a64235050be66988f4dfd564213d2dbc1dcae69e <-- mangosd.conf.dist.in

Posted

It would be nice if Mangos used a modular scripting design like Ascent, to keep things nice and neat, and to support more than scripting plug-ins (Ascent has data-dumpers, and LUA frontends.) I'm not quite sure how to make a compatible module yet, though.

Posted

Derex, I honestly don't know but it should. I don't have access to a linux partition so I can't test it out.

I think it should work because all that patch does is check if the new tag is not empty. (If it's not empty, it tries to load the library named in the tag.) The rest is pretty much the same. So if the .so loaded before, it should still do with that mod.

That patch doesn't change the way a library is compiled.

That's unless I misunderstood what you meant.

Posted

LoL :D

You make it sound like I broke the library loading code! Which is funny. So am I to understand that it didn't work before I made my changes?

    sLog.outString( "Initializing Scripts..." );
-    if(!LoadScriptingModule())
-        exit(1);
-
+    /// Alternate script engine library loading
+    std::string AltLib = sConfig.GetStringDefault("AltLib", "");
+    char const* sAltName = AltLib.c_str();
+
+    if(strlen(sAltName))
+    {
+        /// Load alternate library
+        sLog.outString( "Loading script engine library: %s", sAltName );
+        if(!LoadScriptingModule(sAltName))
+            exit(1);
+    }
+    else
+    {
+        /// bailout w/ default lib
+        sLog.outString( "Loading default MaNGOS script engine.");
+        if(!LoadScriptingModule())
+            exit(1);
+    }
+    
    ///- Initialize game time and timers

NOTE: I used

 tag because it's easier to see the changes when colorized.

Please explain how an IF/ELSE, a Screen Output (sLog.outString) and a Variable check would break the library loading/unloading/compiling? I'm not trying to be sarcastic, but I fail to understand how these changes would impact the way you say it would. These are the only changes I made in that file. The other modification is in mangosd.conf.dist.in The rest hasn't changed one bit (literally).

I just can't connect the dots here... Please explain how my changes break MaNGOS library stuff.

Posted

I dont say you break something, but just that it wotn work on linux as expected. Reccomend you to read libtool manual.

$ readelf -d ./mangos-worldd

Dynamic section at offset 0x827488 contains 37 entries:
 Tag        Type                         Name/Value
0x0000000000000001 (NEEDED)             Shared library: [libmysqlclient_r.so.15]
0x0000000000000001 (NEEDED)             Shared library: [libcrypt.so.1]
0x0000000000000001 (NEEDED)             Shared library: [libnsl.so.1]
0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
0x0000000000000001 (NEEDED)             Shared library: [libssl.so.0.9.8]
0x0000000000000001 (NEEDED)             Shared library: [libACE-5.6.6.so]
0x0000000000000001 (NEEDED)             Shared library: [librt.so.1]
0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
0x0000000000000001 (NEEDED)             Shared library: [libmangosscript.so.0]
0x0000000000000001 (NEEDED)             Shared library: [libZThread.so.0]
0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
0x0000000000000001 (NEEDED)             Shared library: [libcrypto.so.0.9.8]
0x000000000000000f (RPATH)              Library rpath: [/opt/dev/lib]
0x000000000000000c (INIT)               0x6ef0b8
0x000000000000000d (FINI)               0xa8cb64
0x0000000000000004 (HASH)               0x400240
0x000000006ffffef5 (GNU_HASH)           0x42bf50
0x0000000000000005 (STRTAB)             0x5061e0
0x0000000000000006 (SYMTAB)             0x45f650
0x000000000000000a (STRSZ)              1934703 (bytes)
0x000000000000000b (SYMENT)             24 (bytes)
0x0000000000000015 (DEBUG)              0x0
0x0000000000000003 (PLTGOT)             0xe27738
0x0000000000000002 (PLTRELSZ)           10200 (bytes)
0x0000000000000014 (PLTREL)             RELA
0x0000000000000017 (JMPREL)             0x6ec8e0
0x0000000000000007 (RELA)               0x6ec6d0
0x0000000000000008 (RELASZ)             528 (bytes)
0x0000000000000009 (RELAENT)            24 (bytes)
0x000000006ffffffe (VERNEED)            0x6ec5a0
0x000000006fffffff (VERNEEDNUM)         8
0x000000006ffffff0 (VERSYM)             0x6de750
0x0000000000000000 (NULL)               0x0

Posted

Well, let me just say that my intention was to have the possibility to load an alternate scripting library (whether on *nix or windows). That is the only goal here.

Now, if loading/unloading/compiling doesn't work as intended, there is nothing I can do about it. My mod doesn't break any of those things and as such, I don't feel the need to fix what is ailing MaNGOS in the first place (related to that particularity). This is the work of someone who knows about that kind of stuff.

I think the question here is: "Did the problem existed before my changes?" My answer is: I don't know. But if it doesn't work as intended now, I know it's not something in my code. If someone thinks otherwise, please give me clear explanations.

On the other hand, if someone could test it out, I'd be grateful and I think it would put that whole thing to rest.

Let me reiterate here: The patch is about loading an alternate scripting library independent of the platform if an entry is tagged into the configuration file (AltLib = ""). Any other issue should have a post in the BUGS forums unless _my_ code breaks something.

I'm sorry if I sounds like I'm dismissing your point Derex, but I still don't see how my modifications make an impact on what you are suggesting.

  • 2 years later...
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use