aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api
Commit message (Expand)AuthorAge
...
* Allow damage for attached objects, add attach/detach callbacks (#6786)SmallJoker2018-04-30
* Add online content repositoryrubenwardy2018-04-19
* Run callback in IDropAction, refactor function argumentsSmallJoker2018-04-02
* Add player inventory callbacksSmallJoker2018-04-02
* LINT: add clang-tidy step (#6295)Loïc Blot2018-04-01
* Fix a warning reported by clangLoic Blot2018-03-29
* Add reasons to on_dieplayer and on_hpchangeAndrew Ward2018-03-28
* Add `on_auth_fail` callback (#7039)red-0012018-02-15
* Node definition manager refactor (#7016)Dániel Juhász2018-02-10
* Move `setlocale` from Lua to C++.red-0012018-02-08
* [CSM] Don't Load the package library (#6944)red-0012018-01-22
* Change include from "cmake_config.h" to "config.h"Wayward One2018-01-21
* [CSM] Remove `on_connect` callback (#6941)red-0012018-01-21
* [CSM] Don't load the IO library. (#6087)red-0012018-01-04
* Fix crash on can_bypass_userlimit returning non-booleanrubenwardy2018-01-03
* Move files to subdirectories (#6599)Vitaliy2017-11-08
* Unkown nodes: Provide position on interact (#6505)SmallJoker2017-10-07
* [CSM] Add callback on open inventory (#5793)Vincent Glize2017-10-02
* Implement mod communication channels (#6351)Loïc Blot2017-09-26
* Set placer to nil instead of a non-functional one in item_OnPlace (#6449)DTA72017-09-21
* on_death: Fix callback number of pushed arguments (Fixes #6451)SmallJoker2017-09-21
* ServerEnv: Clean up object lifecycle handling (#6414)sfan52017-09-15
* Make INodeDefManager::getIds return a vector, not a setKahrl2017-09-12
* Implement minetest.register_can_bypass_userlimit (#6369)Loïc Blot2017-09-04
* Remove nodeupdate completely (#6358)Rui2017-09-01
* Modernize source code: last part (#6285)Loïc Blot2017-08-20
* Optimize headers (part 2) (#6272)Loïc Blot2017-08-18
* C++ modernize: Pragma once (#6264)Loïc Blot2017-08-17
* Cleanup various headers to reduce compilation times (#6255)Loïc Blot2017-08-16
* Add LuaEntity on_death callback (#6177)Loïc Blot2017-07-27
* Add 'plantlike_rooted' drawtypenumber Zero2017-07-11
* Expose getPointedThing to LuaDániel Juhász2017-07-07
* Create a filesystem abstraction layer for CSM and only allow accessing files ...red-0012017-06-30
* C++11 cleanup on constructors (#6000)Vincent Glize2017-06-19
* Remove threads.h and replace its definitions with their C++11 equivalents (#5...ShadowNinja2017-06-11
* C++11 patchset 6: forbid object copy using assigment/copy function deleters (...Loïc Blot2017-06-10
* Order es_DrawType exactly like enum NodeDrawType in nodedef.h (#5946)Thomas--S2017-06-10
* CSM: Fix documentation error for register_on_*_chat_messages (#5917)DS2017-06-09
* Use C++11 mutexes only (remove compat code) (#5922)Loïc Blot2017-06-06
* Fix CSM crash (#5779)red-0012017-05-20
* Fix a warning pointed by GCC 7.1Loic Blot2017-05-18
* Use a settings object for the main settingsShadowNinja2017-05-06
* [CSM] add `on_item_use` (#5544)red-0012017-05-06
* [CSM] Add event on_place_node API lua (#5548)Vincent Glize2017-04-29
* Fix various points reported by cppcheck (#5656)Loïc Blot2017-04-25
* Pass clang-format on various cpp/header files (#5559)Loïc Blot2017-04-23
* Add on_flood() callback.Auke Kok2017-04-22
* Fix various copy instead of const ref reported by cppcheck (part 3) (#5616)Loïc Blot2017-04-20
* Plug two minor Leaks (#5603)Auke Kok2017-04-17
* Hardware coloring for itemstacksDániel Juhász2017-04-08
class="hl opt">) Settings *getLayer(int layer) const; private: friend class Settings; Settings *getParent(int layer) const; void onLayerCreated(int layer, Settings *obj); void onLayerRemoved(int layer); std::vector<Settings*> layers; }; struct ValueSpec { ValueSpec(ValueType a_type, const char *a_help=NULL) { type = a_type; help = a_help; } ValueType type; const char *help; }; struct SettingsEntry { SettingsEntry() = default; SettingsEntry(const std::string &value_) : value(value_) {} SettingsEntry(Settings *group_) : group(group_), is_group(true) {} std::string value = ""; Settings *group = nullptr; bool is_group = false; }; typedef std::unordered_map<std::string, SettingsEntry> SettingEntries; class Settings { public: /* These functions operate on the global hierarchy! */ static Settings *createLayer(SettingsLayer sl, const std::string &end_tag = ""); static Settings *getLayer(SettingsLayer sl); /**/ Settings(const std::string &end_tag = "") : m_end_tag(end_tag) {} Settings(const std::string &end_tag, SettingsHierarchy *h, int settings_layer); ~Settings(); Settings & operator += (const Settings &other); Settings & operator = (const Settings &other); /*********************** * Reading and writing * ***********************/ // Read configuration file. Returns success. bool readConfigFile(const char *filename); //Updates configuration file. Returns success. bool updateConfigFile(const char *filename); // NOTE: Types of allowed_options are ignored. Returns success. bool parseCommandLine(int argc, char *argv[], std::map<std::string, ValueSpec> &allowed_options); bool parseConfigLines(std::istream &is); void writeLines(std::ostream &os, u32 tab_depth=0) const; /*********** * Getters * ***********/ Settings *getGroup(const std::string &name) const; const std::string &get(const std::string &name) const; bool getBool(const std::string &name) const; u16 getU16(const std::string &name) const; s16 getS16(const std::string &name) const; u32 getU32(const std::string &name) const; s32 getS32(const std::string &name) const; u64 getU64(const std::string &name) const; float getFloat(const std::string &name) const; v2f getV2F(const std::string &name) const; v3f getV3F(const std::string &name) const; u32 getFlagStr(const std::string &name, const FlagDesc *flagdesc, u32 *flagmask) const; bool getNoiseParams(const std::string &name, NoiseParams &np) const; bool getNoiseParamsFromValue(const std::string &name, NoiseParams &np) const; bool getNoiseParamsFromGroup(const std::string &name, NoiseParams &np) const; // return all keys used in this object std::vector<std::string> getNames() const; // check if setting exists anywhere in the hierarchy bool exists(const std::string &name) const; // check if setting exists in this object ("locally") bool existsLocal(const std::string &name) const; /*************************************** * Getters that don't throw exceptions * ***************************************/ bool getGroupNoEx(const std::string &name, Settings *&val) const; bool getNoEx(const std::string &name, std::string &val) const; bool getFlag(const std::string &name) const; bool getU16NoEx(const std::string &name, u16 &val) const; bool getS16NoEx(const std::string &name, s16 &val) const; bool getU32NoEx(const std::string &name, u32 &val) const; bool getS32NoEx(const std::string &name, s32 &val) const; bool getU64NoEx(const std::string &name, u64 &val) const; bool getFloatNoEx(const std::string &name, float &val) const; bool getV2FNoEx(const std::string &name, v2f &val) const; bool getV3FNoEx(const std::string &name, v3f &val) const; // Like other getters, but handling each flag individualy: // 1) Read default flags (or 0) // 2) Override using user-defined flags bool getFlagStrNoEx(const std::string &name, u32 &val, const FlagDesc *flagdesc) const; /*********** * Setters * ***********/ // N.B. Groups not allocated with new must be set to NULL in the settings // tree before object destruction. bool setEntry(const std::string &name, const void *entry, bool set_group); bool set(const std::string &name, const std::string &value); bool setDefault(const std::string &name, const std::string &value); bool setGroup(const std::string &name, const Settings &group); bool setBool(const std::string &name, bool value); bool setS16(const std::string &name, s16 value); bool setU16(const std::string &name, u16 value); bool setS32(const std::string &name, s32 value); bool setU64(const std::string &name, u64 value); bool setFloat(const std::string &name, float value); bool setV2F(const std::string &name, v2f value); bool setV3F(const std::string &name, v3f value); bool setFlagStr(const std::string &name, u32 flags, const FlagDesc *flagdesc = nullptr, u32 flagmask = U32_MAX); bool setNoiseParams(const std::string &name, const NoiseParams &np); // remove a setting bool remove(const std::string &name); /***************** * Miscellaneous * *****************/ void setDefault(const std::string &name, const FlagDesc *flagdesc, u32 flags); const FlagDesc *getFlagDescFallback(const std::string &name) const; void registerChangedCallback(const std::string &name, SettingsChangedCallback cbf, void *userdata = NULL); void deregisterChangedCallback(const std::string &name, SettingsChangedCallback cbf, void *userdata = NULL); void removeSecureSettings(); // Returns the settings layer this object is. // If within the global hierarchy you can cast this to enum SettingsLayer inline int getLayer() const { return m_settingslayer; } private: /*********************** * Reading and writing * ***********************/ SettingsParseEvent parseConfigObject(const std::string &line, std::string &name, std::string &value); bool updateConfigObject(std::istream &is, std::ostream &os, u32 tab_depth=0); static bool checkNameValid(const std::string &name); static bool checkValueValid(const std::string &value); static std::string getMultiline(std::istream &is, size_t *num_lines=NULL); static void printEntry(std::ostream &os, const std::string &name, const SettingsEntry &entry, u32 tab_depth=0); /*********** * Getters * ***********/ Settings *getParent() const; const SettingsEntry &getEntry(const std::string &name) const; // Allow TestSettings to run sanity checks using private functions. friend class TestSettings; // For sane mutex locking when iterating friend class LuaSettings; void updateNoLock(const Settings &other); void clearNoLock(); void clearDefaultsNoLock(); void doCallbacks(const std::string &name) const; SettingEntries m_settings; SettingsCallbackMap m_callbacks; std::string m_end_tag; mutable std::mutex m_callback_mutex; // All methods that access m_settings/m_defaults directly should lock this. mutable std::mutex m_mutex; SettingsHierarchy *m_hierarchy = nullptr; int m_settingslayer = -1; static std::unordered_map<std::string, const FlagDesc *> s_flags; };