Skip to content

Commit

Permalink
add some documentation to RegisterShipInitFunc (HarbourMasters#4995)
Browse files Browse the repository at this point in the history
  • Loading branch information
briaguya-ai authored Feb 7, 2025
1 parent f2a3ac1 commit ca0617b
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions soh/soh/ShipInit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,37 @@ struct ShipInit {
}
};

/**
* @brief Register a function to execute on boot and (optionally) in other situations
*
* @param initFunc The function to execute
* @param updatePaths Strings to specify additional situations in which to execute the function
*
* ### Examples:
*
* #### Execute function `bar` on boot
*
* ```cpp
* static RegisterShipInitFunc foo(bar);
* ```
*
* #### Execute function `bar` on boot and when the CVar `baz` might have changed
*
* ```cpp
* static RegisterShipInitFunc foo(bar, { "baz" });
* ```
*
* #### Execute function `bar` on boot and when `IS_RANDO` might have changed
*
* ```cpp
* static RegisterShipInitFunc foo(bar, { "IS_RANDO" });
* ```
*
* ### Additional Information:
*
* To get a better sense of when your function will be executed
* you can look for `ShipInit::Init` calls throughout the codebase
*/
struct RegisterShipInitFunc {
RegisterShipInitFunc(std::function<void()> initFunc, const std::set<std::string>& updatePaths = {}) {
auto& shipInitFuncs = ShipInit::GetAll();
Expand Down

0 comments on commit ca0617b

Please sign in to comment.