2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include "Platform/Define.h"
24 #include "ScriptCalls.h"
27 ScriptsSet Script
=NULL
;
29 void UnloadScriptingModule()
33 //todo: some check if some func from script library is called right now
34 Script
->ScriptsFree();
35 MANGOS_CLOSE_LIBRARY(Script
->hScriptsLib
);
41 bool LoadScriptingModule(char const* libName
)
43 ScriptsSet testScript
=new _ScriptSet
;
45 std::string name
= strlen(libName
) ? libName
: MANGOS_SCRIPT_NAME
;
46 name
+= MANGOS_SCRIPT_EXT
;
48 testScript
->hScriptsLib
=MANGOS_LOAD_LIBRARY(name
.c_str());
50 if(!testScript
->hScriptsLib
)
52 printf("Error loading Scripts Library %s !\n",name
.c_str());
57 if( !(testScript
->ScriptsInit
=(scriptCallScriptsInit
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"ScriptsInit" ))
58 ||!(testScript
->ScriptsFree
=(scriptCallScriptsFree
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"ScriptsFree" ))
59 ||!(testScript
->ScriptsVersion
=(scriptCallScriptsVersion
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"ScriptsVersion" ))
60 ||!(testScript
->GossipHello
=(scriptCallGossipHello
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"GossipHello" ))
61 ||!(testScript
->GOChooseReward
=(scriptCallGOChooseReward
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"GOChooseReward" ))
62 ||!(testScript
->QuestAccept
=(scriptCallQuestAccept
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"QuestAccept" ))
63 ||!(testScript
->GossipSelect
=(scriptCallGossipSelect
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"GossipSelect" ))
64 ||!(testScript
->GossipSelectWithCode
=(scriptCallGossipSelectWithCode
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"GossipSelectWithCode"))
65 ||!(testScript
->QuestSelect
=(scriptCallQuestSelect
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"QuestSelect" ))
66 ||!(testScript
->QuestComplete
=(scriptCallQuestComplete
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"QuestComplete" ))
67 ||!(testScript
->NPCDialogStatus
=(scriptCallNPCDialogStatus
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"NPCDialogStatus" ))
68 ||!(testScript
->GODialogStatus
=(scriptCallGODialogStatus
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"GODialogStatus" ))
69 ||!(testScript
->ChooseReward
=(scriptCallChooseReward
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"ChooseReward" ))
70 ||!(testScript
->ItemHello
=(scriptCallItemHello
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"ItemHello" ))
71 ||!(testScript
->GOHello
=(scriptCallGOHello
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"GOHello" ))
72 ||!(testScript
->scriptAreaTrigger
=(scriptCallAreaTrigger
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"AreaTrigger" ))
73 ||!(testScript
->ItemQuestAccept
=(scriptCallItemQuestAccept
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"ItemQuestAccept" ))
74 ||!(testScript
->GOQuestAccept
=(scriptCallGOQuestAccept
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"GOQuestAccept" ))
75 ||!(testScript
->ItemUse
=(scriptCallItemUse
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"ItemUse" ))
76 ||!(testScript
->EffectDummyGameObj
=(scriptCallEffectDummyGameObj
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"EffectDummyGameObj" ))
77 ||!(testScript
->EffectDummyCreature
=(scriptCallEffectDummyCreature
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"EffectDummyCreature" ))
78 ||!(testScript
->EffectDummyItem
=(scriptCallEffectDummyItem
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"EffectDummyItem" ))
79 ||!(testScript
->GetAI
=(scriptCallGetAI
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"GetAI" ))
80 ||!(testScript
->CreateInstanceData
=(scriptCallCreateInstanceData
)MANGOS_GET_PROC_ADDR(testScript
->hScriptsLib
,"CreateInstanceData" ))
83 printf("Error loading Scripts Library %s !\n Library missing required functions.",name
.c_str());
84 MANGOS_CLOSE_LIBRARY(testScript
->hScriptsLib
);
90 sLog
.outString( ">>> Scripts Library %s was successfully loaded.\n", name
.c_str() );
92 //heh we are still there :P we have a valid library
94 UnloadScriptingModule();
97 Script
->ScriptsInit(objmgr
.GetScriptNames());
99 sWorld
.SetScriptsVersion(Script
->ScriptsVersion());