Jump to content

[patch][6417] Mersennetwister, Random Numbers


Auntie Mangos

Recommended Posts

* What bug does the patch fix? What features does the patch add?

.

Make the random numbers interface thread safe.

* For which SubVersion revision was the patch created?

6397 ported to 6415

* Is there a thread in the bug report section? If yes, please add a link to the thread.

http://getmangos.eu/community/viewtopic.p...st&p=200806

more info: http://getmangos.eu/community/viewtopic.p...st&p=200917

* Who has been writing this patch? Please include either forum user names or email addresses.

me

Note: the second patch is for ppl that use the ace netcode ,if they have svn conflicts.

Link to comment
Share on other sites

  • 38 years later...

That patch cause a script dev 2 errors

Linking...
    Creating library ..\\..\\..\\..\\bin\\win32_release/MaNGOSScript.lib and object ..\\..\\..\\..\\bin\\win32_release/MaNGOSScript.exp
mob_event_ai.obj : error LNK2019: unresolved external symbol "unsigned int __cdecl urand(unsigned int,unsigned int)" (?urand@@YAIII@Z) referenced in function "public: virtual void __thiscall Mob_EventAI::Reset(void)" (?Reset@Mob_EventAI@@UAEXXZ)
..\\..\\..\\..\\bin\\win32_release/MaNGOSScript.dll : fatal error LNK1120: 1 unresolved externals
Build log was saved at "file://c:\\Documents and Settings\\Администратор\\Рабочий стол\\EmulatorX\\Source\\src\\bindings\\ScriptDev2\\VC80\\ScriptDev2__Win32_Release\\BuildLog.htm"
ScriptDev2 - 2 error(s), 0 warning(s)
========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

As i understand the problem in

                                                (*i).Time = urand((*i).Event.event_param1, (*i).Event.event_param2);

in mob_event_ai.cpp. How i can fix it?

Link to comment
Share on other sites

Thanks, the problem should appar only on win32 and is caused because the random functions are not exported. I will post fix for it tommorow ,because I dont have time atm. I dont have windows too.

[ EDIT ] Now scriptdev should compile on windows.

Link to comment
Share on other sites

I'm getting

1>Linking...
1>     Creating library ..\\..\\..\\..\\bin\\win32_release/MaNGOSScript.lib and object ..\\..\\..\\..\\bin\\win32_release/MaNGOSScript.exp
1>mob_event_ai.obj : error LNK2019: unresolved external symbol "unsigned int __cdecl urand(unsigned int,unsigned int)" (?urand@@YAIII@Z) referenced in function "public: void __thiscall Mob_EventAI::ProcessEvent(struct EventHolder &,class Unit *)" (?ProcessEvent@Mob_EventAI@@QAEXAAUEventHolder@@PAVUnit@@@Z)
1>..\\..\\..\\..\\bin\\win32_release/MaNGOSScript.dll : fatal error LNK1120: 1 unresolved externals
1>Build Time 8:48
1>Build log was saved at "file://d:\\Projects\\MangosCode\\src\\bindings\\ScriptDev2\\VC90\\ScriptDev2__Win32_Release\\BuildLog.htm"
1>ScriptDev2 - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

When compiling SD2 now. Could you please check that you correctly defined urand so that SD2 can use it? We really would like to use the MaNGOS urand and other functions than use rand().

Link to comment
Share on other sites

Define.h

#ifdef WIN32
#ifdef MANGOS_WIN32_DLL_IMPORT

#define MANGOS_DLL_DECL __declspec(dllimport)
#else
#ifdef MANGOS_WIND_DLL_EXPORT
#define MANGOS_DLL_DECL __declspec(dllexport)
#else
#define MANGOS_DLL_DECL
#endif
#endif

#else
#define MANGOS_DLL_DECL
#endif

#if PLATFORM == PLATFORM_WINDOWS
#    define MANGOS_DLL_SPEC __declspec(dllexport)
#    ifndef DECLSPEC_NORETURN
#        define DECLSPEC_NORETURN __declspec(noreturn)
#    endif
#else
#    define MANGOS_DLL_SPEC
#    define DECLSPEC_NORETURN
#endif

According to this code MANGOS_DLL_DECL seems the correct thing to be used ,however all windows project files need to define MANGOS_WIND_DLL_EXPORT . And all scripting module build files need to define MANGOS_WIN32_DLL_IMPORT . At quick look I couldn`t find any project file where these things are defined . Are they deprecated or what ?

MANGOS_DLL_SPEC goes to just one __declspec(dllexport) on windows.

Link to comment
Share on other sites

MANGOS_WIN32_DLL_IMPORT is never used. DLL_SPEC is what all other classes and functions use.

You are probably right about that though. Me and Wyk3d were talking about this issue earlier today on IRC. We probably should be using MANGOS_DLL_DECL with MANGOS_WIND_DLL_EXPORT for Mangos and MANGOS_WIND_DLL_IMPORT for 3rd party script library. I'll have to try that out some time.

Link to comment
Share on other sites

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