summaryrefslogtreecommitdiff
path: root/src/common/core.c
AgeCommit message (Collapse)AuthorFilesLines
2017-01-22Fix CMDLINE_OPT_PARAM arguments in plugins failing to loadHaru1-0/+2
When the server is called with a plugin-defined argument expecting additional values, in the form '--foo bar', the parser is unable to skip the additional value until the plugin is fully loaded. The issue was caused by the first scans of the argument list to find CMDLINE_OPT_PREINIT or CMDLINE_OPT_SILENT arguments, which happen before plugins are loaded, and would cause the parser to choke on the additional values, interpreting them as separate arguments. This is related to PR #1552, where we attempted to use this option for the first time. Signed-off-by: Haru <haru@dotalux.com>
2016-10-04Add missing checks into core.cAndrei Karas1-9/+30
2016-07-12Interface grfio.chemagx1-0/+2
2016-07-12Interface thread.chemagx1-2/+3
2016-07-12Interface random.chemagx1-6/+7
2016-07-12Interface mutex.chemagx1-0/+2
2016-07-12Interface md5calc.chemagx1-0/+2
2016-07-12Interface des.chemagx1-1/+3
2016-07-07Dont show compilation warnings about root if building for ci.Andrei Karas1-0/+6
And allow run under root in ci.
2016-07-04Added messages to discourage running Hercules as root.Haru1-4/+61
- You should not run Hercules as root, period. - If you understand all of the security implications, and still want to do so (and you don't want to be bothered by the warning messages), open core.c and uncomment the line: "//#define I_AM_AWARE_OF_THE_RISK_AND_STILL_WANT_TO_RUN_HERCULES_AS_ROOT" - If you're running Hercules as root because your provider forces (or encourages) you to do so, it means they're really doing it wrong, so please complain to them and ask them for an alternative. - More info on the topic: http://www.tldp.org/HOWTO/Security-HOWTO/local-security.html https://wiki.debian.org/sudo http://wiki.centos.org/TipsAndTricks/BecomingRoot http://fedoraproject.org/wiki/Configuring_Sudo https://help.ubuntu.com/community/RootSudo http://www.freebsdwiki.net/index.php/Root Signed-off-by: Haru <haru@dotalux.com>
2016-02-06Fix memory corruption if plugin add command line parameter without ↵Andrei Karas1-1/+4
help/description.
2015-12-15Added GPL-compliant header to all sources and build scriptsHaru1-4/+20
Signed-off-by: Haru <haru@dotalux.com>
2015-10-19rename malloc.c/h to memmgr.Andrei Karas1-1/+1
2015-10-11Changed cmdline->args_data to a VECTORHaru1-17/+18
Signed-off-by: Haru <haru@dotalux.com>
2015-09-25More aggressive whitespace cleanup. Follow up to 51329e6Haru1-3/+3
Signed-off-by: Haru <haru@dotalux.com>
2015-08-15Added core HPM interfaceHaru1-10/+8
Signed-off-by: Haru <haru@dotalux.com>
2015-08-15HPM compatibility improvementsHaru1-0/+1
Improved compatibility, portability and standards conformance. - Since it is not possible to portably and reliably re-use the core's symbols in plugins, symbols are no longer exported unless explicitly required, in the UNIX builds. This mimics the Windows behavior and adds HPM compatibility to OSes such as FreeBSD. Credits to Andrei Karas for making this possible. - For convenience, it is no longer necessary to call GET_SYMBOL, since the plugin will automatically import all the available symbols when it's loaded, depending on the included headers. - Plugins are now supposed to include the "common/hercules.h" header before including anything else. Incluing common/HPMi.h, common/cbasetypes.h or conf/core.h is no longer necessary, as those are guaranteed to be automatically included by hercules.h. - HPM API version bumped to 1.1. Signed-off-by: Haru <haru@dotalux.com>
2015-08-15Added showmsg HPM interfaceHaru1-2/+5
- The showmsg interface is automatically imported into plugins by the HPM (just like previously, the various Show* functions were). This change requires no actions from plugin developers. - stdout_with_ansisequence is now available through showmsg->stdout_with_ansisequence - msg_silent is now available through showmsg->silent - console_msg_log is now available through showmsg->console_log - timestamp_format is now available through showmsg->timestamp_format - Plugin-safe macros are provided, so that all Show* and Clear* calls will require no changes. - vShowMessage is provided through the public API, as va_list variant of ShowMessage. - vShowMessage_ is no longer part of the public API. If necessary, va_list variants of the other Show* functions will be added at a later time as follow-ups. Signed-off-by: Haru <haru@dotalux.com>
2015-06-19Cleaned up some #includesHaru1-2/+1
Signed-off-by: Haru <haru@dotalux.com>
2015-06-19Removed ".." from include directivesHaru1-25/+24
- Include directives are now directory-independent. - This will allow building plugins from other directories in future. Signed-off-by: Haru <haru@dotalux.com>
2015-06-02Follow up to 712812bMysteries1-1/+1
- More link changes - Added proper link to Roulette topic
2015-01-20Minor fixes and tweaks suggested by cppcheckHaru1-7/+6
- Variable scopes reduced - Parenthesized ambiguous expressions - Removed or added NULL checks where (un)necessary - Corrected format strings - Fixed typos potentially leading to bugs Signed-off-by: Haru <haru@dotalux.com>
2015-01-18Command line arguments handling overhaulHaru1-9/+198
- login_server, char_server, map_server as well as the tools (mapcache) now have a common command line arguments handling mechanism. - All of them now accept `--help` (`-h`), `--version` (`-v`) and `--load-plugin`. - login_server now accepts `--login-config` and `--lan-config` instead of relying on positional arguments to override those files. The old syntax will no longer work, please update your custom startup scripts. - char_server now accepts `--char-config`, `--inter-config`, `--lan-config` instead of relying on positional arguments. The old syntax will no longer work, please update your custom startup scripts. - mapcache now accepts `--grf-list`, `--map-list`, `--map-cache`, `--rebuild` in place of, respectively, `-grf`, `-list`, `-cache`, `-rebuild`. - A new macro `CMDLINEARG()` is provided, to help defining new command line argument handlers (i.e. in plugins). the `addArg()` call is still required, but its syntax has changed. The `help` argument is now of type `const char *` rather than a function pointer, and it is supposed to contain the message to show in the `--help` screen. Pass `NULL` if no help message is desired. Signed-off-by: Haru <haru@dotalux.com>
2015-01-18Implementing nullpo interface for plugin useshennetsind1-0/+2
As proposed in pull request #361 Signed-off-by: shennetsind <ind@henn.et>
2014-11-16Whitespace cleanup (no code changes)Haru1-15/+15
This includes, and is not limited to: mixed or wrong indentation, excess whitespace (horizontal and vertical), misalignment, trailing spaces. Signed-off-by: Haru <haru@dotalux.com>
2014-07-11Explicitly specify 'void' when a function expects no argumentsHaru1-1/+1
- See CERT DCL20-C. Signed-off-by: Haru <haru@dotalux.com>
2014-07-10Re-added revision info to the memory leak logHaru1-1/+1
- Information was missing because sysinfo->final() was freeing the data before iMalloc->final() could log it. Signed-off-by: Haru <haru@dotalux.com>
2014-05-16Follow-up to b6b3f58795288701d0e162d43fa6f0a47af913b3Haru1-4/+5
- Includes in some files weren't sorted alphabetically. Special thanks to KeiKun. Signed-off-by: Haru <haru@dotalux.com>
2014-05-10Re-commit of "Fixed order of includes in all source files"Haru1-17/+21
This reverts commit 94657284973f4037596bae468ebfbee5c217e02b.
2014-05-10Revert "Fixed order of includes in all source files"panikon1-21/+17
This reverts commit b6b3f58795288701d0e162d43fa6f0a47af913b3. Fixes issue 8184 http://hercules.ws/board/tracker/issue-8184-cart-related/
2014-05-09Fixed order of includes in all source filesHaru1-17/+21
- Changed order according to the (upcoming) code style guidelines. - Fixes several issues caused by missing headers when their include order is changed or in plugins. Signed-off-by: Haru <haru@dotalux.com>
2014-05-09Added support to return a different exit status to the OS.Haru1-2/+3
- This can be easily used by plugins. - See an example at http://github.com/HerculesWS/StaffPlugins/Haru/script_mapquit Signed-off-by: Haru <haru@dotalux.com>
2014-04-17Added sysinfo (System Information) functionalitiesHaru1-132/+19
- More informative messages are displayed during startup, to make it easier to identify what system and environment Hercules is running. - Git/SVN revision detection is improved, separating the source version (cached at compile time) from the runtime version, in case the user updated their working copy without recompiling the server. Git version detection is also more reliable, in case a non-default branch is used. - The get_revision script command has been removed (as it was useless to begin with, after the switch to git). An alternative will be provided later, for feature-probing purposes. - The patch was tested under Linux (Gentoo / gcc 4.7 on i686 and x86_64, Debian 6 / gcc 4.4 on i686, Raspbian / gcc 4.6 on armv6l, CentOS 5 / gcc 4.1 on i686, CentOS 6 / gcc 4.4 on x86_64, Linux Mint 15 / gcc 4.7 on x86_64, OS X Mountain Lion / clang 5.0 and gcc 4.8 on x86_64, Cygwin-NT-5.1/gcc 4.8 on i686, FreeBSD 8 / gcc 4.2 on i386, FreeBSD 9 / gcc 4.2 on amd64, FreeBSD 10 / clang 3.3 on amd64, NetBSD 5 / gcc 4.1 on i386, NetBSD 6 / gcc 4.5 on amd64, OpenBSD 5 / gcc 4.2 on amd64, Solaris 11 / gcc 4.5 on i86pc, Windows 7 / Visual Studio 2012 on x86, Windows 8 / Visual Studio 2010 on WOW64, Windows 8.1 / Visual Studio 2013 on WOW64. Signed-off-by: Haru <haru@dotalux.com>
2014-03-16Improved ERS memory handlingshennetsind1-0/+2
On shutdown the ERS will loop thru leftover managers and clear them according to each manager's settings, while also printing errors according to each manager's settings. Will also help pinpoint the causes of http://hercules.ws/board/tracker/issue-8093-memory-leak-after-stop-server-cant-fix/ and similar issues. Signed-off-by: shennetsind <ind@henn.et>
2014-01-18Socket interfacedshennetsind1-4/+5
We designed this one with having as little changes required elsewhere in mind, thus the way most socket-related things are called has not changed. Plugins may now take a greater advantage of the socket features. Signed-off-by: shennetsind <ind@henn.et>
2014-01-18Libconfig Interfacedshennetsind1-0/+2
Ready for plugin use. Thanks to Haruna Signed-off-by: shennetsind <ind@henn.et>
2013-12-17Fixed several compiler warningsHaru1-3/+0
- Warnings detected thanks to Xcode's compiler settings (more strict by default) and clang, warnings mostly but not only related to data sizes on 64 bit systems, that were silenced until now by very lax compiler settings. - This also decreases by a great deal the amount of warnings produced by MSVC in x64 mode (for the adventurous ones who tried that) - Also fixed (or silenced in case of false positives) the potential issues pointed out by the (awesome) clang static analyzer. - Patch co-produced with Ind, I'm merging and committing in his place! Signed-off-by: Haru <haru@dotalux.com>
2013-11-19Sanitized and improved several macros through the codeHaru1-1/+1
- Sanitized all potentially unsafe macros (related eA:15259) - Improved some function-like macros to evaluate their argument only once and keep it in a temporary variable. This improves performance in the damage calculation related code. Signed-off-by: Haru <haru@dotalux.com>
2013-11-09HPM Support for plugin-implemented "--args" (options)shennetsind1-0/+5
As a necessary measure for the upcoming bot that will keep .sql files in sync with their .txt counterparts. Special Thanks to Haruna Signed-off-by: shennetsind <ind@henn.et>
2013-11-05Introducing the Hercules Standalone Script Syntax CheckerHaru1-2/+12
- Added a command line argument '--script-check' to check a script's syntax without running the server (and without requiring a SQL connection). Usage: ./map-server --script-check /path/to/the/script.txt - For convenience, a script-checker bash script is provided, to set the path correctly when called from a different directory. Usage: /path/to/Hercules/script-checker /path/to/the/script/to/check.txt - While the script checker will supposedly work under windows as well, no convenience scripts are currently provided for platforms other than UNIX (feel free to open a pull request with a .bat launcher or whatever you like) - Integration with IDEs or text editors is possible. In fact, I already have a fully functional plugin for vim (through vim-syntastic), and if there's enough interest, I'll publish it. - screenshot: http://d.pr/i/NOBD - If you want an online checker, http://haru.ws/scriptchecker/ is running this code, without modifications and will be kept up to date (without any warranty though.) - Special thanks to Ind, Yommy, Streusel, who helped making this possible, in a way or another.
2013-09-25Renamed iTimer interface to timer.shennetsind1-3/+3
Also removed duplicate mentions of timer within calls to shorten.
2013-07-09Travis Report Fixesshennetsind1-6/+0
warn_unused_result shielding, dropped unused variables and fixed battle_calc_return_damage delay behavior (pointer was unchaged; resulting in the var afterwards always as 0) Special Thanks to Xgear. Signed-off-by: shennetsind <ind@henn.et>
2013-07-05HCache | Item Packages Updateshennetsind1-1/+5
http://hercules.ws/board/topic/1389-hcache-item-packages-update/ Signed-off-by: shennetsind <ind@henn.et>
2013-06-08Follow up d73783f22b2bb881aab74524d153d89a5932a199shennetsind1-2/+2
Adjusting db.c interface name to adhere with the rest (pretty much we try to make it as short as we can, and being there were no conflicts we saw no reason to maintain the 'i') Signed-off-by: shennetsind <ind@henn.et>
2013-06-07Hercules Renewal Phase One : pc, party, map, timerSusu1-7/+7
Added iPc, iParty, iMap, iTimer to HPM exported interfaces
2013-05-17- Made DB and malloc lib HPM-friendlySusu1-4/+6
- Also fixed a bug preventing the plugins to be loeaded because HPMI and HPMI_s weren't HPExport
2013-05-16Fixed Bug #7248shennetsind1-2/+2
http://hercules.ws/board/tracker/issue-7248-after-compiling-patches-from-1505-mapserver-crashed/ Signed-off-by: shennetsind <ind@henn.et>
2013-05-15HPM Updateshennetsind1-9/+14
Made SQL and strlib functions HPM-friendly, special thanks to Yommy for bringing the issue up. Added partial map.c support, for the all-handy map[] array, beware that soon the whole map.c renewal design will be commit and when that happens your usage of map.c functions in plugins might require some updates. Signed-off-by: shennetsind <ind@henn.et>
2013-05-02Introducing Hercules Plugin Manangershennetsind1-4/+12
http://hercules.ws/board/topic/549-introducing-hercules-plugin-manager/ Signed-off-by: shennetsind <ind@henn.et>
2013-03-17Re-Introducing Console Inputshennetsind1-114/+75
It's back. It's efficient. It's awesome. http://hercules.ws/board/topic/272-re-introducing-console-input/ Signed-off-by: shennetsind <ind@henn.et>