2017-12-10 01:52:03 +11:00
|
|
|
#ifndef NATIVE_SCRIPT_H
|
|
|
|
#define NATIVE_SCRIPT_H
|
|
|
|
|
|
|
|
#include <unordered_map>
|
2017-12-12 17:29:31 +11:00
|
|
|
#include <set>
|
2017-12-14 22:30:06 +11:00
|
|
|
#include <queue>
|
2017-12-10 01:52:03 +11:00
|
|
|
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
#include <boost/make_shared.hpp>
|
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
|
2017-12-18 12:36:52 +01:00
|
|
|
#include <common/Crypt/md5.h>
|
2017-12-10 01:52:03 +11:00
|
|
|
|
2017-12-10 15:31:48 +11:00
|
|
|
#include "ScriptLoader.h"
|
2017-12-10 01:52:03 +11:00
|
|
|
|
|
|
|
namespace Core {
|
2017-12-12 14:57:13 +11:00
|
|
|
namespace Scripting {
|
|
|
|
|
2017-12-13 15:07:03 +11:00
|
|
|
class NativeScriptManager
|
2017-12-12 14:57:13 +11:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
std::unordered_map< uint32_t, StatusEffectScript* > m_statusEffectScripts;
|
|
|
|
std::unordered_map< uint32_t, ActionScript* > m_actionScripts;
|
2017-12-13 22:19:00 +11:00
|
|
|
std::unordered_map< uint32_t, EventScript* > m_eventScripts;
|
2017-12-12 14:57:13 +11:00
|
|
|
std::unordered_map< uint32_t, BattleNpcScript* > m_battleNpcScripts;
|
|
|
|
std::unordered_map< uint32_t, ZoneScript* > m_zoneScripts;
|
|
|
|
|
|
|
|
ScriptLoader m_loader;
|
|
|
|
|
2017-12-14 22:30:06 +11:00
|
|
|
std::queue< std::string > m_scriptLoadQueue;
|
|
|
|
|
2017-12-14 13:23:59 +11:00
|
|
|
bool unloadScript( ScriptInfo* info );
|
|
|
|
|
2017-12-12 14:57:13 +11:00
|
|
|
public:
|
2017-12-13 15:07:03 +11:00
|
|
|
NativeScriptManager( );
|
2017-12-12 14:57:13 +11:00
|
|
|
|
|
|
|
StatusEffectScript* getStatusEffectScript( uint32_t statusId );
|
|
|
|
ActionScript* getActionScript( uint32_t actionId );
|
2017-12-13 22:19:00 +11:00
|
|
|
EventScript* getEventScript( uint32_t questId );
|
2017-12-12 14:57:13 +11:00
|
|
|
BattleNpcScript* getBattleNpcScript( uint32_t npcId );
|
|
|
|
ZoneScript* getZoneScript( uint32_t zoneId );
|
|
|
|
|
|
|
|
bool loadScript( const std::string& path );
|
|
|
|
bool unloadScript( const std::string& name );
|
2017-12-14 23:05:53 +11:00
|
|
|
void queueScriptReload( const std::string& name );
|
2017-12-12 17:29:31 +11:00
|
|
|
void findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search );
|
2017-12-12 14:57:13 +11:00
|
|
|
|
2017-12-14 22:30:06 +11:00
|
|
|
void processLoadQueue();
|
|
|
|
|
2017-12-12 14:57:13 +11:00
|
|
|
const std::string getModuleExtension();
|
2017-12-14 22:30:06 +11:00
|
|
|
bool isModuleLoaded( const std::string& name );
|
2017-12-12 14:57:13 +11:00
|
|
|
|
|
|
|
template< typename key, typename val >
|
|
|
|
bool removeValueFromMap( ScriptObject* ptr, std::unordered_map< key, val >& map )
|
|
|
|
{
|
|
|
|
for( typename std::unordered_map< key, val >::iterator it = map.begin(); it != map.end(); ++it )
|
|
|
|
{
|
|
|
|
if( ptr == static_cast< ScriptObject* >( it->second ) )
|
2017-12-12 13:17:43 +11:00
|
|
|
{
|
2017-12-12 14:57:13 +11:00
|
|
|
map.erase( it );
|
|
|
|
return true;
|
2017-12-12 13:17:43 +11:00
|
|
|
}
|
2017-12-12 14:57:13 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
};
|
2017-12-10 01:52:03 +11:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-12-13 15:07:03 +11:00
|
|
|
boost::shared_ptr< NativeScriptManager > createNativeScriptMgr();
|
2017-12-12 14:57:13 +11:00
|
|
|
} }
|
2017-12-10 01:52:03 +11:00
|
|
|
|
|
|
|
|
2017-12-18 12:36:52 +01:00
|
|
|
#endif
|