1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 22:37:45 +00:00

doco cleanup

This commit is contained in:
NotAdam 2018-07-24 23:16:26 +10:00
parent 6e831676f1
commit 279eb0f59d
5 changed files with 64 additions and 35 deletions

View file

@ -15,12 +15,13 @@
using namespace Core; using namespace Core;
// todo: this is shit
// constant script ids for certain events // constant script ids for certain events
#define EVENTSCRIPT_AETHERYTE_ID 0x50000 #define EVENTSCRIPT_AETHERYTE_ID 0x50000
#define EVENTSCRIPT_AETHERNET_ID 0x50001 #define EVENTSCRIPT_AETHERNET_ID 0x50001
/*! /*!
* The base class that any script should inherit from and set the type param accordingly * @brief The base class that any script should inherit from and set the type param accordingly
*/ */
class ScriptObject class ScriptObject
{ {
@ -39,7 +40,8 @@ public:
{ } { }
/*! /*!
* Gets the ID set for this script * @brief Gets the ID set for this script
*
* @return The allocated ID of the script set during object construction * @return The allocated ID of the script set during object construction
*/ */
virtual uint32_t getId() const virtual uint32_t getId() const
@ -48,7 +50,8 @@ public:
} }
/*! /*!
* Gets the unique identifier (hash_code) of the script * @brief Gets the unique identifier (hash_code) of the script
*
* @return The hash_code of the script * @return The hash_code of the script
*/ */
virtual std::size_t getType() const virtual std::size_t getType() const
@ -59,7 +62,7 @@ public:
/*! /*!
* The base class for any scripts that implement behaviour related to status effects. * @brief The base class for any scripts that implement behaviour related to status effects.
*/ */
class StatusEffectScript : public ScriptObject class StatusEffectScript : public ScriptObject
{ {
@ -70,49 +73,57 @@ public:
/*! /*!
* @brief Called on each tick that a status effect is active on an actor * @brief Called on each tick that a status effect is active on an actor
*
* @param actor the actor the status effect is ticking on * @param actor the actor the status effect is ticking on
*/ */
virtual void onTick( Entity::Chara& actor ) { } virtual void onTick( Entity::Chara& actor ) { }
/*! /*!
* @brief Called when the status effect is applied to an actor * @brief Called when the status effect is applied to an actor
*
* @param actor the actor on which the status effect was applied to * @param actor the actor on which the status effect was applied to
*/ */
virtual void onApply( Entity::Chara& actor ) { } virtual void onApply( Entity::Chara& actor ) { }
/*! /*!
* @brief Called when the actor (usually a player) removes the status effect by right clicking it * @brief Called when the actor (usually a player) removes the status effect by right clicking it
*
* @param actor The actor on which the effect was removed from * @param actor The actor on which the effect was removed from
*/ */
virtual void onRemove( Entity::Chara& actor ) { } virtual void onRemove( Entity::Chara& actor ) { }
/*! /*!
* @brief Called when the status effect expires * @brief Called when the status effect expires
*
* @param actor The actor on which the efect expired on * @param actor The actor on which the efect expired on
*/ */
virtual void onExpire( Entity::Chara& actor ) { } virtual void onExpire( Entity::Chara& actor ) { }
/*! /*!
* @brief Called when the player with the status effect collides with another player, eg. hot potato * @brief Called when the player with the status effect collides with another player, eg. hot potato
*
* @param actor The actor which has status effect * @param actor The actor which has status effect
* @param actorHit The actor who collided with the status effect owner * @param actorHit The actor who collided with the status effect owner
*/ */
virtual void onPlayerCollision( Entity::Chara& actor, Entity::Chara& actorHit ) { } virtual void onPlayerCollision( Entity::Chara& actor, Entity::Chara& actorHit ) { }
/*! /*!
* Called when the owner finishes a cast * @brief Called when the owner finishes a cast
*
* @param actor The actor who finished a cast * @param actor The actor who finished a cast
*/ */
virtual void onPlayerFinishCast( Entity::Chara& actor ) { } virtual void onPlayerFinishCast( Entity::Chara& actor ) { }
/*! /*!
* Called when the status effect owner was damaged * @brief Called when the status effect owner was damaged
*
* @param actor The actor that was damaged * @param actor The actor that was damaged
*/ */
virtual void onPlayerDamaged( Entity::Chara& actor ) { } virtual void onPlayerDamaged( Entity::Chara& actor ) { }
/*! /*!
* Called when the status effect owner dies * @brief Called when the status effect owner dies
*
* @param actor The actor that died * @param actor The actor that died
*/ */
virtual void onPlayerDeath( Entity::Chara& actor ) { } virtual void onPlayerDeath( Entity::Chara& actor ) { }
@ -120,7 +131,7 @@ public:
/*! /*!
* The base class for any scripts that implement behaviour related to actions * @brief The base class for any scripts that implement behaviour related to actions
*/ */
class ActionScript : public ScriptObject class ActionScript : public ScriptObject
{ {
@ -136,7 +147,7 @@ public:
/*! /*!
* The base class for any scripts that implement behaviour related to the event system. * @brief The base class for any scripts that implement behaviour related to the event system.
* This includes but is not limited to: NPCs, shops, some world objects * This includes but is not limited to: NPCs, shops, some world objects
*/ */
class EventScript : public ScriptObject class EventScript : public ScriptObject
@ -165,7 +176,7 @@ public:
/*! /*!
* The base class for any scripts that implement behaviour related to BattleNPCs * @brief The base class for any scripts that implement behaviour related to BattleNPCs
*/ */
class BattleNpcScript : public ScriptObject class BattleNpcScript : public ScriptObject
{ {
@ -176,7 +187,7 @@ public:
}; };
/*! /*!
* The base class for any scripts that implement behaviour related to zones * @brief The base class for any scripts that implement behaviour related to zones
*/ */
class ZoneScript : public ScriptObject class ZoneScript : public ScriptObject
{ {
@ -189,7 +200,7 @@ public:
}; };
/*! /*!
* The base class for any scripts that implement behaviour related to instance content zones * @brief The base class for any scripts that implement behaviour related to instance content zones
*/ */
class InstanceContentScript : public ScriptObject class InstanceContentScript : public ScriptObject
{ {

View file

@ -33,7 +33,10 @@ namespace Scripting {
std::queue< std::string > m_scriptLoadQueue; std::queue< std::string > m_scriptLoadQueue;
/*! /*!
* @brief Used to unload a script
*
* Used to unload a script, clears m_scripts of any scripts assoicated with a ScriptInfo and then unloads that module * Used to unload a script, clears m_scripts of any scripts assoicated with a ScriptInfo and then unloads that module
*
* @param info A pointer to the ScriptInfo object that is to be erased * @param info A pointer to the ScriptInfo object that is to be erased
* @return true if successful, false if not * @return true if successful, false if not
*/ */
@ -54,6 +57,7 @@ namespace Scripting {
/*! /*!
* @brief Unloads a script * @brief Unloads a script
*
* @param name The module name of the script to unload * @param name The module name of the script to unload
* @return true if successful * @return true if successful
*/ */
@ -71,31 +75,35 @@ namespace Scripting {
/*! /*!
* @brief Case-insensitive search for modules, useful for debug commands * @brief Case-insensitive search for modules, useful for debug commands
*
* @param scripts a set of ScriptInfo ptrs * @param scripts a set of ScriptInfo ptrs
* @param search the search term * @param search the search term
*/ */
void findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search ); void findScripts( std::set< Core::Scripting::ScriptInfo* >& scripts, const std::string& search );
/*! /*!
* Called on a regular interval, allows for scripts to be loaded from the internal load queue. * @brief Called on a regular interval, allows for scripts to be loaded from the internal load queue.
*/ */
void processLoadQueue(); void processLoadQueue();
/*! /*!
* Gets the module file extention for the current platform (windows, linux, osx) * @brief Gets the module file extention for the current platform (windows, linux, osx)
*
* @return The file extension for the current platform * @return The file extension for the current platform
*/ */
const std::string getModuleExtension(); const std::string getModuleExtension();
/*! /*!
* Checks to see if a module with the specified name exists * @brief Checks to see if a module with the specified name exists
*
* @param name The module name to lookup * @param name The module name to lookup
* @return true if loaded, false if not * @return true if loaded, false if not
*/ */
bool isModuleLoaded( const std::string& name ); bool isModuleLoaded( const std::string& name );
/*! /*!
* Get a specific script from the internal table * @brief Get a specific script from the internal table
*
* @tparam T The type of the script to search for * @tparam T The type of the script to search for
* @param scriptId The ID of the script to search for * @param scriptId The ID of the script to search for
* @return T* if successful, nullptr if the script doesn't exist * @return T* if successful, nullptr if the script doesn't exist
@ -115,7 +123,8 @@ namespace Scripting {
/*! /*!
* Creates an instance of NativeScriptMgr * @brief Creates an instance of NativeScriptMgr
*
* @return a boost::shared_ptr to NativeScriptMgr * @return a boost::shared_ptr to NativeScriptMgr
*/ */
boost::shared_ptr< NativeScriptMgr > createNativeScriptMgr(); boost::shared_ptr< NativeScriptMgr > createNativeScriptMgr();

View file

@ -17,7 +17,8 @@ namespace Core {
namespace Scripting { namespace Scripting {
/*! /*!
* An internal class used to track information about loaded modules and their scripts. * @brief An internal class used to track information about loaded modules and their scripts.
*
* The main purpose of this is to maintain easy access to the module handle and the pointers to scripts that are loaded. * The main purpose of this is to maintain easy access to the module handle and the pointers to scripts that are loaded.
* Furthermore, allows for quick and easy cross platform access to the module paths associated with the runtime module cache and its original path. * Furthermore, allows for quick and easy cross platform access to the module paths associated with the runtime module cache and its original path.
*/ */
@ -36,12 +37,12 @@ namespace Scripting {
std::string library_name; std::string library_name;
/*! /*!
* The path to the module currently loaded in memory from the cached location. * @brief The path to the module currently loaded in memory from the cached location.
*/ */
std::string cache_path; std::string cache_path;
/*! /*!
* The original path of the module before it was copied to the cache location. * @brief The original path of the module before it was copied to the cache location.
*/ */
std::string library_path; std::string library_path;
@ -53,7 +54,7 @@ namespace Scripting {
ModuleHandle handle; ModuleHandle handle;
/*! /*!
* @An internal list of all the pointers to each ScriptObject * @brief An internal list of all the pointers to each ScriptObject
* *
* This is tracked so when we unload this module we can call delete on each ScriptObject and correctly free it from memory. * This is tracked so when we unload this module we can call delete on each ScriptObject and correctly free it from memory.
*/ */

View file

@ -21,18 +21,19 @@ namespace Core {
namespace Scripting { namespace Scripting {
/*! /*!
* Provides low level functionality for loading modules on different platforms along with managing those loaded modules. * @brief Provides low level functionality for loading modules on different platforms along with managing those loaded modules.
*/ */
class ScriptLoader class ScriptLoader
{ {
protected: protected:
/*! /*!
* The internal list of all modules that are loaded. * @brief The internal list of all modules that are loaded.
*/ */
std::unordered_map< std::string, ScriptInfo* > m_scriptMap; std::unordered_map< std::string, ScriptInfo* > m_scriptMap;
/*! /*!
* Unload a loaded module from it's ModuleHandle * @brief Unload a loaded module from it's ModuleHandle
*
* @return true if the unload was successful, false if not * @return true if the unload was successful, false if not
*/ */
bool unloadModule( ModuleHandle ); bool unloadModule( ModuleHandle );
@ -41,7 +42,8 @@ namespace Scripting {
ScriptLoader() = default; ScriptLoader() = default;
/*! /*!
* Gets the module file extention for the current platform (windows, linux, osx) * @brief Gets the module file extention for the current platform (windows, linux, osx)
*
* @return The file extension for the current platform * @return The file extension for the current platform
*/ */
const std::string getModuleExtension(); const std::string getModuleExtension();
@ -56,40 +58,46 @@ namespace Scripting {
ScriptInfo* loadModule( const std::string& ); ScriptInfo* loadModule( const std::string& );
/*! /*!
* Unload a script from it's ScriptInfo object * @brief Unload a script from it's ScriptInfo object
*
* @return true if successful, false if not * @return true if successful, false if not
*/ */
bool unloadScript( ScriptInfo* ); bool unloadScript( ScriptInfo* );
/*! /*!
* Unload a script via it's module handle * @brief Unload a script via it's module handle
*
* @return true if successful, false if not * @return true if successful, false if not
*/ */
bool unloadScript( ModuleHandle ); bool unloadScript( ModuleHandle );
/*! /*!
* Look up a ScriptInfo* by a module name * @brief Look up a ScriptInfo* by a module name
*
* @param name The exact module name to search for, case-sensitive * @param name The exact module name to search for, case-sensitive
* @return The ScriptInfo ptr if successful, nullptr if it wasn't found * @return The ScriptInfo ptr if successful, nullptr if it wasn't found
*/ */
ScriptInfo* getScriptInfo( std::string name ); ScriptInfo* getScriptInfo( std::string name );
/*! /*!
* Get all scripts assoicated with a module * @brief Get all scripts assoicated with a module
*
* @param handle The handle to the module * @param handle The handle to the module
* @return An array of unknown size ending with nullptr if success, nullptr if not * @return An array of unknown size ending with nullptr if success, nullptr if not
*/ */
ScriptObject** getScripts( ModuleHandle handle ); ScriptObject** getScripts( ModuleHandle handle );
/*! /*!
* Checks to see if a module with the specified name exists * @brief Checks to see if a module with the specified name exists
*
* @param name The module name to lookup * @param name The module name to lookup
* @return true if loaded, false if not * @return true if loaded, false if not
*/ */
bool isModuleLoaded( std::string name ); bool isModuleLoaded( std::string name );
/*! /*!
* Case-insensitive search for modules, useful for debug commands * @brief Case-insensitive search for modules, useful for debug commands
*
* @param scripts a set of ScriptInfo ptrs * @param scripts a set of ScriptInfo ptrs
* @param search the search term * @param search the search term
*/ */

View file

@ -17,14 +17,14 @@ namespace Core
{ {
private: private:
/*! /*!
* A shared ptr to NativeScriptMgr, used for accessing and managing the native script system. * @brief A shared ptr to NativeScriptMgr, used for accessing and managing the native script system.
*/ */
boost::shared_ptr< NativeScriptMgr > m_nativeScriptMgr; boost::shared_ptr< NativeScriptMgr > m_nativeScriptMgr;
std::function< std::string( Entity::Player& ) > m_onFirstEnterWorld; std::function< std::string( Entity::Player& ) > m_onFirstEnterWorld;
/*! /*!
* Used to ignore the first change notification that Watchdog emits. * @brief Used to ignore the first change notification that Watchdog emits.
* Because reasons, it likes to emit an initial notification with all the files that match the filter, we don't want that so we ignore it. * Because reasons, it likes to emit an initial notification with all the files that match the filter, we don't want that so we ignore it.
*/ */
bool m_firstScriptChangeNotificiation; bool m_firstScriptChangeNotificiation;
@ -44,12 +44,12 @@ namespace Core
bool init(); bool init();
/*! /*!
* Called on each tick or at a regular interval. Allows for the NativeScriptMgr to process module loading and reloading. * @brief Called on each tick or at a regular interval. Allows for the NativeScriptMgr to process module loading and reloading.
*/ */
void update(); void update();
/*! /*!
* Registers a directory watcher which allows for script modules to be reloaded when changes to the modules occur * @brief Registers a directory watcher which allows for script modules to be reloaded when changes to the modules occur
*/ */
void watchDirectories(); void watchDirectories();