summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--3rdparty/libconfig/AUTHORS5
-rw-r--r--3rdparty/libconfig/CMakeLists.txt2
-rw-r--r--3rdparty/libconfig/ChangeLog623
-rw-r--r--3rdparty/libconfig/Makefile.in2
-rw-r--r--3rdparty/libconfig/extra/.gitignore5
-rwxr-xr-x3rdparty/libconfig/extra/aux-build/ylwrap247
-rwxr-xr-x3rdparty/libconfig/extra/configure5560
-rw-r--r--3rdparty/libconfig/extra/configure.ac79
-rw-r--r--3rdparty/libconfig/extra/doc/LGPL.texi590
-rw-r--r--3rdparty/libconfig/extra/doc/Makefile18
-rw-r--r--3rdparty/libconfig/extra/doc/Makefile.in18
-rw-r--r--3rdparty/libconfig/extra/doc/libconfig.texi1910
-rw-r--r--3rdparty/libconfig/extra/gen/Makefile70
-rw-r--r--3rdparty/libconfig/extra/gen/Makefile.in70
-rw-r--r--3rdparty/libconfig/extra/gen/grammar.y395
-rw-r--r--3rdparty/libconfig/extra/gen/scanner.l196
-rw-r--r--3rdparty/libconfig/grammar.c68
-rw-r--r--3rdparty/libconfig/grammar.h13
-rw-r--r--3rdparty/libconfig/libconfig-1.4.9 (renamed from 3rdparty/libconfig/libconfig-1.4.8)0
-rw-r--r--3rdparty/libconfig/libconfig.c25
-rw-r--r--3rdparty/libconfig/libconfig.h2
-rw-r--r--3rdparty/libconfig/scanner.c413
-rw-r--r--3rdparty/libconfig/scanner.h62
-rw-r--r--3rdparty/mt19937ar/Makefile.in2
-rw-r--r--Makefile.in92
-rw-r--r--README.md2
-rw-r--r--README.txt2
-rw-r--r--cache/README.txt2
-rw-r--r--cache/db/README.txt2
-rw-r--r--cache/db/pre-re/README.txt2
-rw-r--r--cache/db/re/README.txt2
-rw-r--r--conf/atcommand.conf2
-rw-r--r--conf/battle/feature.conf2
-rw-r--r--conf/battle/items.conf2
-rw-r--r--conf/battle/player.conf2
-rw-r--r--conf/battle/skill.conf2
-rw-r--r--conf/battlegrounds.conf2
-rw-r--r--conf/readme.txt2
-rw-r--r--db/cashshop_db.conf2
-rw-r--r--db/homun_skill_tree.txt2
-rw-r--r--db/homunculus_db.txt2
-rw-r--r--db/item_avail.txt2
-rw-r--r--db/pre-re/item_chain.conf2
-rw-r--r--db/pre-re/map_zone_db.conf2
-rw-r--r--db/re/exp_guild.txt2
-rw-r--r--db/re/item_chain.conf2
-rw-r--r--db/re/item_db.txt2
-rw-r--r--db/re/item_group.conf2
-rw-r--r--db/re/map_zone_db.conf2
-rw-r--r--doc/atcommands.txt2
-rw-r--r--doc/item_bonus.txt2
-rw-r--r--doc/md5_hashcheck.txt2
-rw-r--r--doc/permissions.txt2
-rw-r--r--doc/sample/bank_test.txt2
-rw-r--r--doc/sample/basejob_baseclass_upper.txt2
-rw-r--r--doc/sample/checkoption.txt2
-rw-r--r--doc/sample/delitem2.txt2
-rw-r--r--doc/sample/getequipcardid.txt2
-rw-r--r--doc/sample/getequipid.txt2
-rw-r--r--doc/sample/getiteminfo.txt2
-rw-r--r--doc/sample/getmonsterinfo.txt2
-rw-r--r--doc/sample/gstorage_test.txt2
-rw-r--r--doc/sample/npc_dynamic_shop.txt2
-rw-r--r--doc/sample/npc_extend_shop.txt2
-rw-r--r--doc/sample/npc_live_dialogues.txt2
-rw-r--r--doc/sample/npc_shop_test.txt2
-rw-r--r--doc/sample/npc_test_array.txt2
-rw-r--r--doc/sample/npc_test_chat.txt2
-rw-r--r--doc/sample/npc_test_duplicate.txt2
-rw-r--r--doc/sample/npc_test_npctimer.txt2
-rw-r--r--doc/sample/npc_test_npctimer2.txt2
-rw-r--r--doc/sample/npc_test_quest.txt2
-rw-r--r--doc/sample/npc_test_setmapflag.txt2
-rw-r--r--doc/sample/npc_test_time.txt2
-rw-r--r--doc/script_commands.txt2
-rw-r--r--doc/whisper_sys.txt2
-rw-r--r--npc/MOTD.txt2
-rw-r--r--npc/airports/rachel.txt2
-rw-r--r--npc/custom/etc/quest_warper.txt2
-rw-r--r--npc/custom/events/cluckers.txt2
-rw-r--r--npc/custom/jobmaster.txt2
-rw-r--r--npc/custom/quests/berzebub.txt2
-rw-r--r--npc/custom/quests/kaho_balmung.txt2
-rw-r--r--npc/custom/quests/kahohorn.txt2
-rw-r--r--npc/custom/quests/kings_items.txt2
-rw-r--r--npc/custom/quests/quest_shop.txt2
-rw-r--r--npc/custom/quests/sphinx_mask.txt2
-rw-r--r--npc/custom/quests/sunglasses.txt2
-rw-r--r--npc/custom/woe_controller.txt2
-rw-r--r--npc/events/idul_fitri.txt2
-rw-r--r--npc/events/valentinesday.txt2
-rw-r--r--npc/events/valentinesday_2012.txt2
-rw-r--r--npc/guild/trs_rp.txt2
-rw-r--r--npc/guild2/arug_cas01.txt2
-rw-r--r--npc/guild2/arug_cas02.txt2
-rw-r--r--npc/guild2/arug_cas03.txt2
-rw-r--r--npc/guild2/arug_cas04.txt2
-rw-r--r--npc/guild2/arug_cas05.txt2
-rw-r--r--npc/guild2/schg_cas01.txt2
-rw-r--r--npc/guild2/schg_cas02.txt2
-rw-r--r--npc/guild2/schg_cas03.txt2
-rw-r--r--npc/guild2/schg_cas04.txt2
-rw-r--r--npc/guild2/schg_cas05.txt2
-rw-r--r--npc/kafras/functions_kafras.txt2
-rw-r--r--npc/mapflag/skillduration.txt2
-rw-r--r--npc/mapflag/skillmodifier.txt2
-rw-r--r--npc/mapflag/town.txt2
-rw-r--r--npc/mapflag/zone.txt2
-rw-r--r--npc/merchants/cashheadgear_dye.txt2
-rw-r--r--npc/merchants/clothes_dyer.txt4
-rw-r--r--npc/merchants/coin_exchange.txt2
-rw-r--r--npc/merchants/elemental_trader.txt2
-rw-r--r--npc/merchants/enchan_arm.txt2
-rw-r--r--npc/merchants/hd_refine.txt2
-rw-r--r--npc/merchants/renters.txt2
-rw-r--r--npc/other/card_trader.txt2
-rw-r--r--npc/other/comodo_gambling.txt2
-rw-r--r--npc/other/guildpvp.txt2
-rw-r--r--npc/other/monster_race.txt2
-rw-r--r--npc/other/sealstatus.txt2
-rw-r--r--npc/pre-re/cities/izlude.txt2
-rw-r--r--npc/pre-re/guides/guides_alberta.txt2
-rw-r--r--npc/pre-re/guides/guides_moscovia.txt2
-rw-r--r--npc/pre-re/merchants/shops.txt2
-rw-r--r--npc/pre-re/mobs/fields/splendide.txt2
-rw-r--r--npc/pre-re/other/arena.txt2
-rw-r--r--npc/pre-re/quests/doomed_swords.txt2
-rw-r--r--npc/pre-re/quests/monstertamers.txt2
-rw-r--r--npc/pre-re/quests/quests_13_1.txt2
-rw-r--r--npc/pre-re/quests/quests_nameless.txt2
-rw-r--r--npc/pre-re/quests/skills/swordman_skills.txt2
-rw-r--r--npc/pre-re/scripts.conf2
-rw-r--r--npc/pre-re/scripts_warps.conf2
-rw-r--r--npc/quests/kiel_hyre_quest.txt2
-rw-r--r--npc/quests/mage_solution.txt2
-rw-r--r--npc/quests/quests_13_1.txt2
-rw-r--r--npc/quests/thana_quest.txt2
-rw-r--r--npc/re/cities/dicastes.txt2
-rw-r--r--npc/re/cities/jawaii.txt2
-rw-r--r--npc/re/cities/malangdo.txt2
-rw-r--r--npc/re/cities/malaya.txt2
-rw-r--r--npc/re/jobs/3-1/archbishop.txt2
-rw-r--r--npc/re/jobs/3-1/guillotine_cross.txt2
-rw-r--r--npc/re/jobs/3-1/mechanic.txt2
-rw-r--r--npc/re/jobs/3-1/ranger.txt2
-rw-r--r--npc/re/jobs/3-1/warlock.txt2
-rw-r--r--npc/re/jobs/3-2/genetic.txt2
-rw-r--r--npc/re/jobs/3-2/minstrel.txt2
-rw-r--r--npc/re/jobs/3-2/royal_guard.txt2
-rw-r--r--npc/re/jobs/3-2/shadow_chaser.txt2
-rw-r--r--npc/re/jobs/3-2/sorcerer.txt2
-rw-r--r--npc/re/jobs/3-2/sura.txt2
-rw-r--r--npc/re/jobs/3-2/wanderer.txt2
-rw-r--r--npc/re/jobs/novice/novice.txt2
-rw-r--r--npc/re/merchants/3rd_trader.txt2
-rw-r--r--npc/re/merchants/flute.txt2
-rw-r--r--npc/re/mobs/fields/amatsu.txt2
-rw-r--r--npc/re/mobs/fields/comodo.txt2
-rw-r--r--npc/re/mobs/fields/einbroch.txt2
-rw-r--r--npc/re/mobs/fields/geffen.txt2
-rw-r--r--npc/re/mobs/fields/gonryun.txt2
-rw-r--r--npc/re/mobs/fields/hugel.txt2
-rw-r--r--npc/re/mobs/fields/jawaii.txt2
-rw-r--r--npc/re/mobs/fields/lighthalzen.txt2
-rw-r--r--npc/re/mobs/fields/louyang.txt2
-rw-r--r--npc/re/mobs/fields/manuk.txt2
-rw-r--r--npc/re/mobs/fields/mjolnir.txt2
-rw-r--r--npc/re/mobs/fields/morocc.txt2
-rw-r--r--npc/re/mobs/fields/moscovia.txt2
-rw-r--r--npc/re/mobs/fields/payon.txt2
-rw-r--r--npc/re/mobs/fields/prontera.txt2
-rw-r--r--npc/re/mobs/fields/rachel.txt2
-rw-r--r--npc/re/mobs/fields/splendide.txt2
-rw-r--r--npc/re/mobs/fields/umbala.txt2
-rw-r--r--npc/re/mobs/fields/veins.txt2
-rw-r--r--npc/re/mobs/fields/yuno.txt2
-rw-r--r--npc/re/quests/monstertamers.txt2
-rw-r--r--npc/re/quests/quests_13_1.txt2
-rw-r--r--npc/re/quests/quests_malaya.txt2
-rw-r--r--npc/re/quests/quests_veins.txt2
-rw-r--r--npc/re/warps/cities/dicastes.txt2
-rw-r--r--npc/re/warps/cities/izlude.txt2
-rw-r--r--npc/re/warps/cities/malaya.txt2
-rw-r--r--npc/re/warps/dungeons/iz_dun.txt2
-rw-r--r--npc/re/warps/other/jobquests.txt2
-rw-r--r--npc/re/warps/other/s_workshop.txt2
-rw-r--r--npc/scripts_mapflags.conf2
-rw-r--r--npc/scripts_warps.conf2
-rw-r--r--plugins/empty.txt2
-rw-r--r--sql-files/item_db.sql2
-rw-r--r--sql-files/item_db_re.sql2
-rw-r--r--sql-files/upgrades/2013-02-14--16-15.sql2
-rw-r--r--sql-files/upgrades/2013-02-15--18-06.sql2
-rw-r--r--sql-files/upgrades/2013-03-05--01-05.sql2
-rw-r--r--sql-files/upgrades/2013-03-09--01-56.sql2
-rw-r--r--sql-files/upgrades/2013-03-27--18-35.sql2
-rw-r--r--sql-files/upgrades/2013-04-16--01-24.sql2
-rw-r--r--sql-files/upgrades/2013-04-16--02-15.sql2
-rw-r--r--sql-files/upgrades/index.txt2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/char/Makefile.in76
-rw-r--r--src/common/Makefile.in65
-rw-r--r--src/common/thread.c14
-rw-r--r--src/login/Makefile.in62
-rw-r--r--src/map/Makefile.in103
-rw-r--r--src/map/atcommand.c208
-rw-r--r--src/map/battle.c58
-rw-r--r--src/map/battleground.c127
-rw-r--r--src/map/battleground.h36
-rw-r--r--src/map/buyingstore.c2
-rw-r--r--src/map/chat.c894
-rw-r--r--src/map/chat.h112
-rw-r--r--src/map/chrif.c4
-rw-r--r--src/map/clif.c194
-rw-r--r--src/map/clif.h2
-rw-r--r--src/map/duel.c408
-rw-r--r--src/map/elemental.c1969
-rw-r--r--src/map/elemental.h206
-rw-r--r--src/map/guild.c22
-rw-r--r--src/map/homunculus.c18
-rw-r--r--src/map/instance.c6
-rw-r--r--src/map/intif.c10
-rw-r--r--src/map/intif.h256
-rw-r--r--src/map/itemdb.c248
-rw-r--r--src/map/itemdb.h82
-rw-r--r--src/map/map.c109
-rw-r--r--src/map/mapreg.h35
-rw-r--r--src/map/mapreg_sql.c163
-rw-r--r--src/map/mercenary.c10
-rw-r--r--src/map/mob.c883
-rw-r--r--src/map/mob.h189
-rw-r--r--src/map/npc.c733
-rw-r--r--src/map/npc.h250
-rw-r--r--src/map/npc_chat.c117
-rw-r--r--src/map/path.c16
-rw-r--r--src/map/path.h43
-rw-r--r--src/map/pc.c82
-rw-r--r--src/map/pc.h4
-rw-r--r--src/map/pet.c396
-rw-r--r--src/map/pet.h89
-rw-r--r--src/map/quest.c78
-rw-r--r--src/map/quest.h37
-rw-r--r--src/map/script.c413
-rw-r--r--src/map/skill.c350
-rw-r--r--src/map/status.c116
-rw-r--r--src/map/storage.c4
-rw-r--r--src/map/trade.c4
-rw-r--r--src/map/unit.c442
-rw-r--r--src/map/unit.h124
-rw-r--r--src/plugins/CMakeLists.txt2
-rw-r--r--src/plugins/Makefile.in2
-rw-r--r--src/plugins/db2sql.c2
-rw-r--r--src/plugins/sample.c2
-rw-r--r--src/test/Makefile.in34
-rw-r--r--src/tool/Makefile.in40
-rw-r--r--tools/mapreg-converter.php2
256 files changed, 15582 insertions, 5190 deletions
diff --git a/3rdparty/libconfig/AUTHORS b/3rdparty/libconfig/AUTHORS
new file mode 100644
index 000000000..f3f746557
--- /dev/null
+++ b/3rdparty/libconfig/AUTHORS
@@ -0,0 +1,5 @@
+
+Mark Lindner - Lead developer & maintainer.
+Daniel Marjamテ、ki - Enhancements & bugfixes.
+Andrew Tytula - Windows port.
+Glenn Herteg - Enhancements, bugfixes, documentation corrections.
diff --git a/3rdparty/libconfig/CMakeLists.txt b/3rdparty/libconfig/CMakeLists.txt
index 306a85aec..a99441249 100644
--- a/3rdparty/libconfig/CMakeLists.txt
+++ b/3rdparty/libconfig/CMakeLists.txt
@@ -26,4 +26,4 @@ set( LIBCONFIG_SOURCES
CACHE INTERNAL "libconfig sources" )
set( LIBCONFIG_DEFINITIONS
"-DLIBCONFIG_STATIC"
- CACHE INTERNAL "libconfig definitions" ) \ No newline at end of file
+ CACHE INTERNAL "libconfig definitions" )
diff --git a/3rdparty/libconfig/ChangeLog b/3rdparty/libconfig/ChangeLog
new file mode 100644
index 000000000..52125e9fb
--- /dev/null
+++ b/3rdparty/libconfig/ChangeLog
@@ -0,0 +1,623 @@
+ ----- version 1.4.9 ------
+
+2012-09-28 Mark Lindner <markl@neuromancer>
+
+ * lib/libconfigcpp.c++ - Fixed compiler warnings in constructor
+ initializers
+ * tinytest/tiytest.c, tinytest/tinytest.h - added tt_file_exists();
+ added alternate implementations of some test macros since MSVC does
+ not support C99 fully; added comparators for text files (ignoring
+ line endings)
+ * tests/tests.c - use tt_file_exists() rather than access(); alias
+ snprintf to _snprintf for MSVC; compare files as text files rather
+ than as binary files
+ * lib/scanner.l - fixed parsing issue when backslash in string is
+ followed by invalid escape character; reported by Jimmy Scott
+ * lib/scanner.c - regenerated
+ * lib/libconfig.h, lib/libconfig.h++, lib/Makefile.am,
+ doc/libconfig.texi, configure.ac - bump version numbers
+ * aclocal.m4, ac_config.h - regenerated
+ * m4/*, aux-build/*, libtool - updated to newer
+
+2011-12-30 Mark Lindner <markl@neuromancer>
+
+ * debian/control - updates from Jonathan McCrohan
+
+ ----- version 1.4.8 ------
+
+2011-08-04 Mark Lindner <markl@neuromancer>
+
+ * tests/Makefile.am - marked 'libconfig_tests' as non-installable
+ * lib/scanner.l, lib/grammar.y - grammar changes to make trailing
+ semicolons optional (and to allow commas as an alternative)
+ * lib/libconfig.c - bugfixes for lack of auto-conversion handling in
+ the config_lookup*() functions (reported by Feng Yu), and some
+ fixes for compiler warnings
+ * lib/Makefile.am - bump .so version
+ * configure.ac - bump version, add '-Wno-unused-parameter' compiler
+ switch to disable "unused parameter" warnings
+ * doc/libconfig.texi - documentation updates; added a chapter that
+ calls attention to the bundled example programs
+ * lib/libconfig.h, lib/libconfig.h++ - bump versions
+
+ ----- version 1.4.7 ------
+
+2011-03-11 Mark Lindner <markl@neuromancer>
+
+ * doc/libconfig.texi - fixed typo; updated docs
+ * TODO - updated list
+ * lib/libconfig.c, lib/libconfig.h, lib/libconfigcpp.c++,
+ lib/libconfig.h++ - added config{get,set}_default_format(),
+ Config::{get,set}DefaultFormat()
+
+2011-03-10 Mark Lindner <markl@neuromancer>
+
+ * lib/libconfig.c - fixed memory leak when encountering a parse error
+ in an @include'd file
+ * lib/libconfig.h, lib/libconfig.h++, lib/Makefile.am, configure.ac,
+ doc/libconfig.texi - bump versions
+
+ ----- version 1.4.6 ------
+
+2010-09-10 Mark Lindner <markl@neuromancer>
+
+ * doc/libconfig.texi - documentation updates
+ * lib/libconfig.c, lib/libconfigcpp.c++, lib/libconfig.h,
+ lib/libconfig.h++, lib/wincompat.h, lib/scanctx.c - added support
+ for specifying an include directory
+ * m4/* - added local m4 directory
+ * contrib/* - added user-contributed files
+
+2010-09-07 Mark Lindner <markl@neuromancer>
+
+ * lib/scanner.l - bugfix for parse error when there is a missing
+ newline at the end of the file
+ * lib/libconfig.h, lib/libconfig.h++, lib/Makefile.am - bump version
+ * tinytest/* - added a simple unit testing framework
+ * tests/* - added preliminary unit tests
+ * configure.ac, ac_config.h, ac_config.h.in, Makefile.am,
+ lib/Makefile.am, libtool, doc/libconfig.texi - bump versions/dates
+ * lib/grammar.h, lib/grammar.c - regenerated with newer version of
+ Bison
+ * lib/libconfig.c - bugfix: explicitly set starting line number to 1
+ when parsing from strings; otherwise line numbers reported in parse
+ errors are undefined
+
+ ----- version 1.4.5 ------
+
+2010-05-04 Mark Lindner <markl@neuromancer>
+
+ * lib/libconfig.h, lib/libconfig.h++, lib/Makefile.am - bumped version
+ numbers; removed #include for <map> and added one for <exception>
+ * lib/libconfigcpp.c++ - bugfix: properly handle TypeInt64 in add() and
+ assertType()
+ * aux-build/*, ac_config.h, configure.ac, ac_config.h.in, libtool -
+ regenerated with newer autotools
+ * libconfig.c - added declaration of libconfig_yylex_init_extra() to
+ eliminate compiler warning
+ * scanner.l - added #define YY_NO_INPUT to prevent compiler warning
+ * libconfig.texi - Added example code for operator=()
+
+ ----- version 1.4.4 ------
+
+2010-04-12 Mark Lindner <markl@neuromancer>
+
+ * lib/Makefile.am - fixed shared library version info
+ * lib/libconfig.h++ - added Setting::c_str() method
+ * configure.ac, ac_config.h, libconfig.spec, lib/libconfig.h,
+ lib/libconfig.h++ - bump versions
+ * lib/wincompat.h - fixed MinGW build error
+ * doc/libconfig.texi - doc updates
+ * README - added MinGW info
+
+ ----- version 1.4.3 ------
+
+2010-02-13 Mark Lindner <markl@neuromancer>
+
+ * lib/scanner.l - bugfix for matching @include with preceding
+ whitespace
+
+ ----- version 1.4.2 ------
+
+2010-01-19 Mark Lindner <markl@neuromancer>
+
+ * lib/libconfigcpp.c++, lib/libconfig.h++ - bugfix for crash; added
+ copy constructor for ParseException (from Frederic Heitzmann)
+ * lib/libconfig.h, lib/libconfig.h++, lib/Makefile.am,
+ ac_config.h, libconfig.spec, configure.ac - bump versions
+
+2010-01-09 Mark Lindner <markl@neuromancer>
+
+ * lib/libconfigcpp.c++ - bugfix in ParseException constructor (from
+ Ilya Dogolazky)
+ * debian/* - more cleanup, and added debug rules (from Ilya Dogolazky)
+
+ ----- version 1.4.1 ------
+
+2009-12-31 Mark Lindner <markl@neuromancer>
+
+ * lib/libconfig.c - bugfix for crash; removed unnecessary buffer delete
+ in __config_read()
+ * examples/c/Makefile.am, examples/c++/Makefile.am - fixed build issue
+ * configure.ac, Makefile.am - Added `--disable-examples' configure
+ option
+ * configure.ac, lib/Makefile.am, libconfig.spec, ac_config.h - bumped
+ version numbers
+
+ ----- version 1.4 ------
+
+2009-10-24 Mark Lindner <markl@neuromancer>
+
+ * grammar.y, scanner.l - properly report @include errors
+ * exmaples/example4.cpp - new example added
+
+2009-10-14 Mark Lindner <markl@neuromancer>
+
+ * debian/* - more fixes; from Klaus Schneider-Zapp
+ * libconfig.c - when writing strings, escape only control characters
+ with \x
+
+ ----- version 1.4b4 ------
+
+2009-09-09 Mark Lindner <markl@neuromancer>
+
+ * lib/Makefile.am - fixed MinGW build issues
+
+ ----- version 1.4b3 ------
+
+2009-09-04 Mark Lindner <markl@neuromancer>
+
+ * lib/libconfig.c, lib/scanner.l, lib/grammar.y - fixed all memory
+ leaks reported by Valgrind; removed an unncessary strdup()/free().
+
+2009-09-01 Mark Lindner <markl@neuromancer>
+
+ * lib/libconfig.c, lib/libconfig.h, lib/libconfigcpp.c++,
+ lib/libconfig.h++ - added config_error_type() and fixed a segfault
+ when throwing a ParseException.
+ * doc/libconfig.texi - doc updates
+
+ ----- version 1.4b2 ------
+
+2009-08-29 Mark Lindner <markl@neuromancer>
+
+ * examples/* - added new example programs to replace the less
+ practical ones in samples/
+
+2009-08-25 Mark Lindner <markl@neuromancer>
+
+ * lib/libconfig.c, lib/libconfig.h, lib/libconfigcpp.c++,
+ lib/libconfig.h++ - added config_set_tab_width(),
+ config_get_tab_width() and Config::setTabWidth(),
+ Config::getTabWidth().
+ * doc/libconfig.texi - doc updates
+
+ ----- version 1.4b1 ------
+
+2009-08-21 Mark Lindner <markl@neuromancer>
+
+ * lib/libconfig.h++, lib/libconfigcpp.c++ - broke the public
+ dependency on libconfig.h; updated VC++ projects on Windows so that
+ the C++ DLL no longer exports any of the C API functions
+ * debian/* - updated for version 1.4
+ * lib/libconfig.c - fixed an isprint() assertion on Windows
+
+2009-08-20 Mark Lindner <markl@neuromancer>
+
+ * lib/parsectx.c, lib/parsectx.h, lib/scanctx.c, lib/scanctx.h,
+ lib/strbuf.c, lib/strbuf.h - code refactoring to reduce library size
+ lib/Makefile.am - fixed 'make install' error
+
+ ----- version 1.4b ------
+
+2009-08-16 Mark Lindner <markl@neuromancer>
+
+ * lib/libconfig.c, lib/libconfig.h, lib/scanctx.c, lib/scanctx.h,
+ lib/grammar.y, lib/grammar.c, lib/grammar.h - added
+ config_read_string(); added config_setting_source_file() and
+ management of list of input file names; added #ifdef guard for
+ DllMain() function so that it's not included for static library
+ builds
+ * lib/libconfigcpp.c++, lib/libconfig.h++ - added filename to
+ ParseException; bugfix in Setting::setFormat(); made what() methods
+ of exceptions public; added Setting::getSourceFile(),
+ Config::readString().
+ * doc/libconfig.texi - documentation updates
+ * lib/Makefile.am - bump .so version
+ * ac_config.h, configure.ac, libtool - bump version
+
+2009-07-19 Mark Lindner <markl@neuromancer>
+
+ * lib/libconfig.c, lib/libconfig.h, lib/libconfigcpp.c++,
+ lib/libconfig.h++ - added config_read_string() and
+ Config::readString() functions (contributed by Matthias Weisser).
+
+2009-07-02 Mark Lindner <markl@neuromancer>
+
+ * lib/parsectx.c, lib/parsectx.h, lib/scanctx.c, lib/scanctx.h,
+ lib/scanner.l, lib/grammar.y, lib/private.h, lib/Makefile.am,
+ lib/libconfig.c, lib/libconfig.h - replaced ugly C code in scanner.l
+ for processing strings with a new <STRING> scanner state and
+ associated rules; added support for hex character literals (\xNN) in
+ strings; refactored scanner and parser context into separate source
+ files; added preliminary support for include files ("@include"
+ directive).
+
+2009-05-27 Mark Lindner <markl@neuromancer>
+
+ * ltmain.sh, ac_config.h, ac_config.h.in, configure.ac, libconfig.spec,
+ libtool - upgraded to newer versions of autotools
+ * grammar.y, grammar.h, grammar.c, libconfigcpp.c++, libconfig.h++,
+ libconfig.c, libconfig.h - added LIBCONFIG_VER_* macros, changed API
+ to replace 'long' and 'unsigned long' with 'int' and 'unsigned int'
+ to resolve a portability problem; added 'const' to declarations of
+ getLine() and getError() methods on ParseException
+ * <multiple> - directory structure reorg
+
+ ----- version 1.3.2 ------
+
+2009-02-18 Mark Lindner <markl@neuromancer>
+
+ * libconfig.vcproj, libconfig++.vcproj - #define _STDLIB_H to
+ eliminate 'inconsistent dll linkage' warnings for free & malloc
+
+2009-02-17 Mark Lindner <markl@neuromancer>
+
+ * libconfig.c, libconfig.h - added config_setting_lookup*() functions;
+ modified config_lookup_*() functions to have more consistent API
+ (return status, and accept value-result param)
+ * debian/* - updates and cleanup (from Klaus Schneider-Zapp)
+ * libconfig.spec, Makefile.am, ac_config.h - update version number
+ * doc/libconfig.texi - documentation updates
+ * samples/c/sample1.c - patch from Rodolfo Giometti
+ * samples/c/stub.c - fixed relative to API changes
+
+2008-12-06 Mark Lindner <markl@neuromancer>
+
+ * libconfig.c - fix memory leak in config_setting_remove_elem();
+ reported by Timi Tuohenmaa
+ * configure.ac - fix incorrect processing of --enable-cxx option;
+ reported by Thomas Gazzola
+
+2008-09-11 Mark Lindner <markl@neuromancer>
+
+ * debian/libconfigduo2.postinst - fix typo in test stmt
+
+ ----- version 1.3.1 ------
+
+2008-09-07 Mark Lindner <markl@neuromancer>
+
+ * scanner.l, wincompat.h - workarounds for problems with parsing and
+ formatting of 64-bit integers on MinGW
+ * scanner.c - regenerated
+
+2008-09-05 Mark Lindner <markl@neuromancer>
+
+ * libconfig.spec - updated for 1.3.1
+ * Makefile.am - fix version
+ * scanner.l - add fromhex() function, since strtoull() seems broken
+ on MinGW
+
+2008-08-25 Mark Lindner <markl@neuromancer>
+
+ * libconfigcpp.c++, libconfig.h++ - derive exceptions from
+ std::exception
+
+2008-08-10 Mark Lindner <markl@neuromancer>
+
+ * wincompat.h - fix MinGW build issue
+ * configure.ac, ac_config.h, Makefile.am - bump version
+ * doc/libconfig.texi - doc updates
+ * libconfigcpp.c++, libconfig.h++ - include path information in
+ setting exceptions
+ * libconfig.c - force "C" locale for parsing & formatting
+
+ ----- version 1.3 ------
+
+2008-04-07 Mark Lindner <markl@neuromancer>
+
+ * libconfig.spec - updated for 1.3
+
+2008-04-03 Mark Lindner <markl@neuromancer>
+
+ * scanner.l, grammar.y, libconfig.c, libconfig.h, wincompat.h -
+ fix/add comment headers, add C90 portability fixes from
+ Chris Pickett (C-style comments, renamed 'index' to 'idx' to
+ resolve name clash)
+ * scanner.c, grammar.c - regenerated
+ * configure.ac - enable more gcc warnings
+ * libconfigcpp.c++, libconfig.h++ - added getPath(), fixed impl of
+ isRoot(), add portability fixes from Chris Pickett (renamed 'index'
+ to 'idx' to resolve name clash), moved exception constructors into
+ source file; changed SettingExistsException to SettingNameException
+ to be more broad in scope
+ * Makefile.am - add wincompat.h to sources; add missing debian files
+ to EXTRA_DIST
+ * test.cfg - added example 64-bit integer settings
+ * samples/* - expanded some examples
+ * doc/libconfig.texi - documentation updates
+ * Makefile.am, *msvc7* - added (generated) VS2003 projects/solution
+
+2008-03-22 Mark Lindner <markl@neuromancer>
+
+ * debian/* - updates from Klaus Schneider
+
+2008-03-22 Mark Lindner <markl@neuromancer>
+
+ * scanner.l, grammar.y, libconfig.h++, libconfig.c, libconfig.h,
+ wincompat.h, libconfigcpp.c++, grammar.c, scanner.c, grammar.h -
+ add support for 64-bit integer values
+ * libconfig.texi - documentation updates
+ * Makefile.am, ac_config.h, configure.ac, libtool - bump version
+ * libconfig.h - add config_setting_parent(), config_setting_is_root()
+ * libconfigcpp.c++, libconfig.h++ - add isRoot(), getParent() to
+ Setting
+
+2008-03-15 Mark Lindner <markl@neuromancer>
+
+ * scanner.l - made 'true' and 'false' tokens completely
+ case-insensitive
+ * libconfigcpp.cc, libconfig.hh - added alias files for Windows
+ * libconfig.c, libconfig.h - modified __config_write_value() to write
+ out floating point values in a more human-readable form; added name
+ validation; added config_setting_remove_elem() and
+ config_setting_index()
+ * libconfigcpp.c++, libconfig.h++ - added remove(unsigned int) and
+ getIndex() to Setting
+ * libconfig.texi - documentation updates
+
+ ----- version 1.2.1 ------
+
+2007-12-21 Mark Lindner <markl@neuromancer>
+
+ * libconfig.c - source cleanup
+ * config.guess, config.sub, ltmain.sh, libtool - updated to newer
+ * configure.ac, Makefile.am, ac_config.h.in, ac_config.h
+ - MinGW-related fixes
+
+ ----- version 1.2 ------
+
+2007-10-15 Mark Lindner <markl@neuromancer>
+
+ * libconfig.h++, libconfigcpp.c++ - renamed "SettingFormat" to
+ "Setting::Format" to reduce namespace pollution
+
+2007-10-13 Mark Lindner <markl@neuromancer>
+
+ * scanner.l - updated regexp for float to allow for values which have
+ an exponent but no decimal point
+ * grammar.y - capture input line number when parsing settings
+ * libconfig.c, libconfig.h - added config_setting_is*() macros;
+ added config_setting_source_line(); added line member to
+ config_setting_t struct
+ * libconfig.c++, libconfig.h++ - renamed "SettingType" enum to
+ Setting::Type to reduce namespace pollution; added getSourceLine()
+ * samples/* - various updates
+ * debian/changelog - added entry
+ * ac_config.h, configure.ac, libtool, Makefile.am - new version #
+ * TODO - updates
+ * doc/libconfig.texi - documentation updates
+
+2007-10-12 Mark Lindner <markl@neuromancer>
+
+ * libconfig.c, libconfig.h - added config_set_auto_convert(),
+ config_get_auto_convert(), and number auto-conversion logic
+ * libconfigcpp.c++, libconfig.h++ - add setAutoConvert(),
+ getAutoConvert(), lookupValue() that takes std::string&,
+ corrected return values of assignment operators
+ * debian/rules - made file executable
+ * debian/libconfigduo-dev.install - add pkgconfig files to list
+
+2007-09-22 Mark Lindner <markl@neuromancer>
+
+ * libconfig.c, libconfig.h - change 'type' and 'format' members of
+ config_setting_t to short, thereby saving 4 bytes
+
+2007-09-22 Mark Lindner <markl@neuromancer>
+
+ * doc/libconfig.texi - add @direntry to fix install-info warnings
+ * libconfig.spec.in, Makefile.am, configure.ac - added RPM support
+ (from Deneys S. Maartens)
+
+2007-09-18 Mark Lindner <markl@neuromancer>
+
+ * libconfig.h - remove DLL_EXPORT; add LIBCONFIG_STATIC to fix
+ static linking on Windows
+
+2007-09-18 Deneys S. Maartens <dsm@tlabs.ac.za>
+
+ * samples/c/Makefile.am, samples/c++/Makefile.am - Add
+ AM_CPPFLAGS to fix distcheck build failure
+ * Makefile.am - expand wildcards in EXTRA_DIST to fix distcheck
+ build failure
+
+ ----- version 1.1.3 ------
+
+2007-08-03 Mark Lindner <markl@neuromancer>
+
+ * libconfigcpp.c++ - bugfix in unsigned cast operators (incorrect value
+ clipping logic)
+ * debian/control - made some corrections
+
+ ----- version 1.1.2 ------
+
+2007-07-01 Mark Lindner <markl@neuromancer>
+
+ * debian/* added debian package files from Klaus Schneider
+ * libconfig.h++ - added new predicate is<type>() functions
+ * libconfig.h - fix comments
+ * doc/libconfig.texi - documentation updates
+ * ac_config.h, configure.ac, Makefile.am - new version #
+
+ ----- version 1.1.1 ------
+
+2007-06-15 Mark Lindner <markl@neuromancer>
+
+ * scanner.l - bugfix in string parsing
+ * test.cfg - added test case
+
+ ----- version 1.1 ------
+
+2007-04-18 Mark Lindner <markl@neuromancer>
+
+ * libconfigcpp.c++ - bugfix in add(SettingType)
+ * stubcpp.cpp - add more ad-hoc tests
+
+2007-04-05 Mark Lindner <markl@neuromancer>
+
+ * scanner.l - Add string concatenation patch from Glenn Herteg.
+ Add \f as a whitespace character.
+ * grammar.y - add mode directive emacs
+ * libconfigcpp.c++, libconfig.h++ - add exists() and lookupValue()
+ methods; add Setting::operator std::string()
+ * libconfig.texi - documentation updates
+
+ ----- version 1.0.1 ------
+
+2006-11-26 Mark Lindner <markl@neuromancer>
+
+ * samples/c/Makefile.am, samples/c++/Makefile.am - fix linker error
+ * libconfig.texi - documentation update
+
+ ----- version 1.0 ------
+
+2006-10-19 Mark Lindner <markl@neuromancer>
+
+ * libconfigcpp.c++ - bugfix in add() for lists
+
+2006-10-11 Mark Lindner <markl@neuromancer>
+
+ * scanner.l - allow asterisk in setting names (submitted by
+ James McCann)
+ * libconfig.texi - documentation updates
+ * configure.ac, Makefile.am, samples/Makefile.am - add --disable-cxx
+ configure option; conditionally build/install C++ components
+
+2006-10-01 Mark Lindner <markl@neuromancer>
+
+ * <multiple> - samples cleanup
+
+2006-09-14 Mark Lindner <markl@neuromancer>
+
+ * libconfig.c - Change %.8f to %e for double values in
+ __config_write_value(). Submitted by Filipe Maia.
+
+2006-08-31 Mark Lindner <markl@neuromancer>
+
+ * Makefile.am - changed bin_PROGRAMS to noinst_PROGRAMS; the stub
+ programs are for testing and should not be installed.
+
+2006-08-26 Mark Lindner <markl@neuromancer>
+
+ * libconfig.texi - documentation corrections & updates
+ * stub.c, stubcpp.c++ - check return value of fopen(); fix compiler
+ warnings
+ * configure.ac, Makefile.am - add -Wall to CFLAGS only for gcc;
+ add test.cfg to EXTRA_DIST
+ * grammar.y, libconfigcpp.c++ - fix compiler warnings
+ * libconfig.c - use CONFIG_TRUE & CONFIG_FALSE rather than 1 & 0
+ for success/failure return values.
+
+ ----- version 0.9 ------
+
+2006-07-29 Mark Lindner <markl@neuromancer>
+
+ * <multiple> - major grammar redesign: groups are now values instead of
+ distinct syntax constructs; this allows groups to be elements of
+ lists
+ * libconfig.texi - documentation updates; added new chapter containing
+ the BNF grammar
+ * test.cfg - modified to reflect new syntax and to demonstrate lists
+
+2006-06-23 Mark Lindner <markl@neuromancer>
+
+ * <multiple> - added support for lists (collections of
+ heterogeneous values of any type)
+ * libconfig.c - pretty-printing fixes in config_write()
+
+2006-06-08 Mark Lindner <markl@neuromancer>
+
+ * libconfig.h++ - added private copy constructor & assignment operator
+ (from Josef Meile)
+ * ligconfigcpp.c++, libconfig.h++ - added cast operators for unsigned
+ int and unsigned long (from Scott Frazer)
+ * <multiple> - add support for value formats; the only non-default
+ format currently supported is hexadecimal format for integer values
+ (based on patch from Scott Frazer)
+
+2006-04-15 Mark Lindner <markl@neuromancer>
+
+ * <multiple> - added pkg-config support
+
+2006-03-31 mlindner <markl@neuromancer>
+
+ * <multiple> - cleaned up config.tab.h mess (this file was obsolete,
+ and superseded by grammar.h ... problem identified by Scott Frazer)
+
+2006-03-30 mlindner <mlindner@chimera>
+
+ * grammar.y - fixed includes for windows (missing decl of malloc/free)
+ * libconfig.c - fixed several signed/unsigned warnings
+ * doc/libconfig.texi - documentation updates, formatting fix
+ * scanner.l - allow lowercase 'true' and 'false' in addition to
+ 'TRUE' and 'FALSE'
+
+2006-03-27 Mark Lindner <markl@neuromancer>
+
+ * libconfigcpp.c++ - added missing break statements in switch (from
+ Lukas Zweifel)
+ * libconfig.c - don't strdup() a NULL string (from Lukas Zweifel)
+ * grammar.c, grammar.h - regenerated with bison 2.1
+
+2006-03-20 Mark Lindner <markl@neuromancer>
+
+ * scanner.l - added '%option nounistd' and regenerated with newest
+ version of flex; Windows doesn't have unistd.h.
+
+2006-03-17 Mark Lindner <markl@neuromancer>
+
+ * grammar.y - bugfix; error & abort parsing if duplicate setting name
+ encountered (previously caused a crash ... reported by Tobias Witek)
+ * scanner.l - bugfix; multi-line C-style comments were causing line
+ number counting to be thrown off, because the newlines were being
+ "eaten"
+ * <multiple> - various fixes to support building of DLLs on Windows.
+
+2005-11-26 Mark Lindner <markl@neuromancer>
+
+ * grammar.y, scanner.l - always strdup() yytext, and free the memory
+ in the grammar rules.
+
+2005-11-22 Mark Lindner <markl@neuromancer>
+
+ * libconfigcpp.c++, libconfig.h++, libconfig.c, libconfig.h -
+ Added Daniel's enhancements: methods & functions for reading/writing
+ files, fixes for various memory leaks, etc.
+ * samples/* - Added Daniel's example code.
+ * docs/libconfig.texi - Updated documentation
+
+2005-09-28 Mark Lindner <markl@neuromancer>
+
+ * libconfigcpp.c++, libconfig.h++, libconfig.c, libconfig.h
+ Enhanced API to support modification of a configuration.
+ * libconfig.texi - updated manual
+
+2005-06-02 Mark Lindner <markl@neuromancer>
+
+ * libconfigcpp.c++, libconfig.h++ - Added getName() method;
+ fixed operator[](int) to work with groups; this allows iteration over
+ a group's child settings. Added a missing break statement (bugfix
+ submitted by Pablo Barrera Gonzalez). Added operator int() and
+ operator float() to Setting; note that these may cause loss of
+ precision since the actual values are stored internally as long
+ and double, respectively.
+
+ * libconfig.h - added config_setting_name() macro
+
+ * libconfig.c - maintain two lists of children at each node; a sorted
+ list and an unsorted list (to preserve the order of the settings as
+ they appear in the file).
+
+ * scanner.l - fixed scanner rule for comments. '#' no longer has to
+ be in column 0 to be recognized as a comment. Added support for C
+ and C++ style comments.
diff --git a/3rdparty/libconfig/Makefile.in b/3rdparty/libconfig/Makefile.in
index f3c6e986d..d6714e50e 100644
--- a/3rdparty/libconfig/Makefile.in
+++ b/3rdparty/libconfig/Makefile.in
@@ -8,7 +8,7 @@ CC = @CC@
export CC
#####################################################################
-.PHONY : all clean help
+.PHONY: all clean help
all: $(LIBCONFIG_OBJ)
diff --git a/3rdparty/libconfig/extra/.gitignore b/3rdparty/libconfig/extra/.gitignore
new file mode 100644
index 000000000..03f1609a0
--- /dev/null
+++ b/3rdparty/libconfig/extra/.gitignore
@@ -0,0 +1,5 @@
+/config.log
+/config.status
+/gen/*.c
+/gen/*.h
+/autom4te.cache
diff --git a/3rdparty/libconfig/extra/aux-build/ylwrap b/3rdparty/libconfig/extra/aux-build/ylwrap
new file mode 100755
index 000000000..8f072a8e9
--- /dev/null
+++ b/3rdparty/libconfig/extra/aux-build/ylwrap
@@ -0,0 +1,247 @@
+#! /bin/sh
+# ylwrap - wrapper for lex/yacc invocations.
+
+scriptversion=2013-01-12.17; # UTC
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+get_dirname ()
+{
+ case $1 in
+ */*|*\\*) printf '%s\n' "$1" | sed -e 's|\([\\/]\)[^\\/]*$|\1|';;
+ # Otherwise, we want the empty string (not ".").
+ esac
+}
+
+# guard FILE
+# ----------
+# The CPP macro used to guard inclusion of FILE.
+guard ()
+{
+ printf '%s\n' "$1" \
+ | sed \
+ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
+ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g' \
+ -e 's/__*/_/g'
+}
+
+# quote_for_sed [STRING]
+# ----------------------
+# Return STRING (or stdin) quoted to be used as a sed pattern.
+quote_for_sed ()
+{
+ case $# in
+ 0) cat;;
+ 1) printf '%s\n' "$1";;
+ esac \
+ | sed -e 's|[][\\.*]|\\&|g'
+}
+
+case "$1" in
+ '')
+ echo "$0: No files given. Try '$0 --help' for more information." 1>&2
+ exit 1
+ ;;
+ --basedir)
+ basedir=$2
+ shift 2
+ ;;
+ -h|--h*)
+ cat <<\EOF
+Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
+
+Wrapper for lex/yacc invocations, renaming files as desired.
+
+ INPUT is the input file
+ OUTPUT is one file PROG generates
+ DESIRED is the file we actually want instead of OUTPUT
+ PROGRAM is program to run
+ ARGS are passed to PROG
+
+Any number of OUTPUT,DESIRED pairs may be used.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v|--v*)
+ echo "ylwrap $scriptversion"
+ exit $?
+ ;;
+esac
+
+
+# The input.
+input=$1
+shift
+# We'll later need for a correct munging of "#line" directives.
+input_sub_rx=`get_dirname "$input" | quote_for_sed`
+case $input in
+ [\\/]* | ?:[\\/]*)
+ # Absolute path; do nothing.
+ ;;
+ *)
+ # Relative path. Make it absolute.
+ input=`pwd`/$input
+ ;;
+esac
+input_rx=`get_dirname "$input" | quote_for_sed`
+
+# Since DOS filename conventions don't allow two dots,
+# the DOS version of Bison writes out y_tab.c instead of y.tab.c
+# and y_tab.h instead of y.tab.h. Test to see if this is the case.
+y_tab_nodot=false
+if test -f y_tab.c || test -f y_tab.h; then
+ y_tab_nodot=true
+fi
+
+# The parser itself, the first file, is the destination of the .y.c
+# rule in the Makefile.
+parser=$1
+
+# A sed program to s/FROM/TO/g for all the FROM/TO so that, for
+# instance, we rename #include "y.tab.h" into #include "parse.h"
+# during the conversion from y.tab.c to parse.c.
+sed_fix_filenames=
+
+# Also rename header guards, as Bison 2.7 for instance uses its header
+# guard in its implementation file.
+sed_fix_header_guards=
+
+while test $# -ne 0; do
+ if test x"$1" = x"--"; then
+ shift
+ break
+ fi
+ from=$1
+ # Handle y_tab.c and y_tab.h output by DOS
+ if $y_tab_nodot; then
+ case $from in
+ "y.tab.c") from=y_tab.c;;
+ "y.tab.h") from=y_tab.h;;
+ esac
+ fi
+ shift
+ to=$1
+ shift
+ sed_fix_filenames="${sed_fix_filenames}s|"`quote_for_sed "$from"`"|$to|g;"
+ sed_fix_header_guards="${sed_fix_header_guards}s|"`guard "$from"`"|"`guard "$to"`"|g;"
+done
+
+# The program to run.
+prog=$1
+shift
+# Make any relative path in $prog absolute.
+case $prog in
+ [\\/]* | ?:[\\/]*) ;;
+ *[\\/]*) prog=`pwd`/$prog ;;
+esac
+
+dirname=ylwrap$$
+do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret'
+trap "ret=129; $do_exit" 1
+trap "ret=130; $do_exit" 2
+trap "ret=141; $do_exit" 13
+trap "ret=143; $do_exit" 15
+mkdir $dirname || exit 1
+
+cd $dirname
+
+case $# in
+ 0) "$prog" "$input" ;;
+ *) "$prog" "$@" "$input" ;;
+esac
+ret=$?
+
+if test $ret -eq 0; then
+ for from in *
+ do
+ to=`printf '%s\n' "$from" | sed "$sed_fix_filenames"`
+ if test -f "$from"; then
+ # If $2 is an absolute path name, then just use that,
+ # otherwise prepend '../'.
+ case $to in
+ [\\/]* | ?:[\\/]*) target=$to;;
+ *) target=../$to;;
+ esac
+
+ # Do not overwrite unchanged header files to avoid useless
+ # recompilations. Always update the parser itself: it is the
+ # destination of the .y.c rule in the Makefile. Divert the
+ # output of all other files to a temporary file so we can
+ # compare them to existing versions.
+ if test $from != $parser; then
+ realtarget=$target
+ target=tmp-`printf '%s\n' "$target" | sed 's|.*[\\/]||g'`
+ fi
+
+ # Munge "#line" or "#" directives. Don't let the resulting
+ # debug information point at an absolute srcdir. Use the real
+ # output file name, not yy.lex.c for instance. Adjust the
+ # include guards too.
+ sed -e "/^#/!b" \
+ -e "s|$input_rx|$input_sub_rx|" \
+ -e "$sed_fix_filenames" \
+ -e "$sed_fix_header_guards" \
+ "$from" >"$target" || ret=$?
+
+ # Check whether files must be updated.
+ if test "$from" != "$parser"; then
+ if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
+ echo "$to is unchanged"
+ rm -f "$target"
+ else
+ echo "updating $to"
+ mv -f "$target" "$realtarget"
+ fi
+ fi
+ else
+ # A missing file is only an error for the parser. This is a
+ # blatant hack to let us support using "yacc -d". If -d is not
+ # specified, don't fail when the header file is "missing".
+ if test "$from" = "$parser"; then
+ ret=1
+ fi
+ fi
+ done
+fi
+
+# Remove the directory.
+cd ..
+rm -rf $dirname
+
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-time-zone: "UTC"
+# time-stamp-end: "; # UTC"
+# End:
diff --git a/3rdparty/libconfig/extra/configure b/3rdparty/libconfig/extra/configure
new file mode 100755
index 000000000..43a962bdf
--- /dev/null
+++ b/3rdparty/libconfig/extra/configure
@@ -0,0 +1,5560 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.69 for libconfig 1.4.9.
+#
+# Report bugs to <hyperrealm@gmail.com>.
+#
+#
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='print -r --'
+ as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in #(
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there. '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# Use a proper internal environment variable to ensure we don't fall
+ # into an infinite loop, continuously re-executing ourselves.
+ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+ _as_can_reexec=no; export _as_can_reexec;
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+ fi
+ # We don't want this to propagate to other subprocesses.
+ { _as_can_reexec=; unset _as_can_reexec;}
+if test "x$CONFIG_SHELL" = x; then
+ as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '\${1+\"\$@\"}'='\"\$@\"'
+ setopt NO_GLOB_SUBST
+else
+ case \`(set -o) 2>/dev/null\` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+"
+ as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+ exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
+ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+ as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+ eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+ test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+ if (eval "$as_required") 2>/dev/null; then :
+ as_have_required=yes
+else
+ as_have_required=no
+fi
+ if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ as_found=:
+ case $as_dir in #(
+ /*)
+ for as_base in sh bash ksh sh5; do
+ # Try only shells that exist, to save several forks.
+ as_shell=$as_dir/$as_base
+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+ CONFIG_SHELL=$as_shell as_have_required=yes
+ if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+ break 2
+fi
+fi
+ done;;
+ esac
+ as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+ CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+ if test "x$CONFIG_SHELL" != x; then :
+ export CONFIG_SHELL
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
+fi
+
+ if test x$as_have_required = xno; then :
+ $as_echo "$0: This script requires a shell more modern than all"
+ $as_echo "$0: the shells that I found on your system."
+ if test x${ZSH_VERSION+set} = xset ; then
+ $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+ $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+ else
+ $as_echo "$0: Please tell bug-autoconf@gnu.org and
+$0: hyperrealm@gmail.com about your system, including any
+$0: error possibly output before this message. Then install
+$0: a modern shell, or manually run the script under such a
+$0: shell if you do have one."
+ fi
+ exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+ { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+ return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+ set +e
+ as_fn_set_status $1
+ exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || eval $as_mkdir_p || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+ eval 'as_fn_append ()
+ {
+ eval $1+=\$2
+ }'
+else
+ as_fn_append ()
+ {
+ eval $1=\$$1\$2
+ }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+ eval 'as_fn_arith ()
+ {
+ as_val=$(( $* ))
+ }'
+else
+ as_fn_arith ()
+ {
+ as_val=`expr "$@" || test $? -eq 1`
+ }
+fi # as_fn_arith
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+ as_status=$1; test $as_status -eq 0 && as_status=1
+ if test "$4"; then
+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+ fi
+ $as_echo "$as_me: error: $2" >&2
+ as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+ as_lineno_1=$LINENO as_lineno_1a=$LINENO
+ as_lineno_2=$LINENO as_lineno_2a=$LINENO
+ eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+ test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+ # already done that, so ensure we don't try to do so again and fall
+ # in an infinite loop. This has already happened in practice.
+ _as_can_reexec=no; export _as_can_reexec
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+ case `echo 'xy\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ xy) ECHO_C='\c';;
+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
+ ECHO_T=' ';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -pR'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -pR'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -pR'
+ fi
+else
+ as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p='mkdir -p "$as_dir"'
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME='libconfig'
+PACKAGE_TARNAME='libconfig'
+PACKAGE_VERSION='1.4.9'
+PACKAGE_STRING='libconfig 1.4.9'
+PACKAGE_BUGREPORT='hyperrealm@gmail.com'
+PACKAGE_URL='http://www.hyperrealm.com/main.php?s=libconfig'
+
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='LTLIBOBJS
+LIBOBJS
+YFLAGS
+YACC
+LEXLIB
+LEX_OUTPUT_ROOT
+LEX
+EGREP
+GREP
+CPP
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+SET_MAKE
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+'
+ ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CPP
+YACC
+YFLAGS'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval $ac_prev=\$ac_option
+ ac_prev=
+ continue
+ fi
+
+ case $ac_option in
+ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+ *=) ac_optarg= ;;
+ *) ac_optarg=yes ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_dashdash$ac_option in
+ --)
+ ac_dashdash=yes ;;
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=*)
+ datadir=$ac_optarg ;;
+
+ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+ | --dataroo | --dataro | --datar)
+ ac_prev=datarootdir ;;
+ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+ datarootdir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid feature name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=no ;;
+
+ -docdir | --docdir | --docdi | --doc | --do)
+ ac_prev=docdir ;;
+ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+ docdir=$ac_optarg ;;
+
+ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+ ac_prev=dvidir ;;
+ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+ dvidir=$ac_optarg ;;
+
+ -enable-* | --enable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid feature name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=\$ac_optarg ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+ ac_prev=htmldir ;;
+ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+ | --ht=*)
+ htmldir=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localedir | --localedir | --localedi | --localed | --locale)
+ ac_prev=localedir ;;
+ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+ localedir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst | --locals)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+ ac_prev=pdfdir ;;
+ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+ pdfdir=$ac_optarg ;;
+
+ -psdir | --psdir | --psdi | --psd | --ps)
+ ac_prev=psdir ;;
+ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+ psdir=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid package name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=\$ac_optarg ;;
+
+ -without-* | --without-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid package name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=no ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ case $ac_envvar in #(
+ '' | [0-9]* | *[!_$as_cr_alnum]* )
+ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+ esac
+ eval $ac_envvar=\$ac_optarg
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ as_fn_error $? "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+ case $enable_option_checking in
+ no) ;;
+ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+ *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+ esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
+ datadir sysconfdir sharedstatedir localstatedir includedir \
+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+ libdir localedir mandir
+do
+ eval ac_val=\$$ac_var
+ # Remove trailing slashes.
+ case $ac_val in
+ */ )
+ ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+ eval $ac_var=\$ac_val;;
+ esac
+ # Be sure to have absolute directory names.
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) continue;;
+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+ esac
+ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+ as_fn_error $? "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+ as_fn_error $? "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then the parent directory.
+ ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_myself" : 'X\(//\)[^/]' \| \
+ X"$as_myself" : 'X\(//\)$' \| \
+ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r "$srcdir/$ac_unique_file"; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+ pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+ srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+ eval ac_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_env_${ac_var}_value=\$${ac_var}
+ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures libconfig 1.4.9 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking ...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
+ --infodir=DIR info documentation [DATAROOTDIR/info]
+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
+ --mandir=DIR man documentation [DATAROOTDIR/man]
+ --docdir=DIR documentation root [DATAROOTDIR/doc/libconfig]
+ --htmldir=DIR html documentation [DOCDIR]
+ --dvidir=DIR dvi documentation [DOCDIR]
+ --pdfdir=DIR pdf documentation [DOCDIR]
+ --psdir=DIR ps documentation [DOCDIR]
+_ACEOF
+
+ cat <<\_ACEOF
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of libconfig 1.4.9:";;
+ esac
+ cat <<\_ACEOF
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ LIBS libraries to pass to the linker, e.g. -l<library>
+ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+ you have headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+ YACC The `Yet Another Compiler Compiler' implementation to use.
+ Defaults to the first program found out of: `bison -y', `byacc',
+ `yacc'.
+ YFLAGS The list of arguments that will be passed by default to $YACC.
+ This script will default YFLAGS to the empty string to avoid a
+ default value of `-d' given by some make applications.
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <hyperrealm@gmail.com>.
+libconfig home page: <http://www.hyperrealm.com/main.php?s=libconfig>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d "$ac_dir" ||
+ { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+ continue
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+ cd "$ac_dir" || { ac_status=$?; continue; }
+ # Check for guested configure.
+ if test -f "$ac_srcdir/configure.gnu"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+ elif test -f "$ac_srcdir/configure"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure" --help=recursive
+ else
+ $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi || ac_status=$?
+ cd "$ac_pwd" || { ac_status=$?; break; }
+ done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+ cat <<\_ACEOF
+libconfig configure 1.4.9
+generated by GNU Autoconf 2.69
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext
+ if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } > conftest.i && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if eval \${$3+:} false; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_header_compiler=yes
+else
+ ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ ac_header_preproc=yes
+else
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+ yes:no: )
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( $as_echo "## ----------------------------------- ##
+## Report this to hyperrealm@gmail.com ##
+## ----------------------------------- ##"
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=$ac_status
+fi
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ test -x conftest$ac_exeext
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+ # interfere with the next link command; also delete a directory that is
+ # left behind by Apple's compiler. We do this before executing the actions.
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $2 (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_func
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by libconfig $as_me 1.4.9, which was
+generated by GNU Autoconf 2.69. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ $as_echo "PATH: $as_dir"
+ done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *\'*)
+ ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+ 2)
+ as_fn_append ac_configure_args1 " '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ as_fn_append ac_configure_args " '$ac_arg'"
+ ;;
+ esac
+ done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ $as_echo "## ---------------- ##
+## Cache variables. ##
+## ---------------- ##"
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+(
+ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) { eval $ac_var=; unset $ac_var;} ;;
+ esac ;;
+ esac
+ done
+ (set) 2>&1 |
+ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ sed -n \
+ "s/'\''/'\''\\\\'\'''\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+ ;; #(
+ *)
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+)
+ echo
+
+ $as_echo "## ----------------- ##
+## Output variables. ##
+## ----------------- ##"
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ $as_echo "## ------------------- ##
+## File substitutions. ##
+## ------------------- ##"
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ $as_echo "## ----------- ##
+## confdefs.h. ##
+## ----------- ##"
+ echo
+ cat confdefs.h
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ $as_echo "$as_me: caught signal $ac_signal"
+ $as_echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core core.conftest.* &&
+ rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+ # We do not want a PATH search for config.site.
+ case $CONFIG_SITE in #((
+ -*) ac_site_file1=./$CONFIG_SITE;;
+ */*) ac_site_file1=$CONFIG_SITE;;
+ *) ac_site_file1=./$CONFIG_SITE;;
+ esac
+elif test "x$prefix" != xNONE; then
+ ac_site_file1=$prefix/share/config.site
+ ac_site_file2=$prefix/etc/config.site
+else
+ ac_site_file1=$ac_default_prefix/share/config.site
+ ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+ test "x$ac_site_file" = xNONE && continue
+ if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file" \
+ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5; }
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special files
+ # actually), so we avoid doing that. DJGPP emulates it as a regular file.
+ if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . "$cache_file";;
+ *) . "./$cache_file";;
+ esac
+ fi
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val=\$ac_cv_env_${ac_var}_value
+ eval ac_new_val=\$ac_env_${ac_var}_value
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ # differences in whitespace do not lead to failure.
+ ac_old_val_w=`echo x $ac_old_val`
+ ac_new_val_w=`echo x $ac_new_val`
+ if test "$ac_old_val_w" != "$ac_new_val_w"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ ac_cache_corrupted=:
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+ eval $ac_var=\$ac_old_val
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
+$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
+$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+#AC_CANONICAL_TARGET
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: libconfig - made with pride in California" >&5
+$as_echo "$as_me: libconfig - made with pride in California" >&6;}
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+ @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+ *@@@%%%=?*=@@@%%%*)
+ eval ac_cv_prog_make_${ac_make}_set=yes;;
+ *)
+ eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ SET_MAKE=
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define TARGET "${target}"
+_ACEOF
+
+
+# Enable GNU extensions.
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ fi
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl.exe
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl.exe
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CC" && break
+done
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+ { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ sed '10a\
+... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ fi
+ rm -f conftest.er1 conftest.err
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+ esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link_default") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile. We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+ then :; else
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ fi
+ # We set ac_cv_exeext here because the later test for it is not
+ # safe: cross compilers may not add the suffix if given an `-o'
+ # argument, so we may need to know it at that point already.
+ # Even if this section looks crufty: it has the advantage of
+ # actually working.
+ break;;
+ * )
+ break;;
+ esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+ ac_file=''
+fi
+if test -z "$ac_file"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "C compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+ { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ if { ac_try='./conftest$ac_cv_exeext'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5; }
+ fi
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if ${ac_cv_objext+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ for ac_file in conftest.o conftest.obj conftest.*; do
+ test -f "$ac_file" || continue;
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if ${ac_cv_c_compiler_gnu+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_compiler_gnu=yes
+else
+ ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if ${ac_cv_prog_cc_g+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_c_werror_flag=$ac_c_werror_flag
+ ac_c_werror_flag=yes
+ ac_cv_prog_cc_g=no
+ CFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_g=yes
+else
+ CFLAGS=""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ ac_c_werror_flag=$ac_save_c_werror_flag
+ CFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if ${ac_cv_prog_cc_c89+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+ inside strings and character constants. */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+ test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+ x)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+ xno)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+ *)
+ CC="$CC $ac_cv_prog_cc_c89"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if ${ac_cv_prog_CPP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$GREP"; then
+ ac_path_GREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in grep ggrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+ # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'GREP' >> "conftest.nl"
+ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_GREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_GREP="$ac_path_GREP"
+ ac_path_GREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_GREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_GREP"; then
+ as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+ then ac_cv_path_EGREP="$GREP -E"
+ else
+ if test -z "$EGREP"; then
+ ac_path_EGREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in egrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+ # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'EGREP' >> "conftest.nl"
+ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_EGREP="$ac_path_EGREP"
+ ac_path_EGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_EGREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_EGREP"; then
+ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_EGREP=$EGREP
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_header_stdc=yes
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then :
+ :
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+ ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default"
+if test "x$ac_cv_header_minix_config_h" = xyes; then :
+ MINIX=yes
+else
+ MINIX=
+fi
+
+
+ if test "$MINIX" = yes; then
+
+$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h
+
+
+$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h
+
+
+$as_echo "#define _MINIX 1" >>confdefs.h
+
+ fi
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5
+$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; }
+if ${ac_cv_safe_to_define___extensions__+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+# define __EXTENSIONS__ 1
+ $ac_includes_default
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_safe_to_define___extensions__=yes
+else
+ ac_cv_safe_to_define___extensions__=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5
+$as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
+ test $ac_cv_safe_to_define___extensions__ = yes &&
+ $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h
+
+ $as_echo "#define _ALL_SOURCE 1" >>confdefs.h
+
+ $as_echo "#define _GNU_SOURCE 1" >>confdefs.h
+
+ $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h
+
+ $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ fi
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl.exe
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl.exe
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CC" && break
+done
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+ { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ sed '10a\
+... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ fi
+ rm -f conftest.er1 conftest.err
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if ${ac_cv_c_compiler_gnu+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_compiler_gnu=yes
+else
+ ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if ${ac_cv_prog_cc_g+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_c_werror_flag=$ac_c_werror_flag
+ ac_c_werror_flag=yes
+ ac_cv_prog_cc_g=no
+ CFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_g=yes
+else
+ CFLAGS=""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ ac_c_werror_flag=$ac_save_c_werror_flag
+ CFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if ${ac_cv_prog_cc_c89+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+ inside strings and character constants. */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+ test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+ x)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+ xno)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+ *)
+ CC="$CC $ac_cv_prog_cc_c89"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+for ac_prog in flex lex
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_LEX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$LEX"; then
+ ac_cv_prog_LEX="$LEX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_LEX="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+LEX=$ac_cv_prog_LEX
+if test -n "$LEX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LEX" >&5
+$as_echo "$LEX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$LEX" && break
+done
+test -n "$LEX" || LEX=":"
+
+if test "x$LEX" != "x:"; then
+ cat >conftest.l <<_ACEOF
+%%
+a { ECHO; }
+b { REJECT; }
+c { yymore (); }
+d { yyless (1); }
+e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */
+ yyless ((input () != 0)); }
+f { unput (yytext[0]); }
+. { BEGIN INITIAL; }
+%%
+#ifdef YYTEXT_POINTER
+extern char *yytext;
+#endif
+int
+main (void)
+{
+ return ! yylex () + ! yywrap ();
+}
+_ACEOF
+{ { ac_try="$LEX conftest.l"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$LEX conftest.l") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking lex output file root" >&5
+$as_echo_n "checking lex output file root... " >&6; }
+if ${ac_cv_prog_lex_root+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+if test -f lex.yy.c; then
+ ac_cv_prog_lex_root=lex.yy
+elif test -f lexyy.c; then
+ ac_cv_prog_lex_root=lexyy
+else
+ as_fn_error $? "cannot find output from $LEX; giving up" "$LINENO" 5
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5
+$as_echo "$ac_cv_prog_lex_root" >&6; }
+LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root
+
+if test -z "${LEXLIB+set}"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex library" >&5
+$as_echo_n "checking lex library... " >&6; }
+if ${ac_cv_lib_lex+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ac_save_LIBS=$LIBS
+ ac_cv_lib_lex='none needed'
+ for ac_lib in '' -lfl -ll; do
+ LIBS="$ac_lib $ac_save_LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+`cat $LEX_OUTPUT_ROOT.c`
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_lex=$ac_lib
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ test "$ac_cv_lib_lex" != 'none needed' && break
+ done
+ LIBS=$ac_save_LIBS
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lex" >&5
+$as_echo "$ac_cv_lib_lex" >&6; }
+ test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yytext is a pointer" >&5
+$as_echo_n "checking whether yytext is a pointer... " >&6; }
+if ${ac_cv_prog_lex_yytext_pointer+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # POSIX says lex can declare yytext either as a pointer or an array; the
+# default is implementation-dependent. Figure out which it is, since
+# not all implementations provide the %pointer and %array declarations.
+ac_cv_prog_lex_yytext_pointer=no
+ac_save_LIBS=$LIBS
+LIBS="$LEXLIB $ac_save_LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+ #define YYTEXT_POINTER 1
+`cat $LEX_OUTPUT_ROOT.c`
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_prog_lex_yytext_pointer=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_save_LIBS
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_yytext_pointer" >&5
+$as_echo "$ac_cv_prog_lex_yytext_pointer" >&6; }
+if test $ac_cv_prog_lex_yytext_pointer = yes; then
+
+$as_echo "#define YYTEXT_POINTER 1" >>confdefs.h
+
+fi
+rm -f conftest.l $LEX_OUTPUT_ROOT.c
+
+fi
+if test Z"$LEX" != Zflex; then
+cat <<EOF
+*******************************************************************
+You do not seem to have flex. While flex is not required to build
+libconfig, you may need it to regenerate the lexer if you change
+the scanner.l file. Flex 2.5.33 or newer is recommended.
+*******************************************************************
+EOF
+fi
+
+for ac_prog in 'bison -y' byacc
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_YACC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$YACC"; then
+ ac_cv_prog_YACC="$YACC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_YACC="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+YACC=$ac_cv_prog_YACC
+if test -n "$YACC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5
+$as_echo "$YACC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$YACC" && break
+done
+test -n "$YACC" || YACC="yacc"
+
+if test Z"$YACC" != "Zbison -y"; then
+cat <<EOF
+*******************************************************************
+You do not seem to have bison. While bison is not required to build
+libconfig, you may need it to regenerate the parser if you change
+the grammar.y file.
+*******************************************************************
+EOF
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for compiler switch to enable full C/C++ warnings" >&5
+$as_echo_n "checking for compiler switch to enable full C/C++ warnings... " >&6; };
+
+
+case "${CC}" in
+
+gcc)
+ warn_c_sw="-Wall -Wshadow -Wextra -Wdeclaration-after-statement -Wno-unused-parameter";;
+*)
+ warn_c_sw="";;
+esac
+
+if test -n "${warn_c_sw}";
+then
+ CFLAGS="${CFLAGS} ${warn_c_sw}";
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${warn_c_sw}" >&5
+$as_echo "${warn_c_sw}" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: (cannot determine)" >&5
+$as_echo "(cannot determine)" >&6; }
+fi;
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_header_stdc=yes
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then :
+ :
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+for ac_header in unistd.h stdint.h xlocale.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
+$as_echo_n "checking for an ANSI C-conforming const... " >&6; }
+if ${ac_cv_c_const+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+#ifndef __cplusplus
+ /* Ultrix mips cc rejects this sort of thing. */
+ typedef int charset[2];
+ const charset cs = { 0, 0 };
+ /* SunOS 4.1.1 cc rejects this. */
+ char const *const *pcpcc;
+ char **ppc;
+ /* NEC SVR4.0.2 mips cc rejects this. */
+ struct point {int x, y;};
+ static struct point const zero = {0,0};
+ /* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in
+ an arm of an if-expression whose if-part is not a constant
+ expression */
+ const char *g = "string";
+ pcpcc = &g + (g ? g-g : 0);
+ /* HPUX 7.0 cc rejects these. */
+ ++pcpcc;
+ ppc = (char**) pcpcc;
+ pcpcc = (char const *const *) ppc;
+ { /* SCO 3.2v4 cc rejects this sort of thing. */
+ char tx;
+ char *t = &tx;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+ if (s) return 0;
+ }
+ { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+ }
+ { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+ }
+ { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; } bx;
+ struct s *b = &bx; b->j = 5;
+ }
+ { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+ if (!foo) return 0;
+ }
+ return !cs[0] && !zero.x;
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_c_const=yes
+else
+ ac_cv_c_const=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5
+$as_echo "$ac_cv_c_const" >&6; }
+if test $ac_cv_c_const = no; then
+
+$as_echo "#define const /**/" >>confdefs.h
+
+fi
+
+
+
+for ac_func in newlocale uselocale freelocale
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+ac_config_files="$ac_config_files doc/Makefile gen/Makefile"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) { eval $ac_var=; unset $ac_var;} ;;
+ esac ;;
+ esac
+ done
+
+ (set) 2>&1 |
+ case $as_nl`(ac_space=' '; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ # `set' does not quote correctly, so add quotes: double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \.
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;; #(
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+) |
+ sed '
+ /^ac_cv_env_/b end
+ t clear
+ :clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+ if test -w "$cache_file"; then
+ if test "x$cache_file" != "x/dev/null"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+ if test ! -f "$cache_file" || test -h "$cache_file"; then
+ cat confcache >"$cache_file"
+ else
+ case $cache_file in #(
+ */* | ?:*)
+ mv -f confcache "$cache_file"$$ &&
+ mv -f "$cache_file"$$ "$cache_file" ;; #(
+ *)
+ mv -f confcache "$cache_file" ;;
+ esac
+ fi
+ fi
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+#
+# If the first sed substitution is executed (which looks for macros that
+# take arguments), then branch to the quote section. Otherwise,
+# look for a macro that doesn't take arguments.
+ac_script='
+:mline
+/\\$/{
+ N
+ s,\\\n,,
+ b mline
+}
+t clear
+:clear
+s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g
+t quote
+s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g
+t quote
+b any
+:quote
+s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g
+s/\[/\\&/g
+s/\]/\\&/g
+s/\$/$$/g
+H
+:any
+${
+ g
+ s/^\n//
+ s/\n/ /g
+ p
+}
+'
+DEFS=`sed -n "$ac_script" confdefs.h`
+
+
+ac_libobjs=
+ac_ltlibobjs=
+U=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+ ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
+ # will be set to the directory where LIBOBJS objects are built.
+ as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+ as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: "${CONFIG_STATUS=./config.status}"
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='print -r --'
+ as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in #(
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there. '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+ as_status=$1; test $as_status -eq 0 && as_status=1
+ if test "$4"; then
+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+ fi
+ $as_echo "$as_me: error: $2" >&2
+ as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+ return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+ set +e
+ as_fn_set_status $1
+ exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+ { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+ eval 'as_fn_append ()
+ {
+ eval $1+=\$2
+ }'
+else
+ as_fn_append ()
+ {
+ eval $1=\$$1\$2
+ }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+ eval 'as_fn_arith ()
+ {
+ as_val=$(( $* ))
+ }'
+else
+ as_fn_arith ()
+ {
+ as_val=`expr "$@" || test $? -eq 1`
+ }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+ case `echo 'xy\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ xy) ECHO_C='\c';;
+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
+ ECHO_T=' ';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -pR'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -pR'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -pR'
+ fi
+else
+ as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || eval $as_mkdir_p || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p='mkdir -p "$as_dir"'
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by libconfig $as_me 1.4.9, which was
+generated by GNU Autoconf 2.69. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration. Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number and configuration settings, then exit
+ --config print configuration, then exit
+ -q, --quiet, --silent
+ do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+
+Configuration files:
+$config_files
+
+Report bugs to <hyperrealm@gmail.com>.
+libconfig home page: <http://www.hyperrealm.com/main.php?s=libconfig>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+libconfig config.status 1.4.9
+configured by $0, generated by GNU Autoconf 2.69,
+ with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=?*)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ --*=)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=
+ ac_shift=:
+ ;;
+ *)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+ $as_echo "$ac_cs_version"; exit ;;
+ --config | --confi | --conf | --con | --co | --c )
+ $as_echo "$ac_cs_config"; exit ;;
+ --debug | --debu | --deb | --de | --d | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ '') as_fn_error $? "missing file argument" ;;
+ esac
+ as_fn_append CONFIG_FILES " '$ac_optarg'"
+ ac_need_defaults=false;;
+ --he | --h | --help | --hel | -h )
+ $as_echo "$ac_cs_usage"; exit ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) as_fn_error $? "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+ *) as_fn_append ac_config_targets " $1"
+ ac_need_defaults=false ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+ shift
+ \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+ CONFIG_SHELL='$SHELL'
+ export CONFIG_SHELL
+ exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+ $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+ case $ac_config_target in
+ "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
+ "gen/Makefile") CONFIG_FILES="$CONFIG_FILES gen/Makefile" ;;
+
+ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+ esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+ tmp= ac_tmp=
+ trap 'exit_status=$?
+ : "${ac_tmp:=$tmp}"
+ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+' 0
+ trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+ test -d "$tmp"
+} ||
+{
+ tmp=./conf$$-$RANDOM
+ (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+ eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+ ac_cs_awk_cr='\\r'
+else
+ ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+ echo "cat >conf$$subs.awk <<_ACEOF" &&
+ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+ echo "_ACEOF"
+} >conf$$subs.sh ||
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+ . ./conf$$subs.sh ||
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+
+ ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+ if test $ac_delim_n = $ac_delim_num; then
+ break
+ elif $ac_last_try; then
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+ N
+ s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
+ for (key in S) S_is_set[key] = 1
+ FS = ""
+
+}
+{
+ line = $ 0
+ nfields = split(line, field, "@")
+ substed = 0
+ len = length(field[1])
+ for (i = 2; i < nfields; i++) {
+ key = field[i]
+ keylen = length(key)
+ if (S_is_set[key]) {
+ value = S[key]
+ line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+ len += length(value) + length(field[++i])
+ substed = 1
+ } else
+ len += 1 + keylen
+ }
+
+ print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+ cat
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
+ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
+h
+s///
+s/^/:/
+s/[ ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[ ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[ ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+
+eval set X " :F $CONFIG_FILES "
+shift
+for ac_tag
+do
+ case $ac_tag in
+ :[FHLC]) ac_mode=$ac_tag; continue;;
+ esac
+ case $ac_mode$ac_tag in
+ :[FHL]*:*);;
+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+ :[FH]-) ac_tag=-:-;;
+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+ esac
+ ac_save_IFS=$IFS
+ IFS=:
+ set x $ac_tag
+ IFS=$ac_save_IFS
+ shift
+ ac_file=$1
+ shift
+
+ case $ac_mode in
+ :L) ac_source=$1;;
+ :[FH])
+ ac_file_inputs=
+ for ac_f
+ do
+ case $ac_f in
+ -) ac_f="$ac_tmp/stdin";;
+ *) # Look for the file first in the build tree, then in the source tree
+ # (if the path is not absolute). The absolute path cannot be DOS-style,
+ # because $ac_f cannot contain `:'.
+ test -f "$ac_f" ||
+ case $ac_f in
+ [\\/$]*) false;;
+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+ esac ||
+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+ esac
+ case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+ as_fn_append ac_file_inputs " '$ac_f'"
+ done
+
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ configure_input='Generated from '`
+ $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+ `' by configure.'
+ if test x"$ac_file" != x-; then
+ configure_input="$ac_file. $configure_input"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+ fi
+ # Neutralize special characters interpreted by sed in replacement strings.
+ case $configure_input in #(
+ *\&* | *\|* | *\\* )
+ ac_sed_conf_input=`$as_echo "$configure_input" |
+ sed 's/[\\\\&|]/\\\\&/g'`;; #(
+ *) ac_sed_conf_input=$configure_input;;
+ esac
+
+ case $ac_tag in
+ *:-:* | *:-) cat >"$ac_tmp/stdin" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+ esac
+ ;;
+ esac
+
+ ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ as_dir="$ac_dir"; as_fn_mkdir_p
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+ case $ac_mode in
+ :F)
+ #
+ # CONFIG_FILE
+ #
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+ p
+ q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ ac_datarootdir_hack='
+ s&@datadir@&$datadir&g
+ s&@docdir@&$docdir&g
+ s&@infodir@&$infodir&g
+ s&@localedir@&$localedir&g
+ s&@mandir@&$mandir&g
+ s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+ { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
+ "$ac_tmp/out"`; test -z "$ac_out"; } &&
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined" >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined" >&2;}
+
+ rm -f "$ac_tmp/stdin"
+ case $ac_file in
+ -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+ *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+ esac \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+
+
+
+ esac
+
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || as_fn_exit 1
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff --git a/3rdparty/libconfig/extra/configure.ac b/3rdparty/libconfig/extra/configure.ac
new file mode 100644
index 000000000..622abb3e2
--- /dev/null
+++ b/3rdparty/libconfig/extra/configure.ac
@@ -0,0 +1,79 @@
+dnl Process this file with autoconf to produce a configure script.
+
+AC_INIT(libconfig, 1.4.9, hyperrealm@gmail.com, libconfig,
+ [http://www.hyperrealm.com/main.php?s=libconfig])
+#AC_CANONICAL_TARGET
+
+AC_MSG_NOTICE([libconfig - made with pride in California])
+
+AC_PROG_MAKE_SET
+
+AC_DEFINE_UNQUOTED(TARGET, "${target}", [Configured target name.])
+
+# Enable GNU extensions.
+AC_GNU_SOURCE
+
+dnl Checks for programs.
+AC_PROG_CC
+
+AC_PROG_LEX
+if test Z"$LEX" != Zflex; then
+cat <<EOF
+*******************************************************************
+You do not seem to have flex. While flex is not required to build
+libconfig, you may need it to regenerate the lexer if you change
+the scanner.l file. Flex 2.5.33 or newer is recommended.
+*******************************************************************
+EOF
+fi
+
+AC_PROG_YACC
+if test Z"$YACC" != "Zbison -y"; then
+cat <<EOF
+*******************************************************************
+You do not seem to have bison. While bison is not required to build
+libconfig, you may need it to regenerate the parser if you change
+the grammar.y file.
+*******************************************************************
+EOF
+fi
+
+AC_MSG_CHECKING([for compiler switch to enable full C/C++ warnings]);
+
+dnl Checks for libraries
+
+dnl Enable warnings, if we can determine an appropriate switch...
+case "${CC}" in
+
+gcc)
+ warn_c_sw="-Wall -Wshadow -Wextra -Wdeclaration-after-statement -Wno-unused-parameter";;
+*)
+ warn_c_sw="";;
+esac
+
+if test -n "${warn_c_sw}";
+then
+ CFLAGS="${CFLAGS} ${warn_c_sw}";
+ AC_MSG_RESULT([${warn_c_sw}])
+else
+ AC_MSG_RESULT([(cannot determine)])
+fi;
+
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS(unistd.h stdint.h xlocale.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+
+dnl Checks for functions
+
+AC_CHECK_FUNCS([newlocale uselocale freelocale])
+
+dnl Checks for library functions.
+
+AC_OUTPUT(
+ doc/Makefile
+ gen/Makefile
+ )
diff --git a/3rdparty/libconfig/extra/doc/LGPL.texi b/3rdparty/libconfig/extra/doc/LGPL.texi
new file mode 100644
index 000000000..e371ac0d0
--- /dev/null
+++ b/3rdparty/libconfig/extra/doc/LGPL.texi
@@ -0,0 +1,590 @@
+@c \input texinfo.tex @c -*-texinfo-*-
+@c
+@c %**start of header
+
+@c All text is ignored before the setfilename.
+@setfilename LGPL.info
+
+@center GNU LESSER GENERAL PUBLIC LICENSE
+@center Version 2.1, February 1999
+
+@sp 1
+
+Copyright @copyright{} 1991, 1999 Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Everyone is permitted to copy and distribute verbatim copies of this
+license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+as the successor of the GNU Library Public License, version 2, hence the
+version number 2.1.]
+
+@sp 1
+@center Preamble
+@sp 1
+
+The licenses for most software are designed to take away your freedom to
+share and change it. By contrast, the GNU General Public Licenses are
+intended to guarantee your freedom to share and change free software--to
+make sure the software is free for all its users.
+
+This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the Free
+Software Foundation and other authors who decide to use it. You can use
+it too, but we suggest you first think carefully about whether this
+license or the ordinary General Public License is the better strategy to
+use in any particular case, based on the explanations below.
+
+When we speak of free software, we are referring to freedom of use, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish); that you receive source code or can get it if
+you want it; that you can change the software and use pieces of it in
+new free programs; and that you are informed that you can do these
+things.
+
+To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+For example, if you distribute copies of the library, whether gratis or
+for a fee, you must give the recipients all the rights that we gave you.
+You must make sure that they, too, receive or can get the source code.
+If you link other code with the library, you must provide complete
+object files to the recipients, so that they can relink them with the
+library after making changes to the library and recompiling it. And you
+must show them these terms so they know their rights.
+
+We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+To protect each distributor, we want to make it very clear that there is
+no warranty for the free library. Also, if the library is modified by
+someone else and passed on, the recipients should know that what they
+have is not the original version, so that the original author's
+reputation will not be affected by problems that might be introduced by
+others.
+
+Finally, software patents pose a constant threat to the existence of any
+free program. We wish to make sure that a company cannot effectively
+restrict the users of a free program by obtaining a restrictive license
+from a patent holder. Therefore, we insist that any patent license
+obtained for a version of the library must be consistent with the full
+freedom of use specified in this license.
+
+Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License. This license, the GNU Lesser General Public
+License, applies to certain designated libraries, and is quite different
+from the ordinary General Public License. We use this license for
+certain libraries in order to permit linking those libraries into
+non-free programs.
+
+When a program is linked with a library, whether statically or using a
+shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the entire
+combination fits its criteria of freedom. The Lesser General Public
+License permits more lax criteria for linking other code with the
+library.
+
+We call this license the ``Lesser'' General Public License because it does
+Less to protect the user's freedom than the ordinary General Public
+License. It also provides other free software developers Less of an
+advantage over competing non-free programs. These disadvantages are the
+reason we use the ordinary General Public License for many libraries.
+However, the Lesser license provides advantages in certain special
+circumstances.
+
+For example, on rare occasions, there may be a special need to encourage
+the widest possible use of a certain library, so that it becomes a
+de-facto standard. To achieve this, non-free programs must be allowed
+to use the library. A more frequent case is that a free library does
+the same job as widely used non-free libraries. In this case, there is
+little to gain by limiting the free library to free software only, so we
+use the Lesser General Public License.
+
+In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of free
+software. For example, permission to use the GNU C Library in non-free
+programs enables many more people to use the whole GNU operating system,
+as well as its variant, the GNU/Linux operating system.
+
+Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is linked
+with the Library has the freedom and the wherewithal to run that program
+using a modified version of the Library.
+
+The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+``work based on the library'' and a ``work that uses the library''. The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+@page
+
+@center GNU LESSER GENERAL PUBLIC LICENSE
+@center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+@enumerate 0
+
+@sp 1
+@item
+This License Agreement applies to any software library or other program
+which contains a notice placed by the copyright holder or other
+authorized party saying it may be distributed under the terms of this
+Lesser General Public License (also called ``this License''). Each
+licensee is addressed as ``you''.
+
+A ``library'' means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+The ``Library'', below, refers to any such software library or work which
+has been distributed under these terms. A ``work based on the Library''
+means either the Library or any derivative work under copyright law:
+that is to say, a work containing the Library or a portion of it, either
+verbatim or with modifications and/or translated straightforwardly into
+another language. (Hereinafter, translation is included without
+limitation in the term ``modification''.)
+
+``Source code'' for a work means the preferred form of the work for making
+modifications to it. For a library, complete source code means all the
+source code for all modules it contains, plus any associated interface
+definition files, plus the scripts used to control compilation and
+installation of the library.
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of running
+a program using the Library is not restricted, and output from such a
+program is covered only if its contents constitute a work based on the
+Library (independent of the use of the Library in a tool for writing
+it). Whether that is true depends on what the Library does and what the
+program that uses the Library does.
+
+@sp 1
+@item
+You may copy and distribute verbatim copies of the Library's complete
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the notices
+that refer to this License and to the absence of any warranty; and
+distribute a copy of this License along with the Library.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+@sp 1
+@item
+You may modify your copy or copies of the Library or any portion of it,
+thus forming a work based on the Library, and copy and distribute such
+modifications or work under the terms of Section 1 above, provided that
+you also meet all of these conditions:
+
+@enumerate a
+
+@item
+The modified work must itself be a software library.
+
+@sp 1
+@item
+You must cause the files modified to carry prominent notices stating
+that you changed the files and the date of any change.
+
+@sp 1
+@item
+You must cause the whole of the work to be licensed at no charge to all
+third parties under the terms of this License.
+
+@sp 1
+@item
+If a facility in the modified Library refers to a function or a table of
+data to be supplied by an application program that uses the facility,
+other than as an argument passed when the facility is invoked, then you
+must make a good faith effort to ensure that, in the event an
+application does not supply such function or table, the facility still
+operates, and performs whatever part of its purpose remains meaningful.
+
+(For example, a function in a library to compute square roots has a
+purpose that is entirely well-defined independent of the application.
+Therefore, Subsection 2d requires that any application-supplied function
+or table used by this function must be optional: if the application does
+not supply it, the square root function must still compute square
+roots.)
+
+@end enumerate
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library, and
+can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based on
+the Library, the distribution of the whole must be on the terms of this
+License, whose permissions for other licensees extend to the entire
+whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of a
+storage or distribution medium does not bring the other work under the
+scope of this License.
+
+@sp 1
+@item
+You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so that
+they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+Once this change is made in a given copy, it is irreversible for that
+copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+This option is useful when you wish to copy part of the code of the
+Library into a program that is not a library.
+
+@sp 1
+@item
+You may copy and distribute the Library (or a portion or derivative of
+it, under Section 2) in object code or executable form under the terms
+of Sections 1 and 2 above provided that you accompany it with the
+complete corresponding machine-readable source code, which must be
+distributed under the terms of Sections 1 and 2 above on a medium
+customarily used for software interchange.
+
+If distribution of object code is made by offering access to copy from a
+designated place, then offering equivalent access to copy the source
+code from the same place satisfies the requirement to distribute the
+source code, even though third parties are not compelled to copy the
+source along with the object code.
+
+@sp 1
+@item
+A program that contains no derivative of any portion of the Library, but
+is designed to work with the Library by being compiled or linked with
+it, is called a ``work that uses the Library''. Such a work, in
+isolation, is not a derivative work of the Library, and therefore falls
+outside the scope of this License.
+
+However, linking a ``work that uses the Library'' with the Library creates
+an executable that is a derivative of the Library (because it contains
+portions of the Library), rather than a ``work that uses the library''.
+The executable is therefore covered by this License. Section 6 states
+terms for distribution of such executables.
+
+When a ``work that uses the Library'' uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be linked
+without the Library, or if the work is itself a library. The threshold
+for this to be true is not precisely defined by law.
+
+If such an object file uses only numerical parameters, data structure
+layouts and accessors, and small macros and small inline functions (ten
+lines or less in length), then the use of the object file is
+unrestricted, regardless of whether it is legally a derivative work.
+(Executables containing this object code plus portions of the Library
+will still fall under Section 6.)
+
+Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6, whether
+or not they are linked directly with the Library itself.
+
+@sp 1
+@item
+As an exception to the Sections above, you may also combine or link a
+``work that uses the Library'' with the Library to produce a work
+containing portions of the Library, and distribute that work under terms
+of your choice, provided that the terms permit modification of the work
+for the customer's own use and reverse engineering for debugging such
+modifications.
+
+You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+@enumerate a
+
+@sp 1
+@item
+Accompany the work with the complete corresponding machine-readable
+source code for the Library including whatever changes were used in the
+work (which must be distributed under Sections 1 and 2 above); and, if
+the work is an executable linked with the Library, with the complete
+machine-readable ``work that uses the Library'', as object code and/or
+source code, so that the user can modify the Library and then relink to
+produce a modified executable containing the modified Library. (It is
+understood that the user who changes the contents of definitions files
+in the Library will not necessarily be able to recompile the application
+to use the modified definitions.)
+
+@sp 1
+@item
+Use a suitable shared library mechanism for linking with the Library. A
+suitable mechanism is one that (1) uses at run time a copy of the
+library already present on the user's computer system, rather than
+copying library functions into the executable, and (2) will operate
+properly with a modified version of the library, if the user installs
+one, as long as the modified version is interface-compatible with the
+version that the work was made with.
+
+@sp 1
+@item
+Accompany the work with a written offer, valid for at least three years,
+to give the same user the materials specified in Subsection 6a, above,
+for a charge no more than the cost of performing this distribution.
+
+@sp 1
+@item
+If distribution of the work is made by offering access to copy from a
+designated place, offer equivalent access to copy the above specified
+materials from the same place.
+
+@sp 1
+@item
+Verify that the user has already received a copy of these materials or
+that you have already sent this user a copy.
+
+@end enumerate
+
+For an executable, the required form of the ``work that uses the Library''
+must include any data and utility programs needed for reproducing the
+executable from it. However, as a special exception, the materials to
+be distributed need not include anything that is normally distributed
+(in either source or binary form) with the major components (compiler,
+kernel, and so on) of the operating system on which the executable runs,
+unless that component itself accompanies the executable.
+
+It may happen that this requirement contradicts the license restrictions
+of other proprietary libraries that do not normally accompany the
+operating system. Such a contradiction means you cannot use both them
+and the Library together in an executable that you distribute.
+
+@sp 1
+@item
+You may place library facilities that are a work based on the Library
+side-by-side in a single library together with other library facilities
+not covered by this License, and distribute such a combined library,
+provided that the separate distribution of the work based on the Library
+and of the other library facilities is otherwise permitted, and provided
+that you do these two things:
+
+@enumerate a
+
+@sp 1
+@item
+Accompany the combined library with a copy of the same work based on the
+Library, uncombined with any other library facilities. This must be
+distributed under the terms of the Sections above.
+
+@sp 1
+@item
+Give prominent notice with the combined library of the fact that part of
+it is a work based on the Library, and explaining where to find the
+accompanying uncombined form of the same work.
+
+@end enumerate
+
+@sp 1
+@item
+You may not copy, modify, sublicense, link with, or distribute the
+Library except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense, link with, or distribute the
+Library is void, and will automatically terminate your rights under this
+License. However, parties who have received copies, or rights, from you
+under this License will not have their licenses terminated so long as
+such parties remain in full compliance.
+
+@sp 1
+@item
+You are not required to accept this License, since you have not signed
+it. However, nothing else grants you permission to modify or distribute
+the Library or its derivative works. These actions are prohibited by
+law if you do not accept this License. Therefore, by modifying or
+distributing the Library (or any work based on the Library), you
+indicate your acceptance of this License to do so, and all its terms and
+conditions for copying, distributing or modifying the Library or works
+based on it.
+
+@sp 1
+@item
+Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+@sp 1
+@item
+If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent license
+would not permit royalty-free redistribution of the Library by all those
+who receive copies directly or indirectly through you, then the only way
+you could satisfy both it and this License would be to refrain entirely
+from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply, and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is implemented
+by public license practices. Many people have made generous
+contributions to the wide range of software distributed through that
+system in reliance on consistent application of that system; it is up to
+the author/donor to decide if he or she is willing to distribute
+software through any other system and a licensee cannot impose that
+choice.
+
+This section is intended to make thoroughly clear what is believed to be
+a consequence of the rest of this License.
+
+@sp 1
+@item
+If the distribution and/or use of the Library is restricted in certain
+countries either by patents or by copyrighted interfaces, the original
+copyright holder who places the Library under this License may add an
+explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+@sp 1
+@item
+The Free Software Foundation may publish revised and/or new versions of
+the Lesser General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in
+detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and ``any
+later version'', you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a license
+version number, you may choose any version ever published by the Free
+Software Foundation.
+
+@sp 1
+@item
+If you wish to incorporate parts of the Library into other free programs
+whose distribution conditions are incompatible with these, write to the
+author to ask for permission. For software which is copyrighted by the
+Free Software Foundation, write to the Free Software Foundation; we
+sometimes make exceptions for this. Our decision will be guided by the
+two goals of preserving the free status of all derivatives of our free
+software and of promoting the sharing and reuse of software generally.
+
+@sp 1
+@center NO WARRANTY
+@sp 1
+
+@item
+BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
+THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE LIBRARY ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER
+EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
+ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH
+YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+@sp 1
+@item
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR
+DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL
+DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY
+(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
+INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF
+THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR
+OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+@end enumerate
+
+@sp 1
+@center END OF TERMS AND CONDITIONS
+@sp 1
+@page
+@center How to Apply These Terms to Your New Libraries
+
+If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of
+the ordinary General Public License).
+
+To apply these terms, attach the following notices to the library. It
+is safest to attach them to the start of each source file to most
+effectively convey the exclusion of warranty; and each file should have
+at least the ``copyright'' line and a pointer to where the full notice is
+found.
+
+@format
+@t{
+<one line to give the library's name and a brief idea of what it does.>
+Copyright (C) <year> <name of author>
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+}
+@end format
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a ``copyright disclaimer'' for the library, if
+necessary. Here is a sample; alter the names:
+
+@format
+@t{
+Yoyodyne, Inc., hereby disclaims all copyright interest in the
+library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+<signature of Ty Coon>, 1 April 1990
+Ty Coon, President of Vice
+}
+@end format
+
+That's all there is to it!
+
+@c @bye
diff --git a/3rdparty/libconfig/extra/doc/Makefile b/3rdparty/libconfig/extra/doc/Makefile
new file mode 100644
index 000000000..fd84597a6
--- /dev/null
+++ b/3rdparty/libconfig/extra/doc/Makefile
@@ -0,0 +1,18 @@
+HTMLS = libconfig.html
+TEXINFOS = libconfig.texi
+MAKEINFOHTML = $(MAKEINFO) --html
+MAKEINFO = makeinfo
+
+all: html
+
+.SUFFIXES: .html .texi
+
+libconfig.html: $(TEXINFOS)
+
+clean:
+ @-test -z "$(HTMLS)" || rm -rf libconfig.html
+
+.PHONY: all clean html
+
+html: $(HTMLS)
+ $(MAKEINFOHTML) --no-split $(TEXINFOS)
diff --git a/3rdparty/libconfig/extra/doc/Makefile.in b/3rdparty/libconfig/extra/doc/Makefile.in
new file mode 100644
index 000000000..fd84597a6
--- /dev/null
+++ b/3rdparty/libconfig/extra/doc/Makefile.in
@@ -0,0 +1,18 @@
+HTMLS = libconfig.html
+TEXINFOS = libconfig.texi
+MAKEINFOHTML = $(MAKEINFO) --html
+MAKEINFO = makeinfo
+
+all: html
+
+.SUFFIXES: .html .texi
+
+libconfig.html: $(TEXINFOS)
+
+clean:
+ @-test -z "$(HTMLS)" || rm -rf libconfig.html
+
+.PHONY: all clean html
+
+html: $(HTMLS)
+ $(MAKEINFOHTML) --no-split $(TEXINFOS)
diff --git a/3rdparty/libconfig/extra/doc/libconfig.texi b/3rdparty/libconfig/extra/doc/libconfig.texi
new file mode 100644
index 000000000..52dca20fc
--- /dev/null
+++ b/3rdparty/libconfig/extra/doc/libconfig.texi
@@ -0,0 +1,1910 @@
+\input texinfo.tex @c -*-texinfo-*-
+@c
+@c %**start of header
+
+@c All text is ignored before the setfilename.
+@setfilename libconfig.info
+@settitle libconfig
+
+@set edition 1.4.9
+@set update-date 28 September 2012
+@set subtitle-text A Library For Processing Structured Configuration Files
+@set author-text Mark A.@: Lindner
+
+@comment %**end of header
+
+@dircategory Software libraries
+@direntry
+* libconfig: (libconfig). A Library For Processing Structured Configuration Files
+@end direntry
+
+
+@tex
+\global\emergencystretch = .3\hsize
+@end tex
+
+@setchapternewpage odd
+
+@titlepage
+
+@title libconfig
+@subtitle @value{subtitle-text}
+@subtitle Version @value{edition}
+@subtitle @value{update-date}
+
+@author @value{author-text}
+
+@page
+@vskip 0pt plus 1filll
+Copyright @copyright{} 2005-2012 Mark A Lindner
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the entire
+resulting derived work is distributed under the terms of a permission
+notice identical to this one.
+
+@end titlepage
+
+@c Give the HTML output a title page that somewhat resembles the printed one
+@ifhtml
+@html
+<hr noshade size=6 color="black">
+<div align=right>@value{subtitle-text}<br>
+Version @value{edition}<br>
+@value{update-date}</div>
+<br><br><br><br>
+<font size=+1>@value{author-text}</font>
+<hr size=3 noshade color="black">
+<br><br>
+@end html
+@end ifhtml
+
+@contents
+
+@ifnottex
+@node Top
+@comment node-name, next, previous, up
+@top libconfig
+@end ifnottex
+
+@menu
+* Introduction::
+* Configuration Files::
+* The C API::
+* The C++ API::
+* Example Programs::
+* Configuration File Grammar::
+* License::
+* Function Index::
+* Type Index::
+* Concept Index::
+@end menu
+
+@node Introduction, Configuration Files, Top, Top
+@comment node-name, next, previous, up
+@menu
+* Why Another Configuration File Library?::
+* Using the Library from a C Program::
+* Using the Library from a C++ Program::
+* Multithreading Issues::
+* Internationalization Issues::
+* Compiling Using pkg-config::
+* Version Test Macros::
+@end menu
+@chapter Introduction
+
+@i{Libconfig} is a library for reading, manipulating, and writing
+structured configuration files. The library features a fully
+reentrant parser and includes bindings for both the C and C++
+programming languages.
+
+The library runs on modern POSIX-compilant systems, such as Linux,
+Solaris, and Mac OS X (Darwin), as well as on Microsoft Windows
+2000/XP and later (with either Microsoft Visual Studio 2005 or later,
+or the GNU toolchain via the MinGW environment).
+
+@node Why Another Configuration File Library?, Using the Library from a C Program, , Introduction
+@comment node-name, next, previous, up
+@section Why Another Configuration File Library?
+
+There are several open-source configuration file libraries available
+as of this writing. This library was written because each of those
+libraries falls short in one or more ways. The main features of
+@i{libconfig} that set it apart from the other libraries are:
+
+@itemize @bullet
+
+@item A fully reentrant parser. Independent configurations can be parsed in concurrent threads at the same time.
+
+@item Both C @i{and} C++ bindings, as well as hooks to allow for the creation of wrappers in other languages.
+
+@item A simple, structured configuration file format that is more
+readable and compact than XML and more flexible than the obsolete but
+prevalent Windows ``INI'' file format.
+
+@item A low-footprint implementation (just 37K for the C library and 76K for
+the C++ library) that is suitable for memory-constrained systems.
+
+@item Proper documentation.
+
+@end itemize
+
+@node Using the Library from a C Program, Using the Library from a C++ Program, Why Another Configuration File Library?, Introduction
+@comment node-name, next, previous, up
+@section Using the Library from a C Program
+
+To use the library from C code, include the following preprocessor
+directive in your source files:
+
+@sp 1
+@smallexample
+#include <libconfig.h>
+@end smallexample
+@sp 1
+
+To link with the library, specify @samp{-lconfig} as an argument to the
+linker.
+
+@node Using the Library from a C++ Program, Multithreading Issues, Using the Library from a C Program, Introduction
+@comment node-name, next, previous, up
+@section Using the Library from a C++ Program
+
+To use the library from C++, include the following preprocessor
+directive in your source files:
+
+@sp 1
+@smallexample
+#include <libconfig.h++>
+@end smallexample
+@sp 1
+
+Or, alternatively:
+
+@sp 1
+@smallexample
+#include <libconfig.hh>
+@end smallexample
+@sp 1
+@page
+The C++ API classes are defined in the namespace @samp{libconfig}, hence the
+following statement may optionally be used:
+
+@sp 1
+@smallexample
+using namespace libconfig;
+@end smallexample
+@sp 1
+
+To link with the library, specify @samp{-lconfig++} as an argument to
+the linker.
+
+@node Multithreading Issues, Internationalization Issues, Using the Library from a C++ Program, Introduction
+@comment node-name, next, previous, up
+@section Multithreading Issues
+
+@i{Libconfig} is fully @dfn{reentrant}; the functions in the library
+do not make use of global variables and do not maintain state between
+successive calls. Therefore two independent configurations may be safely
+manipulated concurrently by two distinct threads.
+
+@i{Libconfig} is not @dfn{thread-safe}. The library is not aware of
+the presence of threads and knows nothing about the host system's
+threading model. Therefore, if an instance of a configuration is to be
+accessed from multiple threads, it must be suitably protected by
+synchronization mechanisms like read-write locks or mutexes; the
+standard rules for safe multithreaded access to shared data must be
+observed.
+
+@i{Libconfig} is not @dfn{async-safe}. Calls should not be made into
+the library from signal handlers, because some of the C library
+routines that it uses may not be async-safe.
+
+@i{Libconfig} is not guaranteed to be @dfn{cancel-safe}. Since it is
+not aware of the host system's threading model, the library does not
+contain any thread cancellation points. In most cases this will not be
+an issue for multithreaded programs. However, be aware that some of
+the routines in the library (namely those that read/write
+configurations from/to files or streams) perform I/O using C library
+routines which may potentially block; whether or not these C library
+routines are cancel-safe depends on the host system.
+
+@node Internationalization Issues, Compiling Using pkg-config, Multithreading Issues, Introduction
+@comment node-name, next, previous, up
+@section Internationalization Issues
+
+@cindex Unicode
+@cindex UTF-8
+@i{Libconfig} does not natively support Unicode configuration files,
+but string values may contain Unicode text encoded in UTF-8; such
+strings will be treated as ordinary 8-bit ASCII text by the
+library. It is the responsibility of the calling program to perform
+the necessary conversions to/from wide (@t{wchar_t}) strings using the
+wide string conversion functions such as @t{mbsrtowcs()} and
+@t{wcsrtombs()} or the @t{iconv()} function of the @i{libiconv}
+library.
+
+@cindex locale
+The textual representation of a floating point value varies by
+locale. However, the @i{libconfig} grammar specifies that
+floating point values are represented using a period (`.') as the
+radix symbol; this is consistent with the grammar of most programming
+languages. When a configuration is read in or written out,
+@i{libconfig} temporarily changes the @t{LC_NUMERIC} category of the
+locale of the calling thread to the ``C'' locale to ensure consistent
+handling of floating point values regardless of the locale(s) in use
+by the calling program.
+
+Note that the MinGW environment does not (as of this writing) provide
+functions for changing the locale of the calling thread. Therefore,
+when using @i{libconfig} in that environment, the calling program is
+responsible for changing the @t{LC_NUMERIC} category of the locale to
+the "C" locale before reading or writing a configuration.
+
+@node Compiling Using pkg-config, Version Test Macros, Internationalization Issues, Introduction
+@comment node-name, next, previous, up
+@section Compiling Using pkg-config
+
+On UNIX systems you can use the @i{pkg-config} utility (version 0.20
+or later) to automatically select the appropriate compiler and linker
+switches for @i{libconfig}. Ensure that the environment variable
+@code{PKG_CONFIG_PATH} contains the absolute path to the
+@file{lib/pkgconfig} subdirectory of the @i{libconfig} installation. Then,
+you can compile and link C programs with @i{libconfig} as follows:
+
+@smallexample
+gcc `pkg-config --cflags libconfig` myprogram.c -o myprogram \
+ `pkg-config --libs libconfig`
+@end smallexample
+@sp 1
+
+And similarly, for C++ programs:
+
+@smallexample
+g++ `pkg-config --cflags libconfig++` myprogram.cpp -o myprogram \
+ `pkg-config --libs libconfig++`
+@end smallexample
+
+@sp 1
+Note the backticks in the above examples.
+
+When using @b{autoconf}, the @code{PKG_CHECK_MODULES} m4 macro may be used to check for the presence of a given version of @i{libconfig}, and set the appropriate Makefile variables automatically. For example:
+
+@smallexample
+PKG_CHECK_MODULES([LIBCONFIGXX], [libconfig++ >= 1.4],,
+ AC_MSG_ERROR([libconfig++ 1.4 or newer not found.])
+)
+@end smallexample
+
+In the above example, if @i{libconfig++} version 1.4 or newer is found,
+the Makefile variables @code{LIBCONFIGXX_LIBS} and @code{LIBCONFIGXX_CFLAGS} will be
+set to the appropriate compiler and linker flags for compiling with
+@i{libconfig}, and if it is not found, the configure script will abort
+with an error to that effect.
+
+@node Version Test Macros, , Compiling Using pkg-config, Introduction
+@comment node-name, next, previous, up
+@section Version Test Macros
+
+The @file{libconfig.h} header declares the following macros:
+
+@defmac LIBCONFIG_VER_MAJOR
+@defmacx LIBCONFIG_VER_MINOR
+@defmacx LIBCONFIG_VER_REVISION
+
+These macros represent the major version, minor version, and revision
+of the @i{libconfig} library. For example, in @i{libconfig} 1.4 these
+are defined as @samp{1}, @samp{4}, and @samp{0}, respectively. These
+macros can be used in preprocessor directives to determine which
+@i{libconfig} features and/or APIs are present. For example:
+
+@smallexample
+#if (((LIBCONFIG_VER_MAJOR == 1) && (LIBCONFIG_VER_MINOR >= 4)) \
+ || (LIBCONFIG_VER_MAJOR > 1))
+ /* use features present in libconfig 1.4 and later */
+#endif
+@end smallexample
+
+These macros were introduced in @i{libconfig} 1.4.
+
+@end defmac
+
+Similarly, the @file{libconfig.h++} header declares the following macros:
+
+@defmac LIBCONFIGXX_VER_MAJOR
+@defmacx LIBCONFIGXX_VER_MINOR
+@defmacx LIBCONFIGXX_VER_REVISION
+
+These macros represent the major version, minor version, and revision
+of the @i{libconfig++} library.
+
+@end defmac
+
+@node Configuration Files, The C API, Introduction, Top
+@comment node-name, next, previous, up
+@menu
+* Settings::
+* Groups::
+* Arrays::
+* Lists::
+* Integer Values::
+* 64-bit Integer Values::
+* Floating Point Values::
+* Boolean Values::
+* String Values::
+* Comments::
+* Include Directives::
+@end menu
+@chapter Configuration Files
+
+@i{Libconfig} supports structured, hierarchical configurations. These
+configurations can be read from and written to files and manipulated
+in memory.
+
+@cindex setting
+@cindex value
+@cindex scalar value
+@cindex array
+@cindex group
+@cindex list
+@cindex configuration
+A @dfn{configuration} consists of a group of @dfn{settings}, which
+associate names with values. A @dfn{value} can be one of the
+following:
+
+@itemize @bullet
+@item A @dfn{scalar value}: integer, 64-bit integer, floating-point number, boolean,
+or string
+@item An @dfn{array}, which is a sequence of scalar values, all of which must have the same type
+@item A @dfn{group}, which is a collection of settings
+@item A @dfn{list}, which is a sequence of values of any type, including other lists
+@end itemize
+
+Consider the following configuration file for a hypothetical GUI
+application, which illustrates all of the elements of the configuration
+file grammar.
+
+@sp 1
+@cartouche
+@smallexample
+# Example application configuration file
+
+version = "1.0";
+
+application:
+@{
+ window:
+ @{
+ title = "My Application";
+ size = @{ w = 640; h = 480; @};
+ pos = @{ x = 350; y = 250; @};
+ @};
+
+ list = ( ( "abc", 123, true ), 1.234, ( /* an empty list */) );
+
+ books = ( @{ title = "Treasure Island";
+ author = "Robert Louis Stevenson";
+ price = 29.95;
+ qty = 5; @},
+ @{ title = "Snow Crash";
+ author = "Neal Stephenson";
+ price = 9.99;
+ qty = 8; @} );
+
+ misc:
+ @{
+ pi = 3.141592654;
+ bigint = 9223372036854775807L;
+ columns = [ "Last Name", "First Name", "MI" ];
+ bitmask = 0x1FC3;
+ @};
+@};
+@end smallexample
+@end cartouche
+@sp 1
+
+@cindex path
+Settings can be uniquely identified within the configuration by a
+@dfn{path}. The path is a dot-separated sequence of names, beginning
+at a top-level group and ending at the setting itself. Each name in
+the path is the name of a setting; if the setting has no name because
+it is an element in a list or array, an integer index in square
+brackets can be used as the name.
+
+For example, in our hypothetical configuration file, the path to the
+@code{x} setting is @code{application.window.pos.x}; the path to the
+@code{version} setting is simply @code{version}; and the path to the
+@code{title} setting of the second book in the @code{books} list is
+@code{application.books.[1].title}.
+
+The datatype of a value is determined from the format of the value
+itself. If the value is enclosed in double quotes, it is treated as a
+string. If it looks like an integer or floating point number, it is
+treated as such. If it is one of the values @code{TRUE}, @code{true},
+@code{FALSE}, or @code{false} (or any other mixed-case version of
+those tokens, e.g., @code{True} or @code{FaLsE}), it is treated as a
+boolean. If it consists of a comma-separated list of values enclosed
+in square brackets, it is treated as an array. And if it consists of a
+comma-separated list of values enclosed in parentheses, it is treated
+as a list. Any value which does not meet any of these criteria is
+considered invalid and results in a parse error.
+
+All names are case-sensitive. They may consist only of alphanumeric
+characters, dashes (@samp{-}), underscores (@samp{_}), and asterisks
+(@samp{*}), and must begin with a letter or asterisk. No other
+characters are allowed.
+
+In C and C++, integer, 64-bit integer, floating point, and string
+values are mapped to the types @code{int}, @code{long long},
+@code{double}, and @code{const char *}, respectively. The boolean type
+is mapped to @code{int} in C and @code{bool} in C++.
+
+The following sections describe the elements of the configuration file
+grammar in additional detail.
+
+@node Settings, Groups, , Configuration Files
+@comment node-name, next, previous, up
+@section Settings
+
+A setting has the form:
+
+@i{name} @b{=} @i{value} @b{;}
+
+or:
+
+@i{name} @b{:} @i{value} @b{;}
+
+The trailing semicolon is optional. Whitespace is not significant.
+
+The value may be a scalar value, an array, a group, or a list.
+
+@node Groups, Arrays, Settings, Configuration Files
+@comment node-name, next, previous, up
+@section Groups
+
+A group has the form:
+
+@b{@{}
+ @i{settings ...}
+@b{@}}
+
+Groups can contain any number of settings, but each setting must have
+a unique name within the group.
+
+@node Arrays, Lists, Groups, Configuration Files
+@comment node-name, next, previous, up
+@section Arrays
+
+An array has the form:
+
+@b{[} @i{value}@b{,} @i{value ...} @b{]}
+
+An array may have zero or more elements, but the elements must all be
+scalar values of the same type.
+
+@node Lists, Integer Values, Arrays, Configuration Files
+@comment node-name, next, previous, up
+@section Lists
+
+A list has the form:
+
+@b{(} @i{value}@b{,} @i{value ...} @b{)}
+
+A list may have zero or more elements, each of which can be a scalar
+value, an array, a group, or another list.
+
+@node Integer Values, 64-bit Integer Values, Lists, Configuration Files
+@comment node-name, next, previous, up
+@section Integer Values
+
+Integers can be represented in one of two ways: as a series of one or
+more decimal digits (@samp{0} - @samp{9}), with an optional leading
+sign character (@samp{+} or @samp{-}); or as a hexadecimal value
+consisting of the characters @samp{0x} followed by a series of one or
+more hexadecimal digits (@samp{0} - @samp{9}, @samp{A} - @samp{F},
+@samp{a} - @samp{f}).
+
+@node 64-bit Integer Values, Floating Point Values, Integer Values, Configuration Files
+@comment node-name, next, previous, up
+@section 64-bit Integer Values
+
+Long long (64-bit) integers are represented identically to integers,
+except that an 'L' character is appended to indicate a 64-bit
+value. For example, @samp{0L} indicates a 64-bit integer value 0.
+
+@node Floating Point Values, Boolean Values, 64-bit Integer Values, Configuration Files
+@comment node-name, next, previous, up
+@section Floating Point Values
+
+Floating point values consist of a series of one or more digits, one
+decimal point, an optional leading sign character (@samp{+} or
+@samp{-}), and an optional exponent. An exponent consists of the
+letter @samp{E} or @samp{e}, an optional sign character, and a series
+of one or more digits.
+
+@node Boolean Values, String Values, Floating Point Values, Configuration Files
+@comment node-name, next, previous, up
+@section Boolean Values
+
+Boolean values may have one of the following values: @samp{true},
+@samp{false}, or any mixed-case variation thereof.
+
+@node String Values, Comments, Boolean Values, Configuration Files
+@comment node-name, next, previous, up
+@section String Values
+
+@cindex escape sequence
+String values consist of arbitrary text delimited by double
+quotes. Literal double quotes can be escaped by preceding them with a
+backslash: @samp{\"}. The escape sequences @samp{\\}, @samp{\f},
+@samp{\n}, @samp{\r}, and @samp{\t} are also recognized, and have the
+usual meaning.
+
+In addition, the @samp{\x} escape sequence is supported; this sequence
+must be followed by @i{exactly two} hexadecimal digits, which represent an
+8-bit ASCII value. For example, @samp{\xFF} represents the character
+with ASCII code 0xFF.
+
+No other escape sequences are currently supported.
+
+Adjacent strings are automatically concatenated, as in C/C++ source
+code. This is useful for formatting very long strings as sequences of
+shorter strings. For example, the following constructs are equivalent:
+
+@itemize @bullet
+@item
+@code{"The quick brown fox jumped over the lazy dog."}
+
+@item
+@code{"The quick brown fox"} @*
+@code{" jumped over the lazy dog."}
+
+@item
+@code{"The quick" /* comment */ " brown fox " // another comment} @*
+@code{"jumped over the lazy dog."}
+
+@end itemize
+@page
+@node Comments, Include Directives, String Values, Configuration Files
+@comment node-name, next, previous, up
+@section Comments
+
+@cindex comment
+Three types of comments are allowed within a configuration:
+
+@itemize @bullet
+
+@item Script-style comments. All text beginning with a @samp{#} character
+to the end of the line is ignored.
+
+@item C-style comments. All text, including line breaks, between a starting
+@samp{/*} sequence and an ending @samp{*/} sequence is ignored.
+
+@item C++-style comments. All text beginning with a @samp{//} sequence to the
+end of the line is ignored.
+
+@end itemize
+
+As expected, comment delimiters appearing within quoted strings are
+treated as literal text.
+
+Comments are ignored when the configuration is read in, so they are
+not treated as part of the configuration. Therefore if the
+configuration is written back out to a stream, any comments that were
+present in the original configuration will be lost.
+
+@node Include Directives, , Comments, Configuration Files
+@comment node-name, next, previous, up
+@section Include Directives
+
+@cindex include directive
+A configuration file may ``include'' the contents of another file
+using an @i{include directive}. This directive has the effect of
+inlining the contents of the named file at the point of inclusion.
+
+An include directive must appear on its own line in the input. It has
+the form:
+
+@b{@@include "}@i{filename}@b{"}
+
+Any backslashes or double quotes in the filename must be escaped as
+@samp{\\} and @samp{\"}, respectively.
+
+For example, consider the following two configuration files:
+
+@cartouche
+@smallexample
+# file: quote.cfg
+quote = "Criticism may not be agreeable, but it is necessary."
+ " It fulfils the same function as pain in the human"
+ " body. It calls attention to an unhealthy state of"
+ " things.\n"
+ "\t--Winston Churchill";
+@end smallexample
+@end cartouche
+
+@cartouche
+@smallexample
+# file: test.cfg
+info: @{
+ name = "Winston Churchill";
+ @@include "quote.cfg"
+ country = "UK";
+@};
+@end smallexample
+@end cartouche
+
+Include files may be nested to a maximum of 10 levels; exceeding this
+limit results in a parse error.
+
+Like comments, include directives are not part of the configuration
+file syntax. They are processed before the configuration itself is
+parsed. Therefore, they are not preserved when the configuration is
+written back out to a stream. There is presently no support for
+programmatically inserting include directives into a configuration.
+
+@node The C API, The C++ API, Configuration Files, Top
+@comment node-name, next, previous, up
+@chapter The C API
+
+@tindex config_t
+@tindex config_setting_t
+This chapter describes the C library API. The type @i{config_t}
+represents a configuration, and the type @i{config_setting_t} represents
+a configuration setting.
+
+The boolean values @code{CONFIG_TRUE} and @code{CONFIG_FALSE} are
+macros defined as @code{(1)} and @code{(0)}, respectively.
+
+@deftypefun void config_init (@w{config_t * @var{config}})
+@deftypefunx void config_destroy (@w{config_t * @var{config}})
+
+These functions initialize and destroy the configuration object @var{config}.
+
+@code{config_init()} initializes the @i{config_t} structure pointed to by
+@var{config} as a new, empty configuration.
+
+@code{config_destroy()} destroys the configuration @var{config},
+deallocating all memory associated with the configuration, but does not
+attempt to deallocate the @i{config_t} structure itself.
+
+@end deftypefun
+
+@deftypefun int config_read (@w{config_t * @var{config}}, @w{FILE * @var{stream}})
+
+This function reads and parses a configuration from the given
+@var{stream} into the configuration object @var{config}. It returns
+@code{CONFIG_TRUE} on success, or @code{CONFIG_FALSE} on failure; the
+@code{config_error_text()}, @code{config_error_file()},
+@code{config_error_line()}, and @code{config_error_type()} functions,
+described below, can be used to obtain information about the error.
+
+@end deftypefun
+
+@deftypefun int config_read_file (@w{config_t * @var{config}}, @w{const char * @var{filename}})
+
+This function reads and parses a configuration from the file named
+@var{filename} into the configuration object @var{config}. It returns
+@code{CONFIG_TRUE} on success, or @code{CONFIG_FALSE} on failure; the
+@code{config_error_text()} and @code{config_error_line()} functions,
+described below, can be used to obtain information about the error.
+
+@end deftypefun
+
+@deftypefun int config_read_string (@w{config_t * @var{config}}, @w{const char * @var{str}})
+
+This function reads and parses a configuration from the string
+@var{str} into the configuration object @var{config}. It returns
+@code{CONFIG_TRUE} on success, or @code{CONFIG_FALSE} on failure; the
+@code{config_error_text()} and @code{config_error_line()} functions,
+described below, can be used to obtain information about the error.
+
+@end deftypefun
+
+@deftypefun void config_write (@w{const config_t * @var{config}}, @w{FILE * @var{stream}})
+
+This function writes the configuration @var{config} to the given
+@var{stream}.
+
+@end deftypefun
+
+@deftypefun int config_write_file (@w{config_t * @var{config}}, @w{const char * @var{filename}})
+
+This function writes the configuration @var{config} to the file named
+@var{filename}. It returns @code{CONFIG_TRUE} on success, or
+@code{CONFIG_FALSE} on failure.
+
+@end deftypefun
+
+@deftypefun {const char *} config_error_text (@w{const config_t * @var{config}})
+@deftypefunx {const char *} config_error_file (@w{const config_t * @var{config}})
+@deftypefunx int config_error_line (@w{const config_t * @var{config}})
+
+These functions, which are implemented as macros, return the text,
+filename, and line number of the parse error, if one occurred during a
+call to @code{config_read()}, @code{config_read_string()}, or
+@code{config_read_file()}. Storage for the strings returned by
+@code{config_error_text()} and @code{config_error_file()} are managed
+by the library and released automatically when the configuration is
+destroyed; these strings must not be freed by the caller. If the error
+occurred in text that was read from a string or stream,
+@code{config_error_file()} will return NULL.
+
+@end deftypefun
+
+@deftypefun config_error_t config_error_type (@w{const config_t * @var{config}})
+@tindex config_error_t
+This function, which is implemented as a macro, returns the type of
+error that occurred during the last call to one of the read or write
+functions. The @var{config_error_t} type is an enumeration with the
+following values: @code{CONFIG_ERR_NONE}, @code{CONFIG_ERR_FILE_IO},
+@code{CONFIG_ERR_PARSE}. These represent success, a file I/O error,
+and a parsing error, respectively.
+
+@end deftypefun
+
+@deftypefun void config_set_include_dir (@w{config_t *@var{config}}, @w{const char *@var{include_dir}})
+@deftypefunx {const char *} config_get_include_dir (@w{const config_t *@var{config}})
+
+@code{config_set_include_dir()} specifies the include directory,
+@var{include_dir}, relative to which the files specified in
+@samp{@@include} directives will be located for the configuration
+@var{config}. By default, there is no include directory, and all
+include files are expected to be relative to the current working
+directory. If @var{include_dir} is @code{NULL}, the default behavior
+is reinstated.
+
+For example, if the include directory is set to @file{/usr/local/etc},
+the include directive @samp{@@include "configs/extra.cfg"} would include the
+file @file{/usr/local/etc/configs/extra.cfg}.
+
+@code{config_get_include_dir()} returns the current include directory for the
+configuration @var{config}, or @code{NULL} if none is set.
+
+@end deftypefun
+
+@deftypefun void config_set_auto_convert (@w{config_t *@var{config}}, @w{int @var{flag}})
+@deftypefunx int config_get_auto_convert (@w{const config_t *@var{config}})
+
+@code{config_set_auto_convert()} enables number auto-conversion for
+the configuration @var{config} if @var{flag} is non-zero, and disables
+it otherwise. When this feature is enabled, an attempt to retrieve a
+floating point setting's value into an integer (or vice versa), or
+store an integer to a floating point setting's value (or vice versa)
+will cause the library to silently perform the necessary conversion
+(possibly leading to loss of data), rather than reporting failure. By
+default this feature is disabled.
+
+@code{config_get_auto_convert()} returns @code{CONFIG_TRUE} if number
+auto-conversion is currently enabled for @var{config}; otherwise it
+returns @code{CONFIG_FALSE}.
+
+@end deftypefun
+
+@deftypefun void config_set_default_format (@w{config_t * @var{config}}, @w{short @var{format}})
+@deftypefunx short config_get_default_format (@w{config_t * @var{config}})
+
+These functions, which are implemented as macros, set and get the
+default external format for settings in the configuration
+@var{config}. If a non-default format has not been set for a setting
+with @code{config_setting_set_format()}, this configuration-wide
+default format will be used instead when that setting is written to a
+file or stream.
+
+@end deftypefun
+
+@deftypefun void config_set_tab_width (@w{config_t * @var{config}}, @w{unsigned short @var{width}})
+@deftypefunx {unsigned short} config_get_tab_width (@w{const config_t * @var{config}})
+
+These functions, which are implemented as macros, set and get the tab
+width for the configuration @var{config}. The tab width affects the
+formatting of the configuration when it is written to a file or
+stream: each level of nesting is indented by @var{width} spaces, or
+by a single tab character if @var{width} is 0. The tab width has no
+effect on parsing.
+
+Valid tab widths range from 0 to 15. The default tab width is 2.
+
+@end deftypefun
+
+@deftypefun int config_lookup_int (@w{const config_t * @var{config}}, @w{const char * @var{path}}, @w{int * @var{value}})
+@deftypefunx int config_lookup_int64 (@w{const config_t * @var{config}}, @w{const char * @var{path}}, @w{long long * @var{value}})
+@deftypefunx int config_lookup_float (@w{const config_t * @var{config}}, @w{const char * @var{path}}, @w{double * @var{value}})
+@deftypefunx int config_lookup_bool (@w{const config_t * @var{config}}, @w{const char * @var{path}}, @w{int * @var{value}})
+@deftypefunx int config_lookup_string (@w{const config_t * @var{config}}, @w{const char * @var{path}}, @w{const char ** @var{value}})
+
+These functions look up the value of the setting in the configuration
+@var{config} specified by the path @var{path}. They store the value of
+the setting at @var{value} and return @code{CONFIG_TRUE} on
+success. If the setting was not found or if the type of the value did
+not match the type requested, they leave the data pointed to by
+@var{value} unmodified and return @code{CONFIG_FALSE}.
+
+Storage for the string returned by @code{config_lookup_string()} is
+managed by the library and released automatically when the setting is
+destroyed or when the setting's value is changed; the string must not
+be freed by the caller.
+
+@end deftypefun
+
+@deftypefun {config_setting_t *} config_lookup (@w{const config_t * @var{config}}, @w{const char * @var{path}})
+
+This function locates the setting in the configuration @var{config}
+specified by the path @var{path}. It returns a pointer to the
+@code{config_setting_t} structure on success, or @code{NULL} if the
+setting was not found.
+
+@end deftypefun
+
+@deftypefun int config_setting_get_int (@w{const config_setting_t * @var{setting}})
+@deftypefunx {long long} config_setting_get_int64 (@w{const config_setting_t * @var{setting}})
+@deftypefunx double config_setting_get_float (@w{const config_setting_t * @var{setting}})
+@deftypefunx int config_setting_get_bool (@w{const config_setting_t * @var{setting}})
+@deftypefunx {const char *} config_setting_get_string (@w{const config_setting_t * @var{setting}})
+
+These functions return the value of the given @var{setting}. If the
+type of the setting does not match the type requested, a 0 or
+@code{NULL} value is returned. Storage for the string returned by
+@code{config_setting_get_string()} is managed by the library and
+released automatically when the setting is destroyed or when the
+setting's value is changed; the string must not be freed by the
+caller.
+
+@end deftypefun
+@deftypefun int config_setting_set_int (@w{config_setting_t * @var{setting}}, @w{int @var{value}})
+@deftypefunx int config_setting_set_int64 (@w{config_setting_t * @var{setting}}, @w{long long @var{value}})
+@deftypefunx int config_setting_set_float (@w{config_setting_t * @var{setting}}, @w{double @var{value}})
+@deftypefunx int config_setting_set_bool (@w{config_setting_t * @var{setting}}, @w{int @var{value}})
+@deftypefunx int config_setting_set_string (@w{config_setting_t * @var{setting}}, @w{const char * @var{value}})
+
+These functions set the value of the given @var{setting} to
+@var{value}. On success, they return @code{CONFIG_TRUE}. If
+the setting does not match the type of the value, they return
+@code{CONFIG_FALSE}. @code{config_setting_set_string()} makes a copy
+of the passed string @var{value}, so it may be subsequently freed or
+modified by the caller without affecting the value of the setting.
+
+@end deftypefun
+
+@deftypefun int config_setting_lookup_int (@w{const config_setting_t * @var{setting}}, @w{const char * @var{name}}, @w{int * @var{value}})
+@deftypefunx int config_setting_lookup_int64 (@w{const config_setting_t * @var{setting}}, @w{const char * @var{name}}, @w{long long * @var{value}})
+@deftypefunx int config_setting_lookup_float (@w{const config_setting_t * @var{setting}}, @w{const char * @var{name}}, @w{double * @var{value}})
+@deftypefunx int config_setting_lookup_bool (@w{const config_setting_t * @var{setting}}, @w{const char * @var{name}}, @w{int * @var{value}})
+@deftypefunx int config_setting_lookup_string (@w{const config_setting_t * @var{setting}}, @w{const char * @var{name}}, @w{const char ** @var{value}})
+
+These functions look up the value of the child setting named
+@var{name} of the setting @var{setting}. They store the value at
+@var{value} and return @code{CONFIG_TRUE} on success. If the setting
+was not found or if the type of the value did not match the type
+requested, they leave the data pointed to by @var{value} unmodified
+and return @code{CONFIG_FALSE}.
+
+Storage for the string returned by @code{config_setting_lookup_string()} is
+managed by the library and released automatically when the setting is
+destroyed or when the setting's value is changed; the string must not
+be freed by the caller.
+
+@end deftypefun
+
+@deftypefun short config_setting_get_format (@w{config_setting_t * @var{setting}})
+@deftypefunx int config_setting_set_format (@w{config_setting_t * @var{setting}}, @w{short @var{format}})
+
+These functions get and set the external format for the setting @var{setting}.
+
+@tindex SettingFormat
+@cindex format
+
+The @var{format} must be one of the constants
+@code{CONFIG_FORMAT_DEFAULT} or @code{CONFIG_FORMAT_HEX}. All settings
+support the @code{CONFIG_FORMAT_DEFAULT} format. The
+@code{CONFIG_FORMAT_HEX} format specifies hexadecimal formatting for
+integer values, and hence only applies to settings of type
+@code{CONFIG_TYPE_INT} and @code{CONFIG_TYPE_INT64}. If @var{format}
+is invalid for the given setting, it is ignored.
+
+If a non-default format has not been set for the setting, @code{config_setting_get_format()} returns the default format for the configuration, as set by @code{config_set_default_format()}.
+
+@code{config_setting_set_format()} returns @code{CONFIG_TRUE} on
+success and @code{CONFIG_FALSE} on failure.
+
+@end deftypefun
+
+
+@deftypefun {config_setting_t *} config_setting_get_member (@w{config_setting_t * @var{setting}}, @w{const char * @var{name}})
+
+This function fetches the child setting named @var{name} from the group
+@var{setting}. It returns the requested setting on success, or
+@code{NULL} if the setting was not found or if @var{setting} is not a
+group.
+
+@end deftypefun
+
+@deftypefun {config_setting_t *} config_setting_get_elem (@w{const config_setting_t * @var{setting}}, @w{unsigned int @var{index}})
+
+This function fetches the element at the given index @var{index} in the
+setting @var{setting}, which must be an array, list, or group. It returns the
+requested setting on success, or @code{NULL} if @var{index} is out of
+range or if @var{setting} is not an array, list, or group.
+
+@end deftypefun
+
+@deftypefun int config_setting_get_int_elem (@w{const config_setting_t * @var{setting}}, @w{int @var{index}})
+@deftypefunx {long long} config_setting_get_int64_elem (@w{const config_setting_t * @var{setting}}, @w{int @var{index}})
+@deftypefunx double config_setting_get_float_elem (@w{const config_setting_t * @var{setting}}, @w{int @var{index}})
+@deftypefunx int config_setting_get_bool_elem (@w{const config_setting_t * @var{setting}}, @w{int @var{index}})
+@deftypefunx {const char *} config_setting_get_string_elem (@w{const config_setting_t * @var{setting}}, @w{int @var{index}})
+
+These functions return the value at the specified index @var{index} in the
+setting @var{setting}. If the setting is not an array or list, or if
+the type of the element does not match the type requested, or if
+@var{index} is out of range, they return 0 or @code{NULL}. Storage for
+the string returned by @code{config_setting_get_string_elem()} is
+managed by the library and released automatically when the setting is
+destroyed or when its value is changed; the string must not be freed
+by the caller.
+@end deftypefun
+
+@deftypefun {config_setting_t *} config_setting_set_int_elem (@w{config_setting_t * @var{setting}}, @w{int @var{index}}, @w{int @var{value}})
+@deftypefunx {config_setting_t *} config_setting_set_int64_elem (@w{config_setting_t * @var{setting}}, @w{int @var{index}}, @w{long long @var{value}})
+@deftypefunx {config_setting_t *} config_setting_set_float_elem (@w{config_setting_t * @var{setting}}, @w{int @var{index}}, @w{double @var{value}})
+@deftypefunx {config_setting_t *} config_setting_set_bool_elem (@w{config_setting_t * @var{setting}}, @w{int @var{index}}, @w{int @var{value}})
+@deftypefunx {config_setting_t *} config_setting_set_string_elem (@w{config_setting_t * @var{setting}}, @w{int @var{index}}, @w{const char * @var{value}})
+
+These functions set the value at the specified index @var{index} in the
+setting @var{setting} to @var{value}. If @var{index} is negative, a
+new element is added to the end of the array or list. On success,
+these functions return a pointer to the setting representing the
+element. If the setting is not an array or list, or if the setting is
+an array and the type of the array does not match the type of the
+value, or if @var{index} is out of range, they return
+@code{NULL}. @code{config_setting_set_string_elem()} makes a copy of
+the passed string @var{value}, so it may be subsequently freed or
+modified by the caller without affecting the value of the setting.
+@end deftypefun
+
+@deftypefun {config_setting_t *} config_setting_add (@w{config_setting_t * @var{parent}}, @w{const char * @var{name}}, @w{int @var{type}})
+
+This function adds a new child setting or element to the setting
+@var{parent}, which must be a group, array, or list. If @var{parent}
+is an array or list, the @var{name} parameter is ignored and may be
+@code{NULL}.
+
+The function returns the new setting on success, or @code{NULL} if
+@var{parent} is not a group, array, or list; or if there is already a
+child setting of @var{parent} named @var{name}; or if @var{type} is
+invalid. If @var{type} is a scalar type, the new setting will have a
+default value of 0, 0.0, @code{false}, or @code{NULL}, as appropriate.
+@end deftypefun
+
+@deftypefun int config_setting_remove (@w{config_setting_t * @var{parent}}, @w{const char * @var{name}})
+
+This function removes and destroys the setting named @var{name} from
+the parent setting @var{parent}, which must be a group. Any child
+settings of the setting are recursively destroyed as well.
+
+The function returns @code{CONFIG_TRUE} on success. If @var{parent} is
+not a group, or if it has no setting with the given name, it returns
+@code{CONFIG_FALSE}.
+
+@end deftypefun
+
+@deftypefun int config_setting_remove_elem (@w{config_setting_t * @var{parent}}, @w{unsigned int @var{index}})
+
+This function removes the child setting at the given index @var{index} from
+the setting @var{parent}, which must be a group, list, or array. Any
+child settings of the removed setting are recursively destroyed as
+well.
+
+The function returns @code{CONFIG_TRUE} on success. If @var{parent} is
+not a group, list, or array, or if @var{index} is out of range, it returns
+@code{CONFIG_FALSE}.
+
+@end deftypefun
+
+@deftypefun {config_setting_t *} config_root_setting (@w{const config_t * @var{config}})
+
+This function returns the root setting for the configuration
+@var{config}. The root setting is a group.
+
+@end deftypefun
+
+@deftypefun {const char *} config_setting_name (@w{const config_setting_t * @var{setting}})
+
+This function returns the name of the given @var{setting}, or
+@code{NULL} if the setting has no name. Storage for the returned
+string is managed by the library and released automatically when the
+setting is destroyed; the string must not be freed by the caller.
+
+@end deftypefun
+
+@deftypefun {config_setting_t *} config_setting_parent (@w{const config_setting_t * @var{setting}})
+
+This function returns the parent setting of the given @var{setting},
+or @code{NULL} if @var{setting} is the root setting.
+
+@end deftypefun
+
+@deftypefun int config_setting_is_root (@w{const config_setting_t * @var{setting}})
+
+This function returns @code{CONFIG_TRUE} if the given @var{setting} is
+the root setting, and @code{CONFIG_FALSE} otherwise.
+
+@end deftypefun
+
+@deftypefun int config_setting_index (@w{const config_setting_t * @var{setting}})
+
+This function returns the index of the given @var{setting} within its
+parent setting. If @var{setting} is the root setting, this function
+returns -1.
+
+@end deftypefun
+
+@deftypefun int config_setting_length (@w{const config_setting_t * @var{setting}})
+
+This function returns the number of settings in a group, or the number of
+elements in a list or array. For other types of settings, it returns
+0.
+
+@end deftypefun
+
+@deftypefun int config_setting_type (@w{const config_setting_t * @var{setting}})
+
+This function returns the type of the given @var{setting}. The return
+value is one of the constants
+@code{CONFIG_TYPE_INT}, @code{CONFIG_TYPE_INT64}, @code{CONFIG_TYPE_FLOAT},
+@code{CONFIG_TYPE_STRING}, @code{CONFIG_TYPE_BOOL},
+@code{CONFIG_TYPE_ARRAY}, @code{CONFIG_TYPE_LIST}, or @code{CONFIG_TYPE_GROUP}.
+
+@end deftypefun
+
+@deftypefun int config_setting_is_group (@w{const config_setting_t * @var{setting}})
+@deftypefunx int config_setting_is_array (@w{const config_setting_t * @var{setting}})
+@deftypefunx int config_setting_is_list (@w{const config_setting_t * @var{setting}})
+
+These convenience functions, which are implemented as macros, test if
+the setting @var{setting} is of a given type. They return
+@code{CONFIG_TRUE} or @code{CONFIG_FALSE}.
+
+@end deftypefun
+
+@deftypefun int config_setting_is_aggregate (@w{const config_setting_t * @var{setting}})
+@deftypefunx int config_setting_is_scalar (@w{const config_setting_t * @var{setting}})
+@deftypefunx int config_setting_is_number (@w{const config_setting_t * @var{setting}})
+
+@cindex aggregate value
+These convenience functions, which are implemented as macros, test if
+the setting @var{setting} is of an aggregate type (a group, array, or
+list), of a scalar type (integer, 64-bit integer, floating point,
+boolean, or string), and of a number (integer, 64-bit integer, or
+floating point), respectively. They return @code{CONFIG_TRUE} or
+@code{CONFIG_FALSE}.
+
+@end deftypefun
+
+@deftypefun {const char *} config_setting_source_file (@w{const config_setting_t * @var{setting}})
+
+This function returns the name of the file from which the setting
+@var{setting} was read, or NULL if the setting was not read from a
+file. This information is useful for reporting application-level
+errors. Storage for the returned string is managed by the library and
+released automatically when the configuration is destroyed; the
+string must not be freed by the caller.
+
+@end deftypefun
+
+@deftypefun {unsigned int} config_setting_source_line (@w{const config_setting_t * @var{setting}})
+
+This function returns the line number of the configuration file or
+stream at which the setting @var{setting} was read, or 0 if no line
+number is available. This information is useful for reporting
+application-level errors.
+
+@end deftypefun
+
+@deftypefun void config_setting_set_hook (@w{config_setting_t * @var{setting}}, @w{void * @var{hook}})
+@deftypefunx {void *} config_setting_get_hook (@w{const config_setting_t * @var{setting}})
+
+These functions make it possible to attach arbitrary data to each
+setting structure, for instance a ``wrapper'' or ``peer'' object written in
+another programming language. The destructor function, if one has been
+supplied via a call to @code{config_set_destructor()}, will be called
+by the library to dispose of this data when the setting itself is
+destroyed. There is no default destructor.
+
+@end deftypefun
+
+@deftypefun void config_set_destructor (@w{config_t * @var{config}}, @w{void (* @var{destructor})(void *)})
+
+This function assigns the destructor function @var{destructor} for the
+configuration @var{config}. This function accepts a single @code{void
+*} argument and has no return value. See
+@code{config_setting_set_hook()} above for more information.
+
+@end deftypefun
+
+@node The C++ API, Example Programs, The C API, Top
+@comment node-name, next, previous, up
+@chapter The C++ API
+
+@tindex Config
+@tindex Setting
+This chapter describes the C++ library API. The class @code{Config}
+represents a configuration, and the class @code{Setting} represents a
+configuration setting. Note that by design, neither of these classes
+provides a public copy constructor or assignment operator. Therefore,
+instances of these classes may only be passed between functions via
+references or pointers.
+
+@tindex ConfigException
+The library defines a group of exceptions, all of which extend the
+common base exception @code{ConfigException}.
+
+@tindex SettingTypeException
+A @code{SettingTypeException} is thrown when the type of a setting's
+value does not match the type requested.
+
+@tindex SettingNotFoundException
+A @code{SettingNotFoundException} is thrown when a setting is not found.
+
+@tindex SettingNameException
+A @code{SettingNameException} is thrown when an attempt is made to add
+a new setting with a non-unique or invalid name.
+
+@tindex ParseException
+A @code{ParseException} is thrown when a parse error occurs while
+reading a configuration from a stream.
+
+@tindex FileIOException
+A @code{FileIOException} is thrown when an I/O error occurs while
+reading/writing a configuration from/to a file.
+
+@tindex SettingException
+@code{SettingTypeException}, @code{SettingNotFoundException}, and
+@code{SettingNameException} all extend the common base
+exception @code{SettingException}, which provides the following method:
+
+@deftypemethod SettingException {const char *} getPath ()
+
+Returns the path to the setting associated with the exception, or
+@code{NULL} if there is no applicable path.
+
+@end deftypemethod
+
+The remainder of this chapter describes the methods for manipulating
+configurations and configuration settings.
+
+@deftypemethod Config {} Config ()
+@deftypemethodx Config {} ~Config ()
+
+These methods create and destroy @code{Config} objects.
+
+@end deftypemethod
+
+@deftypemethod Config void read (@w{FILE * @var{stream}})
+@deftypemethodx Config void write (@w{FILE * @var{stream}})
+
+The @code{read()} method reads and parses a configuration from the given
+@var{stream}. A @code{ParseException} is thrown if a parse error occurs.
+
+The @code{write()} method writes the configuration to the given @var{stream}.
+
+@end deftypemethod
+
+@deftypemethod Config void readFile (@w{const char * @var{filename}})
+@deftypemethodx Config void writeFile (@w{const char * @var{filename}})
+
+The @code{readFile()} method reads and parses a configuration from the
+file named @var{filename}. A @code{ParseException} is thrown if a
+parse error occurs. A @code{FileIOException} is thrown if the file
+cannot be read.
+
+The @code{writeFile()} method writes the configuration to the file
+named @var{filename}. A @code{FileIOException} is thrown if the file cannot
+be written.
+
+@end deftypemethod
+
+@deftypemethod Config void readString (@w{const char * @var{str}})
+@deftypemethodx Config void readString (@w{const std::string &@var{str}})
+
+These methods read and parse a configuration from the string
+@var{str}. A @code{ParseException} is thrown if a parse error occurs.
+
+@end deftypemethod
+
+@deftypemethod ParseException {const char *} getError ()
+@deftypemethodx ParseException {const char *} getFile ()
+@deftypemethodx ParseException int getLine ()
+
+If a call to @code{readFile()}, @code{readString()}, or @code{read()}
+resulted in a @code{ParseException}, these methods can be called on
+the exception object to obtain the text, filename, and line number of
+the parse error. Storage for the strings returned by @code{getError()}
+and @code{getFile()} are managed by the library; the strings must not
+be freed by the caller.
+
+@end deftypemethod
+
+@deftypemethod Config void setIncludeDir (@w{const char *@var{includeDir}})
+@deftypemethodx Config {const char *} getIncludeDir ()
+
+@code{setIncludeDir()} specifies the include directory,
+@var{includeDir}, relative to which the files specified in
+@samp{@@include} directives will be located for the configuration. By
+default, there is no include directory, and all include files are
+expected to be relative to the current working directory. If
+@var{includeDir} is @code{NULL}, the default behavior is reinstated.
+
+For example, if the include directory is set to @file{/usr/local/etc},
+the include directive @samp{@@include "configs/extra.cfg"} would include the
+file @file{/usr/local/etc/configs/extra.cfg}.
+
+@code{getIncludeDir()} returns the current include directory for the
+configuration, or @code{NULL} if none is set.
+
+@end deftypemethod
+
+@deftypemethod Config void setAutoConvert (bool @var{flag})
+@deftypemethodx Config bool getAutoConvert ()
+
+@code{setAutoConvert()} enables number auto-conversion for the
+configuration if @var{flag} is @code{true}, and disables it
+otherwise. When this feature is enabled, an attempt to assign a
+floating point setting to an integer (or vice versa), or
+assign an integer to a floating point setting (or vice versa) will
+cause the library to silently perform the necessary conversion
+(possibly leading to loss of data), rather than throwing a
+@code{SettingTypeException}. By default this feature is disabled.
+
+@code{getAutoConvert()} returns @code{true} if number auto-conversion
+is currently enabled for the configuration; otherwise it returns
+@code{false}.
+
+@end deftypemethod
+
+@deftypemethod Config void setDefaultFormat (@w{Setting::Format @var{format}})
+@deftypemethodx Config Setting::Format getDefaultFormat ()
+
+These methods set and get the default external format for settings in
+the configuration. If a non-default format has not been set for a
+setting with @code{Setting::setFormat()}, this configuration-wide
+default format will be used instead when that setting is written to a
+file or stream.
+
+@end deftypemethod
+
+@deftypemethod Config void setTabWidth (@w{unsigned short @var{width}})
+@deftypemethodx Config {unsigned short} getTabWidth ()
+
+These methods set and get the tab width for the configuration. The tab
+width affects the formatting of the configuration when it is written
+to a file or stream: each level of nesting is indented by @var{width}
+spaces, or by a single tab character if @var{width} is 0. The tab
+width has no effect on parsing.
+
+Valid tab widths range from 0 to 15. The default tab width is 2.
+
+@end deftypemethod
+
+@deftypemethod Config {Setting &} getRoot ()
+
+This method returns the root setting for the configuration, which is a group.
+
+@end deftypemethod
+
+@deftypemethod Config {Setting &} lookup (@w{const std::string &@var{path}})
+@deftypemethodx Config {Setting &} lookup (@w{const char * @var{path}})
+
+These methods locate the setting specified by the path @var{path}. If
+the requested setting is not found, a @code{SettingNotFoundException} is
+thrown.
+
+@end deftypemethod
+@deftypemethod Config bool exists (@w{const std::string &@var{path}})
+@deftypemethodx Config bool exists (@w{const char *@var{path}})
+
+These methods test if a setting with the given @var{path} exists in
+the configuration. They return @code{true} if the setting exists, and
+@code{false} otherwise. These methods do not throw exceptions.
+
+@end deftypemethod
+
+@deftypemethod Config bool lookupValue (@w{const char *@var{path}}, @w{bool &@var{value}})
+@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{bool &@var{value}})
+
+@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{int &@var{value}})
+@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{int &@var{value}})
+
+@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{unsigned int &@var{value}})
+@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{unsigned int &@var{value}})
+
+@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{long long &@var{value}})
+@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{long long &@var{value}})
+
+@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{float &@var{value}})
+@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{float &@var{value}})
+
+@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{double &@var{value}})
+@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{double &@var{value}})
+
+@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{const char *&@var{value}})
+@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{const char *&@var{value}})
+
+@deftypemethodx Config bool lookupValue (@w{const char *@var{path}}, @w{std::string &@var{value}})
+@deftypemethodx Config bool lookupValue (@w{const std::string &@var{path}}, @w{std::string &@var{value}})
+
+These are convenience methods for looking up the value of a setting
+with the given @var{path}. If the setting is found and is of an
+appropriate type, the value is stored in @var{value} and the method
+returns @code{true}. Otherwise, @var{value} is left unmodified and the
+method returns @code{false}. These methods do not throw exceptions.
+
+Storage for @w{@i{const char *}} values is managed by the library and
+released automatically when the setting is destroyed or when its value
+is changed; the string must not be freed by the caller. For safety and
+convenience, always assigning string values to a @code{std::string} is
+suggested.
+
+Since these methods have boolean return values and do not throw
+exceptions, they can be used within boolean logic expressions. The following
+example presents a concise way to look up three values at once and
+perform error handling if any of them are not found or are of the
+wrong type:
+
+@sp 1
+@cartouche
+@smallexample
+int var1;
+double var2;
+const char *var3;
+
+if(config.lookupValue("values.var1", var1)
+ && config.lookupValue("values.var2", var2)
+ && config.lookupValue("values.var3", var3))
+@{
+ // use var1, var2, var3
+@}
+else
+@{
+ // error handling here
+@}
+@end smallexample
+@end cartouche
+
+This approach also takes advantage of the short-circuit evaluation rules
+of C++, e.g., if the first lookup fails (returning @code{false}), the
+remaining lookups are skipped entirely.
+
+@end deftypemethod
+
+@deftypemethod Setting {} {operator bool ()}
+@deftypemethodx Setting {} {operator int ()}
+@deftypemethodx Setting {} {operator unsigned int ()}
+@deftypemethodx Setting {} {operator long ()}
+@deftypemethodx Setting {} {operator unsigned long ()}
+@deftypemethodx Setting {} {operator long long ()}
+@deftypemethodx Setting {} {operator unsigned long long ()}
+@deftypemethodx Setting {} {operator float ()}
+@deftypemethodx Setting {} {operator double ()}
+@deftypemethodx Setting {} {operator const char * ()}
+@deftypemethodx Setting {} {operator std::string ()}
+@deftypemethodx Setting {const char *} c_str ()
+
+These cast operators allow a @code{Setting} object to be assigned to a
+variable of type @i{bool} if it is of type @code{TypeBoolean};
+@i{int}, @i{unsigned int}; @code{long long} or @code{unsigned long long} if
+it is of type @code{TypeInt64}, @i{float} or @i{double} if it is of type
+@code{TypeFloat}; or @w{@i{const char *}} or @i{std::string} if it is
+of type @code{TypeString}.
+
+Values of type @code{TypeInt} or @code{TypeInt64} may be assigned to
+variables of type @i{long}, or @i{unsigned long}, depending on the
+sizes of those types on the host system.
+
+Storage for @w{@i{const char *}} return values is managed by the
+library and released automatically when the setting is destroyed or
+when its value is changed; the string must not be freed by the
+caller. For safety and convenience, always assigning string return
+values to a @code{std::string} is suggested.
+
+The following examples demonstrate this usage:
+
+@cartouche
+@smallexample
+long width = config.lookup("application.window.size.w");
+
+bool splashScreen = config.lookup("application.splash_screen");
+
+std::string title = config.lookup("application.window.title");
+@end smallexample
+@end cartouche
+
+Note that certain conversions can lead to loss of precision or
+clipping of values, e.g., assigning a negative value to an @i{unsigned
+int} (in which case the value will be treated as 0), or a
+double-precision value to a @i{float}. The library does not treat
+these lossy conversions as errors.
+
+Perhaps surprisingly, the following code in particular will cause a
+compiler error:
+
+@cartouche
+@smallexample
+std::string title;
+.
+.
+.
+title = config.lookup("application.window.title");
+@end smallexample
+@end cartouche
+
+This is because the assignment operator of @code{std::string} is being
+invoked with a @code{Setting &} as an argument. The compiler is unable
+to make an implicit conversion because both the @code{const char *}
+and the @code{std::string} cast operators of @code{Setting} are
+equally appropriate. This is not a bug in @i{libconfig}; providing
+only the @code{const char *} cast operator would resolve this
+particular ambiguity, but would cause assignments to
+@code{std::string} like the one in the previous example to produce a
+compiler error. (To understand why, see section 11.4.1 of @i{The C++
+Programming Language}.)
+
+The solution to this problem is to use an explicit conversion that
+avoids the construction of an intermediate @code{std::string} object,
+as follows:
+
+@cartouche
+@smallexample
+std::string title;
+.
+.
+.
+title = (const char *)config.lookup("application.window.title");
+@end smallexample
+@end cartouche
+
+Or, alternatively, use the @code{c_str()} method, which has the same effect:
+
+@cartouche
+@smallexample
+std::string title;
+.
+.
+.
+title = config.lookup("application.window.title").c_str();
+@end smallexample
+@end cartouche
+
+If the assignment is invalid due to a type mismatch, a
+@code{SettingTypeException} is thrown.
+
+@end deftypemethod
+
+@deftypemethod Setting {Setting &} operator= (@w{bool @var{value}})
+@deftypemethodx Setting {Setting &} operator= (@w{int @var{value}})
+@deftypemethodx Setting {Setting &} operator= (@w{long @var{value}})
+@deftypemethodx Setting {Setting &} operator= (@w{const long long &@var{value}})
+@deftypemethodx Setting {Setting &} operator= (@w{float @var{value}})
+@deftypemethodx Setting {Setting &} operator= (@w{const double &@var{value}})
+@deftypemethodx Setting {Setting &} operator= (@w{const char *@var{value}})
+@deftypemethodx Setting {Setting &} operator= (@w{const std::string &@var{value}})
+
+These assignment operators allow values of type @i{bool}, @i{int},
+@i{long}, @i{long long}, @i{float}, @i{double}, @i{const char *}, and
+@i{std::string} to be assigned to a setting. In the case of strings,
+the library makes a copy of the passed string @var{value}, so it may
+be subsequently freed or modified by the caller without affecting the
+value of the setting.
+
+The following example code looks up a (presumably) integer setting
+and changes its value:
+
+@cartouche
+@smallexample
+Setting &setting = config.lookup("application.window.size.w");
+setting = 1024;
+@end smallexample
+@end cartouche
+
+If the assignment is invalid due to a type mismatch, a
+@code{SettingTypeException} is thrown.
+
+@end deftypemethod
+
+@deftypemethod Setting {Setting &} {operator[]} (@w{int @var{index}})
+@deftypemethodx Setting {Setting &} {operator[]} (@w{const std::string &@var{name}})
+@deftypemethodx Setting {Setting &} {operator[]} (@w{const char *@var{name}})
+
+A @code{Setting} object may be subscripted with an integer index
+@var{index} if it is an array or list, or with either a string
+@var{name} or an integer index @var{index} if it is a group. For example,
+the following code would produce the string @samp{Last Name} when
+applied to the example configuration in @ref{Configuration Files}.
+
+@cartouche
+@smallexample
+Setting& setting = config.lookup("application.misc");
+const char *s = setting["columns"][0];
+@end smallexample
+@end cartouche
+
+If the setting is not an array, list, or group, a
+@code{SettingTypeException} is thrown. If the subscript (@var{index}
+or @var{name}) does not refer to a valid element, a
+@code{SettingNotFoundException} is thrown.
+
+Iterating over a group's child settings with an integer index will
+return the settings in the same order that they appear in the
+configuration.
+
+@end deftypemethod
+
+@deftypemethod Setting bool lookupValue (@w{const char *@var{name}}, @w{bool &@var{value}})
+@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{bool &@var{value}})
+
+@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{int &@var{value}})
+@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{int &@var{value}})
+
+@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{unsigned int &@var{value}})
+@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{unsigned int &@var{value}})
+
+@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{long long &@var{value}})
+@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{long long &@var{value}})
+
+@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{unsigned long long &@var{value}})
+@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{unsigned long long &@var{value}})
+
+@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{float &@var{value}})
+@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{float &@var{value}})
+
+@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{double &@var{value}})
+@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{double &@var{value}})
+
+@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{const char *&@var{value}})
+@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{const char *&@var{value}})
+
+@deftypemethodx Setting bool lookupValue (@w{const char *@var{name}}, @w{std::string &@var{value}})
+@deftypemethodx Setting bool lookupValue (@w{const std::string &@var{name}}, @w{std::string &@var{value}})
+
+These are convenience methods for looking up the value of a child setting
+with the given @var{name}. If the setting is found and is of an
+appropriate type, the value is stored in @var{value} and the method
+returns @code{true}. Otherwise, @var{value} is left unmodified and the
+method returns @code{false}. These methods do not throw exceptions.
+
+Storage for @w{@i{const char *}} values is managed by the library and
+released automatically when the setting is destroyed or when its value
+is changed; the string must not be freed by the caller. For safety and
+convenience, always assigning string values to a @code{std::string} is
+suggested.
+
+Since these methods have boolean return values and do not throw
+exceptions, they can be used within boolean logic expressions. The following
+example presents a concise way to look up three values at once and
+perform error handling if any of them are not found or are of the
+wrong type:
+
+@sp 1
+@cartouche
+@smallexample
+int var1;
+double var2;
+const char *var3;
+
+if(setting.lookupValue("var1", var1)
+ && setting.lookupValue("var2", var2)
+ && setting.lookupValue("var3", var3))
+@{
+ // use var1, var2, var3
+@}
+else
+@{
+ // error handling here
+@}
+@end smallexample
+@end cartouche
+
+This approach also takes advantage of the short-circuit evaluation
+rules of C++, e.g., if the first lookup fails (returning @code{false}), the
+remaining lookups are skipped entirely.
+
+@end deftypemethod
+
+@deftypemethod Setting {Setting &} add (@w{const std::string &@var{name}}, @w{Setting::Type @var{type}})
+@deftypemethodx Setting {Setting &} add (@w{const char *@var{name}}, @w{Setting::Type @var{type}})
+
+These methods add a new child setting with the given @var{name} and
+@var{type} to the setting, which must be a group. They return a
+reference to the new setting. If the setting already has a child
+setting with the given name, or if the name is invalid, a
+@code{SettingNameException} is thrown. If the setting is not a group,
+a @code{SettingTypeException} is thrown.
+
+Once a setting has been created, neither its name nor type can be
+changed.
+
+@end deftypemethod
+
+@deftypemethod Setting {Setting &} add (@w{Setting::Type @var{type}})
+
+This method adds a new element to the setting, which must be of type
+@code{TypeArray} or @code{TypeList}. If the setting is an array which
+currently has zero elements, the @var{type} parameter (which must be
+@code{TypeInt}, @code{TypeInt64}, @code{TypeFloat}, @code{TypeBool},
+or @code{TypeString}) determines the type for the array; otherwise it
+must match the type of the existing elements in the array.
+
+The method returns the new setting on success. If @var{type} is a
+scalar type, the new setting will have a default value of 0, 0.0,
+@code{false}, or @code{NULL}, as appropriate.
+
+The method throws a @code{SettingTypeException} if the setting is not
+an array or list, or if @var{type} is invalid.
+
+@end deftypemethod
+
+@deftypemethod Setting void remove (@w{const std::string &@var{name}})
+@deftypemethodx Setting void remove (@w{const char *@var{name}})
+
+These methods remove the child setting with the given @var{name} from
+the setting, which must be a group. Any child settings of the removed
+setting are recursively destroyed as well.
+
+If the setting is not a group, a @code{SettingTypeException} is
+thrown. If the setting does not have a child setting with the given
+name, a @code{SettingNotFoundException} is thrown.
+
+@end deftypemethod
+
+@deftypemethod Setting void remove (@w{unsigned int @var{index}})
+
+This method removes the child setting at the given index @var{index} from
+the setting, which must be a group, list, or array. Any child settings
+of the removed setting are recursively destroyed as well.
+
+If the setting is not a group, list, or array, a
+@code{SettingTypeException} is thrown. If @var{index} is out of range,
+a @code{SettingNotFoundException} is thrown.
+
+@end deftypemethod
+
+@deftypemethod Setting {const char *} getName ()
+
+This method returns the name of the setting, or @code{NULL} if the
+setting has no name. Storage for the returned string is managed by the
+library and released automatically when the setting is destroyed; the
+string must not be freed by the caller. For safety and convenience,
+consider assigning the return value to a @code{std::string}.
+
+@end deftypemethod
+
+@deftypemethod Setting {std::string} getPath ()
+
+This method returns the complete dot-separated path to the
+setting. Settings which do not have a name (list and array elements)
+are represented by their index in square brackets.
+
+@end deftypemethod
+
+@deftypemethod Setting {Setting &} getParent ()
+
+This method returns the parent setting of the setting. If the setting
+is the root setting, a @code{SettingNotFoundException} is thrown.
+
+@end deftypemethod
+
+@deftypemethod Setting bool isRoot ()
+
+This method returns @code{true} if the setting is the root setting, and
+@code{false} otherwise.
+
+@end deftypemethod
+
+@deftypemethod Setting int getIndex ()
+
+This method returns the index of the setting within its parent
+setting. When applied to the root setting, this method returns -1.
+
+@end deftypemethod
+
+@deftypemethod Setting Setting::Type getType ()
+
+@tindex Setting::Type
+This method returns the type of the setting. The
+@code{Setting::Type} enumeration consists of the following constants:
+@code{TypeInt}, @code{TypeInt64}, @code{TypeFloat}, @code{TypeString},
+@code{TypeBoolean}, @code{TypeArray}, @code{TypeList}, and
+@code{TypeGroup}.
+
+@end deftypemethod
+
+@deftypemethod Setting Setting::Format getFormat ()
+@deftypemethodx Setting void setFormat (@w{Setting::Format @var{format}})
+
+These methods get and set the external format for the setting.
+
+@tindex Setting::Format
+The @var{Setting::Format} enumeration consists of the following
+constants: @code{FormatDefault} and @code{FormatHex}. All settings
+support the @code{FormatDefault} format. The @code{FormatHex} format
+specifies hexadecimal formatting for integer values, and hence only
+applies to settings of type @code{TypeInt} and @code{TypeInt64}. If
+@var{format} is invalid for the given setting, it is ignored.
+
+@end deftypemethod
+
+@deftypemethod Setting bool exists (@w{const std::string &@var{name}})
+@deftypemethodx Setting bool exists (@w{const char *@var{name}})
+
+These methods test if the setting has a child setting with the given
+@var{name}. They return @code{true} if the setting exists, and
+@code{false} otherwise. These methods do not throw exceptions.
+
+@end deftypemethod
+
+@deftypemethod Setting int getLength ()
+
+This method returns the number of settings in a group, or the number of
+elements in a list or array. For other types of settings, it returns
+0.
+
+@end deftypemethod
+
+@deftypemethod Setting bool isGroup ()
+@deftypemethodx Setting bool isArray ()
+@deftypemethodx Setting bool isList ()
+
+These convenience methods test if a setting is of a given type.
+
+@end deftypemethod
+
+@deftypemethod Setting bool isAggregate ()
+@deftypemethodx Setting bool isScalar ()
+@deftypemethodx Setting bool isNumber ()
+
+These convenience methods test if a setting is of an aggregate type (a
+group, array, or list), of a scalar type (integer, 64-bit integer,
+floating point, boolean, or string), and of a number (integer, 64-bit
+integer, or floating point), respectively.
+
+@end deftypemethod
+
+@deftypemethod Setting {const char *} getSourceFile ()
+
+This function returns the name of the file from which the setting was
+read, or NULL if the setting was not read from a file. This
+information is useful for reporting application-level errors. Storage
+for the returned string is managed by the library and released
+automatically when the configuration is destroyed; the string must
+not be freed by the caller.
+
+@end deftypemethod
+
+@deftypemethod Setting {unsigned int} getSourceLine ()
+
+This function returns the line number of the configuration file or
+stream at which the setting @var{setting} was read, or 0 if no line
+number is available. This information is useful for reporting
+application-level errors.
+
+@end deftypemethod
+
+@node Example Programs, Configuration File Grammar, The C++ API, Top
+@comment node-name, next, previous, up
+@chapter Example Programs
+
+Practical example programs that illustrate how to use @i{libconfig}
+from both C and C++ are included in the @file{examples} subdirectory
+of the distribution. These examples include:
+
+@table @file
+
+@item examples/c/example1.c
+An example C program that reads a configuration from an existing file
+@file{example.cfg} (also located in @file{examples/c}) and displays
+some of its contents.
+
+@item examples/c++/example1.cpp
+The C++ equivalent of @file{example1.c}.
+
+@item examples/c/example2.c
+An example C program that reads a configuration from an existing file
+@file{example.cfg} (also located in @file{examples/c}), adds new
+settings to the configuration, and writes the updated configuration to
+another file.
+
+@item examples/c++/example2.cpp
+The C++ equivalent of @file{example2.c}
+
+@item examples/c/example3.c
+An example C program that constructs a new configuration in memory and writes it to a file.
+
+@item examples/c++/example3.cpp
+The C++ equivalent of @file{example3.c}
+
+@end table
+
+@node Configuration File Grammar, License, Example Programs, Top
+@comment node-name, next, previous, up
+@chapter Configuration File Grammar
+
+Below is the BNF grammar for configuration files. Comments and include
+directives are not part of the grammar, so they are not included here.
+
+@sp 1
+@example
+configuration = setting-list | empty
+
+setting-list = setting | setting-list setting
+
+setting = name (":" | "=") value (";" | "," | empty)
+
+value = scalar-value | array | list | group
+
+value-list = value | value-list "," value
+
+scalar-value = boolean | integer | integer64 | hex | hex64 | float
+ | string
+
+scalar-value-list = scalar-value | scalar-value-list "," scalar-value
+
+array = "[" (scalar-value-list | empty) "]"
+
+list = "(" (value-list | empty) ")"
+
+group = "@{" (setting-list | empty) "@}"
+
+empty =
+@end example
+
+@sp 2
+Terminals are defined below as regular expressions:
+@sp 1
+
+@multitable @columnfractions .2 .8
+@item @code{boolean} @tab
+@code{([Tt][Rr][Uu][Ee])|([Ff][Aa][Ll][Ss][Ee])}
+@item @code{string} @tab
+@code{\"([^\"\\]|\\.)*\"}
+@item @code{name} @tab
+@code{[A-Za-z\*][-A-Za-z0-9_\*]*}
+@item @code{integer} @tab
+@code{[-+]?[0-9]+}
+@item @code{integer64} @tab
+@code{[-+]?[0-9]+L(L)?}
+@item @code{hex} @tab
+@code{0[Xx][0-9A-Fa-f]+}
+@item @code{hex64} @tab
+@code{0[Xx][0-9A-Fa-f]+L(L)?}
+@item @code{float} @tab
+@code{([-+]?([0-9]*)?\.[0-9]*([eE][-+]?[0-9]+)?)|([-+]([0-9]+)(\.[0-9]*)?[eE][-+]?[0-9]+)}
+@end multitable
+
+@node License, Function Index, Configuration File Grammar, Top
+@comment node-name, next, previous, up
+@appendix License
+
+@include LGPL.texi
+
+@node Function Index, Type Index, License, Top
+@comment node-name, next, previous, up
+@unnumbered Function Index
+
+@printindex fn
+
+@node Type Index, Concept Index, Function Index, Top
+@comment node-name, next, previous, up
+@unnumbered Type Index
+
+@printindex tp
+
+@node Concept Index, , Type Index, Top
+@comment node-name, next, previous, up
+@unnumbered Concept Index
+
+@printindex cp
+
+@bye
diff --git a/3rdparty/libconfig/extra/gen/Makefile b/3rdparty/libconfig/extra/gen/Makefile
new file mode 100644
index 000000000..b4d2db841
--- /dev/null
+++ b/3rdparty/libconfig/extra/gen/Makefile
@@ -0,0 +1,70 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# gen/Makefile. Generated from Makefile.in by configure.
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+
+LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS)
+YLWRAP = ../aux-build/ylwrap
+YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
+LEX = flex
+LEXLIB = -ll
+LEX_OUTPUT_ROOT = lex.yy
+SHELL = /bin/sh
+YACC = bison -y
+YFLAGS =
+
+PARSER_PREFIX = libconfig_yy
+BUILT_SOURCES = scanner.c scanner.h grammar.c grammar.h
+AM_YFLAGS = -d -p $(PARSER_PREFIX)
+AM_LFLAGS = --nounistd --header-file=scanner.h --prefix=$(PARSER_PREFIX)
+
+all: $(BUILT_SOURCES)
+
+.SUFFIXES: .c .l .y
+
+grammar.h: grammar.c
+ @if test ! -f $@; then \
+ rm -f grammar.c; \
+ $(MAKE) grammar.c; \
+ else :; fi
+
+
+distclean-compile:
+ -rm -f *.tab.c
+
+scanner.h: scanner.c
+
+.l.c:
+ $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE)
+
+.y.c:
+ $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE)
+
+clean:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -rm -f grammar.c
+ -rm -f grammar.h
+ -rm -f scanner.c
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+
+distclean: clean distclean-compile
+
+.MAKE: all
+
+.PHONY: all clean \
+ distclean \
+ distclean-compile
+
diff --git a/3rdparty/libconfig/extra/gen/Makefile.in b/3rdparty/libconfig/extra/gen/Makefile.in
new file mode 100644
index 000000000..5850c2392
--- /dev/null
+++ b/3rdparty/libconfig/extra/gen/Makefile.in
@@ -0,0 +1,70 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS)
+YLWRAP = ../aux-build/ylwrap
+YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+SHELL = @SHELL@
+YACC = @YACC@
+YFLAGS = @YFLAGS@
+
+PARSER_PREFIX = libconfig_yy
+BUILT_SOURCES = scanner.c scanner.h grammar.c grammar.h
+AM_YFLAGS = -d -p $(PARSER_PREFIX)
+AM_LFLAGS = --nounistd --header-file=scanner.h --prefix=$(PARSER_PREFIX)
+
+all: $(BUILT_SOURCES)
+
+.SUFFIXES: .c .l .y
+
+grammar.h: grammar.c
+ @if test ! -f $@; then \
+ rm -f grammar.c; \
+ $(MAKE) grammar.c; \
+ else :; fi
+
+
+distclean-compile:
+ -rm -f *.tab.c
+
+scanner.h: scanner.c
+
+.l.c:
+ $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE)
+
+.y.c:
+ $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE)
+
+clean:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -rm -f grammar.c
+ -rm -f grammar.h
+ -rm -f scanner.c
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+
+distclean: clean distclean-compile
+
+.MAKE: all
+
+.PHONY: all clean \
+ distclean \
+ distclean-compile
+
diff --git a/3rdparty/libconfig/extra/gen/grammar.y b/3rdparty/libconfig/extra/gen/grammar.y
new file mode 100644
index 000000000..f578897cb
--- /dev/null
+++ b/3rdparty/libconfig/extra/gen/grammar.y
@@ -0,0 +1,395 @@
+/* -*- mode: C -*- */
+/* ----------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+%defines
+%output="y.tab.c"
+%pure-parser
+%lex-param{void *scanner}
+%parse-param{void *scanner}
+%parse-param{struct parse_context *ctx}
+%parse-param{struct scan_context *scan_ctx}
+
+%{
+#include <string.h>
+#include <stdlib.h>
+#include "libconfig.h"
+#ifdef WIN32
+#include "wincompat.h"
+
+/* prevent warnings about redefined malloc/free in generated code: */
+#ifndef _STDLIB_H
+#define _STDLIB_H
+#endif
+
+#include <malloc.h>
+#endif
+#include "parsectx.h"
+#include "scanctx.h"
+
+/* these delcarations are provided to suppress compiler warnings */
+extern int libconfig_yylex();
+extern int libconfig_yyget_lineno();
+
+static const char *err_array_elem_type = "mismatched element type in array";
+static const char *err_duplicate_setting = "duplicate setting name";
+
+#define _delete(P) free((void *)(P))
+
+#define IN_ARRAY() \
+ (ctx->parent && (ctx->parent->type == CONFIG_TYPE_ARRAY))
+
+#define IN_LIST() \
+ (ctx->parent && (ctx->parent->type == CONFIG_TYPE_LIST))
+
+static void capture_parse_pos(void *scanner, struct scan_context *scan_ctx,
+ config_setting_t *setting)
+{
+ setting->line = (unsigned int)libconfig_yyget_lineno(scanner);
+ setting->file = scanctx_current_filename(scan_ctx);
+}
+
+#define CAPTURE_PARSE_POS(S) \
+ capture_parse_pos(scanner, scan_ctx, (S))
+
+void libconfig_yyerror(void *scanner, struct parse_context *ctx,
+ struct scan_context *scan_ctx, char const *s)
+{
+ if(ctx->config->error_text) return;
+ ctx->config->error_line = libconfig_yyget_lineno(scanner);
+ ctx->config->error_text = s;
+}
+
+%}
+
+%union
+{
+ int ival;
+ long long llval;
+ double fval;
+ char *sval;
+}
+
+%token <ival> TOK_BOOLEAN TOK_INTEGER TOK_HEX
+%token <llval> TOK_INTEGER64 TOK_HEX64
+%token <fval> TOK_FLOAT
+%token <sval> TOK_STRING TOK_NAME
+%token TOK_EQUALS TOK_NEWLINE TOK_ARRAY_START TOK_ARRAY_END TOK_LIST_START TOK_LIST_END TOK_COMMA TOK_GROUP_START TOK_GROUP_END TOK_SEMICOLON TOK_GARBAGE TOK_ERROR
+
+%%
+
+configuration:
+ /* empty */
+ | setting_list
+ ;
+
+setting_list:
+ setting
+ | setting_list setting
+ ;
+
+setting_list_optional:
+ /* empty */
+ | setting_list
+ ;
+
+setting_terminator:
+ /* empty */
+ | TOK_SEMICOLON
+ | TOK_COMMA
+ ;
+
+setting:
+ TOK_NAME
+ {
+ ctx->setting = config_setting_add(ctx->parent, $1, CONFIG_TYPE_NONE);
+
+ if(ctx->setting == NULL)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_duplicate_setting);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(ctx->setting);
+ }
+ }
+
+ TOK_EQUALS value setting_terminator
+ ;
+
+array:
+ TOK_ARRAY_START
+ {
+ if(IN_LIST())
+ {
+ ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_ARRAY);
+ CAPTURE_PARSE_POS(ctx->parent);
+ }
+ else
+ {
+ ctx->setting->type = CONFIG_TYPE_ARRAY;
+ ctx->parent = ctx->setting;
+ ctx->setting = NULL;
+ }
+ }
+ simple_value_list_optional
+ TOK_ARRAY_END
+ {
+ if(ctx->parent)
+ ctx->parent = ctx->parent->parent;
+ }
+ ;
+
+list:
+ TOK_LIST_START
+ {
+ if(IN_LIST())
+ {
+ ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_LIST);
+ CAPTURE_PARSE_POS(ctx->parent);
+ }
+ else
+ {
+ ctx->setting->type = CONFIG_TYPE_LIST;
+ ctx->parent = ctx->setting;
+ ctx->setting = NULL;
+ }
+ }
+ value_list_optional
+ TOK_LIST_END
+ {
+ if(ctx->parent)
+ ctx->parent = ctx->parent->parent;
+ }
+ ;
+
+value:
+ simple_value
+ | array
+ | list
+ | group
+ ;
+
+string:
+ TOK_STRING { parsectx_append_string(ctx, $1); free($1); }
+ | string TOK_STRING { parsectx_append_string(ctx, $2); free($2); }
+ ;
+
+simple_value:
+ TOK_BOOLEAN
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_bool_elem(ctx->parent, -1,
+ (int)$1);
+
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ config_setting_set_bool(ctx->setting, (int)$1);
+ }
+ | TOK_INTEGER
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, $1);
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ config_setting_set_format(e, CONFIG_FORMAT_DEFAULT);
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_int(ctx->setting, $1);
+ config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT);
+ }
+ }
+ | TOK_INTEGER64
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, $1);
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ config_setting_set_format(e, CONFIG_FORMAT_DEFAULT);
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_int64(ctx->setting, $1);
+ config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT);
+ }
+ }
+ | TOK_HEX
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, $1);
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ config_setting_set_format(e, CONFIG_FORMAT_HEX);
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_int(ctx->setting, $1);
+ config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX);
+ }
+ }
+ | TOK_HEX64
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, $1);
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ config_setting_set_format(e, CONFIG_FORMAT_HEX);
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ config_setting_set_int64(ctx->setting, $1);
+ config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX);
+ }
+ }
+ | TOK_FLOAT
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ config_setting_t *e = config_setting_set_float_elem(ctx->parent, -1, $1);
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ config_setting_set_float(ctx->setting, $1);
+ }
+ | string
+ {
+ if(IN_ARRAY() || IN_LIST())
+ {
+ const char *s = parsectx_take_string(ctx);
+ config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, s);
+ _delete(s);
+
+ if(! e)
+ {
+ libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
+ YYABORT;
+ }
+ else
+ {
+ CAPTURE_PARSE_POS(e);
+ }
+ }
+ else
+ {
+ const char *s = parsectx_take_string(ctx);
+ config_setting_set_string(ctx->setting, s);
+ _delete(s);
+ }
+ }
+ ;
+
+value_list:
+ value
+ | value_list TOK_COMMA value
+ ;
+
+value_list_optional:
+ /* empty */
+ | value_list
+ ;
+
+simple_value_list:
+ simple_value
+ | simple_value_list TOK_COMMA simple_value
+ ;
+
+simple_value_list_optional:
+ /* empty */
+ | simple_value_list
+ ;
+
+group:
+ TOK_GROUP_START
+ {
+ if(IN_LIST())
+ {
+ ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_GROUP);
+ CAPTURE_PARSE_POS(ctx->parent);
+ }
+ else
+ {
+ ctx->setting->type = CONFIG_TYPE_GROUP;
+ ctx->parent = ctx->setting;
+ ctx->setting = NULL;
+ }
+ }
+ setting_list_optional
+ TOK_GROUP_END
+ {
+ if(ctx->parent)
+ ctx->parent = ctx->parent->parent;
+ }
+ ;
+
+%%
diff --git a/3rdparty/libconfig/extra/gen/scanner.l b/3rdparty/libconfig/extra/gen/scanner.l
new file mode 100644
index 000000000..bdc57a8d4
--- /dev/null
+++ b/3rdparty/libconfig/extra/gen/scanner.l
@@ -0,0 +1,196 @@
+/* -*- mode: C -*- */
+/* --------------------------------------------------------------------------
+ libconfig - A library for processing structured configuration files
+ Copyright (C) 2005-2010 Mark A Lindner
+
+ This file is part of libconfig.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, see
+ <http://www.gnu.org/licenses/>.
+ ----------------------------------------------------------------------------
+*/
+
+%option nounistd
+%option reentrant
+%option noyywrap
+%option yylineno
+%option nounput
+%option bison-bridge
+%option never-interactive
+%option header-file="scanner.h"
+%option outfile="lex.yy.c"
+%option extra-type="struct scan_context *"
+
+%top{
+#include "scanctx.h"
+}
+
+%{
+#ifdef _MSC_VER
+#pragma warning (disable: 4996)
+/* disable MSVC warning "signed/unsigned mismatch" associated with code generated by flex versions such as 2.5.35. */
+#pragma warning (disable:4018)
+#endif
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include "grammar.h"
+#include "wincompat.h"
+#include "parsectx.h"
+
+#define YY_NO_INPUT // Suppress generation of useless input() function
+
+static unsigned long long fromhex(const char *s)
+{
+#ifdef __MINGW32__
+
+ /* MinGW's strtoull() seems to be broken; it only returns the lower
+ * 32 bits...
+ */
+
+ const char *p = s;
+ unsigned long long val = 0;
+
+ if(*p != '0')
+ return(0);
+
+ ++p;
+
+ if(*p != 'x' && *p != 'X')
+ return(0);
+
+ for(++p; isxdigit(*p); ++p)
+ {
+ val <<= 4;
+ val |= ((*p < 'A') ? (*p & 0xF) : (9 + (*p & 0x7)));
+ }
+
+ return(val);
+
+#else /* ! __MINGW32__ */
+
+ return(strtoull(s, NULL, 16));
+
+#endif /* __MINGW32__ */
+}
+
+%}
+
+true [Tt][Rr][Uu][Ee]
+false [Ff][Aa][Ll][Ss][Ee]
+name [A-Za-z\*][-A-Za-z0-9_\*']*
+integer [-+]?[0-9]+
+integer64 [-+]?[0-9]+L(L)?
+hex 0[Xx][0-9A-Fa-f]+
+hex64 0[Xx][0-9A-Fa-f]+L(L)?
+hexchar \\[Xx][0-9A-Fa-f]{2}
+float ([-+]?([0-9]*)?\.[0-9]*([eE][-+]?[0-9]+)?)|([-+]?([0-9]+)(\.[0-9]*)?[eE][-+]?[0-9]+)
+comment (#|\/\/).*$
+include_open ^[ \t]*@include[ \t]+\"
+
+%x COMMENT STRING INCLUDE
+
+%%
+
+\/\* { BEGIN COMMENT; }
+<COMMENT>\*\/ { BEGIN INITIAL; }
+<COMMENT>. { /* ignore */ }
+<COMMENT>\n { /* ignore */ }
+
+\" { BEGIN STRING; }
+<STRING>[^\"\\]+ { scanctx_append_string(yyextra, yytext); }
+<STRING>\\n { scanctx_append_string(yyextra, "\n"); }
+<STRING>\\r { scanctx_append_string(yyextra, "\r"); }
+<STRING>\\t { scanctx_append_string(yyextra, "\t"); }
+<STRING>\\f { scanctx_append_string(yyextra, "\f"); }
+<STRING>\\\\ { scanctx_append_string(yyextra, "\\"); }
+<STRING>\\\" { scanctx_append_string(yyextra, "\""); }
+<STRING>{hexchar} {
+ char c[2] = { (char)(strtol(yytext + 2, NULL, 16) & 0xFF),
+ 0 };
+ scanctx_append_string(yyextra, c);
+ }
+<STRING>\\ { scanctx_append_string(yyextra, "\\"); }
+<STRING>\" {
+ yylval->sval = scanctx_take_string(yyextra);
+ BEGIN INITIAL;
+ return(TOK_STRING);
+ }
+
+{include_open} { BEGIN INCLUDE; }
+<INCLUDE>[^\"\\]+ { scanctx_append_string(yyextra, yytext); }
+<INCLUDE>\\\\ { scanctx_append_string(yyextra, "\\"); }
+<INCLUDE>\\\" { scanctx_append_string(yyextra, "\""); }
+<INCLUDE>\" {
+ const char *error;
+ FILE *fp = scanctx_push_include(yyextra,
+ (void *)YY_CURRENT_BUFFER,
+ &error);
+ if(fp)
+ {
+ yyin = fp;
+ yy_switch_to_buffer(
+ yy_create_buffer(yyin, YY_BUF_SIZE, yyscanner),
+ yyscanner);
+ }
+ else
+ {
+ yyextra->config->error_text = error;
+ yyextra->config->error_file = scanctx_current_filename(
+ yyextra);
+ yyextra->config->error_line = libconfig_yyget_lineno(
+ yyscanner);
+ return TOK_ERROR;
+ }
+ BEGIN INITIAL;
+ }
+
+\n|\r|\f { /* ignore */ }
+[ \t]+ { /* ignore */ }
+
+\=|\: { return(TOK_EQUALS); }
+, { return(TOK_COMMA); }
+\{ { return(TOK_GROUP_START); }
+\} { return(TOK_GROUP_END); }
+{true} { yylval->ival = 1; return(TOK_BOOLEAN); }
+{false} { yylval->ival = 0; return(TOK_BOOLEAN); }
+{name} { yylval->sval = yytext; return(TOK_NAME); }
+{float} { yylval->fval = atof(yytext); return(TOK_FLOAT); }
+{integer} { yylval->ival = atoi(yytext); return(TOK_INTEGER); }
+{integer64} { yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
+{hex} {
+ yylval->ival = strtoul(yytext, NULL, 16);
+ return(TOK_HEX);
+ }
+{hex64} { yylval->llval = fromhex(yytext); return(TOK_HEX64); }
+\[ { return(TOK_ARRAY_START); }
+\] { return(TOK_ARRAY_END); }
+\( { return(TOK_LIST_START); }
+\) { return(TOK_LIST_END); }
+; { return(TOK_SEMICOLON); }
+{comment} { /* ignore */ }
+. { return(TOK_GARBAGE); }
+
+<<EOF>> {
+ YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include(
+ yyextra);
+ if(buf)
+ {
+ yy_delete_buffer(YY_CURRENT_BUFFER, yyscanner);
+ yy_switch_to_buffer(buf, yyscanner);
+ }
+ else
+ yyterminate();
+ }
diff --git a/3rdparty/libconfig/grammar.c b/3rdparty/libconfig/grammar.c
index e95a569f6..0331c1854 100644
--- a/3rdparty/libconfig/grammar.c
+++ b/3rdparty/libconfig/grammar.c
@@ -1,10 +1,9 @@
-
-/* A Bison parser, made by GNU Bison 2.4.1. */
+/* A Bison parser, made by GNU Bison 2.4.3. */
/* Skeleton implementation for Bison's Yacc-like parsers in C
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -46,7 +45,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.4.1"
+#define YYBISON_VERSION "2.4.3"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -130,7 +129,7 @@ void libconfig_yyerror(void *scanner, struct parse_context *ctx,
/* Line 189 of yacc.c */
-#line 134 "grammar.c"
+#line 133 "grammar.c"
/* Enabling traces. */
#ifndef YYDEBUG
@@ -219,7 +218,7 @@ typedef union YYSTYPE
/* Line 214 of yacc.c */
-#line 223 "grammar.c"
+#line 222 "grammar.c"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -231,7 +230,7 @@ typedef union YYSTYPE
/* Line 264 of yacc.c */
-#line 235 "grammar.c"
+#line 234 "grammar.c"
#ifdef short
# undef short
@@ -281,7 +280,7 @@ typedef short int yytype_int16;
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
-# if YYENABLE_NLS
+# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
@@ -660,9 +659,18 @@ static const yytype_uint8 yystos[] =
/* Like YYERROR except do call yyerror. This remains here temporarily
to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
+ Once GCC version 2 has supplanted version 1, this can go. However,
+ YYFAIL appears to be in use. Nevertheless, it is formally deprecated
+ in Bison 2.4.2's NEWS entry, where a plan to phase it out is
+ discussed. */
#define YYFAIL goto yyerrlab
+#if defined YYFAIL
+ /* This is here to suppress warnings from the GCC cpp's
+ -Wunused-macros. Normally we don't worry about that warning, but
+ some users do, and we want to make it easy for users to remove
+ YYFAIL uses, which will produce warnings from Bison 2.5. */
+#endif
#define YYRECOVERING() (!!yyerrstatus)
@@ -719,7 +727,7 @@ while (YYID (0))
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
-# if YYLTYPE_IS_TRIVIAL
+# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
@@ -1477,7 +1485,7 @@ yyreduce:
{
case 11:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 123 "grammar.y"
{
ctx->setting = config_setting_add(ctx->parent, (yyvsp[(1) - (1)].sval), CONFIG_TYPE_NONE);
@@ -1496,7 +1504,7 @@ yyreduce:
case 13:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 142 "grammar.y"
{
if(IN_LIST())
@@ -1515,7 +1523,7 @@ yyreduce:
case 14:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 157 "grammar.y"
{
if(ctx->parent)
@@ -1525,7 +1533,7 @@ yyreduce:
case 15:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 165 "grammar.y"
{
if(IN_LIST())
@@ -1544,7 +1552,7 @@ yyreduce:
case 16:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 180 "grammar.y"
{
if(ctx->parent)
@@ -1554,21 +1562,21 @@ yyreduce:
case 21:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 194 "grammar.y"
{ parsectx_append_string(ctx, (yyvsp[(1) - (1)].sval)); free((yyvsp[(1) - (1)].sval)); }
break;
case 22:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 195 "grammar.y"
{ parsectx_append_string(ctx, (yyvsp[(2) - (2)].sval)); free((yyvsp[(2) - (2)].sval)); }
break;
case 23:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 200 "grammar.y"
{
if(IN_ARRAY() || IN_LIST())
@@ -1593,7 +1601,7 @@ yyreduce:
case 24:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 220 "grammar.y"
{
if(IN_ARRAY() || IN_LIST())
@@ -1620,7 +1628,7 @@ yyreduce:
case 25:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 242 "grammar.y"
{
if(IN_ARRAY() || IN_LIST())
@@ -1647,7 +1655,7 @@ yyreduce:
case 26:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 264 "grammar.y"
{
if(IN_ARRAY() || IN_LIST())
@@ -1674,7 +1682,7 @@ yyreduce:
case 27:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 286 "grammar.y"
{
if(IN_ARRAY() || IN_LIST())
@@ -1701,7 +1709,7 @@ yyreduce:
case 28:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 308 "grammar.y"
{
if(IN_ARRAY() || IN_LIST())
@@ -1724,7 +1732,7 @@ yyreduce:
case 29:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 326 "grammar.y"
{
if(IN_ARRAY() || IN_LIST())
@@ -1754,7 +1762,7 @@ yyreduce:
case 38:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 374 "grammar.y"
{
if(IN_LIST())
@@ -1773,7 +1781,7 @@ yyreduce:
case 39:
-/* Line 1455 of yacc.c */
+/* Line 1464 of yacc.c */
#line 389 "grammar.y"
{
if(ctx->parent)
@@ -1783,8 +1791,8 @@ yyreduce:
-/* Line 1455 of yacc.c */
-#line 1788 "grammar.c"
+/* Line 1464 of yacc.c */
+#line 1796 "grammar.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1995,7 +2003,7 @@ yyreturn:
-/* Line 1675 of yacc.c */
+/* Line 1684 of yacc.c */
#line 395 "grammar.y"
diff --git a/3rdparty/libconfig/grammar.h b/3rdparty/libconfig/grammar.h
index 2ce199dde..7da95471c 100644
--- a/3rdparty/libconfig/grammar.h
+++ b/3rdparty/libconfig/grammar.h
@@ -1,10 +1,9 @@
-
-/* A Bison parser, made by GNU Bison 2.4.1. */
+/* A Bison parser, made by GNU Bison 2.4.3. */
/* Skeleton interface for Bison's Yacc-like parsers in C
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
- Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
+ 2009, 2010 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -90,7 +89,7 @@
typedef union YYSTYPE
{
-/* Line 1676 of yacc.c */
+/* Line 1685 of yacc.c */
#line 85 "grammar.y"
int ival;
@@ -100,8 +99,8 @@ typedef union YYSTYPE
-/* Line 1676 of yacc.c */
-#line 105 "grammar.h"
+/* Line 1685 of yacc.c */
+#line 104 "grammar.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
diff --git a/3rdparty/libconfig/libconfig-1.4.8 b/3rdparty/libconfig/libconfig-1.4.9
index e69de29bb..e69de29bb 100644
--- a/3rdparty/libconfig/libconfig-1.4.8
+++ b/3rdparty/libconfig/libconfig-1.4.9
diff --git a/3rdparty/libconfig/libconfig.c b/3rdparty/libconfig/libconfig.c
index e2c583310..194c891be 100644
--- a/3rdparty/libconfig/libconfig.c
+++ b/3rdparty/libconfig/libconfig.c
@@ -96,7 +96,8 @@ static void __config_locale_override(void)
#else
-/* locale overriding is pretty pointless (rathena doesn't make use of the area that uses locale functionality), but I'm actually removing it because it floods the buildbot with warnings */
+/* locale overriding is pretty pointless (Hercules doesn't make use of the area that uses locale functionality),
+ * but I'm actually removing it because it floods the buildbot with warnings */
//#warning "No way to modify calling thread's locale!"
#endif
@@ -118,7 +119,8 @@ static void __config_locale_restore(void)
#else
-/* locale overriding is pretty pointless (rathena doesn't make use of the area that uses locale functionality), but I'm actually removing it because it floods the buildbot with warnings */
+/* locale overriding is pretty pointless (Hercules doesn't make use of the area that uses locale functionality),
+ * but I'm actually removing it because it floods the buildbot with warnings */
//#warning "No way to modify calling thread's locale!"
#endif
@@ -535,12 +537,12 @@ static int __config_validate_name(const char *name)
if(*p == '\0')
return(CONFIG_FALSE);
- if(! isalpha((unsigned char)*p) && (*p != '*'))
+ if(! isalpha((int)*p) && (*p != '*'))
return(CONFIG_FALSE);
for(++p; *p; ++p)
{
- if(! (isalpha((unsigned char)*p) || isdigit((unsigned char)*p) || strchr("*_-'", (int)*p)))
+ if(! (isalpha((int)*p) || isdigit((int)*p) || strchr("*_-'", (int)*p)))
return(CONFIG_FALSE);
}
@@ -1531,11 +1533,24 @@ config_setting_t *config_setting_add(config_setting_t *parent,
if((parent->type == CONFIG_TYPE_ARRAY) || (parent->type == CONFIG_TYPE_LIST))
name = NULL;
- if(name) {
+ if(name)
+ {
if(! __config_validate_name(name))
return(NULL);
}
+#if 0
+ /* https://github.com/HerculesWS/Hercules/pull/136#discussion_r6363319
+ * With this code, accidental duplicate keys would cause the file parsing to fail
+ * (would cause several issues during runtime on file reloads), while libconfig's code
+ * has no problems with duplicate members so it was ducked out -- TODO: looking now though
+ * I'd think it could be useful to have it display a warning or error message when finding
+ * duplicate keys instead of silently moving on. [Ind]
+ */
+ if(config_setting_get_member(parent, name) != NULL)
+ return(NULL); /* already exists */
+#endif
+
return(config_setting_create(parent, name, type));
}
diff --git a/3rdparty/libconfig/libconfig.h b/3rdparty/libconfig/libconfig.h
index 683bda80b..b0ab8f9f7 100644
--- a/3rdparty/libconfig/libconfig.h
+++ b/3rdparty/libconfig/libconfig.h
@@ -40,7 +40,7 @@ extern "C" {
#define LIBCONFIG_VER_MAJOR 1
#define LIBCONFIG_VER_MINOR 4
-#define LIBCONFIG_VER_REVISION 8
+#define LIBCONFIG_VER_REVISION 9
#include <stdio.h>
diff --git a/3rdparty/libconfig/scanner.c b/3rdparty/libconfig/scanner.c
index 118fcf8ad..55e029f9f 100644
--- a/3rdparty/libconfig/scanner.c
+++ b/3rdparty/libconfig/scanner.c
@@ -1,6 +1,10 @@
#line 2 "scanner.c"
+#line 36 "scanner.l"
+#include "scanctx.h"
+
+
-#line 4 "scanner.c"
+#line 8 "scanner.c"
#define YY_INT_ALIGNED short int
@@ -9,7 +13,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 35
+#define YY_FLEX_SUBMINOR_VERSION 37
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -159,15 +163,7 @@ typedef void* yyscan_t;
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
#define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@@ -179,6 +175,11 @@ typedef void* yyscan_t;
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
@@ -214,11 +215,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
#define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
@@ -236,7 +232,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
- int yy_n_chars;
+ yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@@ -315,7 +311,7 @@ static void libconfig_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yys
YY_BUFFER_STATE libconfig_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
void *libconfig_yyalloc (yy_size_t ,yyscan_t yyscanner );
void *libconfig_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
@@ -345,7 +341,7 @@ void libconfig_yyfree (void * ,yyscan_t yyscanner );
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
-#define libconfig_yywrap(n) 1
+#define libconfig_yywrap(yyscanner) 1
#define YY_SKIP_YYWRAP
typedef unsigned char YY_CHAR;
@@ -369,8 +365,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
*yy_cp = '\0'; \
yyg->yy_c_buf_p = yy_cp;
-#define YY_NUM_RULES 41
-#define YY_END_OF_BUFFER 42
+#define YY_NUM_RULES 42
+#define YY_END_OF_BUFFER 43
/* This struct is not used in this scanner,
but its presence is necessary. */
struct yy_trans_info
@@ -380,18 +376,18 @@ struct yy_trans_info
};
static yyconst flex_int16_t yy_accept[103] =
{ 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 42, 40,
- 21, 20, 20, 5, 40, 36, 37, 28, 40, 23,
- 29, 40, 30, 30, 22, 38, 28, 28, 34, 35,
- 24, 25, 21, 40, 3, 4, 3, 6, 14, 41,
- 16, 19, 41, 21, 0, 39, 28, 29, 30, 29,
- 0, 1, 0, 29, 0, 31, 0, 28, 28, 21,
+ 0, 0, 0, 0, 0, 0, 0, 0, 43, 41,
+ 22, 21, 21, 5, 41, 37, 38, 29, 41, 24,
+ 30, 41, 31, 31, 23, 39, 29, 29, 35, 36,
+ 25, 26, 22, 41, 3, 4, 3, 6, 15, 14,
+ 17, 20, 42, 22, 0, 40, 29, 30, 31, 30,
+ 0, 1, 0, 30, 0, 32, 0, 29, 29, 22,
0, 0, 2, 6, 12, 0, 11, 10, 7, 8,
- 9, 16, 18, 17, 0, 29, 29, 0, 0, 29,
- 31, 32, 28, 28, 0, 0, 0, 29, 33, 28,
- 26, 0, 13, 33, 27, 0, 0, 0, 0, 0,
+ 9, 17, 19, 18, 0, 30, 30, 0, 0, 30,
+ 32, 33, 29, 29, 0, 0, 0, 30, 34, 29,
+ 27, 0, 13, 34, 28, 0, 0, 0, 0, 0,
- 15, 0
+ 16, 0
} ;
static yyconst flex_int32_t yy_ec[256] =
@@ -399,17 +395,17 @@ static yyconst flex_int32_t yy_ec[256] =
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 4, 5, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 2, 1, 6, 7, 1, 1, 1, 26, 8,
- 9, 10, 11, 12, 13, 14, 15, 16, 17, 17,
- 17, 17, 17, 17, 17, 17, 17, 18, 19, 1,
- 20, 1, 1, 21, 22, 23, 23, 23, 24, 25,
- 26, 26, 26, 26, 26, 27, 26, 26, 26, 26,
- 26, 28, 29, 30, 31, 26, 26, 32, 26, 26,
- 33, 34, 35, 1, 36, 1, 22, 23, 37, 38,
-
- 39, 40, 26, 26, 41, 26, 26, 42, 26, 43,
- 26, 26, 26, 44, 29, 45, 46, 26, 26, 32,
- 26, 26, 47, 1, 48, 1, 1, 1, 1, 1,
+ 1, 2, 1, 6, 7, 1, 1, 1, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 19, 20, 1,
+ 21, 1, 1, 22, 23, 24, 24, 24, 25, 26,
+ 27, 27, 27, 27, 27, 28, 27, 27, 27, 27,
+ 27, 29, 30, 31, 32, 27, 27, 33, 27, 27,
+ 34, 35, 36, 1, 8, 1, 23, 24, 37, 38,
+
+ 39, 40, 27, 27, 41, 27, 27, 42, 27, 43,
+ 27, 27, 27, 44, 30, 45, 46, 27, 27, 33,
+ 27, 27, 47, 1, 48, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -428,10 +424,10 @@ static yyconst flex_int32_t yy_ec[256] =
static yyconst flex_int32_t yy_meta[49] =
{ 0,
- 1, 1, 1, 1, 1, 2, 1, 1, 1, 3,
- 1, 1, 3, 1, 1, 4, 4, 1, 1, 1,
- 1, 4, 4, 4, 4, 3, 3, 3, 3, 3,
- 3, 3, 1, 2, 1, 3, 4, 4, 4, 4,
+ 1, 1, 1, 1, 1, 2, 1, 3, 1, 1,
+ 3, 1, 1, 3, 1, 1, 4, 4, 1, 1,
+ 1, 1, 4, 4, 4, 4, 3, 3, 3, 3,
+ 3, 3, 3, 1, 2, 1, 4, 4, 4, 4,
3, 3, 3, 3, 3, 3, 1, 1
} ;
@@ -439,17 +435,17 @@ static yyconst flex_int16_t yy_base[113] =
{ 0,
0, 47, 47, 48, 46, 47, 48, 49, 203, 204,
200, 204, 204, 204, 198, 204, 204, 0, 45, 204,
- 47, 50, 60, 74, 204, 204, 178, 28, 204, 204,
- 204, 204, 64, 158, 204, 204, 183, 0, 204, 63,
- 0, 204, 83, 195, 193, 204, 0, 88, 102, 98,
- 62, 204, 190, 104, 119, 162, 0, 67, 65, 121,
- 127, 124, 204, 0, 204, 0, 204, 204, 204, 204,
- 204, 0, 204, 204, 108, 117, 122, 134, 132, 136,
- 204, 139, 136, 116, 126, 0, 140, 142, 135, 130,
- 0, 102, 204, 204, 0, 85, 72, 63, 98, 158,
-
- 204, 204, 169, 173, 177, 181, 183, 187, 191, 89,
- 66, 63
+ 39, 50, 62, 71, 204, 204, 177, 41, 204, 204,
+ 204, 204, 69, 158, 204, 204, 182, 0, 204, 69,
+ 0, 204, 59, 195, 193, 204, 0, 80, 100, 104,
+ 118, 204, 192, 106, 130, 166, 0, 64, 61, 98,
+ 152, 149, 204, 0, 204, 0, 204, 204, 204, 204,
+ 204, 0, 204, 204, 50, 55, 116, 139, 109, 120,
+ 204, 161, 155, 115, 127, 0, 132, 141, 135, 121,
+ 0, 120, 204, 204, 0, 106, 78, 72, 106, 159,
+
+ 204, 204, 165, 169, 173, 177, 179, 183, 187, 99,
+ 72, 70
} ;
static yyconst flex_int16_t yy_def[113] =
@@ -471,27 +467,27 @@ static yyconst flex_int16_t yy_def[113] =
static yyconst flex_int16_t yy_nxt[253] =
{ 0,
- 10, 11, 12, 13, 13, 14, 15, 16, 17, 18,
- 19, 20, 19, 21, 22, 23, 24, 25, 26, 25,
- 10, 18, 18, 18, 27, 18, 18, 18, 18, 28,
- 18, 18, 29, 10, 30, 10, 18, 18, 18, 27,
+ 10, 11, 12, 13, 13, 14, 15, 10, 16, 17,
+ 18, 19, 20, 19, 21, 22, 23, 24, 25, 26,
+ 25, 10, 18, 18, 18, 27, 18, 18, 18, 18,
+ 28, 18, 18, 29, 10, 30, 18, 18, 18, 27,
18, 18, 18, 18, 28, 18, 31, 32, 33, 36,
- 36, 39, 39, 42, 42, 59, 37, 37, 48, 52,
- 49, 49, 50, 50, 53, 60, 93, 34, 65, 86,
- 51, 59, 75, 54, 75, 49, 49, 76, 76, 40,
- 40, 43, 43, 55, 61, 51, 56, 54, 73, 49,
- 49, 57, 82, 83, 66, 84, 67, 55, 55, 100,
-
- 56, 99, 68, 50, 50, 69, 70, 71, 83, 98,
- 84, 51, 55, 50, 50, 54, 74, 49, 49, 77,
- 77, 51, 60, 76, 76, 55, 51, 78, 56, 79,
- 97, 79, 76, 76, 80, 80, 51, 77, 77, 91,
- 55, 61, 78, 96, 87, 78, 87, 80, 80, 88,
- 88, 80, 80, 95, 91, 88, 88, 88, 88, 100,
- 78, 94, 92, 101, 90, 89, 85, 62, 95, 35,
- 35, 35, 35, 38, 38, 38, 38, 41, 41, 41,
- 41, 45, 45, 45, 45, 47, 47, 64, 81, 64,
- 64, 72, 46, 72, 72, 46, 44, 63, 62, 58,
+ 36, 39, 39, 42, 42, 50, 50, 37, 37, 48,
+ 52, 49, 49, 51, 73, 53, 76, 76, 34, 59,
+ 60, 76, 76, 93, 65, 86, 54, 51, 49, 49,
+ 40, 40, 43, 43, 59, 54, 55, 49, 49, 56,
+ 61, 83, 84, 74, 57, 55, 50, 50, 56, 60,
+
+ 55, 66, 82, 67, 51, 83, 84, 100, 68, 55,
+ 99, 69, 70, 71, 54, 98, 49, 49, 51, 61,
+ 50, 50, 77, 77, 55, 80, 80, 56, 51, 75,
+ 78, 75, 77, 77, 76, 76, 80, 80, 55, 91,
+ 78, 79, 51, 79, 78, 95, 80, 80, 88, 88,
+ 87, 97, 87, 91, 78, 88, 88, 88, 88, 95,
+ 100, 96, 94, 92, 101, 35, 35, 35, 35, 38,
+ 38, 38, 38, 41, 41, 41, 41, 45, 45, 45,
+ 45, 47, 47, 64, 90, 64, 64, 72, 89, 72,
+ 72, 85, 62, 81, 46, 46, 44, 63, 62, 58,
46, 44, 102, 9, 102, 102, 102, 102, 102, 102,
102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
@@ -508,22 +504,22 @@ static yyconst flex_int16_t yy_chk[253] =
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
- 4, 5, 6, 7, 8, 28, 3, 4, 19, 22,
- 19, 19, 21, 21, 22, 33, 112, 2, 40, 111,
- 21, 28, 51, 23, 51, 23, 23, 51, 51, 5,
- 6, 7, 8, 23, 33, 21, 23, 24, 43, 24,
- 24, 23, 110, 58, 40, 59, 40, 24, 23, 99,
-
- 24, 98, 40, 48, 48, 40, 40, 40, 58, 97,
- 59, 48, 24, 50, 50, 49, 43, 49, 49, 54,
- 54, 50, 60, 75, 75, 49, 48, 54, 49, 55,
- 96, 55, 76, 76, 55, 55, 50, 77, 77, 84,
- 49, 60, 54, 92, 78, 77, 78, 79, 79, 78,
- 78, 80, 80, 90, 84, 87, 87, 88, 88, 100,
- 77, 89, 85, 100, 83, 82, 62, 61, 90, 103,
- 103, 103, 103, 104, 104, 104, 104, 105, 105, 105,
- 105, 106, 106, 106, 106, 107, 107, 108, 56, 108,
- 108, 109, 53, 109, 109, 45, 44, 37, 34, 27,
+ 4, 5, 6, 7, 8, 21, 21, 3, 4, 19,
+ 22, 19, 19, 21, 43, 22, 75, 75, 2, 28,
+ 33, 76, 76, 112, 40, 111, 23, 21, 23, 23,
+ 5, 6, 7, 8, 28, 24, 23, 24, 24, 23,
+ 33, 58, 59, 43, 23, 24, 48, 48, 24, 60,
+
+ 23, 40, 110, 40, 48, 58, 59, 99, 40, 24,
+ 98, 40, 40, 40, 49, 97, 49, 49, 48, 60,
+ 50, 50, 54, 54, 49, 79, 79, 49, 50, 51,
+ 54, 51, 77, 77, 51, 51, 80, 80, 49, 84,
+ 77, 55, 50, 55, 54, 90, 55, 55, 87, 87,
+ 78, 96, 78, 84, 77, 78, 78, 88, 88, 90,
+ 100, 92, 89, 85, 100, 103, 103, 103, 103, 104,
+ 104, 104, 104, 105, 105, 105, 105, 106, 106, 106,
+ 106, 107, 107, 108, 83, 108, 108, 109, 82, 109,
+ 109, 62, 61, 56, 53, 45, 44, 37, 34, 27,
15, 11, 9, 102, 102, 102, 102, 102, 102, 102,
102, 102, 102, 102, 102, 102, 102, 102, 102, 102,
@@ -534,11 +530,11 @@ static yyconst flex_int16_t yy_chk[253] =
} ;
/* Table of booleans, true if rule could match eol. */
-static yyconst flex_int32_t yy_rule_can_match_eol[42] =
+static yyconst flex_int32_t yy_rule_can_match_eol[43] =
{ 0,
-0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
- 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, };
+0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
+ 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, };
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
@@ -571,10 +567,12 @@ static yyconst flex_int32_t yy_rule_can_match_eol[42] =
----------------------------------------------------------------------------
*/
#define YY_NO_UNISTD_H 1
-#line 35 "scanner.l"
+#line 40 "scanner.l"
#ifdef _MSC_VER
#pragma warning (disable: 4996)
+/* disable MSVC warning "signed/unsigned mismatch" associated with code generated by flex versions such as 2.5.35. */
+#pragma warning (disable:4018)
#endif
#include <stdlib.h>
@@ -583,7 +581,6 @@ static yyconst flex_int32_t yy_rule_can_match_eol[42] =
#include "grammar.h"
#include "wincompat.h"
#include "parsectx.h"
-#include "scanctx.h"
#define YY_NO_INPUT // Suppress generation of useless input() function
@@ -622,21 +619,13 @@ static unsigned long long fromhex(const char *s)
}
-#line 626 "scanner.c"
+#line 623 "scanner.c"
#define INITIAL 0
#define COMMENT 1
#define STRING 2
#define INCLUDE 3
-#ifndef YY_NO_UNISTD_H
-/* Special case for "unistd.h", since it is non-ANSI. We include it way
- * down here because we want the user's section 1 to have been scanned first.
- * The user has a chance to override it with an option.
- */
-#include <unistd.h>
-#endif
-
#define YY_EXTRA_TYPE struct scan_context *
/* Holds the entire state of the reentrant scanner. */
@@ -652,8 +641,8 @@ struct yyguts_t
size_t yy_buffer_stack_max; /**< capacity of stack. */
YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
char yy_hold_char;
- int yy_n_chars;
- int yyleng_r;
+ yy_size_t yy_n_chars;
+ yy_size_t yyleng_r;
char *yy_c_buf_p;
int yy_init;
int yy_start;
@@ -706,7 +695,7 @@ FILE *libconfig_yyget_out (yyscan_t yyscanner );
void libconfig_yyset_out (FILE * out_str ,yyscan_t yyscanner );
-int libconfig_yyget_leng (yyscan_t yyscanner );
+yy_size_t libconfig_yyget_leng (yyscan_t yyscanner );
char *libconfig_yyget_text (yyscan_t yyscanner );
@@ -714,6 +703,10 @@ int libconfig_yyget_lineno (yyscan_t yyscanner );
void libconfig_yyset_lineno (int line_number ,yyscan_t yyscanner );
+int libconfig_yyget_column (yyscan_t yyscanner );
+
+void libconfig_yyset_column (int column_no ,yyscan_t yyscanner );
+
YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner );
void libconfig_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
@@ -750,12 +743,7 @@ static int input (yyscan_t yyscanner );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
#define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
@@ -862,10 +850,10 @@ YY_DECL
register int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
-#line 100 "scanner.l"
+#line 105 "scanner.l"
-#line 869 "scanner.c"
+#line 857 "scanner.c"
yylval = yylval_param;
@@ -927,16 +915,12 @@ yy_match:
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
- while ( yy_base[yy_current_state] != 204 );
+ while ( yy_current_state != 102 );
+ yy_cp = yyg->yy_last_accepting_cpos;
+ yy_current_state = yyg->yy_last_accepting_state;
yy_find_action:
yy_act = yy_accept[yy_current_state];
- if ( yy_act == 0 )
- { /* have to back up */
- yy_cp = yyg->yy_last_accepting_cpos;
- yy_current_state = yyg->yy_last_accepting_state;
- yy_act = yy_accept[yy_current_state];
- }
YY_DO_BEFORE_ACTION;
@@ -965,69 +949,69 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
-#line 102 "scanner.l"
+#line 107 "scanner.l"
{ BEGIN COMMENT; }
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 103 "scanner.l"
+#line 108 "scanner.l"
{ BEGIN INITIAL; }
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 104 "scanner.l"
+#line 109 "scanner.l"
{ /* ignore */ }
YY_BREAK
case 4:
/* rule 4 can match eol */
YY_RULE_SETUP
-#line 105 "scanner.l"
+#line 110 "scanner.l"
{ /* ignore */ }
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 107 "scanner.l"
+#line 112 "scanner.l"
{ BEGIN STRING; }
YY_BREAK
case 6:
/* rule 6 can match eol */
YY_RULE_SETUP
-#line 108 "scanner.l"
+#line 113 "scanner.l"
{ scanctx_append_string(yyextra, yytext); }
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 109 "scanner.l"
+#line 114 "scanner.l"
{ scanctx_append_string(yyextra, "\n"); }
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 110 "scanner.l"
+#line 115 "scanner.l"
{ scanctx_append_string(yyextra, "\r"); }
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 111 "scanner.l"
+#line 116 "scanner.l"
{ scanctx_append_string(yyextra, "\t"); }
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 112 "scanner.l"
+#line 117 "scanner.l"
{ scanctx_append_string(yyextra, "\f"); }
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 113 "scanner.l"
+#line 118 "scanner.l"
{ scanctx_append_string(yyextra, "\\"); }
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 114 "scanner.l"
+#line 119 "scanner.l"
{ scanctx_append_string(yyextra, "\""); }
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 115 "scanner.l"
+#line 120 "scanner.l"
{
char c[2] = { (char)(strtol(yytext + 2, NULL, 16) & 0xFF),
0 };
@@ -1036,37 +1020,42 @@ YY_RULE_SETUP
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 120 "scanner.l"
+#line 125 "scanner.l"
+{ scanctx_append_string(yyextra, "\\"); }
+ YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 126 "scanner.l"
{
yylval->sval = scanctx_take_string(yyextra);
BEGIN INITIAL;
return(TOK_STRING);
}
YY_BREAK
-case 15:
+case 16:
YY_RULE_SETUP
-#line 126 "scanner.l"
+#line 132 "scanner.l"
{ BEGIN INCLUDE; }
YY_BREAK
-case 16:
-/* rule 16 can match eol */
+case 17:
+/* rule 17 can match eol */
YY_RULE_SETUP
-#line 127 "scanner.l"
+#line 133 "scanner.l"
{ scanctx_append_string(yyextra, yytext); }
YY_BREAK
-case 17:
+case 18:
YY_RULE_SETUP
-#line 128 "scanner.l"
+#line 134 "scanner.l"
{ scanctx_append_string(yyextra, "\\"); }
YY_BREAK
-case 18:
+case 19:
YY_RULE_SETUP
-#line 129 "scanner.l"
+#line 135 "scanner.l"
{ scanctx_append_string(yyextra, "\""); }
YY_BREAK
-case 19:
+case 20:
YY_RULE_SETUP
-#line 130 "scanner.l"
+#line 136 "scanner.l"
{
const char *error;
FILE *fp = scanctx_push_include(yyextra,
@@ -1089,123 +1078,123 @@ YY_RULE_SETUP
BEGIN INITIAL;
}
YY_BREAK
-case 20:
-/* rule 20 can match eol */
+case 21:
+/* rule 21 can match eol */
YY_RULE_SETUP
-#line 154 "scanner.l"
+#line 160 "scanner.l"
{ /* ignore */ }
YY_BREAK
-case 21:
+case 22:
YY_RULE_SETUP
-#line 155 "scanner.l"
+#line 161 "scanner.l"
{ /* ignore */ }
YY_BREAK
-case 22:
+case 23:
YY_RULE_SETUP
-#line 157 "scanner.l"
+#line 163 "scanner.l"
{ return(TOK_EQUALS); }
YY_BREAK
-case 23:
+case 24:
YY_RULE_SETUP
-#line 158 "scanner.l"
+#line 164 "scanner.l"
{ return(TOK_COMMA); }
YY_BREAK
-case 24:
+case 25:
YY_RULE_SETUP
-#line 159 "scanner.l"
+#line 165 "scanner.l"
{ return(TOK_GROUP_START); }
YY_BREAK
-case 25:
+case 26:
YY_RULE_SETUP
-#line 160 "scanner.l"
+#line 166 "scanner.l"
{ return(TOK_GROUP_END); }
YY_BREAK
-case 26:
+case 27:
YY_RULE_SETUP
-#line 161 "scanner.l"
+#line 167 "scanner.l"
{ yylval->ival = 1; return(TOK_BOOLEAN); }
YY_BREAK
-case 27:
+case 28:
YY_RULE_SETUP
-#line 162 "scanner.l"
+#line 168 "scanner.l"
{ yylval->ival = 0; return(TOK_BOOLEAN); }
YY_BREAK
-case 28:
+case 29:
YY_RULE_SETUP
-#line 163 "scanner.l"
+#line 169 "scanner.l"
{ yylval->sval = yytext; return(TOK_NAME); }
YY_BREAK
-case 29:
+case 30:
YY_RULE_SETUP
-#line 164 "scanner.l"
+#line 170 "scanner.l"
{ yylval->fval = atof(yytext); return(TOK_FLOAT); }
YY_BREAK
-case 30:
+case 31:
YY_RULE_SETUP
-#line 165 "scanner.l"
+#line 171 "scanner.l"
{ yylval->ival = atoi(yytext); return(TOK_INTEGER); }
YY_BREAK
-case 31:
+case 32:
YY_RULE_SETUP
-#line 166 "scanner.l"
+#line 172 "scanner.l"
{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); }
YY_BREAK
-case 32:
+case 33:
YY_RULE_SETUP
-#line 167 "scanner.l"
+#line 173 "scanner.l"
{
yylval->ival = strtoul(yytext, NULL, 16);
return(TOK_HEX);
}
YY_BREAK
-case 33:
+case 34:
YY_RULE_SETUP
-#line 171 "scanner.l"
+#line 177 "scanner.l"
{ yylval->llval = fromhex(yytext); return(TOK_HEX64); }
YY_BREAK
-case 34:
+case 35:
YY_RULE_SETUP
-#line 172 "scanner.l"
+#line 178 "scanner.l"
{ return(TOK_ARRAY_START); }
YY_BREAK
-case 35:
+case 36:
YY_RULE_SETUP
-#line 173 "scanner.l"
+#line 179 "scanner.l"
{ return(TOK_ARRAY_END); }
YY_BREAK
-case 36:
+case 37:
YY_RULE_SETUP
-#line 174 "scanner.l"
+#line 180 "scanner.l"
{ return(TOK_LIST_START); }
YY_BREAK
-case 37:
+case 38:
YY_RULE_SETUP
-#line 175 "scanner.l"
+#line 181 "scanner.l"
{ return(TOK_LIST_END); }
YY_BREAK
-case 38:
+case 39:
YY_RULE_SETUP
-#line 176 "scanner.l"
+#line 182 "scanner.l"
{ return(TOK_SEMICOLON); }
YY_BREAK
-case 39:
+case 40:
*yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
yyg->yy_c_buf_p = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
-#line 177 "scanner.l"
+#line 183 "scanner.l"
{ /* ignore */ }
YY_BREAK
-case 40:
+case 41:
YY_RULE_SETUP
-#line 178 "scanner.l"
+#line 184 "scanner.l"
{ return(TOK_GARBAGE); }
YY_BREAK
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(COMMENT):
case YY_STATE_EOF(STRING):
case YY_STATE_EOF(INCLUDE):
-#line 180 "scanner.l"
+#line 186 "scanner.l"
{
YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include(
yyextra);
@@ -1218,12 +1207,12 @@ case YY_STATE_EOF(INCLUDE):
yyterminate();
}
YY_BREAK
-case 41:
+case 42:
YY_RULE_SETUP
-#line 191 "scanner.l"
+#line 197 "scanner.l"
ECHO;
YY_BREAK
-#line 1227 "scanner.c"
+#line 1216 "scanner.c"
case YY_END_OF_BUFFER:
{
@@ -1288,7 +1277,8 @@ ECHO;
else
{
- yy_cp = yyg->yy_c_buf_p;
+ yy_cp = yyg->yy_last_accepting_cpos;
+ yy_current_state = yyg->yy_last_accepting_state;
goto yy_find_action;
}
}
@@ -1408,21 +1398,21 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
{
- int num_to_read =
+ yy_size_t num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
int yy_c_buf_p_offset =
(int) (yyg->yy_c_buf_p - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
- int new_size = b->yy_buf_size * 2;
+ yy_size_t new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@@ -1453,7 +1443,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- yyg->yy_n_chars, (size_t) num_to_read );
+ yyg->yy_n_chars, num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
}
@@ -1551,6 +1541,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 102);
+ (void)yyg;
return yy_is_jam ? 0 : yy_current_state;
}
@@ -1579,7 +1570,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
else
{ /* need more input */
- int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+ yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
++yyg->yy_c_buf_p;
switch ( yy_get_next_buffer( yyscanner ) )
@@ -1751,10 +1742,6 @@ static void libconfig_yy_load_buffer_state (yyscan_t yyscanner)
libconfig_yyfree((void *) b ,yyscanner );
}
-#ifndef __cplusplus
-extern int isatty (int );
-#endif /* __cplusplus */
-
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a libconfig_yyrestart() or at EOF.
@@ -1779,7 +1766,7 @@ extern int isatty (int );
b->yy_bs_column = 0;
}
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+ b->yy_is_interactive = 0;
errno = oerrno;
}
@@ -1871,7 +1858,7 @@ void libconfig_yypop_buffer_state (yyscan_t yyscanner)
*/
static void libconfig_yyensure_buffer_stack (yyscan_t yyscanner)
{
- int num_to_alloc;
+ yy_size_t num_to_alloc;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
if (!yyg->yy_buffer_stack) {
@@ -1969,7 +1956,7 @@ YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char * yystr , yyscan_t yyscan
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
+YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
@@ -2084,7 +2071,7 @@ FILE *libconfig_yyget_out (yyscan_t yyscanner)
/** Get the length of the current token.
* @param yyscanner The scanner object.
*/
-int libconfig_yyget_leng (yyscan_t yyscanner)
+yy_size_t libconfig_yyget_leng (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
return yyleng;
@@ -2120,7 +2107,7 @@ void libconfig_yyset_lineno (int line_number , yyscan_t yyscanner)
/* lineno is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- yy_fatal_error( "libconfig_yyset_lineno called with no buffer" , yyscanner);
+ YY_FATAL_ERROR( "libconfig_yyset_lineno called with no buffer" );
yylineno = line_number;
}
@@ -2135,7 +2122,7 @@ void libconfig_yyset_column (int column_no , yyscan_t yyscanner)
/* column is only valid if an input buffer exists. */
if (! YY_CURRENT_BUFFER )
- yy_fatal_error( "libconfig_yyset_column called with no buffer" , yyscanner);
+ YY_FATAL_ERROR( "libconfig_yyset_column called with no buffer" );
yycolumn = column_no;
}
@@ -2359,4 +2346,4 @@ void libconfig_yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
-#line 191 "scanner.l"
+#line 197 "scanner.l"
diff --git a/3rdparty/libconfig/scanner.h b/3rdparty/libconfig/scanner.h
index baa6f771f..da1134498 100644
--- a/3rdparty/libconfig/scanner.h
+++ b/3rdparty/libconfig/scanner.h
@@ -3,8 +3,12 @@
#define libconfig_yyIN_HEADER 1
#line 6 "scanner.h"
+#line 36 "scanner.l"
+#include "scanctx.h"
-#line 8 "scanner.h"
+
+
+#line 12 "scanner.h"
#define YY_INT_ALIGNED short int
@@ -13,7 +17,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 33
+#define YY_FLEX_SUBMINOR_VERSION 37
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -35,7 +39,7 @@
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-#if __STDC_VERSION__ >= 199901L
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
* if you want the limit (max/min) macros for int types.
@@ -58,7 +62,6 @@ typedef int flex_int32_t;
typedef unsigned char flex_uint8_t;
typedef unsigned short int flex_uint16_t;
typedef unsigned int flex_uint32_t;
-#endif /* ! C99 */
/* Limits of integral types. */
#ifndef INT8_MIN
@@ -89,6 +92,8 @@ typedef unsigned int flex_uint32_t;
#define UINT32_MAX (4294967295U)
#endif
+#endif /* ! C99 */
+
#endif /* ! FLEXINT_H */
#ifdef __cplusplus
@@ -98,11 +103,12 @@ typedef unsigned int flex_uint32_t;
#else /* ! __cplusplus */
-#if __STDC__
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
#define YY_USE_CONST
-#endif /* __STDC__ */
+#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
#ifdef YY_USE_CONST
@@ -128,21 +134,19 @@ typedef void* yyscan_t;
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
#define yy_flex_debug yyg->yy_flex_debug_r
-int libconfig_yylex_init (yyscan_t* scanner);
+/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
+#define YY_BUF_SIZE 16384
+#endif
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
-typedef unsigned int yy_size_t;
+typedef size_t yy_size_t;
#endif
#ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -162,7 +166,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
- int yy_n_chars;
+ yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@@ -206,13 +210,13 @@ void libconfig_yypop_buffer_state (yyscan_t yyscanner );
YY_BUFFER_STATE libconfig_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
-YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+YY_BUFFER_STATE libconfig_yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
void *libconfig_yyalloc (yy_size_t ,yyscan_t yyscanner );
void *libconfig_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
void libconfig_yyfree (void * ,yyscan_t yyscanner );
-#define libconfig_yywrap(n) 1
+#define libconfig_yywrap(yyscanner) 1
#define YY_SKIP_YYWRAP
#define yytext_ptr yytext_r
@@ -220,12 +224,16 @@ void libconfig_yyfree (void * ,yyscan_t yyscanner );
#ifdef YY_HEADER_EXPORT_START_CONDITIONS
#define INITIAL 0
#define COMMENT 1
+#define STRING 2
+#define INCLUDE 3
#endif
-#ifndef YY_EXTRA_TYPE
-#define YY_EXTRA_TYPE void *
-#endif
+#define YY_EXTRA_TYPE struct scan_context *
+
+int libconfig_yylex_init (yyscan_t* scanner);
+
+int libconfig_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
/* Accessor methods to globals.
These are made visible to non-reentrant scanners for convenience. */
@@ -248,7 +256,7 @@ FILE *libconfig_yyget_out (yyscan_t yyscanner );
void libconfig_yyset_out (FILE * out_str ,yyscan_t yyscanner );
-int libconfig_yyget_leng (yyscan_t yyscanner );
+yy_size_t libconfig_yyget_leng (yyscan_t yyscanner );
char *libconfig_yyget_text (yyscan_t yyscanner );
@@ -256,6 +264,10 @@ int libconfig_yyget_lineno (yyscan_t yyscanner );
void libconfig_yyset_lineno (int line_number ,yyscan_t yyscanner );
+int libconfig_yyget_column (yyscan_t yyscanner );
+
+void libconfig_yyset_column (int column_no ,yyscan_t yyscanner );
+
YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner );
void libconfig_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
@@ -300,9 +312,11 @@ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
#ifndef YY_DECL
#define YY_DECL_IS_OURS 1
-extern int libconfig_yylex (YYSTYPE * yylval_param ,yyscan_t yyscanner);
+extern int libconfig_yylex \
+ (YYSTYPE * yylval_param ,yyscan_t yyscanner);
-#define YY_DECL int libconfig_yylex (YYSTYPE * yylval_param , yyscan_t yyscanner)
+#define YY_DECL int libconfig_yylex \
+ (YYSTYPE * yylval_param , yyscan_t yyscanner)
#endif /* !YY_DECL */
/* yy_get_previous_state - get the state just before the EOB char was reached */
@@ -319,8 +333,8 @@ extern int libconfig_yylex (YYSTYPE * yylval_param ,yyscan_t yyscanner);
#undef YY_DECL
#endif
-#line 130 "scanner.l"
+#line 197 "scanner.l"
-#line 325 "scanner.h"
+#line 339 "scanner.h"
#undef libconfig_yyIN_HEADER
#endif /* libconfig_yyHEADER_H */
diff --git a/3rdparty/mt19937ar/Makefile.in b/3rdparty/mt19937ar/Makefile.in
index b899c413f..7891bbd2d 100644
--- a/3rdparty/mt19937ar/Makefile.in
+++ b/3rdparty/mt19937ar/Makefile.in
@@ -8,7 +8,7 @@ CC = @CC@
export CC
#####################################################################
-.PHONY : all clean help
+.PHONY: all clean help
all: $(MT19937AR_OBJ)
diff --git a/Makefile.in b/Makefile.in
index 5d59a7144..d78aa631d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -2,14 +2,13 @@
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
- ALL_DEPENDS=common_sql login_sql char_sql map_sql tools import
- SQL_DEPENDS=common_sql login_sql char_sql map_sql import
+ ALL_DEPENDS=common_sql login_sql char_sql map_sql tools | import
+ SQL_DEPENDS=common_sql login_sql char_sql map_sql | import
COMMON_SQL_DEPENDS=mt19937ar libconfig
LOGIN_SQL_DEPENDS=mt19937ar libconfig common_sql
CHAR_SQL_DEPENDS=mt19937ar libconfig common_sql
MAP_SQL_DEPENDS=mt19937ar libconfig common_sql
TOOLS_DEPENDS=mt19937ar libconfig common_sql
- CONVERTERS_DEPENDS=common_sql
else
ALL_DEPENDS=needs_mysql
SQL_DEPENDS=needs_mysql
@@ -49,30 +48,39 @@ all: $(ALL_DEPENDS)
sql: $(SQL_DEPENDS)
common_sql: $(COMMON_SQL_DEPENDS)
+ @echo " MAKE $@"
@$(MAKE) -C src/common sql
mt19937ar:
+ @echo " MAKE $@"
@$(MAKE) -C 3rdparty/mt19937ar
libconfig:
+ @echo " MAKE $@"
@$(MAKE) -C 3rdparty/libconfig
login_sql: $(LOGIN_SQL_DEPENDS)
+ @echo " MAKE $@"
@$(MAKE) -C src/login sql
char_sql: $(CHAR_SQL_DEPENDS)
+ @echo " MAKE $@"
@$(MAKE) -C src/char
map_sql: $(MAP_SQL_DEPENDS)
+ @echo " MAKE $@"
@$(MAKE) -C src/map sql
tools: $(TOOLS_DEPENDS)
+ @echo " MAKE $@"
@$(MAKE) -C src/tool
test:
+ @echo " MAKE $@"
@$(MAKE) -C src/test
plugins: $(PLUGIN_DEPENDS)
+ @echo " MAKE $@"
@$(MAKE) -C src/plugins
import:
@@ -93,15 +101,21 @@ clean:
@$(MAKE) -C src/tool $@
@$(MAKE) -C src/test $@
+distclean: clean
+ @-rm -f Makefile src/common/Makefile 3rdparty/mt19937ar/Makefile \
+ 3rdparty/libconfig/Makefile src/char/Makefile src/login/Makefile \
+ src/map/Makefile src/plugins/Makefile src/tool/Makefile \
+ src/test/Makefile
+
help:
- @echo "most common targets are 'all' 'sql' 'conf' 'clean' 'help'"
+ @echo "most common targets are 'all' 'sql' 'clean' 'plugins' 'help'"
@echo "possible targets are:"
@echo "'common_sql' - builds object files used in SQL servers"
@echo "'mt19937ar' - builds object file of Mersenne Twister MT19937"
@echo "'libconfig' - builds object files of libconfig"
- @echo "'login_sql' - builds login server (SQL version)"
- @echo "'char_sql' - builds char server (SQL version)"
- @echo "'map_sql' - builds map server (SQL version)"
+ @echo "'login_sql' - builds login server"
+ @echo "'char_sql' - builds char server"
+ @echo "'map_sql' - builds map server"
@echo "'tools' - builds all the tools in src/tools"
@echo "'import' - builds conf/import folder from the template conf/import-tmpl"
@echo "'all' - builds all the above targets"
@@ -109,6 +123,7 @@ help:
@echo " 'map_sql' and 'import')"
@echo "'test' - builds tests"
@echo "'clean' - cleans builds and objects"
+ @echo "'distclean' - cleans files generated by ./configure"
@echo "'help' - outputs this message"
#####################################################################
@@ -124,35 +139,34 @@ no_plugins:
#####################################################################
# TODO
-install: conf/%.conf conf/%.txt
- $(shell read -p "WARNING: This target does not work properly yet. Press Ctrl+C to cancel or Enter to continue.")
- $(shell mkdir -p /opt/rathena/bin/)
- $(shell mkdir -p /opt/rathena/etc/rathena/)
- $(shell mkdir -p /opt/rathena/var/log/rathena/)
- $(shell mv save /opt/rathena/etc/rathena/save)
- $(shell mv db /opt/rathena/etc/rathena/db)
- $(shell mv conf /opt/rathena/etc/rathena/conf)
- $(shell mv npc /opt/rathena/etc/rathena/npc)
- $(shell mv log/* /opt/rathena/var/log/rathena/)
- $(shell cp *-server* /opt/rathena/bin/)
- $(shell ln -s /opt/rathena/etc/rathena/save/ /opt/rathena/bin/)
- $(shell ln -s /opt/rathena/etc/rathena/db/ /opt/rathena/bin/)
- $(shell ln -s /opt/rathena/etc/rathena/conf/ /opt/rathena/bin/)
- $(shell ln -s /opt/rathena/etc/rathena/npc/ /opt/rathena/bin/)
- $(shell ln -s /opt/rathena/var/log/rathena/ /opt/rathena/bin/log)
-
-bin-clean:
- $(shell rm /opt/rathena/bin/login-server*)
- $(shell rm /opt/rathena/bin/char-server*)
- $(shell rm /opt/rathena/bin/map-server*)
-
-uninstall:
- $(shell read -p "WARNING: This target does not work properly yet. Press Ctrl+C to cancel or Enter to continue.")
- bin-clean
- $(shell rm /opt/rathena/bin/save)
- $(shell rm /opt/rathena/bin/db)
- $(shell rm /opt/rathena/bin/conf)
- $(shell rm /opt/rathena/bin/npc)
- $(shell rm /opt/rathena/bin/log)
- $(shell rm -rf /opt/rathena/etc/rathena)
- $(shell rm -rf /opt/rathena/var/log/rathena)
+#install: conf/%.conf conf/%.txt
+# @read -p "WARNING: This target does not work properly yet. Press Ctrl+C to cancel or Enter to continue."
+# @mkdir -p /opt/hercules/bin/
+# @mkdir -p /opt/hercules/etc/hercules/
+# @mkdir -p /opt/hercules/var/log/hercules/
+# @mv save /opt/hercules/etc/hercules/save
+# @mv db /opt/hercules/etc/hercules/db
+# @mv conf /opt/hercules/etc/hercules/conf
+# @mv npc /opt/hercules/etc/hercules/npc
+# @mv log/* /opt/hercules/var/log/hercules/
+# @cp *-server /opt/hercules/bin/
+# @ln -s /opt/hercules/etc/hercules/save/ /opt/hercules/bin/
+# @ln -s /opt/hercules/etc/hercules/db/ /opt/hercules/bin/
+# @ln -s /opt/hercules/etc/hercules/conf/ /opt/hercules/bin/
+# @ln -s /opt/hercules/etc/hercules/npc/ /opt/hercules/bin/
+# @ln -s /opt/hercules/var/log/hercules/ /opt/hercules/bin/log
+
+#bin-clean:
+# @rm /opt/hercules/bin/login-server
+# @rm /opt/hercules/bin/char-server
+# @rm /opt/hercules/bin/map-server
+
+#uninstall: bin-clean
+# @read -p "WARNING: This target does not work properly yet. Press Ctrl+C to cancel or Enter to continue."
+# @rm /opt/hercules/bin/save
+# @rm /opt/hercules/bin/db
+# @rm /opt/hercules/bin/conf
+# @rm /opt/hercules/bin/npc
+# @rm /opt/hercules/bin/log
+# @rm -rf /opt/hercules/etc/hercules
+# @rm -rf /opt/hercules/var/log/hercules
diff --git a/README.md b/README.md
index f79cc5d51..7ffe47596 100644
--- a/README.md
+++ b/README.md
@@ -162,4 +162,4 @@ Hercules has a large collection of help files and sample NPC scripts located in
There are more files in the /doc/ directory that will help you to create scripts or update the
mapcache, or even explain how the job system and item bonuses work. Before posting a topic asking
-for help on the forums, we recommend that all users take the time to look over this directory. \ No newline at end of file
+for help on the forums, we recommend that all users take the time to look over this directory.
diff --git a/README.txt b/README.txt
index 81867a4b3..a02c9117a 100644
--- a/README.txt
+++ b/README.txt
@@ -172,4 +172,4 @@ Hercules has a large collection of help files and sample NPC scripts located in
There are more files in the /doc/ directory that will help you to create scripts or update the
mapcache, or even explain how the job system and item bonuses work. Before posting a topic asking
-for help on the forums, we recommend that all users take the time to look over this directory. \ No newline at end of file
+for help on the forums, we recommend that all users take the time to look over this directory.
diff --git a/cache/README.txt b/cache/README.txt
index 1ebe4f4e5..9c97bec71 100644
--- a/cache/README.txt
+++ b/cache/README.txt
@@ -5,4 +5,4 @@
//============================================================
No touching these folders or the files in them!
-they are read and written by the server during runtime when it feels it is wise. \ No newline at end of file
+they are read and written by the server during runtime when it feels it is wise.
diff --git a/cache/db/README.txt b/cache/db/README.txt
index 1ebe4f4e5..9c97bec71 100644
--- a/cache/db/README.txt
+++ b/cache/db/README.txt
@@ -5,4 +5,4 @@
//============================================================
No touching these folders or the files in them!
-they are read and written by the server during runtime when it feels it is wise. \ No newline at end of file
+they are read and written by the server during runtime when it feels it is wise.
diff --git a/cache/db/pre-re/README.txt b/cache/db/pre-re/README.txt
index 1ebe4f4e5..9c97bec71 100644
--- a/cache/db/pre-re/README.txt
+++ b/cache/db/pre-re/README.txt
@@ -5,4 +5,4 @@
//============================================================
No touching these folders or the files in them!
-they are read and written by the server during runtime when it feels it is wise. \ No newline at end of file
+they are read and written by the server during runtime when it feels it is wise.
diff --git a/cache/db/re/README.txt b/cache/db/re/README.txt
index 1ebe4f4e5..9c97bec71 100644
--- a/cache/db/re/README.txt
+++ b/cache/db/re/README.txt
@@ -5,4 +5,4 @@
//============================================================
No touching these folders or the files in them!
-they are read and written by the server during runtime when it feels it is wise. \ No newline at end of file
+they are read and written by the server during runtime when it feels it is wise.
diff --git a/conf/atcommand.conf b/conf/atcommand.conf
index 3b3a156eb..fc2a1af73 100644
--- a/conf/atcommand.conf
+++ b/conf/atcommand.conf
@@ -68,4 +68,4 @@ nolog: {
/* Commands help file */
help: {
@include "conf/help.txt"
-} \ No newline at end of file
+}
diff --git a/conf/battle/feature.conf b/conf/battle/feature.conf
index 7e1f83707..440dbb31a 100644
--- a/conf/battle/feature.conf
+++ b/conf/battle/feature.conf
@@ -17,4 +17,4 @@ feature.search_stores: on
// Atcommand suggestions (Note 1)
// If one type incomplete atcommand, it will suggest the complete ones.
-feature.atcommand_suggestions: off \ No newline at end of file
+feature.atcommand_suggestions: off
diff --git a/conf/battle/items.conf b/conf/battle/items.conf
index 05aadfecd..3a4eb8083 100644
--- a/conf/battle/items.conf
+++ b/conf/battle/items.conf
@@ -85,4 +85,4 @@ item_restricted_consumption_type:1
// Script commands 'enable_items/disable_items' will not be override. (see doc/script_commands.txt)
// 1 : yes(official)
// 0 : no
-item_enabled_npc:1 \ No newline at end of file
+item_enabled_npc:1
diff --git a/conf/battle/player.conf b/conf/battle/player.conf
index ccad0afc0..436399469 100644
--- a/conf/battle/player.conf
+++ b/conf/battle/player.conf
@@ -147,4 +147,4 @@ min_npc_vendchat_distance: 3
// Super Novice's fury is enabled to increments of 10%, such as at 10.0%, 20.0% - 80.0%, 90.0%
// Changing snovice_call_type config to 1 enables its use at 0%, for maxed super novices.
// default: 0
-snovice_call_type: 0 \ No newline at end of file
+snovice_call_type: 0
diff --git a/conf/battle/skill.conf b/conf/battle/skill.conf
index bc107f3d7..9f0b98f90 100644
--- a/conf/battle/skill.conf
+++ b/conf/battle/skill.conf
@@ -279,4 +279,4 @@ skill_trap_type: 0
// Max Possible Level of Monster skills
// Note: If your MVPs are too tough, reduce it to 10.
-mob_max_skilllvl: 100 \ No newline at end of file
+mob_max_skilllvl: 100
diff --git a/conf/battlegrounds.conf b/conf/battlegrounds.conf
index 9412829b2..6864d1584 100644
--- a/conf/battlegrounds.conf
+++ b/conf/battlegrounds.conf
@@ -108,4 +108,4 @@ battlegrounds: (
pGameDuration: 20 /* time to wait for players to confirm their attendence after queueing process has finished */
}
)
-}) \ No newline at end of file
+})
diff --git a/conf/readme.txt b/conf/readme.txt
index 24b113983..3323b5689 100644
--- a/conf/readme.txt
+++ b/conf/readme.txt
@@ -19,4 +19,4 @@ and you'll eliminate any problems updating in the future.
Neat, isn't it?
-- Semi-guide by Ajarn / Euphy \ No newline at end of file
+- Semi-guide by Ajarn / Euphy
diff --git a/db/cashshop_db.conf b/db/cashshop_db.conf
index 05bf5b270..8273b133e 100644
--- a/db/cashshop_db.conf
+++ b/db/cashshop_db.conf
@@ -58,4 +58,4 @@ cash_shop: (
ID907:500
}
}
-) \ No newline at end of file
+)
diff --git a/db/homun_skill_tree.txt b/db/homun_skill_tree.txt
index a64768490..b920ccee4 100644
--- a/db/homun_skill_tree.txt
+++ b/db/homun_skill_tree.txt
@@ -116,4 +116,4 @@
6052,8030,5,0,0,0,0,0,0,0,0,0,0,0 //MH_MIDNIGHT_FRENZY
6052,8036,5,0,0,0,0,0,0,0,0,0,0,0 //MH_TINDER_BREAKER
6052,8037,5,0,0,0,0,0,0,0,0,0,0,0 //MH_CBC
-6052,8038,5,0,0,0,0,0,0,0,0,0,0,0 //MH_EQC \ No newline at end of file
+6052,8038,5,0,0,0,0,0,0,0,0,0,0,0 //MH_EQC
diff --git a/db/homunculus_db.txt b/db/homunculus_db.txt
index b69f42419..d099db173 100644
--- a/db/homunculus_db.txt
+++ b/db/homunculus_db.txt
@@ -30,4 +30,4 @@
6049,6049,Bayeri,6112,60000,1,1,2,0,700,320,10,20,17,35,11,24,12,80,130,1,4,8,20,4,20,4,20,1,10,3,19,3,19,10,20,1,10,1,10,1,5,4,10,1,3,1,4,1,5
6050,6050,Sera,6108,60000,1,1,4,0,700,90,25,29,35,9,8,30,9,45,75,3,6,4,20,8,20,1,10,3,19,4,20,3,19,5,15,5,15,4,10,1,10,1,3,1,4,1,5,1,5
6051,6051,Dieter,6104,60000,1,1,0,0,700,80,11,11,11,11,11,11,11,30,150,0,7,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,30,1,10,1,10,1,10,1,10,1,10,1,10
-6052,6052,Eleanor,6115,60000,1,1,2,0,700,320,10,20,17,35,11,24,12,80,130,1,4,8,20,4,20,4,20,1,10,3,19,3,19,10,20,1,10,1,10,1,5,4,10,1,3,1,4,1,5 \ No newline at end of file
+6052,6052,Eleanor,6115,60000,1,1,2,0,700,320,10,20,17,35,11,24,12,80,130,1,4,8,20,4,20,4,20,1,10,3,19,3,19,10,20,1,10,1,10,1,5,4,10,1,3,1,4,1,5
diff --git a/db/item_avail.txt b/db/item_avail.txt
index a3c7acdfe..7ec78923f 100644
--- a/db/item_avail.txt
+++ b/db/item_avail.txt
@@ -23,4 +23,4 @@
//Enable if you plan to use the quest.
//12715,7721
//7915,673
-//7916,675 \ No newline at end of file
+//7916,675
diff --git a/db/pre-re/item_chain.conf b/db/pre-re/item_chain.conf
index f7591b934..bedb33d73 100644
--- a/db/pre-re/item_chain.conf
+++ b/db/pre-re/item_chain.conf
@@ -101,4 +101,4 @@ ITMCHAIN_FOOD: {
Sweet_Potato: 100
Banana: 100
Apple: 600
-} \ No newline at end of file
+}
diff --git a/db/pre-re/map_zone_db.conf b/db/pre-re/map_zone_db.conf
index f51fd8fc6..384384fec 100644
--- a/db/pre-re/map_zone_db.conf
+++ b/db/pre-re/map_zone_db.conf
@@ -334,4 +334,4 @@ zones: (
Greed_Scroll: true
}
}
-) \ No newline at end of file
+)
diff --git a/db/re/exp_guild.txt b/db/re/exp_guild.txt
index dcf57d159..928047600 100644
--- a/db/re/exp_guild.txt
+++ b/db/re/exp_guild.txt
@@ -48,4 +48,4 @@
220900000
230400000
240100000
-250000000 \ No newline at end of file
+250000000
diff --git a/db/re/item_chain.conf b/db/re/item_chain.conf
index f7591b934..bedb33d73 100644
--- a/db/re/item_chain.conf
+++ b/db/re/item_chain.conf
@@ -101,4 +101,4 @@ ITMCHAIN_FOOD: {
Sweet_Potato: 100
Banana: 100
Apple: 600
-} \ No newline at end of file
+}
diff --git a/db/re/item_db.txt b/db/re/item_db.txt
index b9c3c8c09..b4c2ca654 100644
--- a/db/re/item_db.txt
+++ b/db/re/item_db.txt
@@ -8295,4 +8295,4 @@
21004,Alca_Bringer_,Alca Bringer,4,20,,3400,280,,2,2,0x00004080,56,2,34,3,100,1,3,{},{},{}
21005,Metal_Two_Hand_Sword,Metal Two-Handed Sword,4,20,,0,95,,1,1,0x00004082,63,2,34,3,0,1,3,{},{},{}
22514,Candy_Holder,Candy Holder,11,20,,10,,,,,0xFFFFFFFF,63,2,,,,,,{},{},{}
-22540,Runstone_Luxanima,Lux Anima Rune,11,2,,100,,,,,0xFFFFFFFF,63,2,,,,,,{ itemskill "RK_LUXANIMA",1; },{},{} \ No newline at end of file
+22540,Runstone_Luxanima,Lux Anima Rune,11,2,,100,,,,,0xFFFFFFFF,63,2,,,,,,{ itemskill "RK_LUXANIMA",1; },{},{}
diff --git a/db/re/item_group.conf b/db/re/item_group.conf
index 92a98fedc..85d2610fb 100644
--- a/db/re/item_group.conf
+++ b/db/re/item_group.conf
@@ -4741,4 +4741,4 @@ Lucky_Bag: (
("Taiwan_Luk_Coin",3),
"Big_Luk_Bookmark"
)
-*/ \ No newline at end of file
+*/
diff --git a/db/re/map_zone_db.conf b/db/re/map_zone_db.conf
index f51fd8fc6..384384fec 100644
--- a/db/re/map_zone_db.conf
+++ b/db/re/map_zone_db.conf
@@ -334,4 +334,4 @@ zones: (
Greed_Scroll: true
}
}
-) \ No newline at end of file
+)
diff --git a/doc/atcommands.txt b/doc/atcommands.txt
index 1e2985f66..42b085cd6 100644
--- a/doc/atcommands.txt
+++ b/doc/atcommands.txt
@@ -1428,4 +1428,4 @@ Sets the intimacy level of your homunculus, with 1000 being "Loyal".
Sets the hunger level of your homunculus, with 100 being "Stuffed".
---------------------------------------- \ No newline at end of file
+---------------------------------------
diff --git a/doc/item_bonus.txt b/doc/item_bonus.txt
index 7545016b5..b9dc9080f 100644
--- a/doc/item_bonus.txt
+++ b/doc/item_bonus.txt
@@ -412,4 +412,4 @@ bonus bVariableCast,x; Increases variable cast time of all skills by x millise
bonus2 bSkillFixedCast,s,x; Increases fixed cast time of skill s by x milliseconds. (supports skill names.)
bonus2 bSkillVariableCast,s,x; Increases variable cast time of skill s by x milliseconds. (supports skill names.)
bonus2 bVariableCastrate,s,x; Increases variable cast time of skill s by x%. (supports skill names.)
-bonus2 bFixedCastrate,s,x; Increases fixed cast time of skill s by x%. (supports skill names.) \ No newline at end of file
+bonus2 bFixedCastrate,s,x; Increases fixed cast time of skill s by x%. (supports skill names.)
diff --git a/doc/md5_hashcheck.txt b/doc/md5_hashcheck.txt
index a2dbf42fa..779785638 100644
--- a/doc/md5_hashcheck.txt
+++ b/doc/md5_hashcheck.txt
@@ -35,4 +35,4 @@ To enable MD5 hash checks, set 'client_hash_check' to 'on'.
The 'client_hash' group_id can be any of the groups in conf\groups.conf,
and is particularly useful if you wanted to allow GMs a different client
than normal players; for example, a GM client could be hexed differently
-with dual-clienting enabled and chat flood disabled. \ No newline at end of file
+with dual-clienting enabled and chat flood disabled.
diff --git a/doc/permissions.txt b/doc/permissions.txt
index 6cfb98897..9760f716c 100644
--- a/doc/permissions.txt
+++ b/doc/permissions.txt
@@ -31,4 +31,4 @@ show_bossmobs : Ability to see boss mobs with @showmobs.
disable_pvm : Ability to disable Player vs. Monster.
disable_pvp : Ability to disable Player vs. Player.
disable_commands_when_dead : Ability to disable @command usage when dead.
-hchsys_admin : Hercules Chat System Admin (Ability to modify channel settings regardless of ownership and join password-protected channels without requiring a password.) \ No newline at end of file
+hchsys_admin : Hercules Chat System Admin (Ability to modify channel settings regardless of ownership and join password-protected channels without requiring a password.)
diff --git a/doc/sample/bank_test.txt b/doc/sample/bank_test.txt
index e63ef7e12..8b29abd93 100644
--- a/doc/sample/bank_test.txt
+++ b/doc/sample/bank_test.txt
@@ -64,4 +64,4 @@ B_EXIT2:
mes "Good bye!";
cutin "kafra_06",255;
close;
-} \ No newline at end of file
+}
diff --git a/doc/sample/basejob_baseclass_upper.txt b/doc/sample/basejob_baseclass_upper.txt
index 04f7d310f..8e2501e09 100644
--- a/doc/sample/basejob_baseclass_upper.txt
+++ b/doc/sample/basejob_baseclass_upper.txt
@@ -15,4 +15,4 @@ prontera,155,177,1 script Tell Me 725,{
mes "BaseJob: " + BaseJob;
mes "Upper: " + Upper;
close;
-} \ No newline at end of file
+}
diff --git a/doc/sample/checkoption.txt b/doc/sample/checkoption.txt
index eb768b9b2..8f0f96d9f 100644
--- a/doc/sample/checkoption.txt
+++ b/doc/sample/checkoption.txt
@@ -14,4 +14,4 @@ prontera,156,89,6 script test_checkoption 117,{
if(checkoption(@value) == 1) mes "True!";
else if(checkoption(@value) == 0) mes "False!";
close;
-} \ No newline at end of file
+}
diff --git a/doc/sample/delitem2.txt b/doc/sample/delitem2.txt
index f38d59c27..9e74d76e7 100644
--- a/doc/sample/delitem2.txt
+++ b/doc/sample/delitem2.txt
@@ -36,4 +36,4 @@ prontera,160,182,5 script Delitem2 51,{
delitem2 @nameid,@amount,@iden,@ref,@attr,@c1,@c2,@c3,@c4;
mes "And here is the moment when your item should disappear! :P";
close;
-} \ No newline at end of file
+}
diff --git a/doc/sample/getequipcardid.txt b/doc/sample/getequipcardid.txt
index 0447bf533..6b435f41f 100644
--- a/doc/sample/getequipcardid.txt
+++ b/doc/sample/getequipcardid.txt
@@ -22,4 +22,4 @@ prontera,155,177,4 script Check My Hat 810,{
mes "Nothing?";
emotion e_hmm;
close;
-} \ No newline at end of file
+}
diff --git a/doc/sample/getequipid.txt b/doc/sample/getequipid.txt
index 654c58f3b..6a2ef342f 100644
--- a/doc/sample/getequipid.txt
+++ b/doc/sample/getequipid.txt
@@ -13,4 +13,4 @@ prontera,161,181,6 script GetEquipID Sample 105,{
for(set .@i,1; .@i<11; set .@i,.@i+1)
mes "GetEquipID(" + .@i + ") : " + getequipid(1);
close;
-} \ No newline at end of file
+}
diff --git a/doc/sample/getiteminfo.txt b/doc/sample/getiteminfo.txt
index 15b81b749..632999f3b 100644
--- a/doc/sample/getiteminfo.txt
+++ b/doc/sample/getiteminfo.txt
@@ -20,4 +20,4 @@ prontera,156,179,6 script test_getiteminfo 117,{
for(set .@id,0; .@id<14; set .@id,.@id+1)
mes " getiteminfo("+.@value+","+.@id+") = "+getiteminfo(.@value,.@id);
close;
-} \ No newline at end of file
+}
diff --git a/doc/sample/getmonsterinfo.txt b/doc/sample/getmonsterinfo.txt
index 079d9e7e9..471af9e5c 100644
--- a/doc/sample/getmonsterinfo.txt
+++ b/doc/sample/getmonsterinfo.txt
@@ -20,4 +20,4 @@ prontera,156,179,6 script test_getmonsterinfo 117,{
for(set .@id,0; .@id<23; set .@id,.@id+1)
mes " getmonsterinfo("+.@value+","+@id+") = "+getmonsterinfo(.@value,@id);
close;
-} \ No newline at end of file
+}
diff --git a/doc/sample/gstorage_test.txt b/doc/sample/gstorage_test.txt
index 559f7f76e..b8f9fe2c4 100644
--- a/doc/sample/gstorage_test.txt
+++ b/doc/sample/gstorage_test.txt
@@ -41,4 +41,4 @@ GS_EXIT3:
GS_EXIT4:
cutin "kafra_06",255;
close;
-} \ No newline at end of file
+}
diff --git a/doc/sample/npc_dynamic_shop.txt b/doc/sample/npc_dynamic_shop.txt
index b6ed48808..c3bc78293 100644
--- a/doc/sample/npc_dynamic_shop.txt
+++ b/doc/sample/npc_dynamic_shop.txt
@@ -92,4 +92,4 @@ OnInit:
set $@rpotsleft, 10;
set $@opotsleft, 10;
end;
-} \ No newline at end of file
+}
diff --git a/doc/sample/npc_extend_shop.txt b/doc/sample/npc_extend_shop.txt
index ccc2ce5bb..1ca4ed7b8 100644
--- a/doc/sample/npc_extend_shop.txt
+++ b/doc/sample/npc_extend_shop.txt
@@ -27,4 +27,4 @@ prontera,146,229,5 shop Armor Card Merchant 80,4003:100000,4008:100000,4011:1000
prontera,144,227,5 shop Shield Card Merchant 80,4013:100000,4032:100000,4058:100000,4059:100000,4066:100000,4074:100000,4083:100000,4120:100000,4124:100000,4136:100000,4138:100000,4045:100000,4067:100000,4075:100000,4090:100000
prontera,142,225,5 shop Robe Card Merchant 80,4056:100000,4071:100000,4081:100000,4095:100000,4108:100000,4109:100000,4113:100000,4116:100000,4133:100000,4015:100000,4088:100000,4102:100000,4129:100000
prontera,140,223,5 shop Shoes Card Merchant 80,4009:100000,4038:100000,4050:100000,4070:100000,4097:100000,4100:100000,4107:100000
-prontera,138,221,5 shop Accessory Card Merchant 80,4022:100500,4027:100500,4028:100500,4034:100500,4051:100500,4064:100500,4091:100500,4079:100500,4033:100500,4040:100500,4044:100500,4048:100500,4053:100500,4073:100500,4077:100500,4084:100500,4093:100500,4103:100500,4139:100500 \ No newline at end of file
+prontera,138,221,5 shop Accessory Card Merchant 80,4022:100500,4027:100500,4028:100500,4034:100500,4051:100500,4064:100500,4091:100500,4079:100500,4033:100500,4040:100500,4044:100500,4048:100500,4053:100500,4073:100500,4077:100500,4084:100500,4093:100500,4103:100500,4139:100500
diff --git a/doc/sample/npc_live_dialogues.txt b/doc/sample/npc_live_dialogues.txt
index 22422d9af..8778f6c50 100644
--- a/doc/sample/npc_live_dialogues.txt
+++ b/doc/sample/npc_live_dialogues.txt
@@ -51,4 +51,4 @@ M_BYE:
// Add some random goodbye from Global_Functions.txt
mes callfunc("F_Bye");
close;
-} \ No newline at end of file
+}
diff --git a/doc/sample/npc_shop_test.txt b/doc/sample/npc_shop_test.txt
index fa58f3f52..5e492b257 100644
--- a/doc/sample/npc_shop_test.txt
+++ b/doc/sample/npc_shop_test.txt
@@ -37,4 +37,4 @@ prontera,218,211,4 shop Pet Groomer 125,537:2500,643:3000,10013:1500,10014:2000
izlude,164,138,4 shop Pet Groomer 124,537:2500,643:3000,10013:1500,10014:2000
morocc,269,167,4 shop Pet Groomer 125,537:2500,643:3000,10013:1500,10014:2000
geffen,193,152,4 shop Pet Groomer 124,537:2500,643:3000,10013:1500,10014:2000
-payon,142,104,4 shop Pet Groomer 124,537:2500,643:3000,10013:1500,10014:2000 \ No newline at end of file
+payon,142,104,4 shop Pet Groomer 124,537:2500,643:3000,10013:1500,10014:2000
diff --git a/doc/sample/npc_test_array.txt b/doc/sample/npc_test_array.txt
index b6185adbc..36b54a3fe 100644
--- a/doc/sample/npc_test_array.txt
+++ b/doc/sample/npc_test_array.txt
@@ -40,4 +40,4 @@ prontera,164,190,1 script Array Test 112,{
mes "hoge[2]=> " + @hoge[2];
mes "hoge[3]=> " + @hoge[3];
close;
-} \ No newline at end of file
+}
diff --git a/doc/sample/npc_test_chat.txt b/doc/sample/npc_test_chat.txt
index 24176b802..ca81840ea 100644
--- a/doc/sample/npc_test_chat.txt
+++ b/doc/sample/npc_test_chat.txt
@@ -34,4 +34,4 @@ OnChatEvent:
disablewaitingroomevent;
warpwaitingpc "prontera",160,180;
end;
-} \ No newline at end of file
+}
diff --git a/doc/sample/npc_test_duplicate.txt b/doc/sample/npc_test_duplicate.txt
index 237e7e57d..d052e1cee 100644
--- a/doc/sample/npc_test_duplicate.txt
+++ b/doc/sample/npc_test_duplicate.txt
@@ -29,4 +29,4 @@ OnTouch:
prontera,150,175,4 duplicate(Test Script) Test1 909
prontera,155,175,4 duplicate(Test Script) Test2 909,2,2
-prontera,160,175,4 duplicate(Test Script) Test3 909,3,3 \ No newline at end of file
+prontera,160,175,4 duplicate(Test Script) Test3 909,3,3
diff --git a/doc/sample/npc_test_npctimer.txt b/doc/sample/npc_test_npctimer.txt
index f3c2d8bee..7dc625785 100644
--- a/doc/sample/npc_test_npctimer.txt
+++ b/doc/sample/npc_test_npctimer.txt
@@ -39,4 +39,4 @@ OnTimer5000:
OnTimer10000:
npctalk "After 10 seconds...";
end;
-} \ No newline at end of file
+}
diff --git a/doc/sample/npc_test_npctimer2.txt b/doc/sample/npc_test_npctimer2.txt
index 6c5d139f0..1bb856b13 100644
--- a/doc/sample/npc_test_npctimer2.txt
+++ b/doc/sample/npc_test_npctimer2.txt
@@ -20,4 +20,4 @@ OnTimer5000:
mes "Ah, your level is " + readparam(11) + "!";
detachnpctimer;
close;
-} \ No newline at end of file
+}
diff --git a/doc/sample/npc_test_quest.txt b/doc/sample/npc_test_quest.txt
index 39f838e23..821c83739 100644
--- a/doc/sample/npc_test_quest.txt
+++ b/doc/sample/npc_test_quest.txt
@@ -45,4 +45,4 @@ prontera,90,95,1 script Jelly 123,{
mes "Thanks again for doing that for me!";
close;
}
-} \ No newline at end of file
+}
diff --git a/doc/sample/npc_test_setmapflag.txt b/doc/sample/npc_test_setmapflag.txt
index 010a6f85d..681fbc43a 100644
--- a/doc/sample/npc_test_setmapflag.txt
+++ b/doc/sample/npc_test_setmapflag.txt
@@ -29,4 +29,4 @@ prontera,165,145,0 script EXPflagtest 123,{
removemapflag "prontera",MF_PVP;
close;
}
-} \ No newline at end of file
+}
diff --git a/doc/sample/npc_test_time.txt b/doc/sample/npc_test_time.txt
index f9c40b910..ffa6a5ca2 100644
--- a/doc/sample/npc_test_time.txt
+++ b/doc/sample/npc_test_time.txt
@@ -22,4 +22,4 @@ prontera,157,181,6 script Time Sample 105,{
mes " GetTime(7) : " + gettime(7) + " (Year)";
mes " GetTimeStr : " + gettimestr("%Y-%m/%d %H:%M:%S",19);
close;
-} \ No newline at end of file
+}
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 75c731d53..29a1478fa 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -1,4 +1,4 @@
-サソ//===== Hercules Documentation ===============================
+//===== Hercules Documentation ===============================
//= Hercules Script Commands
//===== By: ==================================================
//= Hercules Dev Team
diff --git a/doc/whisper_sys.txt b/doc/whisper_sys.txt
index 3c870b543..39e2a54f2 100644
--- a/doc/whisper_sys.txt
+++ b/doc/whisper_sys.txt
@@ -49,4 +49,4 @@ OnWhisperGlobal:
// Script for an MVP summoning event.
}
end;
-} \ No newline at end of file
+}
diff --git a/npc/MOTD.txt b/npc/MOTD.txt
index 7b2f086b4..5e00f85b7 100644
--- a/npc/MOTD.txt
+++ b/npc/MOTD.txt
@@ -12,4 +12,4 @@
- script HerculesMOTD -1,{
message strcharinfo(0),"Welcome to Hercules! Enjoy! Please report any bugs you find.";
end;
-} \ No newline at end of file
+}
diff --git a/npc/airports/rachel.txt b/npc/airports/rachel.txt
index 88c48cd16..fce302cbc 100644
--- a/npc/airports/rachel.txt
+++ b/npc/airports/rachel.txt
@@ -31,4 +31,4 @@ OnTouch:
}
mes "Thank you, please come again.";
close;
-} \ No newline at end of file
+}
diff --git a/npc/custom/etc/quest_warper.txt b/npc/custom/etc/quest_warper.txt
index 840325636..a8e06cc75 100644
--- a/npc/custom/etc/quest_warper.txt
+++ b/npc/custom/etc/quest_warper.txt
@@ -1689,4 +1689,4 @@ treasure02,104,40,3 script Warpra Helper#24 112,{ callfunc "QWS_Dungeon_Warpra",
xmas_dun02,124,131,3 script Warpra Helper#25 112,{ callfunc "QWS_Dungeon_Warpra",25,"Toy Factory Dungeon"; close; }
um_dun02,44,28,3 script Warpra Helper#26 112,{ callfunc "QWS_Dungeon_Warpra",27,"Umbala Dungeon"; close; }
tur_dun02,162,23,3 script Warpra Helper#27 112,{ callfunc "QWS_Dungeon_Warpra",26,"Turtle Island Dungeon"; close; }
-prt_maze02,102,69,4 script Warpra Helper#28 112,{ callfunc "QWS_Dungeon_Warpra",13,"Hidden Dungeon"; close; } \ No newline at end of file
+prt_maze02,102,69,4 script Warpra Helper#28 112,{ callfunc "QWS_Dungeon_Warpra",13,"Hidden Dungeon"; close; }
diff --git a/npc/custom/events/cluckers.txt b/npc/custom/events/cluckers.txt
index cf296cb18..b221b1b7a 100644
--- a/npc/custom/events/cluckers.txt
+++ b/npc/custom/events/cluckers.txt
@@ -111,4 +111,4 @@ OnTimer40000:
if (!$cluck_item_amount) set $cluck_item_amount,1;
set .startcluck,1;
end;
-} \ No newline at end of file
+}
diff --git a/npc/custom/jobmaster.txt b/npc/custom/jobmaster.txt
index 00963bf36..68feb5b16 100644
--- a/npc/custom/jobmaster.txt
+++ b/npc/custom/jobmaster.txt
@@ -187,4 +187,4 @@ OnInit:
set .SkillPointCheck,1; // Force player to use up all skill points? (1: yes / 0: no)
set .Platinum,1; // Get platinum skills automatically? (1: yes / 0: no)
end;
-} \ No newline at end of file
+}
diff --git a/npc/custom/quests/berzebub.txt b/npc/custom/quests/berzebub.txt
index 1ba44211e..6f58870eb 100644
--- a/npc/custom/quests/berzebub.txt
+++ b/npc/custom/quests/berzebub.txt
@@ -59,4 +59,4 @@ M_Leave:
mes .@n$;
mes "Such a great item I have right here...";
close;
-} \ No newline at end of file
+}
diff --git a/npc/custom/quests/kaho_balmung.txt b/npc/custom/quests/kaho_balmung.txt
index a2a154acf..47b12ca87 100644
--- a/npc/custom/quests/kaho_balmung.txt
+++ b/npc/custom/quests/kaho_balmung.txt
@@ -48,4 +48,4 @@ prontera,158,356,4 script Royal Messenger 105,{
mes "I see you already have all the items you need. Here's your "+getitemname(getd(".@Req"+.@i+"[0]"))+", as promised.";
getitem getd(".@Req"+.@i+"[0]"),1;
close;
-} \ No newline at end of file
+}
diff --git a/npc/custom/quests/kahohorn.txt b/npc/custom/quests/kahohorn.txt
index 031631b74..6a6e36e7c 100644
--- a/npc/custom/quests/kahohorn.txt
+++ b/npc/custom/quests/kahohorn.txt
@@ -66,4 +66,4 @@ geffen,115,107,5 script Lord Kaho's Servant 61,{
getitem 5013,1;
mes "Enjoy being God of Rune-Midgard!";
close;
-} \ No newline at end of file
+}
diff --git a/npc/custom/quests/kings_items.txt b/npc/custom/quests/kings_items.txt
index d935dac08..bd2288d28 100644
--- a/npc/custom/quests/kings_items.txt
+++ b/npc/custom/quests/kings_items.txt
@@ -76,4 +76,4 @@ prt_castle,84,170,4 script King's Daughter 62,{
mes "Well, he won't give me what I want!!";
mes "He's the King of Prontera. He should be able to get me ANYTHING!!!";
close;
-} \ No newline at end of file
+}
diff --git a/npc/custom/quests/quest_shop.txt b/npc/custom/quests/quest_shop.txt
index 3395ac102..0483e90da 100644
--- a/npc/custom/quests/quest_shop.txt
+++ b/npc/custom/quests/quest_shop.txt
@@ -229,4 +229,4 @@ function script qshop {
- shop qshop2 -1,909:-1
- shop qshop3 -1,909:-1
- shop qshop4 -1,909:-1
-- shop qshop5 -1,909:-1 \ No newline at end of file
+- shop qshop5 -1,909:-1
diff --git a/npc/custom/quests/sphinx_mask.txt b/npc/custom/quests/sphinx_mask.txt
index b2cf64559..fb006f3fa 100644
--- a/npc/custom/quests/sphinx_mask.txt
+++ b/npc/custom/quests/sphinx_mask.txt
@@ -49,4 +49,4 @@ L_Menu:
getitem 7114,1;
set sphmask_q,1;
close;
-} \ No newline at end of file
+}
diff --git a/npc/custom/quests/sunglasses.txt b/npc/custom/quests/sunglasses.txt
index 6e44ce007..c7ebbf937 100644
--- a/npc/custom/quests/sunglasses.txt
+++ b/npc/custom/quests/sunglasses.txt
@@ -105,4 +105,4 @@ moc_fild07,334,186,5 script Maseph 702,{
getitem 2202,1;
set SG_QUEST1,0;
close;
-} \ No newline at end of file
+}
diff --git a/npc/custom/woe_controller.txt b/npc/custom/woe_controller.txt
index c7d3f4e9e..9ddaeb362 100644
--- a/npc/custom/woe_controller.txt
+++ b/npc/custom/woe_controller.txt
@@ -447,4 +447,4 @@ while(1) {
case 5:
close;
} }
-} \ No newline at end of file
+}
diff --git a/npc/events/idul_fitri.txt b/npc/events/idul_fitri.txt
index c4c06f07f..557ce62c9 100644
--- a/npc/events/idul_fitri.txt
+++ b/npc/events/idul_fitri.txt
@@ -68,4 +68,4 @@ prontera,146,92,3 script Cellerb 58,{
emotion e_hmm;
close;
}
-} \ No newline at end of file
+}
diff --git a/npc/events/valentinesday.txt b/npc/events/valentinesday.txt
index 8f2bd85d5..a08a1a701 100644
--- a/npc/events/valentinesday.txt
+++ b/npc/events/valentinesday.txt
@@ -126,4 +126,4 @@ prt_castle,54,34,4 script Carl Orleans 47,{
mes "[Carl Orleans]";
mes "Enjoy.";
close;
-} \ No newline at end of file
+}
diff --git a/npc/events/valentinesday_2012.txt b/npc/events/valentinesday_2012.txt
index a8597cd22..6ae844305 100644
--- a/npc/events/valentinesday_2012.txt
+++ b/npc/events/valentinesday_2012.txt
@@ -153,4 +153,4 @@ mosk_in,21,244,3 script Baker Extraordinaire 410,{
mes "Hello, "+strcharinfo(0)+"!";
close;
}
-} \ No newline at end of file
+}
diff --git a/npc/guild/trs_rp.txt b/npc/guild/trs_rp.txt
index 7b3ae5545..0c4374b66 100644
--- a/npc/guild/trs_rp.txt
+++ b/npc/guild/trs_rp.txt
@@ -52,4 +52,4 @@ gefg_cas01,154,112,0 duplicate(Gld_Trea_Protect) ban_warp#gefg_cas01 -1,6,6
gefg_cas02,140,116,0 duplicate(Gld_Trea_Protect) ban_warp#gefg_cas02 -1,6,6
gefg_cas03,271,290,0 duplicate(Gld_Trea_Protect) ban_warp#gefg_cas03 -1,6,6
gefg_cas04,116,119,0 duplicate(Gld_Trea_Protect) ban_warp#gefg_cas04 -1,6,6
-gefg_cas05,144,110,0 duplicate(Gld_Trea_Protect) ban_warp#gefg_cas05 -1,6,6 \ No newline at end of file
+gefg_cas05,144,110,0 duplicate(Gld_Trea_Protect) ban_warp#gefg_cas05 -1,6,6
diff --git a/npc/guild2/arug_cas01.txt b/npc/guild2/arug_cas01.txt
index a2b929347..1f54b54ee 100644
--- a/npc/guild2/arug_cas01.txt
+++ b/npc/guild2/arug_cas01.txt
@@ -72,4 +72,4 @@ OnRecvCastleAr01:
}
aru_gld,142,235,4 duplicate(Ar01_Flag) Mardol#flag_Ar01_2 722
aru_gld,164,245,5 duplicate(Ar01_Flag) Mardol#flag_Ar01_3 722
-aru_gld,182,255,5 duplicate(Ar01_Flag) Mardol#flag_Ar01_4 722 \ No newline at end of file
+aru_gld,182,255,5 duplicate(Ar01_Flag) Mardol#flag_Ar01_4 722
diff --git a/npc/guild2/arug_cas02.txt b/npc/guild2/arug_cas02.txt
index a6b7f0d55..006443d14 100644
--- a/npc/guild2/arug_cas02.txt
+++ b/npc/guild2/arug_cas02.txt
@@ -77,4 +77,4 @@ OnAgitInit2:
OnRecvCastleAr02:
FlagEmblem GetCastleData("arug_cas02",1);
end;
-} \ No newline at end of file
+}
diff --git a/npc/guild2/arug_cas03.txt b/npc/guild2/arug_cas03.txt
index bf11c9449..93144fd36 100644
--- a/npc/guild2/arug_cas03.txt
+++ b/npc/guild2/arug_cas03.txt
@@ -69,4 +69,4 @@ OnRecvCastleAr03:
FlagEmblem GetCastleData("arug_cas03",1);
end;
}
-aru_gld,74,174,0 duplicate(Ar03_Flag) Horn#flag_Ar03_2 722 \ No newline at end of file
+aru_gld,74,174,0 duplicate(Ar03_Flag) Horn#flag_Ar03_2 722
diff --git a/npc/guild2/arug_cas04.txt b/npc/guild2/arug_cas04.txt
index c46c7ff15..6826d0d5e 100644
--- a/npc/guild2/arug_cas04.txt
+++ b/npc/guild2/arug_cas04.txt
@@ -78,4 +78,4 @@ OnRecvCastlear04:
FlagEmblem GetCastleData("arug_cas04",1);
end;
}
-aru_gld,313,318,4 duplicate(ar04_Flag2) Gefn#flag_ar04_4 722 \ No newline at end of file
+aru_gld,313,318,4 duplicate(ar04_Flag2) Gefn#flag_ar04_4 722
diff --git a/npc/guild2/arug_cas05.txt b/npc/guild2/arug_cas05.txt
index b250a9385..70b61e3cb 100644
--- a/npc/guild2/arug_cas05.txt
+++ b/npc/guild2/arug_cas05.txt
@@ -78,4 +78,4 @@ OnRecvCastlear05:
FlagEmblem GetCastleData("arug_cas05",1);
end;
}
-aru_gld,350,88,6 duplicate(ar05_Flag2) Banadis#flag_ar05_4 722 \ No newline at end of file
+aru_gld,350,88,6 duplicate(ar05_Flag2) Banadis#flag_ar05_4 722
diff --git a/npc/guild2/schg_cas01.txt b/npc/guild2/schg_cas01.txt
index 8200b49a0..f001f3379 100644
--- a/npc/guild2/schg_cas01.txt
+++ b/npc/guild2/schg_cas01.txt
@@ -69,4 +69,4 @@ OnRecvCastlesc01:
FlagEmblem GetCastleData("schg_cas01",1);
end;
}
-sch_gld,297,90,0 duplicate(Sc01_Flag) Himinn#flag_sc01_2 722 \ No newline at end of file
+sch_gld,297,90,0 duplicate(Sc01_Flag) Himinn#flag_sc01_2 722
diff --git a/npc/guild2/schg_cas02.txt b/npc/guild2/schg_cas02.txt
index 0a39f484a..bf7b457ba 100644
--- a/npc/guild2/schg_cas02.txt
+++ b/npc/guild2/schg_cas02.txt
@@ -61,4 +61,4 @@ OnRecvCastlesc02:
FlagEmblem GetCastleData("schg_cas02",1);
end;
}
-sch_gld,280,247,4 duplicate(Sc02_Flag) Andlangr#flag_sc02_2 722 \ No newline at end of file
+sch_gld,280,247,4 duplicate(Sc02_Flag) Andlangr#flag_sc02_2 722
diff --git a/npc/guild2/schg_cas03.txt b/npc/guild2/schg_cas03.txt
index 6adfa0ca1..b473c2702 100644
--- a/npc/guild2/schg_cas03.txt
+++ b/npc/guild2/schg_cas03.txt
@@ -69,4 +69,4 @@ OnRecvCastlesc03:
FlagEmblem GetCastleData("schg_cas03",1);
end;
}
-sch_gld,104,191,0 duplicate(Sc03_Flag) Bidblind#flag_sc03_2 722 \ No newline at end of file
+sch_gld,104,191,0 duplicate(Sc03_Flag) Bidblind#flag_sc03_2 722
diff --git a/npc/guild2/schg_cas04.txt b/npc/guild2/schg_cas04.txt
index 8da46dec5..51e21b972 100644
--- a/npc/guild2/schg_cas04.txt
+++ b/npc/guild2/schg_cas04.txt
@@ -69,4 +69,4 @@ OnRecvCastlesc04:
FlagEmblem GetCastleData("schg_cas04",1);
end;
}
-sch_gld,141,97,4 duplicate(sc04_Flag) Hljod#flag_sc04_2 722 \ No newline at end of file
+sch_gld,141,97,4 duplicate(sc04_Flag) Hljod#flag_sc04_2 722
diff --git a/npc/guild2/schg_cas05.txt b/npc/guild2/schg_cas05.txt
index 46b03e8bd..6f2b84544 100644
--- a/npc/guild2/schg_cas05.txt
+++ b/npc/guild2/schg_cas05.txt
@@ -71,4 +71,4 @@ OnRecvCastlesc05:
}
sch_gld,91,284,4 duplicate(sc05_Flag) Skidbladnir#flag_sc05_2 722
sch_gld,66,320,6 duplicate(sc05_Flag) Skidbladnir#flag_sc05_3 722
-sch_gld,66,310,6 duplicate(sc05_Flag) Skidbladnir#flag_sc05_4 722 \ No newline at end of file
+sch_gld,66,310,6 duplicate(sc05_Flag) Skidbladnir#flag_sc05_4 722
diff --git a/npc/kafras/functions_kafras.txt b/npc/kafras/functions_kafras.txt
index c3df4e0af..d10c2fe2f 100644
--- a/npc/kafras/functions_kafras.txt
+++ b/npc/kafras/functions_kafras.txt
@@ -634,4 +634,4 @@ function script F_KafSet {
setd "@wrpC$["+.@i+"]",getd("@wrpD$["+.@i+"]")+" -> "+getd("@wrpP["+.@i+"]");
setd "@wrpC$["+getarraysize(@wrpC$)+"]","Cancel";
return;
-} \ No newline at end of file
+}
diff --git a/npc/mapflag/skillduration.txt b/npc/mapflag/skillduration.txt
index ca2f82a40..d3d96cae3 100644
--- a/npc/mapflag/skillduration.txt
+++ b/npc/mapflag/skillduration.txt
@@ -19,4 +19,4 @@
//= durations not controlled by the server (e.g. Storm Gust).
//===== Additional Comments: =================================
//= 1.0 - Initial script.
-//============================================================ \ No newline at end of file
+//============================================================
diff --git a/npc/mapflag/skillmodifier.txt b/npc/mapflag/skillmodifier.txt
index bd60806f7..60c623a36 100644
--- a/npc/mapflag/skillmodifier.txt
+++ b/npc/mapflag/skillmodifier.txt
@@ -16,4 +16,4 @@
//= Doubles the damage of Firebolt in Prontera.
//===== Additional Comments: =================================
//= 1.0 - Initial script.
-//============================================================ \ No newline at end of file
+//============================================================
diff --git a/npc/mapflag/town.txt b/npc/mapflag/town.txt
index 46331818b..a89e5f7be 100644
--- a/npc/mapflag/town.txt
+++ b/npc/mapflag/town.txt
@@ -37,4 +37,4 @@ mora mapflag town
dewata mapflag town
malangdo mapflag town
malaya mapflag town
-eclage mapflag town \ No newline at end of file
+eclage mapflag town
diff --git a/npc/mapflag/zone.txt b/npc/mapflag/zone.txt
index 62047effa..9c0be04c4 100644
--- a/npc/mapflag/zone.txt
+++ b/npc/mapflag/zone.txt
@@ -107,4 +107,4 @@ splendide mapflag zone Towns
umbala mapflag zone Towns
veins mapflag zone Towns
xmas mapflag zone Towns
-yuno mapflag zone Towns \ No newline at end of file
+yuno mapflag zone Towns
diff --git a/npc/merchants/cashheadgear_dye.txt b/npc/merchants/cashheadgear_dye.txt
index 49003e18b..3d9fd89d8 100644
--- a/npc/merchants/cashheadgear_dye.txt
+++ b/npc/merchants/cashheadgear_dye.txt
@@ -114,4 +114,4 @@ prt_in,253,168,4 script Alora 862,{
delitem .@myHG,1; // Your headgear
getitem .@dyHG,1; // Dyed headgear
close;
-} \ No newline at end of file
+}
diff --git a/npc/merchants/clothes_dyer.txt b/npc/merchants/clothes_dyer.txt
index 38e44d3cb..253e849a7 100644
--- a/npc/merchants/clothes_dyer.txt
+++ b/npc/merchants/clothes_dyer.txt
@@ -1,4 +1,4 @@
-サソ//===== Hercules Script ======================================
+//===== Hercules Script ======================================
//= Clothes Dyer
//===== By: ==================================================
//= Usnul
@@ -171,4 +171,4 @@ function Dyes {
mes "Your clothes have been dyed "+((.@s)?.@DyeName$[getarg((.@s-1)*2)]:.@DyeName$[0])+".";
close;
}
-} \ No newline at end of file
+}
diff --git a/npc/merchants/coin_exchange.txt b/npc/merchants/coin_exchange.txt
index c52db9787..04c4f793c 100644
--- a/npc/merchants/coin_exchange.txt
+++ b/npc/merchants/coin_exchange.txt
@@ -84,4 +84,4 @@
}
}
man_in01,286,16,1 duplicate(merchant_13_2) Merchant of Manuk 454
-spl_in01,110,326,5 duplicate(merchant_13_2) Merchant of Splendide 439 \ No newline at end of file
+spl_in01,110,326,5 duplicate(merchant_13_2) Merchant of Splendide 439
diff --git a/npc/merchants/elemental_trader.txt b/npc/merchants/elemental_trader.txt
index 2d120d190..10dcec3e4 100644
--- a/npc/merchants/elemental_trader.txt
+++ b/npc/merchants/elemental_trader.txt
@@ -155,4 +155,4 @@ ama_in02,61,27,7 script Alchemist#ama 749,{
mes "Bring me stones! You said you are going to help me!";
mes "Keep your promises! Kehehehkehkeh...";
close;
-} \ No newline at end of file
+}
diff --git a/npc/merchants/enchan_arm.txt b/npc/merchants/enchan_arm.txt
index a9ad383b8..5bb9a7d7d 100644
--- a/npc/merchants/enchan_arm.txt
+++ b/npc/merchants/enchan_arm.txt
@@ -150,4 +150,4 @@ S_EnchantArmor:
mes "Please come back with just ONE equipment to be enchanted.";
close;
}
-} \ No newline at end of file
+}
diff --git a/npc/merchants/hd_refine.txt b/npc/merchants/hd_refine.txt
index f944d34ba..dd7b0a813 100644
--- a/npc/merchants/hd_refine.txt
+++ b/npc/merchants/hd_refine.txt
@@ -315,4 +315,4 @@ payon,148,174,3 duplicate(Basta) Basta#payon 826
alberta_in,18,56,3 duplicate(Basta) Basta#alberta 826
yuno_in01,173,18,3 duplicate(Basta) Basta#yuno 826
ein_in01,24,82,3 duplicate(Basta) Basta#einbroch 826
-lhz_in02,280,17,3 duplicate(Basta) Basta#lighthalzen 826 \ No newline at end of file
+lhz_in02,280,17,3 duplicate(Basta) Basta#lighthalzen 826
diff --git a/npc/merchants/renters.txt b/npc/merchants/renters.txt
index 02afc4059..8f9410eda 100644
--- a/npc/merchants/renters.txt
+++ b/npc/merchants/renters.txt
@@ -224,4 +224,4 @@ hu_in01,381,304,5 script Falcon Breeder#hnt 105,{
mes "...Heh heh, jealous?";
close;
}
-} \ No newline at end of file
+}
diff --git a/npc/other/card_trader.txt b/npc/other/card_trader.txt
index e451a596e..c89bc8518 100644
--- a/npc/other/card_trader.txt
+++ b/npc/other/card_trader.txt
@@ -193,4 +193,4 @@ prontera,115,90,0 script Putty 90,{
break;
}
close;
-} \ No newline at end of file
+}
diff --git a/npc/other/comodo_gambling.txt b/npc/other/comodo_gambling.txt
index 188066181..8a300253c 100644
--- a/npc/other/comodo_gambling.txt
+++ b/npc/other/comodo_gambling.txt
@@ -569,4 +569,4 @@ mjolnir_02,85,362,3 script Blacksmith Miner 726,{
mes "you at a cheap price.";
close;
}
-} \ No newline at end of file
+}
diff --git a/npc/other/guildpvp.txt b/npc/other/guildpvp.txt
index 68aca1f5d..047093e5d 100644
--- a/npc/other/guildpvp.txt
+++ b/npc/other/guildpvp.txt
@@ -51,4 +51,4 @@ pvp_y_room,77,85,4 script Guild Battle Guide 105,{
close2;
warp "guild_vs"+.@i,getd(".@map"+.@j+"X["+.@i+"]"),.@mapY[.@i];
end;
-} \ No newline at end of file
+}
diff --git a/npc/other/monster_race.txt b/npc/other/monster_race.txt
index a48afea3e..273df9345 100644
--- a/npc/other/monster_race.txt
+++ b/npc/other/monster_race.txt
@@ -2962,4 +2962,4 @@ p_track01,45,42,3 script Absent Minded Man#single 881,{
mes "I should win at least once,";
mes "right? What's going on?!";
close;
-} \ No newline at end of file
+}
diff --git a/npc/other/sealstatus.txt b/npc/other/sealstatus.txt
index 038d5357d..cb2806c6a 100644
--- a/npc/other/sealstatus.txt
+++ b/npc/other/sealstatus.txt
@@ -32,4 +32,4 @@ prontera,113,294,3 script Sign Post 837,{
if (god_mjo_0 < 11) mes "^ff0000Mjolnir Seal: Not Completed^000000";
else mes "^00ff00Mjolnir Seal: Completed^000000";
close;
-} \ No newline at end of file
+}
diff --git a/npc/pre-re/cities/izlude.txt b/npc/pre-re/cities/izlude.txt
index 950f19abd..2ad5b16a8 100644
--- a/npc/pre-re/cities/izlude.txt
+++ b/npc/pre-re/cities/izlude.txt
@@ -25,4 +25,4 @@ izlude,58,126,2 duplicate(Cebalis_izlude) Cebalis#izlude 98
izlude,124,178,2 duplicate(Soldier_izlude) Soldier#izlude 105
izlude,171,133,3 duplicate(bdt) Bullet Dealer Tony#iz 86
izlude,171,127,3 duplicate(mdk) Magazine Dealer Kenny 83
-izlude_in,110,64,3 duplicate(Dorian) Dorian#izlude 878,2,2,{ \ No newline at end of file
+izlude_in,110,64,3 duplicate(Dorian) Dorian#izlude 878,2,2,{
diff --git a/npc/pre-re/guides/guides_alberta.txt b/npc/pre-re/guides/guides_alberta.txt
index c08894f52..966e0c364 100644
--- a/npc/pre-re/guides/guides_alberta.txt
+++ b/npc/pre-re/guides/guides_alberta.txt
@@ -156,4 +156,4 @@ alberta,23,238,4 script Guide#alb::AlbGuide 105,{
end;
}
-alberta,120,60,3 duplicate(AlbGuide) Guide#2alb 105 \ No newline at end of file
+alberta,120,60,3 duplicate(AlbGuide) Guide#2alb 105
diff --git a/npc/pre-re/guides/guides_moscovia.txt b/npc/pre-re/guides/guides_moscovia.txt
index 8986c7502..790e42472 100644
--- a/npc/pre-re/guides/guides_moscovia.txt
+++ b/npc/pre-re/guides/guides_moscovia.txt
@@ -89,4 +89,4 @@ moscovia,161,76,4 script Moscovia Guide#mosk 959,{
mes "Take care.";
close;
}
-} \ No newline at end of file
+}
diff --git a/npc/pre-re/merchants/shops.txt b/npc/pre-re/merchants/shops.txt
index 124ea0ef3..eb72c44a5 100644
--- a/npc/pre-re/merchants/shops.txt
+++ b/npc/pre-re/merchants/shops.txt
@@ -21,4 +21,4 @@ izlude,94,98,4 shop Fruit Gardener#iz 53,512:-1,513:-1,515:-1,516:-1
izlude,105,92,7 shop Vendor from Milk Ranch#i 90,519:-1
izlude,164,138,4 shop Pet Groomer#iz 124,537:-1,643:-1,10013:-1,10014:-1,554:-1,6113:-1,6114:-1,6115:-1
izlude_in,115,61,0 shop Tool Dealer#iz 47,611:-1,501:-1,502:-1,503:-1,504:-1,506:-1,645:-1,656:-1,601:-1,602:-1,1065:-1,1750:-1
-izlude_in,121,64,3 shop Trading Merchant#iz 900,13200:-1,13201:-1,13202:-1,13150:-1,13102:-1,13151:-1,13154:-1,13155:-1,13163:-1,13165:-1,13168:-1 \ No newline at end of file
+izlude_in,121,64,3 shop Trading Merchant#iz 900,13200:-1,13201:-1,13202:-1,13150:-1,13102:-1,13151:-1,13154:-1,13155:-1,13163:-1,13165:-1,13168:-1
diff --git a/npc/pre-re/mobs/fields/splendide.txt b/npc/pre-re/mobs/fields/splendide.txt
index 9dfbbfa90..f8b08fe04 100644
--- a/npc/pre-re/mobs/fields/splendide.txt
+++ b/npc/pre-re/mobs/fields/splendide.txt
@@ -29,4 +29,4 @@ spl_fild02,0,0,0,0 monster Luciola Vespa 1994,15,0,0,0
spl_fild03,0,0,0,0 monster Luciola Vespa 1994,35,0,0,0
spl_fild03,0,0,0,0 monster Cornus 1992,25,0,0,0
spl_fild03,0,0,0,0 monster Naga 1993,20,0,0,0
-spl_fild03,0,0,0,0 monster Tendril Lion 1991,1,3600000,0,0 \ No newline at end of file
+spl_fild03,0,0,0,0 monster Tendril Lion 1991,1,3600000,0,0
diff --git a/npc/pre-re/other/arena.txt b/npc/pre-re/other/arena.txt
index ff88f4c28..e8fd938c6 100644
--- a/npc/pre-re/other/arena.txt
+++ b/npc/pre-re/other/arena.txt
@@ -12,4 +12,4 @@
//============================================================
izlude,128,226,0 warp welcome_arena 1,1,arena_room,100,30
-arena_room,99,24,0 warp bye_arena 2,2,izlude,128,220 \ No newline at end of file
+arena_room,99,24,0 warp bye_arena 2,2,izlude,128,220
diff --git a/npc/pre-re/quests/doomed_swords.txt b/npc/pre-re/quests/doomed_swords.txt
index 9d27d588b..6e8c45eba 100644
--- a/npc/pre-re/quests/doomed_swords.txt
+++ b/npc/pre-re/quests/doomed_swords.txt
@@ -61,4 +61,4 @@ izlude_in,173,88,2 script Nain#magum 102,{
set event_magum,5;
set dmdswrd_Q2,dmdswrd_Q2 | 4;
close;
-} \ No newline at end of file
+}
diff --git a/npc/pre-re/quests/monstertamers.txt b/npc/pre-re/quests/monstertamers.txt
index 86f118f5a..df1cb6c9d 100644
--- a/npc/pre-re/quests/monstertamers.txt
+++ b/npc/pre-re/quests/monstertamers.txt
@@ -12,4 +12,4 @@
//= 1.0 Duplicates for Monster Tamer [Streusel]
//============================================================
-izlude_in,129,64,4 duplicate(Monster_Tamer#izu) Monster Tamer#izlude 125 \ No newline at end of file
+izlude_in,129,64,4 duplicate(Monster_Tamer#izu) Monster Tamer#izlude 125
diff --git a/npc/pre-re/quests/quests_13_1.txt b/npc/pre-re/quests/quests_13_1.txt
index b98aa2b95..5e61465d8 100644
--- a/npc/pre-re/quests/quests_13_1.txt
+++ b/npc/pre-re/quests/quests_13_1.txt
@@ -14,4 +14,4 @@
// Onward to the New World
//============================================================
-izlude,101,173,6 duplicate(Promotional Staff#iz) Promotional Staff#izlude 100 \ No newline at end of file
+izlude,101,173,6 duplicate(Promotional Staff#iz) Promotional Staff#izlude 100
diff --git a/npc/pre-re/quests/quests_nameless.txt b/npc/pre-re/quests/quests_nameless.txt
index ab5d816dc..e272ad43b 100644
--- a/npc/pre-re/quests/quests_nameless.txt
+++ b/npc/pre-re/quests/quests_nameless.txt
@@ -388,4 +388,4 @@ izlude_in,113,66,0 script Strange Machine 111,{
mes "a hand on my precious";
mes "masterpiece inventions! ";
close;
-} \ No newline at end of file
+}
diff --git a/npc/pre-re/quests/skills/swordman_skills.txt b/npc/pre-re/quests/skills/swordman_skills.txt
index 7a4aa2ff3..47858500f 100644
--- a/npc/pre-re/quests/skills/swordman_skills.txt
+++ b/npc/pre-re/quests/skills/swordman_skills.txt
@@ -145,4 +145,4 @@ izlude_in,175,130,2 script Knight De Thomas 98,4,4,{
mes "I have a certain duty these days.";
mes "Ehem! Need I say more.";
close;
-} \ No newline at end of file
+}
diff --git a/npc/pre-re/scripts.conf b/npc/pre-re/scripts.conf
index 6a69ede0e..a06cab57f 100644
--- a/npc/pre-re/scripts.conf
+++ b/npc/pre-re/scripts.conf
@@ -73,4 +73,4 @@ npc: npc/pre-re/quests/quests_lighthalzen.txt
npc: npc/pre-re/quests/monstertamers.txt
npc: npc/pre-re/quests/quests_nameless.txt
npc: npc/pre-re/quests/quests_13_1.txt
-npc: npc/pre-re/quests/skills/swordman_skills.txt \ No newline at end of file
+npc: npc/pre-re/quests/skills/swordman_skills.txt
diff --git a/npc/pre-re/scripts_warps.conf b/npc/pre-re/scripts_warps.conf
index d650676c6..55b335078 100644
--- a/npc/pre-re/scripts_warps.conf
+++ b/npc/pre-re/scripts_warps.conf
@@ -19,4 +19,4 @@ npc: npc/pre-re/warps/fields/veins_fild.txt
npc: npc/pre-re/warps/fields/yuno_fild.txt
// --------------------------- Others ---------------------------
-npc: npc/pre-re/warps/other/sign.txt \ No newline at end of file
+npc: npc/pre-re/warps/other/sign.txt
diff --git a/npc/quests/kiel_hyre_quest.txt b/npc/quests/kiel_hyre_quest.txt
index 3f5a3ddf5..2940951fe 100644
--- a/npc/quests/kiel_hyre_quest.txt
+++ b/npc/quests/kiel_hyre_quest.txt
@@ -7231,4 +7231,4 @@ OnInit:
//= to after finishing the quest.
//= 3.7 Corrected NPC names to fall within proper restrictions. [L0ne_W0lf]
//= 3.8 Corrected some delitems. (bugreport:690) [Samuray22]
-//= 3.9 Fixed a cutin not being erased. (bugreport:1539) [L0ne_W0lf] \ No newline at end of file
+//= 3.9 Fixed a cutin not being erased. (bugreport:1539) [L0ne_W0lf]
diff --git a/npc/quests/mage_solution.txt b/npc/quests/mage_solution.txt
index b29fd4416..0eb3b101a 100644
--- a/npc/quests/mage_solution.txt
+++ b/npc/quests/mage_solution.txt
@@ -39,4 +39,4 @@ pay_arche,122,100,0 script Dollshoi 88,{
getitem 1089,1; //Payon_Potion
}
close;
-} \ No newline at end of file
+}
diff --git a/npc/quests/quests_13_1.txt b/npc/quests/quests_13_1.txt
index 523b5ff00..ddb7a3eea 100644
--- a/npc/quests/quests_13_1.txt
+++ b/npc/quests/quests_13_1.txt
@@ -14989,4 +14989,4 @@ prontera,161,192,5 script Ash Vacuum Warper 707,{
}
end;
}
-*/ \ No newline at end of file
+*/
diff --git a/npc/quests/thana_quest.txt b/npc/quests/thana_quest.txt
index 362695bef..b9a251d6c 100644
--- a/npc/quests/thana_quest.txt
+++ b/npc/quests/thana_quest.txt
@@ -2312,4 +2312,4 @@ OnTouch:
}
mes "A mysterious power is blocking my path.";
close;
-} \ No newline at end of file
+}
diff --git a/npc/re/cities/dicastes.txt b/npc/re/cities/dicastes.txt
index 5fd555b8f..c47671b4b 100644
--- a/npc/re/cities/dicastes.txt
+++ b/npc/re/cities/dicastes.txt
@@ -693,4 +693,4 @@ dic_in01,98,96,3 script Lost Galten#a 492,{
mes "。。。 「」 ";
mes "。。「イ 。 。。";
close;
-} \ No newline at end of file
+}
diff --git a/npc/re/cities/jawaii.txt b/npc/re/cities/jawaii.txt
index a4b584d3a..f1020b2f8 100644
--- a/npc/re/cities/jawaii.txt
+++ b/npc/re/cities/jawaii.txt
@@ -13,4 +13,4 @@
//= 1.1 Changed to Official coordinates [Streusel]
//============================================================
-izlude,180,224,6 duplicate(Honeymoon_Helper_Izlude) Honeymoon Helper#Izlude 71 \ No newline at end of file
+izlude,180,224,6 duplicate(Honeymoon_Helper_Izlude) Honeymoon Helper#Izlude 71
diff --git a/npc/re/cities/malangdo.txt b/npc/re/cities/malangdo.txt
index 0ee7ca8be..76cc418cf 100644
--- a/npc/re/cities/malangdo.txt
+++ b/npc/re/cities/malangdo.txt
@@ -389,4 +389,4 @@ OnTouch:
emotion e_flash;
end;
}
-malangdo,164,203,3 duplicate(Cat Trainer#mal1) Cat Trainer#mal2 853,5,8 \ No newline at end of file
+malangdo,164,203,3 duplicate(Cat Trainer#mal1) Cat Trainer#mal2 853,5,8
diff --git a/npc/re/cities/malaya.txt b/npc/re/cities/malaya.txt
index dd5ca3101..30a38cf4d 100644
--- a/npc/re/cities/malaya.txt
+++ b/npc/re/cities/malaya.txt
@@ -1763,4 +1763,4 @@ malaya,257,58,6 script Jeepney Driver#09 582,{
"Since everybody have different tastes, you can see those with cool and elaborate decorations.",
"Of course you don't need to drive them yourselves, but you can ride them so please feel free to do so."
);
-} \ No newline at end of file
+}
diff --git a/npc/re/jobs/3-1/archbishop.txt b/npc/re/jobs/3-1/archbishop.txt
index c71e2abd3..9a13aa359 100644
--- a/npc/re/jobs/3-1/archbishop.txt
+++ b/npc/re/jobs/3-1/archbishop.txt
@@ -1664,4 +1664,4 @@ job3_arch01,1,1,1 script control#arch 844,{
close;
}
}
-*/ \ No newline at end of file
+*/
diff --git a/npc/re/jobs/3-1/guillotine_cross.txt b/npc/re/jobs/3-1/guillotine_cross.txt
index 71769be81..47b42e16f 100644
--- a/npc/re/jobs/3-1/guillotine_cross.txt
+++ b/npc/re/jobs/3-1/guillotine_cross.txt
@@ -3916,4 +3916,4 @@ job3_guil03,1,8,0 script #GMhelper02_gc 844,{
mes "-_-.";
close;
}
-*/ \ No newline at end of file
+*/
diff --git a/npc/re/jobs/3-1/mechanic.txt b/npc/re/jobs/3-1/mechanic.txt
index c38d4608f..4890d072b 100644
--- a/npc/re/jobs/3-1/mechanic.txt
+++ b/npc/re/jobs/3-1/mechanic.txt
@@ -730,4 +730,4 @@ OnTouch:
}
jupe_core2,150,33,0 duplicate(#Acquiring Knowledge) #Acquiring Knowledge2 139,1,0
-jupe_core2,0,0,0,0 monster Dimik 1669,100,0,0,0 \ No newline at end of file
+jupe_core2,0,0,0,0 monster Dimik 1669,100,0,0,0
diff --git a/npc/re/jobs/3-1/ranger.txt b/npc/re/jobs/3-1/ranger.txt
index 314f199d2..02af29d54 100644
--- a/npc/re/jobs/3-1/ranger.txt
+++ b/npc/re/jobs/3-1/ranger.txt
@@ -1803,4 +1803,4 @@ job3_rang01,58,1,0 script Worker#job_ranger 88,{
close;
}
}
-*/ \ No newline at end of file
+*/
diff --git a/npc/re/jobs/3-1/warlock.txt b/npc/re/jobs/3-1/warlock.txt
index 9894eae4b..d08d7395d 100644
--- a/npc/re/jobs/3-1/warlock.txt
+++ b/npc/re/jobs/3-1/warlock.txt
@@ -1096,4 +1096,4 @@ job3_war01,1,2,0 script Button Girl 66,{
*/
spl_fild02,0,0,0,0 monster Bradium Golem 2049,20,5000,0,0
-spl_fild02,0,0,0,0 monster Naga 2047,20,5000,0,0 \ No newline at end of file
+spl_fild02,0,0,0,0 monster Naga 2047,20,5000,0,0
diff --git a/npc/re/jobs/3-2/genetic.txt b/npc/re/jobs/3-2/genetic.txt
index bfa7d422c..5ca20d2d3 100644
--- a/npc/re/jobs/3-2/genetic.txt
+++ b/npc/re/jobs/3-2/genetic.txt
@@ -1044,4 +1044,4 @@ job3_gen01,23,33,0,0 monster Poison Spore 1428,1,7000,0,0
job3_gen01,21,30,0,0 monster Poison Spore 1428,1,7000,0,0
job3_gen01,26,34,0,0 monster Poison Spore 1428,1,7000,0,0
job3_gen01,23,33,0,0 monster Poison Spore 1428,1,7000,0,0
-job3_gen01,21,30,0,0 monster Poison Spore 1428,1,7000,0,0 \ No newline at end of file
+job3_gen01,21,30,0,0 monster Poison Spore 1428,1,7000,0,0
diff --git a/npc/re/jobs/3-2/minstrel.txt b/npc/re/jobs/3-2/minstrel.txt
index a9d584526..5ffc84a06 100644
--- a/npc/re/jobs/3-2/minstrel.txt
+++ b/npc/re/jobs/3-2/minstrel.txt
@@ -1917,4 +1917,4 @@ prt_in,94,172,4 script Karian#job_min3 480,{
mes "[Karian]";
mes "How did you get in here?";
close;
-} \ No newline at end of file
+}
diff --git a/npc/re/jobs/3-2/royal_guard.txt b/npc/re/jobs/3-2/royal_guard.txt
index 614896133..1222c23ed 100644
--- a/npc/re/jobs/3-2/royal_guard.txt
+++ b/npc/re/jobs/3-2/royal_guard.txt
@@ -538,4 +538,4 @@ sec_in02,12,43,3 script sorcereryal 57,1,1,{
close;
}
}
-*/ \ No newline at end of file
+*/
diff --git a/npc/re/jobs/3-2/shadow_chaser.txt b/npc/re/jobs/3-2/shadow_chaser.txt
index f9d27dc84..313ce7390 100644
--- a/npc/re/jobs/3-2/shadow_chaser.txt
+++ b/npc/re/jobs/3-2/shadow_chaser.txt
@@ -2503,4 +2503,4 @@ OnTouch:
//============================================================
tur_dun03,0,0,0,0 monster Shadow of Deception 2076,1,1000,0,0
ice_dun02,0,0,0,0 monster Shadow of Illusion 2077,1,1000,0,0
-niflheim,0,0,0,0 monster Shadow of Pleasure 2078,1,1000,0,0 \ No newline at end of file
+niflheim,0,0,0,0 monster Shadow of Pleasure 2078,1,1000,0,0
diff --git a/npc/re/jobs/3-2/sorcerer.txt b/npc/re/jobs/3-2/sorcerer.txt
index 71ec97e4b..d2cec9242 100644
--- a/npc/re/jobs/3-2/sorcerer.txt
+++ b/npc/re/jobs/3-2/sorcerer.txt
@@ -417,4 +417,4 @@ gef_tower,113,161,5 script Karacas 754,{
thor_v01,64,252,0 duplicate(Spirit Detecting Staff#0) Spirit Detecting Staff#1 836
ice_dun01,274,274,0 duplicate(Spirit Detecting Staff#0) Spirit Detecting Staff#2 836
mjo_dun03,200,141,0 duplicate(Spirit Detecting Staff#0) Spirit Detecting Staff#3 836
-gon_dun02,195,190,0 duplicate(Spirit Detecting Staff#0) Spirit Detecting Staff#4 836 \ No newline at end of file
+gon_dun02,195,190,0 duplicate(Spirit Detecting Staff#0) Spirit Detecting Staff#4 836
diff --git a/npc/re/jobs/3-2/sura.txt b/npc/re/jobs/3-2/sura.txt
index 311e95ec1..5a0e8e36a 100644
--- a/npc/re/jobs/3-2/sura.txt
+++ b/npc/re/jobs/3-2/sura.txt
@@ -864,4 +864,4 @@ sword_2-1,1,2,0 script Button Girl#sura 66,{
close;
}
}
-*/ \ No newline at end of file
+*/
diff --git a/npc/re/jobs/3-2/wanderer.txt b/npc/re/jobs/3-2/wanderer.txt
index 41839b644..fd3b75f59 100644
--- a/npc/re/jobs/3-2/wanderer.txt
+++ b/npc/re/jobs/3-2/wanderer.txt
@@ -1034,4 +1034,4 @@ xmas,145,127,7 duplicate(#wander_xmas) Spectator#xmas2 712
xmas,148,127,7 duplicate(#wander_xmas) Soy#xmas 714
xmas,149,127,1 duplicate(#wander_xmas) Mimi#xmas 714
xmas,151,127,1 duplicate(#wander_xmas) Spectator#xmas3 716
-xmas,154,129,1 duplicate(#wander_xmas) Spectator#xmas4 797 \ No newline at end of file
+xmas,154,129,1 duplicate(#wander_xmas) Spectator#xmas4 797
diff --git a/npc/re/jobs/novice/novice.txt b/npc/re/jobs/novice/novice.txt
index ebefaff48..b9c2a10ac 100644
--- a/npc/re/jobs/novice/novice.txt
+++ b/npc/re/jobs/novice/novice.txt
@@ -2053,4 +2053,4 @@ new_5-3,0,0,0,0 monster Fabre 1184,5,0,0,0
new_5-3,0,0,0,0 monster Rocker 1052,10,0,0,0
new_5-3,0,0,0,0 monster Spore 1014,1,0,0,0
new_5-3,0,0,0,0 monster Thief Bug 1051,1,0,0,0
-new_5-3,0,0,0,0 monster Thief Bug 1053,1,0,0,0 \ No newline at end of file
+new_5-3,0,0,0,0 monster Thief Bug 1053,1,0,0,0
diff --git a/npc/re/merchants/3rd_trader.txt b/npc/re/merchants/3rd_trader.txt
index 7c3ca3cac..86dd01656 100644
--- a/npc/re/merchants/3rd_trader.txt
+++ b/npc/re/merchants/3rd_trader.txt
@@ -225,4 +225,4 @@ gef_tower,105,172,5 script Point Salesman#Sorcerer::pss 700,{
}
comodo,241,103,6 duplicate(pss) Point Salesman#1 700
alberta,105,52,7 duplicate(pss) Point Salesman#2 700
-veins,202,128,6 duplicate(pss) Point Salesman#3 700 \ No newline at end of file
+veins,202,128,6 duplicate(pss) Point Salesman#3 700
diff --git a/npc/re/merchants/flute.txt b/npc/re/merchants/flute.txt
index 8eb987e08..1aa7c38d4 100644
--- a/npc/re/merchants/flute.txt
+++ b/npc/re/merchants/flute.txt
@@ -138,4 +138,4 @@ tur_dun01,89,170,5 script Expert Flute Crafter 59,{
mes "Eeehh? You are not a Ranger?";
mes "Then this flute is totally useless for you!";
close;
-} \ No newline at end of file
+}
diff --git a/npc/re/mobs/fields/amatsu.txt b/npc/re/mobs/fields/amatsu.txt
index 86e96f337..c0469afff 100644
--- a/npc/re/mobs/fields/amatsu.txt
+++ b/npc/re/mobs/fields/amatsu.txt
@@ -32,4 +32,4 @@ ama_fild01,171,313,0,0 monster Hydra 1068,1,66000,33000,0
ama_fild01,171,314,0,0 monster Hydra 1068,1,69000,34500,0
ama_fild01,171,315,0,0 monster Hydra 1068,1,69000,34500,0
ama_fild01,175,314,0,0 monster Hydra 1068,1,72000,39000,0
-ama_fild01,169,315,0,0 monster Hydra 1068,1,72000,39000,0 \ No newline at end of file
+ama_fild01,169,315,0,0 monster Hydra 1068,1,72000,39000,0
diff --git a/npc/re/mobs/fields/comodo.txt b/npc/re/mobs/fields/comodo.txt
index ae4ddedeb..b2db8d86b 100644
--- a/npc/re/mobs/fields/comodo.txt
+++ b/npc/re/mobs/fields/comodo.txt
@@ -94,4 +94,4 @@ cmd_fild09,0,0,0,0 monster Metaller 1058,145,5000,0,0
cmd_fild09,0,0,0,0 monster Deniro 1105,15,5000,0,0
cmd_fild09,0,0,0,0 monster Piere 1160,15,5000,0,0
cmd_fild09,0,0,0,0 monster Andre 1095,15,5000,0,0
-cmd_fild09,0,0,0,0 monster Ant Egg 1097,10,5000,0,0 \ No newline at end of file
+cmd_fild09,0,0,0,0 monster Ant Egg 1097,10,5000,0,0
diff --git a/npc/re/mobs/fields/einbroch.txt b/npc/re/mobs/fields/einbroch.txt
index f31395f3b..eaf12a96d 100644
--- a/npc/re/mobs/fields/einbroch.txt
+++ b/npc/re/mobs/fields/einbroch.txt
@@ -104,4 +104,4 @@ ein_fild09,0,0,0,0 monster Red Mushroom 1085,10,120000,60000,0
//==================================================
//ein_fild10,0,0,0,0 monster Red Plant 1078,20,120000,60000,1
//ein_fild10,0,0,0,0 monster Yellow Plant 1081,20,120000,60000,1
-//ein_fild10,0,0,0,0 monster Blue Plant 1079,20,600000,300000,1 \ No newline at end of file
+//ein_fild10,0,0,0,0 monster Blue Plant 1079,20,600000,300000,1
diff --git a/npc/re/mobs/fields/geffen.txt b/npc/re/mobs/fields/geffen.txt
index 35ff2e814..d6d6be055 100644
--- a/npc/re/mobs/fields/geffen.txt
+++ b/npc/re/mobs/fields/geffen.txt
@@ -197,4 +197,4 @@ gef_fild11,283,100,4,1 monster Black Mushroom 1084,3,360000,180000,1
//==================================================
// gef_fild14 - Disabled on Renewal
-//================================================== \ No newline at end of file
+//==================================================
diff --git a/npc/re/mobs/fields/gonryun.txt b/npc/re/mobs/fields/gonryun.txt
index 290524caa..5ffd88921 100644
--- a/npc/re/mobs/fields/gonryun.txt
+++ b/npc/re/mobs/fields/gonryun.txt
@@ -17,4 +17,4 @@ gon_fild01,0,0,0,0 monster Dumpling Child 1409,55,5000,0,0
gon_fild01,0,0,0,0 monster Baby Leopard 1415,40,5000,0,0
gon_fild01,0,0,0,0 monster Side Winder 1037,10,5000,0,0
gon_fild01,0,0,0,0 monster Green Plant 1080,5,10000,0,1
-gon_fild01,0,0,0,0 monster Shining Plant 1083,1,10000,0,1 \ No newline at end of file
+gon_fild01,0,0,0,0 monster Shining Plant 1083,1,10000,0,1
diff --git a/npc/re/mobs/fields/hugel.txt b/npc/re/mobs/fields/hugel.txt
index 852d35e4e..fd04fc658 100644
--- a/npc/re/mobs/fields/hugel.txt
+++ b/npc/re/mobs/fields/hugel.txt
@@ -71,4 +71,4 @@ hu_fild06,234,251,14,120 monster Yellow Plant 1081,10,600000,0,1
//==================================================
// hu_fild07 - Disabled on Renewal
//==================================================
-//hu_fild07,0,0,0,0 monster Yellow Plant 1081,20,10000,0,1 \ No newline at end of file
+//hu_fild07,0,0,0,0 monster Yellow Plant 1081,20,10000,0,1
diff --git a/npc/re/mobs/fields/jawaii.txt b/npc/re/mobs/fields/jawaii.txt
index 14490c698..b2483deca 100644
--- a/npc/re/mobs/fields/jawaii.txt
+++ b/npc/re/mobs/fields/jawaii.txt
@@ -24,4 +24,4 @@ jawaii_in,128,121,1,4 monster Red Mushroom 1085,1,3000000,1200000,0
jawaii_in,124,76,1,1 monster Black Mushroom 1084,1,3600000,1200000,0
jawaii_in,72,74,5,1 monster Black Mushroom 1084,2,3000000,1200000,0
jawaii_in,73,117,4,4 monster Thief Bug Egg 1048,1,5400000,3000000,0
-jawaii_in,83,117,5,5 monster Thief Bug Egg 1048,1,4800000,2400000,0 \ No newline at end of file
+jawaii_in,83,117,5,5 monster Thief Bug Egg 1048,1,4800000,2400000,0
diff --git a/npc/re/mobs/fields/lighthalzen.txt b/npc/re/mobs/fields/lighthalzen.txt
index 92cbad659..6438c3c93 100644
--- a/npc/re/mobs/fields/lighthalzen.txt
+++ b/npc/re/mobs/fields/lighthalzen.txt
@@ -45,4 +45,4 @@ lhz_fild03,0,0,0,0 monster Rafflesia 1162,20,5000,0,0
lhz_fild03,0,0,0,0 monster Metaling 1613,20,5000,0,0
lhz_fild03,0,0,0,0 monster Demon Pungus 1378,15,5000,0,0
lhz_fild03,0,0,0,0 monster Red Plant 1078,10,60000,30000,1
-lhz_fild03,0,0,0,0 monster Green Plant 1080,10,60000,30000,0 \ No newline at end of file
+lhz_fild03,0,0,0,0 monster Green Plant 1080,10,60000,30000,0
diff --git a/npc/re/mobs/fields/louyang.txt b/npc/re/mobs/fields/louyang.txt
index 586b49960..6654d835a 100644
--- a/npc/re/mobs/fields/louyang.txt
+++ b/npc/re/mobs/fields/louyang.txt
@@ -18,4 +18,4 @@ lou_fild01,0,0,0,0 monster Mi Gao 1516,40,5000,0,0
lou_fild01,0,0,0,0 monster Mantis 1139,19,5000,0,0
lou_fild01,0,0,0,0 monster Geographer 1368,19,5000,0,0
lou_fild01,0,0,0,0 monster Black Mushroom 1084,5,5000,0,0
-lou_fild01,0,0,0,0 monster Yellow Plant 1081,10,10000,0,1 \ No newline at end of file
+lou_fild01,0,0,0,0 monster Yellow Plant 1081,10,10000,0,1
diff --git a/npc/re/mobs/fields/manuk.txt b/npc/re/mobs/fields/manuk.txt
index e27d7f6c6..eddc7169b 100644
--- a/npc/re/mobs/fields/manuk.txt
+++ b/npc/re/mobs/fields/manuk.txt
@@ -31,4 +31,4 @@ man_fild02,0,0,0,0 monster Tatacho 1986,25,5000,0,0
man_fild03,0,0,0,0 monster Hillslion 1989,25,5000,0,0
man_fild03,0,0,0,0 monster Tatacho 1986,25,5000,0,0
man_fild03,0,0,0,0 monster Centipede 1987,25,5000,0,0
-man_fild03,0,0,0,0 monster Hardrock Mammoth 1990,1,14400000,0,0 \ No newline at end of file
+man_fild03,0,0,0,0 monster Hardrock Mammoth 1990,1,14400000,0,0
diff --git a/npc/re/mobs/fields/mjolnir.txt b/npc/re/mobs/fields/mjolnir.txt
index 58fba9422..78e39d96b 100644
--- a/npc/re/mobs/fields/mjolnir.txt
+++ b/npc/re/mobs/fields/mjolnir.txt
@@ -224,4 +224,4 @@ mjolnir_11,295,271,0,0 monster Green Plant 1080,1,180000,90000,1
//==================================================
mjolnir_12,0,0,0,0 monster Dustiness 1114,130,5000,0,0
mjolnir_12,0,0,0,0 monster Hunter Fly 1035,35,5000,0,0
-mjolnir_12,0,0,0,0 monster Mantis 1139,35,5000,0,0 \ No newline at end of file
+mjolnir_12,0,0,0,0 monster Mantis 1139,35,5000,0,0
diff --git a/npc/re/mobs/fields/morocc.txt b/npc/re/mobs/fields/morocc.txt
index 3e71b0846..663f46134 100644
--- a/npc/re/mobs/fields/morocc.txt
+++ b/npc/re/mobs/fields/morocc.txt
@@ -214,4 +214,4 @@ moc_fild22,0,0,0,0 monster Incarnation of Morroc 1918,60,30000,0,0
moc_fild22,0,0,0,0 monster Incarnation of Morroc 1919,60,30000,0,0
moc_fild22,0,0,0,0 monster Incarnation of Morroc 1920,60,30000,0,0
moc_fild22,0,0,0,0 monster Incarnation of Morroc 1921,25,10000,0,0
-moc_fild22,0,0,0,0 boss_monster Wounded Morroc 1917,1,43200000,600000,0 \ No newline at end of file
+moc_fild22,0,0,0,0 boss_monster Wounded Morroc 1917,1,43200000,600000,0
diff --git a/npc/re/mobs/fields/moscovia.txt b/npc/re/mobs/fields/moscovia.txt
index 7ffbd4c28..158fb2d66 100644
--- a/npc/re/mobs/fields/moscovia.txt
+++ b/npc/re/mobs/fields/moscovia.txt
@@ -18,4 +18,4 @@ mosk_fild02,0,0,0,0 monster Argiope 1099,30,5000,0,0
mosk_fild02,0,0,0,0 monster Mantis 1139,10,5000,0,0
mosk_fild02,0,0,0,0 monster Geographer 1368,5,5000,0,0
mosk_fild02,0,0,0,0 monster Yellow Plant 1081,5,10000,0,1
-mosk_fild02,0,0,0,0 monster White Plant 1082,5,10000,0,1 \ No newline at end of file
+mosk_fild02,0,0,0,0 monster White Plant 1082,5,10000,0,1
diff --git a/npc/re/mobs/fields/payon.txt b/npc/re/mobs/fields/payon.txt
index 9736fb31b..41e239861 100644
--- a/npc/re/mobs/fields/payon.txt
+++ b/npc/re/mobs/fields/payon.txt
@@ -127,4 +127,4 @@ pay_fild10,66,332,10,10 monster Blue Plant 1079,1,360000,180000,1
//==================================================
// pay_fild11 - Disabled on Renewal
-//================================================== \ No newline at end of file
+//==================================================
diff --git a/npc/re/mobs/fields/prontera.txt b/npc/re/mobs/fields/prontera.txt
index 5eec3c925..0930fc088 100644
--- a/npc/re/mobs/fields/prontera.txt
+++ b/npc/re/mobs/fields/prontera.txt
@@ -122,4 +122,4 @@ prt_fild11,0,0,0,0 monster Goblin 1125,10,5000,0,0
prt_fild11,0,0,0,0 monster Goblin 1123,10,5000,0,0
prt_fild11,0,0,0,0 monster Goblin 1122,10,5000,0,0
prt_fild11,0,0,0,0 monster Panzer Goblin 1308,1,1800000,1200000,0
-prt_fild11,0,0,0,0 monster Red Mushroom 1085,10,180000,90000,1 \ No newline at end of file
+prt_fild11,0,0,0,0 monster Red Mushroom 1085,10,180000,90000,1
diff --git a/npc/re/mobs/fields/rachel.txt b/npc/re/mobs/fields/rachel.txt
index 68e34c4c5..d8dd26f42 100644
--- a/npc/re/mobs/fields/rachel.txt
+++ b/npc/re/mobs/fields/rachel.txt
@@ -99,4 +99,4 @@ ra_fild12,0,0,0,0 monster Red Plant 1078,5,10000,0,1
//==================================================
// ra_fild13 - Disabled on Renewal
-//================================================== \ No newline at end of file
+//==================================================
diff --git a/npc/re/mobs/fields/splendide.txt b/npc/re/mobs/fields/splendide.txt
index a9b5c8a1a..97a6befd4 100644
--- a/npc/re/mobs/fields/splendide.txt
+++ b/npc/re/mobs/fields/splendide.txt
@@ -30,4 +30,4 @@ spl_fild02,0,0,0,0 monster Luciola Vespa 1994,15,5000,0,0
spl_fild03,0,0,0,0 monster Luciola Vespa 1994,35,5000,0,0
spl_fild03,0,0,0,0 monster Cornus 1992,25,5000,0,0
spl_fild03,0,0,0,0 monster Naga 1993,20,5000,0,0
-spl_fild03,0,0,0,0 monster Tendrilion 1991,1,3600000,0,0 \ No newline at end of file
+spl_fild03,0,0,0,0 monster Tendrilion 1991,1,3600000,0,0
diff --git a/npc/re/mobs/fields/umbala.txt b/npc/re/mobs/fields/umbala.txt
index e3bd52469..3914207a3 100644
--- a/npc/re/mobs/fields/umbala.txt
+++ b/npc/re/mobs/fields/umbala.txt
@@ -54,4 +54,4 @@ um_fild04,0,0,0,0 monster Wootan Fighter 1499,5,5000,0,0
um_fild04,0,0,0,0 monster Wooden Golem 1497,10,5000,0,0
um_fild04,0,0,0,0 monster Choco 1214,2,5000,0,0
um_fild04,0,0,0,0 monster Red Plant 1078,5,180000,90000,1
-um_fild04,0,0,0,0 monster Yellow Plant 1081,5,180000,90000,1 \ No newline at end of file
+um_fild04,0,0,0,0 monster Yellow Plant 1081,5,180000,90000,1
diff --git a/npc/re/mobs/fields/veins.txt b/npc/re/mobs/fields/veins.txt
index ca8cc431e..dd52b4257 100644
--- a/npc/re/mobs/fields/veins.txt
+++ b/npc/re/mobs/fields/veins.txt
@@ -75,4 +75,4 @@ ve_fild04,288,273,4,4 monster Blue Plant 1079,3,660000,0,1
ve_fild07,0,0,0,0 monster Stapo 1784,100,5000,0,0
ve_fild07,0,0,0,0 monster Drosera 1781,50,5000,0,0
ve_fild07,0,0,0,0 monster Muscipular 1780,30,5000,0,0
-ve_fild07,0,0,0,0 monster White Plant 1082,10,600000,0,1 \ No newline at end of file
+ve_fild07,0,0,0,0 monster White Plant 1082,10,600000,0,1
diff --git a/npc/re/mobs/fields/yuno.txt b/npc/re/mobs/fields/yuno.txt
index 13f1ecb63..15aa2046b 100644
--- a/npc/re/mobs/fields/yuno.txt
+++ b/npc/re/mobs/fields/yuno.txt
@@ -138,4 +138,4 @@ yuno_fild11,0,0,0,0 monster Yellow Plant 1081,10,180000,90000,1
// yuno_fild12 - Border Checkpoint
//==================================================
yuno_fild12,0,0,0,0 monster Geographer 1368,60,5000,0,0
-yuno_fild12,0,0,0,0 monster Mantis 1139,30,5000,0,0 \ No newline at end of file
+yuno_fild12,0,0,0,0 monster Mantis 1139,30,5000,0,0
diff --git a/npc/re/quests/monstertamers.txt b/npc/re/quests/monstertamers.txt
index cc95d3749..c2a1388e1 100644
--- a/npc/re/quests/monstertamers.txt
+++ b/npc/re/quests/monstertamers.txt
@@ -12,4 +12,4 @@
//= 1.0 Duplicates for Monster Tamer
//============================================================
-izlude_in,55,105,4 duplicate(Monster_Tamer#izu) Monster Tamer#izlude 125 \ No newline at end of file
+izlude_in,55,105,4 duplicate(Monster_Tamer#izu) Monster Tamer#izlude 125
diff --git a/npc/re/quests/quests_13_1.txt b/npc/re/quests/quests_13_1.txt
index 107b7c029..f1908874e 100644
--- a/npc/re/quests/quests_13_1.txt
+++ b/npc/re/quests/quests_13_1.txt
@@ -14,4 +14,4 @@
// Onward to the New World
//============================================================
-izlude,102,171,6 duplicate(Promotional Staff#iz) Promotional Staff#izlude 100 \ No newline at end of file
+izlude,102,171,6 duplicate(Promotional Staff#iz) Promotional Staff#izlude 100
diff --git a/npc/re/quests/quests_malaya.txt b/npc/re/quests/quests_malaya.txt
index 002130ee6..96fb036b0 100644
--- a/npc/re/quests/quests_malaya.txt
+++ b/npc/re/quests/quests_malaya.txt
@@ -1480,4 +1480,4 @@ ma_fild02,308,262,3 script Guard#buwayacave 570,{
OnInit:
disablenpc "Guard#buwayacave";
end;
-} \ No newline at end of file
+}
diff --git a/npc/re/quests/quests_veins.txt b/npc/re/quests/quests_veins.txt
index 3478fe16b..0f3df7828 100644
--- a/npc/re/quests/quests_veins.txt
+++ b/npc/re/quests/quests_veins.txt
@@ -12,4 +12,4 @@
//= 1.0 First version.
//============================================================
-ve_fild02,337,314,4 duplicate(WincingOldMan_veins) Wincing Old Man#ve 945 \ No newline at end of file
+ve_fild02,337,314,4 duplicate(WincingOldMan_veins) Wincing Old Man#ve 945
diff --git a/npc/re/warps/cities/dicastes.txt b/npc/re/warps/cities/dicastes.txt
index d2c84ad0a..1a59f5241 100644
--- a/npc/re/warps/cities/dicastes.txt
+++ b/npc/re/warps/cities/dicastes.txt
@@ -71,4 +71,4 @@ dic_in01,57,48,0 duplicate(Elevator#main) Elevator#9 844
dic_in01,137,46,0 duplicate(Elevator#main) Elevator#10 844
dic_in01,222,46,0 duplicate(Elevator#main) Elevator#11 844
dic_in01,388,272,0 duplicate(Elevator#main) Elevator#12 844
-dic_in01,389,208,0 duplicate(Elevator#main) Elevator#13 844 \ No newline at end of file
+dic_in01,389,208,0 duplicate(Elevator#main) Elevator#13 844
diff --git a/npc/re/warps/cities/izlude.txt b/npc/re/warps/cities/izlude.txt
index 4be33317e..fa888c7fb 100644
--- a/npc/re/warps/cities/izlude.txt
+++ b/npc/re/warps/cities/izlude.txt
@@ -38,4 +38,4 @@ iz_ac01,100,24,0 warp iz_ac01 2,2,izlude,127,253
iz_ac01,122,25,0 warp iz_ac02 2,2,iz_ac02,104,27
iz_ac01,78,25,0 warp iz_ac03 2,2,iz_ac02,104,27
iz_ac02,113,27,0 warp iz_ac04 2,2,iz_ac01,122,28
-iz_ac02,94,27,0 warp iz_ac05 2,2,iz_ac01,78,28 \ No newline at end of file
+iz_ac02,94,27,0 warp iz_ac05 2,2,iz_ac01,78,28
diff --git a/npc/re/warps/cities/malaya.txt b/npc/re/warps/cities/malaya.txt
index a792c4690..38e67e3e0 100644
--- a/npc/re/warps/cities/malaya.txt
+++ b/npc/re/warps/cities/malaya.txt
@@ -99,4 +99,4 @@ ma_zif05,30,22,0 warp malaya_car0005 1,1,malaya,341,150
ma_zif06,30,22,0 warp malaya_car0006 1,1,malaya,294,293
ma_zif07,30,22,0 warp malaya_car0007 1,1,malaya,239,221
ma_zif08,30,22,0 warp malaya_car0008 1,1,malaya,59,246
-ma_zif09,30,22,0 warp malaya_car0009 1,1,malaya,254,68 \ No newline at end of file
+ma_zif09,30,22,0 warp malaya_car0009 1,1,malaya,254,68
diff --git a/npc/re/warps/dungeons/iz_dun.txt b/npc/re/warps/dungeons/iz_dun.txt
index bbe68f8b8..7b46b5e2d 100644
--- a/npc/re/warps/dungeons/iz_dun.txt
+++ b/npc/re/warps/dungeons/iz_dun.txt
@@ -60,4 +60,4 @@ iz_dun05,142,190,5 script Guard#iz_dun 413,{
mes "You're braver than I thought.";
close;
}
-} \ No newline at end of file
+}
diff --git a/npc/re/warps/other/jobquests.txt b/npc/re/warps/other/jobquests.txt
index 5b62a74a4..3a2a321fb 100644
--- a/npc/re/warps/other/jobquests.txt
+++ b/npc/re/warps/other/jobquests.txt
@@ -41,4 +41,4 @@ job3_gen01,71,56,0 warp #from2to1gen 1,1,job3_gen01,11,60
//==============================================================================
//Shadow Chaser
//==============================================================================
-job3_sha01,71,19,0 warp shadowc1 1,1,tha_t01,149,224 \ No newline at end of file
+job3_sha01,71,19,0 warp shadowc1 1,1,tha_t01,149,224
diff --git a/npc/re/warps/other/s_workshop.txt b/npc/re/warps/other/s_workshop.txt
index bc04509b3..3f50edb6b 100644
--- a/npc/re/warps/other/s_workshop.txt
+++ b/npc/re/warps/other/s_workshop.txt
@@ -28,4 +28,4 @@ s_atelier,80,66,0 warp s_atelier0012 1,1,s_atelier,32,56
s_atelier,109,129,0 warp s_atelier0013 1,1,s_atelier,159,125
s_atelier,160,130,0 warp s_atelier0014 1,1,s_atelier,114,129
yuno,278,66,0 warp s_atelier0015 1,1,s_atelier,111,122
-s_atelier,107,122,0 warp s_atelier0016 1,1,yuno,274,66 \ No newline at end of file
+s_atelier,107,122,0 warp s_atelier0016 1,1,yuno,274,66
diff --git a/npc/scripts_mapflags.conf b/npc/scripts_mapflags.conf
index 2fe92eb0a..29a72171b 100644
--- a/npc/scripts_mapflags.conf
+++ b/npc/scripts_mapflags.conf
@@ -29,4 +29,4 @@ npc: npc/mapflag/town.txt
npc: npc/mapflag/reset.txt
npc: npc/mapflag/skillmodifier.txt
npc: npc/mapflag/skillduration.txt
-npc: npc/mapflag/notomb.txt \ No newline at end of file
+npc: npc/mapflag/notomb.txt
diff --git a/npc/scripts_warps.conf b/npc/scripts_warps.conf
index 75b14bb47..6f3a25558 100644
--- a/npc/scripts_warps.conf
+++ b/npc/scripts_warps.conf
@@ -87,4 +87,4 @@ npc: npc/warps/other/kiel.txt
npc: npc/warps/other/other.txt
npc: npc/warps/other/arena.txt
npc: npc/warps/guildcastles.txt
-npc: npc/warps/pvp.txt \ No newline at end of file
+npc: npc/warps/pvp.txt
diff --git a/plugins/empty.txt b/plugins/empty.txt
index e6b990d30..81128d0e2 100644
--- a/plugins/empty.txt
+++ b/plugins/empty.txt
@@ -1 +1 @@
-Oi. nothing to see here! unless you compile a plugin :P \ No newline at end of file
+Oi. nothing to see here! unless you compile a plugin :P
diff --git a/sql-files/item_db.sql b/sql-files/item_db.sql
index 67421fd77..6a62fd4c6 100644
--- a/sql-files/item_db.sql
+++ b/sql-files/item_db.sql
@@ -6178,4 +6178,4 @@ INSERT INTO `item_db` (`id`, `name_english`, `name_japanese`, `type`, `price_buy
(19505, 'T_Cigarette', 'T Cigarette', 5, 0, 0, 0, 0, 0, 0, 0, 4294967295, 7, 2, 4096, 0, 0, 0, 54, '', '', ''),
(19506, 'T_Valkyrie_Feather_Band', 'T Valkyrie Feather Band', 5, 0, 0, 0, 0, 0, 0, 0, 4294967295, 7, 2, 1024, 0, 0, 1, 300, '', '', ''),
(19507, 'Clear_Sun', 'Clear Sun', 5, 0, 0, 0, 0, 0, 0, 0, 4294967295, 7, 2, 1024, 0, 1, 0, 654, '', '', ''),
-(22540, 'Runstone_Luxanima', 'Lux Anima Rune', 11, 2, 1, 100, 0, 0, 0, 0, 4294967295, 7, 2, 0, 0, 0, 0, 0, 'itemskill "RK_LUXANIMA",1;', '', ''); \ No newline at end of file
+(22540, 'Runstone_Luxanima', 'Lux Anima Rune', 11, 2, 1, 100, 0, 0, 0, 0, 4294967295, 7, 2, 0, 0, 0, 0, 0, 'itemskill "RK_LUXANIMA",1;', '', '');
diff --git a/sql-files/item_db_re.sql b/sql-files/item_db_re.sql
index a6c53f1e7..dfe4f7830 100644
--- a/sql-files/item_db_re.sql
+++ b/sql-files/item_db_re.sql
@@ -8165,4 +8165,4 @@ INSERT INTO `item_db_re` (`id`, `name_english`, `name_japanese`, `type`, `price_
(21004, 'Alca_Bringer_', 'Alca Bringer', 4, 20, 10, 3400, 280, 0, 0, 2, 2, 16512, 56, 2, 34, 3, 100, 0, 1, 3, '', '', ''),
(21005, 'Metal_Two_Hand_Sword', 'Metal Two-Handed Sword', 4, 20, 10, 0, 95, 0, 0, 1, 1, 16514, 63, 2, 34, 3, 0, 0, 1, 3, '', '', ''),
(22514, 'Candy_Holder', 'Candy Holder', 11, 20, 10, 10, 0, 0, 0, 0, 0, 4294967295, 63, 2, 0, 0, 0, 0, 0, 0, '', '', ''),
-(22540, 'Runstone_Luxanima', 'Lux Anima Rune', 11, 2, 1, 100, 0, 0, 0, 0, 0, 4294967295, 63, 2, 0, 0, 0, 0, 0, 0, 'itemskill "RK_LUXANIMA",1;', '', ''); \ No newline at end of file
+(22540, 'Runstone_Luxanima', 'Lux Anima Rune', 11, 2, 1, 100, 0, 0, 0, 0, 0, 4294967295, 63, 2, 0, 0, 0, 0, 0, 0, 'itemskill "RK_LUXANIMA",1;', '', '');
diff --git a/sql-files/upgrades/2013-02-14--16-15.sql b/sql-files/upgrades/2013-02-14--16-15.sql
index 9afd034b1..9eac1a5e8 100644
--- a/sql-files/upgrades/2013-02-14--16-15.sql
+++ b/sql-files/upgrades/2013-02-14--16-15.sql
@@ -4,4 +4,4 @@ CREATE TABLE IF NOT EXISTS `sql_updates` (
`ignored` enum('Yes','No') NOT NULL DEFAULT 'No'
) ENGINE=MyISAM;
ALTER TABLE `skill` ADD COLUMN `flag` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
-INSERT INTO `sql_updates` (`timestamp`) VALUES (1360858500); \ No newline at end of file
+INSERT INTO `sql_updates` (`timestamp`) VALUES (1360858500);
diff --git a/sql-files/upgrades/2013-02-15--18-06.sql b/sql-files/upgrades/2013-02-15--18-06.sql
index 066693c70..836655095 100644
--- a/sql-files/upgrades/2013-02-15--18-06.sql
+++ b/sql-files/upgrades/2013-02-15--18-06.sql
@@ -1,3 +1,3 @@
#1360951560
ALTER TABLE `sql_updates` ADD PRIMARY KEY(`timestamp`);
-INSERT INTO `sql_updates` (`timestamp`) VALUES (1360951560); \ No newline at end of file
+INSERT INTO `sql_updates` (`timestamp`) VALUES (1360951560);
diff --git a/sql-files/upgrades/2013-03-05--01-05.sql b/sql-files/upgrades/2013-03-05--01-05.sql
index 4a1e23807..a280dc8dd 100644
--- a/sql-files/upgrades/2013-03-05--01-05.sql
+++ b/sql-files/upgrades/2013-03-05--01-05.sql
@@ -1,3 +1,3 @@
#1362445531
ALTER TABLE `login` ADD `character_slots` TINYINT( 3 ) UNSIGNED NOT NULL;
-INSERT INTO `sql_updates` (`timestamp`) VALUES (1362445531); \ No newline at end of file
+INSERT INTO `sql_updates` (`timestamp`) VALUES (1362445531);
diff --git a/sql-files/upgrades/2013-03-09--01-56.sql b/sql-files/upgrades/2013-03-09--01-56.sql
index 43811ee33..c35777283 100644
--- a/sql-files/upgrades/2013-03-09--01-56.sql
+++ b/sql-files/upgrades/2013-03-09--01-56.sql
@@ -1,4 +1,4 @@
#1362794218
ALTER TABLE `login` ADD COLUMN `pincode` varchar(4) NOT NULL DEFAULT '';
ALTER TABLE `login` ADD COLUMN `pincode_change` int(11) unsigned NOT NULL DEFAULT '0';
-INSERT INTO `sql_updates` (`timestamp`) VALUES (1362794218); \ No newline at end of file
+INSERT INTO `sql_updates` (`timestamp`) VALUES (1362794218);
diff --git a/sql-files/upgrades/2013-03-27--18-35.sql b/sql-files/upgrades/2013-03-27--18-35.sql
index fc50953c4..323aa2ace 100644
--- a/sql-files/upgrades/2013-03-27--18-35.sql
+++ b/sql-files/upgrades/2013-03-27--18-35.sql
@@ -1,3 +1,3 @@
#1364409316
ALTER TABLE `char` ADD COLUMN `slotchange` SMALLINT(3) unsigned NOT NULL default '0';
-INSERT INTO `sql_updates` (`timestamp`) VALUES (1364409316); \ No newline at end of file
+INSERT INTO `sql_updates` (`timestamp`) VALUES (1364409316);
diff --git a/sql-files/upgrades/2013-04-16--01-24.sql b/sql-files/upgrades/2013-04-16--01-24.sql
index 69672b368..a55eebe1a 100644
--- a/sql-files/upgrades/2013-04-16--01-24.sql
+++ b/sql-files/upgrades/2013-04-16--01-24.sql
@@ -1,3 +1,3 @@
#1366075474
#Info http://hercules.ws/board/topic/410-skill-script-command-updatefix/
-UPDATE `skill` SET `flag` = 0 WHERE `flag` = 4 AND `id` != 2535 AND `id` != 681; \ No newline at end of file
+UPDATE `skill` SET `flag` = 0 WHERE `flag` = 4 AND `id` != 2535 AND `id` != 681;
diff --git a/sql-files/upgrades/2013-04-16--02-15.sql b/sql-files/upgrades/2013-04-16--02-15.sql
index 771bd6ec2..3a0895204 100644
--- a/sql-files/upgrades/2013-04-16--02-15.sql
+++ b/sql-files/upgrades/2013-04-16--02-15.sql
@@ -1,4 +1,4 @@
#1366078541
ALTER TABLE `char` ADD `char_opt` INT( 11 ) UNSIGNED NOT NULL DEFAULT '0';
INSERT INTO `sql_updates` (`timestamp`) VALUES (1366075474);#for the previous that missed it..
-INSERT INTO `sql_updates` (`timestamp`) VALUES (1366078541); \ No newline at end of file
+INSERT INTO `sql_updates` (`timestamp`) VALUES (1366078541);
diff --git a/sql-files/upgrades/index.txt b/sql-files/upgrades/index.txt
index 54502d48b..984898b22 100644
--- a/sql-files/upgrades/index.txt
+++ b/sql-files/upgrades/index.txt
@@ -3,4 +3,4 @@
2013-03-05--01-05.sql
2013-03-06--00-00.sql
2013-03-09--01-56.sql
-2013-04-16--01-24.sql \ No newline at end of file
+2013-04-16--01-24.sql
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 100958358..0c120f99a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -17,4 +17,4 @@ add_subdirectory( login )
add_subdirectory( char )
add_subdirectory( map )
add_subdirectory( tool )
-add_subdirectory( plugins ) \ No newline at end of file
+add_subdirectory( plugins )
diff --git a/src/char/Makefile.in b/src/char/Makefile.in
index 0c4034a53..b2cee3f88 100644
--- a/src/char/Makefile.in
+++ b/src/char/Makefile.in
@@ -1,27 +1,29 @@
COMMON_H = $(shell ls ../common/*.h)
-
-MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o
-MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h
-MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar
-
-LIBCONFIG_OBJ = ../../3rdparty/libconfig/libconfig.o ../../3rdparty/libconfig/grammar.o \
- ../../3rdparty/libconfig/scanctx.o ../../3rdparty/libconfig/scanner.o ../../3rdparty/libconfig/strbuf.o
-LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/grammar.h \
- ../../3rdparty/libconfig/parsectx.h ../../3rdparty/libconfig/scanctx.h ../../3rdparty/libconfig/scanner.h \
- ../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h
-LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig
-
-COMMON_SQL_OBJ = ../common/obj_sql/sql.o
-COMMON_H = ../common/sql.h
-
-CHAR_OBJ = obj_sql/char.o obj_sql/inter.o obj_sql/int_party.o obj_sql/int_guild.o \
- obj_sql/int_storage.o obj_sql/int_pet.o obj_sql/int_homun.o obj_sql/int_mail.o obj_sql/int_auction.o obj_sql/int_quest.o obj_sql/int_mercenary.o obj_sql/int_elemental.o obj_sql/pincode.o
-CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h int_mail.h int_auction.h int_quest.h int_mercenary.h int_elemental.h pincode.h
+CONFIG_H = $(shell ls ../config/*.h ../config/*/*.h)
+
+MT19937AR_D = ../../3rdparty/mt19937ar
+MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
+MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
+MT19937AR_INCLUDE = -I$(MT19937AR_D)
+
+LIBCONFIG_D = ../../3rdparty/libconfig
+LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
+ scanner.o strbuf.o)
+LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
+ scanctx.h scanner.h strbuf.h wincompat.h)
+LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
+
+CHAR_OBJ = $(addprefix obj_sql/, char.o inter.o int_auction.o int_elemental.o \
+ int_guild.o int_homun.o int_mail.o int_mercenary.o int_party.o \
+ int_pet.o int_quest.o int_storage.o pincode.o)
+CHAR_H = char.h inter.h int_auction.h int_elemental.h int_guild.h int_homun.h \
+ int_mail.h int_mercenary.h int_party.h int_pet.h int_quest.h \
+ int_storage.h pincode.h
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
- CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ)
+ CHAR_SERVER_SQL_DEPENDS=$(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ)
else
CHAR_SERVER_SQL_DEPENDS=needs_mysql
endif
@@ -32,13 +34,11 @@ CC = @CC@
export CC
#####################################################################
-.PHONY : all char-server clean help
+.PHONY: all sql char-server clean help
-all: char-server
+all: sql
-char-server: $(CHAR_SERVER_SQL_DEPENDS)
- @echo " LD $@"
- @$(CC) @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
+sql: char-server
clean:
@echo " CLEAN char"
@@ -46,10 +46,10 @@ clean:
help:
@echo "possible targets are 'char-server' 'all' 'clean' 'help'"
- @echo "'char-server' - char server (SQL version)"
- @echo "'all' - builds all above targets"
- @echo "'clean' - cleans builds and objects"
- @echo "'help' - outputs this message"
+ @echo "'char-server' - char server"
+ @echo "'all' - builds all above targets"
+ @echo "'clean' - cleans builds and objects"
+ @echo "'help' - outputs this message"
#####################################################################
@@ -57,23 +57,37 @@ needs_mysql:
@echo "MySQL not found or disabled by the configure script"
@exit 1
+# object directories
+
obj_sql:
@echo " MKDIR obj_sql"
@-mkdir obj_sql
-obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H) $(LIBCONFIG_H)
+# executables
+
+char-server: $(CHAR_SERVER_SQL_DEPENDS)
+ @echo " LD $@"
+ @$(CC) @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
+
+# char object files
+
+obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql
@echo " CC $<"
@$(CC) @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
../common/obj_all/common.a:
+ @echo " MAKE $@"
@$(MAKE) -C ../common sql
../common/obj_sql/common_sql.a:
+ @echo " MAKE $@"
@$(MAKE) -C ../common sql
$(MT19937AR_OBJ):
- @$(MAKE) -C ../../3rdparty/mt19937ar
+ @echo " MAKE $@"
+ @$(MAKE) -C $(MT19937AR_D)
$(LIBCONFIG_OBJ):
- @$(MAKE) -C ../../3rdparty/libconfig
+ @echo " MAKE $@"
+ @$(MAKE) -C $(LIBCONFIG_D)
diff --git a/src/common/Makefile.in b/src/common/Makefile.in
index 313db8ccc..7efad9e45 100644
--- a/src/common/Makefile.in
+++ b/src/common/Makefile.in
@@ -1,30 +1,32 @@
-COMMON_OBJ = obj_all/core.o obj_all/socket.o obj_all/timer.o obj_all/db.o obj_all/HPM.o \
- obj_all/nullpo.o obj_all/malloc.o obj_all/showmsg.o obj_all/strlib.o obj_all/utils.o \
- obj_all/grfio.o obj_all/mapindex.o obj_all/ers.o obj_all/md5calc.o \
- obj_all/minicore.o obj_all/minisocket.o obj_all/minimalloc.o obj_all/random.o obj_all/des.o \
- obj_all/conf.o obj_all/thread.o obj_all/mutex.o obj_all/raconf.o obj_all/mempool.o obj_all/console.o \
- obj_all/miniconsole.o
-
-COMMON_H = $(shell ls ../common/*.h)
+MT19937AR_D = ../../3rdparty/mt19937ar
+MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
+MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
+MT19937AR_INCLUDE = -I$(MT19937AR_D)
+
+LIBCONFIG_D = ../../3rdparty/libconfig
+LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
+ scanner.o strbuf.o)
+LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
+ scanctx.h scanner.h strbuf.h wincompat.h)
+LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
+
+COMMON_OBJ = $(addprefix obj_all/, conf.o console.o core.o db.o des.o ers.o \
+ grfio.o HPM.o malloc.o mapindex.o md5calc.o mempool.o \
+ miniconsole.o minicore.o minimalloc.o minisocket.o mutex.o \
+ nullpo.o raconf.o random.o showmsg.o socket.o strlib.o thread.o \
+ timer.o utils.o)
+COMMON_H = atomic.h cbasetypes.h conf.h console.h core.h db.h des.h ers.h \
+ evdp.h grfio.h HPM.h HPMi.h malloc.h mapindex.h md5calc.h \
+ mempool.h mmo.h mutex.h netbuffer.h network.h nullpo.h raconf.h \
+ random.h showmsg.h socket.h spinlock.h sql.h strlib.h thread.h \
+ timer.h utils.h winapi.h
COMMON_SQL_OBJ = obj_sql/sql.o
COMMON_SQL_H = sql.h
-MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o
-MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h
-MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar
-
-LIBCONFIG_OBJ = ../../3rdparty/libconfig/libconfig.o ../../3rdparty/libconfig/grammar.o \
- ../../3rdparty/libconfig/scanctx.o ../../3rdparty/libconfig/scanner.o ../../3rdparty/libconfig/strbuf.o
-LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/grammar.h \
- ../../3rdparty/libconfig/parsectx.h ../../3rdparty/libconfig/scanctx.h ../../3rdparty/libconfig/scanner.h \
- ../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h
-LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig
-
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
- ALL_DEPENDS=sql
SQL_DEPENDS=common common_sql
else
SQL_DEPENDS=needs_mysql
@@ -36,9 +38,9 @@ CC = @CC@
export CC
#####################################################################
-.PHONY : all sql clean help
+.PHONY: all sql common common_sql clean help
-all: $(ALL_DEPENDS)
+all: sql
sql: $(SQL_DEPENDS)
@@ -59,6 +61,8 @@ needs_mysql:
@echo "MySQL not found or disabled by the configure script"
@exit 1
+# object directories
+
obj_all:
@echo " MKDIR obj_all"
@-mkdir obj_all
@@ -74,28 +78,29 @@ obj_all/common.a: $(COMMON_OBJ)
obj_sql/common_sql.a: $(COMMON_SQL_OBJ)
@echo " AR $@"
@@AR@ rcs obj_sql/common_sql.a $(COMMON_SQL_OBJ)
-
-common: obj_all $(COMMON_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common.a
+common: $(COMMON_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common.a
-common_sql: obj_sql $(COMMON_SQL_OBJ) obj_sql/common_sql.a
+common_sql: $(COMMON_SQL_OBJ) obj_sql/common_sql.a
-obj_all/%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H)
+obj_all/%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_all
@echo " CC $<"
@$(CC) @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
-obj_all/mini%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H)
+obj_all/mini%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_all
@echo " CC $<"
@$(CC) @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
-obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) $(LIBCONFIG_H)
+obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) $(CONFIG_H) $(LIBCONFIG_H) | obj_sql
@echo " CC $<"
@$(CC) @CFLAGS@ $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
$(MT19937AR_OBJ):
- @$(MAKE) -C ../../3rdparty/mt19937ar
+ @echo " MAKE $@"
+ @$(MAKE) -C $(MT19937AR_D)
$(LIBCONFIG_OBJ):
- @$(MAKE) -C ../../3rdparty/libconfig
+ @echo " MAKE $@"
+ @$(MAKE) -C $(LIBCONFIG_D)
diff --git a/src/common/thread.c b/src/common/thread.c
index 315b310b2..4d110f2dd 100644
--- a/src/common/thread.c
+++ b/src/common/thread.c
@@ -96,15 +96,11 @@ void rathread_final(){
// gets called whenever a thread terminated ..
-static void rat_thread_terminated( rAthread handle ){
-
- int id_backup = handle->myID;
-
- // Simply set all members to 0 (except the id)
- memset(handle, 0x00, sizeof(struct rAthread));
-
- handle->myID = id_backup; // done ;)
-
+static void rat_thread_terminated(rAthread handle) {
+ // Preserve handle->myID and handle->hThread, set everything else to its default value
+ handle->param = NULL;
+ handle->proc = NULL;
+ handle->prio = RAT_PRIO_NORMAL;
}//end: rat_thread_terminated()
#ifdef WIN32
diff --git a/src/login/Makefile.in b/src/login/Makefile.in
index 5014d667a..125f4fb7a 100644
--- a/src/login/Makefile.in
+++ b/src/login/Makefile.in
@@ -1,25 +1,26 @@
COMMON_H = $(shell ls ../common/*.h)
-
-MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o
-MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h
-MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar
-
-LIBCONFIG_OBJ = ../../3rdparty/libconfig/libconfig.o ../../3rdparty/libconfig/grammar.o \
- ../../3rdparty/libconfig/scanctx.o ../../3rdparty/libconfig/scanner.o ../../3rdparty/libconfig/strbuf.o
-LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/grammar.h \
- ../../3rdparty/libconfig/parsectx.h ../../3rdparty/libconfig/scanctx.h ../../3rdparty/libconfig/scanner.h \
- ../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h
-LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig
-
-LOGIN_OBJ = login.o
-LOGIN_SQL_OBJ = $(LOGIN_OBJ:%=obj_sql/%) \
- obj_sql/account_sql.o obj_sql/ipban_sql.o obj_sql/loginlog_sql.o
+CONFIG_H = $(shell ls ../config/*.h ../config/*/*.h)
+
+MT19937AR_D = ../../3rdparty/mt19937ar
+MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
+MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
+MT19937AR_INCLUDE = -I$(MT19937AR_D)
+
+LIBCONFIG_D = ../../3rdparty/libconfig
+LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
+ scanner.o strbuf.o)
+LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
+ scanctx.h scanner.h strbuf.h wincompat.h)
+LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
+
+LOGIN_OBJ = $(addprefix obj_sql/, account_sql.o ipban_sql.o login.o \
+ loginlog_sql.o)
LOGIN_H = login.h account.h ipban.h loginlog.h
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
- LOGIN_SERVER_SQL_DEPENDS=obj_sql $(LOGIN_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ)
+ LOGIN_SERVER_SQL_DEPENDS=$(LOGIN_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ)
else
LOGIN_SERVER_SQL_DEPENDS=needs_mysql
endif
@@ -30,22 +31,22 @@ CC = @CC@
export CC
#####################################################################
-.PHONY :all sql clean help
+.PHONY: all sql login-server clean help
all: sql
-sql: obj_sql login-server
+sql: login-server
clean:
@echo " CLEAN login"
@rm -rf *.o obj_sql ../../login-server@EXEEXT@
help:
- @echo "possible targets are 'sql' 'all' 'clean' 'help'"
- @echo "'sql' - login server (SQL version)"
- @echo "'all' - builds all above targets"
- @echo "'clean' - cleans builds and objects"
- @echo "'help' - outputs this message"
+ @echo "possible targets are 'login-server' 'all' 'clean' 'help'"
+ @echo "'login-server' - login server"
+ @echo "'all' - builds all above targets"
+ @echo "'clean' - cleans builds and objects"
+ @echo "'help' - outputs this message"
#####################################################################
@@ -59,28 +60,31 @@ obj_sql:
@echo " MKDIR obj_sql"
@-mkdir obj_sql
-#executables
+# executables
login-server: $(LOGIN_SERVER_SQL_DEPENDS)
@echo " LD $@"
- @$(CC) @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
-
+ @$(CC) @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
# login object files
-obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H)
+obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql
@echo " CC $<"
@$(CC) @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
../common/obj_all/common.a:
+ @echo " MAKE $@"
@$(MAKE) -C ../common sql
../common/obj_sql/common_sql.a:
+ @echo " MAKE $@"
@$(MAKE) -C ../common sql
$(MT19937AR_OBJ):
- @$(MAKE) -C ../../3rdparty/mt19937ar
+ @echo " MAKE $@"
+ @$(MAKE) -C $(MT19937AR_D)
$(LIBCONFIG_OBJ):
- @$(MAKE) -C ../../3rdparty/libconfig
+ @echo " MAKE $@"
+ @$(MAKE) -C $(LIBCONFIG_D)
diff --git a/src/map/Makefile.in b/src/map/Makefile.in
index 588d19eae..ed1b9a79d 100644
--- a/src/map/Makefile.in
+++ b/src/map/Makefile.in
@@ -1,43 +1,38 @@
COMMON_H = $(shell ls ../common/*.h)
-
-MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o
-MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h
-MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar
-
-LIBCONFIG_OBJ = ../../3rdparty/libconfig/libconfig.o ../../3rdparty/libconfig/grammar.o \
- ../../3rdparty/libconfig/scanctx.o ../../3rdparty/libconfig/scanner.o ../../3rdparty/libconfig/strbuf.o
-LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/grammar.h \
- ../../3rdparty/libconfig/parsectx.h ../../3rdparty/libconfig/scanctx.h ../../3rdparty/libconfig/scanner.h \
- ../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h
-LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig
-
-MAP_OBJ = map.o chrif.o clif.o pc.o status.o npc.o \
- npc_chat.o chat.o path.o itemdb.o mob.o script.o \
- storage.o skill.o atcommand.o battle.o battleground.o \
- intif.o trade.o party.o vending.o guild.o pet.o \
- log.o mail.o date.o unit.o homunculus.o mercenary.o quest.o instance.o \
- buyingstore.o searchstore.o duel.o pc_groups.o elemental.o irc-bot.o HPMmap.o
-MAP_SQL_OBJ = $(MAP_OBJ:%=obj_sql/%) \
- obj_sql/mapreg_sql.o
-MAP_H = map.h chrif.h clif.h pc.h status.h npc.h \
- chat.h itemdb.h mob.h script.h path.h \
- storage.h skill.h atcommand.h battle.h battleground.h \
- intif.h trade.h party.h vending.h guild.h pet.h \
- log.h mail.h date.h unit.h homunculus.h mercenary.h quest.h instance.h mapreg.h \
- buyingstore.h searchstore.h duel.h pc_groups.h \
- ../config/core.h ../config/renewal.h ../config/secure.h ../config/const.h \
- ../config/classes/general.h elemental.h packets.h packets_struct.h irc-bot.h HPMmap.h
+CONFIG_H = $(shell ls ../config/*.h ../config/*/*.h)
+
+MT19937AR_D = ../../3rdparty/mt19937ar
+MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
+MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
+MT19937AR_INCLUDE = -I$(MT19937AR_D)
+
+LIBCONFIG_D = ../../3rdparty/libconfig
+LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
+ scanner.o strbuf.o)
+LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
+ scanctx.h scanner.h strbuf.h wincompat.h)
+LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
+
+MAP_OBJ = $(addprefix obj_sql/, atcommand.o battle.o battleground.o \
+ buyingstore.o chat.o chrif.o clif.o date.o duel.o elemental.o \
+ guild.o homunculus.o HPMmap.o instance.o intif.o irc-bot.o itemdb.o \
+ log.o mail.o map.o mapreg_sql.o mercenary.o mob.o npc.o npc_chat.o \
+ party.o path.o pc.o pc_groups.o pet.o quest.o script.o \
+ searchstore.o skill.o status.o storage.o trade.o unit.o vending.o)
+MAP_H = atcommand.h battle.h battleground.h buyingstore.h chat.h chrif.h \
+ clif.h date.h duel.h elemental.h guild.h homunculus.h HPMmap.h \
+ instance.h intif.h irc-bot.h itemdb.h log.h mail.h map.h mapreg.h \
+ mercenary.h mob.h npc.h packets.h packets_struct.h party.h path.h \
+ pc.h pc_groups.h pet.h quest.h script.h searchstore.h skill.h \
+ status.h storage.h trade.h unit.h vending.h
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
- ALL_DEPENDS=txt sql
- SQL_DEPENDS=map-server
+ MAP_SERVER_SQL_DEPENDS=$(MAP_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ)
else
- ALL_TARGET=txt
- SQL_DEPENDS=needs_mysql
+ MAP_SERVER_SQL_DEPENDS=needs_mysql
endif
-TXT_DEPENDS=map-server
HAVE_PCRE=@HAVE_PCRE@
ifeq ($(HAVE_PCRE),yes)
@@ -52,29 +47,22 @@ CC = @CC@
export CC
#####################################################################
-.PHONY : all txt sql clean help
-
-all: $(ALL_DEPENDS)
+.PHONY: all sql map-server clean help
-txt: $(TXT_DEPENDS)
+all: sql
-sql: $(SQL_DEPENDS)
+sql: map-server
clean:
@echo " CLEAN map"
- @rm -rf *.o obj_txt obj_sql ../../map-server@EXEEXT@
+ @rm -rf *.o obj_sql ../../map-server@EXEEXT@
help:
-ifeq ($(HAVE_MYSQL),yes)
- @echo "possible targets are 'sql' 'txt' 'all' 'clean' 'help'"
- @echo "'sql' - map server (SQL version)"
-else
- @echo "possible targets are 'txt' 'all' 'clean' 'help'"
-endif
- @echo "'txt' - map server (TXT version)"
- @echo "'all' - builds all above targets"
- @echo "'clean' - cleans builds and objects"
- @echo "'help' - outputs this message"
+ @echo "possible targets are 'map-server' 'all' 'clean' 'help'"
+ @echo "'map-server' - map server"
+ @echo "'all' - builds all above targets"
+ @echo "'clean' - cleans builds and objects"
+ @echo "'help' - outputs this message"
#####################################################################
@@ -83,9 +71,6 @@ needs_mysql:
@exit 1
# object directories
-obj_txt:
- @echo " MKDIR obj_txt"
- @-mkdir obj_txt
obj_sql:
@echo " MKDIR obj_sql"
@@ -93,25 +78,29 @@ obj_sql:
# executables
-map-server: obj_sql $(MAP_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a
+map-server: $(MAP_SERVER_SQL_DEPENDS)
@echo " LD $@"
- @$(CC) @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@
+ @$(CC) @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@
# map object files
-obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H)
+obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql
@echo " CC $<"
@$(CC) @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
../common/obj_all/common.a:
+ @echo " MAKE $@"
@$(MAKE) -C ../common sql
../common/obj_sql/common_sql.a:
+ @echo " MAKE $@"
@$(MAKE) -C ../common sql
$(MT19937AR_OBJ):
- @$(MAKE) -C ../../3rdparty/mt19937ar
+ @echo " MAKE $@"
+ @$(MAKE) -C $(MT19937AR_D)
$(LIBCONFIG_OBJ):
- @$(MAKE) -C ../../3rdparty/libconfig
+ @echo " MAKE $@"
+ @$(MAKE) -C $(LIBCONFIG_D)
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index df97740e1..2466c2cca 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -1157,12 +1157,12 @@ ACMD(item)
item_id = item_data->nameid;
get_count = number;
//Check if it's stackable.
- if (!itemdb_isstackable2(item_data))
+ if (!itemdb->isstackable2(item_data))
get_count = 1;
for (i = 0; i < number; i += get_count) {
// if not pet egg
- if (!pet_create_egg(sd, item_id)) {
+ if (!pet->create_egg(sd, item_id)) {
memset(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = item_id;
item_tmp.identify = 1;
@@ -1453,11 +1453,11 @@ ACMD(help) {
// parameter: '0' - everyone, 'id' - only those attacking someone with that id
static int atcommand_stopattack(struct block_list *bl,va_list ap)
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
int id = va_arg(ap, int);
if (ud && ud->attacktimer != INVALID_TIMER && (!id || id == ud->target))
{
- unit_stop_attack(bl);
+ unit->stop_attack(bl);
return 1;
}
return 0;
@@ -1929,8 +1929,8 @@ ACMD(monster)
return false;
}
- if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
- mob_id = mobdb_checkid(atoi(monster));
+ if ((mob_id = mob->db_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number)
+ mob_id = mob->db_checkid(atoi(monster));
if (mob_id == 0) {
clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
@@ -1966,7 +1966,7 @@ ACMD(monster)
range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around)
for (i = 0; i < number; i++) {
iMap->search_freecell(&sd->bl, 0, &mx, &my, range, range, 0);
- k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
+ k = mob->once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, eventname, size, AI_NONE);
count += (k != 0) ? 1 : 0;
}
@@ -2138,7 +2138,7 @@ ACMD(produce)
item_id = item_data->nameid;
- if (itemdb_isequip2(item_data)) {
+ if (itemdb->isequip2(item_data)) {
int flag = 0;
if (attribute < MIN_ATTRIBUTE || attribute > MAX_ATTRIBUTE)
attribute = ATTRIBUTE_NORMAL;
@@ -2553,21 +2553,21 @@ ACMD(makeegg)
if ((item_data = itemdb->search_name(message)) != NULL) // for egg name
id = item_data->nameid;
else
- if ((id = mobdb_searchname(message)) != 0) // for monster name
+ if ((id = mob->db_searchname(message)) != 0) // for monster name
;
else
id = atoi(message);
- pet_id = search_petDB_index(id, PET_CLASS);
+ pet_id = pet->search_petDB_index(id, PET_CLASS);
if (pet_id < 0)
- pet_id = search_petDB_index(id, PET_EGG);
+ pet_id = pet->search_petDB_index(id, PET_EGG);
if (pet_id >= 0) {
- sd->catch_target_class = pet_db[pet_id].class_;
+ sd->catch_target_class = pet->db[pet_id].class_;
intif->create_pet(
sd->status.account_id, sd->status.char_id,
- (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
- (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
- 100, 0, 1, pet_db[pet_id].jname);
+ (short)pet->db[pet_id].class_, (short)mob->db(pet->db[pet_id].class_)->lv,
+ (short)pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate,
+ 100, 0, 1, pet->db[pet_id].jname);
} else {
clif->message(fd, msg_txt(180)); // The monster/egg name/id doesn't exist.
return false;
@@ -2623,7 +2623,7 @@ ACMD(petfriendly)
return false;
}
- pet_set_intimate(pd, friendly);
+ pet->set_intimate(pd, friendly);
clif->send_petstatus(sd);
clif->message(fd, msg_txt(182)); // Pet intimacy changed.
return true;
@@ -3595,8 +3595,8 @@ ACMD(reloaditemdb)
*------------------------------------------*/
ACMD(reloadmobdb) {
nullpo_retr(-1, sd);
- mob_reload();
- read_petdb();
+ mob->reload();
+ pet->read_db();
homun->reload();
mercenary->read_db();
mercenary->read_skilldb();
@@ -3689,7 +3689,7 @@ ACMD(reloadbattleconf)
|| prev_config.job_exp_rate != battle_config.job_exp_rate
)
{ // Exp or Drop rates changed.
- mob_reload(); //Needed as well so rate changes take effect.
+ mob->reload(); //Needed as well so rate changes take effect.
chrif->ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
}
clif->message(fd, msg_txt(255));
@@ -3749,7 +3749,7 @@ ACMD(reloadscript)
flush_fifos();
iMap->reloadnpc(true); // reload config files seeking for npcs
script->reload();
- npc_reload();
+ npc->reload();
clif->message(fd, msg_txt(100)); // Scripts have been reloaded.
@@ -4237,7 +4237,7 @@ ACMD(tonpc)
return false;
}
- if ((nd = npc_name2id(npcname)) != NULL) {
+ if ((nd = npc->name2id(npcname)) != NULL) {
if (pc->setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == 0)
clif->message(fd, msg_txt(0)); // Warped.
else
@@ -4265,8 +4265,8 @@ ACMD(shownpc)
return false;
}
- if (npc_name2id(NPCname) != NULL) {
- npc_enable(NPCname, 1);
+ if (npc->name2id(NPCname) != NULL) {
+ npc->enable(NPCname, 1);
clif->message(fd, msg_txt(110)); // Npc Enabled.
} else {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
@@ -4291,12 +4291,12 @@ ACMD(hidenpc)
return false;
}
- if (npc_name2id(NPCname) == NULL) {
+ if (npc->name2id(NPCname) == NULL) {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
return false;
}
- npc_enable(NPCname, 0);
+ npc->enable(NPCname, 0);
clif->message(fd, msg_txt(112)); // Npc Disabled.
return true;
}
@@ -4318,9 +4318,9 @@ ACMD(loadnpc)
fclose(fp);
// add to list of script sources and run it
- npc_addsrcfile(message);
- npc_parsesrcfile(message,true);
- npc_read_event_script();
+ npc->addsrcfile(message);
+ npc->parsesrcfile(message,true);
+ npc->read_event_script();
clif->message(fd, msg_txt(262));
@@ -4340,14 +4340,14 @@ ACMD(unloadnpc)
return false;
}
- if ((nd = npc_name2id(NPCname)) == NULL) {
+ if ((nd = npc->name2id(NPCname)) == NULL) {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
return false;
}
- npc_unload_duplicates(nd);
- npc_unload(nd,true);
- npc_read_event_script();
+ npc->unload_duplicates(nd);
+ npc->unload(nd,true);
+ npc->read_event_script();
clif->message(fd, msg_txt(112)); // Npc Disabled.
return true;
}
@@ -4744,12 +4744,12 @@ ACMD(disguise)
if ((id = atoi(message)) > 0)
{ //Acquired an ID
- if (!mobdb_checkid(id) && !npcdb_checkid(id))
+ if (!mob->db_checkid(id) && !npcdb_checkid(id))
id = 0; //Invalid id for either mobs or npcs.
} else { //Acquired a Name
- if ((id = mobdb_searchname(message)) == 0)
+ if ((id = mob->db_searchname(message)) == 0)
{
- struct npc_data* nd = npc_name2id(message);
+ struct npc_data* nd = npc->name2id(message);
if (nd != NULL)
id = nd->class_;
}
@@ -4788,10 +4788,10 @@ ACMD(disguiseall)
return false;
}
- if ((mob_id = mobdb_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
+ if ((mob_id = mob->db_searchname(message)) == 0) // check name first (to avoid possible name begining by a number)
mob_id = atoi(message);
- if (!mobdb_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
+ if (!mob->db_checkid(mob_id) && !npcdb_checkid(mob_id)) { //if mob or npc...
clif->message(fd, msg_txt(123)); // Monster/NPC name/id not found.
return false;
}
@@ -4824,11 +4824,11 @@ ACMD(disguiseguild)
}
if( (id = atoi(monster)) > 0 ) {
- if( !mobdb_checkid(id) && !npcdb_checkid(id) )
+ if( !mob->db_checkid(id) && !npcdb_checkid(id) )
id = 0;
} else {
- if( (id = mobdb_searchname(monster)) == 0 ) {
- struct npc_data* nd = npc_name2id(monster);
+ if( (id = mob->db_searchname(monster)) == 0 ) {
+ struct npc_data* nd = npc->name2id(monster);
if( nd != NULL )
id = nd->class_;
}
@@ -5116,7 +5116,7 @@ ACMD(npcmove)
return false;
}
- if ((nd = npc_name2id(atcmd_player_name)) == NULL)
+ if ((nd = npc->name2id(atcmd_player_name)) == NULL)
{
clif->message(fd, msg_txt(111)); // This NPC doesn't exist.
return false;
@@ -5165,7 +5165,7 @@ ACMD(addwarp)
return false;
}
- nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
+ nd = npc->add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
if( nd == NULL )
return false;
@@ -5429,9 +5429,9 @@ ACMD(useskill)
bl = &sd->bl;
if (skill->get_inf(skill_id)&INF_GROUND_SKILL)
- unit_skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
+ unit->skilluse_pos(bl, pl_sd->bl.x, pl_sd->bl.y, skill_id, skill_lv);
else
- unit_skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
+ unit->skilluse_id(bl, pl_sd->bl.id, skill_id, skill_lv);
return true;
}
@@ -6091,14 +6091,14 @@ ACMD(mobsearch)
}
if ((mob_id = atoi(mob_name)) == 0)
- mob_id = mobdb_searchname(mob_name);
- if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
+ mob_id = mob->db_searchname(mob_name);
+ if(mob_id > 0 && mob->db_checkid(mob_id) == 0){
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1219),mob_name); // Invalid mob ID %s!
clif->message(fd, atcmd_output);
return false;
}
- if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
- strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
+ if(mob_id == atoi(mob_name) && mob->db(mob_id)->jname)
+ strcpy(mob_name,mob->db(mob_id)->jname); // --ja--
// strcpy(mob_name,mob_db(mob_id)->name); // --en--
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1220), mob_name, mapindex_id2name(sd->mapindex)); // Mob Search... %s %s
@@ -6194,7 +6194,7 @@ ACMD(npctalk)
}
}
- if (!(nd = npc_name2id(name))) {
+ if (!(nd = npc->name2id(name))) {
clif->message(fd, msg_txt(111)); // This NPC doesn't exist
return false;
}
@@ -6355,23 +6355,23 @@ ACMD(summon)
duration =60;
if ((mob_id = atoi(name)) == 0)
- mob_id = mobdb_searchname(name);
- if(mob_id == 0 || mobdb_checkid(mob_id) == 0)
+ mob_id = mob->db_searchname(name);
+ if(mob_id == 0 || mob->db_checkid(mob_id) == 0)
{
clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
return false;
}
- md = mob_once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(&sd->bl, sd->bl.m, -1, -1, "--ja--", mob_id, "", SZ_SMALL, AI_NONE);
if(!md)
return false;
md->master_id=sd->bl.id;
md->special_state.ai=1;
- md->deletetimer=iTimer->add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
+ md->deletetimer=iTimer->add_timer(tick+(duration*60000),mob->timer_delete,md->bl.id,0);
clif->specialeffect(&md->bl,344,AREA);
- mob_spawn(md);
+ mob->spawn(md);
sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
clif->skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
clif->message(fd, msg_txt(39)); // All monster summoned!
@@ -6643,7 +6643,7 @@ ACMD(mobinfo)
unsigned char melement[10][8] = {"Neutral", "Water", "Earth", "Fire", "Wind", "Poison", "Holy", "Dark", "Ghost", "Undead"};
char atcmd_output2[CHAT_SIZE_MAX];
struct item_data *item_data;
- struct mob_db *mob, *mob_array[MAX_SEARCH];
+ struct mob_db *monster, *mob_array[MAX_SEARCH];
int count;
int i, j, k;
@@ -6656,11 +6656,11 @@ ACMD(mobinfo)
}
// If monster identifier/name argument is a name
- if ((i = mobdb_checkid(atoi(message)))) {
- mob_array[0] = mob_db(i);
+ if ((i = mob->db_checkid(atoi(message)))) {
+ mob_array[0] = mob->db(i);
count = 1;
} else
- count = mobdb_searchname_array(mob_array, MAX_SEARCH, message, 0);
+ count = mob->db_searchname_array(mob_array, MAX_SEARCH, message, 0);
if (!count) {
clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
@@ -6676,37 +6676,37 @@ ACMD(mobinfo)
for (k = 0; k < count; k++) {
unsigned int job_exp, base_exp;
- mob = mob_array[k];
+ monster = mob_array[k];
- job_exp = mob->job_exp;
- base_exp = mob->base_exp;
+ job_exp = monster->job_exp;
+ base_exp = monster->base_exp;
#ifdef RENEWAL_EXP
if( battle_config.atcommand_mobinfo_type ) {
- base_exp = base_exp * pc->level_penalty_mod(mob->lv - sd->status.base_level, mob->status.race, mob->status.mode, 1) / 100;
- job_exp = job_exp * pc->level_penalty_mod(mob->lv - sd->status.base_level, mob->status.race, mob->status.mode, 1) / 100;
+ base_exp = base_exp * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 1) / 100;
+ job_exp = job_exp * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 1) / 100;
}
#endif
// stats
- if (mob->mexp)
- sprintf(atcmd_output, msg_txt(1240), mob->name, mob->jname, mob->sprite, mob->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
+ if (monster->mexp)
+ sprintf(atcmd_output, msg_txt(1240), monster->name, monster->jname, monster->sprite, monster->vd.class_); // MVP Monster: '%s'/'%s'/'%s' (%d)
else
- sprintf(atcmd_output, msg_txt(1241), mob->name, mob->jname, mob->sprite, mob->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
+ sprintf(atcmd_output, msg_txt(1241), monster->name, monster->jname, monster->sprite, monster->vd.class_); // Monster: '%s'/'%s'/'%s' (%d)
clif->message(fd, atcmd_output);
- sprintf(atcmd_output, msg_txt(1242), mob->lv, mob->status.max_hp, base_exp, job_exp,MOB_HIT(mob), MOB_FLEE(mob)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
+ sprintf(atcmd_output, msg_txt(1242), monster->lv, monster->status.max_hp, base_exp, job_exp, MOB_HIT(monster), MOB_FLEE(monster)); // Lv:%d HP:%d Base EXP:%u Job EXP:%u HIT:%d FLEE:%d
clif->message(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(1243), // DEF:%d MDEF:%d STR:%d AGI:%d VIT:%d INT:%d DEX:%d LUK:%d
- mob->status.def, mob->status.mdef,mob->status.str, mob->status.agi,
- mob->status.vit, mob->status.int_, mob->status.dex, mob->status.luk);
+ monster->status.def, monster->status.mdef, monster->status.str, monster->status.agi,
+ monster->status.vit, monster->status.int_, monster->status.dex, monster->status.luk);
clif->message(fd, atcmd_output);
sprintf(atcmd_output, msg_txt(1244), // ATK:%d~%d Range:%d~%d~%d Size:%s Race: %s Element: %s (Lv:%d)
- mob->status.rhw.atk, mob->status.rhw.atk2, mob->status.rhw.range,
- mob->range2 , mob->range3, msize[mob->status.size],
- mrace[mob->status.race], melement[mob->status.def_ele], mob->status.ele_lv);
+ monster->status.rhw.atk, monster->status.rhw.atk2, monster->status.rhw.range,
+ monster->range2 , monster->range3, msize[monster->status.size],
+ mrace[monster->status.race], melement[monster->status.def_ele], monster->status.ele_lv);
clif->message(fd, atcmd_output);
// drops
@@ -6716,14 +6716,14 @@ ACMD(mobinfo)
for (i = 0; i < MAX_MOB_DROP; i++) {
int droprate;
- if (mob->dropitem[i].nameid <= 0 || mob->dropitem[i].p < 1 || (item_data = itemdb->exists(mob->dropitem[i].nameid)) == NULL)
+ if (monster->dropitem[i].nameid <= 0 || monster->dropitem[i].p < 1 || (item_data = itemdb->exists(monster->dropitem[i].nameid)) == NULL)
continue;
- droprate = mob->dropitem[i].p;
+ droprate = monster->dropitem[i].p;
#ifdef RENEWAL_DROP
if( battle_config.atcommand_mobinfo_type ) {
- droprate = droprate * pc->level_penalty_mod(mob->lv - sd->status.base_level, mob->status.race, mob->status.mode, 2) / 100;
+ droprate = droprate * pc->level_penalty_mod(monster->lv - sd->status.base_level, monster->status.race, monster->status.mode, 2) / 100;
if (droprate <= 0 && !battle_config.drop_rate0item)
droprate = 1;
@@ -6748,21 +6748,21 @@ ACMD(mobinfo)
else if (j % 3 != 0)
clif->message(fd, atcmd_output);
// mvp
- if (mob->mexp) {
- sprintf(atcmd_output, msg_txt(1247), mob->mexp); // MVP Bonus EXP:%u
+ if (monster->mexp) {
+ sprintf(atcmd_output, msg_txt(1247), monster->mexp); // MVP Bonus EXP:%u
clif->message(fd, atcmd_output);
strcpy(atcmd_output, msg_txt(1248)); // MVP Items:
j = 0;
for (i = 0; i < MAX_MVP_DROP; i++) {
- if (mob->mvpitem[i].nameid <= 0 || (item_data = itemdb->exists(mob->mvpitem[i].nameid)) == NULL)
+ if (monster->mvpitem[i].nameid <= 0 || (item_data = itemdb->exists(monster->mvpitem[i].nameid)) == NULL)
continue;
- if (mob->mvpitem[i].p > 0) {
+ if (monster->mvpitem[i].p > 0) {
j++;
if (j == 1)
- sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
+ sprintf(atcmd_output2, " %s %02.02f%%", item_data->jname, (float)monster->mvpitem[i].p / 100);
else
- sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)mob->mvpitem[i].p / 100);
+ sprintf(atcmd_output2, " - %s %02.02f%%", item_data->jname, (float)monster->mvpitem[i].p / 100);
strcat(atcmd_output, atcmd_output2);
}
}
@@ -6792,20 +6792,20 @@ ACMD(showmobs)
return false;
if((mob_id = atoi(mob_name)) == 0)
- mob_id = mobdb_searchname(mob_name);
- if(mob_id > 0 && mobdb_checkid(mob_id) == 0){
+ mob_id = mob->db_searchname(mob_name);
+ if(mob_id > 0 && mob->db_checkid(mob_id) == 0){
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1250),mob_name); // Invalid mob id %s!
clif->message(fd, atcmd_output);
return true;
}
- if(mob_db(mob_id)->status.mode&MD_BOSS && !pc->has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
+ if(mob->db(mob_id)->status.mode&MD_BOSS && !pc->has_permission(sd, PC_PERM_SHOW_BOSS)){ // If player group does not have access to boss mobs.
clif->message(fd, msg_txt(1251)); // Can't show boss mobs!
return true;
}
- if(mob_id == atoi(mob_name) && mob_db(mob_id)->jname)
- strcpy(mob_name,mob_db(mob_id)->jname); // --ja--
+ if(mob_id == atoi(mob_name) && mob->db(mob_id)->jname)
+ strcpy(mob_name,mob->db(mob_id)->jname); // --ja--
//strcpy(mob_name,mob_db(mob_id)->name); // --en--
snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1252), // Mob Search... %s %s
@@ -7222,7 +7222,7 @@ ACMD(iteminfo)
item_data = item_array[i];
sprintf(atcmd_output, msg_txt(1277), // Item: '%s'/'%s'[%d] (%d) Type: %s | Extra Effect: %s
item_data->name,item_data->jname,item_data->slot,item_data->nameid,
- itemdb_typename(item_data->type),
+ itemdb->typename(item_data->type),
(item_data->script==NULL)? msg_txt(1278) : msg_txt(1279) // None / With script
);
clif->message(fd, atcmd_output);
@@ -7283,7 +7283,7 @@ ACMD(whodrops)
for (j=0; j < MAX_SEARCH && item_data->mob[j].chance > 0; j++)
{
- sprintf(atcmd_output, "- %s (%02.02f%%)", mob_db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
+ sprintf(atcmd_output, "- %s (%02.02f%%)", mob->db(item_data->mob[j].id)->jname, item_data->mob[j].chance/100.);
clif->message(fd, atcmd_output);
}
}
@@ -7293,7 +7293,7 @@ ACMD(whodrops)
ACMD(whereis)
{
- struct mob_db *mob, *mob_array[MAX_SEARCH];
+ struct mob_db *monster, *mob_array[MAX_SEARCH];
int count;
int i, j, k;
@@ -7303,12 +7303,12 @@ ACMD(whereis)
}
// If monster identifier/name argument is a name
- if ((i = mobdb_checkid(atoi(message))))
+ if ((i = mob->db_checkid(atoi(message))))
{
- mob_array[0] = mob_db(i);
+ mob_array[0] = mob->db(i);
count = 1;
} else
- count = mobdb_searchname_array(mob_array, MAX_SEARCH, message, 0);
+ count = mob->db_searchname_array(mob_array, MAX_SEARCH, message, 0);
if (!count) {
clif->message(fd, msg_txt(40)); // Invalid monster ID or name.
@@ -7321,15 +7321,15 @@ ACMD(whereis)
count = MAX_SEARCH;
}
for (k = 0; k < count; k++) {
- mob = mob_array[k];
- snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), mob->jname); // %s spawns in:
+ monster = mob_array[k];
+ snprintf(atcmd_output, sizeof atcmd_output, msg_txt(1289), monster->jname); // %s spawns in:
clif->message(fd, atcmd_output);
- for (i = 0; i < ARRAYLENGTH(mob->spawn) && mob->spawn[i].qty; i++)
+ for (i = 0; i < ARRAYLENGTH(monster->spawn) && monster->spawn[i].qty; i++)
{
- j = iMap->mapindex2mapid(mob->spawn[i].mapindex);
+ j = iMap->mapindex2mapid(monster->spawn[i].mapindex);
if (j < 0) continue;
- snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, mob->spawn[i].qty);
+ snprintf(atcmd_output, sizeof atcmd_output, "%s (%d)", map[j].name, monster->spawn[i].qty);
clif->message(fd, atcmd_output);
}
if (i == 0)
@@ -7979,7 +7979,7 @@ ACMD(clone)
}
master = sd->bl.id;
if (battle_config.atc_slave_clone_limit
- && mob_countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
+ && mob->countslave(&sd->bl) >= battle_config.atc_slave_clone_limit) {
clif->message(fd, msg_txt(127)); // You've reached your slave clones limit.
return true;
}
@@ -7995,7 +7995,7 @@ ACMD(clone)
y = sd->bl.y;
}
- if((x = mob_clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
+ if((x = mob->clone_spawn(pl_sd, sd->bl.m, x, y, "", master, 0, flag?1:0, 0)) > 0) {
clif->message(fd, msg_txt(128+flag*2)); // Evil Clone spawned. Clone spawned. Slave clone spawned.
return true;
}
@@ -8622,7 +8622,7 @@ ACMD(set) {
data->u.str = pc->readregstr(sd, script->add_str(reg));
break;
case '$':
- data->u.str = mapreg_readregstr(script->add_str(reg));
+ data->u.str = mapreg->readregstr(script->add_str(reg));
break;
case '#':
if( reg[1] == '#' )
@@ -8651,7 +8651,7 @@ ACMD(set) {
data->u.num = pc->readreg(sd, script->add_str(reg));
break;
case '$':
- data->u.num = mapreg_readreg(script->add_str(reg));
+ data->u.num = mapreg->readreg(script->add_str(reg));
break;
case '#':
if( reg[1] == '#' )
@@ -8689,7 +8689,7 @@ ACMD(set) {
return true;
}
ACMD(reloadquestdb) {
- do_reload_quest();
+ quest->reload();
clif->message(fd, msg_txt(1377)); // Quest database has been reloaded.
return true;
}
@@ -8759,7 +8759,7 @@ ACMD(unloadnpcfile) {
return false;
}
- if( npc_unloadfile(message) )
+ if( npc->unloadfile(message) )
clif->message(fd, msg_txt(1386)); // File unloaded. Be aware that mapflags and monsters spawned directly are not removed.
else {
clif->message(fd, msg_txt(1387)); // File not found.
@@ -10018,7 +10018,7 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
if( binding->log ) /* log only if this command should be logged [Ind/Hercules] */
logs->atcommand(sd, atcmd_msg);
- npc_do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
+ npc->do_atcmd_event((invokeFlag ? sd : ssd), command, params, binding->npc_event);
return true;
}
}
diff --git a/src/map/battle.c b/src/map/battle.c
index f64700f0c..85fa2cb98 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -50,7 +50,7 @@ int battle_getcurrentskill(struct block_list *bl) { //Returns the current/last s
return su->group?su->group->skill_id:0;
}
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
return ud?ud->skill_id:0;
}
@@ -74,7 +74,7 @@ int battle_gettargeted_sub(struct block_list *bl, va_list ap) {
if (*c >= 24)
return 0;
- if ( !(ud = unit_bl2ud(bl)) )
+ if ( !(ud = unit->bl2ud(bl)) )
return 0;
if (ud->target == target_id || ud->skilltarget == target_id) {
@@ -1250,7 +1250,7 @@ int64 battle_calc_defense(int attack_type, struct block_list *src, struct block_
if( battle_config.vit_penalty_type && battle_config.vit_penalty_target&target->type ) {
unsigned char target_count; //256 max targets should be a sane max
- target_count = unit_counttargeted(target);
+ target_count = unit->counttargeted(target);
if(target_count >= battle_config.vit_penalty_count) {
if(battle_config.vit_penalty_type == 1) {
if( !tsc || !tsc->data[SC_STEELBODY] )
@@ -2337,7 +2337,7 @@ int battle_calc_skillratio(int attack_type, struct block_list *src, struct block
int hp = status_get_max_hp(src) * (10 + 2 * skill_lv) / 100,
sp = status_get_max_sp(src) * (6 + skill_lv) / 100;
if( sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == SR_FALLENEMPIRE ) // ATK [((Caster consumed HP + SP) / 2) x Caster Base Level / 100] %
- skillratio += -100 + hp+sp / 2;
+ skillratio += -100 + (hp+sp) / 2;
else
skillratio += -100 + (hp+sp) / 4;
RE_LVL_DMOD(100);
@@ -2553,7 +2553,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if( !damage )
return 0;
- if( battle_config.ksprotection && mob_ksprotected(src, bl) )
+ if( battle_config.ksprotection && mob->ksprotected(src, bl) )
return 0;
if( iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKMAELSTROM) && skill->get_type(skill_id) != BF_MISC
&& skill->get_casttype(skill_id) == CAST_GROUND )
@@ -2664,7 +2664,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
delay = 200;
else
delay = 100;
- unit_set_walkdelay(bl, iTimer->gettick(), delay, 1);
+ unit->set_walkdelay(bl, iTimer->gettick(), delay, 1);
if(sc->data[SC_CR_SHRINK] && rnd()%100<5*sce->val1)
skill->blown(bl,src,skill->get_blewcount(CR_SHRINK,1),-1,0);
@@ -2834,14 +2834,14 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if (src->type == BL_MOB) {
int i;
if (sc->data[SC_MANU_DEF])
- for (i=0;ARRAYLENGTH(mob_manuk)>i;i++)
- if (mob_manuk[i]==((TBL_MOB*)src)->class_) {
+ for (i=0;ARRAYLENGTH(mob->manuk)>i;i++)
+ if (mob->manuk[i]==((TBL_MOB*)src)->class_) {
damage -= damage * sc->data[SC_MANU_DEF]->val1 / 100;
break;
}
if (sc->data[SC_SPL_DEF])
- for (i=0;ARRAYLENGTH(mob_splendide)>i;i++)
- if (mob_splendide[i]==((TBL_MOB*)src)->class_) {
+ for (i=0;ARRAYLENGTH(mob->splendide)>i;i++)
+ if (mob->splendide[i]==((TBL_MOB*)src)->class_) {
damage -= damage * sc->data[SC_SPL_DEF]->val1 / 100;
break;
}
@@ -2931,9 +2931,9 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
int dx[8]={0,-1,-1,-1,0,1,1,1};
int dy[8]={1,1,0,-1,-1,-1,0,1};
uint8 dir = iMap->calc_dir(bl, src->x, src->y);
- if( unit_movepos(bl, src->x-dx[dir], src->y-dy[dir], 1, 1) ) {
+ if( unit->movepos(bl, src->x-dx[dir], src->y-dy[dir], 1, 1) ) {
clif->slide(bl,src->x-dx[dir],src->y-dy[dir]);
- unit_setdir(bl, dir);
+ unit->setdir(bl, dir);
}
d->dmg_lv = ATK_DEF;
status_change_end(bl, SC_LIGHTNINGWALK, INVALID_TIMER);
@@ -2991,16 +2991,16 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if ( ((sce=sc->data[SC_MANU_ATK]) && (flag&BF_WEAPON)) ||
((sce=sc->data[SC_MANU_MATK]) && (flag&BF_MAGIC))
)
- for (i=0;ARRAYLENGTH(mob_manuk)>i;i++)
- if (((TBL_MOB*)bl)->class_==mob_manuk[i]) {
+ for (i=0;ARRAYLENGTH(mob->manuk)>i;i++)
+ if (((TBL_MOB*)bl)->class_==mob->manuk[i]) {
damage += damage * sce->val1 / 100;
break;
}
if ( ((sce=sc->data[SC_SPL_ATK]) && (flag&BF_WEAPON)) ||
((sce=sc->data[SC_SPL_MATK]) && (flag&BF_MAGIC))
)
- for (i=0;ARRAYLENGTH(mob_splendide)>i;i++)
- if (((TBL_MOB*)bl)->class_==mob_splendide[i]) {
+ for (i=0;ARRAYLENGTH(mob->splendide)>i;i++)
+ if (((TBL_MOB*)bl)->class_==mob->splendide[i]) {
damage += damage * sce->val1 / 100;
break;
}
@@ -3052,9 +3052,9 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if( bl->type == BL_MOB && !iStatus->isdead(bl) && src != bl) {
if (damage > 0 )
- mobskill_event((TBL_MOB*)bl,src,iTimer->gettick(),flag);
+ mob->skill_event((TBL_MOB*)bl,src,iTimer->gettick(),flag);
if (skill_id)
- mobskill_event((TBL_MOB*)bl,src,iTimer->gettick(),MSC_SKILLUSED|(skill_id<<16));
+ mob->skill_event((TBL_MOB*)bl,src,iTimer->gettick(),MSC_SKILLUSED|(skill_id<<16));
}
if( sd ) {
if( pc_ismadogear(sd) && rnd()%100 < 50 ) {
@@ -3837,7 +3837,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
if(battle_config.agi_penalty_type && battle_config.agi_penalty_target&target->type) {
unsigned char attacker_count; //256 max targets should be a sane max
- attacker_count = unit_counttargeted(target);
+ attacker_count = unit->counttargeted(target);
if(attacker_count >= battle_config.agi_penalty_count)
{
if (battle_config.agi_penalty_type == 1)
@@ -4303,7 +4303,7 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list
if(battle_config.agi_penalty_type && battle_config.agi_penalty_target&target->type) {
unsigned char attacker_count; //256 max targets should be a sane max
- attacker_count = unit_counttargeted(target);
+ attacker_count = unit->counttargeted(target);
if(attacker_count >= battle_config.agi_penalty_count) {
if (battle_config.agi_penalty_type == 1)
flee = (flee * (100 - (attacker_count - (battle_config.agi_penalty_count - 1))*battle_config.agi_penalty_num))/100;
@@ -5199,7 +5199,7 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i
int ratio = (status_get_hp(src) / 100) * sc->data[SC_CRESCENTELBOW]->val1 * iStatus->get_lv(bl) / 125;
if (ratio > 5000) ratio = 5000; // Maximum of 5000% ATK
rdamage = rdamage * ratio / 100 + (*dmg) * (10 + sc->data[SC_CRESCENTELBOW]->val1 * 20 / 10) / 10;
- skill->blown(bl, src, skill->get_blewcount(SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1), unit_getdir(src), 0);
+ skill->blown(bl, src, skill->get_blewcount(SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1), unit->getdir(src), 0);
clif->skill_damage(bl, src, iTimer->gettick(), status_get_amotion(src), 0, rdamage,
1, SR_CRESCENTELBOW_AUTOSPELL, sc->data[SC_CRESCENTELBOW]->val1, 6); // This is how official does
clif->damage(src, bl, iTimer->gettick(), status_get_amotion(src)+1000, 0, rdamage/10, 1, 0, 0);
@@ -5226,13 +5226,13 @@ int64 battle_calc_return_damage(struct block_list* bl, struct block_list *src, i
}
if( sc->data[SC_DEATHBOUND] && skill_id != WS_CARTTERMINATION && !is_boss(src) ) {
uint8 dir = iMap->calc_dir(bl,src->x,src->y),
- t_dir = unit_getdir(bl);
+ t_dir = unit->getdir(bl);
if( !iMap->check_dir(dir,t_dir) ) {
int64 rd1 = damage * sc->data[SC_DEATHBOUND]->val2 / 100; // Amplify damage.
trdamage += rdamage = rd1 - (*dmg = rd1 * 30 / 100); // not normalized as intended.
clif->skill_damage(src, bl, iTimer->gettick(), status_get_amotion(src), 0, -3000, 1, RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1, 6);
- skill->blown(bl, src, skill->get_blewcount(RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1), unit_getdir(src), 0);
+ skill->blown(bl, src, skill->get_blewcount(RK_DEATHBOUND, sc->data[SC_DEATHBOUND]->val1), unit->getdir(src), 0);
if( skill_id )
status_change_end(bl, SC_DEATHBOUND, INVALID_TIMER);
*delay = clif->damage(src, src, iTimer->gettick(), status_get_amotion(src), status_get_dmotion(src), rdamage, 1, 4, 0);
@@ -5417,7 +5417,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
if( tsc && tsc->data[SC_AUTOCOUNTER] && iStatus->check_skilluse(target, src, KN_AUTOCOUNTER, 1) )
{
uint8 dir = iMap->calc_dir(target,src->x,src->y);
- int t_dir = unit_getdir(target);
+ int t_dir = unit->getdir(target);
int dist = distance_bl(src, target);
if(dist <= 0 || (!iMap->check_dir(dir,t_dir) && dist <= tstatus->rhw.range+1))
{
@@ -6028,8 +6028,8 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
int sbg_id = 0, tbg_id = 0;
if( map[m].flag.battleground )
{
- sbg_id = bg_team_get_id(s_bl);
- tbg_id = bg_team_get_id(t_bl);
+ sbg_id = bg->team_get_id(s_bl);
+ tbg_id = bg->team_get_id(t_bl);
}
if( flag&(BCT_PARTY|BCT_ENEMY) )
{
@@ -6091,7 +6091,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
}
/*==========================================
* Check if can attack from this range
- * Basic check then calling path_search for obstacle etc..
+ * Basic check then calling path->search for obstacle etc..
*------------------------------------------*/
bool battle_check_range(struct block_list *src, struct block_list *bl, int range)
{
@@ -6105,7 +6105,7 @@ bool battle_check_range(struct block_list *src, struct block_list *bl, int range
#ifndef CIRCULAR_AREA
if( src->type == BL_PC ) { // Range for players' attacks and skills should always have a circular check. [Angezerus]
int dx = src->x - bl->x, dy = src->y - bl->y;
- if( !check_distance(dx, dy, range) )
+ if( !path->check_distance(dx, dy, range) )
return false;
} else
#endif
@@ -6118,7 +6118,7 @@ bool battle_check_range(struct block_list *src, struct block_list *bl, int range
if( d > AREA_SIZE )
return false; // Avoid targetting objects beyond your range of sight.
- return path_search_long(NULL,src->m,src->x,src->y,bl->x,bl->y,CELL_CHKWALL);
+ return path->search_long(NULL,src->m,src->x,src->y,bl->x,bl->y,CELL_CHKWALL);
}
static const struct _battle_data {
diff --git a/src/map/battleground.c b/src/map/battleground.c
index 3b2e0b1ce..e72683880 100644
--- a/src/map/battleground.c
+++ b/src/map/battleground.c
@@ -26,13 +26,11 @@
#include <string.h>
#include <stdio.h>
-static DBMap* bg_team_db; // int bg_id -> struct battleground_data*
-static unsigned int bg_team_counter = 0; // Next bg_id
struct battleground_interface bg_s;
struct battleground_data* bg_team_search(int bg_id) { // Search a BG Team using bg_id
if( !bg_id ) return NULL;
- return (struct battleground_data *)idb_get(bg_team_db, bg_id);
+ return (struct battleground_data *)idb_get(bg->team_db, bg_id);
}
struct map_session_data* bg_getavailablesd(struct battleground_data *bg) {
@@ -46,28 +44,28 @@ int bg_team_delete(int bg_id)
{ // Deletes BG Team from db
int i;
struct map_session_data *sd;
- struct battleground_data *bg = bg_team_search(bg_id);
+ struct battleground_data *bgd = bg->team_search(bg_id);
if( bg == NULL ) return 0;
for( i = 0; i < MAX_BG_MEMBERS; i++ )
{
- if( (sd = bg->members[i].sd) == NULL )
+ if( (sd = bgd->members[i].sd) == NULL )
continue;
- bg_send_dot_remove(sd);
+ bg->send_dot_remove(sd);
sd->bg_id = 0;
}
- idb_remove(bg_team_db, bg_id);
+ idb_remove(bg->team_db, bg_id);
return 1;
}
int bg_team_warp(int bg_id, unsigned short mapindex, short x, short y)
{ // Warps a Team
int i;
- struct battleground_data *bg = bg_team_search(bg_id);
+ struct battleground_data *bgd = bg->team_search(bg_id);
if( bg == NULL ) return 0;
for( i = 0; i < MAX_BG_MEMBERS; i++ )
- if( bg->members[i].sd != NULL ) pc->setpos(bg->members[i].sd, mapindex, x, y, CLR_TELEPORT);
+ if( bgd->members[i].sd != NULL ) pc->setpos(bgd->members[i].sd, mapindex, x, y, CLR_TELEPORT);
return 1;
}
@@ -81,33 +79,33 @@ int bg_send_dot_remove(struct map_session_data *sd)
int bg_team_join(int bg_id, struct map_session_data *sd)
{ // Player joins team
int i;
- struct battleground_data *bg = bg_team_search(bg_id);
+ struct battleground_data *bgd = bg->team_search(bg_id);
struct map_session_data *pl_sd;
if( bg == NULL || sd == NULL || sd->bg_id ) return 0;
- ARR_FIND(0, MAX_BG_MEMBERS, i, bg->members[i].sd == NULL);
+ ARR_FIND(0, MAX_BG_MEMBERS, i, bgd->members[i].sd == NULL);
if( i == MAX_BG_MEMBERS ) return 0; // No free slots
sd->bg_id = bg_id;
- bg->members[i].sd = sd;
- bg->members[i].x = sd->bl.x;
- bg->members[i].y = sd->bl.y;
+ bgd->members[i].sd = sd;
+ bgd->members[i].x = sd->bl.x;
+ bgd->members[i].y = sd->bl.y;
/* populate 'where i came from' */
if(map[sd->bl.m].flag.nosave || map[sd->bl.m].instance_id >= 0){
struct map_data *m=&map[sd->bl.m];
if(m->save.map)
- memcpy(&bg->members[i].source,&m->save,sizeof(struct point));
+ memcpy(&bgd->members[i].source,&m->save,sizeof(struct point));
else
- memcpy(&bg->members[i].source,&sd->status.save_point,sizeof(struct point));
+ memcpy(&bgd->members[i].source,&sd->status.save_point,sizeof(struct point));
} else
- memcpy(&bg->members[i].source,&sd->status.last_point,sizeof(struct point));
- bg->count++;
+ memcpy(&bgd->members[i].source,&sd->status.last_point,sizeof(struct point));
+ bgd->count++;
guild->send_dot_remove(sd);
for( i = 0; i < MAX_BG_MEMBERS; i++ ) {
- if( (pl_sd = bg->members[i].sd) != NULL && pl_sd != sd )
+ if( (pl_sd = bgd->members[i].sd) != NULL && pl_sd != sd )
clif->hpmeter_single(sd->fd, pl_sd->bl.id, pl_sd->battle_status.hp, pl_sd->battle_status.max_hp);
}
@@ -124,11 +122,11 @@ int bg_team_leave(struct map_session_data *sd, int flag)
if( sd == NULL || !sd->bg_id )
return 0;
- bg_send_dot_remove(sd);
+ bg->send_dot_remove(sd);
bg_id = sd->bg_id;
sd->bg_id = 0;
- if( (bg_data = bg_team_search(bg_id)) == NULL )
+ if( (bg_data = bg->team_search(bg_id)) == NULL )
return 0;
ARR_FIND(0, MAX_BG_MEMBERS, i, bg_data->members[i].sd == sd);
@@ -149,7 +147,7 @@ int bg_team_leave(struct map_session_data *sd, int flag)
}
if( bg_data->logout_event[0] && flag )
- npc_event(sd, bg_data->logout_event, 0);
+ npc->event(sd, bg_data->logout_event, 0);
if( sd->bg_queue.arena ) {
bg->queue_pc_cleanup(sd);
@@ -160,34 +158,34 @@ int bg_team_leave(struct map_session_data *sd, int flag)
int bg_member_respawn(struct map_session_data *sd)
{ // Respawn after killed
- struct battleground_data *bg;
- if( sd == NULL || !pc_isdead(sd) || !sd->bg_id || (bg = bg_team_search(sd->bg_id)) == NULL )
+ struct battleground_data *bgd;
+ if( sd == NULL || !pc_isdead(sd) || !sd->bg_id || (bgd = bg->team_search(sd->bg_id)) == NULL )
return 0;
- if( bg->mapindex == 0 )
+ if( bgd->mapindex == 0 )
return 0; // Respawn not handled by Core
- pc->setpos(sd, bg->mapindex, bg->x, bg->y, CLR_OUTSIGHT);
+ pc->setpos(sd, bgd->mapindex, bgd->x, bgd->y, CLR_OUTSIGHT);
iStatus->revive(&sd->bl, 1, 100);
return 1; // Warped
}
int bg_create(unsigned short mapindex, short rx, short ry, const char *ev, const char *dev) {
- struct battleground_data *bg;
- bg_team_counter++;
-
- CREATE(bg, struct battleground_data, 1);
- bg->bg_id = bg_team_counter;
- bg->count = 0;
- bg->mapindex = mapindex;
- bg->x = rx;
- bg->y = ry;
- safestrncpy(bg->logout_event, ev, sizeof(bg->logout_event));
- safestrncpy(bg->die_event, dev, sizeof(bg->die_event));
-
- memset(&bg->members, 0, sizeof(bg->members));
- idb_put(bg_team_db, bg_team_counter, bg);
-
- return bg->bg_id;
+ struct battleground_data *bgd;
+ bg->team_counter++;
+
+ CREATE(bgd, struct battleground_data, 1);
+ bgd->bg_id = bg->team_counter;
+ bgd->count = 0;
+ bgd->mapindex = mapindex;
+ bgd->x = rx;
+ bgd->y = ry;
+ safestrncpy(bgd->logout_event, ev, sizeof(bgd->logout_event));
+ safestrncpy(bgd->die_event, dev, sizeof(bgd->die_event));
+
+ memset(&bgd->members, 0, sizeof(bgd->members));
+ idb_put(bg->team_db, bg->team_counter, bg);
+
+ return bgd->bg_id;
}
int bg_team_get_id(struct block_list *bl)
@@ -226,12 +224,12 @@ int bg_team_get_id(struct block_list *bl)
int bg_send_message(struct map_session_data *sd, const char *mes, int len)
{
- struct battleground_data *bg;
+ struct battleground_data *bgd;
nullpo_ret(sd);
- if( sd->bg_id == 0 || (bg = bg_team_search(sd->bg_id)) == NULL )
+ if( sd->bg_id == 0 || (bgd = bg->team_search(sd->bg_id)) == NULL )
return 0;
- clif->bg_message(bg, sd->bl.id, sd->status.name, mes, len);
+ clif->bg_message(bgd, sd->bl.id, sd->status.name, mes, len);
return 0;
}
@@ -257,7 +255,7 @@ int bg_send_xy_timer_sub(DBKey key, DBData *data, va_list ap)
}
int bg_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data) {
- bg_team_db->foreach(bg_team_db, bg_send_xy_timer_sub, tick);
+ bg->team_db->foreach(bg->team_db, bg->send_xy_timer_sub, tick);
return 0;
}
void bg_config_read(void) {
@@ -497,7 +495,7 @@ void bg_match_over(struct bg_arena *arena, bool canceled) {
if( queue->item[i] > 0 && ( sd = iMap->id2sd(queue->item[i]) ) ) {
if( sd->bg_queue.arena ) {
- bg_team_leave(sd, 0);
+ bg->team_leave(sd, 0);
bg->queue_pc_cleanup(sd);
}
if( canceled )
@@ -532,9 +530,9 @@ void bg_begin(struct bg_arena *arena) {
bg->match_over(arena,true);
} else {
arena->ongoing = true;
- mapreg_setreg(script->add_str("$@bg_queue_id"),arena->queue_id);/* TODO: make this a arena-independant var? or just .@? */
- mapreg_setregstr(script->add_str("$@bg_delay_var$"),bg->gdelay_var);
- npc_event_do(arena->npc_event);
+ mapreg->setreg(script->add_str("$@bg_queue_id"),arena->queue_id);/* TODO: make this a arena-independant var? or just .@? */
+ mapreg->setregstr(script->add_str("$@bg_delay_var$"),bg->gdelay_var);
+ npc->event_do(arena->npc_event);
/* we split evenly? */
/* but if a party of say 10 joins, it cant be split evenly unless by luck there are 10 soloers in the queue besides them */
/* not sure how to split T_T needs more info */
@@ -570,7 +568,7 @@ void bg_queue_check(struct bg_arena *arena) {
int count = script->hq[arena->queue_id].items;
if( count == arena->max_players ) {
if( arena->fillup_timer != INVALID_TIMER ) {
- iTimer->delete_timer(arena->fillup_timer,bg_fillup_timer);
+ iTimer->delete_timer(arena->fillup_timer,bg->fillup_timer);
arena->fillup_timer = INVALID_TIMER;
}
bg->queue_pregame(arena);
@@ -765,16 +763,16 @@ enum BATTLEGROUNDS_QUEUE_ACK bg_canqueue(struct map_session_data *sd, struct bg_
return BGQA_SUCCESS;
}
void do_init_battleground(void) {
- bg_team_db = idb_alloc(DB_OPT_RELEASE_DATA);
- iTimer->add_timer_func_list(bg_send_xy_timer, "bg_send_xy_timer");
- iTimer->add_timer_interval(iTimer->gettick() + battle_config.bg_update_interval, bg_send_xy_timer, 0, 0, battle_config.bg_update_interval);
+ bg->team_db = idb_alloc(DB_OPT_RELEASE_DATA);
+ iTimer->add_timer_func_list(bg->send_xy_timer, "bg_send_xy_timer");
+ iTimer->add_timer_interval(iTimer->gettick() + battle_config.bg_update_interval, bg->send_xy_timer, 0, 0, battle_config.bg_update_interval);
bg->config_read();
}
void do_final_battleground(void) {
int i;
- bg_team_db->destroy(bg_team_db, NULL);
+ db_destroy(bg->team_db);
for( i = 0; i < bg->arenas; i++ ) {
if( bg->arena[i] )
@@ -793,6 +791,12 @@ void battleground_defaults(void) {
bg->arena = NULL;
bg->arenas = 0;
/* */
+ bg->team_db = NULL;
+ bg->team_counter = 0;
+ /* */
+ bg->init = do_init_battleground;
+ bg->final = do_final_battleground;
+ /* */
bg->name2arena = bg_name2arena;
bg->queue_add = bg_queue_add;
bg->can_queue = bg_canqueue;
@@ -805,6 +809,19 @@ void battleground_defaults(void) {
bg->queue_ready_ack = bg_queue_ready_ack;
bg->match_over = bg_match_over;
bg->queue_check = bg_queue_check;
+ bg->team_search = bg_team_search;
+ bg->getavailablesd = bg_getavailablesd;
+ bg->team_delete = bg_team_delete;
+ bg->team_warp = bg_team_warp;
+ bg->send_dot_remove = bg_send_dot_remove;
+ bg->team_join = bg_team_join;
+ bg->team_leave = bg_team_leave;
+ bg->member_respawn = bg_member_respawn;
+ bg->create = bg_create;
+ bg->team_get_id = bg_team_get_id;
+ bg->send_message = bg_send_message;
+ bg->send_xy_timer_sub = bg_send_xy_timer_sub;
+ bg->send_xy_timer = bg_send_xy_timer;
/* */
bg->config_read = bg_config_read;
}
diff --git a/src/map/battleground.h b/src/map/battleground.h
index 1566e92b8..3edecf902 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -43,22 +43,6 @@ struct battleground_data {
char die_event[EVENT_NAME_LENGTH];
};
-void do_init_battleground(void);
-void do_final_battleground(void);
-
-struct battleground_data* bg_team_search(int bg_id);
-int bg_send_dot_remove(struct map_session_data *sd);
-int bg_team_get_id(struct block_list *bl);
-struct map_session_data* bg_getavailablesd(struct battleground_data *bg);
-
-int bg_create(unsigned short mapindex, short rx, short ry, const char *ev, const char *dev);
-int bg_team_join(int bg_id, struct map_session_data *sd);
-int bg_team_delete(int bg_id);
-int bg_team_leave(struct map_session_data *sd, int flag);
-int bg_team_warp(int bg_id, unsigned short mapindex, short x, short y);
-int bg_member_respawn(struct map_session_data *sd);
-int bg_send_message(struct map_session_data *sd, const char *mes, int len);
-
struct bg_arena {
char name[NAME_LENGTH];
unsigned char id;
@@ -79,7 +63,6 @@ struct bg_arena {
bool ongoing;
};
-/* battleground.c interface (incomplete) */
struct battleground_interface {
bool queue_on;
/* */
@@ -89,6 +72,12 @@ struct battleground_interface {
struct bg_arena **arena;
unsigned char arenas;
/* */
+ DBMap *team_db; // int bg_id -> struct battleground_data*
+ unsigned int team_counter; // Next bg_id
+ /* */
+ void (*init) (void);
+ void (*final) (void);
+ /* */
struct bg_arena *(*name2arena) (char *name);
void (*queue_add) (struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type);
enum BATTLEGROUNDS_QUEUE_ACK (*can_queue) (struct map_session_data *sd, struct bg_arena *arena, enum bg_queue_types type);
@@ -101,6 +90,19 @@ struct battleground_interface {
void (*queue_ready_ack) (struct bg_arena *arena, struct map_session_data *sd, bool response);
void (*match_over) (struct bg_arena *arena, bool canceled);
void (*queue_check) (struct bg_arena *arena);
+ struct battleground_data* (*team_search) (int bg_id);
+ struct map_session_data* (*getavailablesd) (struct battleground_data *bg);
+ int (*team_delete) (int bg_id);
+ int (*team_warp) (int bg_id, unsigned short mapindex, short x, short y);
+ int (*send_dot_remove) (struct map_session_data *sd);
+ int (*team_join) (int bg_id, struct map_session_data *sd);
+ int (*team_leave) (struct map_session_data *sd, int flag);
+ int (*member_respawn) (struct map_session_data *sd);
+ int (*create) (unsigned short mapindex, short rx, short ry, const char *ev, const char *dev);
+ int (*team_get_id) (struct block_list *bl);
+ int (*send_message) (struct map_session_data *sd, const char *mes, int len);
+ int (*send_xy_timer_sub) (DBKey key, DBData *data, va_list ap);
+ int (*send_xy_timer) (int tid, unsigned int tick, int id, intptr_t data);
/* */
void (*config_read) (void);
};
diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c
index 73c50b0bf..5edf9a321 100644
--- a/src/map/buyingstore.c
+++ b/src/map/buyingstore.c
@@ -147,7 +147,7 @@ void buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned cha
break;
}
- if( !id->flag.buyingstore || !itemdb_cantrade_sub(id, pc->get_group_level(sd), pc->get_group_level(sd)) || ( idx = pc->search_inventory(sd, nameid) ) == -1 )
+ if( !id->flag.buyingstore || !itemdb->cantrade_sub(id, pc->get_group_level(sd), pc->get_group_level(sd)) || ( idx = pc->search_inventory(sd, nameid) ) == -1 )
{// restrictions: allowed, no character-bound items and at least one must be owned
break;
}
diff --git a/src/map/chat.c b/src/map/chat.c
index 75ae3681b..28de86fe1 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -1,447 +1,447 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
-
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/nullpo.h"
-#include "../common/showmsg.h"
-#include "../common/strlib.h"
-#include "../common/mmo.h"
-#include "atcommand.h" // msg_txt()
-#include "battle.h" // struct battle_config
-#include "clif.h"
-#include "map.h"
-#include "npc.h" // npc_event_do()
-#include "pc.h"
-#include "skill.h" // ext_skill_unit_onplace()
-#include "chat.h"
-
-#include <stdio.h>
-#include <string.h>
-
-
-int chat_triggerevent(struct chat_data *cd); // forward declaration
-
-/// Initializes a chatroom object (common functionality for both pc and npc chatrooms).
-/// Returns a chatroom object on success, or NULL on failure.
-static struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl)
-{
- struct chat_data* cd;
- nullpo_retr(NULL, bl);
-
- cd = (struct chat_data *) aMalloc(sizeof(struct chat_data));
-
- safestrncpy(cd->title, title, sizeof(cd->title));
- safestrncpy(cd->pass, pass, sizeof(cd->pass));
- cd->pub = pub;
- cd->users = 0;
- cd->limit = min(limit, ARRAYLENGTH(cd->usersd));
- cd->trigger = trigger;
- cd->zeny = zeny;
- cd->minLvl = minLvl;
- cd->maxLvl = maxLvl;
- memset(cd->usersd, 0, sizeof(cd->usersd));
- cd->owner = bl;
- safestrncpy(cd->npc_event, ev, sizeof(cd->npc_event));
-
- cd->bl.id = iMap->get_new_object_id();
- cd->bl.m = bl->m;
- cd->bl.x = bl->x;
- cd->bl.y = bl->y;
- cd->bl.type = BL_CHAT;
- cd->bl.next = cd->bl.prev = NULL;
-
- if( cd->bl.id == 0 )
- {
- aFree(cd);
- cd = NULL;
- }
-
- iMap->addiddb(&cd->bl);
-
- if( bl->type != BL_NPC )
- cd->kick_list = idb_alloc(DB_OPT_BASE);
-
- return cd;
-}
-
-/*==========================================
- * player chatroom creation
- *------------------------------------------*/
-int chat_createpcchat(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub)
-{
- struct chat_data* cd;
- nullpo_ret(sd);
-
- if( sd->chatID )
- return 0; //Prevent people abusing the chat system by creating multiple chats, as pointed out by End of Exam. [Skotlex]
-
- if( sd->state.vending || sd->state.buyingstore )
- {// not chat, when you already have a store open
- return 0;
- }
-
- if( map[sd->bl.m].flag.nochat )
- {
- clif->message(sd->fd, msg_txt(281));
- return 0; //Can't create chatrooms on this map.
- }
-
- if( iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) )
- {
- clif->message (sd->fd, msg_txt(665));
- return 0;
- }
-
- pc_stop_walking(sd,1);
-
- cd = chat_createchat(&sd->bl, title, pass, limit, pub, 0, "", 0, 1, MAX_LEVEL);
- if( cd ) {
- cd->users = 1;
- cd->usersd[0] = sd;
- pc_setchatid(sd,cd->bl.id);
- pc_stop_attack(sd);
- clif->createchat(sd,0);
- clif->dispchat(cd,0);
- } else
- clif->createchat(sd,1);
-
- return 0;
-}
-
-/*==========================================
- * join an existing chatroom
- *------------------------------------------*/
-int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass)
-{
- struct chat_data* cd;
-
- nullpo_ret(sd);
- cd = (struct chat_data*)iMap->id2bl(chatid);
-
- if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit )
- {
- clif->joinchatfail(sd,0);
- return 0;
- }
-
- if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !pc->has_permission(sd, PC_PERM_JOIN_ALL_CHAT) )
- {
- clif->joinchatfail(sd,1);
- return 0;
- }
-
- if( sd->status.base_level < cd->minLvl || sd->status.base_level > cd->maxLvl ) {
- if(sd->status.base_level < cd->minLvl)
- clif->joinchatfail(sd,5);
- else
- clif->joinchatfail(sd,6);
-
- return 0;
- }
-
- if( sd->status.zeny < cd->zeny ) {
- clif->joinchatfail(sd,4);
- return 0;
- }
-
- if( cd->owner->type != BL_NPC && idb_exists(cd->kick_list,sd->status.char_id) ) {
- clif->joinchatfail(sd,2);//You have been kicked out of the room.
- return 0;
- }
-
- pc_stop_walking(sd,1);
- cd->usersd[cd->users] = sd;
- cd->users++;
-
- pc_setchatid(sd,cd->bl.id);
-
- clif->joinchatok(sd, cd); //To the person who newly joined the list of all
- clif->addchat(cd, sd); //Reports To the person who already in the chat
- clif->dispchat(cd, 0); //Reported number of changes to the people around
-
- chat_triggerevent(cd); //Event
-
- return 0;
-}
-
-
-/*==========================================
- * leave a chatroom
- *------------------------------------------*/
-int chat_leavechat(struct map_session_data* sd, bool kicked)
-{
- struct chat_data* cd;
- int i;
- int leavechar;
-
- nullpo_retr(1, sd);
-
- cd = (struct chat_data*)iMap->id2bl(sd->chatID);
- if( cd == NULL )
- {
- pc_setchatid(sd, 0);
- return 1;
- }
-
- ARR_FIND( 0, cd->users, i, cd->usersd[i] == sd );
- if ( i == cd->users )
- { // Not found in the chatroom?
- pc_setchatid(sd, 0);
- return -1;
- }
-
- clif->leavechat(cd, sd, kicked);
- pc_setchatid(sd, 0);
- cd->users--;
-
- leavechar = i;
-
- for( i = leavechar; i < cd->users; i++ )
- cd->usersd[i] = cd->usersd[i+1];
-
-
- if( cd->users == 0 && cd->owner->type == BL_PC ) { // Delete empty chatroom
- struct skill_unit* unit;
- struct skill_unit_group* group;
-
- clif->clearchat(cd, 0);
- db_destroy(cd->kick_list);
- iMap->deliddb(&cd->bl);
- iMap->delblock(&cd->bl);
- iMap->freeblock(&cd->bl);
-
- unit = iMap->find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0);
- group = (unit != NULL) ? unit->group : NULL;
- if (group != NULL)
- skill->unit_onplace(unit, &sd->bl, group->tick);
-
- return 1;
- }
-
- if( leavechar == 0 && cd->owner->type == BL_PC )
- { // Set and announce new owner
- cd->owner = (struct block_list*) cd->usersd[0];
- clif->changechatowner(cd, cd->usersd[0]);
- clif->clearchat(cd, 0);
-
- //Adjust Chat location after owner has been changed.
- iMap->delblock( &cd->bl );
- cd->bl.x=cd->usersd[0]->bl.x;
- cd->bl.y=cd->usersd[0]->bl.y;
- iMap->addblock( &cd->bl );
-
- clif->dispchat(cd,0);
- }
- else
- clif->dispchat(cd,0); // refresh chatroom
-
- return 0;
-}
-
-/*==========================================
- * change a chatroom's owner
- *------------------------------------------*/
-int chat_changechatowner(struct map_session_data* sd, const char* nextownername)
-{
- struct chat_data* cd;
- struct map_session_data* tmpsd;
- int i;
-
- nullpo_retr(1, sd);
-
- cd = (struct chat_data*)iMap->id2bl(sd->chatID);
- if( cd == NULL || (struct block_list*) sd != cd->owner )
- return 1;
-
- ARR_FIND( 1, cd->users, i, strncmp(cd->usersd[i]->status.name, nextownername, NAME_LENGTH) == 0 );
- if( i == cd->users )
- return -1; // name not found
-
- // erase temporarily
- clif->clearchat(cd,0);
-
- // set new owner
- cd->owner = (struct block_list*) cd->usersd[i];
- clif->changechatowner(cd,cd->usersd[i]);
-
- // swap the old and new owners' positions
- tmpsd = cd->usersd[i];
- cd->usersd[i] = cd->usersd[0];
- cd->usersd[0] = tmpsd;
-
- // set the new chatroom position
- iMap->delblock( &cd->bl );
- cd->bl.x = cd->owner->x;
- cd->bl.y = cd->owner->y;
- iMap->addblock( &cd->bl );
-
- // and display again
- clif->dispchat(cd,0);
-
- return 0;
-}
-
-/*==========================================
- * change a chatroom's status (title, etc)
- *------------------------------------------*/
-int chat_changechatstatus(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub)
-{
- struct chat_data* cd;
-
- nullpo_retr(1, sd);
-
- cd = (struct chat_data*)iMap->id2bl(sd->chatID);
- if( cd==NULL || (struct block_list *)sd != cd->owner )
- return 1;
-
- safestrncpy(cd->title, title, CHATROOM_TITLE_SIZE);
- safestrncpy(cd->pass, pass, CHATROOM_PASS_SIZE);
- cd->limit = min(limit, ARRAYLENGTH(cd->usersd));
- cd->pub = pub;
-
- clif->changechatstatus(cd);
- clif->dispchat(cd,0);
-
- return 0;
-}
-
-/*==========================================
- * kick an user from a chatroom
- *------------------------------------------*/
-int chat_kickchat(struct map_session_data* sd, const char* kickusername)
-{
- struct chat_data* cd;
- int i;
-
- nullpo_retr(1, sd);
-
- cd = (struct chat_data *)iMap->id2bl(sd->chatID);
-
- if( cd==NULL || (struct block_list *)sd != cd->owner )
- return -1;
-
- ARR_FIND( 0, cd->users, i, strncmp(cd->usersd[i]->status.name, kickusername, NAME_LENGTH) == 0 );
- if( i == cd->users )
- return -1;
-
- if (pc->has_permission(cd->usersd[i], PC_PERM_NO_CHAT_KICK))
- return 0; //gm kick protection [Valaris]
-
- idb_put(cd->kick_list,cd->usersd[i]->status.char_id,(void*)1);
-
- chat->leavechat(cd->usersd[i],1);
- return 0;
-}
-
-/// Creates a chat room for the npc.
-int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl)
-{
- struct chat_data* cd;
- nullpo_ret(nd);
-
- if( nd->chat_id ) {
- ShowError("chat_createnpcchat: npc '%s' already has a chatroom, cannot create new one!\n", nd->exname);
- return 0;
- }
-
- if( zeny > MAX_ZENY || maxLvl > MAX_LEVEL ) {
- ShowError("chat_createnpcchat: npc '%s' has a required lvl or amount of zeny over the max limit!\n", nd->exname);
- return 0;
- }
-
- cd = chat_createchat(&nd->bl, title, "", limit, pub, trigger, ev, zeny, minLvl, maxLvl);
-
- if( cd ) {
- nd->chat_id = cd->bl.id;
- clif->dispchat(cd,0);
- }
-
- return 0;
-}
-
-/// Removes the chatroom from the npc.
-int chat_deletenpcchat(struct npc_data* nd)
-{
- struct chat_data *cd;
- nullpo_ret(nd);
-
- cd = (struct chat_data*)iMap->id2bl(nd->chat_id);
- if( cd == NULL )
- return 0;
-
- chat->npckickall(cd);
- clif->clearchat(cd, 0);
- iMap->deliddb(&cd->bl);
- iMap->delblock(&cd->bl);
- iMap->freeblock(&cd->bl);
- nd->chat_id = 0;
-
- return 0;
-}
-
-/*==========================================
- * Trigger npc event when we enter the chatroom
- *------------------------------------------*/
-int chat_triggerevent(struct chat_data *cd)
-{
- nullpo_ret(cd);
-
- if( cd->users >= cd->trigger && cd->npc_event[0] )
- npc_event_do(cd->npc_event);
- return 0;
-}
-
-/// Enables the event of the chat room.
-/// At most, 127 users are needed to trigger the event.
-int chat_enableevent(struct chat_data* cd)
-{
- nullpo_ret(cd);
-
- cd->trigger &= 0x7f;
- chat_triggerevent(cd);
- return 0;
-}
-
-/// Disables the event of the chat room
-int chat_disableevent(struct chat_data* cd)
-{
- nullpo_ret(cd);
-
- cd->trigger |= 0x80;
- return 0;
-}
-
-/// Kicks all the users from the chat room.
-int chat_npckickall(struct chat_data* cd)
-{
- nullpo_ret(cd);
-
- while( cd->users > 0 )
- chat->leavechat(cd->usersd[cd->users-1],0);
-
- return 0;
-}
-
-/*=====================================
-* Default Functions : chat.h
-* Generated by HerculesInterfaceMaker
-* created by Susu
-*-------------------------------------*/
-void chat_defaults(void) {
- chat = &chat_s;
- /* funcs */
-
- chat->createpcchat = chat_createpcchat;
- chat->joinchat = chat_joinchat;
- chat->leavechat = chat_leavechat;
- chat->changechatowner = chat_changechatowner;
- chat->changechatstatus = chat_changechatstatus;
- chat->kickchat = chat_kickchat;
-
- chat->createnpcchat = chat_createnpcchat;
- chat->deletenpcchat = chat_deletenpcchat;
- chat->enableevent = chat_enableevent;
- chat->disableevent = chat_disableevent;
- chat->npckickall = chat_npckickall;
-}
+// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+
+#include "../common/cbasetypes.h"
+#include "../common/malloc.h"
+#include "../common/nullpo.h"
+#include "../common/showmsg.h"
+#include "../common/strlib.h"
+#include "../common/mmo.h"
+#include "atcommand.h" // msg_txt()
+#include "battle.h" // struct battle_config
+#include "clif.h"
+#include "map.h"
+#include "npc.h" // npc_event_do()
+#include "pc.h"
+#include "skill.h" // ext_skill_unit_onplace()
+#include "chat.h"
+
+#include <stdio.h>
+#include <string.h>
+
+
+int chat_triggerevent(struct chat_data *cd); // forward declaration
+
+/// Initializes a chatroom object (common functionality for both pc and npc chatrooms).
+/// Returns a chatroom object on success, or NULL on failure.
+static struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl)
+{
+ struct chat_data* cd;
+ nullpo_retr(NULL, bl);
+
+ cd = (struct chat_data *) aMalloc(sizeof(struct chat_data));
+
+ safestrncpy(cd->title, title, sizeof(cd->title));
+ safestrncpy(cd->pass, pass, sizeof(cd->pass));
+ cd->pub = pub;
+ cd->users = 0;
+ cd->limit = min(limit, ARRAYLENGTH(cd->usersd));
+ cd->trigger = trigger;
+ cd->zeny = zeny;
+ cd->minLvl = minLvl;
+ cd->maxLvl = maxLvl;
+ memset(cd->usersd, 0, sizeof(cd->usersd));
+ cd->owner = bl;
+ safestrncpy(cd->npc_event, ev, sizeof(cd->npc_event));
+
+ cd->bl.id = iMap->get_new_object_id();
+ cd->bl.m = bl->m;
+ cd->bl.x = bl->x;
+ cd->bl.y = bl->y;
+ cd->bl.type = BL_CHAT;
+ cd->bl.next = cd->bl.prev = NULL;
+
+ if( cd->bl.id == 0 )
+ {
+ aFree(cd);
+ cd = NULL;
+ }
+
+ iMap->addiddb(&cd->bl);
+
+ if( bl->type != BL_NPC )
+ cd->kick_list = idb_alloc(DB_OPT_BASE);
+
+ return cd;
+}
+
+/*==========================================
+ * player chatroom creation
+ *------------------------------------------*/
+int chat_createpcchat(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub)
+{
+ struct chat_data* cd;
+ nullpo_ret(sd);
+
+ if( sd->chatID )
+ return 0; //Prevent people abusing the chat system by creating multiple chats, as pointed out by End of Exam. [Skotlex]
+
+ if( sd->state.vending || sd->state.buyingstore )
+ {// not chat, when you already have a store open
+ return 0;
+ }
+
+ if( map[sd->bl.m].flag.nochat )
+ {
+ clif->message(sd->fd, msg_txt(281));
+ return 0; //Can't create chatrooms on this map.
+ }
+
+ if( iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) )
+ {
+ clif->message (sd->fd, msg_txt(665));
+ return 0;
+ }
+
+ pc_stop_walking(sd,1);
+
+ cd = chat_createchat(&sd->bl, title, pass, limit, pub, 0, "", 0, 1, MAX_LEVEL);
+ if( cd ) {
+ cd->users = 1;
+ cd->usersd[0] = sd;
+ pc_setchatid(sd,cd->bl.id);
+ pc_stop_attack(sd);
+ clif->createchat(sd,0);
+ clif->dispchat(cd,0);
+ } else
+ clif->createchat(sd,1);
+
+ return 0;
+}
+
+/*==========================================
+ * join an existing chatroom
+ *------------------------------------------*/
+int chat_joinchat(struct map_session_data* sd, int chatid, const char* pass)
+{
+ struct chat_data* cd;
+
+ nullpo_ret(sd);
+ cd = (struct chat_data*)iMap->id2bl(chatid);
+
+ if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit )
+ {
+ clif->joinchatfail(sd,0);
+ return 0;
+ }
+
+ if( !cd->pub && strncmp(pass, cd->pass, sizeof(cd->pass)) != 0 && !pc->has_permission(sd, PC_PERM_JOIN_ALL_CHAT) )
+ {
+ clif->joinchatfail(sd,1);
+ return 0;
+ }
+
+ if( sd->status.base_level < cd->minLvl || sd->status.base_level > cd->maxLvl ) {
+ if(sd->status.base_level < cd->minLvl)
+ clif->joinchatfail(sd,5);
+ else
+ clif->joinchatfail(sd,6);
+
+ return 0;
+ }
+
+ if( sd->status.zeny < cd->zeny ) {
+ clif->joinchatfail(sd,4);
+ return 0;
+ }
+
+ if( cd->owner->type != BL_NPC && idb_exists(cd->kick_list,sd->status.char_id) ) {
+ clif->joinchatfail(sd,2);//You have been kicked out of the room.
+ return 0;
+ }
+
+ pc_stop_walking(sd,1);
+ cd->usersd[cd->users] = sd;
+ cd->users++;
+
+ pc_setchatid(sd,cd->bl.id);
+
+ clif->joinchatok(sd, cd); //To the person who newly joined the list of all
+ clif->addchat(cd, sd); //Reports To the person who already in the chat
+ clif->dispchat(cd, 0); //Reported number of changes to the people around
+
+ chat_triggerevent(cd); //Event
+
+ return 0;
+}
+
+
+/*==========================================
+ * leave a chatroom
+ *------------------------------------------*/
+int chat_leavechat(struct map_session_data* sd, bool kicked)
+{
+ struct chat_data* cd;
+ int i;
+ int leavechar;
+
+ nullpo_retr(1, sd);
+
+ cd = (struct chat_data*)iMap->id2bl(sd->chatID);
+ if( cd == NULL )
+ {
+ pc_setchatid(sd, 0);
+ return 1;
+ }
+
+ ARR_FIND( 0, cd->users, i, cd->usersd[i] == sd );
+ if ( i == cd->users )
+ { // Not found in the chatroom?
+ pc_setchatid(sd, 0);
+ return -1;
+ }
+
+ clif->leavechat(cd, sd, kicked);
+ pc_setchatid(sd, 0);
+ cd->users--;
+
+ leavechar = i;
+
+ for( i = leavechar; i < cd->users; i++ )
+ cd->usersd[i] = cd->usersd[i+1];
+
+
+ if( cd->users == 0 && cd->owner->type == BL_PC ) { // Delete empty chatroom
+ struct skill_unit* unit;
+ struct skill_unit_group* group;
+
+ clif->clearchat(cd, 0);
+ db_destroy(cd->kick_list);
+ iMap->deliddb(&cd->bl);
+ iMap->delblock(&cd->bl);
+ iMap->freeblock(&cd->bl);
+
+ unit = iMap->find_skill_unit_oncell(&sd->bl, sd->bl.x, sd->bl.y, AL_WARP, NULL, 0);
+ group = (unit != NULL) ? unit->group : NULL;
+ if (group != NULL)
+ skill->unit_onplace(unit, &sd->bl, group->tick);
+
+ return 1;
+ }
+
+ if( leavechar == 0 && cd->owner->type == BL_PC )
+ { // Set and announce new owner
+ cd->owner = (struct block_list*) cd->usersd[0];
+ clif->changechatowner(cd, cd->usersd[0]);
+ clif->clearchat(cd, 0);
+
+ //Adjust Chat location after owner has been changed.
+ iMap->delblock( &cd->bl );
+ cd->bl.x=cd->usersd[0]->bl.x;
+ cd->bl.y=cd->usersd[0]->bl.y;
+ iMap->addblock( &cd->bl );
+
+ clif->dispchat(cd,0);
+ }
+ else
+ clif->dispchat(cd,0); // refresh chatroom
+
+ return 0;
+}
+
+/*==========================================
+ * change a chatroom's owner
+ *------------------------------------------*/
+int chat_changechatowner(struct map_session_data* sd, const char* nextownername)
+{
+ struct chat_data* cd;
+ struct map_session_data* tmpsd;
+ int i;
+
+ nullpo_retr(1, sd);
+
+ cd = (struct chat_data*)iMap->id2bl(sd->chatID);
+ if( cd == NULL || (struct block_list*) sd != cd->owner )
+ return 1;
+
+ ARR_FIND( 1, cd->users, i, strncmp(cd->usersd[i]->status.name, nextownername, NAME_LENGTH) == 0 );
+ if( i == cd->users )
+ return -1; // name not found
+
+ // erase temporarily
+ clif->clearchat(cd,0);
+
+ // set new owner
+ cd->owner = (struct block_list*) cd->usersd[i];
+ clif->changechatowner(cd,cd->usersd[i]);
+
+ // swap the old and new owners' positions
+ tmpsd = cd->usersd[i];
+ cd->usersd[i] = cd->usersd[0];
+ cd->usersd[0] = tmpsd;
+
+ // set the new chatroom position
+ iMap->delblock( &cd->bl );
+ cd->bl.x = cd->owner->x;
+ cd->bl.y = cd->owner->y;
+ iMap->addblock( &cd->bl );
+
+ // and display again
+ clif->dispchat(cd,0);
+
+ return 0;
+}
+
+/*==========================================
+ * change a chatroom's status (title, etc)
+ *------------------------------------------*/
+int chat_changechatstatus(struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub)
+{
+ struct chat_data* cd;
+
+ nullpo_retr(1, sd);
+
+ cd = (struct chat_data*)iMap->id2bl(sd->chatID);
+ if( cd==NULL || (struct block_list *)sd != cd->owner )
+ return 1;
+
+ safestrncpy(cd->title, title, CHATROOM_TITLE_SIZE);
+ safestrncpy(cd->pass, pass, CHATROOM_PASS_SIZE);
+ cd->limit = min(limit, ARRAYLENGTH(cd->usersd));
+ cd->pub = pub;
+
+ clif->changechatstatus(cd);
+ clif->dispchat(cd,0);
+
+ return 0;
+}
+
+/*==========================================
+ * kick an user from a chatroom
+ *------------------------------------------*/
+int chat_kickchat(struct map_session_data* sd, const char* kickusername)
+{
+ struct chat_data* cd;
+ int i;
+
+ nullpo_retr(1, sd);
+
+ cd = (struct chat_data *)iMap->id2bl(sd->chatID);
+
+ if( cd==NULL || (struct block_list *)sd != cd->owner )
+ return -1;
+
+ ARR_FIND( 0, cd->users, i, strncmp(cd->usersd[i]->status.name, kickusername, NAME_LENGTH) == 0 );
+ if( i == cd->users )
+ return -1;
+
+ if (pc->has_permission(cd->usersd[i], PC_PERM_NO_CHAT_KICK))
+ return 0; //gm kick protection [Valaris]
+
+ idb_put(cd->kick_list,cd->usersd[i]->status.char_id,(void*)1);
+
+ chat->leavechat(cd->usersd[i],1);
+ return 0;
+}
+
+/// Creates a chat room for the npc.
+int chat_createnpcchat(struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl)
+{
+ struct chat_data* cd;
+ nullpo_ret(nd);
+
+ if( nd->chat_id ) {
+ ShowError("chat_createnpcchat: npc '%s' already has a chatroom, cannot create new one!\n", nd->exname);
+ return 0;
+ }
+
+ if( zeny > MAX_ZENY || maxLvl > MAX_LEVEL ) {
+ ShowError("chat_createnpcchat: npc '%s' has a required lvl or amount of zeny over the max limit!\n", nd->exname);
+ return 0;
+ }
+
+ cd = chat_createchat(&nd->bl, title, "", limit, pub, trigger, ev, zeny, minLvl, maxLvl);
+
+ if( cd ) {
+ nd->chat_id = cd->bl.id;
+ clif->dispchat(cd,0);
+ }
+
+ return 0;
+}
+
+/// Removes the chatroom from the npc.
+int chat_deletenpcchat(struct npc_data* nd)
+{
+ struct chat_data *cd;
+ nullpo_ret(nd);
+
+ cd = (struct chat_data*)iMap->id2bl(nd->chat_id);
+ if( cd == NULL )
+ return 0;
+
+ chat->npckickall(cd);
+ clif->clearchat(cd, 0);
+ iMap->deliddb(&cd->bl);
+ iMap->delblock(&cd->bl);
+ iMap->freeblock(&cd->bl);
+ nd->chat_id = 0;
+
+ return 0;
+}
+
+/*==========================================
+ * Trigger npc event when we enter the chatroom
+ *------------------------------------------*/
+int chat_triggerevent(struct chat_data *cd)
+{
+ nullpo_ret(cd);
+
+ if( cd->users >= cd->trigger && cd->npc_event[0] )
+ npc->event_do(cd->npc_event);
+ return 0;
+}
+
+/// Enables the event of the chat room.
+/// At most, 127 users are needed to trigger the event.
+int chat_enableevent(struct chat_data* cd)
+{
+ nullpo_ret(cd);
+
+ cd->trigger &= 0x7f;
+ chat_triggerevent(cd);
+ return 0;
+}
+
+/// Disables the event of the chat room
+int chat_disableevent(struct chat_data* cd)
+{
+ nullpo_ret(cd);
+
+ cd->trigger |= 0x80;
+ return 0;
+}
+
+/// Kicks all the users from the chat room.
+int chat_npckickall(struct chat_data* cd)
+{
+ nullpo_ret(cd);
+
+ while( cd->users > 0 )
+ chat->leavechat(cd->usersd[cd->users-1],0);
+
+ return 0;
+}
+
+/*=====================================
+* Default Functions : chat.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+void chat_defaults(void) {
+ chat = &chat_s;
+ /* funcs */
+
+ chat->createpcchat = chat_createpcchat;
+ chat->joinchat = chat_joinchat;
+ chat->leavechat = chat_leavechat;
+ chat->changechatowner = chat_changechatowner;
+ chat->changechatstatus = chat_changechatstatus;
+ chat->kickchat = chat_kickchat;
+
+ chat->createnpcchat = chat_createnpcchat;
+ chat->deletenpcchat = chat_deletenpcchat;
+ chat->enableevent = chat_enableevent;
+ chat->disableevent = chat_disableevent;
+ chat->npckickall = chat_npckickall;
+}
diff --git a/src/map/chat.h b/src/map/chat.h
index ff78d8617..a7736e9f3 100644
--- a/src/map/chat.h
+++ b/src/map/chat.h
@@ -1,56 +1,56 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
-#ifndef _CHAT_H_
-#define _CHAT_H_
-#include "map.h" // struct block_list, CHATROOM_TITLE_SIZE
-struct map_session_data;
-struct chat_data;
-
-
-struct chat_data {
- struct block_list bl; // data for this map object
- char title[CHATROOM_TITLE_SIZE]; // room title
- char pass[CHATROOM_PASS_SIZE]; // password
- bool pub; // private/public flag
- uint8 users; // current user count
- uint8 limit; // join limit
- uint8 trigger; // number of users needed to trigger event
- uint32 zeny; // required zeny to join
- uint32 minLvl; // minimum base level to join
- uint32 maxLvl; // maximum base level allowed to join
- struct map_session_data* usersd[20];
- struct block_list* owner;
- char npc_event[EVENT_NAME_LENGTH];
- DBMap* kick_list; //DBMap of users who were kicked from this chat
-};
-
-
-
-
-/*=====================================
-* Interface : chat.h
-* Generated by HerculesInterfaceMaker
-* created by Susu
-*-------------------------------------*/
-struct chat_interface {
- /* funcs */
-
- int (*createpcchat) (struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub);
- int (*joinchat) (struct map_session_data* sd, int chatid, const char* pass);
- int (*leavechat) (struct map_session_data* sd, bool kicked);
- int (*changechatowner) (struct map_session_data* sd, const char* nextownername);
- int (*changechatstatus) (struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub);
- int (*kickchat) (struct map_session_data* sd, const char* kickusername);
-
- int (*createnpcchat) (struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl);
- int (*deletenpcchat) (struct npc_data* nd);
- int (*enableevent) (struct chat_data* cd);
- int (*disableevent) (struct chat_data* cd);
- int (*npckickall) (struct chat_data* cd);
-} chat_s;
-
-struct chat_interface *chat;
-
-void chat_defaults(void);
-
-#endif /* _CHAT_H_ */
+// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+#ifndef _CHAT_H_
+#define _CHAT_H_
+#include "map.h" // struct block_list, CHATROOM_TITLE_SIZE
+struct map_session_data;
+struct chat_data;
+
+
+struct chat_data {
+ struct block_list bl; // data for this map object
+ char title[CHATROOM_TITLE_SIZE]; // room title
+ char pass[CHATROOM_PASS_SIZE]; // password
+ bool pub; // private/public flag
+ uint8 users; // current user count
+ uint8 limit; // join limit
+ uint8 trigger; // number of users needed to trigger event
+ uint32 zeny; // required zeny to join
+ uint32 minLvl; // minimum base level to join
+ uint32 maxLvl; // maximum base level allowed to join
+ struct map_session_data* usersd[20];
+ struct block_list* owner;
+ char npc_event[EVENT_NAME_LENGTH];
+ DBMap* kick_list; //DBMap of users who were kicked from this chat
+};
+
+
+
+
+/*=====================================
+* Interface : chat.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+struct chat_interface {
+ /* funcs */
+
+ int (*createpcchat) (struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub);
+ int (*joinchat) (struct map_session_data* sd, int chatid, const char* pass);
+ int (*leavechat) (struct map_session_data* sd, bool kicked);
+ int (*changechatowner) (struct map_session_data* sd, const char* nextownername);
+ int (*changechatstatus) (struct map_session_data* sd, const char* title, const char* pass, int limit, bool pub);
+ int (*kickchat) (struct map_session_data* sd, const char* kickusername);
+
+ int (*createnpcchat) (struct npc_data* nd, const char* title, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl);
+ int (*deletenpcchat) (struct npc_data* nd);
+ int (*enableevent) (struct chat_data* cd);
+ int (*disableevent) (struct chat_data* cd);
+ int (*npckickall) (struct chat_data* cd);
+} chat_s;
+
+struct chat_interface *chat;
+
+void chat_defaults(void);
+
+#endif /* _CHAT_H_ */
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 6b0397b56..524286da1 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -463,10 +463,10 @@ int chrif_connectack(int fd) {
chrif_sendmap(fd);
- ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInit"));
+ ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc->event_doall("OnInterIfInit"));
if( !char_init_done ) {
char_init_done = true;
- ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInitOnce"));
+ ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc->event_doall("OnInterIfInitOnce"));
guild->castle_map_init();
}
diff --git a/src/map/clif.c b/src/map/clif.c
index d26f11ba3..342f1d943 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -339,7 +339,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
struct map_session_data *sd, *tsd;
struct party_data *p = NULL;
struct guild *g = NULL;
- struct battleground_data *bg = NULL;
+ struct battleground_data *bgd = NULL;
int x0 = 0, x1 = 0, y0 = 0, y1 = 0, fd;
struct s_mapiterator* iter;
@@ -545,9 +545,9 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
case BG_SAMEMAP_WOS:
case BG:
case BG_WOS:
- if( sd && sd->bg_id && (bg = bg_team_search(sd->bg_id)) != NULL ) {
+ if( sd && sd->bg_id && (bgd = bg->team_search(sd->bg_id)) != NULL ) {
for( i = 0; i < MAX_BG_MEMBERS; i++ ) {
- if( (sd = bg->members[i].sd) == NULL || !(fd = sd->fd) )
+ if( (sd = bgd->members[i].sd) == NULL || !(fd = sd->fd) )
continue;
if( sd->bl.id == bl->id && (type == BG_WOS || type == BG_SAMEMAP_WOS || type == BG_AREA_WOS) )
continue;
@@ -902,7 +902,7 @@ void clif_set_unit_idle2(struct block_list* bl, struct map_session_data *tsd, en
p.virtue = (sc) ? sc->opt3 : 0;
p.isPKModeON = (sd) ? sd->status.karma : 0;
p.sex = vd->sex;
- WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl));
+ WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit->getdir(bl));
p.xSize = p.ySize = (sd) ? 5 : 0;
p.state = vd->dead_sit;
p.clevel = clif_setlevel(bl);
@@ -965,7 +965,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu
p.virtue = (sc) ? sc->opt3 : 0;
p.isPKModeON = (sd) ? sd->status.karma : 0;
p.sex = vd->sex;
- WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl));
+ WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit->getdir(bl));
p.xSize = p.ySize = (sd) ? 5 : 0;
p.state = vd->dead_sit;
p.clevel = clif_setlevel(bl);
@@ -1034,7 +1034,7 @@ void clif_spawn_unit2(struct block_list* bl, enum send_target target) {
p.headDir = (sd)? sd->head_dir : 0;
p.isPKModeON = (sd) ? sd->status.karma : 0;
p.sex = vd->sex;
- WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl));
+ WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit->getdir(bl));
p.xSize = p.ySize = (sd) ? 5 : 0;
clif->send(&p,sizeof(p),bl,target);
@@ -1092,7 +1092,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) {
p.virtue = (sc) ? sc->opt3 : 0;
p.isPKModeON = (sd) ? sd->status.karma : 0;
p.sex = vd->sex;
- WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit_getdir(bl));
+ WBUFPOS(&p.PosDir[0],0,bl->x,bl->y,unit->getdir(bl));
p.xSize = p.ySize = (sd) ? 5 : 0;
p.clevel = clif_setlevel(bl);
#if PACKETVER >= 20080102
@@ -1928,7 +1928,7 @@ void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes)
int slen = strlen(mes) + 9;
struct block_list *bl = NULL;
- if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m ||
+ if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
clif->sendfakenpc(sd, npcid);
@@ -1960,7 +1960,7 @@ void clif_scriptinput(struct map_session_data *sd, int npcid)
nullpo_retv(sd);
- if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m ||
+ if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
clif->sendfakenpc(sd, npcid);
@@ -1991,7 +1991,7 @@ void clif_scriptinputstr(struct map_session_data *sd, int npcid)
nullpo_retv(sd);
- if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m ||
+ if (!sd->state.using_fake_npc && (npcid == npc->fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m ||
bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1))))
clif->sendfakenpc(sd, npcid);
@@ -2326,7 +2326,7 @@ void clif_inventorylist(struct map_session_data *sd) {
if( sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL )
continue;
- if( !itemdb_isstackable2(sd->inventory_data[i]) )
+ if( !itemdb->isstackable2(sd->inventory_data[i]) )
{ //Non-stackable (Equippable)
WBUFW(bufe,ne*se+4)=i+2;
clif->item_sub(bufe, ne*se+6, &sd->status.inventory[i], sd->inventory_data[i], pc->equippoint(sd,i));
@@ -2415,7 +2415,7 @@ void clif_equiplist(struct map_session_data *sd)
if (sd->status.inventory[i].nameid <=0 || sd->inventory_data[i] == NULL)
continue;
- if(itemdb_isstackable2(sd->inventory_data[i]))
+ if(itemdb->isstackable2(sd->inventory_data[i]))
continue;
//Equippable
WBUFW(buf,n*cmd+4)=i+2;
@@ -2473,7 +2473,7 @@ void clif_storagelist(struct map_session_data* sd, struct item* items, int items
if( items[i].nameid <= 0 )
continue;
id = itemdb->search(items[i].nameid);
- if( !itemdb_isstackable2(id) )
+ if( !itemdb->isstackable2(id) )
{ //Equippable
WBUFW(bufe,ne*cmd+4)=i+1;
clif->item_sub(bufe, ne*cmd+6, &items[i], id, id->equip);
@@ -2553,7 +2553,7 @@ void clif_cartlist(struct map_session_data *sd)
if( sd->status.cart[i].nameid <= 0 )
continue;
id = itemdb->search(sd->status.cart[i].nameid);
- if( !itemdb_isstackable2(id) )
+ if( !itemdb->isstackable2(id) )
{ //Equippable
WBUFW(bufe,ne*cmd+4)=i+2;
clif->item_sub(bufe, ne*cmd+6, &sd->status.cart[i], id, id->equip);
@@ -4328,7 +4328,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) {
if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->option&OPTION_INVISIBLE))
return;
- if ( ( ud = unit_bl2ud(bl) ) && ud->walktimer != INVALID_TIMER )
+ if ( ( ud = unit->bl2ud(bl) ) && ud->walktimer != INVALID_TIMER )
clif->set_unit_walking(bl,sd,ud,SELF);
else
clif->set_unit_idle(bl,sd,SELF);
@@ -4512,7 +4512,7 @@ int clif_damage(struct block_list* src, struct block_list* dst, unsigned int tic
}
if(src == dst) {
- unit_setdir(src,unit_getdir(src));
+ unit->setdir(src,unit->getdir(src));
}
//Return adjusted can't walk delay for further processing.
return clif->calc_walkdelay(dst,ddelay,type,damage+damage2,div);
@@ -8904,8 +8904,8 @@ void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int cl
{
if( pcdb_checkid(class_) ) {
clif->starskill(sd, pc->job_name(class_), class_, hate_level, type ? 10 : 11);
- } else if( mobdb_checkid(class_) ) {
- clif->starskill(sd, mob_db(class_)->jname, class_, hate_level, type ? 10 : 11);
+ } else if( mob->db_checkid(class_) ) {
+ clif->starskill(sd, mob->db(class_)->jname, class_, hate_level, type ? 10 : 11);
} else {
ShowWarning("clif_hate_info: Received invalid class %d for this packet (char_id=%d, hate_level=%u, type=%u).\n", class_, sd->status.char_id, (unsigned int)hate_level, (unsigned int)type);
}
@@ -8916,7 +8916,7 @@ void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int cl
*------------------------------------------*/
void clif_mission_info(struct map_session_data *sd, int mob_id, unsigned char progress)
{
- clif->starskill(sd, mob_db(mob_id)->jname, mob_id, progress, 20);
+ clif->starskill(sd, mob->db(mob_id)->jname, mob_id, progress, 20);
}
/*==========================================
@@ -9012,7 +9012,7 @@ void clif_viewequip_ack(struct map_session_data* sd, struct map_session_data* ts
{
if (tsd->status.inventory[i].nameid <= 0 || tsd->inventory_data[i] == NULL) // Item doesn't exist
continue;
- if (!itemdb_isequip2(tsd->inventory_data[i])) // Is not equippable
+ if (!itemdb->isequip2(tsd->inventory_data[i])) // Is not equippable
continue;
// Inventory position
@@ -9444,7 +9444,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
if( sd->pd ) {
if( battle_config.pet_no_gvg && map_flag_gvg2(sd->bl.m) ) { //Return the pet to egg. [Skotlex]
clif->message(sd->fd, msg_txt(666));
- pet_menu(sd, 3); //Option 3 is return to egg.
+ pet->menu(sd, 3); //Option 3 is return to egg.
} else {
iMap->addblock(&sd->pd->bl);
clif->spawn(&sd->pd->bl);
@@ -9517,7 +9517,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
}
if(sd->pd && sd->pd->pet.intimate > 900)
- clif->pet_emotion(sd->pd,(sd->pd->pet.class_ - 100)*100 + 50 + pet_hungry_val(sd->pd));
+ clif->pet_emotion(sd->pd,(sd->pd->pet.class_ - 100)*100 + 50 + pet->hungry_val(sd->pd));
if(homun_alive(sd->hd))
homun->init_timers(sd->hd);
@@ -9531,7 +9531,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
iMap->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1);
//Login Event
- npc_script_event(sd, NPCE_LOGIN);
+ npc->script_event(sd, NPCE_LOGIN);
} else {
//For some reason the client "loses" these on warp/map-change.
clif->updatestatus(sd,SP_STR);
@@ -9547,7 +9547,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
sd->npc_menu = 0;
if(sd->npc_id)
- npc_event_dequeue(sd);
+ npc->event_dequeue(sd);
if( sd->guild && ( battle_config.guild_notice_changemap == 2 || ( battle_config.guild_notice_changemap == 1 && sd->state.changemap ) ) )
clif->guild_notice(sd,sd->guild);
@@ -9611,7 +9611,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
}
if(map[sd->bl.m].flag.loadevent) // Lance
- npc_script_event(sd, NPCE_LOADMAP);
+ npc->script_event(sd, NPCE_LOADMAP);
if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd)) //blindness [Komurka]
clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_DEVIL1);
@@ -9623,7 +9623,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) {
// For automatic triggering of NPCs after map loading (so you don't need to walk 1 step first)
if (iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC))
- npc_touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y);
+ npc->touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y);
else
sd->areanpc_id = 0;
@@ -9750,7 +9750,7 @@ void clif_parse_progressbar(int fd, struct map_session_data * sd)
sd->st->state = END;
sd->state.workinprogress = sd->progressbar.npc_id = sd->progressbar.timeout = 0;
- npc_scriptcont(sd, npc_id, false);
+ npc->scriptcont(sd, npc_id, false);
}
@@ -9784,7 +9784,7 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd)
//Set last idle time... [Skotlex]
sd->idletime = last_tick;
- unit_walktoxy(&sd->bl, x, y, 4);
+ unit->walktoxy(&sd->bl, x, y, 4);
}
@@ -9945,7 +9945,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
pc->disguise(sd,sd->status.class_);
if( pc_isdead(sd) )
clif_clearunit_single(-sd->bl.id, CLR_DEAD, sd->fd);
- if( unit_is_walking(&sd->bl) )
+ if( unit->is_walking(&sd->bl) )
clif->move(&sd->ud);
} else if ( sd->disguise == sd->status.class_ && sd->fontcolor_tid != INVALID_TIMER ) {
const struct TimerData *timer;
@@ -10000,7 +10000,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd)
WFIFOSET(fd, WFIFOW(fd,2));
#ifdef PCRE_SUPPORT
// trigger listening npcs
- iMap->foreachinrange(npc_chat_sub, &sd->bl, AREA_SIZE, BL_NPC, text, textlen, &sd->bl);
+ iMap->foreachinrange(npc_chat->sub, &sd->bl, AREA_SIZE, BL_NPC, text, textlen, &sd->bl);
#endif
// Chat logging type 'O' / Global Chat
@@ -10045,7 +10045,7 @@ void clif_changed_dir(struct block_list *bl, enum send_target target)
WBUFW(buf,0) = 0x9c;
WBUFL(buf,2) = bl->id;
WBUFW(buf,6) = bl->type==BL_PC?((TBL_PC*)bl)->head_dir:0;
- WBUFB(buf,8) = unit_getdir(bl);
+ WBUFB(buf,8) = unit->getdir(bl);
clif->send(buf, packet_len(0x9c), bl, target);
@@ -10169,7 +10169,7 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type,
pc->delinvincibletimer(sd);
sd->idletime = last_tick;
- unit_attack(&sd->bl, target_id, action_type != 0);
+ unit->attack(&sd->bl, target_id, action_type != 0);
break;
case 0x02: // sitdown
if (battle_config.basic_skill_check && pc->checkskill(sd, NV_BASIC) < 3) {
@@ -10401,8 +10401,8 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
//-------------------------------------------------------//
if (target[0] && (strncasecmp(target,"NPC:",4) == 0) && (strlen(target) > 4)) {
char* str = target+4; //Skip the NPC: string part.
- struct npc_data* npc;
- if ((npc = npc_name2id(str))) {
+ struct npc_data *nd;
+ if ((nd = npc->name2id(str))) {
char split_data[NUM_WHISPER_VAR][CHAT_SIZE_MAX];
char *split;
char output[256];
@@ -10429,8 +10429,8 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd)
script->set_var(sd,output,(char *) split_data[i]);
}
- sprintf(output, "%s::OnWhisperGlobal", npc->exname);
- npc_event(sd,output,0); // Calls the NPC label
+ sprintf(output, "%s::OnWhisperGlobal", nd->exname);
+ npc->event(sd,output,0); // Calls the NPC label
return;
}
@@ -10678,7 +10678,7 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd)
return;
if(sd->inventory_data[index]->type == IT_PETARMOR){
- pet_equipitem(sd,index);
+ pet->equipitem(sd,index);
return;
}
@@ -10837,7 +10837,7 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd)
break;
}
if( bl->m != -1 )// the user can't click floating npcs directly (hack attempt)
- npc_click(sd,(TBL_NPC*)bl);
+ npc->click(sd,(TBL_NPC*)bl);
break;
}
}
@@ -10852,7 +10852,7 @@ void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd)
{
if (sd->state.trading)
return;
- npc_buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6));
+ npc->buysellsel(sd,RFIFOL(fd,2),RFIFOB(fd,6));
}
@@ -10884,7 +10884,7 @@ void clif_parse_NpcBuyListSend(int fd, struct map_session_data* sd)
if( sd->state.trading || !sd->npc_shopid )
result = 1;
else
- result = npc_buylist(sd,n,item_list);
+ result = npc->buylist(sd,n,item_list);
sd->npc_shopid = 0; //Clear shop data.
@@ -10920,7 +10920,7 @@ void clif_parse_NpcSellListSend(int fd,struct map_session_data *sd)
if (sd->state.trading || !sd->npc_shopid)
fail = 1;
else
- fail = npc_selllist(sd,n,item_list);
+ fail = npc->selllist(sd,n,item_list);
sd->npc_shopid = 0; //Clear shop data.
@@ -10949,7 +10949,7 @@ void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd)
clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,3);
return;
}
- if( npc_isnear(&sd->bl) ) {
+ if( npc->isnear(&sd->bl) ) {
// uncomment for more verbose message.
//char output[150];
//sprintf(output, msg_txt(662), battle_config.min_npc_vendchat_distance);
@@ -11248,7 +11248,7 @@ void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_dat
if( skill_lv > lv )
skill_lv = lv;
if( skill_lv )
- unit_skilluse_id(&hd->bl, target_id, skill_id, skill_lv);
+ unit->skilluse_id(&hd->bl, target_id, skill_id, skill_lv);
}
void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo)
@@ -11269,7 +11269,7 @@ void clif_parse_UseSkillToPos_homun(struct homun_data *hd, struct map_session_da
if( skill_lv > lv )
skill_lv = lv;
if( skill_lv )
- unit_skilluse_pos(&hd->bl, x, y, skill_id, skill_lv);
+ unit->skilluse_pos(&hd->bl, x, y, skill_id, skill_lv);
}
void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id)
@@ -11291,7 +11291,7 @@ void clif_parse_UseSkillToId_mercenary(struct mercenary_data *md, struct map_ses
if( skill_lv > lv )
skill_lv = lv;
if( skill_lv )
- unit_skilluse_id(&md->bl, target_id, skill_id, skill_lv);
+ unit->skilluse_id(&md->bl, target_id, skill_id, skill_lv);
}
void clif_parse_UseSkillToPos_mercenary(struct mercenary_data *md, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, short x, short y, int skillmoreinfo)
@@ -11314,7 +11314,7 @@ void clif_parse_UseSkillToPos_mercenary(struct mercenary_data *md, struct map_se
if( skill_lv > lv )
skill_lv = lv;
if( skill_lv )
- unit_skilluse_pos(&md->bl, x, y, skill_id, skill_lv);
+ unit->skilluse_pos(&md->bl, x, y, skill_id, skill_lv);
}
@@ -11398,7 +11398,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
skill_lv = sd->skillitemlv;
if( !(tmp&INF_SELF_SKILL) )
pc->delinvincibletimer(sd); // Target skills thru items cancel invincibility. [Inkfish]
- unit_skilluse_id(&sd->bl, target_id, skill_id, skill_lv);
+ unit->skilluse_id(&sd->bl, target_id, skill_id, skill_lv);
return;
}
@@ -11418,7 +11418,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
pc->delinvincibletimer(sd);
if( skill_lv )
- unit_skilluse_id(&sd->bl, target_id, skill_id, skill_lv);
+ unit->skilluse_id(&sd->bl, target_id, skill_id, skill_lv);
}
/*==========================================
@@ -11490,14 +11490,14 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski
if( sd->skillitem == skill_id ) {
if( skill_lv != sd->skillitemlv )
skill_lv = sd->skillitemlv;
- unit_skilluse_pos(&sd->bl, x, y, skill_id, skill_lv);
+ unit->skilluse_pos(&sd->bl, x, y, skill_id, skill_lv);
} else {
int lv;
sd->skillitem = sd->skillitemlv = 0;
if( (lv = pc->checkskill(sd, skill_id)) > 0 ) {
if( skill_lv > lv )
skill_lv = lv;
- unit_skilluse_pos(&sd->bl, x, y, skill_id,skill_lv);
+ unit->skilluse_pos(&sd->bl, x, y, skill_id,skill_lv);
}
}
}
@@ -11695,7 +11695,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
}
sd->npc_menu = select;
- npc_scriptcont(sd,npc_id, false);
+ npc->scriptcont(sd,npc_id, false);
}
@@ -11703,7 +11703,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd)
/// 00b9 <npc id>.L
void clif_parse_NpcNextClicked(int fd,struct map_session_data *sd)
{
- npc_scriptcont(sd,RFIFOL(fd,2), false);
+ npc->scriptcont(sd,RFIFOL(fd,2), false);
}
@@ -11715,7 +11715,7 @@ void clif_parse_NpcAmountInput(int fd,struct map_session_data *sd)
int amount = (int)RFIFOL(fd,6);
sd->npc_amount = amount;
- npc_scriptcont(sd, npcid, false);
+ npc->scriptcont(sd, npcid, false);
}
@@ -11731,7 +11731,7 @@ void clif_parse_NpcStringInput(int fd, struct map_session_data* sd)
return; // invalid input
safestrncpy(sd->npc_str, message, min(message_len,CHATBOX_SIZE));
- npc_scriptcont(sd, npcid, false);
+ npc->scriptcont(sd, npcid, false);
}
@@ -11741,7 +11741,7 @@ void clif_parse_NpcCloseClicked(int fd,struct map_session_data *sd)
{
if (!sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex]
return;
- npc_scriptcont(sd, RFIFOL(fd,2), true);
+ npc->scriptcont(sd, RFIFOL(fd,2), true);
}
@@ -13047,7 +13047,7 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd)
}
if( sd->bg_id )
- bg_send_message(sd, text, textlen);
+ bg->send_message(sd, text, textlen);
else
guild->send_message(sd, text, textlen);
}
@@ -13162,7 +13162,7 @@ void clif_parse_GuildBreak(int fd, struct map_session_data *sd)
/// 4 = unequip accessory
void clif_parse_PetMenu(int fd, struct map_session_data *sd)
{
- pet_menu(sd,RFIFOB(fd,2));
+ pet->menu(sd,RFIFOB(fd,2));
}
@@ -13170,7 +13170,7 @@ void clif_parse_PetMenu(int fd, struct map_session_data *sd)
/// 019f <id>.L
void clif_parse_CatchPet(int fd, struct map_session_data *sd)
{
- pet_catch_process2(sd,RFIFOL(fd,2));
+ pet->catch_process2(sd,RFIFOL(fd,2));
}
@@ -13183,7 +13183,7 @@ void clif_parse_SelectEgg(int fd, struct map_session_data *sd)
clif->authfail_fd(fd, 0);
return;
}
- pet_select_egg(sd,RFIFOW(fd,2)-2);
+ pet->select_egg(sd,RFIFOW(fd,2)-2);
clif_menuskill_clear(sd);
}
@@ -13223,7 +13223,7 @@ void clif_parse_SendEmotion(int fd, struct map_session_data *sd)
/// 01a5 <name>.24B
void clif_parse_ChangePetName(int fd, struct map_session_data *sd)
{
- pet_change_name(sd,(char*)RFIFOP(fd,2));
+ pet->change_name(sd,(char*)RFIFOP(fd,2));
}
@@ -13275,9 +13275,9 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd)
clif->GM_kickack(sd, 0);
return;
}
- npc_unload_duplicates(nd);
- npc_unload(nd,true);
- npc_read_event_script();
+ npc->unload_duplicates(nd);
+ npc->unload(nd,true);
+ npc->read_event_script();
}
break;
@@ -13416,7 +13416,7 @@ void clif_parse_GM_Monster_Item(int fd, struct map_session_data *sd)
return;
}
- if( (count=mobdb_searchname_array(mob_array, 10, item_monster_name, 1)) > 0){
+ if( (count=mob->db_searchname_array(mob_array, 10, item_monster_name, 1)) > 0){
for(i = 0; i < count; i++){
if( mob_array[i] && strcmp(mob_array[i]->sprite, item_monster_name) == 0 ) // It only accepts sprite name
break;
@@ -14378,9 +14378,9 @@ void clif_parse_HomMoveToMaster(int fd, struct map_session_data *sd)
else
return;
- unit_calc_pos(bl, sd->bl.x, sd->bl.y, sd->ud.dir);
- ud = unit_bl2ud(bl);
- unit_walktoxy(bl, ud->to_x, ud->to_y, 4);
+ unit->calc_pos(bl, sd->bl.x, sd->bl.y, sd->ud.dir);
+ ud = unit->bl2ud(bl);
+ unit->walktoxy(bl, ud->to_x, ud->to_y, 4);
}
@@ -14401,7 +14401,7 @@ void clif_parse_HomMoveTo(int fd, struct map_session_data *sd)
else
return;
- unit_walktoxy(bl, x, y, 4);
+ unit->walktoxy(bl, x, y, 4);
}
@@ -14422,8 +14422,8 @@ void clif_parse_HomAttack(int fd,struct map_session_data *sd)
bl = &sd->md->bl;
else return;
- unit_stop_attack(bl);
- unit_attack(bl, target_id, action_type != 0);
+ unit->stop_attack(bl);
+ unit->attack(bl, target_id, action_type != 0);
}
@@ -15389,7 +15389,7 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd)
short amount = RFIFOW(fd,4);
int points = RFIFOL(fd,6);
- fail = npc_cashshop_buy(sd, nameid, amount, points);
+ fail = npc->cashshop_buy(sd, nameid, amount, points);
#else
int len = RFIFOW(fd,2);
int points = RFIFOL(fd,4);
@@ -15401,7 +15401,7 @@ void clif_parse_cashshop_buy(int fd, struct map_session_data *sd)
ShowWarning("Player %u sent incorrect cash shop buy packet (len %u:%u)!\n", sd->status.char_id, len, 10 + count * 4);
return;
}
- fail = npc_cashshop_buylist(sd,points,count,item_list);
+ fail = npc->cashshop_buylist(sd,points,count,item_list);
#endif
}
@@ -15601,7 +15601,7 @@ void clif_quest_send_mission(struct map_session_data * sd)
int fd = sd->fd;
int i, j;
int len = sd->avail_quests*104+8;
- struct mob_db *mob;
+ struct mob_db *monster;
WFIFOHEAD(fd, len);
WFIFOW(fd, 0) = 0x2b2;
@@ -15610,16 +15610,16 @@ void clif_quest_send_mission(struct map_session_data * sd)
for( i = 0; i < sd->avail_quests; i++ ) {
WFIFOL(fd, i*104+8) = sd->quest_log[i].quest_id;
- WFIFOL(fd, i*104+12) = sd->quest_log[i].time - quest_db[sd->quest_index[i]].time;
+ WFIFOL(fd, i*104+12) = sd->quest_log[i].time - quest->db[sd->quest_index[i]].time;
WFIFOL(fd, i*104+16) = sd->quest_log[i].time;
- WFIFOW(fd, i*104+20) = quest_db[sd->quest_index[i]].num_objectives;
+ WFIFOW(fd, i*104+20) = quest->db[sd->quest_index[i]].num_objectives;
- for( j = 0 ; j < quest_db[sd->quest_index[i]].num_objectives; j++ )
+ for( j = 0 ; j < quest->db[sd->quest_index[i]].num_objectives; j++ )
{
- WFIFOL(fd, i*104+22+j*30) = quest_db[sd->quest_index[i]].mob[j];
+ WFIFOL(fd, i*104+22+j*30) = quest->db[sd->quest_index[i]].mob[j];
WFIFOW(fd, i*104+26+j*30) = sd->quest_log[i].count[j];
- mob = mob_db(quest_db[sd->quest_index[i]].mob[j]);
- memcpy(WFIFOP(fd, i*104+28+j*30), mob?mob->jname:"NULL", NAME_LENGTH);
+ monster = mob->db(quest->db[sd->quest_index[i]].mob[j]);
+ memcpy(WFIFOP(fd, i*104+28+j*30), monster?monster->jname:"NULL", NAME_LENGTH);
}
}
@@ -15633,21 +15633,21 @@ void clif_quest_add(struct map_session_data * sd, struct quest * qd, int index)
{
int fd = sd->fd;
int i;
- struct mob_db *mob;
+ struct mob_db *monster;
WFIFOHEAD(fd, packet_len(0x2b3));
WFIFOW(fd, 0) = 0x2b3;
WFIFOL(fd, 2) = qd->quest_id;
WFIFOB(fd, 6) = qd->state;
- WFIFOB(fd, 7) = qd->time - quest_db[index].time;
+ WFIFOB(fd, 7) = qd->time - quest->db[index].time;
WFIFOL(fd, 11) = qd->time;
- WFIFOW(fd, 15) = quest_db[index].num_objectives;
+ WFIFOW(fd, 15) = quest->db[index].num_objectives;
- for( i = 0; i < quest_db[index].num_objectives; i++ ) {
- WFIFOL(fd, i*30+17) = quest_db[index].mob[i];
+ for( i = 0; i < quest->db[index].num_objectives; i++ ) {
+ WFIFOL(fd, i*30+17) = quest->db[index].mob[i];
WFIFOW(fd, i*30+21) = qd->count[i];
- mob = mob_db(quest_db[index].mob[i]);
- memcpy(WFIFOP(fd, i*30+23), mob?mob->jname:"NULL", NAME_LENGTH);
+ monster = mob->db(quest->db[index].mob[i]);
+ memcpy(WFIFOP(fd, i*30+23), monster?monster->jname:"NULL", NAME_LENGTH);
}
WFIFOSET(fd, packet_len(0x2b3));
@@ -15673,17 +15673,17 @@ void clif_quest_update_objective(struct map_session_data * sd, struct quest * qd
{
int fd = sd->fd;
int i;
- int len = quest_db[index].num_objectives*12+6;
+ int len = quest->db[index].num_objectives*12+6;
WFIFOHEAD(fd, len);
WFIFOW(fd, 0) = 0x2b5;
WFIFOW(fd, 2) = len;
- WFIFOW(fd, 4) = quest_db[index].num_objectives;
+ WFIFOW(fd, 4) = quest->db[index].num_objectives;
- for( i = 0; i < quest_db[index].num_objectives; i++ ) {
+ for( i = 0; i < quest->db[index].num_objectives; i++ ) {
WFIFOL(fd, i*12+6) = qd->quest_id;
- WFIFOL(fd, i*12+10) = quest_db[index].mob[i];
- WFIFOW(fd, i*12+14) = quest_db[index].count[i];
+ WFIFOL(fd, i*12+10) = quest->db[index].mob[i];
+ WFIFOW(fd, i*12+14) = quest->db[index].count[i];
WFIFOW(fd, i*12+16) = qd->count[i];
}
@@ -15695,7 +15695,7 @@ void clif_quest_update_objective(struct map_session_data * sd, struct quest * qd
/// 02b6 <quest id>.L <active>.B
void clif_parse_questStateAck(int fd, struct map_session_data * sd)
{
- quest_update_status(sd, RFIFOL(fd,2), RFIFOB(fd,6)?Q_ACTIVE:Q_INACTIVE);
+ quest->update_status(sd, RFIFOL(fd,2), RFIFOB(fd,6)?Q_ACTIVE:Q_INACTIVE);
}
@@ -16016,11 +16016,11 @@ void clif_bg_xy_remove(struct map_session_data *sd)
/// Notifies clients of a battleground message (ZC_BATTLEFIELD_CHAT).
/// 02dc <packet len>.W <account id>.L <name>.24B <message>.?B
-void clif_bg_message(struct battleground_data *bg, int src_id, const char *name, const char *mes, int len)
+void clif_bg_message(struct battleground_data *bgd, int src_id, const char *name, const char *mes, int len)
{
struct map_session_data *sd;
unsigned char *buf;
- if( !bg->count || (sd = bg_getavailablesd(bg)) == NULL )
+ if( !bgd->count || (sd = bg->getavailablesd(bgd)) == NULL )
return;
buf = (unsigned char*)aMalloc((len + NAME_LENGTH + 8)*sizeof(unsigned char));
@@ -16062,7 +16062,7 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd)
sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay;
}
- bg_send_message(sd, text, textlen);
+ bg->send_message(sd, text, textlen);
}
@@ -17410,12 +17410,12 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
get_count = qty;
- if (!itemdb_isstackable2(data))
+ if (!itemdb->isstackable2(data))
get_count = 1;
pc->paycash(sd, clif->cs.data[tab][j]->price * qty, kafra_pay);// [Ryuuzaki]
for (k = 0; k < qty; k += get_count) {
- if (!pet_create_egg(sd, data->nameid)) {
+ if (!pet->create_egg(sd, data->nameid)) {
memset(&item_tmp, 0, sizeof(item_tmp));
item_tmp.nameid = data->nameid;
item_tmp.identify = 1;
diff --git a/src/map/clif.h b/src/map/clif.h
index 3a42b54da..b364765e5 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -836,7 +836,7 @@ struct clif_interface {
void (*bg_hp) (struct map_session_data *sd);
void (*bg_xy) (struct map_session_data *sd);
void (*bg_xy_remove) (struct map_session_data *sd);
- void (*bg_message) (struct battleground_data *bg, int src_id, const char *name, const char *mes, int len);
+ void (*bg_message) (struct battleground_data *bgd, int src_id, const char *name, const char *mes, int len);
void (*bg_updatescore) (int16 m);
void (*bg_updatescore_single) (struct map_session_data *sd);
void (*sendbgemblem_area) (struct map_session_data *sd);
diff --git a/src/map/duel.c b/src/map/duel.c
index a04ed855b..c3b241e9e 100644
--- a/src/map/duel.c
+++ b/src/map/duel.c
@@ -1,204 +1,204 @@
-// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
-// See the LICENSE file
-// Portions Copyright (c) Athena Dev Teams
-
-#include "../common/cbasetypes.h"
-
-#include "atcommand.h" // msg_txt
-#include "clif.h"
-#include "duel.h"
-#include "pc.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-/*==========================================
- * Duel organizing functions [LuzZza]
- *------------------------------------------*/
-void duel_savetime(struct map_session_data* sd)
-{
- time_t timer;
- struct tm *t;
-
- time(&timer);
- t = localtime(&timer);
-
- pc_setglobalreg(sd, "PC_LAST_DUEL_TIME", t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
-}
-
-int duel_checktime(struct map_session_data* sd)
-{
- int diff;
- time_t timer;
- struct tm *t;
-
- time(&timer);
- t = localtime(&timer);
-
- diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min - pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
-
- return !(diff >= 0 && diff < battle_config.duel_time_interval);
-}
-static int duel_showinfo_sub(struct map_session_data* sd, va_list va)
-{
- struct map_session_data *ssd = va_arg(va, struct map_session_data*);
- int *p = va_arg(va, int*);
- char output[256];
-
- if (sd->duel_group != ssd->duel_group) return 0;
-
- sprintf(output, " %d. %s", ++(*p), sd->status.name);
- clif->disp_onlyself(ssd, output, strlen(output));
- return 1;
-}
-
-void duel_showinfo(const unsigned int did, struct map_session_data* sd)
-{
- int p=0;
- char output[256];
-
- if(iDuel->duel_list[did].max_players_limit > 0)
- sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
- did, iDuel->duel_count,
- iDuel->duel_list[did].members_count,
- iDuel->duel_list[did].members_count + iDuel->duel_list[did].invites_count,
- iDuel->duel_list[did].max_players_limit);
- else
- sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
- did, iDuel->duel_count,
- iDuel->duel_list[did].members_count,
- iDuel->duel_list[did].members_count + iDuel->duel_list[did].invites_count);
-
- clif->disp_onlyself(sd, output, strlen(output));
- iMap->map_foreachpc(duel_showinfo_sub, sd, &p);
-}
-
-int duel_create(struct map_session_data* sd, const unsigned int maxpl)
-{
- int i=1;
- char output[256];
-
- while(iDuel->duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
- if(i == MAX_DUEL) return 0;
-
- iDuel->duel_count++;
- sd->duel_group = i;
- iDuel->duel_list[i].members_count++;
- iDuel->duel_list[i].invites_count = 0;
- iDuel->duel_list[i].max_players_limit = maxpl;
-
- strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
- clif->disp_onlyself(sd, output, strlen(output));
-
- clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
- clif->maptypeproperty2(&sd->bl,SELF);
- return i;
-}
-
-void duel_invite(const unsigned int did, struct map_session_data* sd, struct map_session_data* target_sd)
-{
- char output[256];
-
- // " -- Player %s invites %s to duel --"
- sprintf(output, msg_txt(373), sd->status.name, target_sd->status.name);
- clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
-
- target_sd->duel_invite = did;
- iDuel->duel_list[did].invites_count++;
-
- // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
- sprintf(output, msg_txt(374), sd->status.name);
- clif->broadcast((struct block_list *)target_sd, output, strlen(output)+1, BC_BLUE, SELF);
-}
-
-static int duel_leave_sub(struct map_session_data* sd, va_list va)
-{
- int did = va_arg(va, int);
- if (sd->duel_invite == did)
- sd->duel_invite = 0;
- return 0;
-}
-
-void duel_leave(const unsigned int did, struct map_session_data* sd)
-{
- char output[256];
-
- // " <- Player %s has left duel --"
- sprintf(output, msg_txt(375), sd->status.name);
- clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
-
- iDuel->duel_list[did].members_count--;
-
- if(iDuel->duel_list[did].members_count == 0) {
- iMap->map_foreachpc(duel_leave_sub, did);
- iDuel->duel_count--;
- }
-
- sd->duel_group = 0;
- duel_savetime(sd);
- clif->map_property(sd, MAPPROPERTY_NOTHING);
- clif->maptypeproperty2(&sd->bl,SELF);
-}
-
-void duel_accept(const unsigned int did, struct map_session_data* sd)
-{
- char output[256];
-
- iDuel->duel_list[did].members_count++;
- sd->duel_group = sd->duel_invite;
- iDuel->duel_list[did].invites_count--;
- sd->duel_invite = 0;
-
- // " -> Player %s has accepted duel --"
- sprintf(output, msg_txt(376), sd->status.name);
- clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
-
- clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
- clif->maptypeproperty2(&sd->bl,SELF);
-}
-
-void duel_reject(const unsigned int did, struct map_session_data* sd)
-{
- char output[256];
-
- // " -- Player %s has rejected duel --"
- sprintf(output, msg_txt(377), sd->status.name);
- clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
-
- iDuel->duel_list[did].invites_count--;
- sd->duel_invite = 0;
-}
-
-void do_final_duel(void)
-{
-}
-
-void do_init_duel(void)
-{
- memset(&iDuel->duel_list[0], 0, sizeof(iDuel->duel_list));
-}
-
-/*=====================================
-* Default Functions : duel.h
-* Generated by HerculesInterfaceMaker
-* created by Susu
-*-------------------------------------*/
-void iDuel_defaults(void) {
- iDuel = &iDuel_s;
- /* vars */
- iDuel->duel_count = 0;
- /* funcs */
- //Duel functions // [LuzZza]
- iDuel->create = duel_create;
- iDuel->invite = duel_invite;
- iDuel->accept = duel_accept;
- iDuel->reject = duel_reject;
- iDuel->leave = duel_leave;
- iDuel->showinfo = duel_showinfo;
- iDuel->checktime = duel_checktime;
-
- iDuel->do_init_duel = do_init_duel;
- iDuel->do_final_duel = do_final_duel;
-}
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
+
+#include "../common/cbasetypes.h"
+
+#include "atcommand.h" // msg_txt
+#include "clif.h"
+#include "duel.h"
+#include "pc.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+/*==========================================
+ * Duel organizing functions [LuzZza]
+ *------------------------------------------*/
+void duel_savetime(struct map_session_data* sd)
+{
+ time_t timer;
+ struct tm *t;
+
+ time(&timer);
+ t = localtime(&timer);
+
+ pc_setglobalreg(sd, "PC_LAST_DUEL_TIME", t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min);
+}
+
+int duel_checktime(struct map_session_data* sd)
+{
+ int diff;
+ time_t timer;
+ struct tm *t;
+
+ time(&timer);
+ t = localtime(&timer);
+
+ diff = t->tm_mday*24*60 + t->tm_hour*60 + t->tm_min - pc_readglobalreg(sd, "PC_LAST_DUEL_TIME");
+
+ return !(diff >= 0 && diff < battle_config.duel_time_interval);
+}
+static int duel_showinfo_sub(struct map_session_data* sd, va_list va)
+{
+ struct map_session_data *ssd = va_arg(va, struct map_session_data*);
+ int *p = va_arg(va, int*);
+ char output[256];
+
+ if (sd->duel_group != ssd->duel_group) return 0;
+
+ sprintf(output, " %d. %s", ++(*p), sd->status.name);
+ clif->disp_onlyself(ssd, output, strlen(output));
+ return 1;
+}
+
+void duel_showinfo(const unsigned int did, struct map_session_data* sd)
+{
+ int p=0;
+ char output[256];
+
+ if(iDuel->duel_list[did].max_players_limit > 0)
+ sprintf(output, msg_txt(370), //" -- Duels: %d/%d, Members: %d/%d, Max players: %d --"
+ did, iDuel->duel_count,
+ iDuel->duel_list[did].members_count,
+ iDuel->duel_list[did].members_count + iDuel->duel_list[did].invites_count,
+ iDuel->duel_list[did].max_players_limit);
+ else
+ sprintf(output, msg_txt(371), //" -- Duels: %d/%d, Members: %d/%d --"
+ did, iDuel->duel_count,
+ iDuel->duel_list[did].members_count,
+ iDuel->duel_list[did].members_count + iDuel->duel_list[did].invites_count);
+
+ clif->disp_onlyself(sd, output, strlen(output));
+ iMap->map_foreachpc(duel_showinfo_sub, sd, &p);
+}
+
+int duel_create(struct map_session_data* sd, const unsigned int maxpl)
+{
+ int i=1;
+ char output[256];
+
+ while(iDuel->duel_list[i].members_count > 0 && i < MAX_DUEL) i++;
+ if(i == MAX_DUEL) return 0;
+
+ iDuel->duel_count++;
+ sd->duel_group = i;
+ iDuel->duel_list[i].members_count++;
+ iDuel->duel_list[i].invites_count = 0;
+ iDuel->duel_list[i].max_players_limit = maxpl;
+
+ strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --"
+ clif->disp_onlyself(sd, output, strlen(output));
+
+ clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
+ clif->maptypeproperty2(&sd->bl,SELF);
+ return i;
+}
+
+void duel_invite(const unsigned int did, struct map_session_data* sd, struct map_session_data* target_sd)
+{
+ char output[256];
+
+ // " -- Player %s invites %s to duel --"
+ sprintf(output, msg_txt(373), sd->status.name, target_sd->status.name);
+ clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
+
+ target_sd->duel_invite = did;
+ iDuel->duel_list[did].invites_count++;
+
+ // "Blue -- Player %s invites you to PVP duel (@accept/@reject) --"
+ sprintf(output, msg_txt(374), sd->status.name);
+ clif->broadcast((struct block_list *)target_sd, output, strlen(output)+1, BC_BLUE, SELF);
+}
+
+static int duel_leave_sub(struct map_session_data* sd, va_list va)
+{
+ int did = va_arg(va, int);
+ if (sd->duel_invite == did)
+ sd->duel_invite = 0;
+ return 0;
+}
+
+void duel_leave(const unsigned int did, struct map_session_data* sd)
+{
+ char output[256];
+
+ // " <- Player %s has left duel --"
+ sprintf(output, msg_txt(375), sd->status.name);
+ clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
+
+ iDuel->duel_list[did].members_count--;
+
+ if(iDuel->duel_list[did].members_count == 0) {
+ iMap->map_foreachpc(duel_leave_sub, did);
+ iDuel->duel_count--;
+ }
+
+ sd->duel_group = 0;
+ duel_savetime(sd);
+ clif->map_property(sd, MAPPROPERTY_NOTHING);
+ clif->maptypeproperty2(&sd->bl,SELF);
+}
+
+void duel_accept(const unsigned int did, struct map_session_data* sd)
+{
+ char output[256];
+
+ iDuel->duel_list[did].members_count++;
+ sd->duel_group = sd->duel_invite;
+ iDuel->duel_list[did].invites_count--;
+ sd->duel_invite = 0;
+
+ // " -> Player %s has accepted duel --"
+ sprintf(output, msg_txt(376), sd->status.name);
+ clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
+
+ clif->map_property(sd, MAPPROPERTY_FREEPVPZONE);
+ clif->maptypeproperty2(&sd->bl,SELF);
+}
+
+void duel_reject(const unsigned int did, struct map_session_data* sd)
+{
+ char output[256];
+
+ // " -- Player %s has rejected duel --"
+ sprintf(output, msg_txt(377), sd->status.name);
+ clif->disp_message(&sd->bl, output, strlen(output), DUEL_WOS);
+
+ iDuel->duel_list[did].invites_count--;
+ sd->duel_invite = 0;
+}
+
+void do_final_duel(void)
+{
+}
+
+void do_init_duel(void)
+{
+ memset(&iDuel->duel_list[0], 0, sizeof(iDuel->duel_list));
+}
+
+/*=====================================
+* Default Functions : duel.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+void iDuel_defaults(void) {
+ iDuel = &iDuel_s;
+ /* vars */
+ iDuel->duel_count = 0;
+ /* funcs */
+ //Duel functions // [LuzZza]
+ iDuel->create = duel_create;
+ iDuel->invite = duel_invite;
+ iDuel->accept = duel_accept;
+ iDuel->reject = duel_reject;
+ iDuel->leave = duel_leave;
+ iDuel->showinfo = duel_showinfo;
+ iDuel->checktime = duel_checktime;
+
+ iDuel->do_init_duel = do_init_duel;
+ iDuel->do_final_duel = do_final_duel;
+}
diff --git a/src/map/elemental.c b/src/map/elemental.c
index 03aa93e49..855d9e2c6 100644
--- a/src/map/elemental.c
+++ b/src/map/elemental.c
@@ -1,984 +1,985 @@
-// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
-// See the LICENSE file
-// Portions Copyright (c) Athena Dev Teams
-
-#include "../common/cbasetypes.h"
-#include "../common/malloc.h"
-#include "../common/socket.h"
-#include "../common/timer.h"
-#include "../common/nullpo.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-#include "../common/utils.h"
-#include "../common/random.h"
-#include "../common/strlib.h"
-
-#include "log.h"
-#include "clif.h"
-#include "chrif.h"
-#include "intif.h"
-#include "itemdb.h"
-#include "map.h"
-#include "pc.h"
-#include "status.h"
-#include "skill.h"
-#include "mob.h"
-#include "pet.h"
-#include "battle.h"
-#include "party.h"
-#include "guild.h"
-#include "atcommand.h"
-#include "script.h"
-#include "npc.h"
-#include "trade.h"
-#include "unit.h"
-#include "elemental.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-int elemental_search_index(int class_) {
- int i;
- ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, elemental->elemental_db[i].class_ == class_);
- return (i == MAX_ELEMENTAL_CLASS)?-1:i;
-}
-
-bool elemental_class(int class_) {
- return (bool)(elemental_search_index(class_) > -1);
-}
-
-struct view_data * elemental_get_viewdata(int class_) {
- int i = elemental_search_index(class_);
- if( i < 0 )
- return 0;
-
- return &elemental->elemental_db[i].vd;
-}
-
-int elemental_create(struct map_session_data *sd, int class_, unsigned int lifetime) {
- struct s_elemental ele;
- struct s_elemental_db *db;
- int i;
-
- nullpo_retr(1,sd);
-
- if( (i = elemental_search_index(class_)) < 0 )
- return 0;
-
- db = &elemental->elemental_db[i];
- memset(&ele,0,sizeof(struct s_elemental));
-
- ele.char_id = sd->status.char_id;
- ele.class_ = class_;
- ele.mode = EL_MODE_PASSIVE; // Initial mode
- i = db->status.size+1; // summon level
-
- //[(Casterソスs Max HP/ 3 ) + (Casterソスs INT x 10 )+ (Casterソスs Job Level x 20 )] x [(Elemental Summon Level + 2) / 3]
- ele.hp = ele.max_hp = (sd->battle_status.max_hp/3 + sd->battle_status.int_*10 + sd->status.job_level) * ((i + 2) / 3);
- //Casterソスs Max SP /4
- ele.sp = ele.max_sp = sd->battle_status.max_sp/4;
- //Casterソスs [ Max SP / (18 / Elemental Summon Skill Level) 1- 100 ]
- ele.atk = (sd->battle_status.max_sp / (18 / i) * 1 - 100);
- //Casterソスs [ Max SP / (18 / Elemental Summon Skill Level) ]
- ele.atk2 = sd->battle_status.max_sp / 18;
- //Casterソスs HIT + (Casterソスs Base Level )
- ele.hit = sd->battle_status.hit + sd->status.base_level;
- //[Elemental Summon Skill Level x (Casterソスs INT / 2 + Casterソスs DEX / 4)]
- ele.matk = i * (sd->battle_status.int_ / 2 + sd->battle_status.dex / 4);
- //150 + [Casterソスs DEX / 10] + [Elemental Summon Skill Level x 3 ]
- ele.amotion = 150 + sd->battle_status.dex / 10 + i * 3;
- //Casterソスs DEF + (Casterソスs Base Level / (5 ソス Elemental Summon Skill Level)
- ele.def = sd->battle_status.def + sd->status.base_level / (5-i);
- //Casterソスs MDEF + (Casterソスs INT / (5 - Elemental Summon Skill Level)
- ele.mdef = sd->battle_status.mdef + sd->battle_status.int_ / (5-i);
- //Casterソスs FLEE + (Casterソスs Base Level / (5 ソス Elemental Summon Skill Level)
- ele.flee = sd->status.base_level / (5-i);
- //Casterソスs HIT + (Casterソスs Base Level )
- ele.hit = sd->battle_status.hit + sd->status.base_level;
-
- //per individual bonuses
- switch(db->class_){
- case 2114: case 2115:
- case 2116: //ATK + (Summon Agni Skill Level x 20) / HIT + (Summon Agni Skill Level x 10)
- ele.atk += i * 20;
- ele.atk2 += i * 20;
- ele.hit += i * 10;
- break;
- case 2117: case 2118:
- case 2119: //MDEF + (Summon Aqua Skill Level x 10) / MATK + (Summon Aqua Skill Level x 20)
- ele.mdef += i * 10;
- ele.matk += i * 20;
- break;
- case 2120: case 2121:
- case 2122: //FLEE + (Summon Ventus Skill Level x 20) / MATK + (Summon Ventus Skill Level x 10)
- ele.flee += i * 20;
- ele.matk += i * 10;
- break;
- case 2123: case 2124:
- case 2125: //DEF + (Summon Tera Skill Level x 25) / ATK + (Summon Tera Skill Level x 5)
- ele.def += i * 25;
- ele.atk += i * 5;
- ele.atk2 += i * 5;
- break;
- }
-
- if( (i=pc->checkskill(sd,SO_EL_SYMPATHY)) > 0 ){
- ele.hp = ele.max_hp = ele.max_hp * 5 * i / 100;
- ele.sp = ele.max_sp = ele.max_sp * 5 * i / 100;
- ele.atk += 25 * i;
- ele.atk2 += 25 * i;
- ele.matk += 25 * i;
- }
-
- ele.life_time = lifetime;
-
- // Request Char Server to create this elemental
- intif->elemental_create(&ele);
-
- return 1;
-}
-
-int elemental_get_lifetime(struct elemental_data *ed) {
- const struct TimerData * td;
- if( ed == NULL || ed->summon_timer == INVALID_TIMER )
- return 0;
-
- td = iTimer->get_timer(ed->summon_timer);
- return (td != NULL) ? DIFF_TICK(td->tick, iTimer->gettick()) : 0;
-}
-
-int elemental_save(struct elemental_data *ed) {
- ed->elemental.mode = ed->battle_status.mode;
- ed->elemental.hp = ed->battle_status.hp;
- ed->elemental.sp = ed->battle_status.sp;
- ed->elemental.max_hp = ed->battle_status.max_hp;
- ed->elemental.max_sp = ed->battle_status.max_sp;
- ed->elemental.atk = ed->battle_status.rhw.atk;
- ed->elemental.atk2 = ed->battle_status.rhw.atk2;
- ed->elemental.matk = ed->battle_status.matk_min;
- ed->elemental.def = ed->battle_status.def;
- ed->elemental.mdef = ed->battle_status.mdef;
- ed->elemental.flee = ed->battle_status.flee;
- ed->elemental.hit = ed->battle_status.hit;
- ed->elemental.life_time = elemental->get_lifetime(ed);
- intif->elemental_save(&ed->elemental);
- return 1;
-}
-
-static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t data) {
- struct map_session_data *sd;
- struct elemental_data *ed;
-
- if( (sd = iMap->id2sd(id)) == NULL )
- return 1;
- if( (ed = sd->ed) == NULL )
- return 1;
-
- if( ed->summon_timer != tid ) {
- ShowError("elemental_summon_end %d != %d.\n", ed->summon_timer, tid);
- return 0;
- }
-
- ed->summon_timer = INVALID_TIMER;
- elemental->delete(ed, 0); // Elemental's summon time is over.
-
- return 0;
-}
-
-void elemental_summon_stop(struct elemental_data *ed) {
- nullpo_retv(ed);
- if( ed->summon_timer != INVALID_TIMER )
- iTimer->delete_timer(ed->summon_timer, elemental_summon_end);
- ed->summon_timer = INVALID_TIMER;
-}
-
-int elemental_delete(struct elemental_data *ed, int reply) {
- struct map_session_data *sd;
- nullpo_ret(ed);
-
- sd = ed->master;
- ed->elemental.life_time = 0;
-
- elemental->clean_effect(ed);
- elemental->summon_stop(ed);
-
- if( !sd )
- return unit_free(&ed->bl, 0);
-
- sd->ed = NULL;
- sd->status.ele_id = 0;
-
- return unit_remove_map(&ed->bl, 0);
-}
-
-void elemental_summon_init(struct elemental_data *ed) {
- if( ed->summon_timer == INVALID_TIMER )
- ed->summon_timer = iTimer->add_timer(iTimer->gettick() + ed->elemental.life_time, elemental_summon_end, ed->master->bl.id, 0);
-
- ed->regen.state.block = 0;
-}
-
-int elemental_data_received(struct s_elemental *ele, bool flag) {
- struct map_session_data *sd;
- struct elemental_data *ed;
- struct s_elemental_db *db;
- int i = elemental_search_index(ele->class_);
-
- if( (sd = iMap->charid2sd(ele->char_id)) == NULL )
- return 0;
-
- if( !flag || i < 0 ) { // Not created - loaded - DB info
- sd->status.ele_id = 0;
- return 0;
- }
-
- db = &elemental->elemental_db[i];
- if( !sd->ed ) { // Initialize it after first summon.
- sd->ed = ed = (struct elemental_data*)aCalloc(1,sizeof(struct elemental_data));
- ed->bl.type = BL_ELEM;
- ed->bl.id = npc_get_new_npc_id();
- ed->master = sd;
- ed->db = db;
- memcpy(&ed->elemental, ele, sizeof(struct s_elemental));
- iStatus->set_viewdata(&ed->bl, ed->elemental.class_);
- ed->vd->head_mid = 10; // Why?
- iStatus->change_init(&ed->bl);
- unit_dataset(&ed->bl);
- ed->ud.dir = sd->ud.dir;
-
- ed->bl.m = sd->bl.m;
- ed->bl.x = sd->bl.x;
- ed->bl.y = sd->bl.y;
- unit_calc_pos(&ed->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
- ed->bl.x = ed->ud.to_x;
- ed->bl.y = ed->ud.to_y;
-
- iMap->addiddb(&ed->bl);
- status_calc_elemental(ed,1);
- ed->last_spdrain_time = ed->last_thinktime = iTimer->gettick();
- ed->summon_timer = INVALID_TIMER;
- elemental_summon_init(ed);
- } else {
- memcpy(&sd->ed->elemental, ele, sizeof(struct s_elemental));
- ed = sd->ed;
- }
-
- sd->status.ele_id = ele->elemental_id;
-
- if( ed->bl.prev == NULL && sd->bl.prev != NULL ) {
- iMap->addblock(&ed->bl);
- clif->spawn(&ed->bl);
- clif->elemental_info(sd);
- clif->elemental_updatestatus(sd,SP_HP);
- clif->hpmeter_single(sd->fd,ed->bl.id,ed->battle_status.hp,ed->battle_status.max_hp);
- clif->elemental_updatestatus(sd,SP_SP);
- }
-
- return 1;
-}
-
-int elemental_clean_single_effect(struct elemental_data *ed, uint16 skill_id) {
- struct block_list *bl;
- sc_type type = iStatus->skill2sc(skill_id);
-
- nullpo_ret(ed);
-
- bl = battle->get_master(&ed->bl);
-
- if( type ) {
- switch( type ) {
- // Just remove status change.
- case SC_PYROTECHNIC_OPTION:
- case SC_HEATER_OPTION:
- case SC_TROPIC_OPTION:
- case SC_FIRE_CLOAK_OPTION:
- case SC_AQUAPLAY_OPTION:
- case SC_WATER_SCREEN_OPTION:
- case SC_COOLER_OPTION:
- case SC_CHILLY_AIR_OPTION:
- case SC_GUST_OPTION:
- case SC_WIND_STEP_OPTION:
- case SC_BLAST_OPTION:
- case SC_WATER_DROP_OPTION:
- case SC_WIND_CURTAIN_OPTION:
- case SC_WILD_STORM_OPTION:
- case SC_PETROLOGY_OPTION:
- case SC_SOLID_SKIN_OPTION:
- case SC_CURSED_SOIL_OPTION:
- case SC_STONE_SHIELD_OPTION:
- case SC_UPHEAVAL_OPTION:
- case SC_CIRCLE_OF_FIRE_OPTION:
- case SC_TIDAL_WEAPON_OPTION:
- if( bl ) status_change_end(bl,type,INVALID_TIMER); // Master
- status_change_end(&ed->bl,type-1,INVALID_TIMER); // Elemental Spirit
- break;
- case SC_ZEPHYR:
- if( bl ) status_change_end(bl,type,INVALID_TIMER);
- break;
- default:
- ShowWarning("Invalid SC=%d in elemental_clean_single_effect\n",type);
- break;
- }
- }
-
- return 1;
-}
-
-int elemental_clean_effect(struct elemental_data *ed) {
- struct map_session_data *sd;
-
- nullpo_ret(ed);
-
- // Elemental side
- status_change_end(&ed->bl, SC_TROPIC, INVALID_TIMER);
- status_change_end(&ed->bl, SC_HEATER, INVALID_TIMER);
- status_change_end(&ed->bl, SC_AQUAPLAY, INVALID_TIMER);
- status_change_end(&ed->bl, SC_COOLER, INVALID_TIMER);
- status_change_end(&ed->bl, SC_CHILLY_AIR, INVALID_TIMER);
- status_change_end(&ed->bl, SC_PYROTECHNIC, INVALID_TIMER);
- status_change_end(&ed->bl, SC_FIRE_CLOAK, INVALID_TIMER);
- status_change_end(&ed->bl, SC_WATER_DROP, INVALID_TIMER);
- status_change_end(&ed->bl, SC_WATER_SCREEN, INVALID_TIMER);
- status_change_end(&ed->bl, SC_GUST, INVALID_TIMER);
- status_change_end(&ed->bl, SC_WIND_STEP, INVALID_TIMER);
- status_change_end(&ed->bl, SC_BLAST, INVALID_TIMER);
- status_change_end(&ed->bl, SC_WIND_CURTAIN, INVALID_TIMER);
- status_change_end(&ed->bl, SC_WILD_STORM, INVALID_TIMER);
- status_change_end(&ed->bl, SC_PETROLOGY, INVALID_TIMER);
- status_change_end(&ed->bl, SC_SOLID_SKIN, INVALID_TIMER);
- status_change_end(&ed->bl, SC_CURSED_SOIL, INVALID_TIMER);
- status_change_end(&ed->bl, SC_STONE_SHIELD, INVALID_TIMER);
- status_change_end(&ed->bl, SC_UPHEAVAL, INVALID_TIMER);
- status_change_end(&ed->bl, SC_CIRCLE_OF_FIRE, INVALID_TIMER);
- status_change_end(&ed->bl, SC_TIDAL_WEAPON, INVALID_TIMER);
-
- if( (sd = ed->master) == NULL )
- return 0;
-
- // Master side
- status_change_end(&sd->bl, SC_TROPIC_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_HEATER_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_AQUAPLAY_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_COOLER_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_CHILLY_AIR_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_PYROTECHNIC_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_FIRE_CLOAK_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_WATER_DROP_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_WATER_SCREEN_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_GUST_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_WIND_STEP_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_BLAST_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_WATER_DROP_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_WIND_CURTAIN_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_WILD_STORM_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_ZEPHYR, INVALID_TIMER);
- status_change_end(&sd->bl, SC_WIND_STEP_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_PETROLOGY_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_SOLID_SKIN_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_CURSED_SOIL_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_STONE_SHIELD_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_UPHEAVAL_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_CIRCLE_OF_FIRE_OPTION, INVALID_TIMER);
- status_change_end(&sd->bl, SC_TIDAL_WEAPON_OPTION, INVALID_TIMER);
-
- return 1;
-}
-
-int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned int tick) {
- struct skill_condition req;
- uint16 skill_id, skill_lv;
- int i;
-
- nullpo_ret(ed);
- nullpo_ret(bl);
-
- if( !ed->master )
- return 0;
-
- if( ed->target_id )
- elemental->unlocktarget(ed); // Remove previous target.
-
- ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&EL_SKILLMODE_AGGRESSIVE));
- if( i == MAX_ELESKILLTREE )
- return 0;
-
- skill_id = ed->db->skill[i].id;
- skill_lv = ed->db->skill[i].lv;
-
- if( elemental->skillnotok(skill_id, ed) )
- return 0;
-
- if( ed->ud.skilltimer != INVALID_TIMER )
- return 0;
- else if( DIFF_TICK(tick, ed->ud.canact_tick) < 0 )
- return 0;
-
- ed->target_id = ed->ud.skilltarget = bl->id; // Set new target
- ed->last_thinktime = tick;
-
- // Not in skill range.
- if( !battle->check_range(&ed->bl,bl,skill->get_range(skill_id,skill_lv)) ) {
- // Try to walk to the target.
- if( !unit_walktobl(&ed->bl, bl, skill->get_range(skill_id,skill_lv), 2) )
- elemental->unlocktarget(ed);
- else {
- // Walking, waiting to be in range. Client don't handle it, then we must handle it here.
- int walk_dist = distance_bl(&ed->bl,bl) - skill->get_range(skill_id,skill_lv);
- ed->ud.skill_id = skill_id;
- ed->ud.skill_lv = skill_lv;
-
- if( skill->get_inf(skill_id) & INF_GROUND_SKILL )
- ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 );
- else
- ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 );
- }
- return 1;
-
- }
-
- req = elemental->skill_get_requirements(skill_id, skill_lv);
-
- if(req.hp || req.sp){
- struct map_session_data *sd = BL_CAST(BL_PC, battle->get_master(&ed->bl));
- if( sd ){
- if( sd->skill_id_old != SO_EL_ACTION && //regardless of remaining HP/SP it can be cast
- (status_get_hp(&ed->bl) < req.hp || status_get_sp(&ed->bl) < req.sp) )
- return 1;
- else
- status_zap(&ed->bl, req.hp, req.sp);
- }
- }
-
- //Otherwise, just cast the skill.
- if( skill->get_inf(skill_id) & INF_GROUND_SKILL )
- unit_skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv);
- else
- unit_skilluse_id(&ed->bl, bl->id, skill_id, skill_lv);
-
- // Reset target.
- ed->target_id = 0;
-
- return 1;
-}
-
-/*===============================================================
- * Action that elemental perform after changing mode.
- * Activates one of the skills of the new mode.
- *-------------------------------------------------------------*/
-int elemental_change_mode_ack(struct elemental_data *ed, int mode) {
- struct block_list *bl = &ed->master->bl;
- uint16 skill_id, skill_lv;
- int i;
-
- nullpo_ret(ed);
-
- if( !bl )
- return 0;
-
- // Select a skill.
- ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&mode));
- if( i == MAX_ELESKILLTREE )
- return 0;
-
- skill_id = ed->db->skill[i].id;
- skill_lv = ed->db->skill[i].lv;
-
- if( elemental->skillnotok(skill_id, ed) )
- return 0;
-
- if( ed->ud.skilltimer != INVALID_TIMER )
- return 0;
- else if( DIFF_TICK(iTimer->gettick(), ed->ud.canact_tick) < 0 )
- return 0;
-
- ed->target_id = bl->id; // Set new target
- ed->last_thinktime = iTimer->gettick();
-
- if( skill->get_inf(skill_id) & INF_GROUND_SKILL )
- unit_skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv);
- else
- unit_skilluse_id(&ed->bl,bl->id,skill_id,skill_lv);
-
- ed->target_id = 0; // Reset target after casting the skill to avoid continious attack.
-
- return 1;
-}
-
-/*===============================================================
- * Change elemental mode.
- *-------------------------------------------------------------*/
-int elemental_change_mode(struct elemental_data *ed, int mode) {
- nullpo_ret(ed);
-
- // Remove target
- elemental->unlocktarget(ed);
-
- // Removes the effects of the previous mode.
- if(ed->elemental.mode != mode ) elemental->clean_effect(ed);
-
- ed->battle_status.mode = ed->elemental.mode = mode;
-
- // Normalize elemental mode to elemental skill mode.
- if( mode == EL_MODE_AGGRESSIVE ) mode = EL_SKILLMODE_AGGRESSIVE; // Aggressive spirit mode -> Aggressive spirit skill.
- else if( mode == EL_MODE_ASSIST ) mode = EL_SKILLMODE_ASSIST; // Assist spirit mode -> Assist spirit skill.
- else mode = EL_SKILLMODE_PASIVE; // Passive spirit mode -> Passive spirit skill.
-
- // Use a skill inmediately after every change mode.
- if( mode != EL_SKILLMODE_AGGRESSIVE )
- elemental->change_mode_ack(ed,mode);
- return 1;
-}
-
-void elemental_heal(struct elemental_data *ed, int hp, int sp) {
- if( hp )
- clif->elemental_updatestatus(ed->master, SP_HP);
- if( sp )
- clif->elemental_updatestatus(ed->master, SP_SP);
-}
-
-int elemental_dead(struct elemental_data *ed) {
- elemental->delete(ed, 1);
- return 0;
-}
-
-int elemental_unlocktarget(struct elemental_data *ed) {
- nullpo_ret(ed);
-
- ed->target_id = 0;
- elemental_stop_attack(ed);
- elemental_stop_walking(ed,1);
- return 0;
-}
-
-int elemental_skillnotok(uint16 skill_id, struct elemental_data *ed) {
- int idx = skill->get_index(skill_id);
- nullpo_retr(1,ed);
-
- if (idx == 0)
- return 1; // invalid skill id
-
- return skill->not_ok(skill_id, ed->master);
-}
-
-struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16 skill_lv){
- struct skill_condition req;
- int idx = skill->get_index(skill_id);
-
- memset(&req,0,sizeof(req));
-
- if( idx == 0 ) // invalid skill id
- return req;
-
- if( skill_lv < 1 || skill_lv > MAX_SKILL_LEVEL )
- return req;
-
- req.hp = skill_db[idx].hp[skill_lv-1];
- req.sp = skill_db[idx].sp[skill_lv-1];
-
- return req;
-}
-
-int elemental_set_target( struct map_session_data *sd, struct block_list *bl ) {
- struct elemental_data *ed = sd->ed;
-
- nullpo_ret(ed);
- nullpo_ret(bl);
-
- if( ed->bl.m != bl->m || !check_distance_bl(&ed->bl, bl, ed->db->range2) )
- return 0;
-
- if( !iStatus->check_skilluse(&ed->bl, bl, 0, 0) )
- return 0;
-
- if( ed->target_id == 0 )
- ed->target_id = bl->id;
-
- return 1;
-}
-
-static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap) {
- struct elemental_data *ed;
- struct block_list **target;
- int dist;
-
- nullpo_ret(bl);
-
- ed = va_arg(ap,struct elemental_data *);
- target = va_arg(ap,struct block_list**);
-
- //If can't seek yet, not an enemy, or you can't attack it, skip.
- if( (*target) == bl || !iStatus->check_skilluse(&ed->bl, bl, 0, 0) )
- return 0;
-
- if( battle->check_target(&ed->bl,bl,BCT_ENEMY) <= 0 )
- return 0;
-
- switch( bl->type ) {
- case BL_PC:
- if( !map_flag_vs(ed->bl.m) )
- return 0;
- default:
- dist = distance_bl(&ed->bl, bl);
- if( ((*target) == NULL || !check_distance_bl(&ed->bl, *target, dist)) && battle->check_range(&ed->bl,bl,ed->db->range2) ) { //Pick closest target?
- (*target) = bl;
- ed->target_id = bl->id;
- ed->min_chase = dist + ed->db->range3;
- if( ed->min_chase > AREA_SIZE )
- ed->min_chase = AREA_SIZE;
- return 1;
- }
- break;
- }
- return 0;
-}
-
-static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *sd, unsigned int tick) {
- struct block_list *target = NULL;
- int master_dist, view_range, mode;
-
- nullpo_ret(ed);
- nullpo_ret(sd);
-
- if( ed->bl.prev == NULL || sd == NULL || sd->bl.prev == NULL )
- return 0;
-
- // Check if caster can sustain the summoned elemental
- if( DIFF_TICK(tick,ed->last_spdrain_time) >= 10000 ){// Drain SP every 10 seconds
- int sp = 5;
-
- switch(ed->vd->class_){
- case 2115: case 2118:
- case 2121: case 2124:
- sp = 8;
- break;
- case 2116: case 2119:
- case 2122: case 2125:
- sp = 11;
- break;
- }
-
- if( status_get_sp(&sd->bl) < sp ){ // Can't sustain delete it.
- elemental->delete(sd->ed,0);
- return 0;
- }
-
- status_zap(&sd->bl,0,sp);
- ed->last_spdrain_time = tick;
- }
-
- if( DIFF_TICK(tick,ed->last_thinktime) < MIN_ELETHINKTIME )
- return 0;
-
- ed->last_thinktime = tick;
-
- if( ed->ud.skilltimer != INVALID_TIMER )
- return 0;
-
- if( ed->ud.walktimer != INVALID_TIMER && ed->ud.walkpath.path_pos <= 2 )
- return 0; //No thinking when you just started to walk.
-
- if(ed->ud.walkpath.path_pos < ed->ud.walkpath.path_len && ed->ud.target == sd->bl.id)
- return 0; //No thinking until be near the master.
-
- if( ed->sc.count && ed->sc.data[SC_BLIND] )
- view_range = 3;
- else
- view_range = ed->db->range2;
-
- mode = status_get_mode(&ed->bl);
-
- master_dist = distance_bl(&sd->bl, &ed->bl);
- if( master_dist > AREA_SIZE ) { // Master out of vision range.
- elemental->unlocktarget(ed);
- unit_warp(&ed->bl,sd->bl.m,sd->bl.x,sd->bl.y,CLR_TELEPORT);
- clif->elemental_updatestatus(sd,SP_HP);
- clif->elemental_updatestatus(sd,SP_SP);
- return 0;
- } else if( master_dist > MAX_ELEDISTANCE ) { // Master too far, chase.
- short x = sd->bl.x, y = sd->bl.y;
- if( ed->target_id )
- elemental->unlocktarget(ed);
- if( ed->ud.walktimer != INVALID_TIMER && ed->ud.target == sd->bl.id )
- return 0; //Already walking to him
- if( DIFF_TICK(tick, ed->ud.canmove_tick) < 0 )
- return 0; //Can't move yet.
- if( iMap->search_freecell(&ed->bl, sd->bl.m, &x, &y, MIN_ELEDISTANCE, MIN_ELEDISTANCE, 1)
- && unit_walktoxy(&ed->bl, x, y, 0) )
- return 0;
- }
-
- if( mode == EL_MODE_AGGRESSIVE ) {
- target = iMap->id2bl(ed->ud.target);
-
- if( !target )
- iMap->foreachinrange(elemental_ai_sub_timer_activesearch, &ed->bl, view_range, BL_CHAR, ed, &target, status_get_mode(&ed->bl));
-
- if( !target ) { //No targets available.
- elemental->unlocktarget(ed);
- return 1;
- }
-
- if( battle->check_range(&ed->bl,target,view_range) && rnd()%100 < 2 ) { // 2% chance to cast attack skill.
- if( elemental->action(ed,target,tick) )
- return 1;
- }
-
- //Attempt to attack.
- //At this point we know the target is attackable, we just gotta check if the range matches.
- if( ed->ud.target == target->id && ed->ud.attacktimer != INVALID_TIMER ) //Already locked.
- return 1;
-
- if( battle->check_range(&ed->bl, target, ed->base_status.rhw.range) ) {//Target within range, engage
- unit_attack(&ed->bl,target->id,1);
- return 1;
- }
-
- //Follow up if possible.
- if( !unit_walktobl(&ed->bl, target, ed->base_status.rhw.range, 2) )
- elemental->unlocktarget(ed);
- }
-
- return 0;
-}
-
-static int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list ap) {
- unsigned int tick = va_arg(ap,unsigned int);
- if(sd->status.ele_id && sd->ed)
- elemental_ai_sub_timer(sd->ed,sd,tick);
-
- return 0;
-}
-
-static int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) {
- iMap->map_foreachpc(elemental_ai_sub_foreachclient,tick);
- return 0;
-}
-
-int read_elementaldb(void) {
- FILE *fp;
- char line[1024], *p;
- char *str[26];
- int i, j = 0, k = 0, ele;
- struct s_elemental_db *db;
- struct status_data *status;
-
- sprintf(line, "%s/%s", iMap->db_path, "elemental_db.txt");
- memset(elemental->elemental_db,0,sizeof(elemental->elemental_db));
-
- fp = fopen(line, "r");
- if( !fp ) {
- ShowError("read_elementaldb : can't read elemental_db.txt\n");
- return -1;
- }
-
- while( fgets(line, sizeof(line), fp) && j < MAX_ELEMENTAL_CLASS ) {
- k++;
- if( line[0] == '/' && line[1] == '/' )
- continue;
-
- if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r')
- continue;
-
- i = 0;
- p = strtok(line, ",");
- while( p != NULL && i < 26 ) {
- str[i++] = p;
- p = strtok(NULL, ",");
- }
- if( i < 26 ) {
- ShowError("read_elementaldb : Incorrect number of columns at elemental_db.txt line %d.\n", k);
- continue;
- }
-
- db = &elemental->elemental_db[j];
- db->class_ = atoi(str[0]);
- safestrncpy(db->sprite, str[1], NAME_LENGTH);
- safestrncpy(db->name, str[2], NAME_LENGTH);
- db->lv = atoi(str[3]);
-
- status = &db->status;
- db->vd.class_ = db->class_;
-
- status->max_hp = atoi(str[4]);
- status->max_sp = atoi(str[5]);
- status->rhw.range = atoi(str[6]);
- status->rhw.atk = atoi(str[7]);
- status->rhw.atk2 = atoi(str[8]);
- status->def = atoi(str[9]);
- status->mdef = atoi(str[10]);
- status->str = atoi(str[11]);
- status->agi = atoi(str[12]);
- status->vit = atoi(str[13]);
- status->int_ = atoi(str[14]);
- status->dex = atoi(str[15]);
- status->luk = atoi(str[16]);
- db->range2 = atoi(str[17]);
- db->range3 = atoi(str[18]);
- status->size = atoi(str[19]);
- status->race = atoi(str[20]);
-
- ele = atoi(str[21]);
- status->def_ele = ele%10;
- status->ele_lv = ele/20;
- if( status->def_ele >= ELE_MAX ) {
- ShowWarning("Elemental %d has invalid element type %d (max element is %d)\n", db->class_, status->def_ele, ELE_MAX - 1);
- status->def_ele = ELE_NEUTRAL;
- }
- if( status->ele_lv < 1 || status->ele_lv > 4 ) {
- ShowWarning("Elemental %d has invalid element level %d (max is 4)\n", db->class_, status->ele_lv);
- status->ele_lv = 1;
- }
-
- status->aspd_rate = 1000;
- status->speed = atoi(str[22]);
- status->adelay = atoi(str[23]);
- status->amotion = atoi(str[24]);
- status->dmotion = atoi(str[25]);
-
- j++;
- }
-
- fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' elementals in '"CL_WHITE"db/elemental_db.txt"CL_RESET"'.\n",j);
-
- return 0;
-}
-
-int read_elemental_skilldb(void) {
- FILE *fp;
- char line[1024], *p;
- char *str[4];
- struct s_elemental_db *db;
- int i, j = 0, k = 0, class_;
- uint16 skill_id, skill_lv;
- int skillmode;
-
- sprintf(line, "%s/%s", iMap->db_path, "elemental_skill_db.txt");
- fp = fopen(line, "r");
- if( !fp ) {
- ShowError("read_elemental_skilldb : can't read elemental_skill_db.txt\n");
- return -1;
- }
-
- while( fgets(line, sizeof(line), fp) ) {
- k++;
- if( line[0] == '/' && line[1] == '/' )
- continue;
-
- if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r')
- continue;
-
- i = 0;
- p = strtok(line, ",");
- while( p != NULL && i < 4 ) {
- str[i++] = p;
- p = strtok(NULL, ",");
- }
- if( i < 4 ) {
- ShowError("read_elemental_skilldb : Incorrect number of columns at elemental_skill_db.txt line %d.\n", k);
- continue;
- }
-
- class_ = atoi(str[0]);
- ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, class_ == elemental->elemental_db[i].class_);
- if( i == MAX_ELEMENTAL_CLASS ) {
- ShowError("read_elemental_skilldb : Class not found in elemental_db for skill entry, line %d.\n", k);
- continue;
- }
-
- skill_id = atoi(str[1]);
- if( skill_id < EL_SKILLBASE || skill_id >= EL_SKILLBASE + MAX_ELEMENTALSKILL ) {
- ShowError("read_elemental_skilldb : Skill out of range, line %d.\n", k);
- continue;
- }
-
- db = &elemental->elemental_db[i];
- skill_lv = atoi(str[2]);
-
- skillmode = atoi(str[3]);
- if( skillmode < EL_SKILLMODE_PASIVE || skillmode > EL_SKILLMODE_AGGRESSIVE ) {
- ShowError("read_elemental_skilldb : Skillmode out of range, line %d.\n",k);
- continue;
- }
- ARR_FIND( 0, MAX_ELESKILLTREE, i, db->skill[i].id == 0 || db->skill[i].id == skill_id );
- if( i == MAX_ELESKILLTREE ) {
- ShowWarning("Unable to load skill %d into Elemental %d's tree. Maximum number of skills per elemental has been reached.\n", skill_id, class_);
- continue;
- }
- db->skill[i].id = skill_id;
- db->skill[i].lv = skill_lv;
- db->skill[i].mode = skillmode;
- j++;
- }
-
- fclose(fp);
- ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"db/elemental_skill_db.txt"CL_RESET"'.\n",j);
- return 0;
-}
-
-void reload_elementaldb(void) {
- read_elementaldb();
- elemental->reload_skilldb();
-}
-
-void reload_elemental_skilldb(void) {
- elemental->read_skilldb();
-}
-
-int do_init_elemental(void) {
- read_elementaldb();
- elemental->read_skilldb();
-
- iTimer->add_timer_func_list(elemental_ai_timer,"elemental_ai_timer");
- iTimer->add_timer_interval(iTimer->gettick()+MIN_ELETHINKTIME,elemental_ai_timer,0,0,MIN_ELETHINKTIME);
-
- return 0;
-}
-
-void do_final_elemental(void) {
- return;
-}
-
-/*=====================================
-* Default Functions : elemental.h
-* Generated by HerculesInterfaceMaker
-* created by Susu
-*-------------------------------------*/
-void elemental_defaults(void) {
- elemental = &elemental_s;
- /* funcs */
-
- elemental->class = elemental_class;
- elemental->get_viewdata = elemental_get_viewdata;
-
- elemental->create = elemental_create;
- elemental->data_received = elemental_data_received;
- elemental->save = elemental_save;
-
- elemental->change_mode_ack = elemental_change_mode_ack;
- elemental->change_mode = elemental_change_mode;
-
- elemental->heal = elemental_heal;
- elemental->dead = elemental_dead;
-
- elemental->delete = elemental_delete;
- elemental->summon_stop = elemental_summon_stop;
-
- elemental->get_lifetime = elemental_get_lifetime;
-
- elemental->unlocktarget = elemental_unlocktarget;
- elemental->skillnotok = elemental_skillnotok;
- elemental->set_target = elemental_set_target;
- elemental->clean_single_effect = elemental_clean_single_effect;
- elemental->clean_effect = elemental_clean_effect;
- elemental->action = elemental_action;
- elemental->skill_get_requirements = elemental_skill_get_requirements;
-
- elemental->read_skilldb = read_elemental_skilldb;
- elemental->reload_elementaldb = reload_elementaldb;
- elemental->reload_skilldb = reload_elemental_skilldb;
- elemental->do_init_elemental = do_init_elemental;
- elemental->do_final_elemental = do_final_elemental;
-}
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
+
+#include "../common/cbasetypes.h"
+#include "../common/malloc.h"
+#include "../common/socket.h"
+#include "../common/timer.h"
+#include "../common/nullpo.h"
+#include "../common/mmo.h"
+#include "../common/showmsg.h"
+#include "../common/utils.h"
+#include "../common/random.h"
+#include "../common/strlib.h"
+
+#include "log.h"
+#include "clif.h"
+#include "chrif.h"
+#include "intif.h"
+#include "itemdb.h"
+#include "map.h"
+#include "pc.h"
+#include "status.h"
+#include "skill.h"
+#include "mob.h"
+#include "pet.h"
+#include "battle.h"
+#include "party.h"
+#include "guild.h"
+#include "atcommand.h"
+#include "script.h"
+#include "npc.h"
+#include "trade.h"
+#include "unit.h"
+#include "elemental.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+int elemental_search_index(int class_) {
+ int i;
+ ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, elemental->elemental_db[i].class_ == class_);
+ return (i == MAX_ELEMENTAL_CLASS)?-1:i;
+}
+
+bool elemental_class(int class_) {
+ return (bool)(elemental_search_index(class_) > -1);
+}
+
+struct view_data * elemental_get_viewdata(int class_) {
+ int i = elemental_search_index(class_);
+ if( i < 0 )
+ return 0;
+
+ return &elemental->elemental_db[i].vd;
+}
+
+int elemental_create(struct map_session_data *sd, int class_, unsigned int lifetime) {
+ struct s_elemental ele;
+ struct s_elemental_db *db;
+ int i;
+
+ nullpo_retr(1,sd);
+
+ if( (i = elemental_search_index(class_)) < 0 )
+ return 0;
+
+ db = &elemental->elemental_db[i];
+ memset(&ele,0,sizeof(struct s_elemental));
+
+ ele.char_id = sd->status.char_id;
+ ele.class_ = class_;
+ ele.mode = EL_MODE_PASSIVE; // Initial mode
+ i = db->status.size+1; // summon level
+
+ //[(Casterソスs Max HP/ 3 ) + (Casterソスs INT x 10 )+ (Casterソスs Job Level x 20 )] x [(Elemental Summon Level + 2) / 3]
+ ele.hp = ele.max_hp = (sd->battle_status.max_hp/3 + sd->battle_status.int_*10 + sd->status.job_level) * ((i + 2) / 3);
+ //Casterソスs Max SP /4
+ ele.sp = ele.max_sp = sd->battle_status.max_sp/4;
+ //Casterソスs [ Max SP / (18 / Elemental Summon Skill Level) 1- 100 ]
+ ele.atk = (sd->battle_status.max_sp / (18 / i) * 1 - 100);
+ //Casterソスs [ Max SP / (18 / Elemental Summon Skill Level) ]
+ ele.atk2 = sd->battle_status.max_sp / 18;
+ //Casterソスs HIT + (Casterソスs Base Level )
+ ele.hit = sd->battle_status.hit + sd->status.base_level;
+ //[Elemental Summon Skill Level x (Casterソスs INT / 2 + Casterソスs DEX / 4)]
+ ele.matk = i * (sd->battle_status.int_ / 2 + sd->battle_status.dex / 4);
+ //150 + [Casterソスs DEX / 10] + [Elemental Summon Skill Level x 3 ]
+ ele.amotion = 150 + sd->battle_status.dex / 10 + i * 3;
+ //Casterソスs DEF + (Casterソスs Base Level / (5 ソス Elemental Summon Skill Level)
+ ele.def = sd->battle_status.def + sd->status.base_level / (5-i);
+ //Casterソスs MDEF + (Casterソスs INT / (5 - Elemental Summon Skill Level)
+ ele.mdef = sd->battle_status.mdef + sd->battle_status.int_ / (5-i);
+ //Casterソスs FLEE + (Casterソスs Base Level / (5 ソス Elemental Summon Skill Level)
+ ele.flee = sd->status.base_level / (5-i);
+ //Casterソスs HIT + (Casterソスs Base Level )
+ ele.hit = sd->battle_status.hit + sd->status.base_level;
+
+ //per individual bonuses
+ switch(db->class_){
+ case 2114: case 2115:
+ case 2116: //ATK + (Summon Agni Skill Level x 20) / HIT + (Summon Agni Skill Level x 10)
+ ele.atk += i * 20;
+ ele.atk2 += i * 20;
+ ele.hit += i * 10;
+ break;
+ case 2117: case 2118:
+ case 2119: //MDEF + (Summon Aqua Skill Level x 10) / MATK + (Summon Aqua Skill Level x 20)
+ ele.mdef += i * 10;
+ ele.matk += i * 20;
+ break;
+ case 2120: case 2121:
+ case 2122: //FLEE + (Summon Ventus Skill Level x 20) / MATK + (Summon Ventus Skill Level x 10)
+ ele.flee += i * 20;
+ ele.matk += i * 10;
+ break;
+ case 2123: case 2124:
+ case 2125: //DEF + (Summon Tera Skill Level x 25) / ATK + (Summon Tera Skill Level x 5)
+ ele.def += i * 25;
+ ele.atk += i * 5;
+ ele.atk2 += i * 5;
+ break;
+ }
+
+ if( (i=pc->checkskill(sd,SO_EL_SYMPATHY)) > 0 ){
+ ele.hp = ele.max_hp = ele.max_hp * 5 * i / 100;
+ ele.sp = ele.max_sp = ele.max_sp * 5 * i / 100;
+ ele.atk += 25 * i;
+ ele.atk2 += 25 * i;
+ ele.matk += 25 * i;
+ }
+
+ ele.life_time = lifetime;
+
+ // Request Char Server to create this elemental
+ intif->elemental_create(&ele);
+
+ return 1;
+}
+
+int elemental_get_lifetime(struct elemental_data *ed) {
+ const struct TimerData * td;
+ if( ed == NULL || ed->summon_timer == INVALID_TIMER )
+ return 0;
+
+ td = iTimer->get_timer(ed->summon_timer);
+ return (td != NULL) ? DIFF_TICK(td->tick, iTimer->gettick()) : 0;
+}
+
+int elemental_save(struct elemental_data *ed) {
+ ed->elemental.mode = ed->battle_status.mode;
+ ed->elemental.hp = ed->battle_status.hp;
+ ed->elemental.sp = ed->battle_status.sp;
+ ed->elemental.max_hp = ed->battle_status.max_hp;
+ ed->elemental.max_sp = ed->battle_status.max_sp;
+ ed->elemental.atk = ed->battle_status.rhw.atk;
+ ed->elemental.atk2 = ed->battle_status.rhw.atk2;
+ ed->elemental.matk = ed->battle_status.matk_min;
+ ed->elemental.def = ed->battle_status.def;
+ ed->elemental.mdef = ed->battle_status.mdef;
+ ed->elemental.flee = ed->battle_status.flee;
+ ed->elemental.hit = ed->battle_status.hit;
+ ed->elemental.life_time = elemental->get_lifetime(ed);
+ intif->elemental_save(&ed->elemental);
+ return 1;
+}
+
+static int elemental_summon_end(int tid, unsigned int tick, int id, intptr_t data) {
+ struct map_session_data *sd;
+ struct elemental_data *ed;
+
+ if( (sd = iMap->id2sd(id)) == NULL )
+ return 1;
+ if( (ed = sd->ed) == NULL )
+ return 1;
+
+ if( ed->summon_timer != tid ) {
+ ShowError("elemental_summon_end %d != %d.\n", ed->summon_timer, tid);
+ return 0;
+ }
+
+ ed->summon_timer = INVALID_TIMER;
+ elemental->delete(ed, 0); // Elemental's summon time is over.
+
+ return 0;
+}
+
+void elemental_summon_stop(struct elemental_data *ed) {
+ nullpo_retv(ed);
+ if( ed->summon_timer != INVALID_TIMER )
+ iTimer->delete_timer(ed->summon_timer, elemental_summon_end);
+ ed->summon_timer = INVALID_TIMER;
+}
+
+int elemental_delete(struct elemental_data *ed, int reply) {
+ struct map_session_data *sd;
+ nullpo_ret(ed);
+
+ sd = ed->master;
+ ed->elemental.life_time = 0;
+
+ elemental->clean_effect(ed);
+ elemental->summon_stop(ed);
+
+ if( !sd )
+ return unit->free(&ed->bl, 0);
+
+ sd->ed = NULL;
+ sd->status.ele_id = 0;
+
+ return unit->remove_map(&ed->bl, 0, ALC_MARK);
+}
+
+void elemental_summon_init(struct elemental_data *ed) {
+ if( ed->summon_timer == INVALID_TIMER )
+ ed->summon_timer = iTimer->add_timer(iTimer->gettick() + ed->elemental.life_time, elemental_summon_end, ed->master->bl.id, 0);
+
+ ed->regen.state.block = 0;
+}
+
+int elemental_data_received(struct s_elemental *ele, bool flag) {
+ struct map_session_data *sd;
+ struct elemental_data *ed;
+ struct s_elemental_db *db;
+ int i = elemental_search_index(ele->class_);
+
+ if( (sd = iMap->charid2sd(ele->char_id)) == NULL )
+ return 0;
+
+ if( !flag || i < 0 ) { // Not created - loaded - DB info
+ sd->status.ele_id = 0;
+ return 0;
+ }
+
+ db = &elemental->elemental_db[i];
+ if( !sd->ed ) { // Initialize it after first summon.
+ sd->ed = ed = (struct elemental_data*)aCalloc(1,sizeof(struct elemental_data));
+ ed->bl.type = BL_ELEM;
+ ed->bl.id = npc->get_new_npc_id();
+ ed->master = sd;
+ ed->db = db;
+ memcpy(&ed->elemental, ele, sizeof(struct s_elemental));
+ iStatus->set_viewdata(&ed->bl, ed->elemental.class_);
+ ed->vd->head_mid = 10; // Why?
+ iStatus->change_init(&ed->bl);
+ unit->dataset(&ed->bl);
+ ed->ud.dir = sd->ud.dir;
+
+ ed->bl.m = sd->bl.m;
+ ed->bl.x = sd->bl.x;
+ ed->bl.y = sd->bl.y;
+ unit->calc_pos(&ed->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
+ ed->bl.x = ed->ud.to_x;
+ ed->bl.y = ed->ud.to_y;
+
+ iMap->addiddb(&ed->bl);
+ status_calc_elemental(ed,1);
+ ed->last_spdrain_time = ed->last_thinktime = iTimer->gettick();
+ ed->summon_timer = INVALID_TIMER;
+ elemental_summon_init(ed);
+ } else {
+ memcpy(&sd->ed->elemental, ele, sizeof(struct s_elemental));
+ ed = sd->ed;
+ }
+
+ sd->status.ele_id = ele->elemental_id;
+
+ if( ed->bl.prev == NULL && sd->bl.prev != NULL ) {
+ iMap->addblock(&ed->bl);
+ clif->spawn(&ed->bl);
+ clif->elemental_info(sd);
+ clif->elemental_updatestatus(sd,SP_HP);
+ clif->hpmeter_single(sd->fd,ed->bl.id,ed->battle_status.hp,ed->battle_status.max_hp);
+ clif->elemental_updatestatus(sd,SP_SP);
+ }
+
+ return 1;
+}
+
+int elemental_clean_single_effect(struct elemental_data *ed, uint16 skill_id) {
+ struct block_list *bl;
+ sc_type type = iStatus->skill2sc(skill_id);
+
+ nullpo_ret(ed);
+
+ bl = battle->get_master(&ed->bl);
+
+ if( type ) {
+ switch( type ) {
+ // Just remove status change.
+ case SC_PYROTECHNIC_OPTION:
+ case SC_HEATER_OPTION:
+ case SC_TROPIC_OPTION:
+ case SC_FIRE_CLOAK_OPTION:
+ case SC_AQUAPLAY_OPTION:
+ case SC_WATER_SCREEN_OPTION:
+ case SC_COOLER_OPTION:
+ case SC_CHILLY_AIR_OPTION:
+ case SC_GUST_OPTION:
+ case SC_WIND_STEP_OPTION:
+ case SC_BLAST_OPTION:
+ case SC_WATER_DROP_OPTION:
+ case SC_WIND_CURTAIN_OPTION:
+ case SC_WILD_STORM_OPTION:
+ case SC_PETROLOGY_OPTION:
+ case SC_SOLID_SKIN_OPTION:
+ case SC_CURSED_SOIL_OPTION:
+ case SC_STONE_SHIELD_OPTION:
+ case SC_UPHEAVAL_OPTION:
+ case SC_CIRCLE_OF_FIRE_OPTION:
+ case SC_TIDAL_WEAPON_OPTION:
+ if( bl ) status_change_end(bl,type,INVALID_TIMER); // Master
+ status_change_end(&ed->bl,type-1,INVALID_TIMER); // Elemental Spirit
+ break;
+ case SC_ZEPHYR:
+ if( bl ) status_change_end(bl,type,INVALID_TIMER);
+ break;
+ default:
+ ShowWarning("Invalid SC=%d in elemental_clean_single_effect\n",type);
+ break;
+ }
+ }
+
+ return 1;
+}
+
+int elemental_clean_effect(struct elemental_data *ed) {
+ struct map_session_data *sd;
+
+ nullpo_ret(ed);
+
+ // Elemental side
+ status_change_end(&ed->bl, SC_TROPIC, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_HEATER, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_AQUAPLAY, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_COOLER, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_CHILLY_AIR, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_PYROTECHNIC, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_FIRE_CLOAK, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_WATER_DROP, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_WATER_SCREEN, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_GUST, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_WIND_STEP, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_BLAST, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_WIND_CURTAIN, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_WILD_STORM, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_PETROLOGY, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_SOLID_SKIN, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_CURSED_SOIL, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_STONE_SHIELD, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_UPHEAVAL, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_CIRCLE_OF_FIRE, INVALID_TIMER);
+ status_change_end(&ed->bl, SC_TIDAL_WEAPON, INVALID_TIMER);
+
+ if( (sd = ed->master) == NULL )
+ return 0;
+
+ // Master side
+ status_change_end(&sd->bl, SC_TROPIC_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_HEATER_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_AQUAPLAY_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_COOLER_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_CHILLY_AIR_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_PYROTECHNIC_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_FIRE_CLOAK_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_WATER_DROP_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_WATER_SCREEN_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_GUST_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_WIND_STEP_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_BLAST_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_WATER_DROP_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_WIND_CURTAIN_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_WILD_STORM_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_ZEPHYR, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_WIND_STEP_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_PETROLOGY_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_SOLID_SKIN_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_CURSED_SOIL_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_STONE_SHIELD_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_UPHEAVAL_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_CIRCLE_OF_FIRE_OPTION, INVALID_TIMER);
+ status_change_end(&sd->bl, SC_TIDAL_WEAPON_OPTION, INVALID_TIMER);
+
+ return 1;
+}
+
+int elemental_action(struct elemental_data *ed, struct block_list *bl, unsigned int tick) {
+ struct skill_condition req;
+ uint16 skill_id, skill_lv;
+ int i;
+
+ nullpo_ret(ed);
+ nullpo_ret(bl);
+
+ if( !ed->master )
+ return 0;
+
+ if( ed->target_id )
+ elemental->unlocktarget(ed); // Remove previous target.
+
+ ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&EL_SKILLMODE_AGGRESSIVE));
+ if( i == MAX_ELESKILLTREE )
+ return 0;
+
+ skill_id = ed->db->skill[i].id;
+ skill_lv = ed->db->skill[i].lv;
+
+ if( elemental->skillnotok(skill_id, ed) )
+ return 0;
+
+ if( ed->ud.skilltimer != INVALID_TIMER )
+ return 0;
+ else if( DIFF_TICK(tick, ed->ud.canact_tick) < 0 )
+ return 0;
+
+ ed->target_id = ed->ud.skilltarget = bl->id; // Set new target
+ ed->last_thinktime = tick;
+
+ // Not in skill range.
+ if( !battle->check_range(&ed->bl,bl,skill->get_range(skill_id,skill_lv)) ) {
+ // Try to walk to the target.
+ if( !unit->walktobl(&ed->bl, bl, skill->get_range(skill_id,skill_lv), 2) )
+ elemental->unlocktarget(ed);
+ else {
+ // Walking, waiting to be in range. Client don't handle it, then we must handle it here.
+ int walk_dist = distance_bl(&ed->bl,bl) - skill->get_range(skill_id,skill_lv);
+ ed->ud.skill_id = skill_id;
+ ed->ud.skill_lv = skill_lv;
+
+ if( skill->get_inf(skill_id) & INF_GROUND_SKILL )
+ ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_pos, ed->bl.id, 0 );
+ else
+ ed->ud.skilltimer = iTimer->add_timer( tick+iStatus->get_speed(&ed->bl)*walk_dist, skill->castend_id, ed->bl.id, 0 );
+ }
+ return 1;
+
+ }
+
+ req = elemental->skill_get_requirements(skill_id, skill_lv);
+
+ if(req.hp || req.sp){
+ struct map_session_data *sd = BL_CAST(BL_PC, battle->get_master(&ed->bl));
+ if( sd ){
+ if( sd->skill_id_old != SO_EL_ACTION && //regardless of remaining HP/SP it can be cast
+ (status_get_hp(&ed->bl) < req.hp || status_get_sp(&ed->bl) < req.sp) )
+ return 1;
+ else
+ status_zap(&ed->bl, req.hp, req.sp);
+ }
+ }
+
+ //Otherwise, just cast the skill.
+ if( skill->get_inf(skill_id) & INF_GROUND_SKILL )
+ unit->skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv);
+ else
+ unit->skilluse_id(&ed->bl, bl->id, skill_id, skill_lv);
+
+ // Reset target.
+ ed->target_id = 0;
+
+ return 1;
+}
+
+/*===============================================================
+ * Action that elemental perform after changing mode.
+ * Activates one of the skills of the new mode.
+ *-------------------------------------------------------------*/
+int elemental_change_mode_ack(struct elemental_data *ed, int mode) {
+ struct block_list *bl = &ed->master->bl;
+ uint16 skill_id, skill_lv;
+ int i;
+
+ nullpo_ret(ed);
+
+ if( !bl )
+ return 0;
+
+ // Select a skill.
+ ARR_FIND(0, MAX_ELESKILLTREE, i, ed->db->skill[i].id && (ed->db->skill[i].mode&mode));
+ if( i == MAX_ELESKILLTREE )
+ return 0;
+
+ skill_id = ed->db->skill[i].id;
+ skill_lv = ed->db->skill[i].lv;
+
+ if( elemental->skillnotok(skill_id, ed) )
+ return 0;
+
+ if( ed->ud.skilltimer != INVALID_TIMER )
+ return 0;
+ else if( DIFF_TICK(iTimer->gettick(), ed->ud.canact_tick) < 0 )
+ return 0;
+
+ ed->target_id = bl->id; // Set new target
+ ed->last_thinktime = iTimer->gettick();
+
+ if( skill->get_inf(skill_id) & INF_GROUND_SKILL )
+ unit->skilluse_pos(&ed->bl, bl->x, bl->y, skill_id, skill_lv);
+ else
+ unit->skilluse_id(&ed->bl,bl->id,skill_id,skill_lv);
+
+ ed->target_id = 0; // Reset target after casting the skill to avoid continious attack.
+
+ return 1;
+}
+
+/*===============================================================
+ * Change elemental mode.
+ *-------------------------------------------------------------*/
+int elemental_change_mode(struct elemental_data *ed, int mode) {
+ nullpo_ret(ed);
+
+ // Remove target
+ elemental->unlocktarget(ed);
+
+ // Removes the effects of the previous mode.
+ if(ed->elemental.mode != mode ) elemental->clean_effect(ed);
+
+ ed->battle_status.mode = ed->elemental.mode = mode;
+
+ // Normalize elemental mode to elemental skill mode.
+ if( mode == EL_MODE_AGGRESSIVE ) mode = EL_SKILLMODE_AGGRESSIVE; // Aggressive spirit mode -> Aggressive spirit skill.
+ else if( mode == EL_MODE_ASSIST ) mode = EL_SKILLMODE_ASSIST; // Assist spirit mode -> Assist spirit skill.
+ else mode = EL_SKILLMODE_PASIVE; // Passive spirit mode -> Passive spirit skill.
+
+ // Use a skill inmediately after every change mode.
+ if( mode != EL_SKILLMODE_AGGRESSIVE )
+ elemental->change_mode_ack(ed,mode);
+ return 1;
+}
+
+void elemental_heal(struct elemental_data *ed, int hp, int sp) {
+ if( hp )
+ clif->elemental_updatestatus(ed->master, SP_HP);
+ if( sp )
+ clif->elemental_updatestatus(ed->master, SP_SP);
+}
+
+int elemental_dead(struct elemental_data *ed) {
+ elemental->delete(ed, 1);
+ return 0;
+}
+
+int elemental_unlocktarget(struct elemental_data *ed) {
+ nullpo_ret(ed);
+
+ ed->target_id = 0;
+ elemental_stop_attack(ed);
+ elemental_stop_walking(ed,1);
+ return 0;
+}
+
+int elemental_skillnotok(uint16 skill_id, struct elemental_data *ed) {
+ int idx = skill->get_index(skill_id);
+ nullpo_retr(1,ed);
+
+ if (idx == 0)
+ return 1; // invalid skill id
+
+ return skill->not_ok(skill_id, ed->master);
+}
+
+struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16 skill_lv){
+ struct skill_condition req;
+ int idx = skill->get_index(skill_id);
+
+ memset(&req,0,sizeof(req));
+
+ if( idx == 0 ) // invalid skill id
+ return req;
+
+ if( skill_lv < 1 || skill_lv > MAX_SKILL_LEVEL )
+ return req;
+
+ req.hp = skill_db[idx].hp[skill_lv-1];
+ req.sp = skill_db[idx].sp[skill_lv-1];
+
+ return req;
+}
+
+int elemental_set_target( struct map_session_data *sd, struct block_list *bl ) {
+ struct elemental_data *ed = sd->ed;
+
+ nullpo_ret(ed);
+ nullpo_ret(bl);
+
+ if( ed->bl.m != bl->m || !check_distance_bl(&ed->bl, bl, ed->db->range2) )
+ return 0;
+
+ if( !iStatus->check_skilluse(&ed->bl, bl, 0, 0) )
+ return 0;
+
+ if( ed->target_id == 0 )
+ ed->target_id = bl->id;
+
+ return 1;
+}
+
+static int elemental_ai_sub_timer_activesearch(struct block_list *bl, va_list ap) {
+ struct elemental_data *ed;
+ struct block_list **target;
+ int dist;
+
+ nullpo_ret(bl);
+
+ ed = va_arg(ap,struct elemental_data *);
+ target = va_arg(ap,struct block_list**);
+
+ //If can't seek yet, not an enemy, or you can't attack it, skip.
+ if( (*target) == bl || !iStatus->check_skilluse(&ed->bl, bl, 0, 0) )
+ return 0;
+
+ if( battle->check_target(&ed->bl,bl,BCT_ENEMY) <= 0 )
+ return 0;
+
+ switch( bl->type ) {
+ case BL_PC:
+ if( !map_flag_vs(ed->bl.m) )
+ return 0;
+ default:
+ dist = distance_bl(&ed->bl, bl);
+ if( ((*target) == NULL || !check_distance_bl(&ed->bl, *target, dist)) && battle->check_range(&ed->bl,bl,ed->db->range2) ) { //Pick closest target?
+ (*target) = bl;
+ ed->target_id = bl->id;
+ ed->min_chase = dist + ed->db->range3;
+ if( ed->min_chase > AREA_SIZE )
+ ed->min_chase = AREA_SIZE;
+ return 1;
+ }
+ break;
+ }
+ return 0;
+}
+
+static int elemental_ai_sub_timer(struct elemental_data *ed, struct map_session_data *sd, unsigned int tick) {
+ struct block_list *target = NULL;
+ int master_dist, view_range, mode;
+
+ nullpo_ret(ed);
+ nullpo_ret(sd);
+
+ if( ed->bl.prev == NULL || sd == NULL || sd->bl.prev == NULL )
+ return 0;
+
+ // Check if caster can sustain the summoned elemental
+ if( DIFF_TICK(tick,ed->last_spdrain_time) >= 10000 ){// Drain SP every 10 seconds
+ int sp = 5;
+
+ switch(ed->vd->class_){
+ case 2115: case 2118:
+ case 2121: case 2124:
+ sp = 8;
+ break;
+ case 2116: case 2119:
+ case 2122: case 2125:
+ sp = 11;
+ break;
+ }
+
+ if( status_get_sp(&sd->bl) < sp ){ // Can't sustain delete it.
+ elemental->delete(sd->ed,0);
+ return 0;
+ }
+
+ status_zap(&sd->bl,0,sp);
+ ed->last_spdrain_time = tick;
+ }
+
+ if( DIFF_TICK(tick,ed->last_thinktime) < MIN_ELETHINKTIME )
+ return 0;
+
+ ed->last_thinktime = tick;
+
+ if( ed->ud.skilltimer != INVALID_TIMER )
+ return 0;
+
+ if( ed->ud.walktimer != INVALID_TIMER && ed->ud.walkpath.path_pos <= 2 )
+ return 0; //No thinking when you just started to walk.
+
+ if(ed->ud.walkpath.path_pos < ed->ud.walkpath.path_len && ed->ud.target == sd->bl.id)
+ return 0; //No thinking until be near the master.
+
+ if( ed->sc.count && ed->sc.data[SC_BLIND] )
+ view_range = 3;
+ else
+ view_range = ed->db->range2;
+
+ mode = status_get_mode(&ed->bl);
+
+ master_dist = distance_bl(&sd->bl, &ed->bl);
+ if( master_dist > AREA_SIZE ) { // Master out of vision range.
+ elemental->unlocktarget(ed);
+ unit->warp(&ed->bl,sd->bl.m,sd->bl.x,sd->bl.y,CLR_TELEPORT);
+ clif->elemental_updatestatus(sd,SP_HP);
+ clif->elemental_updatestatus(sd,SP_SP);
+ return 0;
+ } else if( master_dist > MAX_ELEDISTANCE ) { // Master too far, chase.
+ short x = sd->bl.x, y = sd->bl.y;
+ if( ed->target_id )
+ elemental->unlocktarget(ed);
+ if( ed->ud.walktimer != INVALID_TIMER && ed->ud.target == sd->bl.id )
+ return 0; //Already walking to him
+ if( DIFF_TICK(tick, ed->ud.canmove_tick) < 0 )
+ return 0; //Can't move yet.
+ if( iMap->search_freecell(&ed->bl, sd->bl.m, &x, &y, MIN_ELEDISTANCE, MIN_ELEDISTANCE, 1)
+ && unit->walktoxy(&ed->bl, x, y, 0) )
+ return 0;
+ }
+
+ if( mode == EL_MODE_AGGRESSIVE ) {
+ target = iMap->id2bl(ed->ud.target);
+
+ if( !target )
+ iMap->foreachinrange(elemental_ai_sub_timer_activesearch, &ed->bl, view_range, BL_CHAR, ed, &target, status_get_mode(&ed->bl));
+
+ if( !target ) { //No targets available.
+ elemental->unlocktarget(ed);
+ return 1;
+ }
+
+ if( battle->check_range(&ed->bl,target,view_range) && rnd()%100 < 2 ) { // 2% chance to cast attack skill.
+ if( elemental->action(ed,target,tick) )
+ return 1;
+ }
+
+ //Attempt to attack.
+ //At this point we know the target is attackable, we just gotta check if the range matches.
+ if( ed->ud.target == target->id && ed->ud.attacktimer != INVALID_TIMER ) //Already locked.
+ return 1;
+
+ if( battle->check_range(&ed->bl, target, ed->base_status.rhw.range) ) {//Target within range, engage
+ unit->attack(&ed->bl,target->id,1);
+ return 1;
+ }
+
+ //Follow up if possible.
+ if( !unit->walktobl(&ed->bl, target, ed->base_status.rhw.range, 2) )
+ elemental->unlocktarget(ed);
+ }
+
+ return 0;
+}
+
+static int elemental_ai_sub_foreachclient(struct map_session_data *sd, va_list ap) {
+ unsigned int tick = va_arg(ap,unsigned int);
+ if(sd->status.ele_id && sd->ed)
+ elemental_ai_sub_timer(sd->ed,sd,tick);
+
+ return 0;
+}
+
+static int elemental_ai_timer(int tid, unsigned int tick, int id, intptr_t data) {
+ iMap->map_foreachpc(elemental_ai_sub_foreachclient,tick);
+ return 0;
+}
+
+int read_elementaldb(void) {
+ FILE *fp;
+ char line[1024], *p;
+ char *str[26];
+ int i, j = 0, k = 0, ele;
+ struct s_elemental_db *db;
+ struct status_data *status;
+
+ sprintf(line, "%s/%s", iMap->db_path, "elemental_db.txt");
+ memset(elemental->elemental_db,0,sizeof(elemental->elemental_db));
+
+ fp = fopen(line, "r");
+ if( !fp ) {
+ ShowError("read_elementaldb : can't read elemental_db.txt\n");
+ return -1;
+ }
+
+ while( fgets(line, sizeof(line), fp) && j < MAX_ELEMENTAL_CLASS ) {
+ k++;
+ if( line[0] == '/' && line[1] == '/' )
+ continue;
+
+ if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r')
+ continue;
+
+ i = 0;
+ p = strtok(line, ",");
+ while( p != NULL && i < 26 ) {
+ str[i++] = p;
+ p = strtok(NULL, ",");
+ }
+ if( i < 26 ) {
+ ShowError("read_elementaldb : Incorrect number of columns at elemental_db.txt line %d.\n", k);
+ continue;
+ }
+
+ db = &elemental->elemental_db[j];
+ db->class_ = atoi(str[0]);
+ safestrncpy(db->sprite, str[1], NAME_LENGTH);
+ safestrncpy(db->name, str[2], NAME_LENGTH);
+ db->lv = atoi(str[3]);
+
+ status = &db->status;
+ db->vd.class_ = db->class_;
+
+ status->max_hp = atoi(str[4]);
+ status->max_sp = atoi(str[5]);
+ status->rhw.range = atoi(str[6]);
+ status->rhw.atk = atoi(str[7]);
+ status->rhw.atk2 = atoi(str[8]);
+ status->def = atoi(str[9]);
+ status->mdef = atoi(str[10]);
+ status->str = atoi(str[11]);
+ status->agi = atoi(str[12]);
+ status->vit = atoi(str[13]);
+ status->int_ = atoi(str[14]);
+ status->dex = atoi(str[15]);
+ status->luk = atoi(str[16]);
+ db->range2 = atoi(str[17]);
+ db->range3 = atoi(str[18]);
+ status->size = atoi(str[19]);
+ status->race = atoi(str[20]);
+
+ ele = atoi(str[21]);
+ status->def_ele = ele%10;
+ status->ele_lv = ele/20;
+ if( status->def_ele >= ELE_MAX ) {
+ ShowWarning("Elemental %d has invalid element type %d (max element is %d)\n", db->class_, status->def_ele, ELE_MAX - 1);
+ status->def_ele = ELE_NEUTRAL;
+ }
+ if( status->ele_lv < 1 || status->ele_lv > 4 ) {
+ ShowWarning("Elemental %d has invalid element level %d (max is 4)\n", db->class_, status->ele_lv);
+ status->ele_lv = 1;
+ }
+
+ status->aspd_rate = 1000;
+ status->speed = atoi(str[22]);
+ status->adelay = atoi(str[23]);
+ status->amotion = atoi(str[24]);
+ status->dmotion = atoi(str[25]);
+
+ j++;
+ }
+
+ fclose(fp);
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' elementals in '"CL_WHITE"db/elemental_db.txt"CL_RESET"'.\n",j);
+
+ return 0;
+}
+
+int read_elemental_skilldb(void) {
+ FILE *fp;
+ char line[1024], *p;
+ char *str[4];
+ struct s_elemental_db *db;
+ int i, j = 0, k = 0, class_;
+ uint16 skill_id, skill_lv;
+ int skillmode;
+
+ sprintf(line, "%s/%s", iMap->db_path, "elemental_skill_db.txt");
+ fp = fopen(line, "r");
+ if( !fp ) {
+ ShowError("read_elemental_skilldb : can't read elemental_skill_db.txt\n");
+ return -1;
+ }
+
+ while( fgets(line, sizeof(line), fp) ) {
+ k++;
+ if( line[0] == '/' && line[1] == '/' )
+ continue;
+
+ if( line[0] == '\0' || line[0] == '\n' || line[0] == '\r')
+ continue;
+
+ i = 0;
+ p = strtok(line, ",");
+ while( p != NULL && i < 4 ) {
+ str[i++] = p;
+ p = strtok(NULL, ",");
+ }
+ if( i < 4 ) {
+ ShowError("read_elemental_skilldb : Incorrect number of columns at elemental_skill_db.txt line %d.\n", k);
+ continue;
+ }
+
+ class_ = atoi(str[0]);
+ ARR_FIND(0, MAX_ELEMENTAL_CLASS, i, class_ == elemental->elemental_db[i].class_);
+ if( i == MAX_ELEMENTAL_CLASS ) {
+ ShowError("read_elemental_skilldb : Class not found in elemental_db for skill entry, line %d.\n", k);
+ continue;
+ }
+
+ skill_id = atoi(str[1]);
+ if( skill_id < EL_SKILLBASE || skill_id >= EL_SKILLBASE + MAX_ELEMENTALSKILL ) {
+ ShowError("read_elemental_skilldb : Skill out of range, line %d.\n", k);
+ continue;
+ }
+
+ db = &elemental->elemental_db[i];
+ skill_lv = atoi(str[2]);
+
+ skillmode = atoi(str[3]);
+ if( skillmode < EL_SKILLMODE_PASIVE || skillmode > EL_SKILLMODE_AGGRESSIVE ) {
+ ShowError("read_elemental_skilldb : Skillmode out of range, line %d.\n",k);
+ continue;
+ }
+ ARR_FIND( 0, MAX_ELESKILLTREE, i, db->skill[i].id == 0 || db->skill[i].id == skill_id );
+ if( i == MAX_ELESKILLTREE ) {
+ ShowWarning("Unable to load skill %d into Elemental %d's tree. Maximum number of skills per elemental has been reached.\n", skill_id, class_);
+ continue;
+ }
+ db->skill[i].id = skill_id;
+ db->skill[i].lv = skill_lv;
+ db->skill[i].mode = skillmode;
+ j++;
+ }
+
+ fclose(fp);
+ ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"db/elemental_skill_db.txt"CL_RESET"'.\n",j);
+ return 0;
+}
+
+void reload_elementaldb(void) {
+ read_elementaldb();
+ elemental->reload_skilldb();
+}
+
+void reload_elemental_skilldb(void) {
+ elemental->read_skilldb();
+}
+
+int do_init_elemental(void) {
+ read_elementaldb();
+ elemental->read_skilldb();
+
+ iTimer->add_timer_func_list(elemental_ai_timer,"elemental_ai_timer");
+ iTimer->add_timer_interval(iTimer->gettick()+MIN_ELETHINKTIME,elemental_ai_timer,0,0,MIN_ELETHINKTIME);
+
+ return 0;
+}
+
+void do_final_elemental(void) {
+ return;
+}
+
+/*=====================================
+* Default Functions : elemental.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+void elemental_defaults(void) {
+ elemental = &elemental_s;
+
+ /* funcs */
+
+ elemental->class = elemental_class;
+ elemental->get_viewdata = elemental_get_viewdata;
+
+ elemental->create = elemental_create;
+ elemental->data_received = elemental_data_received;
+ elemental->save = elemental_save;
+
+ elemental->change_mode_ack = elemental_change_mode_ack;
+ elemental->change_mode = elemental_change_mode;
+
+ elemental->heal = elemental_heal;
+ elemental->dead = elemental_dead;
+
+ elemental->delete = elemental_delete;
+ elemental->summon_stop = elemental_summon_stop;
+
+ elemental->get_lifetime = elemental_get_lifetime;
+
+ elemental->unlocktarget = elemental_unlocktarget;
+ elemental->skillnotok = elemental_skillnotok;
+ elemental->set_target = elemental_set_target;
+ elemental->clean_single_effect = elemental_clean_single_effect;
+ elemental->clean_effect = elemental_clean_effect;
+ elemental->action = elemental_action;
+ elemental->skill_get_requirements = elemental_skill_get_requirements;
+
+ elemental->read_skilldb = read_elemental_skilldb;
+ elemental->reload_elementaldb = reload_elementaldb;
+ elemental->reload_skilldb = reload_elemental_skilldb;
+ elemental->do_init_elemental = do_init_elemental;
+ elemental->do_final_elemental = do_final_elemental;
+}
diff --git a/src/map/elemental.h b/src/map/elemental.h
index 96d2ed89f..ccc3bcb5f 100644
--- a/src/map/elemental.h
+++ b/src/map/elemental.h
@@ -1,106 +1,100 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
-#ifndef _ELEMENTAL_H_
-#define _ELEMENTAL_H_
-#include "status.h" // struct status_data, struct status_change
-#include "unit.h" // struct unit_data
-#define MIN_ELETHINKTIME 100
-#define MIN_ELEDISTANCE 2
-#define MAX_ELEDISTANCE 5
-#define EL_MODE_AGGRESSIVE (MD_CANMOVE|MD_AGGRESSIVE|MD_CANATTACK)
-#define EL_MODE_ASSIST (MD_CANMOVE|MD_ASSIST)
-#define EL_MODE_PASSIVE MD_CANMOVE
-#define EL_SKILLMODE_PASIVE 0x1
-#define EL_SKILLMODE_ASSIST 0x2
-#define EL_SKILLMODE_AGGRESSIVE 0x4
-struct elemental_skill {
- unsigned short id, lv;
- short mode;
-};
-struct s_elemental_db {
- int class_;
- char sprite[NAME_LENGTH], name[NAME_LENGTH];
- unsigned short lv;
- short range2, range3;
- struct status_data status;
- struct view_data vd;
- struct elemental_skill skill[MAX_ELESKILLTREE];
-};
-struct elemental_data {
- struct block_list bl;
- struct unit_data ud;
- struct view_data *vd;
- struct status_data base_status, battle_status;
- struct status_change sc;
- struct regen_data regen;
-
- struct s_elemental_db *db;
- struct s_elemental elemental;
-
- struct map_session_data *master;
- int summon_timer;
- int skill_timer;
-
- unsigned last_thinktime, last_linktime, last_spdrain_time;
- short min_chase;
- int target_id, attacked_id;
-};
-
-
-
-
-
-
-
-
-#define elemental_stop_walking(ed, type) unit_stop_walking(&(ed)->bl, type)
-#define elemental_stop_attack(ed) unit_stop_attack(&(ed)->bl)
-
-
-/*=====================================
-* Interface : elemental.h
-* Generated by HerculesInterfaceMaker
-* created by Susu
-*-------------------------------------*/
-struct elemental_interface {
- /* vars */
- struct s_elemental_db elemental_db[MAX_ELEMENTAL_CLASS]; // Elemental Database
- /* funcs */
- bool (*class) (int class_);
- struct view_data * (*get_viewdata) (int class_);
-
- int (*create) (struct map_session_data *sd, int class_, unsigned int lifetime);
- int (*data_received) (struct s_elemental *ele, bool flag);
- int (*save) (struct elemental_data *ed);
-
- int (*change_mode_ack) (struct elemental_data *ed, int mode);
- int (*change_mode) (struct elemental_data *ed, int mode);
-
- void (*heal) (struct elemental_data *ed, int hp, int sp);
- int (*dead) (struct elemental_data *ed);
-
- int (*delete) (struct elemental_data *ed, int reply);
- void (*summon_stop) (struct elemental_data *ed);
-
- int (*get_lifetime) (struct elemental_data *ed);
-
- int (*unlocktarget) (struct elemental_data *ed);
- int (*skillnotok) (uint16 skill_id, struct elemental_data *ed);
- int (*set_target) (struct map_session_data *sd, struct block_list *bl);
- int (*clean_single_effect) (struct elemental_data *ed, uint16 skill_id);
- int (*clean_effect) (struct elemental_data *ed);
- int (*action) (struct elemental_data *ed, struct block_list *bl, unsigned int tick);
- struct skill_condition (*skill_get_requirements) (uint16 skill_id, uint16 skill_lv);
-
- int (*read_skilldb) (void);
- void (*reload_elementaldb) (void);
- void (*reload_skilldb) (void);
- int (*do_init_elemental) (void);
- void (*do_final_elemental) (void);
-} elemental_s;
-
-struct elemental_interface *elemental;
-
-void elemental_defaults(void);
-
-#endif /* _ELEMENTAL_H_ */
+// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+#ifndef _ELEMENTAL_H_
+#define _ELEMENTAL_H_
+#include "status.h" // struct status_data, struct status_change
+#include "unit.h" // struct unit_data
+#define MIN_ELETHINKTIME 100
+#define MIN_ELEDISTANCE 2
+#define MAX_ELEDISTANCE 5
+#define EL_MODE_AGGRESSIVE (MD_CANMOVE|MD_AGGRESSIVE|MD_CANATTACK)
+#define EL_MODE_ASSIST (MD_CANMOVE|MD_ASSIST)
+#define EL_MODE_PASSIVE MD_CANMOVE
+#define EL_SKILLMODE_PASIVE 0x1
+#define EL_SKILLMODE_ASSIST 0x2
+#define EL_SKILLMODE_AGGRESSIVE 0x4
+struct elemental_skill {
+ unsigned short id, lv;
+ short mode;
+};
+struct s_elemental_db {
+ int class_;
+ char sprite[NAME_LENGTH], name[NAME_LENGTH];
+ unsigned short lv;
+ short range2, range3;
+ struct status_data status;
+ struct view_data vd;
+ struct elemental_skill skill[MAX_ELESKILLTREE];
+};
+struct elemental_data {
+ struct block_list bl;
+ struct unit_data ud;
+ struct view_data *vd;
+ struct status_data base_status, battle_status;
+ struct status_change sc;
+ struct regen_data regen;
+
+ struct s_elemental_db *db;
+ struct s_elemental elemental;
+
+ struct map_session_data *master;
+ int summon_timer;
+ int skill_timer;
+
+ unsigned last_thinktime, last_linktime, last_spdrain_time;
+ short min_chase;
+ int target_id, attacked_id;
+};
+
+#define elemental_stop_walking(ed, type) unit->stop_walking(&(ed)->bl, type)
+#define elemental_stop_attack(ed) unit->stop_attack(&(ed)->bl)
+
+/*=====================================
+* Interface : elemental.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+struct elemental_interface {
+
+ /* vars */
+ struct s_elemental_db elemental_db[MAX_ELEMENTAL_CLASS]; // Elemental Database
+
+ /* funcs */
+ bool (*class) (int class_);
+ struct view_data * (*get_viewdata) (int class_);
+
+ int (*create) (struct map_session_data *sd, int class_, unsigned int lifetime);
+ int (*data_received) (struct s_elemental *ele, bool flag);
+ int (*save) (struct elemental_data *ed);
+
+ int (*change_mode_ack) (struct elemental_data *ed, int mode);
+ int (*change_mode) (struct elemental_data *ed, int mode);
+
+ void (*heal) (struct elemental_data *ed, int hp, int sp);
+ int (*dead) (struct elemental_data *ed);
+
+ int (*delete) (struct elemental_data *ed, int reply);
+ void (*summon_stop) (struct elemental_data *ed);
+
+ int (*get_lifetime) (struct elemental_data *ed);
+
+ int (*unlocktarget) (struct elemental_data *ed);
+ int (*skillnotok) (uint16 skill_id, struct elemental_data *ed);
+ int (*set_target) (struct map_session_data *sd, struct block_list *bl);
+ int (*clean_single_effect) (struct elemental_data *ed, uint16 skill_id);
+ int (*clean_effect) (struct elemental_data *ed);
+ int (*action) (struct elemental_data *ed, struct block_list *bl, unsigned int tick);
+ struct skill_condition (*skill_get_requirements) (uint16 skill_id, uint16 skill_lv);
+
+ int (*read_skilldb) (void);
+ void (*reload_elementaldb) (void);
+ void (*reload_skilldb) (void);
+ int (*do_init_elemental) (void);
+ void (*do_final_elemental) (void);
+} elemental_s;
+
+struct elemental_interface *elemental;
+
+void elemental_defaults(void);
+
+#endif /* _ELEMENTAL_H_ */
diff --git a/src/map/guild.c b/src/map/guild.c
index 601d88387..6219fc770 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -429,7 +429,7 @@ int guild_npc_request_info(int guild_id,const char *event)
if( guild->search(guild_id) )
{
if( event && *event )
- npc_event_do(event);
+ npc->event_do(event);
return 0;
}
@@ -622,7 +622,7 @@ int guild_recv_info(struct guild *sg) {
if (guild_infoevent_db->remove(guild_infoevent_db, DB->i2key(sg->guild_id), &data)) {
struct eventlist *ev = DB->data2ptr(&data), *ev2;
while(ev) {
- npc_event_do(ev->name);
+ npc->event_do(ev->name);
ev2=ev->next;
aFree(ev);
ev=ev2;
@@ -1736,7 +1736,7 @@ int castle_guild_broken_sub(DBKey key, DBData *data, va_list ap)
// We call castle_event::OnGuildBreak of all castles of the guild
// You can set all castle_events in the 'db/castle_db.txt'
safestrncpy(name, gc->castle_event, sizeof(name));
- npc_event_do(strcat(name, "::OnGuildBreak"));
+ npc->event_do(strcat(name, "::OnGuildBreak"));
//Save the new 'owner', this should invoke guardian clean up and other such things.
guild->castledatasave(gc->castle_id, 1, 0);
@@ -1883,7 +1883,7 @@ int guild_break(struct map_session_data *sd,char *name) {
}
/* regardless of char server allowing it, we clear the guild master's auras */
- if( (ud = unit_bl2ud(&sd->bl)) ) {
+ if( (ud = unit->bl2ud(&sd->bl)) ) {
int count = 0;
struct skill_unit_group *groups[4];
for (i=0;i<MAX_SKILLUNITGROUP && ud->skillunit[i];i++) {
@@ -1960,7 +1960,7 @@ int guild_castledatasave(int castle_id, int index, int value)
gc->guild_id = value;
for (i = 0; i < MAX_GUARDIANS; i++)
if (gc->guardian[i].visible && (gd = iMap->id2md(gc->guardian[i].id)) != NULL)
- mob_guardian_guildchange(gd);
+ mob->guardian_guildchange(gd);
break;
}
case 2:
@@ -2044,8 +2044,8 @@ int guild_castledataloadack(int len, struct guild_castle *gc)
ev = i; // offset of castle or -1
if( ev < 0 ) { //No castles owned, invoke OnAgitInit as it is.
- npc_event_doall("OnAgitInit");
- npc_event_doall("OnAgitInit2");
+ npc->event_doall("OnAgitInit");
+ npc->event_doall("OnAgitInit2");
} else { // load received castles into memory, one by one
for( i = 0; i < n; i++, gc++ ) {
struct guild_castle *c = guild->castle_search(gc->castle_id);
@@ -2076,7 +2076,7 @@ int guild_castledataloadack(int len, struct guild_castle *gc)
*---------------------------------------------------*/
void guild_agit_start(void)
{ // Run All NPC_Event[OnAgitStart]
- int c = npc_event_doall("OnAgitStart");
+ int c = npc->event_doall("OnAgitStart");
ShowStatus("NPC_Event:[OnAgitStart] Run (%d) Events by @AgitStart.\n",c);
}
@@ -2085,7 +2085,7 @@ void guild_agit_start(void)
*---------------------------------------------------*/
void guild_agit_end(void)
{ // Run All NPC_Event[OnAgitEnd]
- int c = npc_event_doall("OnAgitEnd");
+ int c = npc->event_doall("OnAgitEnd");
ShowStatus("NPC_Event:[OnAgitEnd] Run (%d) Events by @AgitEnd.\n",c);
}
@@ -2094,7 +2094,7 @@ void guild_agit_end(void)
*---------------------------------------------------*/
void guild_agit2_start(void)
{ // Run All NPC_Event[OnAgitStart2]
- int c = npc_event_doall("OnAgitStart2");
+ int c = npc->event_doall("OnAgitStart2");
ShowStatus("NPC_Event:[OnAgitStart2] Run (%d) Events by @AgitStart2.\n",c);
}
@@ -2103,7 +2103,7 @@ void guild_agit2_start(void)
*---------------------------------------------------*/
void guild_agit2_end(void)
{ // Run All NPC_Event[OnAgitEnd2]
- int c = npc_event_doall("OnAgitEnd2");
+ int c = npc->event_doall("OnAgitEnd2");
ShowStatus("NPC_Event:[OnAgitEnd2] Run (%d) Events by @AgitEnd2.\n",c);
}
diff --git a/src/map/homunculus.c b/src/map/homunculus.c
index 3a6ed074c..81971ebef 100644
--- a/src/map/homunculus.c
+++ b/src/map/homunculus.c
@@ -157,7 +157,7 @@ int homunculus_vaporize(struct map_session_data *sd, int flag) {
memset(hd->blockskill, 0, sizeof(hd->blockskill));
clif->hominfo(sd, sd->hd, 0);
homun->save(hd);
- return unit_remove_map(&hd->bl, CLR_OUTSIGHT);
+ return unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK);
}
//delete a homunculus, completely "killing it".
@@ -168,7 +168,7 @@ int homunculus_delete(struct homun_data *hd, int emote) {
sd = hd->master;
if (!sd)
- return unit_free(&hd->bl,CLR_DEAD);
+ return unit->free(&hd->bl,CLR_DEAD);
if (emote >= 0)
clif->emotion(&sd->bl, emote);
@@ -178,7 +178,7 @@ int homunculus_delete(struct homun_data *hd, int emote) {
// Send homunculus_dead to client
hd->homunculus.hp = 0;
clif->hominfo(sd, hd, 0);
- return unit_remove_map(&hd->bl,CLR_OUTSIGHT);
+ return unit->remove_map(&hd->bl,CLR_OUTSIGHT, ALC_MARK);
}
int homunculus_calc_skilltree(struct homun_data *hd, int flag_evolve) {
@@ -403,7 +403,7 @@ bool homunculus_evolve(struct homun_data *hd) {
hom->luk += 10*rnd_value(min->luk, max->luk);
hom->intimacy = 500;
- unit_remove_map(&hd->bl, CLR_OUTSIGHT);
+ unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK);
iMap->addblock(&hd->bl);
clif->spawn(&hd->bl);
@@ -447,7 +447,7 @@ bool homunculus_mutate(struct homun_data *hd, int homun_id) {
return false;
}
- unit_remove_map(&hd->bl, CLR_OUTSIGHT);
+ unit->remove_map(&hd->bl, CLR_OUTSIGHT, ALC_MARK);
iMap->addblock(&hd->bl);
clif->spawn(&hd->bl);
@@ -736,7 +736,7 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) {
}
sd->hd = hd = (struct homun_data*)aCalloc(1,sizeof(struct homun_data));
hd->bl.type = BL_HOM;
- hd->bl.id = npc_get_new_npc_id();
+ hd->bl.id = npc->get_new_npc_id();
hd->master = sd;
hd->homunculusDB = &homun->db[i];
@@ -745,14 +745,14 @@ bool homunculus_create(struct map_session_data *sd, struct s_homunculus *hom) {
iStatus->set_viewdata(&hd->bl, hd->homunculus.class_);
iStatus->change_init(&hd->bl);
- unit_dataset(&hd->bl);
+ unit->dataset(&hd->bl);
hd->ud.dir = sd->ud.dir;
// Find a random valid pos around the player
hd->bl.m = sd->bl.m;
hd->bl.x = sd->bl.x;
hd->bl.y = sd->bl.y;
- unit_calc_pos(&hd->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
+ unit->calc_pos(&hd->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
hd->bl.x = hd->ud.to_x;
hd->bl.y = hd->ud.to_y;
@@ -801,7 +801,7 @@ bool homunculus_call(struct map_session_data *sd) {
homun->save(hd);
} else
//Warp him to master.
- unit_warp(&hd->bl,sd->bl.m, sd->bl.x, sd->bl.y,CLR_OUTSIGHT);
+ unit->warp(&hd->bl,sd->bl.m, sd->bl.x, sd->bl.y,CLR_OUTSIGHT);
return true;
}
diff --git a/src/map/instance.c b/src/map/instance.c
index 4e145fb8f..98a0dfc8f 100644
--- a/src/map/instance.c
+++ b/src/map/instance.c
@@ -297,7 +297,7 @@ int instance_map_npcsub(struct block_list* bl, va_list args) {
struct npc_data* nd = (struct npc_data*)bl;
int16 m = va_arg(args, int); // Destination Map
- if ( npc_duplicate4instance(nd, m) )
+ if ( npc->duplicate4instance(nd, m) )
ShowDebug("instance_map_npcsub:npc_duplicate4instance failed (%s/%d)\n",nd->name,m);
return 1;
@@ -341,10 +341,10 @@ int instance_cleanup_sub(struct block_list *bl, va_list ap) {
iMap->quit((struct map_session_data *) bl);
break;
case BL_NPC:
- npc_unload((struct npc_data *)bl,true);
+ npc->unload((struct npc_data *)bl,true);
break;
case BL_MOB:
- unit_free(bl,CLR_OUTSIGHT);
+ unit->free(bl,CLR_OUTSIGHT);
break;
case BL_PET:
//There is no need for this, the pet is removed together with the player. [Skotlex]
diff --git a/src/map/intif.c b/src/map/intif.c
index 1713cb38e..ac1471d23 100644
--- a/src/map/intif.c
+++ b/src/map/intif.c
@@ -1278,7 +1278,7 @@ int intif_parse_GuildMasterChanged(int fd)
// Request pet creation
int intif_parse_CreatePet(int fd)
{
- pet_get_egg(RFIFOL(fd,2),RFIFOL(fd,7),RFIFOB(fd,6));
+ pet->get_egg(RFIFOL(fd,2),RFIFOL(fd,7),RFIFOB(fd,6));
return 0;
}
@@ -1294,7 +1294,7 @@ int intif_parse_RecvPetData(int fd)
}
else{
memcpy(&p,RFIFOP(fd,9),sizeof(struct s_pet));
- pet_recv_petdata(RFIFOL(fd,4),&p,RFIFOB(fd,8));
+ pet->recv_petdata(RFIFOL(fd,4),&p,RFIFOB(fd,8));
}
return 0;
@@ -1330,7 +1330,7 @@ int intif_parse_ChangeNameOk(int fd)
case 0: //Players [NOT SUPPORTED YET]
break;
case 1: //Pets
- pet_change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11));
+ pet->change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11));
break;
case 2: //Hom
homun->change_name_ack(sd, (char*)RFIFOP(fd,12), RFIFOB(fd,11));
@@ -1419,7 +1419,7 @@ int intif_parse_questlog(int fd)
{
memcpy(&sd->quest_log[i], RFIFOP(fd, i*sizeof(struct quest)+8), sizeof(struct quest));
- sd->quest_index[i] = quest_search_db(sd->quest_log[i].quest_id);
+ sd->quest_index[i] = quest->search_db(sd->quest_log[i].quest_id);
if( sd->quest_index[i] < 0 )
{
@@ -1434,7 +1434,7 @@ int intif_parse_questlog(int fd)
sd->avail_quests--;
}
- quest_pc_login(sd);
+ quest->pc_login(sd);
return 0;
}
diff --git a/src/map/intif.h b/src/map/intif.h
index f0c1067fb..8abcf819d 100644
--- a/src/map/intif.h
+++ b/src/map/intif.h
@@ -1,128 +1,128 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
-#ifndef _INTIF_H_
-#define _INFIF_H_
-//#include "../common/mmo.h"
-struct party_member;
-struct guild_member;
-struct guild_position;
-struct s_pet;
-struct s_homunculus;
-struct s_mercenary;
-struct s_elemental;
-struct mail_message;
-struct auction_data;
-
-
-
-
-
-#define intif_rename_pc(sd, name) intif->rename(sd, 0, name)
-#define intif_rename_pet(sd, name) intif->rename(sd, 1, name)
-#define intif_rename_hom(sd, name) intif->rename(sd, 2, name)
-
-
-
-
-
-
-/*=====================================
-* Interface : intif.h
-* Generated by HerculesInterfaceMaker
-* created by Susu
-*-------------------------------------*/
-struct intif_interface {
- /* funcs */
-
-
- int (*parse) (int fd);
-
- int (*create_pet)(int account_id, int char_id, short pet_type, short pet_lv, short pet_egg_id,
- short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name);
-
- int (*broadcast) (const char* mes, int len, int type);
- int (*broadcast2) (const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY);
- int (*main_message) (struct map_session_data* sd, const char* message);
-
- int (*wis_message) (struct map_session_data *sd,char *nick,char *mes,int mes_len);
- int (*wis_message_to_gm) (char *Wisp_name, int permission, char *mes);
-
- int (*saveregistry) (struct map_session_data *sd, int type);
- int (*request_registry) (struct map_session_data *sd, int flag);
-
- int (*request_guild_storage) (int account_id, int guild_id);
- int (*send_guild_storage) (int account_id, struct guild_storage *gstor);
-
- int (*create_party) (struct party_member *member,char *name,int item,int item2);
- int (*request_partyinfo) (int party_id, int char_id);
-
- int (*party_addmember) (int party_id,struct party_member *member);
- int (*party_changeoption) (int party_id, int account_id, int exp, int item);
- int (*party_leave) (int party_id,int account_id, int char_id);
- int (*party_changemap) (struct map_session_data *sd, int online);
- int (*break_party) (int party_id);
- int (*party_message) (int party_id, int account_id, const char *mes,int len);
- int (*party_leaderchange) (int party_id,int account_id,int char_id);
-
- int (*guild_create) (const char *name, const struct guild_member *master);
- int (*guild_request_info) (int guild_id);
- int (*guild_addmember) (int guild_id, struct guild_member *m);
- int (*guild_leave) (int guild_id, int account_id, int char_id, int flag, const char *mes);
- int (*guild_memberinfoshort) (int guild_id, int account_id, int char_id, int online, int lv, int class_);
- int (*guild_break) (int guild_id);
- int (*guild_message) (int guild_id, int account_id, const char *mes, int len);
- int (*guild_change_gm) (int guild_id, const char* name, int len);
- int (*guild_change_basicinfo) (int guild_id, int type, const void *data, int len);
- int (*guild_change_memberinfo) (int guild_id, int account_id, int char_id, int type, const void *data, int len);
- int (*guild_position) (int guild_id, int idx, struct guild_position *p);
- int (*guild_skillup) (int guild_id, uint16 skill_id, int account_id, int max);
- int (*guild_alliance) (int guild_id1, int guild_id2, int account_id1, int account_id2, int flag);
- int (*guild_notice) (int guild_id, const char *mes1, const char *mes2);
- int (*guild_emblem) (int guild_id, int len, const char *data);
- int (*guild_castle_dataload) (int num, int *castle_ids);
- int (*guild_castle_datasave) (int castle_id, int index, int value);
- int (*request_petdata) (int account_id, int char_id, int pet_id);
- int (*save_petdata) (int account_id, struct s_pet *p);
- int (*delete_petdata) (int pet_id);
- int (*rename) (struct map_session_data *sd, int type, char *name);
- int (*homunculus_create) (int account_id, struct s_homunculus *sh);
- bool (*homunculus_requestload) (int account_id, int homun_id);
- int (*homunculus_requestsave) (int account_id, struct s_homunculus* sh);
- int (*homunculus_requestdelete) (int homun_id);
- /******QUEST SYTEM*******/
- int (*request_questlog) (struct map_session_data * sd);
- int (*quest_save) (struct map_session_data * sd);
- // MERCENARY SYSTEM
- int (*mercenary_create) (struct s_mercenary *merc);
- int (*mercenary_request) (int merc_id, int char_id);
- int (*mercenary_delete) (int merc_id);
- int (*mercenary_save) (struct s_mercenary *merc);
- // MAIL SYSTEM
- int (*Mail_requestinbox) (int char_id, unsigned char flag);
- int (*Mail_read) (int mail_id);
- int (*Mail_getattach) (int char_id, int mail_id);
- int (*Mail_delete) (int char_id, int mail_id);
- int (*Mail_return) (int char_id, int mail_id);
- int (*Mail_send) (int account_id, struct mail_message *msg);
- // AUCTION SYSTEM
- int (*Auction_requestlist) (int char_id, short type, int price, const char* searchtext, short page);
- int (*Auction_register) (struct auction_data *auction);
- int (*Auction_cancel) (int char_id, unsigned int auction_id);
- int (*Auction_close) (int char_id, unsigned int auction_id);
- int (*Auction_bid) (int char_id, const char* name, unsigned int auction_id, int bid);
- // ELEMENTAL SYSTEM
- int (*elemental_create) (struct s_elemental *ele);
- int (*elemental_request) (int ele_id, int char_id);
- int (*elemental_delete) (int ele_id);
- int (*elemental_save) (struct s_elemental *ele);
- /* @accinfo */
- void (*request_accinfo) (int u_fd, int aid, int group_lv, char* query);
-
- int (*CheckForCharServer) (void);
-} intif_s;
-
-struct intif_interface *intif;
-
-void intif_defaults(void);
-
-#endif /* _INTIF_H_ */
+// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
+// For more information, see LICENCE in the main folder
+#ifndef _INTIF_H_
+#define _INFIF_H_
+//#include "../common/mmo.h"
+struct party_member;
+struct guild_member;
+struct guild_position;
+struct s_pet;
+struct s_homunculus;
+struct s_mercenary;
+struct s_elemental;
+struct mail_message;
+struct auction_data;
+
+
+
+
+
+#define intif_rename_pc(sd, name) intif->rename(sd, 0, name)
+#define intif_rename_pet(sd, name) intif->rename(sd, 1, name)
+#define intif_rename_hom(sd, name) intif->rename(sd, 2, name)
+
+
+
+
+
+
+/*=====================================
+* Interface : intif.h
+* Generated by HerculesInterfaceMaker
+* created by Susu
+*-------------------------------------*/
+struct intif_interface {
+ /* funcs */
+
+
+ int (*parse) (int fd);
+
+ int (*create_pet)(int account_id, int char_id, short pet_type, short pet_lv, short pet_egg_id,
+ short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name);
+
+ int (*broadcast) (const char* mes, int len, int type);
+ int (*broadcast2) (const char* mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY);
+ int (*main_message) (struct map_session_data* sd, const char* message);
+
+ int (*wis_message) (struct map_session_data *sd,char *nick,char *mes,int mes_len);
+ int (*wis_message_to_gm) (char *Wisp_name, int permission, char *mes);
+
+ int (*saveregistry) (struct map_session_data *sd, int type);
+ int (*request_registry) (struct map_session_data *sd, int flag);
+
+ int (*request_guild_storage) (int account_id, int guild_id);
+ int (*send_guild_storage) (int account_id, struct guild_storage *gstor);
+
+ int (*create_party) (struct party_member *member,char *name,int item,int item2);
+ int (*request_partyinfo) (int party_id, int char_id);
+
+ int (*party_addmember) (int party_id,struct party_member *member);
+ int (*party_changeoption) (int party_id, int account_id, int exp, int item);
+ int (*party_leave) (int party_id,int account_id, int char_id);
+ int (*party_changemap) (struct map_session_data *sd, int online);
+ int (*break_party) (int party_id);
+ int (*party_message) (int party_id, int account_id, const char *mes,int len);
+ int (*party_leaderchange) (int party_id,int account_id,int char_id);
+
+ int (*guild_create) (const char *name, const struct guild_member *master);
+ int (*guild_request_info) (int guild_id);
+ int (*guild_addmember) (int guild_id, struct guild_member *m);
+ int (*guild_leave) (int guild_id, int account_id, int char_id, int flag, const char *mes);
+ int (*guild_memberinfoshort) (int guild_id, int account_id, int char_id, int online, int lv, int class_);
+ int (*guild_break) (int guild_id);
+ int (*guild_message) (int guild_id, int account_id, const char *mes, int len);
+ int (*guild_change_gm) (int guild_id, const char* name, int len);
+ int (*guild_change_basicinfo) (int guild_id, int type, const void *data, int len);
+ int (*guild_change_memberinfo) (int guild_id, int account_id, int char_id, int type, const void *data, int len);
+ int (*guild_position) (int guild_id, int idx, struct guild_position *p);
+ int (*guild_skillup) (int guild_id, uint16 skill_id, int account_id, int max);
+ int (*guild_alliance) (int guild_id1, int guild_id2, int account_id1, int account_id2, int flag);
+ int (*guild_notice) (int guild_id, const char *mes1, const char *mes2);
+ int (*guild_emblem) (int guild_id, int len, const char *data);
+ int (*guild_castle_dataload) (int num, int *castle_ids);
+ int (*guild_castle_datasave) (int castle_id, int index, int value);
+ int (*request_petdata) (int account_id, int char_id, int pet_id);
+ int (*save_petdata) (int account_id, struct s_pet *p);
+ int (*delete_petdata) (int pet_id);
+ int (*rename) (struct map_session_data *sd, int type, char *name);
+ int (*homunculus_create) (int account_id, struct s_homunculus *sh);
+ bool (*homunculus_requestload) (int account_id, int homun_id);
+ int (*homunculus_requestsave) (int account_id, struct s_homunculus* sh);
+ int (*homunculus_requestdelete) (int homun_id);
+ /******QUEST SYTEM*******/
+ int (*request_questlog) (struct map_session_data * sd);
+ int (*quest_save) (struct map_session_data * sd);
+ // MERCENARY SYSTEM
+ int (*mercenary_create) (struct s_mercenary *merc);
+ int (*mercenary_request) (int merc_id, int char_id);
+ int (*mercenary_delete) (int merc_id);
+ int (*mercenary_save) (struct s_mercenary *merc);
+ // MAIL SYSTEM
+ int (*Mail_requestinbox) (int char_id, unsigned char flag);
+ int (*Mail_read) (int mail_id);
+ int (*Mail_getattach) (int char_id, int mail_id);
+ int (*Mail_delete) (int char_id, int mail_id);
+ int (*Mail_return) (int char_id, int mail_id);
+ int (*Mail_send) (int account_id, struct mail_message *msg);
+ // AUCTION SYSTEM
+ int (*Auction_requestlist) (int char_id, short type, int price, const char* searchtext, short page);
+ int (*Auction_register) (struct auction_data *auction);
+ int (*Auction_cancel) (int char_id, unsigned int auction_id);
+ int (*Auction_close) (int char_id, unsigned int auction_id);
+ int (*Auction_bid) (int char_id, const char* name, unsigned int auction_id, int bid);
+ // ELEMENTAL SYSTEM
+ int (*elemental_create) (struct s_elemental *ele);
+ int (*elemental_request) (int ele_id, int char_id);
+ int (*elemental_delete) (int ele_id);
+ int (*elemental_save) (struct s_elemental *ele);
+ /* @accinfo */
+ void (*request_accinfo) (int u_fd, int aid, int group_lv, char* query);
+
+ int (*CheckForCharServer) (void);
+} intif_s;
+
+struct intif_interface *intif;
+
+void intif_defaults(void);
+
+#endif /* _INTIF_H_ */
diff --git a/src/map/itemdb.c b/src/map/itemdb.c
index fcd4ccbc1..c2a25c2d4 100644
--- a/src/map/itemdb.c
+++ b/src/map/itemdb.c
@@ -19,11 +19,6 @@
#include <stdlib.h>
#include <string.h>
-static struct item_data* itemdb_array[MAX_ITEMDB];
-static DBMap* itemdb_other;// int nameid -> struct item_data*
-
-struct item_data dummy_item; //This is the default dummy item used for non-existant items. [Skotlex]
-
struct itemdb_interface itemdb_s;
/**
@@ -31,14 +26,14 @@ struct itemdb_interface itemdb_s;
* name = item alias, so we should find items aliases first. if not found then look for "jname" (full name)
* @see DBApply
*/
-static int itemdb_searchname_sub(DBKey key, DBData *data, va_list ap)
+int itemdb_searchname_sub(DBKey key, DBData *data, va_list ap)
{
struct item_data *item = DB->data2ptr(data), **dst, **dst2;
char *str;
str=va_arg(ap,char *);
dst=va_arg(ap,struct item_data **);
dst2=va_arg(ap,struct item_data **);
- if(item == &dummy_item) return 0;
+ if(item == &itemdb->dummy) return 0;
//Absolute priority to Aegis code name.
if (*dst != NULL) return 0;
@@ -60,8 +55,8 @@ struct item_data* itemdb_searchname(const char *str) {
struct item_data* item2=NULL;
int i;
- for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) {
- item = itemdb_array[i];
+ for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i ) {
+ item = itemdb->array[i];
if( item == NULL )
continue;
@@ -75,7 +70,7 @@ struct item_data* itemdb_searchname(const char *str) {
}
item = NULL;
- itemdb_other->foreach(itemdb_other,itemdb_searchname_sub,str,&item,&item2);
+ itemdb->other->foreach(itemdb->other,itemdb->searchname_sub,str,&item,&item2);
return item?item:item2;
}
/* name to item data */
@@ -86,12 +81,12 @@ struct item_data* itemdb_name2id(const char *str) {
/**
* @see DBMatcher
*/
-static int itemdb_searchname_array_sub(DBKey key, DBData data, va_list ap)
+int itemdb_searchname_array_sub(DBKey key, DBData data, va_list ap)
{
struct item_data *item = DB->data2ptr(&data);
char *str;
str=va_arg(ap,char *);
- if (item == &dummy_item)
+ if (item == &itemdb->dummy)
return 1; //Invalid item.
if(stristr(item->jname,str))
return 0;
@@ -112,9 +107,9 @@ int itemdb_searchname_array(struct item_data** data, int size, const char *str,
int count=0;
// Search in the array
- for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i )
+ for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i )
{
- item = itemdb_array[i];
+ item = itemdb->array[i];
if( item == NULL )
continue;
@@ -133,7 +128,7 @@ int itemdb_searchname_array(struct item_data** data, int size, const char *str,
DBData *db_data[MAX_SEARCH];
int db_count = 0;
size -= count;
- db_count = itemdb_other->getall(itemdb_other, (DBData**)&db_data, size, itemdb_searchname_array_sub, str);
+ db_count = itemdb->other->getall(itemdb->other, (DBData**)&db_data, size, itemdb->searchname_array_sub, str);
for (i = 0; i < db_count; i++)
data[count++] = DB->data2ptr(db_data[i]);
count += db_count;
@@ -190,7 +185,7 @@ void itemdb_package_item(struct map_session_data *sd, struct item_package *packa
if( package->must_items[i].announce )
clif->package_announce(sd,package->must_items[i].id,package->id);
- get_count = itemdb_isstackable(package->must_items[i].id) ? package->must_items[i].qty : 1;
+ get_count = itemdb->isstackable(package->must_items[i].id) ? package->must_items[i].qty : 1;
it.amount = get_count == 1 ? 1 : get_count;
@@ -231,7 +226,7 @@ void itemdb_package_item(struct map_session_data *sd, struct item_package *packa
if( entry->announce )
clif->package_announce(sd,entry->id,package->id);
- get_count = itemdb_isstackable(entry->id) ? entry->qty : 1;
+ get_count = itemdb->isstackable(entry->id) ? entry->qty : 1;
it.amount = get_count == 1 ? 1 : get_count;
@@ -274,10 +269,10 @@ struct item_data* itemdb_exists(int nameid)
{
struct item_data* item;
- if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) )
- return itemdb_array[nameid];
- item = (struct item_data*)idb_get(itemdb_other,nameid);
- if( item == &dummy_item )
+ if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb->array) )
+ return itemdb->array[nameid];
+ item = (struct item_data*)idb_get(itemdb->other,nameid);
+ if( item == &itemdb->dummy )
return NULL;// dummy data, doesn't exist
return item;
}
@@ -307,7 +302,7 @@ const char* itemdb_typename(int type)
* Converts the jobid from the format in itemdb
* to the format used by the map server. [Skotlex]
*------------------------------------------*/
-static void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask)
+void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask)
{
int i;
bclass[0]= bclass[1]= bclass[2]= 0;
@@ -373,19 +368,19 @@ static void itemdb_jobid2mapid(unsigned int *bclass, unsigned int jobmask)
bclass[1] |= 1<<MAPID_NINJA;
}
-static void create_dummy_data(void)
+void create_dummy_data(void)
{
- memset(&dummy_item, 0, sizeof(struct item_data));
- dummy_item.nameid=500;
- dummy_item.weight=1;
- dummy_item.value_sell=1;
- dummy_item.type=IT_ETC; //Etc item
- safestrncpy(dummy_item.name,"UNKNOWN_ITEM",sizeof(dummy_item.name));
- safestrncpy(dummy_item.jname,"UNKNOWN_ITEM",sizeof(dummy_item.jname));
- dummy_item.view_id=UNKNOWN_ITEM_ID;
+ memset(&itemdb->dummy, 0, sizeof(struct item_data));
+ itemdb->dummy.nameid=500;
+ itemdb->dummy.weight=1;
+ itemdb->dummy.value_sell=1;
+ itemdb->dummy.type=IT_ETC; //Etc item
+ safestrncpy(itemdb->dummy.name,"UNKNOWN_ITEM",sizeof(itemdb->dummy.name));
+ safestrncpy(itemdb->dummy.jname,"UNKNOWN_ITEM",sizeof(itemdb->dummy.jname));
+ itemdb->dummy.view_id=UNKNOWN_ITEM_ID;
}
-static struct item_data* create_item_data(int nameid)
+struct item_data* create_item_data(int nameid)
{
struct item_data *id;
CREATE(id, struct item_data, 1);
@@ -401,19 +396,19 @@ static struct item_data* create_item_data(int nameid)
struct item_data* itemdb_load(int nameid) {
struct item_data *id;
- if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) )
+ if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb->array) )
{
- id = itemdb_array[nameid];
- if( id == NULL || id == &dummy_item )
- id = itemdb_array[nameid] = create_item_data(nameid);
+ id = itemdb->array[nameid];
+ if( id == NULL || id == &itemdb->dummy )
+ id = itemdb->array[nameid] = itemdb->create_item_data(nameid);
return id;
}
- id = (struct item_data*)idb_get(itemdb_other, nameid);
- if( id == NULL || id == &dummy_item )
+ id = (struct item_data*)idb_get(itemdb->other, nameid);
+ if( id == NULL || id == &itemdb->dummy )
{
- id = create_item_data(nameid);
- idb_put(itemdb_other, nameid, id);
+ id = itemdb->create_item_data(nameid);
+ idb_put(itemdb->other, nameid, id);
}
return id;
}
@@ -424,16 +419,16 @@ struct item_data* itemdb_load(int nameid) {
struct item_data* itemdb_search(int nameid)
{
struct item_data* id;
- if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) )
- id = itemdb_array[nameid];
+ if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb->array) )
+ id = itemdb->array[nameid];
else
- id = (struct item_data*)idb_get(itemdb_other, nameid);
+ id = (struct item_data*)idb_get(itemdb->other, nameid);
if( id == NULL )
{
ShowWarning("itemdb_search: Item ID %d does not exists in the item_db. Using dummy data.\n", nameid);
- id = &dummy_item;
- dummy_item.nameid = nameid;
+ id = &itemdb->dummy;
+ itemdb->dummy.nameid = nameid;
}
return id;
}
@@ -546,7 +541,7 @@ int itemdb_canauction_sub(struct item_data* item, int gmlv, int unused) {
int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(struct item_data*, int, int))
{
- struct item_data* item_data = itemdb_search(item->nameid);
+ struct item_data* item_data = itemdb->search(item->nameid);
int i;
if (!func(item_data, gmlv, gmlv2))
@@ -557,7 +552,7 @@ int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(stru
for(i = 0; i < item_data->slot; i++) {
if (!item->card[i]) continue;
- if (!func(itemdb_search(item->card[i]), gmlv, gmlv2))
+ if (!func(itemdb->search(item->card[i]), gmlv, gmlv2))
return 0;
}
return 1;
@@ -594,7 +589,7 @@ int itemdb_isidentified2(struct item_data *data) {
* Search by name for the override flags available items
* (Give item another sprite)
*------------------------------------------*/
-static bool itemdb_read_itemavail(char* str[], int columns, int current)
+bool itemdb_read_itemavail(char* str[], int columns, int current)
{// <nameid>,<sprite>
int nameid, sprite;
struct item_data *id;
@@ -1202,7 +1197,7 @@ void itemdb_read_chains(void) {
/*==========================================
* Reads item trade restrictions [Skotlex]
*------------------------------------------*/
-static bool itemdb_read_itemtrade(char* str[], int columns, int current)
+bool itemdb_read_itemtrade(char* str[], int columns, int current)
{// <nameid>,<mask>,<gm level>
int nameid, flag, gmlv;
struct item_data *id;
@@ -1239,7 +1234,7 @@ static bool itemdb_read_itemtrade(char* str[], int columns, int current)
/*==========================================
* Reads item delay amounts [Paradox924X]
*------------------------------------------*/
-static bool itemdb_read_itemdelay(char* str[], int columns, int current)
+bool itemdb_read_itemdelay(char* str[], int columns, int current)
{// <nameid>,<delay>
int nameid, delay;
struct item_data *id;
@@ -1268,7 +1263,7 @@ static bool itemdb_read_itemdelay(char* str[], int columns, int current)
/*==================================================================
* Reads item stacking restrictions
*----------------------------------------------------------------*/
-static bool itemdb_read_stack(char* fields[], int columns, int current)
+bool itemdb_read_stack(char* fields[], int columns, int current)
{// <item id>,<stack limit amount>,<type>
unsigned short nameid, amount;
unsigned int type;
@@ -1282,7 +1277,7 @@ static bool itemdb_read_stack(char* fields[], int columns, int current)
return false;
}
- if( !itemdb_isstackable2(id) )
+ if( !itemdb->isstackable2(id) )
{
ShowWarning("itemdb_read_stack: Item id '%hu' is not stackable.\n", nameid);
return false;
@@ -1307,7 +1302,7 @@ static bool itemdb_read_stack(char* fields[], int columns, int current)
/// Reads items allowed to be sold in buying stores
-static bool itemdb_read_buyingstore(char* fields[], int columns, int current)
+bool itemdb_read_buyingstore(char* fields[], int columns, int current)
{// <nameid>
int nameid;
struct item_data* id;
@@ -1320,7 +1315,7 @@ static bool itemdb_read_buyingstore(char* fields[], int columns, int current)
return false;
}
- if( !itemdb_isstackable2(id) )
+ if( !itemdb->isstackable2(id) )
{
ShowWarning("itemdb_read_buyingstore: Non-stackable item id %d cannot be enabled for buying store.\n", nameid);
return false;
@@ -1334,7 +1329,7 @@ static bool itemdb_read_buyingstore(char* fields[], int columns, int current)
/*******************************************
** Item usage restriction (item_nouse.txt)
********************************************/
-static bool itemdb_read_nouse(char* fields[], int columns, int current)
+bool itemdb_read_nouse(char* fields[], int columns, int current)
{// <nameid>,<flag>,<override>
int nameid, flag, override;
struct item_data* id;
@@ -1443,7 +1438,7 @@ void itemdb_read_combos() {
struct item_data * id = NULL;
int idx = 0;
- if((retcount = itemdb_combo_split_atoi(str[0], items)) < 2) {
+ if((retcount = itemdb->combo_split_atoi(str[0], items)) < 2) {
ShowError("itemdb_read_combos: line %d of \"%s\" doesn't have enough items to make for a combo (min:2), skipping.\n", lines, path);
continue;
}
@@ -1524,7 +1519,7 @@ void itemdb_read_combos() {
/*======================================
* Applies gender restrictions according to settings. [Skotlex]
*======================================*/
-static int itemdb_gendercheck(struct item_data *id)
+int itemdb_gendercheck(struct item_data *id)
{
if (id->nameid == WEDDING_RING_M) //Grom Ring
return 1;
@@ -1588,7 +1583,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt)
}
//ID,Name,Jname,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Job Upper,Gender,Loc,wLV,eLV,refineable,View
- id = itemdb_load(nameid);
+ id = itemdb->load(nameid);
safestrncpy(id->name, str[1], sizeof(id->name));
safestrncpy(id->jname, str[2], sizeof(id->jname));
@@ -1637,7 +1632,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt)
id->matk = atoi(str[8]);
offset += 1;
} else
- itemdb_re_split_atoi(str[7],&id->atk,&id->matk);
+ itemdb->re_split_atoi(str[7],&id->atk,&id->matk);
#else
id->atk = atoi(str[7]);
#endif
@@ -1650,12 +1645,12 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt)
id->slot = MAX_SLOTS;
}
- itemdb_jobid2mapid(id->class_base, (unsigned int)strtoul(str[11+offset],NULL,0));
+ itemdb->jobid2mapid(id->class_base, (unsigned int)strtoul(str[11+offset],NULL,0));
id->class_upper = atoi(str[12+offset]);
id->sex = atoi(str[13+offset]);
id->equip = atoi(str[14+offset]);
- if (!id->equip && itemdb_isequip2(id)) {
+ if (!id->equip && itemdb->isequip2(id)) {
ShowWarning("Item %d (%s) is an equipment with no equip-field! Making it an etc item.\n", nameid, id->jname);
id->type = IT_ETC;
}
@@ -1667,7 +1662,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt)
id->elvmax = atoi(str[17+offset]);
offset += 1;
} else
- itemdb_re_split_atoi(str[16],&id->elv,&id->elvmax);
+ itemdb->re_split_atoi(str[16],&id->elv,&id->elvmax);
#else
id->elv = atoi(str[16]);
#endif
@@ -1676,7 +1671,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt)
id->flag.available = 1;
id->view_id = 0;
- id->sex = itemdb_gendercheck(id); //Apply gender filtering.
+ id->sex = itemdb->gendercheck(id); //Apply gender filtering.
if (id->script) {
script->free_code(id->script);
@@ -1705,7 +1700,7 @@ int itemdb_parse_dbrow(char** str, const char* source, int line, int scriptopt)
* Reading item from item db
* item_db2 overwriting item_db
*------------------------------------------*/
-static int itemdb_readdb(void)
+int itemdb_readdb(void)
{
const char* filename[] = {
DBPATH"item_db.txt",
@@ -1831,7 +1826,7 @@ static int itemdb_readdb(void)
/*======================================
* item_db table reading
*======================================*/
-static int itemdb_read_sqldb(void) {
+int itemdb_read_sqldb(void) {
const char* item_db_name[] = {
#ifdef RENEWAL
@@ -1914,7 +1909,7 @@ int itemdb_uid_load() {
}
SQL->GetData(mmysql_handle, 0, &uid, NULL);
- itemdb_unique_id(1, (uint64)strtoull(uid, NULL, 10));
+ itemdb->unique_id(1, (uint64)strtoull(uid, NULL, 10));
SQL->FreeResult(mmysql_handle);
return 0;
@@ -1923,37 +1918,37 @@ int itemdb_uid_load() {
/*====================================
* read all item-related databases
*------------------------------------*/
-static void itemdb_read(void) {
+void itemdb_read(void) {
int i;
DBData prev;
if (iMap->db_use_sql_item_db)
- itemdb_read_sqldb();
+ itemdb->read_sqldb();
else
- itemdb_readdb();
+ itemdb->readdb();
- for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i ) {
- if( itemdb_array[i] ) {
- if( itemdb->names->put(itemdb->names,DB->str2key(itemdb_array[i]->name),DB->ptr2data(itemdb_array[i]),&prev) ) {
+ for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i ) {
+ if( itemdb->array[i] ) {
+ if( itemdb->names->put(itemdb->names,DB->str2key(itemdb->array[i]->name),DB->ptr2data(itemdb->array[i]),&prev) ) {
struct item_data *data = DB->data2ptr(&prev);
- ShowError("itemdb_read: duplicate AegisName '%s' in item ID %d and %d\n",itemdb_array[i]->name,itemdb_array[i]->nameid,data->nameid);
+ ShowError("itemdb_read: duplicate AegisName '%s' in item ID %d and %d\n",itemdb->array[i]->name,itemdb->array[i]->nameid,data->nameid);
}
}
}
- itemdb_read_combos();
+ itemdb->read_combos();
itemdb->read_groups();
itemdb->read_chains();
itemdb->read_packages();
- sv->readdb(iMap->db_path, "item_avail.txt", ',', 2, 2, -1, &itemdb_read_itemavail);
- sv->readdb(iMap->db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, &itemdb_read_itemtrade);
- sv->readdb(iMap->db_path, "item_delay.txt", ',', 2, 2, -1, &itemdb_read_itemdelay);
- sv->readdb(iMap->db_path, "item_stack.txt", ',', 3, 3, -1, &itemdb_read_stack);
- sv->readdb(iMap->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore);
- sv->readdb(iMap->db_path, "item_nouse.txt", ',', 3, 3, -1, &itemdb_read_nouse);
+ sv->readdb(iMap->db_path, "item_avail.txt", ',', 2, 2, -1, itemdb->read_itemavail);
+ sv->readdb(iMap->db_path, DBPATH"item_trade.txt", ',', 3, 3, -1, itemdb->read_itemtrade);
+ sv->readdb(iMap->db_path, "item_delay.txt", ',', 2, 2, -1, itemdb->read_itemdelay);
+ sv->readdb(iMap->db_path, "item_stack.txt", ',', 3, 3, -1, itemdb->read_stack);
+ sv->readdb(iMap->db_path, DBPATH"item_buyingstore.txt", ',', 1, 1, -1, itemdb->read_buyingstore);
+ sv->readdb(iMap->db_path, "item_nouse.txt", ',', 3, 3, -1, itemdb->read_nouse);
- itemdb_uid_load();
+ itemdb->uid_load();
}
/*==========================================
@@ -1961,7 +1956,7 @@ static void itemdb_read(void) {
*------------------------------------------*/
/// Destroys the item_data.
-static void destroy_item_data(struct item_data* self, int free_self)
+void destroy_item_data(struct item_data* self, int free_self)
{
if( self == NULL )
return;
@@ -1995,12 +1990,12 @@ static void destroy_item_data(struct item_data* self, int free_self)
/**
* @see DBApply
*/
-static int itemdb_final_sub(DBKey key, DBData *data, va_list ap)
+int itemdb_final_sub(DBKey key, DBData *data, va_list ap)
{
struct item_data *id = DB->data2ptr(data);
- if( id != &dummy_item )
- destroy_item_data(id, 1);
+ if( id != &itemdb->dummy )
+ itemdb->destroy_item_data(id, 1);
return 0;
}
@@ -2012,9 +2007,9 @@ void itemdb_reload(void) {
int i,d,k;
// clear the previous itemdb data
- for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i )
- if( itemdb_array[i] )
- destroy_item_data(itemdb_array[i], 1);
+ for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i )
+ if( itemdb->array[i] )
+ itemdb->destroy_item_data(itemdb->array[i], 1);
for( i = 0; i < itemdb->group_count; i++ ) {
if( itemdb->groups[i].nameid )
@@ -2054,14 +2049,14 @@ void itemdb_reload(void) {
itemdb->packages = NULL;
itemdb->package_count = 0;
- itemdb_other->clear(itemdb_other, itemdb_final_sub);
+ itemdb->other->clear(itemdb->other, itemdb->final_sub);
- memset(itemdb_array, 0, sizeof(itemdb_array));
+ memset(itemdb->array, 0, sizeof(itemdb->array));
db_clear(itemdb->names);
// read new data
- itemdb_read();
+ itemdb->read();
//Epoque's awesome @reloaditemdb fix - thanks! [Ind]
//- Fixes the need of a @reloadmobdb after a @reloaditemdb to re-link monster drop data
@@ -2069,12 +2064,12 @@ void itemdb_reload(void) {
struct mob_db *entry;
if( !((i < 1324 || i > 1363) && (i < 1938 || i > 1946)) )
continue;
- entry = mob_db(i);
+ entry = mob->db(i);
for(d = 0; d < MAX_MOB_DROP; d++) {
struct item_data *id;
if( !entry->dropitem[d].nameid )
continue;
- id = itemdb_search(entry->dropitem[d].nameid);
+ id = itemdb->search(entry->dropitem[d].nameid);
for (k = 0; k < MAX_SEARCH; k++) {
if (id->mob[k].chance <= entry->dropitem[d].p)
@@ -2132,9 +2127,9 @@ void itemdb_force_name_constants(void) {
void do_final_itemdb(void) {
int i;
- for( i = 0; i < ARRAYLENGTH(itemdb_array); ++i )
- if( itemdb_array[i] )
- destroy_item_data(itemdb_array[i], 1);
+ for( i = 0; i < ARRAYLENGTH(itemdb->array); ++i )
+ if( itemdb->array[i] )
+ itemdb->destroy_item_data(itemdb->array[i], 1);
for( i = 0; i < itemdb->group_count; i++ ) {
if( itemdb->groups[i].nameid )
@@ -2165,26 +2160,25 @@ void do_final_itemdb(void) {
if( itemdb->packages )
aFree(itemdb->packages);
- itemdb_other->destroy(itemdb_other, itemdb_final_sub);
- destroy_item_data(&dummy_item, 0);
+ itemdb->other->destroy(itemdb->other, itemdb->final_sub);
+ itemdb->destroy_item_data(&itemdb->dummy, 0);
db_destroy(itemdb->names);
}
void do_init_itemdb(void) {
- memset(itemdb_array, 0, sizeof(itemdb_array));
- itemdb_other = idb_alloc(DB_OPT_BASE);
+ memset(itemdb->array, 0, sizeof(itemdb->array));
+ itemdb->other = idb_alloc(DB_OPT_BASE);
itemdb->names = strdb_alloc(DB_OPT_BASE,ITEM_NAME_LENGTH);
- create_dummy_data(); //Dummy data item.
- itemdb_read();
+ itemdb->create_dummy_data(); //Dummy data item.
+ itemdb->read();
clif->cashshop_load();
}
-/* incomplete */
void itemdb_defaults(void) {
itemdb = &itemdb_s;
itemdb->init = do_init_itemdb;
itemdb->final = do_final_itemdb;
- itemdb->reload = itemdb_reload;//incomplete
+ itemdb->reload = itemdb_reload;
itemdb->name_constants = itemdb_name_constants;
itemdb->force_name_constants = itemdb_force_name_constants;
/* */
@@ -2199,6 +2193,10 @@ void itemdb_defaults(void) {
/* */
itemdb->names = NULL;
/* */
+ /* itemdb->array is cleared on itemdb->init() */
+ itemdb->other = NULL;
+ memset(&itemdb->dummy, 0, sizeof(struct item_data));
+ /* */
itemdb->read_groups = itemdb_read_groups;
itemdb->read_chains = itemdb_read_chains;
itemdb->read_packages = itemdb_read_packages;
@@ -2212,9 +2210,49 @@ void itemdb_defaults(void) {
itemdb->load = itemdb_load;
itemdb->search = itemdb_search;
itemdb->parse_dbrow = itemdb_parse_dbrow;
- itemdb->exists = itemdb_exists;//incomplete
+ itemdb->exists = itemdb_exists;
itemdb->in_group = itemdb_in_group;
itemdb->group_item = itemdb_searchrandomid;
itemdb->chain_item = itemdb_chain_item;
itemdb->package_item = itemdb_package_item;
+ itemdb->searchname_sub = itemdb_searchname_sub;
+ itemdb->searchname_array_sub = itemdb_searchname_array_sub;
+ itemdb->searchrandomid = itemdb_searchrandomid;
+ itemdb->typename = itemdb_typename;
+ itemdb->jobid2mapid = itemdb_jobid2mapid;
+ itemdb->create_dummy_data = create_dummy_data;
+ itemdb->create_item_data = create_item_data;
+ itemdb->isequip = itemdb_isequip;
+ itemdb->isequip2 = itemdb_isequip2;
+ itemdb->isstackable = itemdb_isstackable;
+ itemdb->isstackable2 = itemdb_isstackable2;
+ itemdb->isdropable_sub = itemdb_isdropable_sub;
+ itemdb->cantrade_sub = itemdb_cantrade_sub;
+ itemdb->canpartnertrade_sub = itemdb_canpartnertrade_sub;
+ itemdb->cansell_sub = itemdb_cansell_sub;
+ itemdb->cancartstore_sub = itemdb_cancartstore_sub;
+ itemdb->canstore_sub = itemdb_canstore_sub;
+ itemdb->canguildstore_sub = itemdb_canguildstore_sub;
+ itemdb->canmail_sub = itemdb_canmail_sub;
+ itemdb->canauction_sub = itemdb_canauction_sub;
+ itemdb->isrestricted = itemdb_isrestricted;
+ itemdb->isidentified = itemdb_isidentified;
+ itemdb->isidentified2 = itemdb_isidentified2;
+ itemdb->read_itemavail = itemdb_read_itemavail;
+ itemdb->read_itemtrade = itemdb_read_itemtrade;
+ itemdb->read_itemdelay = itemdb_read_itemdelay;
+ itemdb->read_stack = itemdb_read_stack;
+ itemdb->read_buyingstore = itemdb_read_buyingstore;
+ itemdb->read_nouse = itemdb_read_nouse;
+ itemdb->combo_split_atoi = itemdb_combo_split_atoi;
+ itemdb->read_combos = itemdb_read_combos;
+ itemdb->gendercheck = itemdb_gendercheck;
+ itemdb->re_split_atoi = itemdb_re_split_atoi;
+ itemdb->readdb = itemdb_readdb;
+ itemdb->read_sqldb = itemdb_read_sqldb;
+ itemdb->unique_id = itemdb_unique_id;
+ itemdb->uid_load = itemdb_uid_load;
+ itemdb->read = itemdb_read;
+ itemdb->destroy_item_data = destroy_item_data;
+ itemdb->final_sub = itemdb_final_sub;
}
diff --git a/src/map/itemdb.h b/src/map/itemdb.h
index 126ba6334..fe67ebbef 100644
--- a/src/map/itemdb.h
+++ b/src/map/itemdb.h
@@ -240,41 +240,21 @@ struct item_package {
#define itemdb_iscashfood(id) ( (id) >= 12202 && (id) <= 12207 )
#define itemdb_is_GNbomb(n) (n >= 13260 && n <= 13267)
#define itemdb_is_GNthrowable(n) (n >= 13268 && n <= 13290)
-const char* itemdb_typename(int type);
#define itemdb_value_buy(n) itemdb->search(n)->value_buy
#define itemdb_value_sell(n) itemdb->search(n)->value_sell
#define itemdb_canrefine(n) (!itemdb->search(n)->flag.no_refine)
//Item trade restrictions [Skotlex]
-int itemdb_isdropable_sub(struct item_data *, int, int);
-int itemdb_cantrade_sub(struct item_data*, int, int);
-int itemdb_canpartnertrade_sub(struct item_data*, int, int);
-int itemdb_cansell_sub(struct item_data*,int, int);
-int itemdb_cancartstore_sub(struct item_data*, int, int);
-int itemdb_canstore_sub(struct item_data*, int, int);
-int itemdb_canguildstore_sub(struct item_data*, int, int);
-int itemdb_canmail_sub(struct item_data*, int, int);
-int itemdb_canauction_sub(struct item_data*, int, int);
-int itemdb_isrestricted(struct item* item, int gmlv, int gmlv2, int (*func)(struct item_data*, int, int));
-#define itemdb_isdropable(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_isdropable_sub)
-#define itemdb_cantrade(item, gmlv, gmlv2) itemdb_isrestricted(item, gmlv, gmlv2, itemdb_cantrade_sub)
-#define itemdb_canpartnertrade(item, gmlv, gmlv2) itemdb_isrestricted(item, gmlv, gmlv2, itemdb_canpartnertrade_sub)
-#define itemdb_cansell(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_cansell_sub)
-#define itemdb_cancartstore(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_cancartstore_sub)
-#define itemdb_canstore(item, gmlv) itemdb_isrestricted(item, gmlv, 0, itemdb_canstore_sub)
-#define itemdb_canguildstore(item, gmlv) itemdb_isrestricted(item , gmlv, 0, itemdb_canguildstore_sub)
-#define itemdb_canmail(item, gmlv) itemdb_isrestricted(item , gmlv, 0, itemdb_canmail_sub)
-#define itemdb_canauction(item, gmlv) itemdb_isrestricted(item , gmlv, 0, itemdb_canauction_sub)
+#define itemdb_isdropable(item, gmlv) itemdb->isrestricted(item, gmlv, 0, itemdb->isdropable_sub)
+#define itemdb_cantrade(item, gmlv, gmlv2) itemdb->isrestricted(item, gmlv, gmlv2, itemdb->cantrade_sub)
+#define itemdb_canpartnertrade(item, gmlv, gmlv2) itemdb->isrestricted(item, gmlv, gmlv2, itemdb->canpartnertrade_sub)
+#define itemdb_cansell(item, gmlv) itemdb->isrestricted(item, gmlv, 0, itemdb->cansell_sub)
+#define itemdb_cancartstore(item, gmlv) itemdb->isrestricted(item, gmlv, 0, itemdb->cancartstore_sub)
+#define itemdb_canstore(item, gmlv) itemdb->isrestricted(item, gmlv, 0, itemdb->canstore_sub)
+#define itemdb_canguildstore(item, gmlv) itemdb->isrestricted(item , gmlv, 0, itemdb->canguildstore_sub)
+#define itemdb_canmail(item, gmlv) itemdb->isrestricted(item , gmlv, 0, itemdb->canmail_sub)
+#define itemdb_canauction(item, gmlv) itemdb->isrestricted(item , gmlv, 0, itemdb->canauction_sub)
-int itemdb_isequip(int);
-int itemdb_isequip2(struct item_data *);
-int itemdb_isidentified(int);
-int itemdb_isidentified2(struct item_data *data);
-int itemdb_isstackable(int);
-int itemdb_isstackable2(struct item_data *);
-uint64 itemdb_unique_id(int8 flag, int64 value); // Unique Item ID
-
-/* incomplete */
struct itemdb_interface {
void (*init) (void);
void (*final) (void);
@@ -294,6 +274,10 @@ struct itemdb_interface {
/* */
DBMap *names;
/* */
+ struct item_data *array[MAX_ITEMDB];
+ DBMap *other;// int nameid -> struct item_data*
+ struct item_data dummy; //This is the default dummy item used for non-existant items. [Skotlex]
+ /* */
void (*read_groups) (void);
void (*read_chains) (void);
void (*read_packages) (void);
@@ -312,6 +296,46 @@ struct itemdb_interface {
int (*group_item) (struct item_group *group);
int (*chain_item) (unsigned short chain_id, int *rate);
void (*package_item) (struct map_session_data *sd, struct item_package *package);
+ int (*searchname_sub) (DBKey key, DBData *data, va_list ap);
+ int (*searchname_array_sub) (DBKey key, DBData data, va_list ap);
+ int (*searchrandomid) (struct item_group *group);
+ const char* (*typename) (int type);
+ void (*jobid2mapid) (unsigned int *bclass, unsigned int jobmask);
+ void (*create_dummy_data) (void);
+ struct item_data* (*create_item_data) (int nameid);
+ int (*isequip) (int nameid);
+ int (*isequip2) (struct item_data *data);
+ int (*isstackable) (int nameid);
+ int (*isstackable2) (struct item_data *data);
+ int (*isdropable_sub) (struct item_data *item, int gmlv, int unused);
+ int (*cantrade_sub) (struct item_data *item, int gmlv, int gmlv2);
+ int (*canpartnertrade_sub) (struct item_data *item, int gmlv, int gmlv2);
+ int (*cansell_sub) (struct item_data *item, int gmlv, int unused);
+ int (*cancartstore_sub) (struct item_data *item, int gmlv, int unused);
+ int (*canstore_sub) (struct item_data *item, int gmlv, int unused);
+ int (*canguildstore_sub) (struct item_data *item, int gmlv, int unused);
+ int (*canmail_sub) (struct item_data *item, int gmlv, int unused);
+ int (*canauction_sub) (struct item_data *item, int gmlv, int unused);
+ int (*isrestricted) (struct item *item, int gmlv, int gmlv2, int(*func)(struct item_data *, int, int));
+ int (*isidentified) (int nameid);
+ int (*isidentified2) (struct item_data *data);
+ bool (*read_itemavail) (char *str[], int columns, int current);
+ bool (*read_itemtrade) (char *str[], int columns, int current);
+ bool (*read_itemdelay) (char *str[], int columns, int current);
+ bool (*read_stack) (char *fields[], int columns, int current);
+ bool (*read_buyingstore) (char *fields[], int columns, int current);
+ bool (*read_nouse) (char *fields[], int columns, int current);
+ int (*combo_split_atoi) (char *str, int *val);
+ void (*read_combos) ();
+ int (*gendercheck) (struct item_data *id);
+ void (*re_split_atoi) (char *str, int *atk, int *matk);
+ int (*readdb) (void);
+ int (*read_sqldb) (void);
+ uint64 (*unique_id) (int8 flag, int64 value);
+ int (*uid_load) ();
+ void (*read) (void);
+ void (*destroy_item_data) (struct item_data *self, int free_self);
+ int (*final_sub) (DBKey key, DBData *data, va_list ap);
};
struct itemdb_interface *itemdb;
diff --git a/src/map/map.c b/src/map/map.c
index cbef8ca95..d4568766a 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -372,7 +372,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
sc->data[SC_PROPERTYWALK]->val3 >= skill->get_maxcount(sc->data[SC_PROPERTYWALK]->val1,sc->data[SC_PROPERTYWALK]->val2) )
status_change_end(bl,SC_PROPERTYWALK,INVALID_TIMER);
} else if (bl->type == BL_NPC)
- npc_unsetcells((TBL_NPC*)bl);
+ npc->unsetcells((TBL_NPC*)bl);
if (moveblock) iMap->delblock(bl);
#ifdef CELL_NOSTACK
@@ -443,7 +443,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, unsigned int tick)
}
}
} else if (bl->type == BL_NPC)
- npc_setcells((TBL_NPC*)bl);
+ npc->setcells((TBL_NPC*)bl);
return 0;
}
@@ -810,7 +810,7 @@ static int bl_vgetall_inshootrange(struct block_list *bl, va_list args)
if (!check_distance_bl(center, bl, range))
return 0;
#endif
- if (!path_search_long(NULL, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL))
+ if (!path->search_long(NULL, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL))
return 0;
return 1;
}
@@ -1039,7 +1039,7 @@ static int bl_vgetall_inpath(struct block_list *bl, va_list args)
if ( k < 0 || k > len_limit ) //Since more skills use this, check for ending point as well.
return 0;
- if ( k > magnitude2 && !path_search_long(NULL, m, x0, y0, xi, yi, CELL_CHKWALL) )
+ if ( k > magnitude2 && !path->search_long(NULL, m, x0, y0, xi, yi, CELL_CHKWALL) )
return 0; //Targets beyond the initial ending point need the wall check.
//All these shifts are to increase the precision of the intersection point and distance considering how it's
@@ -1187,7 +1187,7 @@ int map_clearflooritem_timer(int tid, unsigned int tick, int id, intptr_t data)
}
- if (search_petDB_index(fitem->item_data.nameid, PET_EGG) >= 0)
+ if (pet->search_petDB_index(fitem->item_data.nameid, PET_EGG) >= 0)
intif->delete_petdata(MakeDWord(fitem->item_data.card[1], fitem->item_data.card[2]));
clif->clearflooritem(fitem, 0);
@@ -1307,7 +1307,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1
if (iMap->getcell(m,*x,*y,CELL_CHKREACH))
{
- if(flag&2 && !unit_can_reach_pos(src, *x, *y, 1))
+ if(flag&2 && !unit->can_reach_pos(src, *x, *y, 1))
continue;
if(flag&4) {
if (spawn >= 100) return 0; //Limit of retries reached.
@@ -1534,13 +1534,13 @@ int map_quit(struct map_session_data *sd) {
}
if (sd->npc_timer_id != INVALID_TIMER) //Cancel the event timer.
- npc_timerevent_quit(sd);
+ npc->timerevent_quit(sd);
if (sd->npc_id)
- npc_event_dequeue(sd);
+ npc->event_dequeue(sd);
if( sd->bg_id && !sd->bg_queue.arena ) /* TODO: dump this chunk after bg_queue is fully enabled */
- bg_team_leave(sd,1);
+ bg->team_leave(sd,1);
skill->cooldown_save(sd);
pc->itemcd_do(sd,false);
@@ -1548,7 +1548,7 @@ int map_quit(struct map_session_data *sd) {
for( i = 0; i < sd->queues_count; i++ ) {
struct hQueue *queue;
if( (queue = script->queue(sd->queues[i])) && queue->onLogOut[0] != '\0' ) {
- npc_event(sd, queue->onLogOut, 0);
+ npc->event(sd, queue->onLogOut, 0);
}
}
/* two times, the npc event above may assign a new one or delete others */
@@ -1557,7 +1557,7 @@ int map_quit(struct map_session_data *sd) {
script->queue_remove(sd->queues[i],sd->status.account_id);
}
- npc_script_event(sd, NPCE_LOGOUT);
+ npc->script_event(sd, NPCE_LOGOUT);
//Unit_free handles clearing the player related data,
//iMap->quit handles extra specific data which is related to quitting normally
@@ -1587,7 +1587,7 @@ int map_quit(struct map_session_data *sd) {
}
// Return loot to owner
- if( sd->pd ) pet_lootitem_drop(sd->pd, sd);
+ if( sd->pd ) pet->lootitem_drop(sd->pd, sd);
if( sd->state.storage_flag == 1 ) sd->state.storage_flag = 0; // No need to Double Save Storage on Quit.
@@ -1595,7 +1595,7 @@ int map_quit(struct map_session_data *sd) {
if( sd->ed ) {
elemental->clean_effect(sd->ed);
- unit_remove_map(&sd->ed->bl,CLR_TELEPORT);
+ unit->remove_map(&sd->ed->bl,CLR_TELEPORT,ALC_MARK);
}
if( hChSys.local && map[sd->bl.m].channel && idb_exists(map[sd->bl.m].channel->users, sd->status.char_id) ) {
@@ -1604,7 +1604,7 @@ int map_quit(struct map_session_data *sd) {
clif->chsys_quit(sd);
- unit_remove_map_pc(sd,CLR_TELEPORT);
+ unit->remove_map_pc(sd,CLR_TELEPORT);
if( map[sd->bl.m].instance_id >= 0 ) { // Avoid map conflicts and warnings on next login
int16 m;
@@ -1630,7 +1630,7 @@ int map_quit(struct map_session_data *sd) {
pc->makesavestatus(sd);
pc->clean_skilltree(sd);
chrif->save(sd,1);
- unit_free_pc(sd);
+ unit->free_pc(sd);
return 0;
}
@@ -2104,7 +2104,7 @@ void map_spawnmobs(int16 m)
if(map[m].moblist[i]!=NULL)
{
k+=map[m].moblist[i]->num;
- npc_parse_mob2(map[m].moblist[i]);
+ npc->parse_mob2(map[m].moblist[i]);
}
if (battle_config.etc_log && k > 0)
@@ -2135,7 +2135,7 @@ int map_removemobs_sub(struct block_list *bl, va_list ap)
if( md->db->mexp > 0 )
return 0;
- unit_free(&md->bl,CLR_OUTSIGHT);
+ unit->free(&md->bl,CLR_OUTSIGHT);
return 1;
}
@@ -2244,7 +2244,7 @@ uint8 map_calc_dir(struct block_list* src, int16 x, int16 y)
if( dx == 0 && dy == 0 )
{ // both are standing on the same spot
//dir = 6; // aegis-style, makes knockback default to the left
- dir = unit_getdir(src); // athena-style, makes knockback default to behind 'src'
+ dir = unit->getdir(src); // athena-style, makes knockback default to behind 'src'
}
else if( dx >= 0 && dy >=0 )
{ // upper-right
@@ -2296,7 +2296,7 @@ int map_random_dir(struct block_list *bl, int16 *x, int16 *y)
segment = (short)sqrt((float)(dist2 - segment*segment)); //The complement of the previously picked segment
yi = bl->y + segment*diry[j];
} while (
- (iMap->getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH))
+ (iMap->getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH))
&& (++i)<100 );
if (i < 100) {
@@ -2361,7 +2361,7 @@ void map_cellfromcache(struct map_data *m) {
m->setcell = map_setcell;
for(i = 0; i < m->npc_num; i++) {
- npc_setcells(m->npc[i]);
+ npc->setcells(m->npc[i]);
}
}
}
@@ -3274,9 +3274,9 @@ int map_config_read(char *cfgName) {
else if (strcmpi(w1, "delmap") == 0)
iMap->map_num--;
else if (strcmpi(w1, "npc") == 0)
- npc_addsrcfile(w2);
+ npc->addsrcfile(w2);
else if (strcmpi(w1, "delnpc") == 0)
- npc_delsrcfile(w2);
+ npc->delsrcfile(w2);
else if (strcmpi(w1, "autosave_time") == 0) {
iMap->autosave_interval = atoi(w2);
if (iMap->autosave_interval < 1) //Revert to default saving.
@@ -3379,7 +3379,7 @@ void map_reloadnpc_sub(char *cfgName)
*ptr = '\0';
if (strcmpi(w1, "npc") == 0)
- npc_addsrcfile(w2);
+ npc->addsrcfile(w2);
else if (strcmpi(w1, "import") == 0)
map_reloadnpc_sub(w2);
else
@@ -3392,7 +3392,7 @@ void map_reloadnpc_sub(char *cfgName)
void map_reloadnpc(bool clear)
{
if (clear)
- npc_addsrcfile("clear"); // this will clear the current script list
+ npc->addsrcfile("clear"); // this will clear the current script list
#ifdef RENEWAL
map_reloadnpc_sub("npc/re/scripts_main.conf");
@@ -3469,7 +3469,7 @@ int inter_config_read(char *cfgName) {
else if(strcmpi(w1,"log_db_db")==0)
strcpy(log_db_db, w2);
/* mapreg */
- else if( mapreg_config_read(w1,w2) )
+ else if( mapreg->config_read(w1,w2) )
continue;
/* import */
else if(strcmpi(w1,"import")==0)
@@ -3563,7 +3563,7 @@ void map_zone_remove(int m) {
}
}
- npc_parse_mapflag(map[m].name,empty,flag,params,empty,empty,empty);
+ npc->parse_mapflag(map[m].name,empty,flag,params,empty,empty,empty);
aFree(map[m].zone_mf[k]);
map[m].zone_mf[k] = NULL;
}
@@ -4287,7 +4287,7 @@ void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const
if( map_zone_mf_cache(m,flag,params) )
continue;
- npc_parse_mapflag(map[m].name,empty,flag,params,start,buffer,filepath);
+ npc->parse_mapflag(map[m].name,empty,flag,params,start,buffer,filepath);
}
}
/* used on npc load and reload to apply all "Normal" and "PK Mode" zones */
@@ -4315,7 +4315,7 @@ void map_zone_init(void) {
if( map[j].zone == zone ) {
if( map_zone_mf_cache(j,flag,params) )
break;
- npc_parse_mapflag(map[j].name,empty,flag,params,empty,empty,empty);
+ npc->parse_mapflag(map[j].name,empty,flag,params,empty,empty,empty);
}
}
}
@@ -4337,7 +4337,7 @@ void map_zone_init(void) {
if( map[j].zone == zone ) {
if( map_zone_mf_cache(j,flag,params) )
break;
- npc_parse_mapflag(map[j].name,empty,flag,params,empty,empty,empty);
+ npc->parse_mapflag(map[j].name,empty,flag,params,empty,empty,empty);
}
}
}
@@ -4869,10 +4869,10 @@ int cleanup_sub(struct block_list *bl, va_list ap) {
iMap->quit((struct map_session_data *) bl);
break;
case BL_NPC:
- npc_unload((struct npc_data *)bl,false);
+ npc->unload((struct npc_data *)bl,false);
break;
case BL_MOB:
- unit_free(bl,CLR_OUTSIGHT);
+ unit->free(bl,CLR_OUTSIGHT);
break;
case BL_PET:
//There is no need for this, the pet is removed together with the player. [Skotlex]
@@ -4917,7 +4917,7 @@ void do_final(void)
mapit->free(iter);
/* prepares npcs for a faster shutdown process */
- do_clear_npc();
+ npc->do_clear_npc();
// remove all objects on maps
for (i = 0; i < iMap->map_num; i++) {
@@ -4936,7 +4936,7 @@ void do_final(void)
chrif->do_final_chrif();
ircbot->final();/* before clif. */
clif->final();
- do_final_npc();
+ npc->final();
script->final();
itemdb->final();
instance->final();
@@ -4944,14 +4944,14 @@ void do_final(void)
guild->final();
party->do_final_party();
pc->do_final_pc();
- do_final_pet();
- do_final_mob();
+ pet->final();
+ mob->final();
homun->final();
atcommand->final_msg();
skill->final();
iStatus->do_final_status();
- do_final_unit();
- do_final_battleground();
+ unit->final();
+ bg->final();
iDuel->do_final_duel();
elemental->do_final_elemental();
do_final_maps();
@@ -5168,8 +5168,16 @@ void map_hp_symbols(void) {
HPM->share(elemental,"elemental");
HPM->share(intif,"intif");
HPM->share(mercenary,"mercenary");
-
-
+ HPM->share(mob,"mob");
+ HPM->share(unit,"unit");
+ HPM->share(npc,"npc");
+ HPM->share(mapreg,"mapreg");
+ HPM->share(pet,"pet");
+ HPM->share(path,"path");
+ HPM->share(quest,"quest");
+#ifdef PCRE_SUPPORT
+ HPM->share(npc_chat,"npc_chat");
+#endif
/* partial */
HPM->share(mapit,"mapit");
/* sql link */
@@ -5214,6 +5222,15 @@ void map_load_defaults(void) {
elemental_defaults();
intif_defaults();
mercenary_defaults();
+ mob_defaults();
+ unit_defaults();
+ mapreg_defaults();
+ pet_defaults();
+ path_defaults();
+ quest_defaults();
+#ifdef PCRE_SUPPORT
+ npc_chat_defaults();
+#endif
}
int do_init(int argc, char *argv[])
{
@@ -5402,24 +5419,24 @@ int do_init(int argc, char *argv[])
itemdb->init();
skill->init();
read_map_zone_db();/* read after item and skill initalization */
- do_init_mob();
+ mob->init();
pc->do_init_pc();
iStatus->do_init_status();
party->do_init_party();
guild->init();
storage->init();
- do_init_pet();
+ pet->init();
homun->init();
mercenary->init();
elemental->do_init_elemental();
- do_init_quest();
- do_init_npc();
- do_init_unit();
- do_init_battleground();
+ quest->init();
+ npc->init();
+ unit->init();
+ bg->init();
iDuel->do_init_duel();
vending->init();
- npc_event_do_oninit(); // Init npcs (OnInit)
+ npc->event_do_oninit(); // Init npcs (OnInit)
if (battle_config.pk_mode)
ShowNotice("Server is running on '"CL_WHITE"PK Mode"CL_RESET"'.\n");
diff --git a/src/map/mapreg.h b/src/map/mapreg.h
index e83f9e053..3c1d0ba0e 100644
--- a/src/map/mapreg.h
+++ b/src/map/mapreg.h
@@ -5,6 +5,9 @@
#ifndef _MAPREG_H_
#define _MAPREG_H_
+#include "../common/cbasetypes.h"
+#include "../common/db.h"
+
struct mapreg_save {
int uid;
union {
@@ -14,14 +17,30 @@ struct mapreg_save {
bool save;
};
-void mapreg_reload(void);
-void mapreg_final(void);
-void mapreg_init(void);
-bool mapreg_config_read(const char* w1, const char* w2);
+struct mapreg_interface {
+ DBMap *db; // int var_id -> int value
+ DBMap *str_db; // int var_id -> char* value
+ struct eri *ers; //[Ind/Hercules]
+ char table[32];
+ bool i_dirty;
+ bool str_dirty;
+ /* */
+ void (*init) (void);
+ void (*final) (void);
+ /* */
+ int (*readreg) (int uid);
+ char* (*readregstr) (int uid);
+ bool (*setreg) (int uid, int val);
+ bool (*setregstr) (int uid, const char *str);
+ void (*load) (void);
+ void (*save) (void);
+ int (*save_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ void (*reload) (void);
+ bool (*config_read) (const char *w1, const char *w2);
+};
+
+struct mapreg_interface *mapreg;
-int mapreg_readreg(int uid);
-char* mapreg_readregstr(int uid);
-bool mapreg_setreg(int uid, int val);
-bool mapreg_setregstr(int uid, const char* str);
+void mapreg_defaults(void);
#endif /* _MAPREG_H_ */
diff --git a/src/map/mapreg_sql.c b/src/map/mapreg_sql.c
index 4f9888aba..c0bfeb987 100644
--- a/src/map/mapreg_sql.c
+++ b/src/map/mapreg_sql.c
@@ -16,26 +16,19 @@
#include <stdlib.h>
#include <string.h>
-static DBMap* mapreg_db = NULL; // int var_id -> int value
-static DBMap* mapregstr_db = NULL; // int var_id -> char* value
-static struct eri *mapreg_ers; //[Ind/Hercules]
-
-static char mapreg_table[32] = "mapreg";
-static bool mapreg_i_dirty = false;
-static bool mapreg_str_dirty = false;
+struct mapreg_interface mapreg_s;
#define MAPREG_AUTOSAVE_INTERVAL (300*1000)
-
/// Looks up the value of an integer variable using its uid.
int mapreg_readreg(int uid) {
- struct mapreg_save *m = idb_get(mapreg_db, uid);
+ struct mapreg_save *m = idb_get(mapreg->db, uid);
return m?m->u.i:0;
}
/// Looks up the value of a string variable using its uid.
char* mapreg_readregstr(int uid) {
- struct mapreg_save *m = idb_get(mapregstr_db, uid);
+ struct mapreg_save *m = idb_get(mapreg->str_db, uid);
return m?m->u.str:NULL;
}
@@ -47,14 +40,14 @@ bool mapreg_setreg(int uid, int val) {
const char* name = script->get_str(num);
if( val != 0 ) {
- if( (m = idb_get(mapreg_db,uid)) ) {
+ if( (m = idb_get(mapreg->db,uid)) ) {
m->u.i = val;
if(name[1] != '@') {
m->save = true;
- mapreg_i_dirty = true;
+ mapreg->i_dirty = true;
}
} else {
- m = ers_alloc(mapreg_ers, struct mapreg_save);
+ m = ers_alloc(mapreg->ers, struct mapreg_save);
m->u.i = val;
m->uid = uid;
@@ -63,19 +56,19 @@ bool mapreg_setreg(int uid, int val) {
if(name[1] != '@') {// write new variable to database
char tmp_str[32*2+1];
SQL->EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32));
- if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg_table, tmp_str, i, val) )
+ if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%d')", mapreg->table, tmp_str, i, val) )
Sql_ShowDebug(mmysql_handle);
}
- idb_put(mapreg_db, uid, m);
+ idb_put(mapreg->db, uid, m);
}
} else { // val == 0
- if( (m = idb_get(mapreg_db,uid)) ) {
- ers_free(mapreg_ers, m);
+ if( (m = idb_get(mapreg->db,uid)) ) {
+ ers_free(mapreg->ers, m);
}
- idb_remove(mapreg_db,uid);
+ idb_remove(mapreg->db,uid);
if( name[1] != '@' ) {// Remove from database because it is unused.
- if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) )
+ if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) )
Sql_ShowDebug(mmysql_handle);
}
}
@@ -92,26 +85,26 @@ bool mapreg_setregstr(int uid, const char* str) {
if( str == NULL || *str == 0 ) {
if(name[1] != '@') {
- if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg_table, name, i) )
+ if( SQL_ERROR == SQL->Query(mmysql_handle, "DELETE FROM `%s` WHERE `varname`='%s' AND `index`='%d'", mapreg->table, name, i) )
Sql_ShowDebug(mmysql_handle);
}
- if( (m = idb_get(mapregstr_db,uid)) ) {
+ if( (m = idb_get(mapreg->str_db,uid)) ) {
if( m->u.str != NULL )
aFree(m->u.str);
- ers_free(mapreg_ers, m);
+ ers_free(mapreg->ers, m);
}
- idb_remove(mapregstr_db,uid);
+ idb_remove(mapreg->str_db,uid);
} else {
- if( (m = idb_get(mapregstr_db,uid)) ) {
+ if( (m = idb_get(mapreg->str_db,uid)) ) {
if( m->u.str != NULL )
aFree(m->u.str);
m->u.str = aStrdup(str);
if(name[1] != '@') {
- mapreg_str_dirty = true;
+ mapreg->str_dirty = true;
m->save = true;
}
} else {
- m = ers_alloc(mapreg_ers, struct mapreg_save);
+ m = ers_alloc(mapreg->ers, struct mapreg_save);
m->uid = uid;
m->u.str = aStrdup(str);
@@ -122,10 +115,10 @@ bool mapreg_setregstr(int uid, const char* str) {
char tmp_str2[255*2+1];
SQL->EscapeStringLen(mmysql_handle, tmp_str, name, strnlen(name, 32));
SQL->EscapeStringLen(mmysql_handle, tmp_str2, str, strnlen(str, 255));
- if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg_table, tmp_str, i, tmp_str2) )
+ if( SQL_ERROR == SQL->Query(mmysql_handle, "INSERT INTO `%s`(`varname`,`index`,`value`) VALUES ('%s','%d','%s')", mapreg->table, tmp_str, i, tmp_str2) )
Sql_ShowDebug(mmysql_handle);
}
- idb_put(mapregstr_db, uid, m);
+ idb_put(mapreg->str_db, uid, m);
}
}
@@ -133,7 +126,7 @@ bool mapreg_setregstr(int uid, const char* str) {
}
/// Loads permanent variables from database
-static void script_load_mapreg(void) {
+void script_load_mapreg(void) {
/*
0 1 2
+-------------------------+
@@ -146,7 +139,7 @@ static void script_load_mapreg(void) {
char value[255+1];
uint32 length;
- if ( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `varname`, `index`, `value` FROM `%s`", mapreg_table)
+ if ( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `varname`, `index`, `value` FROM `%s`", mapreg->table)
|| SQL_ERROR == SQL->StmtExecute(stmt)
) {
SqlStmt_ShowDebug(stmt);
@@ -164,59 +157,59 @@ static void script_load_mapreg(void) {
int i = index;
if( varname[length-1] == '$' ) {
- if( idb_exists(mapregstr_db, (i<<24)|s) ) {
+ if( idb_exists(mapreg->str_db, (i<<24)|s) ) {
ShowWarning("load_mapreg: duplicate! '%s' => '%s' skipping...\n",varname,value);
continue;
}
} else {
- if( idb_exists(mapreg_db, (i<<24)|s) ) {
+ if( idb_exists(mapreg->db, (i<<24)|s) ) {
ShowWarning("load_mapreg: duplicate! '%s' => '%s' skipping...\n",varname,value);
continue;
}
}
- m = ers_alloc(mapreg_ers, struct mapreg_save);
+ m = ers_alloc(mapreg->ers, struct mapreg_save);
m->uid = (i<<24)|s;
m->save = false;
if( varname[length-1] == '$' ) {
m->u.str = aStrdup(value);
- idb_put(mapregstr_db, m->uid, m);
+ idb_put(mapreg->str_db, m->uid, m);
} else {
m->u.i = atoi(value);
- idb_put(mapreg_db, m->uid, m);
+ idb_put(mapreg->db, m->uid, m);
}
}
SQL->StmtFree(stmt);
- mapreg_i_dirty = false;
- mapreg_str_dirty = false;
+ mapreg->i_dirty = false;
+ mapreg->str_dirty = false;
}
/// Saves permanent variables to database
-static void script_save_mapreg(void) {
+void script_save_mapreg(void) {
DBIterator* iter;
struct mapreg_save *m = NULL;
- if( mapreg_i_dirty ) {
- iter = db_iterator(mapreg_db);
+ if( mapreg->i_dirty ) {
+ iter = db_iterator(mapreg->db);
for( m = dbi_first(iter); dbi_exists(iter); m = dbi_next(iter) ) {
if( m->save ) {
int num = (m->uid & 0x00ffffff);
int i = (m->uid & 0xff000000) >> 24;
const char* name = script->get_str(num);
- if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, m->u.i, name, i) )
+ if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%d' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, m->u.i, name, i) )
Sql_ShowDebug(mmysql_handle);
m->save = false;
}
}
dbi_destroy(iter);
- mapreg_i_dirty = false;
+ mapreg->i_dirty = false;
}
- if( mapreg_str_dirty ) {
- iter = db_iterator(mapregstr_db);
+ if( mapreg->str_dirty ) {
+ iter = db_iterator(mapreg->str_db);
for( m = dbi_first(iter); dbi_exists(iter); m = dbi_next(iter) ) {
if( m->save ) {
int num = (m->uid & 0x00ffffff);
@@ -225,18 +218,18 @@ static void script_save_mapreg(void) {
char tmp_str2[2*255+1];
SQL->EscapeStringLen(mmysql_handle, tmp_str2, m->u.str, safestrnlen(m->u.str, 255));
- if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg_table, tmp_str2, name, i) )
+ if( SQL_ERROR == SQL->Query(mmysql_handle, "UPDATE `%s` SET `value`='%s' WHERE `varname`='%s' AND `index`='%d' LIMIT 1", mapreg->table, tmp_str2, name, i) )
Sql_ShowDebug(mmysql_handle);
m->save = false;
}
}
dbi_destroy(iter);
- mapreg_str_dirty = false;
+ mapreg->str_dirty = false;
}
}
-static int script_autosave_mapreg(int tid, unsigned int tick, int id, intptr_t data) {
- script_save_mapreg();
+int script_autosave_mapreg(int tid, unsigned int tick, int id, intptr_t data) {
+ mapreg->save();
return 0;
}
@@ -245,72 +238,100 @@ void mapreg_reload(void) {
DBIterator* iter;
struct mapreg_save *m = NULL;
- script_save_mapreg();
+ mapreg->save();
- iter = db_iterator(mapreg_db);
+ iter = db_iterator(mapreg->db);
for( m = dbi_first(iter); dbi_exists(iter); m = dbi_next(iter) ) {
- ers_free(mapreg_ers, m);
+ ers_free(mapreg->ers, m);
}
dbi_destroy(iter);
- iter = db_iterator(mapregstr_db);
+ iter = db_iterator(mapreg->str_db);
for( m = dbi_first(iter); dbi_exists(iter); m = dbi_next(iter) ) {
if( m->u.str != NULL ) {
aFree(m->u.str);
}
- ers_free(mapreg_ers, m);
+ ers_free(mapreg->ers, m);
}
dbi_destroy(iter);
- db_clear(mapreg_db);
- db_clear(mapregstr_db);
+ db_clear(mapreg->db);
+ db_clear(mapreg->str_db);
- script_load_mapreg();
+ mapreg->load();
}
void mapreg_final(void) {
DBIterator* iter;
struct mapreg_save *m = NULL;
- script_save_mapreg();
+ mapreg->save();
- iter = db_iterator(mapreg_db);
+ iter = db_iterator(mapreg->db);
for( m = dbi_first(iter); dbi_exists(iter); m = dbi_next(iter) ) {
- ers_free(mapreg_ers, m);
+ ers_free(mapreg->ers, m);
}
dbi_destroy(iter);
- iter = db_iterator(mapregstr_db);
+ iter = db_iterator(mapreg->str_db);
for( m = dbi_first(iter); dbi_exists(iter); m = dbi_next(iter) ) {
if( m->u.str != NULL ) {
aFree(m->u.str);
}
- ers_free(mapreg_ers, m);
+ ers_free(mapreg->ers, m);
}
dbi_destroy(iter);
- db_destroy(mapreg_db);
- db_destroy(mapregstr_db);
+ db_destroy(mapreg->db);
+ db_destroy(mapreg->str_db);
- ers_destroy(mapreg_ers);
+ ers_destroy(mapreg->ers);
}
void mapreg_init(void) {
- mapreg_db = idb_alloc(DB_OPT_BASE);
- mapregstr_db = idb_alloc(DB_OPT_BASE);
- mapreg_ers = ers_new(sizeof(struct mapreg_save), "mapreg_sql.c::mapreg_ers", ERS_OPT_NONE);
+ mapreg->db = idb_alloc(DB_OPT_BASE);
+ mapreg->str_db = idb_alloc(DB_OPT_BASE);
+ mapreg->ers = ers_new(sizeof(struct mapreg_save), "mapreg_sql.c::mapreg_ers", ERS_OPT_NONE);
- script_load_mapreg();
+ mapreg->load();
- iTimer->add_timer_func_list(script_autosave_mapreg, "script_autosave_mapreg");
- iTimer->add_timer_interval(iTimer->gettick() + MAPREG_AUTOSAVE_INTERVAL, script_autosave_mapreg, 0, 0, MAPREG_AUTOSAVE_INTERVAL);
+ iTimer->add_timer_func_list(mapreg->save_timer, "mapreg_script_autosave_mapreg");
+ iTimer->add_timer_interval(iTimer->gettick() + MAPREG_AUTOSAVE_INTERVAL, mapreg->save_timer, 0, 0, MAPREG_AUTOSAVE_INTERVAL);
}
bool mapreg_config_read(const char* w1, const char* w2) {
if(!strcmpi(w1, "mapreg_db"))
- safestrncpy(mapreg_table, w2, sizeof(mapreg_table));
+ safestrncpy(mapreg->table, w2, sizeof(mapreg->table));
else
return false;
return true;
}
+void mapreg_defaults(void) {
+ mapreg = &mapreg_s;
+
+ /* */
+ mapreg->db = NULL;
+ mapreg->str_db = NULL;
+ mapreg->ers = NULL;
+
+ safestrncpy(mapreg->table, "mapreg", sizeof(mapreg->table));
+ mapreg->i_dirty = false;
+ mapreg->str_dirty = false;
+
+ /* */
+ mapreg->init = mapreg_init;
+ mapreg->final = mapreg_final;
+
+ /* */
+ mapreg->readreg = mapreg_readreg;
+ mapreg->readregstr = mapreg_readregstr;
+ mapreg->setreg = mapreg_setreg;
+ mapreg->setregstr = mapreg_setregstr;
+ mapreg->load = script_load_mapreg;
+ mapreg->save = script_save_mapreg;
+ mapreg->save_timer = script_autosave_mapreg;
+ mapreg->reload = mapreg_reload;
+ mapreg->config_read = mapreg_config_read;
+
+}
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index bb30bb0d1..bf802c643 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -247,7 +247,7 @@ int merc_delete(struct mercenary_data *md, int reply)
mercenary->contract_stop(md);
if( !sd )
- return unit_free(&md->bl, CLR_OUTSIGHT);
+ return unit->free(&md->bl, CLR_OUTSIGHT);
if( md->devotion_flag )
{
@@ -262,7 +262,7 @@ int merc_delete(struct mercenary_data *md, int reply)
}
clif->mercenary_message(sd, reply);
- return unit_remove_map(&md->bl, CLR_OUTSIGHT);
+ return unit->remove_map(&md->bl, CLR_OUTSIGHT, ALC_MARK);
}
void merc_contract_stop(struct mercenary_data *md)
@@ -301,7 +301,7 @@ int merc_data_received(struct s_mercenary *merc, bool flag)
{
sd->md = md = (struct mercenary_data*)aCalloc(1,sizeof(struct mercenary_data));
md->bl.type = BL_MER;
- md->bl.id = npc_get_new_npc_id();
+ md->bl.id = npc->get_new_npc_id();
md->devotion_flag = 0;
md->master = sd;
@@ -309,13 +309,13 @@ int merc_data_received(struct s_mercenary *merc, bool flag)
memcpy(&md->mercenary, merc, sizeof(struct s_mercenary));
iStatus->set_viewdata(&md->bl, md->mercenary.class_);
iStatus->change_init(&md->bl);
- unit_dataset(&md->bl);
+ unit->dataset(&md->bl);
md->ud.dir = sd->ud.dir;
md->bl.m = sd->bl.m;
md->bl.x = sd->bl.x;
md->bl.y = sd->bl.y;
- unit_calc_pos(&md->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
+ unit->calc_pos(&md->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
md->bl.x = md->ud.to_x;
md->bl.y = md->ud.to_y;
diff --git a/src/map/mob.c b/src/map/mob.c
index b16c57ef8..146f82239 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -43,6 +43,8 @@
#include <string.h>
#include <math.h>
+struct mob_interface mob_s;
+
#define ACTIVE_AI_RANGE 2 //Distance added on top of 'AREA_SIZE' at which mobs enter active AI mode.
#define IDLE_SKILL_INTERVAL 10 //Active idle skills should be triggered every 1 second (1000/MIN_MOBTHINKTIME)
@@ -54,17 +56,6 @@
#define MOB_MAX_DELAY (24*3600*1000)
#define MAX_MINCHASE 30 //Max minimum chase value to use for mobs.
#define RUDE_ATTACKED_COUNT 2 //After how many rude-attacks should the skill be used?
-#define MAX_MOB_CHAT 250 //Max Skill's messages
-
-//Dynamic mob database, allows saving of memory when there's big gaps in the mob_db [Skotlex]
-struct mob_db *mob_db_data[MAX_MOB_DB+1];
-struct mob_db *mob_dummy = NULL; //Dummy mob to be returned when a non-existant one is requested.
-
-struct mob_db *mob_db(int index) { if (index < 0 || index > MAX_MOB_DB || mob_db_data[index] == NULL) return mob_dummy; return mob_db_data[index]; }
-
-//Dynamic mob chat database
-struct mob_chat *mob_chat_db[MAX_MOB_CHAT+1];
-struct mob_chat *mob_chat(short id) { if(id<=0 || id>MAX_MOB_CHAT || mob_chat_db[id]==NULL) return (struct mob_chat*)NULL; return mob_chat_db[id]; }
//Dynamic item drop ratio database for per-item drop ratio modifiers overriding global drop ratios.
#define MAX_ITEMRATIO_MOBS 10
@@ -82,16 +73,16 @@ static struct {
int class_[350];
} summon[MAX_RANDOMMONSTER];
-//Defines the Manuk/Splendide mob groups for the status reductions [Epoque]
-const int mob_manuk[8] = { 1986, 1987, 1988, 1989, 1990, 1997, 1998, 1999 };
-const int mob_splendide[5] = { 1991, 1992, 1993, 1994, 1995 };
-
-/*==========================================
- * Local prototype declaration (only required thing)
- *------------------------------------------*/
-static int mob_makedummymobdb(int);
-static int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t data);
-int mob_skill_id2skill_idx(int class_,uint16 skill_id);
+struct mob_db *mob_db(int index) {
+ if (index < 0 || index > MAX_MOB_DB || mob->db_data[index] == NULL)
+ return mob->dummy;
+ return mob->db_data[index];
+}
+struct mob_chat *mob_chat(short id) {
+ if(id <= 0 || id > MAX_MOB_CHAT || mob->chat_db[id] == NULL)
+ return NULL;
+ return mob->chat_db[id];
+}
/*==========================================
* Mob is searched with a name.
@@ -99,35 +90,34 @@ int mob_skill_id2skill_idx(int class_,uint16 skill_id);
int mobdb_searchname(const char *str)
{
int i;
- struct mob_db* mob;
+ struct mob_db* monster;
for(i=0;i<=MAX_MOB_DB;i++){
- mob = mob_db(i);
- if(mob == mob_dummy) //Skip dummy mobs.
+ monster = mob->db(i);
+ if(monster == mob->dummy) //Skip dummy mobs.
continue;
- if(strcmpi(mob->name,str)==0 || strcmpi(mob->jname,str)==0 || strcmpi(mob->sprite,str)==0)
+ if(strcmpi(monster->name,str)==0 || strcmpi(monster->jname,str)==0 || strcmpi(monster->sprite,str)==0)
return i;
}
return 0;
}
-static int mobdb_searchname_array_sub(struct mob_db* mob, const char *str, int flag)
-{
- if (mob == mob_dummy)
+int mobdb_searchname_array_sub(struct mob_db* monster, const char *str, int flag) {
+ if (monster == mob->dummy)
return 1;
- if(!mob->base_exp && !mob->job_exp && mob->spawn[0].qty < 1)
+ if(!monster->base_exp && !monster->job_exp && monster->spawn[0].qty < 1)
return 1; // Monsters with no base/job exp and no spawn point are, by this criteria, considered "slave mobs" and excluded from search results
if( !flag ){
- if(stristr(mob->jname,str))
+ if(stristr(monster->jname,str))
return 0;
- if(stristr(mob->name,str))
+ if(stristr(monster->name,str))
return 0;
- return strcmpi(mob->jname,str);
+ return strcmpi(monster->jname,str);
}
- if(strcmp(mob->jname,str) == 0)
+ if(strcmp(monster->jname,str) == 0)
return 0;
- if(strcmp(mob->name,str) == 0)
+ if(strcmp(monster->name,str) == 0)
return 0;
- return strcmp(mob->sprite,str);
+ return strcmp(monster->sprite,str);
}
/*==========================================
@@ -138,11 +128,11 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time)
struct npc_data *nd;
if ( md->tomb_nid )
- mvptomb_destroy(md);
+ mob->mvptomb_destroy(md);
CREATE(nd, struct npc_data, 1);
- nd->bl.id = md->tomb_nid = npc_get_new_npc_id();
+ nd->bl.id = md->tomb_nid = npc->get_new_npc_id();
nd->dir = md->ud.dir;
nd->bl.m = md->bl.m;
@@ -204,14 +194,14 @@ void mvptomb_destroy(struct mob_data *md) {
int mobdb_searchname_array(struct mob_db** data, int size, const char *str, int flag)
{
int count = 0, i;
- struct mob_db* mob;
+ struct mob_db* monster;
for(i=0;i<=MAX_MOB_DB;i++){
- mob = mob_db(i);
- if (mob == mob_dummy || mob_is_clone(i) ) //keep clones out (or you leak player stats)
+ monster = mob->db(i);
+ if (monster == mob->dummy || mob->is_clone(i) ) //keep clones out (or you leak player stats)
continue;
- if (!mobdb_searchname_array_sub(mob, str, flag)) {
+ if (!mob->db_searchname_array_sub(monster, str, flag)) {
if (count < size)
- data[count] = mob;
+ data[count] = monster;
count++;
}
}
@@ -223,9 +213,9 @@ int mobdb_searchname_array(struct mob_db** data, int size, const char *str, int
*------------------------------------------*/
int mobdb_checkid(const int id)
{
- if (mob_db(id) == mob_dummy)
+ if (mob->db(id) == mob->dummy)
return 0;
- if (mob_is_clone(id)) //checkid is used mostly for random ID based code, therefore clone mobs are out of the question.
+ if (mob->is_clone(id)) //checkid is used mostly for random ID based code, therefore clone mobs are out of the question.
return 0;
return id;
}
@@ -235,9 +225,9 @@ int mobdb_checkid(const int id)
*------------------------------------------*/
struct view_data * mob_get_viewdata(int class_)
{
- if (mob_db(class_) == mob_dummy)
+ if (mob->db(class_) == mob->dummy)
return 0;
- return &mob_db(class_)->vd;
+ return &mob->db(class_)->vd;
}
/*==========================================
* Cleans up mob-spawn data to make it "valid"
@@ -246,7 +236,7 @@ int mob_parse_dataset(struct spawn_data *data)
{
size_t len;
- if ((!mobdb_checkid(data->class_) && !mob_is_clone(data->class_)) || !data->num)
+ if ((!mob->db_checkid(data->class_) && !mob->is_clone(data->class_)) || !data->num)
return 0;
if( ( len = strlen(data->eventname) ) > 0 )
@@ -258,9 +248,9 @@ int mob_parse_dataset(struct spawn_data *data)
}
if(strcmp(data->name,"--en--")==0)
- safestrncpy(data->name, mob_db(data->class_)->name, sizeof(data->name));
+ safestrncpy(data->name, mob->db(data->class_)->name, sizeof(data->name));
else if(strcmp(data->name,"--ja--")==0)
- safestrncpy(data->name, mob_db(data->class_)->jname, sizeof(data->name));
+ safestrncpy(data->name, mob->db(data->class_)->jname, sizeof(data->name));
return 1;
}
@@ -269,14 +259,14 @@ int mob_parse_dataset(struct spawn_data *data)
*------------------------------------------*/
struct mob_data* mob_spawn_dataset(struct spawn_data *data) {
struct mob_data *md = (struct mob_data*)aCalloc(1, sizeof(struct mob_data));
- md->bl.id= npc_get_new_npc_id();
+ md->bl.id= npc->get_new_npc_id();
md->bl.type = BL_MOB;
md->bl.m = data->m;
md->bl.x = data->x;
md->bl.y = data->y;
md->class_ = data->class_;
md->state.boss = data->state.boss;
- md->db = mob_db(md->class_);
+ md->db = mob->db(md->class_);
if (data->level > 0 && data->level <= MAX_LEVEL)
md->level = data->level;
memcpy(md->name, data->name, NAME_LENGTH);
@@ -293,7 +283,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data) {
md->skill_idx = -1;
iStatus->set_viewdata(&md->bl, md->class_);
iStatus->change_init(&md->bl);
- unit_dataset(&md->bl);
+ unit->dataset(&md->bl);
iMap->addiddb(&md->bl);
return md;
@@ -314,7 +304,7 @@ struct mob_data* mob_spawn_dataset(struct spawn_data *data) {
*------------------------------------------*/
int mob_get_random_id(int type, int flag, int lv)
{
- struct mob_db *mob;
+ struct mob_db *monster;
int i=0, class_;
if(type < 0 || type >= MAX_RANDOMMONSTER) {
ShowError("mob_get_random_id: Invalid type (%d) of random monster.\n", type);
@@ -325,17 +315,17 @@ int mob_get_random_id(int type, int flag, int lv)
class_ = summon[type].class_[rnd()%summon[type].qty];
else //Dead branch
class_ = rnd() % MAX_MOB_DB;
- mob = mob_db(class_);
- } while ((mob == mob_dummy ||
- mob_is_clone(class_) ||
- (flag&1 && mob->summonper[type] <= rnd() % 1000000) ||
- (flag&2 && lv < mob->lv) ||
- (flag&4 && mob->status.mode&MD_BOSS) ||
- (flag&8 && mob->spawn[0].qty < 1)
+ monster = mob->db(class_);
+ } while ((monster == mob->dummy ||
+ mob->is_clone(class_) ||
+ (flag&1 && monster->summonper[type] <= rnd() % 1000000) ||
+ (flag&2 && lv < monster->lv) ||
+ (flag&4 && monster->status.mode&MD_BOSS) ||
+ (flag&8 && monster->spawn[0].qty < 1)
) && (i++) < MAX_MOB_DB);
if(i >= MAX_MOB_DB) // no suitable monster found, use fallback for given list
- class_ = mob_db_data[0]->summonper[type];
+ class_ = mob->db_data[0]->summonper[type];
return class_;
}
@@ -458,10 +448,10 @@ struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int
data.x = x;
data.y = y;
- if (!mob_parse_dataset(&data))
+ if (!mob->parse_dataset(&data))
return NULL;
- return mob_spawn_dataset(&data);
+ return mob->spawn_dataset(&data);
}
/*==========================================
@@ -479,8 +469,8 @@ int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const
for (count = 0; count < amount; count++)
{
- int c = (class_ >= 0) ? class_ : mob_get_random_id(-class_ - 1, (battle_config.random_monster_checklv) ? 3 : 1, lv);
- md = mob_once_spawn_sub((sd) ? &sd->bl : NULL, m, x, y, mobname, c, event, size, ai);
+ int c = (class_ >= 0) ? class_ : mob->get_random_id(-class_ - 1, (battle_config.random_monster_checklv) ? 3 : 1, lv);
+ md = mob->once_spawn_sub((sd) ? &sd->bl : NULL, m, x, y, mobname, c, event, size, ai);
if (!md)
continue;
@@ -501,11 +491,11 @@ int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const
memcpy(md->guardian_data->guild_name, g->name, NAME_LENGTH);
}
else if (gc->guild_id) //Guild not yet available, retry in 5.
- iTimer->add_timer(iTimer->gettick()+5000,mob_spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id);
+ iTimer->add_timer(iTimer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id);
}
} // end addition [Valaris]
- mob_spawn(md);
+ mob->spawn(md);
if (class_ < 0 && battle_config.dead_branch_active)
//Behold Aegis's masterful decisions yet again...
@@ -565,7 +555,7 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0
lx = x;
ly = y;
- id = mob_once_spawn(sd, m, x, y, mobname, class_, 1, event, size, ai);
+ id = mob->once_spawn(sd, m, x, y, mobname, class_, 1, event, size, ai);
}
return id; // id of last spawned mob
@@ -573,7 +563,7 @@ int mob_once_spawn_area(struct map_session_data* sd, int16 m, int16 x0, int16 y0
/*==========================================
* Set a Guardian's guild data [Skotlex]
*------------------------------------------*/
-static int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t data)
+int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t data)
{ //Needed because the guild_data may not be available at guardian spawn time.
struct block_list* bl = iMap->id2bl(id);
struct mob_data* md;
@@ -607,7 +597,7 @@ static int mob_spawn_guardian_sub(int tid, unsigned int tick, int id, intptr_t d
} else {
if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS && md->guardian_data->castle->guardian[md->guardian_data->number].visible)
guild->castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number,0);
- unit_free(&md->bl,CLR_OUTSIGHT); //Remove guardian.
+ unit->free(&md->bl,CLR_OUTSIGHT); //Remove guardian.
}
return 0;
}
@@ -643,7 +633,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam
data.m = m;
data.num = 1;
if(class_<=0) {
- class_ = mob_get_random_id(-class_-1, 1, 99);
+ class_ = mob->get_random_id(-class_-1, 1, 99);
if (!class_) return 0;
}
@@ -668,7 +658,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam
data.y = y;
safestrncpy(data.name, mobname, sizeof(data.name));
safestrncpy(data.eventname, event, sizeof(data.eventname));
- if (!mob_parse_dataset(&data))
+ if (!mob->parse_dataset(&data))
return 0;
gc=guild->mapname2gc(map[m].name);
@@ -693,7 +683,7 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam
}
}
- md = mob_spawn_dataset(&data);
+ md = mob->spawn_dataset(&data);
md->guardian_data = (struct guardian_data*)aCalloc(1, sizeof(struct guardian_data));
md->guardian_data->number = guardian;
md->guardian_data->guild_id = gc->guild_id;
@@ -719,8 +709,8 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam
memcpy (md->guardian_data->guild_name, g->name, NAME_LENGTH);
md->guardian_data->guardup_lv = guild->checkskill(g,GD_GUARDUP);
} else if (md->guardian_data->guild_id)
- iTimer->add_timer(iTimer->gettick()+5000,mob_spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id);
- mob_spawn(md);
+ iTimer->add_timer(iTimer->gettick()+5000,mob->spawn_guardian_sub,md->bl.id,md->guardian_data->guild_id);
+ mob->spawn(md);
return md->bl.id;
}
@@ -745,7 +735,7 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int
data.num = 1;
if( class_ <= 0 )
{
- class_ = mob_get_random_id(-class_-1,1,99);
+ class_ = mob->get_random_id(-class_-1,1,99);
if( !class_ ) return 0;
}
@@ -760,11 +750,11 @@ int mob_spawn_bg(const char* mapname, short x, short y, const char* mobname, int
data.y = y;
safestrncpy(data.name, mobname, sizeof(data.name));
safestrncpy(data.eventname, event, sizeof(data.eventname));
- if( !mob_parse_dataset(&data) )
+ if( !mob->parse_dataset(&data) )
return 0;
- md = mob_spawn_dataset(&data);
- mob_spawn(md);
+ md = mob->spawn_dataset(&data);
+ mob->spawn(md);
md->bg_id = bg_id; // BG Team ID
return md->bl.id;
@@ -793,7 +783,7 @@ int mob_can_reach(struct mob_data *md,struct block_list *bl,int range, int state
easy = 1;
break;
}
- return unit_can_reach_bl(&md->bl, bl, range, easy, NULL, NULL);
+ return unit->can_reach_bl(&md->bl, bl, range, easy, NULL, NULL);
}
/*==========================================
@@ -816,7 +806,7 @@ int mob_linksearch(struct block_list *bl,va_list ap)
&& !md->target_id)
{
md->last_linktime = tick;
- if( mob_can_reach(md,target,md->db->range2, MSS_FOLLOW) ){ // Reachability judging
+ if( mob->can_reach(md,target,md->db->range2, MSS_FOLLOW) ){ // Reachability judging
md->target_id = target->id;
md->min_chase=md->db->range3;
return 1;
@@ -842,7 +832,7 @@ int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data)
return 0;
}
md->spawn_timer = INVALID_TIMER;
- mob_spawn(md);
+ mob->spawn(md);
}
return 0;
}
@@ -856,14 +846,14 @@ int mob_setdelayspawn(struct mob_data *md)
struct mob_db *db;
if (!md->spawn) //Doesn't has respawn data!
- return unit_free(&md->bl,CLR_DEAD);
+ return unit->free(&md->bl,CLR_DEAD);
spawntime = md->spawn->delay1; //Base respawn time
if (md->spawn->delay2) //random variance
spawntime+= rnd()%md->spawn->delay2;
//Apply the spawn delay fix [Skotlex]
- db = mob_db(md->spawn->class_);
+ db = mob->db(md->spawn->class_);
mode = db->status.mode;
if (mode & MD_BOSS) { //Bosses
if (battle_config.boss_spawn_delay != 100) {
@@ -883,8 +873,8 @@ int mob_setdelayspawn(struct mob_data *md)
spawntime = 5000;
if( md->spawn_timer != INVALID_TIMER )
- iTimer->delete_timer(md->spawn_timer, mob_delayspawn);
- md->spawn_timer = iTimer->add_timer(iTimer->gettick()+spawntime, mob_delayspawn, md->bl.id, 0);
+ iTimer->delete_timer(md->spawn_timer, mob->delayspawn);
+ md->spawn_timer = iTimer->add_timer(iTimer->gettick()+spawntime, mob->delayspawn, md->bl.id, 0);
return 0;
}
@@ -910,13 +900,11 @@ int mob_spawn (struct mob_data *md)
md->last_thinktime = tick;
if (md->bl.prev != NULL)
- unit_remove_map(&md->bl,CLR_RESPAWN);
- else
- if (md->spawn && md->class_ != md->spawn->class_)
- {
+ unit->remove_map(&md->bl,CLR_RESPAWN,ALC_MARK);
+ else if (md->spawn && md->class_ != md->spawn->class_) {
md->class_ = md->spawn->class_;
iStatus->set_viewdata(&md->bl, md->class_);
- md->db = mob_db(md->class_);
+ md->db = mob->db(md->class_);
memcpy(md->name,md->spawn->name,NAME_LENGTH);
}
@@ -930,16 +918,16 @@ int mob_spawn (struct mob_data *md)
if( !iMap->search_freecell(&md->bl, -1, &md->bl.x, &md->bl.y, md->spawn->xs, md->spawn->ys, battle_config.no_spawn_on_player?4:0) )
{ // retry again later
if( md->spawn_timer != INVALID_TIMER )
- iTimer->delete_timer(md->spawn_timer, mob_delayspawn);
- md->spawn_timer = iTimer->add_timer(tick+5000,mob_delayspawn,md->bl.id,0);
+ iTimer->delete_timer(md->spawn_timer, mob->delayspawn);
+ md->spawn_timer = iTimer->add_timer(tick+5000,mob->delayspawn,md->bl.id,0);
return 1;
}
}
- else if( battle_config.no_spawn_on_player > 99 && iMap->foreachinrange(mob_count_sub, &md->bl, AREA_SIZE, BL_PC) )
+ else if( battle_config.no_spawn_on_player > 99 && iMap->foreachinrange(mob->count_sub, &md->bl, AREA_SIZE, BL_PC) )
{ // retry again later (players on sight)
if( md->spawn_timer != INVALID_TIMER )
- iTimer->delete_timer(md->spawn_timer, mob_delayspawn);
- md->spawn_timer = iTimer->add_timer(tick+5000,mob_delayspawn,md->bl.id,0);
+ iTimer->delete_timer(md->spawn_timer, mob->delayspawn);
+ md->spawn_timer = iTimer->add_timer(tick+5000,mob->delayspawn,md->bl.id,0);
return 1;
}
}
@@ -953,7 +941,7 @@ int mob_spawn (struct mob_data *md)
md->ud.target_to = 0;
if( md->spawn_timer != INVALID_TIMER )
{
- iTimer->delete_timer(md->spawn_timer, mob_delayspawn);
+ iTimer->delete_timer(md->spawn_timer, mob->delayspawn);
md->spawn_timer = INVALID_TIMER;
}
@@ -984,20 +972,20 @@ int mob_spawn (struct mob_data *md)
// MvP tomb [GreenBox]
if ( md->tomb_nid )
- mvptomb_destroy(md);
+ mob->mvptomb_destroy(md);
iMap->addblock(&md->bl);
if( map[md->bl.m].users )
clif->spawn(&md->bl);
skill->unit_move(&md->bl,tick,1);
- mobskill_use(md, tick, MSC_SPAWN);
+ mob->skill_use(md, tick, MSC_SPAWN);
return 0;
}
/*==========================================
* Determines if the mob can change target. [Skotlex]
*------------------------------------------*/
-static int mob_can_changetarget(struct mob_data* md, struct block_list* target, int mode)
+int mob_can_changetarget(struct mob_data* md, struct block_list* target, int mode)
{
// if the monster was provoked ignore the above rule [celest]
if(md->state.provoke_flag)
@@ -1035,7 +1023,7 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist)
nullpo_ret(bl);
// Nothing will be carried out if there is no mind of changing TAGE by TAGE ending.
- if(md->target_id && !mob_can_changetarget(md, bl, status_get_mode(&md->bl)))
+ if(md->target_id && !mob->can_changetarget(md, bl, status_get_mode(&md->bl)))
return 0;
if(!iStatus->check_skilluse(&md->bl, bl, 0, 0))
@@ -1053,7 +1041,7 @@ int mob_target(struct mob_data *md,struct block_list *bl,int dist)
/*==========================================
* The ?? routine of an active monster
*------------------------------------------*/
-static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap)
+int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap)
{
struct mob_data *md;
struct block_list **target;
@@ -1093,7 +1081,7 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap)
) { //Pick closest target?
if( map[bl->m].icewall_num &&
- !path_search_long(NULL,bl->m,md->bl.x,md->bl.y,bl->x,bl->y,CELL_CHKICEWALL) ) {
+ !path->search_long(NULL,bl->m,md->bl.x,md->bl.y,bl->x,bl->y,CELL_CHKICEWALL) ) {
if( !check_distance_bl(&md->bl, bl, status_get_range(&md->bl) ) )
return 0;
@@ -1115,7 +1103,7 @@ static int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap)
/*==========================================
* chase target-change routine.
*------------------------------------------*/
-static int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap)
+int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap)
{
struct mob_data *md;
struct block_list **target;
@@ -1141,7 +1129,7 @@ static int mob_ai_sub_hard_changechase(struct block_list *bl,va_list ap)
/*==========================================
* finds nearby bg ally for guardians looking for users to follow.
*------------------------------------------*/
-static int mob_ai_sub_hard_bg_ally(struct block_list *bl,va_list ap) {
+int mob_ai_sub_hard_bg_ally(struct block_list *bl,va_list ap) {
struct mob_data *md;
struct block_list **target;
@@ -1158,7 +1146,7 @@ static int mob_ai_sub_hard_bg_ally(struct block_list *bl,va_list ap) {
/*==========================================
* loot monster item search
*------------------------------------------*/
-static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
+int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
{
struct mob_data* md;
struct block_list **target;
@@ -1168,7 +1156,7 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
target= va_arg(ap,struct block_list**);
dist=distance_bl(&md->bl, bl);
- if(mob_can_reach(md,bl,dist+1, MSS_LOOT) &&
+ if(mob->can_reach(md,bl,dist+1, MSS_LOOT) &&
((*target) == NULL || !check_distance_bl(&md->bl, *target, dist)) //New target closer than previous one.
) {
(*target) = bl;
@@ -1178,7 +1166,7 @@ static int mob_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
return 0;
}
-static int mob_warpchase_sub(struct block_list *bl,va_list ap) {
+int mob_warpchase_sub(struct block_list *bl,va_list ap) {
struct block_list *target;
struct npc_data **target_nd;
struct npc_data *nd;
@@ -1209,7 +1197,7 @@ static int mob_warpchase_sub(struct block_list *bl,va_list ap) {
/*==========================================
* Processing of slave monsters
*------------------------------------------*/
-static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
+int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
{
struct block_list *bl;
@@ -1236,7 +1224,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
md->master_dist > MAX_MINCHASE
){
md->master_dist = 0;
- unit_warp(&md->bl,bl->m,bl->x,bl->y,CLR_TELEPORT);
+ unit->warp(&md->bl,bl->m,bl->x,bl->y,CLR_TELEPORT);
return 1;
}
@@ -1245,12 +1233,12 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
// Approach master if within view range, chase back to Master's area also if standing on top of the master.
if((md->master_dist>MOB_SLAVEDISTANCE || md->master_dist == 0) &&
- unit_can_move(&md->bl))
+ unit->can_move(&md->bl))
{
short x = bl->x, y = bl->y;
mob_stop_attack(md);
if(iMap->search_freecell(&md->bl, bl->m, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 1)
- && unit_walktoxy(&md->bl, x, y, 0))
+ && unit->walktoxy(&md->bl, x, y, 0))
return 1;
}
} else if (bl->m != md->bl.m && map_flag_gvg(md->bl.m)) {
@@ -1262,7 +1250,7 @@ static int mob_ai_sub_hard_slavemob(struct mob_data *md,unsigned int tick)
//Avoid attempting to lock the master's target too often to avoid unnecessary overload. [Skotlex]
if (DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME && !md->target_id)
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
md->last_linktime = tick;
if (ud) {
@@ -1306,12 +1294,12 @@ int mob_unlocktarget(struct mob_data *md, unsigned int tick)
case MSS_IDLE:
// Idle skill.
if ((md->target_id || !(++md->ud.walk_count%IDLE_SKILL_INTERVAL)) &&
- mobskill_use(md, tick, -1))
+ mob->skill_use(md, tick, -1))
break;
//Random walk.
if (!md->master_id &&
DIFF_TICK(md->next_walktime, tick) <= 0 &&
- !mob_randomwalk(md,tick))
+ !mob->randomwalk(md,tick))
//Delay next random walk when this one failed.
md->next_walktime=tick+rnd()%3000;
break;
@@ -1326,7 +1314,7 @@ int mob_unlocktarget(struct mob_data *md, unsigned int tick)
if (md->target_id) {
md->target_id=0;
md->ud.target_to = 0;
- unit_set_target(&md->ud, 0);
+ unit->set_target(&md->ud, 0);
}
return 0;
}
@@ -1342,7 +1330,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick)
nullpo_ret(md);
if(DIFF_TICK(md->next_walktime,tick)>0 ||
- !unit_can_move(&md->bl) ||
+ !unit->can_move(&md->bl) ||
!(status_get_mode(&md->bl)&MD_CANMOVE))
return 0;
@@ -1355,7 +1343,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick)
x+=md->bl.x;
y+=md->bl.y;
- if((iMap->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit_walktoxy(&md->bl,x,y,1)){
+ if((iMap->getcell(md->bl.m,x,y,CELL_CHKPASS)) && unit->walktoxy(&md->bl,x,y,1)){
break;
}
}
@@ -1364,7 +1352,7 @@ int mob_randomwalk(struct mob_data *md,unsigned int tick)
if(md->move_fail_count>1000){
ShowWarning("MOB can't move. random spawn %d, class = %d, at %s (%d,%d)\n",md->bl.id,md->class_,map[md->bl.m].name, md->bl.x, md->bl.y);
md->move_fail_count=0;
- mob_spawn(md);
+ mob->spawn(md);
}
return 0;
}
@@ -1396,10 +1384,10 @@ int mob_warpchase(struct mob_data *md, struct block_list *target)
return 1; //Already walking to a warp.
//Search for warps within mob's viewing range.
- iMap->foreachinrange (mob_warpchase_sub, &md->bl,
+ iMap->foreachinrange (mob->warpchase_sub, &md->bl,
md->db->range2, BL_NPC, target, &warp, &distance);
- if (warp && unit_walktobl(&md->bl, &warp->bl, 1, 1))
+ if (warp && unit->walktobl(&md->bl, &warp->bl, 1, 1))
return 1;
return 0;
}
@@ -1407,7 +1395,7 @@ int mob_warpchase(struct mob_data *md, struct block_list *target)
/*==========================================
* AI of MOB whose is near a Player
*------------------------------------------*/
-static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
+bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
{
struct block_list *tbl = NULL, *abl = NULL;
int mode;
@@ -1440,7 +1428,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
view_range = md->db->range2;
mode = status_get_mode(&md->bl);
- can_move = (mode&MD_CANMOVE)&&unit_can_move(&md->bl);
+ can_move = (mode&MD_CANMOVE)&&unit->can_move(&md->bl);
if (md->target_id)
{ //Check validity of current target. [Skotlex]
@@ -1453,9 +1441,9 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
((((TBL_PC*)tbl)->state.gangsterparadise && !(mode&MD_BOSS)) ||
((TBL_PC*)tbl)->invincible_timer != INVALID_TIMER)
)) { //Unlock current target.
- if (mob_warpchase(md, tbl))
+ if (mob->warpchase(md, tbl))
return true; //Chasing this target.
- mob_unlocktarget(md, tick-(battle_config.mob_ai&0x8?3000:0)); //Imediately do random walk.
+ mob->unlocktarget(md, tick-(battle_config.mob_ai&0x8?3000:0)); //Imediately do random walk.
tbl = NULL;
}
}
@@ -1470,18 +1458,18 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
(!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1)
|| md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP]
|| md->sc.data[SC__MANHOLE])) // Not yet confirmed if boss will teleport once it can't reach target.
- || !mob_can_reach(md, tbl, md->min_chase, MSS_RUSH)
+ || !mob->can_reach(md, tbl, md->min_chase, MSS_RUSH)
)
&& md->state.attacked_count++ >= RUDE_ATTACKED_COUNT
- && !mobskill_use(md, tick, MSC_RUDEATTACKED) // If can't rude Attack
- && can_move && unit_escape(&md->bl, tbl, rnd()%10 +1)) // Attempt escape
+ && !mob->skill_use(md, tick, MSC_RUDEATTACKED) // If can't rude Attack
+ && can_move && unit->escape(&md->bl, tbl, rnd()%10 +1)) // Attempt escape
{ //Escaped
md->attacked_id = 0;
return true;
}
}
else
- if( (abl = iMap->id2bl(md->attacked_id)) && (!tbl || mob_can_changetarget(md, abl, mode)) )
+ if( (abl = iMap->id2bl(md->attacked_id)) && (!tbl || mob->can_changetarget(md, abl, mode)) )
{
int dist;
if( md->bl.m != abl->m || abl->prev == NULL
@@ -1493,13 +1481,13 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
(!can_move && DIFF_TICK(tick, md->ud.canmove_tick) > 0 && (battle_config.mob_ai&0x2 || (md->sc.data[SC_SPIDERWEB] && md->sc.data[SC_SPIDERWEB]->val1)
|| md->sc.data[SC_WUGBITE] || md->sc.data[SC_VACUUM_EXTREME] || md->sc.data[SC_THORNS_TRAP]
|| md->sc.data[SC__MANHOLE])) // Not yet confirmed if boss will teleport once it can't reach target.
- || !mob_can_reach(md, abl, dist+md->db->range3, MSS_RUSH)
+ || !mob->can_reach(md, abl, dist+md->db->range3, MSS_RUSH)
)
) )
{ // Rude attacked
if (md->state.attacked_count++ >= RUDE_ATTACKED_COUNT
- && !mobskill_use(md, tick, MSC_RUDEATTACKED) && can_move
- && !tbl && unit_escape(&md->bl, abl, rnd()%10 +1))
+ && !mob->skill_use(md, tick, MSC_RUDEATTACKED) && can_move
+ && !tbl && unit->escape(&md->bl, abl, rnd()%10 +1))
{ //Escaped.
//TODO: Maybe it shouldn't attempt to run if it has another, valid target?
md->attacked_id = 0;
@@ -1533,26 +1521,26 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
}
// Processing of slave monster
- if (md->master_id > 0 && mob_ai_sub_hard_slavemob(md, tick))
+ if (md->master_id > 0 && mob->ai_sub_hard_slavemob(md, tick))
return true;
// Scan area for targets
if (!tbl && mode&MD_LOOTER && md->lootitem && DIFF_TICK(tick, md->ud.canact_tick) > 0 &&
(md->lootitem_count < LOOTITEM_SIZE || battle_config.monster_loot_type != 1))
{ // Scan area for items to loot, avoid trying to loot if the mob is full and can't consume the items.
- iMap->foreachinrange (mob_ai_sub_hard_lootsearch, &md->bl, view_range, BL_ITEM, md, &tbl);
+ iMap->foreachinrange (mob->ai_sub_hard_lootsearch, &md->bl, view_range, BL_ITEM, md, &tbl);
}
if ((!tbl && mode&MD_AGGRESSIVE) || md->state.skillstate == MSS_FOLLOW)
{
- iMap->foreachinrange (mob_ai_sub_hard_activesearch, &md->bl, view_range, DEFAULT_ENEMY_TYPE(md), md, &tbl, mode);
+ iMap->foreachinrange (mob->ai_sub_hard_activesearch, &md->bl, view_range, DEFAULT_ENEMY_TYPE(md), md, &tbl, mode);
}
else
if (mode&MD_CHANGECHASE && (md->state.skillstate == MSS_RUSH || md->state.skillstate == MSS_FOLLOW))
{
int search_size;
search_size = view_range<md->status.rhw.range ? view_range:md->status.rhw.range;
- iMap->foreachinrange (mob_ai_sub_hard_changechase, &md->bl, search_size, DEFAULT_ENEMY_TYPE(md), md, &tbl);
+ iMap->foreachinrange (mob->ai_sub_hard_changechase, &md->bl, search_size, DEFAULT_ENEMY_TYPE(md), md, &tbl);
}
if (!tbl) { //No targets available.
@@ -1563,15 +1551,15 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
if( md->bg_id && mode&MD_CANATTACK ) {
if( md->ud.walktimer != INVALID_TIMER )
return true;/* we are already moving */
- iMap->foreachinrange (mob_ai_sub_hard_bg_ally, &md->bl, view_range, BL_PC, md, &tbl, mode);
+ iMap->foreachinrange (mob->ai_sub_hard_bg_ally, &md->bl, view_range, BL_PC, md, &tbl, mode);
if( tbl ) {
- if( distance_blxy(&md->bl, tbl->x, tbl->y) <= 3 || unit_walktobl(&md->bl, tbl, 1, 1) )
+ if( distance_blxy(&md->bl, tbl->x, tbl->y) <= 3 || unit->walktobl(&md->bl, tbl, 1, 1) )
return true;/* we're moving or close enough don't unlock the target. */
}
}
//This handles triggering idle walk/skill.
- mob_unlocktarget(md, tick);
+ mob->unlocktarget(md, tick);
return true;
}
@@ -1583,21 +1571,21 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
return true; //Already locked.
if (md->lootitem == NULL)
{ //Can't loot...
- mob_unlocktarget (md, tick);
+ mob->unlocktarget (md, tick);
return true;
}
if (!check_distance_bl(&md->bl, tbl, 1))
{ //Still not within loot range.
if (!(mode&MD_CANMOVE))
{ //A looter that can't move? Real smart.
- mob_unlocktarget(md,tick);
+ mob->unlocktarget(md,tick);
return true;
}
if (!can_move) //Stuck. Wait before walking.
return true;
md->state.skillstate = MSS_LOOT;
- if (!unit_walktobl(&md->bl, tbl, 1, 1))
- mob_unlocktarget(md, tick); //Can't loot...
+ if (!unit->walktobl(&md->bl, tbl, 1, 1))
+ mob->unlocktarget(md, tick); //Can't loot...
return true;
}
//Within looting range.
@@ -1620,11 +1608,11 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
{ //Give them walk act/delay to properly mimic players. [Skotlex]
clif->takeitem(&md->bl,tbl);
md->ud.canact_tick = tick + md->status.amotion;
- unit_set_walkdelay(&md->bl, tick, md->status.amotion, 1);
+ unit->set_walkdelay(&md->bl, tick, md->status.amotion, 1);
}
//Clear item.
iMap->clearflooritem (tbl);
- mob_unlocktarget (md,tick);
+ mob->unlocktarget (md,tick);
return true;
}
//Attempt to attack.
@@ -1636,8 +1624,8 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
{ //Target within range, engage
if(tbl->type == BL_PC)
- mob_log_damage(md, tbl, 0); //Log interaction (counts as 'attacker' for the exp bonus)
- unit_attack(&md->bl,tbl->id,1);
+ mob->log_damage(md, tbl, 0); //Log interaction (counts as 'attacker' for the exp bonus)
+ unit->attack(&md->bl,tbl->id,1);
return true;
}
@@ -1645,8 +1633,8 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
if (!(mode&MD_CANMOVE))
{ //Can't chase. Attempt an idle skill before unlocking.
md->state.skillstate = MSS_IDLE;
- if (!mobskill_use(md, tick, -1))
- mob_unlocktarget(md,tick);
+ if (!mob->skill_use(md, tick, -1))
+ mob->unlocktarget(md,tick);
return true;
}
@@ -1654,7 +1642,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
{ //Stuck. Attempt an idle skill
md->state.skillstate = MSS_IDLE;
if (!(++md->ud.walk_count%IDLE_SKILL_INTERVAL))
- mobskill_use(md, tick, -1);
+ mob->skill_use(md, tick, -1);
return true;
}
@@ -1666,18 +1654,18 @@ static bool mob_ai_sub_hard(struct mob_data *md, unsigned int tick)
return true;
//Follow up if possible.
- if(!mob_can_reach(md, tbl, md->min_chase, MSS_RUSH) ||
- !unit_walktobl(&md->bl, tbl, md->status.rhw.range, 2))
- mob_unlocktarget(md,tick);
+ if(!mob->can_reach(md, tbl, md->min_chase, MSS_RUSH) ||
+ !unit->walktobl(&md->bl, tbl, md->status.rhw.range, 2))
+ mob->unlocktarget(md,tick);
return true;
}
-static int mob_ai_sub_hard_timer(struct block_list *bl,va_list ap)
+int mob_ai_sub_hard_timer(struct block_list *bl,va_list ap)
{
struct mob_data *md = (struct mob_data*)bl;
unsigned int tick = va_arg(ap, unsigned int);
- if (mob_ai_sub_hard(md, tick))
+ if (mob->ai_sub_hard(md, tick))
{ //Hard AI triggered.
if(!md->state.spotted)
md->state.spotted = 1;
@@ -1689,11 +1677,11 @@ static int mob_ai_sub_hard_timer(struct block_list *bl,va_list ap)
/*==========================================
* Serious processing for mob in PC field of view (foreachclient)
*------------------------------------------*/
-static int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap)
+int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap)
{
unsigned int tick;
tick=va_arg(ap,unsigned int);
- iMap->foreachinrange(mob_ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick);
+ iMap->foreachinrange(mob->ai_sub_hard_timer,&sd->bl, AREA_SIZE+ACTIVE_AI_RANGE, BL_MOB,tick);
return 0;
}
@@ -1701,7 +1689,7 @@ static int mob_ai_sub_foreachclient(struct map_session_data *sd,va_list ap)
/*==========================================
* Negligent mode MOB AI (PC is not in near)
*------------------------------------------*/
-static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
+int mob_ai_sub_lazy(struct mob_data *md, va_list args)
{
unsigned int tick;
@@ -1713,7 +1701,7 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
tick = va_arg(args,unsigned int);
if (battle_config.mob_ai&0x20 && map[md->bl.m].users>0)
- return (int)mob_ai_sub_hard(md, tick);
+ return (int)mob->ai_sub_hard(md, tick);
if (md->bl.prev==NULL || md->status.hp == 0)
return 1;
@@ -1724,7 +1712,7 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
DIFF_TICK(tick,md->last_thinktime) > MIN_MOBTHINKTIME)
{
if (DIFF_TICK(tick,md->last_pcneartime) < battle_config.mob_active_time)
- return (int)mob_ai_sub_hard(md, tick);
+ return (int)mob->ai_sub_hard(md, tick);
md->last_pcneartime = 0;
}
@@ -1734,7 +1722,7 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
DIFF_TICK(tick,md->last_thinktime) > MIN_MOBTHINKTIME)
{
if (DIFF_TICK(tick,md->last_pcneartime) < battle_config.boss_active_time)
- return (int)mob_ai_sub_hard(md, tick);
+ return (int)mob->ai_sub_hard(md, tick);
md->last_pcneartime = 0;
}
@@ -1744,24 +1732,24 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
md->last_thinktime=tick;
if (md->master_id) {
- mob_ai_sub_hard_slavemob (md,tick);
+ mob->ai_sub_hard_slavemob (md,tick);
return 0;
}
- if( DIFF_TICK(md->next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit_can_move(&md->bl) )
+ if( DIFF_TICK(md->next_walktime,tick) < 0 && (status_get_mode(&md->bl)&MD_CANMOVE) && unit->can_move(&md->bl) )
{
if( map[md->bl.m].users > 0 )
{
if( rnd()%1000 < MOB_LAZYMOVEPERC(md) )
- mob_randomwalk(md, tick);
+ mob->randomwalk(md, tick);
else
if( rnd()%1000 < MOB_LAZYSKILLPERC ) //Chance to do a mob's idle skill.
- mobskill_use(md, tick, -1);
+ mob->skill_use(md, tick, -1);
}
else
{
if( rnd()%1000 < MOB_LAZYMOVEPERC(md) )
- mob_randomwalk(md, tick);
+ mob->randomwalk(md, tick);
}
}
return 0;
@@ -1770,22 +1758,22 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
/*==========================================
* Negligent processing for mob outside PC field of view (interval timer function)
*------------------------------------------*/
-static int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data)
+int mob_ai_lazy(int tid, unsigned int tick, int id, intptr_t data)
{
- iMap->map_foreachmob(mob_ai_sub_lazy,tick);
+ iMap->map_foreachmob(mob->ai_sub_lazy,tick);
return 0;
}
/*==========================================
* Serious processing for mob in PC field of view (interval timer function)
*------------------------------------------*/
-static int mob_ai_hard(int tid, unsigned int tick, int id, intptr_t data)
+int mob_ai_hard(int tid, unsigned int tick, int id, intptr_t data)
{
if (battle_config.mob_ai&0x20)
- iMap->map_foreachmob(mob_ai_sub_lazy,tick);
+ iMap->map_foreachmob(mob->ai_sub_lazy,tick);
else
- iMap->map_foreachpc(mob_ai_sub_foreachclient,tick);
+ iMap->map_foreachpc(mob->ai_sub_foreachclient,tick);
return 0;
}
@@ -1793,12 +1781,12 @@ static int mob_ai_hard(int tid, unsigned int tick, int id, intptr_t data)
/*==========================================
* Initializes the delay drop structure for mob-dropped items.
*------------------------------------------*/
-static struct item_drop* mob_setdropitem(int nameid, int qty, struct item_data *data) {
+struct item_drop* mob_setdropitem(int nameid, int qty, struct item_data *data) {
struct item_drop *drop = ers_alloc(item_drop_ers, struct item_drop);
memset(&drop->item_data, 0, sizeof(struct item));
drop->item_data.nameid = nameid;
drop->item_data.amount = qty;
- drop->item_data.identify = data ? itemdb_isidentified2(data) : itemdb_isidentified(nameid);
+ drop->item_data.identify = data ? itemdb->isidentified2(data) : itemdb->isidentified(nameid);
drop->next = NULL;
return drop;
}
@@ -1806,7 +1794,7 @@ static struct item_drop* mob_setdropitem(int nameid, int qty, struct item_data *
/*==========================================
* Initializes the delay drop structure for mob-looted items.
*------------------------------------------*/
-static struct item_drop* mob_setlootitem(struct item* item)
+struct item_drop* mob_setlootitem(struct item* item)
{
struct item_drop *drop = ers_alloc(item_drop_ers, struct item_drop);
memcpy(&drop->item_data, item, sizeof(struct item));
@@ -1817,7 +1805,7 @@ static struct item_drop* mob_setlootitem(struct item* item)
/*==========================================
* item drop with delay (timer function)
*------------------------------------------*/
-static int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data)
+int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data)
{
struct item_drop_list *list;
struct item_drop *ditem, *ditem_prev;
@@ -1841,7 +1829,7 @@ static int mob_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data
* rate is the drop-rate of the item, required for autoloot.
* flag : Killed only by homunculus?
*------------------------------------------*/
-static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct item_drop *ditem, int loot, int drop_rate, unsigned short flag)
+void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct item_drop *ditem, int loot, int drop_rate, unsigned short flag)
{
TBL_PC* sd;
@@ -1886,7 +1874,7 @@ int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data)
}
//for Alchemist CANNIBALIZE [Lupus]
md->deletetimer = INVALID_TIMER;
- unit_free(bl, CLR_TELEPORT);
+ unit->free(bl, CLR_TELEPORT);
}
return 0;
}
@@ -1915,7 +1903,7 @@ int mob_deleteslave(struct mob_data *md)
{
nullpo_ret(md);
- iMap->foreachinmap(mob_deleteslave_sub, md->bl.m, BL_MOB,md->bl.id);
+ iMap->foreachinmap(mob->deleteslave_sub, md->bl.m, BL_MOB,md->bl.id);
return 0;
}
// Mob respawning through KAIZEL or NPC_REBIRTH [Skotlex]
@@ -2060,7 +2048,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) {
}
//Log damage
if (src)
- mob_log_damage(md, src, damage);
+ mob->log_damage(md, src, damage);
md->dmgtick = iTimer->gettick();
}
@@ -2085,7 +2073,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage) {
if( md->special_state.ai == 2 ) {//LOne WOlf explained that ANYONE can trigger the marine countdown skill. [Skotlex]
md->state.alchemist = 1;
- mobskill_use(md, iTimer->gettick(), MSC_ALCHEMIST);
+ mob->skill_use(md, iTimer->gettick(), MSC_ALCHEMIST);
}
}
@@ -2123,7 +2111,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if( src )
{ // Use Dead skill only if not killed by Script or Command
md->state.skillstate = MSS_DEAD;
- mobskill_use(md,tick,-1);
+ mob->skill_use(md,tick,-1);
}
iMap->freeblock_lock();
@@ -2131,7 +2119,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
memset(pt,0,sizeof(pt));
if(src && src->type == BL_MOB)
- mob_unlocktarget((struct mob_data *)src,tick);
+ mob->unlocktarget((struct mob_data *)src,tick);
// filter out entries not eligible for exp distribution
memset(tmpsd,0,sizeof(tmpsd));
@@ -2382,11 +2370,11 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
continue;
if( mvp_sd && it->type == IT_PETEGG ) {
- pet_create_egg(mvp_sd, md->db->dropitem[i].nameid);
+ pet->create_egg(mvp_sd, md->db->dropitem[i].nameid);
continue;
}
- ditem = mob_setdropitem(md->db->dropitem[i].nameid, 1, it);
+ ditem = mob->setdropitem(md->db->dropitem[i].nameid, 1, it);
//A Rare Drop Global Announce by Lupus
if( mvp_sd && drop_rate <= battle_config.rare_drop_announce ) {
@@ -2397,14 +2385,14 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
}
// Announce first, or else ditem will be freed. [Lance]
// By popular demand, use base drop rate for autoloot code. [Skotlex]
- mob_item_drop(md, dlist, ditem, 0, md->db->dropitem[i].p, homkillonly);
+ mob->item_drop(md, dlist, ditem, 0, md->db->dropitem[i].p, homkillonly);
}
// Ore Discovery [Celest]
if (sd == mvp_sd && pc->checkskill(sd,BS_FINDINGORE) > 0) {
if( (temp = itemdb->chain_item(itemdb->chain_cache[ECC_ORE],&i)) ) {
- ditem = mob_setdropitem(temp, 1, NULL);
- mob_item_drop(md, dlist, ditem, 0, i, homkillonly);
+ ditem = mob->setdropitem(temp, 1, NULL);
+ mob->item_drop(md, dlist, ditem, 0, i, homkillonly);
}
}
@@ -2435,7 +2423,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
continue;
itemid = (sd->add_drop[i].id > 0) ? sd->add_drop[i].id : itemdb->chain_item(sd->add_drop[i].group,&drop_rate);
if( itemid )
- mob_item_drop(md, dlist, mob_setdropitem(itemid,1,NULL), 0, drop_rate, homkillonly);
+ mob->item_drop(md, dlist, mob->setdropitem(itemid,1,NULL), 0, drop_rate, homkillonly);
}
}
@@ -2450,10 +2438,10 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
// process items looted by the mob
if(md->lootitem) {
for(i = 0; i < md->lootitem_count; i++)
- mob_item_drop(md, dlist, mob_setlootitem(&md->lootitem[i]), 1, 10000, homkillonly);
+ mob->item_drop(md, dlist, mob->setlootitem(&md->lootitem[i]), 1, 10000, homkillonly);
}
if (dlist->item) //There are drop items.
- iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, 0, (intptr_t)dlist);
+ iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist);
else //No drops
ers_free(item_drop_list_ers, dlist);
} else if (md->lootitem && md->lootitem_count) { //Loot MUST drop!
@@ -2466,8 +2454,8 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
dlist->third_charid = (third_sd ? third_sd->status.char_id : 0);
dlist->item = NULL;
for(i = 0; i < md->lootitem_count; i++)
- mob_item_drop(md, dlist, mob_setlootitem(&md->lootitem[i]), 1, 10000, homkillonly);
- iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, 0, (intptr_t)dlist);
+ mob->item_drop(md, dlist, mob->setlootitem(&md->lootitem[i]), 1, 10000, homkillonly);
+ iTimer->add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob->delay_item_drop, 0, (intptr_t)dlist);
}
if(mvp_sd && md->db->mexp > 0 && !md->special_state.ai) {
@@ -2525,7 +2513,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
memset(&item,0,sizeof(item));
item.nameid=mdrop_id[i];
- item.identify= itemdb_isidentified2(data);
+ item.identify= itemdb->isidentified2(data);
clif->mvp_item(mvp_sd,item.nameid);
log_mvp[0] = item.nameid;
@@ -2569,7 +2557,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
if( sd ) {
if( sd->mission_mobid == md->class_) { //TK_MISSION [Skotlex]
- if( ++sd->mission_count >= 100 && (temp = mob_get_random_id(0, 0xE, sd->status.base_level)) ) {
+ if( ++sd->mission_count >= 100 && (temp = mob->get_random_id(0, 0xE, sd->status.base_level)) ) {
pc->addfame(sd, 1);
sd->mission_mobid = temp;
pc_setglobalreg(sd,"TK_MISSION_ID", temp);
@@ -2580,40 +2568,40 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
}
if( sd->status.party_id )
- iMap->foreachinrange(quest_update_objective_sub,&md->bl,AREA_SIZE,BL_PC,sd->status.party_id,md->class_);
+ iMap->foreachinrange(quest->update_objective_sub,&md->bl,AREA_SIZE,BL_PC,sd->status.party_id,md->class_);
else if( sd->avail_quests )
- quest_update_objective(sd, md->class_);
+ quest->update_objective(sd, md->class_);
- if( sd->md && src && src->type != BL_HOM && mob_db(md->class_)->lv > sd->status.base_level/2 )
+ if( sd->md && src && src->type != BL_HOM && mob->db(md->class_)->lv > sd->status.base_level/2 )
mercenary->kills(sd->md);
}
if( md->npc_event[0] && !md->state.npc_killmonster ) {
if( sd && battle_config.mob_npc_event_type ) {
pc->setparam(sd, SP_KILLERRID, sd->bl.id);
- npc_event(sd,md->npc_event,0);
+ npc->event(sd,md->npc_event,0);
} else if( mvp_sd ) {
pc->setparam(mvp_sd, SP_KILLERRID, sd?sd->bl.id:0);
- npc_event(mvp_sd,md->npc_event,0);
+ npc->event(mvp_sd,md->npc_event,0);
} else
- npc_event_do(md->npc_event);
+ npc->event_do(md->npc_event);
} else if( mvp_sd && !md->state.npc_killmonster ) {
pc->setparam(mvp_sd, SP_KILLEDRID, md->class_);
- npc_script_event(mvp_sd, NPCE_KILLNPC); // PCKillNPC [Lance]
+ npc->script_event(mvp_sd, NPCE_KILLNPC); // PCKillNPC [Lance]
}
md->status.hp = 1;
}
if(md->deletetimer != INVALID_TIMER) {
- iTimer->delete_timer(md->deletetimer,mob_timer_delete);
+ iTimer->delete_timer(md->deletetimer,mob->timer_delete);
md->deletetimer = INVALID_TIMER;
}
/**
* Only loops if necessary (e.g. a poring would never need to loop)
**/
if( md->can_summon )
- mob_deleteslave(md);
+ mob->deleteslave(md);
iMap->freeblock_unlock();
@@ -2637,11 +2625,11 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
// MvP tomb [GreenBox]
if (battle_config.mvp_tomb_enabled && md->spawn->state.boss && map[md->bl.m].flag.notomb != 1)
- mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL));
+ mob->mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL));
if( !rebirth ) {
iStatus->change_clear(&md->bl,1);
- mob_setdelayspawn(md); //Set respawning.
+ mob->setdelayspawn(md); //Set respawning.
}
return 3; //Remove from map.
}
@@ -2660,7 +2648,7 @@ void mob_revive(struct mob_data *md, unsigned int hp)
iMap->addblock(&md->bl);
clif->spawn(&md->bl);
skill->unit_move(&md->bl,tick,1);
- mobskill_use(md, tick, MSC_SPAWN);
+ mob->skill_use(md, tick, MSC_SPAWN);
if (battle_config.show_mob_info&3)
clif->charnameack (0, &md->bl);
}
@@ -2683,7 +2671,7 @@ int mob_guardian_guildchange(struct mob_data *md)
} else {
if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS && md->guardian_data->castle->guardian[md->guardian_data->number].visible)
guild->castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number, 0);
- unit_free(&md->bl,CLR_OUTSIGHT); //Remove guardian.
+ unit->free(&md->bl,CLR_OUTSIGHT); //Remove guardian.
}
return 0;
}
@@ -2694,7 +2682,7 @@ int mob_guardian_guildchange(struct mob_data *md)
ShowError("mob_guardian_guildchange: New Guild (id %d) does not exists!\n", md->guardian_data->guild_id);
if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS)
guild->castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number, 0);
- unit_free(&md->bl,CLR_OUTSIGHT);
+ unit->free(&md->bl,CLR_OUTSIGHT);
return 0;
}
@@ -2716,16 +2704,16 @@ int mob_random_class (int *value, size_t count)
// no count specified, look into the array manually, but take only max 5 elements
if (count < 1) {
count = 0;
- while(count < 5 && mobdb_checkid(value[count])) count++;
+ while(count < 5 && mob->db_checkid(value[count])) count++;
if(count < 1) // nothing found
return 0;
} else {
// check if at least the first value is valid
- if(mobdb_checkid(value[0]) == 0)
+ if(mob->db_checkid(value[0]) == 0)
return 0;
}
//Pick a random value, hoping it exists. [Skotlex]
- return mobdb_checkid(value[rnd()%count]);
+ return mob->db_checkid(value[rnd()%count]);
}
/*==========================================
@@ -2751,7 +2739,7 @@ int mob_class_change (struct mob_data *md, int class_)
if( md->special_state.ai > 1 )
return 0; //Marine Spheres and Floras.
- if( mob_is_clone(md->class_) )
+ if( mob->is_clone(md->class_) )
return 0; //Clones
if( md->class_ == class_ )
@@ -2759,7 +2747,7 @@ int mob_class_change (struct mob_data *md, int class_)
hp_rate = get_percentage(md->status.hp, md->status.max_hp);
md->class_ = class_;
- md->db = mob_db(class_);
+ md->db = mob->db(class_);
if (battle_config.override_mob_names==1)
memcpy(md->name,md->db->name,NAME_LENGTH);
else
@@ -2767,7 +2755,7 @@ int mob_class_change (struct mob_data *md, int class_)
mob_stop_attack(md);
mob_stop_walking(md, 0);
- unit_skillcastcancel(&md->bl, 0);
+ unit->skillcastcancel(&md->bl, 0);
iStatus->set_viewdata(&md->bl, class_);
clif->class_change(&md->bl, md->vd->class_, 1);
status_calc_mob(md, 1);
@@ -2820,7 +2808,7 @@ int mob_warpslave_sub(struct block_list *bl,va_list ap)
return 0;
iMap->search_freecell(master, 0, &x, &y, range, range, 0);
- unit_warp(&md->bl, master->m, x, y,CLR_RESPAWN);
+ unit->warp(&md->bl, master->m, x, y,CLR_RESPAWN);
return 1;
}
@@ -2834,7 +2822,7 @@ int mob_warpslave(struct block_list *bl, int range)
if (range < 1)
range = 1; //Min range needed to avoid crashes and stuff. [Skotlex]
- return iMap->foreachinmap(mob_warpslave_sub, bl->m, BL_MOB, bl, range);
+ return iMap->foreachinmap(mob->warpslave_sub, bl->m, BL_MOB, bl, range);
}
/*==========================================
@@ -2857,7 +2845,7 @@ int mob_countslave_sub(struct block_list *bl,va_list ap)
*------------------------------------------*/
int mob_countslave(struct block_list *bl)
{
- return iMap->foreachinmap(mob_countslave_sub, bl->m, BL_MOB,bl->id);
+ return iMap->foreachinmap(mob->countslave_sub, bl->m, BL_MOB,bl->id);
}
/*==========================================
@@ -2880,14 +2868,14 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id)
data.state.size = md2->special_state.size;
data.state.ai = md2->special_state.ai;
- if(mobdb_checkid(value[0]) == 0)
+ if(mob->db_checkid(value[0]) == 0)
return 0;
/**
* Flags this monster is able to summon; saves a worth amount of memory upon deletion
**/
md2->can_summon = 1;
- while(count < 5 && mobdb_checkid(value[count])) count++;
+ while(count < 5 && mob->db_checkid(value[count])) count++;
if(count < 1) return 0;
if (amount > 0 && amount < count) { //Do not start on 0, pick some random sub subset [Skotlex]
k = rnd()%count;
@@ -2901,7 +2889,7 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id)
for(;k<amount;k++) {
short x,y;
data.class_ = value[k%count]; //Summon slaves in round-robin fashion. [Skotlex]
- if (mobdb_checkid(data.class_) == 0)
+ if (mob->db_checkid(data.class_) == 0)
continue;
if (iMap->search_freecell(&md2->bl, 0, &x, &y, MOB_SLAVEDISTANCE, MOB_SLAVEDISTANCE, 0)) {
@@ -2918,15 +2906,15 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id)
else
strcpy(data.name,"--ja--");
- if (!mob_parse_dataset(&data))
+ if (!mob->parse_dataset(&data))
continue;
- md= mob_spawn_dataset(&data);
+ md= mob->spawn_dataset(&data);
if(skill_id == NPC_SUMMONSLAVE){
md->master_id=md2->bl.id;
md->special_state.ai = md2->special_state.ai;
}
- mob_spawn(md);
+ mob->spawn(md);
if (hp_rate) //Scale HP
md->status.hp = md->status.max_hp*hp_rate/100;
@@ -2964,8 +2952,8 @@ int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id)
*------------------------------------------*/
int mob_skill_id2skill_idx(int class_,uint16 skill_id)
{
- int i, max = mob_db(class_)->maxskill;
- struct mob_skill *ms=mob_db(class_)->skill;
+ int i, max = mob->db(class_)->maxskill;
+ struct mob_skill *ms=mob->db(class_)->skill;
if(ms==NULL)
return -1;
@@ -3003,7 +2991,7 @@ int mob_getfriendhprate_sub(struct block_list *bl,va_list ap)
(*fr) = bl;
return 1;
}
-static struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,int max_rate)
+struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,int max_rate)
{
struct block_list *fr=NULL;
int type = BL_MOB;
@@ -3013,7 +3001,7 @@ static struct block_list *mob_getfriendhprate(struct mob_data *md,int min_rate,i
if (md->special_state.ai) //Summoned creatures. [Skotlex]
type = BL_PC;
- iMap->foreachinrange(mob_getfriendhprate_sub, &md->bl, 8, type,md,min_rate,max_rate,&fr);
+ iMap->foreachinrange(mob->getfriendhprate_sub, &md->bl, 8, type,md,min_rate,max_rate,&fr);
return fr;
}
/*==========================================
@@ -3070,7 +3058,7 @@ struct mob_data *mob_getfriendstatus(struct mob_data *md,int cond1,int cond2)
struct mob_data* fr = NULL;
nullpo_ret(md);
- iMap->foreachinrange(mob_getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr);
+ iMap->foreachinrange(mob->getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr);
return fr;
}
@@ -3149,20 +3137,20 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
}
flag ^= (ms[i].cond1 == MSC_MYSTATUSOFF); break;
case MSC_FRIENDHPLTMAXRATE: // friend HP < maxhp%
- flag = ((fbl = mob_getfriendhprate(md, 0, ms[i].cond2)) != NULL); break;
+ flag = ((fbl = mob->getfriendhprate(md, 0, ms[i].cond2)) != NULL); break;
case MSC_FRIENDHPINRATE :
- flag = ((fbl = mob_getfriendhprate(md, ms[i].cond2, ms[i].val[0])) != NULL); break;
+ flag = ((fbl = mob->getfriendhprate(md, ms[i].cond2, ms[i].val[0])) != NULL); break;
case MSC_FRIENDSTATUSON: // friend status[num] on
case MSC_FRIENDSTATUSOFF: // friend status[num] off
- flag = ((fmd = mob_getfriendstatus(md, ms[i].cond1, ms[i].cond2)) != NULL); break;
+ flag = ((fmd = mob->getfriendstatus(md, ms[i].cond1, ms[i].cond2)) != NULL); break;
case MSC_SLAVELT: // slave < num
- flag = (mob_countslave(&md->bl) < c2 ); break;
+ flag = (mob->countslave(&md->bl) < c2 ); break;
case MSC_ATTACKPCGT: // attack pc > num
- flag = (unit_counttargeted(&md->bl) > c2); break;
+ flag = (unit->counttargeted(&md->bl) > c2); break;
case MSC_SLAVELE: // slave <= num
- flag = (mob_countslave(&md->bl) <= c2 ); break;
+ flag = (mob->countslave(&md->bl) <= c2 ); break;
case MSC_ATTACKPCGE: // attack pc >= num
- flag = (unit_counttargeted(&md->bl) >= c2); break;
+ flag = (unit->counttargeted(&md->bl) >= c2); break;
case MSC_AFTERSKILL:
flag = (md->ud.skill_id == c2); break;
case MSC_RUDEATTACKED:
@@ -3170,9 +3158,9 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
if (flag) md->state.attacked_count = 0; //Rude attacked count should be reset after the skill condition is met. Thanks to Komurka [Skotlex]
break;
case MSC_MASTERHPLTMAXRATE:
- flag = ((fbl = mob_getmasterhpltmaxrate(md, ms[i].cond2)) != NULL); break;
+ flag = ((fbl = mob->getmasterhpltmaxrate(md, ms[i].cond2)) != NULL); break;
case MSC_MASTERATTACKED:
- flag = (md->master_id > 0 && (fbl=iMap->id2bl(md->master_id)) && unit_counttargeted(fbl) > 0); break;
+ flag = (md->master_id > 0 && (fbl=iMap->id2bl(md->master_id)) && unit->counttargeted(fbl) > 0); break;
case MSC_ALCHEMIST:
flag = (md->state.alchemist);
break;
@@ -3224,7 +3212,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
md->skill_idx = i;
iMap->freeblock_lock();
if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) ||
- !unit_skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) )
+ !unit->skilluse_pos2(&md->bl, x, y,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) )
{
iMap->freeblock_unlock();
continue;
@@ -3262,7 +3250,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
md->skill_idx = i;
iMap->freeblock_lock();
if( !battle->check_range(&md->bl,bl,skill->get_range2(&md->bl, ms[i].skill_id,ms[i].skill_lv)) ||
- !unit_skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) )
+ !unit->skilluse_id2(&md->bl, bl->id,ms[i].skill_id, ms[i].skill_lv,ms[i].casttime, ms[i].cancel) )
{
iMap->freeblock_unlock();
continue;
@@ -3270,7 +3258,7 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
}
//Skill used. Post-setups...
if ( ms[ i ].msg_id ){ //Display color message [SnakeDrak]
- struct mob_chat *mc = mob_chat(ms[i].msg_id);
+ struct mob_chat *mc = mob->chat(ms[i].msg_id);
char temp[CHAT_SIZE_MAX];
char name[NAME_LENGTH];
snprintf(name, sizeof name,"%s", md->name);
@@ -3306,13 +3294,13 @@ int mobskill_event(struct mob_data *md, struct block_list *src, unsigned int tic
md->target_id = src->id;
if (flag == -1)
- res = mobskill_use(md, tick, MSC_CASTTARGETED);
+ res = mob->skill_use(md, tick, MSC_CASTTARGETED);
else if ((flag&0xffff) == MSC_SKILLUSED)
- res = mobskill_use(md, tick, flag);
+ res = mob->skill_use(md, tick, flag);
else if (flag&BF_SHORT)
- res = mobskill_use(md, tick, MSC_CLOSEDATTACKED);
+ res = mob->skill_use(md, tick, MSC_CLOSEDATTACKED);
else if (flag&BF_LONG && !(flag&BF_MAGIC)) //Long-attacked should not include magic.
- res = mobskill_use(md, tick, MSC_LONGRANGEATTACKED);
+ res = mob->skill_use(md, tick, MSC_LONGRANGEATTACKED);
if (!res)
//Restore previous target only if skill condition failed to trigger. [Skotlex]
@@ -3329,7 +3317,7 @@ int mob_is_clone(int class_)
{
if(class_ < MOB_CLONE_START || class_ > MOB_CLONE_END)
return 0;
- if (mob_db(class_) == mob_dummy)
+ if (mob->db(class_) == mob->dummy)
return 0;
return class_;
}
@@ -3353,11 +3341,11 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons
if(pc_isdead(sd) && master_id && flag&1)
return 0;
- ARR_FIND( MOB_CLONE_START, MOB_CLONE_END, class_, mob_db_data[class_] == NULL );
+ ARR_FIND( MOB_CLONE_START, MOB_CLONE_END, class_, mob->db_data[class_] == NULL );
if(class_ >= MOB_CLONE_END)
return 0;
- db = mob_db_data[class_]=(struct mob_db*)aCalloc(1, sizeof(struct mob_db));
+ db = mob->db_data[class_]=(struct mob_db*)aCalloc(1, sizeof(struct mob_db));
status = &db->status;
strcpy(db->sprite,sd->status.name);
strcpy(db->name,sd->status.name);
@@ -3519,7 +3507,7 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons
sd->fd = fd;
//Finally, spawn it.
- md = mob_once_spawn_sub(&sd->bl, m, x, y, "--en--", class_, event, SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(&sd->bl, m, x, y, "--en--", class_, event, SZ_SMALL, AI_NONE);
if (!md) return 0; //Failed?
md->special_state.clone = 1;
@@ -3532,12 +3520,12 @@ int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, cons
if (duration) //Auto Delete after a while.
{
if( md->deletetimer != INVALID_TIMER )
- iTimer->delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = iTimer->add_timer (iTimer->gettick() + duration, mob_timer_delete, md->bl.id, 0);
+ iTimer->delete_timer(md->deletetimer, mob->timer_delete);
+ md->deletetimer = iTimer->add_timer (iTimer->gettick() + duration, mob->timer_delete, md->bl.id, 0);
}
}
- mob_spawn(md);
+ mob->spawn(md);
return md->bl.id;
}
@@ -3546,11 +3534,11 @@ int mob_clone_delete(struct mob_data *md)
{
const int class_ = md->class_;
if (class_ >= MOB_CLONE_START && class_ < MOB_CLONE_END
- && mob_db_data[class_]!=NULL) {
- aFree(mob_db_data[class_]);
- mob_db_data[class_]=NULL;
+ && mob->db_data[class_]!=NULL) {
+ aFree(mob->db_data[class_]);
+ mob->db_data[class_]=NULL;
//Clear references to the db
- md->db = mob_dummy;
+ md->db = mob->dummy;
md->vd = NULL;
return 1;
}
@@ -3563,50 +3551,50 @@ int mob_clone_delete(struct mob_data *md)
/*==========================================
* Since un-setting [ mob ] up was used, it is an initial provisional value setup.
*------------------------------------------*/
-static int mob_makedummymobdb(int class_)
+int mob_makedummymobdb(int class_)
{
- if (mob_dummy != NULL)
+ if (mob->dummy != NULL)
{
- if (mob_db(class_) == mob_dummy)
- return 1; //Using the mob_dummy data already. [Skotlex]
+ if (mob->db(class_) == mob->dummy)
+ return 1; //Using the mob->dummy data already. [Skotlex]
if (class_ > 0 && class_ <= MAX_MOB_DB)
{ //Remove the mob data so that it uses the dummy data instead.
- aFree(mob_db_data[class_]);
- mob_db_data[class_] = NULL;
+ aFree(mob->db_data[class_]);
+ mob->db_data[class_] = NULL;
}
return 0;
}
//Initialize dummy data.
- mob_dummy = (struct mob_db*)aCalloc(1, sizeof(struct mob_db)); //Initializing the dummy mob.
- sprintf(mob_dummy->sprite,"DUMMY");
- sprintf(mob_dummy->name,"Dummy");
- sprintf(mob_dummy->jname,"Dummy");
- mob_dummy->lv=1;
- mob_dummy->status.max_hp=1000;
- mob_dummy->status.max_sp=1;
- mob_dummy->status.rhw.range=1;
- mob_dummy->status.rhw.atk=7;
- mob_dummy->status.rhw.atk2=10;
- mob_dummy->status.str=1;
- mob_dummy->status.agi=1;
- mob_dummy->status.vit=1;
- mob_dummy->status.int_=1;
- mob_dummy->status.dex=6;
- mob_dummy->status.luk=2;
- mob_dummy->status.speed=300;
- mob_dummy->status.adelay=1000;
- mob_dummy->status.amotion=500;
- mob_dummy->status.dmotion=500;
- mob_dummy->base_exp=2;
- mob_dummy->job_exp=1;
- mob_dummy->range2=10;
- mob_dummy->range3=10;
+ mob->dummy = (struct mob_db*)aCalloc(1, sizeof(struct mob_db)); //Initializing the dummy mob.
+ sprintf(mob->dummy->sprite,"DUMMY");
+ sprintf(mob->dummy->name,"Dummy");
+ sprintf(mob->dummy->jname,"Dummy");
+ mob->dummy->lv=1;
+ mob->dummy->status.max_hp=1000;
+ mob->dummy->status.max_sp=1;
+ mob->dummy->status.rhw.range=1;
+ mob->dummy->status.rhw.atk=7;
+ mob->dummy->status.rhw.atk2=10;
+ mob->dummy->status.str=1;
+ mob->dummy->status.agi=1;
+ mob->dummy->status.vit=1;
+ mob->dummy->status.int_=1;
+ mob->dummy->status.dex=6;
+ mob->dummy->status.luk=2;
+ mob->dummy->status.speed=300;
+ mob->dummy->status.adelay=1000;
+ mob->dummy->status.amotion=500;
+ mob->dummy->status.dmotion=500;
+ mob->dummy->base_exp=2;
+ mob->dummy->job_exp=1;
+ mob->dummy->range2=10;
+ mob->dummy->range3=10;
return 0;
}
//Adjusts the drop rate of item according to the criteria given. [Skotlex]
-static unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned short rate_min, unsigned short rate_max)
+unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned short rate_min, unsigned short rate_max)
{
double rate = baserate;
@@ -3628,7 +3616,7 @@ static unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned shor
* @param mob_id ID of the monster
* @param rate_adjust pointer to store ratio if found
*/
-static void item_dropratio_adjust(int nameid, int mob_id, int *rate_adjust)
+void item_dropratio_adjust(int nameid, int mob_id, int *rate_adjust)
{
if( item_drop_ratio_db[nameid] ) {
if( item_drop_ratio_db[nameid]->mob_id[0] ) { // only for listed mobs
@@ -3655,7 +3643,7 @@ static inline int mob_parse_dbrow_cap_value(int class_, int min, int max, int va
/*==========================================
* processes one mobdb entry
*------------------------------------------*/
-static bool mob_parse_dbrow(char** str)
+bool mob_parse_dbrow(char** str)
{
struct mob_db *db, entry;
struct status_data *status;
@@ -3803,8 +3791,8 @@ static bool mob_parse_dbrow(char** str)
db->mvpitem[i].p = 0; //No item....
continue;
}
- item_dropratio_adjust(db->mvpitem[i].nameid, class_, &rate_adjust);
- db->mvpitem[i].p = mob_drop_adjust(atoi(str[32+i*2]), rate_adjust, battle_config.item_drop_mvp_min, battle_config.item_drop_mvp_max);
+ mob->item_dropratio_adjust(db->mvpitem[i].nameid, class_, &rate_adjust);
+ db->mvpitem[i].p = mob->drop_adjust(atoi(str[32+i*2]), rate_adjust, battle_config.item_drop_mvp_min, battle_config.item_drop_mvp_max);
//calculate and store Max available drop chance of the MVP item
if (db->mvpitem[i].p) {
@@ -3867,8 +3855,8 @@ static bool mob_parse_dbrow(char** str)
ratemax = battle_config.item_drop_common_max;
break;
}
- item_dropratio_adjust(id->nameid, class_, &rate_adjust);
- db->dropitem[i].p = mob_drop_adjust(rate, rate_adjust, ratemin, ratemax);
+ mob->item_dropratio_adjust(id->nameid, class_, &rate_adjust);
+ db->dropitem[i].p = mob->drop_adjust(rate, rate_adjust, ratemin, ratemax);
//calculate and store Max available drop chance of the item
if( db->dropitem[i].p && (class_ < 1324 || class_ > 1363) && (class_ < 1938 || class_ > 1946) )
@@ -3890,25 +3878,25 @@ static bool mob_parse_dbrow(char** str)
}
}
// Finally insert monster's data into the database.
- if (mob_db_data[class_] == NULL)
- mob_db_data[class_] = (struct mob_db*)aMalloc(sizeof(struct mob_db));
+ if (mob->db_data[class_] == NULL)
+ mob->db_data[class_] = (struct mob_db*)aMalloc(sizeof(struct mob_db));
else
//Copy over spawn data
- memcpy(&db->spawn, mob_db_data[class_]->spawn, sizeof(db->spawn));
+ memcpy(&db->spawn, mob->db_data[class_]->spawn, sizeof(db->spawn));
- memcpy(mob_db_data[class_], db, sizeof(struct mob_db));
+ memcpy(mob->db_data[class_], db, sizeof(struct mob_db));
return true;
}
/*==========================================
* mob_db.txt reading
*------------------------------------------*/
-static bool mob_readdb_sub(char* fields[], int columns, int current)
+bool mob_readdb_sub(char* fields[], int columns, int current)
{
- return mob_parse_dbrow(fields);
+ return mob->parse_dbrow(fields);
}
-static void mob_readdb(void)
+void mob_readdb(void)
{
const char* filename[] = {
DBPATH"mob_db.txt",
@@ -3927,14 +3915,14 @@ static void mob_readdb(void)
}
}
- sv->readdb(iMap->db_path, filename[fi], ',', 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, -1, &mob_readdb_sub);
+ sv->readdb(iMap->db_path, filename[fi], ',', 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, 31+2*MAX_MVP_DROP+2*MAX_MOB_DROP, -1, mob->readdb_sub);
}
}
/*==========================================
* mob_db table reading
*------------------------------------------*/
-static int mob_read_sqldb(void)
+int mob_read_sqldb(void)
{
const char* mob_db_name[] = { iMap->mob_db_db, iMap->mob_db2_db };
int fi;
@@ -3968,7 +3956,7 @@ static int mob_read_sqldb(void)
p+= len + 1;
}
- if (!mob_parse_dbrow(str))
+ if (!mob->parse_dbrow(str))
continue;
count++;
@@ -3985,13 +3973,13 @@ static int mob_read_sqldb(void)
/*==========================================
* MOB display graphic change data reading
*------------------------------------------*/
-static bool mob_readdb_mobavail(char* str[], int columns, int current)
+bool mob_readdb_mobavail(char* str[], int columns, int current)
{
int class_, k;
class_=atoi(str[0]);
- if(mob_db(class_) == mob_dummy) // invalid class (probably undefined in db)
+ if(mob->db(class_) == mob->dummy) // invalid class (probably undefined in db)
{
ShowWarning("mob_readdb_mobavail: Unknown mob id %d.\n", class_);
return false;
@@ -3999,24 +3987,24 @@ static bool mob_readdb_mobavail(char* str[], int columns, int current)
k=atoi(str[1]);
- memset(&mob_db_data[class_]->vd, 0, sizeof(struct view_data));
- mob_db_data[class_]->vd.class_=k;
+ memset(&mob->db_data[class_]->vd, 0, sizeof(struct view_data));
+ mob->db_data[class_]->vd.class_=k;
//Player sprites
if(pcdb_checkid(k) && columns==12) {
- mob_db_data[class_]->vd.sex=atoi(str[2]);
- mob_db_data[class_]->vd.hair_style=atoi(str[3]);
- mob_db_data[class_]->vd.hair_color=atoi(str[4]);
- mob_db_data[class_]->vd.weapon=atoi(str[5]);
- mob_db_data[class_]->vd.shield=atoi(str[6]);
- mob_db_data[class_]->vd.head_top=atoi(str[7]);
- mob_db_data[class_]->vd.head_mid=atoi(str[8]);
- mob_db_data[class_]->vd.head_bottom=atoi(str[9]);
- mob_db_data[class_]->option=atoi(str[10])&~(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE);
- mob_db_data[class_]->vd.cloth_color=atoi(str[11]); // Monster player dye option - Valaris
+ mob->db_data[class_]->vd.sex=atoi(str[2]);
+ mob->db_data[class_]->vd.hair_style=atoi(str[3]);
+ mob->db_data[class_]->vd.hair_color=atoi(str[4]);
+ mob->db_data[class_]->vd.weapon=atoi(str[5]);
+ mob->db_data[class_]->vd.shield=atoi(str[6]);
+ mob->db_data[class_]->vd.head_top=atoi(str[7]);
+ mob->db_data[class_]->vd.head_mid=atoi(str[8]);
+ mob->db_data[class_]->vd.head_bottom=atoi(str[9]);
+ mob->db_data[class_]->option=atoi(str[10])&~(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE);
+ mob->db_data[class_]->vd.cloth_color=atoi(str[11]); // Monster player dye option - Valaris
}
else if(columns==3)
- mob_db_data[class_]->vd.head_bottom=atoi(str[2]); // mob equipment [Valaris]
+ mob->db_data[class_]->vd.head_bottom=atoi(str[2]); // mob equipment [Valaris]
else if( columns != 2 )
return false;
@@ -4026,7 +4014,7 @@ static bool mob_readdb_mobavail(char* str[], int columns, int current)
/*==========================================
* Reading of random monster data
*------------------------------------------*/
-static int mob_read_randommonster(void)
+int mob_read_randommonster(void)
{
FILE *fp;
char line[1024];
@@ -4043,7 +4031,7 @@ static int mob_read_randommonster(void)
for( i = 0; i < ARRAYLENGTH(mobfile) && i < MAX_RANDOMMONSTER; i++ ) {
unsigned int count = 0;
- mob_db_data[0]->summonper[i] = 1002; // Default fallback value, in case the database does not provide one
+ mob->db_data[0]->summonper[i] = 1002; // Default fallback value, in case the database does not provide one
sprintf(line, "%s/%s", iMap->db_path, mobfile[i]);
fp=fopen(line,"r");
if(fp==NULL){
@@ -4066,10 +4054,10 @@ static int mob_read_randommonster(void)
continue;
class_ = atoi(str[0]);
- if(mob_db(class_) == mob_dummy)
+ if(mob->db(class_) == mob->dummy)
continue;
count++;
- mob_db_data[class_]->summonper[i]=atoi(str[2]);
+ mob->db_data[class_]->summonper[i]=atoi(str[2]);
if (i) {
if( summon[i].qty < ARRAYLENGTH(summon[i].class_) ) //MvPs
summon[i].class_[summon[i].qty++] = class_;
@@ -4080,7 +4068,7 @@ static int mob_read_randommonster(void)
}
}
if (i && !summon[i].qty) { //At least have the default here.
- summon[i].class_[0] = mob_db_data[0]->summonper[i];
+ summon[i].class_[0] = mob->db_data[0]->summonper[i];
summon[i].qty = 1;
}
fclose(fp);
@@ -4093,7 +4081,7 @@ static int mob_read_randommonster(void)
* processes one mob_chat_db entry [SnakeDrak]
* @param last_msg_id ensures that only one error message per mob id is printed
*------------------------------------------*/
-static bool mob_parse_row_chatdb(char** str, const char* source, int line, int* last_msg_id)
+bool mob_parse_row_chatdb(char** str, const char* source, int line, int* last_msg_id)
{
char* msg;
struct mob_chat *ms;
@@ -4111,10 +4099,10 @@ static bool mob_parse_row_chatdb(char** str, const char* source, int line, int*
return false;
}
- if (mob_chat_db[msg_id] == NULL)
- mob_chat_db[msg_id] = (struct mob_chat*)aCalloc(1, sizeof (struct mob_chat));
+ if (mob->chat_db[msg_id] == NULL)
+ mob->chat_db[msg_id] = (struct mob_chat*)aCalloc(1, sizeof (struct mob_chat));
- ms = mob_chat_db[msg_id];
+ ms = mob->chat_db[msg_id];
//MSG ID
ms->msg_id=msg_id;
//Color
@@ -4151,7 +4139,7 @@ static bool mob_parse_row_chatdb(char** str, const char* source, int line, int*
/*==========================================
* mob_chat_db.txt reading [SnakeDrak]
*-------------------------------------------------------------------------*/
-static void mob_readchatdb(void)
+void mob_readchatdb(void)
{
char arc[]="mob_chat_db.txt";
uint32 lines=0, count=0;
@@ -4195,7 +4183,7 @@ static void mob_readchatdb(void)
continue;
}
- if( !mob_parse_row_chatdb(str, path, lines, &tmp) )
+ if( !mob->parse_row_chatdb(str, path, lines, &tmp) )
continue;
count++;
@@ -4207,7 +4195,7 @@ static void mob_readchatdb(void)
/*==========================================
* processes one mob_skill_db entry
*------------------------------------------*/
-static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
+bool mob_parse_row_mobskilldb(char** str, int columns, int current)
{
static const struct {
char str[32];
@@ -4289,7 +4277,7 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
mob_id = atoi(str[0]);
- if (mob_id > 0 && mob_db(mob_id) == mob_dummy)
+ if (mob_id > 0 && mob->db(mob_id) == mob->dummy)
{
if (mob_id != last_mob_id) {
ShowError("mob_parse_row_mobskilldb: Non existant Mob id %d\n", mob_id);
@@ -4300,8 +4288,8 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
if( strcmp(str[1],"clear")==0 ){
if (mob_id < 0)
return false;
- memset(mob_db_data[mob_id]->skill,0,sizeof(struct mob_skill));
- mob_db_data[mob_id]->maxskill=0;
+ memset(mob->db_data[mob_id]->skill,0,sizeof(struct mob_skill));
+ mob->db_data[mob_id]->maxskill=0;
return true;
}
@@ -4310,11 +4298,11 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
memset(&gms, 0, sizeof (struct mob_skill));
ms = &gms;
} else {
- ARR_FIND( 0, MAX_MOBSKILL, i, (ms = &mob_db_data[mob_id]->skill[i])->skill_id == 0 );
+ ARR_FIND( 0, MAX_MOBSKILL, i, (ms = &mob->db_data[mob_id]->skill[i])->skill_id == 0 );
if( i == MAX_MOBSKILL )
{
if (mob_id != last_mob_id) {
- ShowError("mob_parse_row_mobskilldb: Too many skills for monster %d[%s]\n", mob_id, mob_db_data[mob_id]->sprite);
+ ShowError("mob_parse_row_mobskilldb: Too many skills for monster %d[%s]\n", mob_id, mob->db_data[mob_id]->sprite);
last_mob_id = mob_id;
}
return false;
@@ -4336,7 +4324,7 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
if (mob_id < 0)
ShowError("mob_parse_row_mobskilldb: Invalid Skill ID (%d) for all mobs\n", j);
else
- ShowError("mob_parse_row_mobskilldb: Invalid Skill ID (%d) for mob %d (%s)\n", j, mob_id, mob_db_data[mob_id]->sprite);
+ ShowError("mob_parse_row_mobskilldb: Invalid Skill ID (%d) for mob %d (%s)\n", j, mob_id, mob->db_data[mob_id]->sprite);
return false;
}
ms->skill_id=j;
@@ -4378,13 +4366,13 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
if (ms->target > MST_AROUND) {
ShowWarning("mob_parse_row_mobskilldb: Wrong mob skill target for ground skill %d (%s) for %s.\n",
ms->skill_id, skill_db[sidx].name,
- mob_id < 0?"all mobs":mob_db_data[mob_id]->sprite);
+ mob_id < 0?"all mobs":mob->db_data[mob_id]->sprite);
ms->target = MST_TARGET;
}
} else if (ms->target > MST_MASTER) {
ShowWarning("mob_parse_row_mobskilldb: Wrong mob skill target 'around' for non-ground skill %d (%s) for %s.\n",
ms->skill_id, skill_db[sidx].name,
- mob_id < 0?"all mobs":mob_db_data[mob_id]->sprite);
+ mob_id < 0?"all mobs":mob->db_data[mob_id]->sprite);
ms->target = MST_TARGET;
}
@@ -4412,7 +4400,7 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
ms->val[4]=(int)strtol(str[16],NULL,0);
if(ms->skill_id == NPC_EMOTION && mob_id>0 &&
- ms->val[1] == mob_db(mob_id)->status.mode)
+ ms->val[1] == mob->db(mob_id)->status.mode)
{
ms->val[1] = 0;
ms->val[4] = 1; //request to return mode to normal.
@@ -4431,7 +4419,7 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
else
ms->emotion=-1;
- if(str[18]!=NULL && mob_chat_db[atoi(str[18])]!=NULL)
+ if(str[18]!=NULL && mob->chat_db[atoi(str[18])]!=NULL)
ms->msg_id=atoi(str[18]);
else
ms->msg_id=0;
@@ -4441,9 +4429,9 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
mob_id *= -1;
for (i = 1; i < MAX_MOB_DB; i++)
{
- if (mob_db_data[i] == NULL)
+ if (mob->db_data[i] == NULL)
continue;
- if (mob_db_data[i]->status.mode&MD_BOSS)
+ if (mob->db_data[i]->status.mode&MD_BOSS)
{
if (!(mob_id&2)) //Skill not for bosses
continue;
@@ -4451,15 +4439,15 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
if (!(mob_id&1)) //Skill not for normal enemies.
continue;
- ARR_FIND( 0, MAX_MOBSKILL, j, mob_db_data[i]->skill[j].skill_id == 0 );
+ ARR_FIND( 0, MAX_MOBSKILL, j, mob->db_data[i]->skill[j].skill_id == 0 );
if(j==MAX_MOBSKILL)
continue;
- memcpy (&mob_db_data[i]->skill[j], ms, sizeof(struct mob_skill));
- mob_db_data[i]->maxskill=j+1;
+ memcpy (&mob->db_data[i]->skill[j], ms, sizeof(struct mob_skill));
+ mob->db_data[i]->maxskill=j+1;
}
} else //Skill set on a single mob.
- mob_db_data[mob_id]->maxskill=i+1;
+ mob->db_data[mob_id]->maxskill=i+1;
return true;
}
@@ -4467,7 +4455,7 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
/*==========================================
* mob_skill_db.txt reading
*------------------------------------------*/
-static void mob_readskilldb(void) {
+void mob_readskilldb(void) {
const char* filename[] = {
DBPATH"mob_skill_db.txt",
"mob_skill_db2.txt" };
@@ -4491,7 +4479,7 @@ static void mob_readskilldb(void) {
}
}
- sv->readdb(iMap->db_path, filename[fi], ',', 19, 19, -1, &mob_parse_row_mobskilldb);
+ sv->readdb(iMap->db_path, filename[fi], ',', 19, 19, -1, mob->parse_row_mobskilldb);
}
}
@@ -4500,7 +4488,7 @@ static void mob_readskilldb(void) {
* not overly sure if this is all correct
* seems to work though...
*/
-static int mob_read_sqlskilldb(void)
+int mob_read_sqlskilldb(void)
{
const char* mob_skill_db_name[] = { iMap->mob_skill_db_db, iMap->mob_skill_db2_db };
int fi;
@@ -4533,7 +4521,7 @@ static int mob_read_sqlskilldb(void)
if( str[i] == NULL ) str[i] = dummy; // get rid of NULL columns
}
- if (!mob_parse_row_mobskilldb(str, 19, count))
+ if (!mob->parse_row_mobskilldb(str, 19, count))
continue;
count++;
@@ -4550,7 +4538,7 @@ static int mob_read_sqlskilldb(void)
/*==========================================
* mob_race2_db.txt reading
*------------------------------------------*/
-static bool mob_readdb_race2(char* fields[], int columns, int current)
+bool mob_readdb_race2(char* fields[], int columns, int current)
{
int race, mobid, i;
@@ -4565,12 +4553,12 @@ static bool mob_readdb_race2(char* fields[], int columns, int current)
for(i = 1; i<columns; i++)
{
mobid = atoi(fields[i]);
- if (mob_db(mobid) == mob_dummy)
+ if (mob->db(mobid) == mob->dummy)
{
ShowWarning("mob_readdb_race2: Unknown mob id %d for race2 %d.\n", mobid, race);
continue;
}
- mob_db_data[mobid]->race2 = race;
+ mob->db_data[mobid]->race2 = race;
}
return true;
}
@@ -4578,7 +4566,7 @@ static bool mob_readdb_race2(char* fields[], int columns, int current)
/**
* Read mob_item_ratio.txt
*/
-static bool mob_readdb_itemratio(char* str[], int columns, int current)
+bool mob_readdb_itemratio(char* str[], int columns, int current)
{
int nameid, ratio, i;
nameid = atoi(str[0]);
@@ -4604,26 +4592,25 @@ static bool mob_readdb_itemratio(char* str[], int columns, int current)
/**
* read all mob-related databases
*/
-static void mob_load(void)
-{
- sv->readdb(iMap->db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, &mob_readdb_itemratio); // must be read before mobdb
- mob_readchatdb();
+void mob_load(void) {
+ sv->readdb(iMap->db_path, "mob_item_ratio.txt", ',', 2, 2+MAX_ITEMRATIO_MOBS, -1, mob->readdb_itemratio); // must be read before mobdb
+ mob->readchatdb();
if (iMap->db_use_sql_mob_db)
{
- mob_read_sqldb();
+ mob->read_sqldb();
}
if (iMap->db_use_sql_mob_skill_db)
{
- mob_read_sqlskilldb();
+ mob->read_sqlskilldb();
}
else
{
- mob_readdb();
- mob_readskilldb();
+ mob->readdb();
+ mob->readskilldb();
}
- sv->readdb(iMap->db_path, "mob_avail.txt", ',', 2, 12, -1, &mob_readdb_mobavail);
- mob_read_randommonster();
- sv->readdb(iMap->db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, &mob_readdb_race2);
+ sv->readdb(iMap->db_path, "mob_avail.txt", ',', 2, 12, -1, mob->readdb_mobavail);
+ mob->read_randommonster();
+ sv->readdb(iMap->db_path, DBPATH"mob_race2_db.txt", ',', 2, 20, -1, mob->readdb_race2);
}
void mob_reload(void) {
@@ -4631,9 +4618,9 @@ void mob_reload(void) {
//Mob skills need to be cleared before re-reading them. [Skotlex]
for (i = 0; i < MAX_MOB_DB; i++)
- if (mob_db_data[i] && !mob_is_clone(i)) {
- memset(&mob_db_data[i]->skill,0,sizeof(mob_db_data[i]->skill));
- mob_db_data[i]->maxskill=0;
+ if (mob->db_data[i] && !mob->is_clone(i)) {
+ memset(&mob->db_data[i]->skill,0,sizeof(mob->db_data[i]->skill));
+ mob->db_data[i]->maxskill=0;
}
// Clear item_drop_ratio_db
@@ -4644,15 +4631,15 @@ void mob_reload(void) {
}
}
- mob_load();
+ mob->load();
}
void mob_clear_spawninfo()
{ //Clears spawn related information for a script reload.
int i;
for (i = 0; i < MAX_MOB_DB; i++)
- if (mob_db_data[i])
- memset(&mob_db_data[i]->spawn,0,sizeof(mob_db_data[i]->spawn));
+ if (mob->db_data[i])
+ memset(&mob->db_data[i]->spawn,0,sizeof(mob->db_data[i]->spawn));
}
/*==========================================
@@ -4660,23 +4647,23 @@ void mob_clear_spawninfo()
*------------------------------------------*/
int do_init_mob(void)
{ //Initialize the mob database
- memset(mob_db_data,0,sizeof(mob_db_data)); //Clear the array
- mob_db_data[0] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns
- mob_makedummymobdb(0); //The first time this is invoked, it creates the dummy mob
+ memset(mob->db_data,0,sizeof(mob->db_data)); //Clear the array
+ mob->db_data[0] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns
+ mob->makedummymobdb(0); //The first time this is invoked, it creates the dummy mob
item_drop_ers = ers_new(sizeof(struct item_drop),"mob.c::item_drop_ers",ERS_OPT_NONE);
item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"mob.c::item_drop_list_ers",ERS_OPT_NONE);
- mob_load();
+ mob->load();
- iTimer->add_timer_func_list(mob_delayspawn,"mob_delayspawn");
- iTimer->add_timer_func_list(mob_delay_item_drop,"mob_delay_item_drop");
- iTimer->add_timer_func_list(mob_ai_hard,"mob_ai_hard");
- iTimer->add_timer_func_list(mob_ai_lazy,"mob_ai_lazy");
- iTimer->add_timer_func_list(mob_timer_delete,"mob_timer_delete");
- iTimer->add_timer_func_list(mob_spawn_guardian_sub,"mob_spawn_guardian_sub");
- iTimer->add_timer_func_list(mob_respawn,"mob_respawn");
- iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME,mob_ai_hard,0,0,MIN_MOBTHINKTIME);
- iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME*10,mob_ai_lazy,0,0,MIN_MOBTHINKTIME*10);
+ iTimer->add_timer_func_list(mob->delayspawn,"mob_delayspawn");
+ iTimer->add_timer_func_list(mob->delay_item_drop,"mob_delay_item_drop");
+ iTimer->add_timer_func_list(mob->ai_hard,"mob_ai_hard");
+ iTimer->add_timer_func_list(mob->ai_lazy,"mob_ai_lazy");
+ iTimer->add_timer_func_list(mob->timer_delete,"mob_timer_delete");
+ iTimer->add_timer_func_list(mob->spawn_guardian_sub,"mob_spawn_guardian_sub");
+ iTimer->add_timer_func_list(mob->respawn,"mob_respawn");
+ iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME,mob->ai_hard,0,0,MIN_MOBTHINKTIME);
+ iTimer->add_timer_interval(iTimer->gettick()+MIN_MOBTHINKTIME*10,mob->ai_lazy,0,0,MIN_MOBTHINKTIME*10);
return 0;
}
@@ -4687,25 +4674,25 @@ int do_init_mob(void)
int do_final_mob(void)
{
int i;
- if (mob_dummy)
+ if (mob->dummy)
{
- aFree(mob_dummy);
- mob_dummy = NULL;
+ aFree(mob->dummy);
+ mob->dummy = NULL;
}
for (i = 0; i <= MAX_MOB_DB; i++)
{
- if (mob_db_data[i] != NULL)
+ if (mob->db_data[i] != NULL)
{
- aFree(mob_db_data[i]);
- mob_db_data[i] = NULL;
+ aFree(mob->db_data[i]);
+ mob->db_data[i] = NULL;
}
}
for (i = 0; i <= MAX_MOB_CHAT; i++)
{
- if (mob_chat_db[i] != NULL)
+ if (mob->chat_db[i] != NULL)
{
- aFree(mob_chat_db[i]);
- mob_chat_db[i] = NULL;
+ aFree(mob->chat_db[i]);
+ mob->chat_db[i] = NULL;
}
}
for (i = 0; i < MAX_ITEMDB; i++)
@@ -4720,3 +4707,115 @@ int do_final_mob(void)
ers_destroy(item_drop_list_ers);
return 0;
}
+
+void mob_defaults(void) {
+ //Defines the Manuk/Splendide mob groups for the status reductions [Epoque]
+ const int mob_manuk[8] = { 1986, 1987, 1988, 1989, 1990, 1997, 1998, 1999 };
+ const int mob_splendide[5] = { 1991, 1992, 1993, 1994, 1995 };
+
+ mob = &mob_s;
+
+ memset(mob->db_data, 0, sizeof(mob->db_data));
+ mob->dummy = NULL;
+ memset(mob->chat_db, 0, sizeof(mob->chat_db));
+
+ memcpy(mob->manuk, mob_manuk, sizeof(mob->manuk));
+ memcpy(mob->splendide, mob_splendide, sizeof(mob->splendide));
+ /* */
+ mob->reload = mob_reload;
+ mob->init = do_init_mob;
+ mob->final = do_final_mob;
+ /* */
+ mob->db = mob_db;
+ mob->chat = mob_chat;
+ mob->makedummymobdb = mob_makedummymobdb;
+ mob->spawn_guardian_sub = mob_spawn_guardian_sub;
+ mob->skill_id2skill_idx = mob_skill_id2skill_idx;
+ mob->db_searchname = mobdb_searchname;
+ mob->db_searchname_array_sub = mobdb_searchname_array_sub;
+ mob->mvptomb_create = mvptomb_create;
+ mob->mvptomb_destroy = mvptomb_destroy;
+ mob->db_searchname_array = mobdb_searchname_array;
+ mob->db_checkid = mobdb_checkid;
+ mob->get_viewdata = mob_get_viewdata;
+ mob->parse_dataset = mob_parse_dataset;
+ mob->spawn_dataset = mob_spawn_dataset;
+ mob->get_random_id = mob_get_random_id;
+ mob->ksprotected = mob_ksprotected;
+ mob->once_spawn_sub = mob_once_spawn_sub;
+ mob->once_spawn = mob_once_spawn;
+ mob->once_spawn_area = mob_once_spawn_area;
+ mob->spawn_guardian = mob_spawn_guardian;
+ mob->spawn_bg = mob_spawn_bg;
+ mob->can_reach = mob_can_reach;
+ mob->linksearch = mob_linksearch;
+ mob->delayspawn = mob_delayspawn;
+ mob->setdelayspawn = mob_setdelayspawn;
+ mob->count_sub = mob_count_sub;
+ mob->spawn = mob_spawn;
+ mob->can_changetarget = mob_can_changetarget;
+ mob->target = mob_target;
+ mob->ai_sub_hard_activesearch = mob_ai_sub_hard_activesearch;
+ mob->ai_sub_hard_changechase = mob_ai_sub_hard_changechase;
+ mob->ai_sub_hard_bg_ally = mob_ai_sub_hard_bg_ally;
+ mob->ai_sub_hard_lootsearch = mob_ai_sub_hard_lootsearch;
+ mob->warpchase_sub = mob_warpchase_sub;
+ mob->ai_sub_hard_slavemob = mob_ai_sub_hard_slavemob;
+ mob->unlocktarget = mob_unlocktarget;
+ mob->randomwalk = mob_randomwalk;
+ mob->warpchase = mob_warpchase;
+ mob->ai_sub_hard = mob_ai_sub_hard;
+ mob->ai_sub_hard_timer = mob_ai_sub_hard_timer;
+ mob->ai_sub_foreachclient = mob_ai_sub_foreachclient;
+ mob->ai_sub_lazy = mob_ai_sub_lazy;
+ mob->ai_lazy = mob_ai_lazy;
+ mob->ai_hard = mob_ai_hard;
+ mob->setdropitem = mob_setdropitem;
+ mob->setlootitem = mob_setlootitem;
+ mob->delay_item_drop = mob_delay_item_drop;
+ mob->item_drop = mob_item_drop;
+ mob->timer_delete = mob_timer_delete;
+ mob->deleteslave_sub = mob_deleteslave_sub;
+ mob->deleteslave = mob_deleteslave;
+ mob->respawn = mob_respawn;
+ mob->log_damage = mob_log_damage;
+ mob->damage = mob_damage;
+ mob->dead = mob_dead;
+ mob->revive = mob_revive;
+ mob->guardian_guildchange = mob_guardian_guildchange;
+ mob->random_class = mob_random_class;
+ mob->class_change = mob_class_change;
+ mob->heal = mob_heal;
+ mob->warpslave_sub = mob_warpslave_sub;
+ mob->warpslave = mob_warpslave;
+ mob->countslave_sub = mob_countslave_sub;
+ mob->countslave = mob_countslave;
+ mob->summonslave = mob_summonslave;
+ mob->getfriendhprate_sub = mob_getfriendhprate_sub;
+ mob->getfriendhprate = mob_getfriendhprate;
+ mob->getmasterhpltmaxrate = mob_getmasterhpltmaxrate;
+ mob->getfriendstatus_sub = mob_getfriendstatus_sub;
+ mob->getfriendstatus = mob_getfriendstatus;
+ mob->skill_use = mobskill_use;
+ mob->skill_event = mobskill_event;
+ mob->is_clone = mob_is_clone;
+ mob->clone_spawn = mob_clone_spawn;
+ mob->clone_delete = mob_clone_delete;
+ mob->drop_adjust = mob_drop_adjust;
+ mob->item_dropratio_adjust = item_dropratio_adjust;
+ mob->parse_dbrow = mob_parse_dbrow;
+ mob->readdb_sub = mob_readdb_sub;
+ mob->readdb = mob_readdb;
+ mob->read_sqldb = mob_read_sqldb;
+ mob->readdb_mobavail = mob_readdb_mobavail;
+ mob->read_randommonster = mob_read_randommonster;
+ mob->parse_row_chatdb = mob_parse_row_chatdb;
+ mob->readchatdb = mob_readchatdb;
+ mob->parse_row_mobskilldb = mob_parse_row_mobskilldb;
+ mob->readskilldb = mob_readskilldb;
+ mob->read_sqlskilldb = mob_read_sqlskilldb;
+ mob->readdb_race2 = mob_readdb_race2;
+ mob->readdb_itemratio = mob_readdb_itemratio;
+ mob->load = mob_load;
+ mob->clear_spawninfo = mob_clear_spawninfo;
+}
diff --git a/src/map/mob.h b/src/map/mob.h
index 137e33ee7..4ac8f7bcb 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _MOB_H_
#define _MOB_H_
@@ -38,9 +39,7 @@
//Used to determine default enemy type of mobs (for use in eachinrange calls)
#define DEFAULT_ENEMY_TYPE(md) (md->special_state.ai?BL_CHAR:BL_MOB|BL_PC|BL_HOM|BL_MER)
-//Externals for the status effects. [Epoque]
-extern const int mob_manuk[8];
-extern const int mob_splendide[5];
+#define MAX_MOB_CHAT 250 //Max Skill's messages
//Mob skill states.
enum MobSkillState {
@@ -243,78 +242,124 @@ struct item_drop_list {
struct item_drop* item; // linked list of drops
};
-struct mob_db* mob_db(int class_);
-int mobdb_searchname(const char *str);
-int mobdb_searchname_array(struct mob_db** data, int size, const char *str, int flag);
-int mobdb_checkid(const int id);
-struct view_data* mob_get_viewdata(int class_);
-
-struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m,
- short x, short y, const char *mobname, int class_, const char *event, unsigned int size, unsigned int ai);
-
-int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y,
- const char* mobname, int class_, int amount, const char* event, unsigned int size, unsigned int ai);
-
-int mob_once_spawn_area(struct map_session_data* sd, int16 m,
- int16 x0, int16 y0, int16 x1, int16 y1, const char* mobname, int class_, int amount, const char* event, unsigned int size, unsigned int ai);
-
-bool mob_ksprotected (struct block_list *src, struct block_list *target);
-
-int mob_spawn_guardian(const char* mapname, int16 x, int16 y, const char* mobname, int class_, const char* event, int guardian, bool has_index); // Spawning Guardians [Valaris]
-int mob_spawn_bg(const char* mapname, int16 x, int16 y, const char* mobname, int class_, const char* event, unsigned int bg_id);
-int mob_guardian_guildchange(struct mob_data *md); //Change Guardian's ownership. [Skotlex]
-
-int mob_randomwalk(struct mob_data *md,unsigned int tick);
-int mob_warpchase(struct mob_data *md, struct block_list *target);
-int mob_target(struct mob_data *md,struct block_list *bl,int dist);
-int mob_unlocktarget(struct mob_data *md, unsigned int tick);
-struct mob_data* mob_spawn_dataset(struct spawn_data *data);
-int mob_spawn(struct mob_data *md);
-int mob_delayspawn(int tid, unsigned int tick, int id, intptr_t data);
-int mob_setdelayspawn(struct mob_data *md);
-int mob_parse_dataset(struct spawn_data *data);
-void mob_log_damage(struct mob_data *md, struct block_list *src, int damage);
-void mob_damage(struct mob_data *md, struct block_list *src, int damage);
-int mob_dead(struct mob_data *md, struct block_list *src, int type);
-void mob_revive(struct mob_data *md, unsigned int hp);
-void mob_heal(struct mob_data *md,unsigned int heal);
-
-#define mob_stop_walking(md, type) unit_stop_walking(&(md)->bl, type)
-#define mob_stop_attack(md) unit_stop_attack(&(md)->bl)
+
+#define mob_stop_walking(md, type) unit->stop_walking(&(md)->bl, type)
+#define mob_stop_attack(md) unit->stop_attack(&(md)->bl)
#define mob_is_battleground(md) ( map[(md)->bl.m].flag.battleground && ((md)->class_ == MOBID_BARRICADE2 || ((md)->class_ >= MOBID_FOOD_STOR && (md)->class_ <= MOBID_PINK_CRYST)) )
#define mob_is_gvg(md) (map[(md)->bl.m].flag.gvg_castle && ( (md)->class_ == MOBID_EMPERIUM || (md)->class_ == MOBID_BARRICADE1 || (md)->class_ == MOBID_GUARIDAN_STONE1 || (md)->class_ == MOBID_GUARIDAN_STONE2) )
#define mob_is_treasure(md) (((md)->class_ >= MOBID_TREAS01 && (md)->class_ <= MOBID_TREAS40) || ((md)->class_ >= MOBID_TREAS41 && (md)->class_ <= MOBID_TREAS49))
-void mob_clear_spawninfo();
-int do_init_mob(void);
-int do_final_mob(void);
-
-int mob_timer_delete(int tid, unsigned int tick, int id, intptr_t data);
-int mob_deleteslave(struct mob_data *md);
-
-int mob_random_class (int *value, size_t count);
-int mob_get_random_id(int type, int flag, int lv);
-int mob_class_change(struct mob_data *md,int class_);
-int mob_warpslave(struct block_list *bl, int range);
-int mob_linksearch(struct block_list *bl,va_list ap);
-
-int mobskill_use(struct mob_data *md,unsigned int tick,int event);
-int mobskill_event(struct mob_data *md,struct block_list *src,unsigned int tick, int flag);
-int mobskill_castend_id( int tid, unsigned int tick, int id,int data );
-int mobskill_castend_pos( int tid, unsigned int tick, int id,int data );
-int mob_summonslave(struct mob_data *md2,int *value,int amount,uint16 skill_id);
-int mob_countslave(struct block_list *bl);
-int mob_count_sub(struct block_list *bl, va_list ap);
-
-int mob_is_clone(int class_);
-
-int mob_clone_spawn(struct map_session_data *sd, int16 m, int16 x, int16 y, const char *event, int master_id, int mode, int flag, unsigned int duration);
-int mob_clone_delete(struct mob_data *md);
+struct mob_interface {
+ //Dynamic mob database, allows saving of memory when there's big gaps in the mob_db [Skotlex]
+ struct mob_db *db_data[MAX_MOB_DB+1];
+ struct mob_db *dummy; //Dummy mob to be returned when a non-existant one is requested.
+ //Dynamic mob chat database
+ struct mob_chat *chat_db[MAX_MOB_CHAT+1];
+ //Defines the Manuk/Splendide mob groups for the status reductions [Epoque]
+ int manuk[8];
+ int splendide[5];
+ /* */
+ int (*init) (void);
+ int (*final) (void);
+ void (*reload) (void);
+ /* */
+ struct mob_db* (*db) (int index);
+ struct mob_chat* (*chat) (short id);
+ int (*makedummymobdb) (int);
+ int (*spawn_guardian_sub) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*skill_id2skill_idx) (int class_, uint16 skill_id);
+ int (*db_searchname) (const char *str);
+ int (*db_searchname_array_sub) (struct mob_db *mob, const char *str, int flag);
+ // MvP Tomb System
+ void (*mvptomb_create) (struct mob_data *md, char *killer, time_t time);
+ void (*mvptomb_destroy) (struct mob_data *md);
+ int (*db_searchname_array) (struct mob_db **data, int size, const char *str, int flag);
+ int (*db_checkid) (const int id);
+ struct view_data* (*get_viewdata) (int class_);
+ int (*parse_dataset) (struct spawn_data *data);
+ struct mob_data* (*spawn_dataset) (struct spawn_data *data);
+ int (*get_random_id) (int type, int flag, int lv);
+ bool (*ksprotected) (struct block_list *src, struct block_list *target);
+ struct mob_data* (*once_spawn_sub) (struct block_list *bl, int16 m, int16 x, int16 y, const char *mobname, int class_, const char *event, unsigned int size, unsigned int ai);
+ int (*once_spawn) (struct map_session_data *sd, int16 m, int16 x, int16 y, const char *mobname, int class_, int amount, const char *event, unsigned int size, unsigned int ai);
+ int (*once_spawn_area) (struct map_session_data *sd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, const char *mobname, int class_, int amount, const char *event, unsigned int size, unsigned int ai);
+ int (*spawn_guardian) (const char *mapname, short x, short y, const char *mobname, int class_, const char *event, int guardian, bool has_index);
+ int (*spawn_bg) (const char *mapname, short x, short y, const char *mobname, int class_, const char *event, unsigned int bg_id);
+ int (*can_reach) (struct mob_data *md, struct block_list *bl, int range, int state);
+ int (*linksearch) (struct block_list *bl, va_list ap);
+ int (*delayspawn) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*setdelayspawn) (struct mob_data *md);
+ int (*count_sub) (struct block_list *bl, va_list ap);
+ int (*spawn) (struct mob_data *md);
+ int (*can_changetarget) (struct mob_data *md, struct block_list *target, int mode);
+ int (*target) (struct mob_data *md, struct block_list *bl, int dist);
+ int (*ai_sub_hard_activesearch) (struct block_list *bl, va_list ap);
+ int (*ai_sub_hard_changechase) (struct block_list *bl, va_list ap);
+ int (*ai_sub_hard_bg_ally) (struct block_list *bl, va_list ap);
+ int (*ai_sub_hard_lootsearch) (struct block_list *bl, va_list ap);
+ int (*warpchase_sub) (struct block_list *bl, va_list ap);
+ int (*ai_sub_hard_slavemob) (struct mob_data *md, unsigned int tick);
+ int (*unlocktarget) (struct mob_data *md, unsigned int tick);
+ int (*randomwalk) (struct mob_data *md, unsigned int tick);
+ int (*warpchase) (struct mob_data *md, struct block_list *target);
+ bool (*ai_sub_hard) (struct mob_data *md, unsigned int tick);
+ int (*ai_sub_hard_timer) (struct block_list *bl, va_list ap);
+ int (*ai_sub_foreachclient) (struct map_session_data *sd, va_list ap);
+ int (*ai_sub_lazy) (struct mob_data *md, va_list args);
+ int (*ai_lazy) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*ai_hard) (int tid, unsigned int tick, int id, intptr_t data);
+ struct item_drop* (*setdropitem) (int nameid, int qty, struct item_data *data);
+ struct item_drop* (*setlootitem) (struct item *item);
+ int (*delay_item_drop) (int tid, unsigned int tick, int id, intptr_t data);
+ void (*item_drop) (struct mob_data *md, struct item_drop_list *dlist, struct item_drop *ditem, int loot, int drop_rate, unsigned short flag);
+ int (*timer_delete) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*deleteslave_sub) (struct block_list *bl, va_list ap);
+ int (*deleteslave) (struct mob_data *md);
+ int (*respawn) (int tid, unsigned int tick, int id, intptr_t data);
+ void (*log_damage) (struct mob_data *md, struct block_list *src, int damage);
+ void (*damage) (struct mob_data *md, struct block_list *src, int damage);
+ int (*dead) (struct mob_data *md, struct block_list *src, int type);
+ void (*revive) (struct mob_data *md, unsigned int hp);
+ int (*guardian_guildchange) (struct mob_data *md);
+ int (*random_class) (int *value, size_t count);
+ int (*class_change) (struct mob_data *md, int class_);
+ void (*heal) (struct mob_data *md, unsigned int heal);
+ int (*warpslave_sub) (struct block_list *bl, va_list ap);
+ int (*warpslave) (struct block_list *bl, int range);
+ int (*countslave_sub) (struct block_list *bl, va_list ap);
+ int (*countslave) (struct block_list *bl);
+ int (*summonslave) (struct mob_data *md2, int *value, int amount, uint16 skill_id);
+ int (*getfriendhprate_sub) (struct block_list *bl, va_list ap);
+ struct block_list* (*getfriendhprate) (struct mob_data *md, int min_rate, int max_rate);
+ struct block_list* (*getmasterhpltmaxrate) (struct mob_data *md, int rate);
+ int (*getfriendstatus_sub) (struct block_list *bl, va_list ap);
+ struct mob_data* (*getfriendstatus) (struct mob_data *md, int cond1, int cond2);
+ int (*skill_use) (struct mob_data *md, unsigned int tick, int event);
+ int (*skill_event) (struct mob_data *md, struct block_list *src, unsigned int tick, int flag);
+ int (*is_clone) (int class_);
+ int (*clone_spawn) (struct map_session_data *sd, int16 m, int16 x, int16 y, const char *event, int master_id, int mode, int flag, unsigned int duration);
+ int (*clone_delete) (struct mob_data *md);
+ unsigned int (*drop_adjust) (int baserate, int rate_adjust, unsigned short rate_min, unsigned short rate_max);
+ void (*item_dropratio_adjust) (int nameid, int mob_id, int *rate_adjust);
+ bool (*parse_dbrow) (char **str);
+ bool (*readdb_sub) (char *fields[], int columns, int current);
+ void (*readdb) (void);
+ int (*read_sqldb) (void);
+ bool (*readdb_mobavail) (char *str[], int columns, int current);
+ int (*read_randommonster) (void);
+ bool (*parse_row_chatdb) (char **str, const char *source, int line, int *last_msg_id);
+ void (*readchatdb) (void);
+ bool (*parse_row_mobskilldb) (char **str, int columns, int current);
+ void (*readskilldb) (void);
+ int (*read_sqlskilldb) (void);
+ bool (*readdb_race2) (char *fields[], int columns, int current);
+ bool (*readdb_itemratio) (char *str[], int columns, int current);
+ void (*load) (void);
+ void (*clear_spawninfo) ();
+};
-void mob_reload(void);
+struct mob_interface *mob;
-// MvP Tomb System
-void mvptomb_create(struct mob_data *md, char *killer, time_t time);
-void mvptomb_destroy(struct mob_data *md);
+void mob_defaults(void);
#endif /* _MOB_H_ */
diff --git a/src/map/npc.c b/src/map/npc.c
index 8a2c0f746..51d01d711 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -36,15 +36,7 @@
#include <time.h>
#include <errno.h>
-
-struct npc_data* fake_nd;
-
-// linked list of npc source files
-struct npc_src_list {
- struct npc_src_list* next;
- char name[4]; // dynamic array, the structure is allocated with extra bytes (string length)
-};
-static struct npc_src_list* npc_src_files = NULL;
+struct npc_interface npc_s;
static int npc_id=START_NPC_NUM;
static int npc_warp=0;
@@ -54,46 +46,9 @@ static int npc_mob=0;
static int npc_delay_mob=0;
static int npc_cache_mob=0;
-/// Returns a new npc id that isn't being used in id_db.
-/// Fatal error if nothing is available.
-int npc_get_new_npc_id(void) {
- if( npc_id >= START_NPC_NUM && !iMap->blid_exists(npc_id) )
- return npc_id++;// available
- else {// find next id
- int base_id = npc_id;
- while( base_id != ++npc_id ) {
- if( npc_id < START_NPC_NUM )
- npc_id = START_NPC_NUM;
- if( !iMap->blid_exists(npc_id) )
- return npc_id++;// available
- }
- // full loop, nothing available
- ShowFatalError("npc_get_new_npc_id: All ids are taken. Exiting...");
- exit(1);
- }
-}
-
-static DBMap* ev_db; // const char* event_name -> struct event_data*
-static DBMap* ev_label_db; // const char* label_name (without leading "::") -> struct linkdb_node** (key: struct npc_data*; data: struct event_data*)
-static DBMap* npcname_db; // const char* npc_name -> struct npc_data*
-
-struct event_data {
- struct npc_data *nd;
- int pos;
-};
-
-static struct eri *timer_event_ers; //For the npc timer data. [Skotlex]
-
-/* hello */
static char *npc_last_path;
static char *npc_last_ref;
-
-struct npc_path_data {
- char* path;
- unsigned short references;
-};
struct npc_path_data *npc_last_npd;
-static DBMap *npc_path_db;
//For holding the view data of npc classes. [Skotlex]
static struct view_data npc_viewdb[MAX_NPC_CLASS];
@@ -120,7 +75,26 @@ struct view_data* npc_get_viewdata(int class_)
return NULL;
}
-static int npc_isnear_sub(struct block_list* bl, va_list args) {
+/// Returns a new npc id that isn't being used in id_db.
+/// Fatal error if nothing is available.
+int npc_get_new_npc_id(void) {
+ if( npc_id >= START_NPC_NUM && !iMap->blid_exists(npc_id) )
+ return npc_id++;// available
+ else {// find next id
+ int base_id = npc_id;
+ while( base_id != ++npc_id ) {
+ if( npc_id < START_NPC_NUM )
+ npc_id = START_NPC_NUM;
+ if( !iMap->blid_exists(npc_id) )
+ return npc_id++;// available
+ }
+ // full loop, nothing available
+ ShowFatalError("npc_get_new_npc_id: All ids are taken. Exiting...");
+ exit(1);
+ }
+}
+
+int npc_isnear_sub(struct block_list* bl, va_list args) {
struct npc_data *nd = (struct npc_data*)bl;
if( nd->option & (OPTION_HIDE|OPTION_INVISIBLE) )
@@ -132,7 +106,7 @@ static int npc_isnear_sub(struct block_list* bl, va_list args) {
bool npc_isnear(struct block_list * bl) {
if( battle_config.min_npc_vendchat_distance > 0 &&
- iMap->foreachinrange(npc_isnear_sub,bl, battle_config.min_npc_vendchat_distance, BL_NPC) )
+ iMap->foreachinrange(npc->isnear_sub,bl, battle_config.min_npc_vendchat_distance, BL_NPC) )
return true;
return false;
@@ -149,7 +123,7 @@ int npc_ontouch_event(struct map_session_data *sd, struct npc_data *nd)
return 1; // Can't trigger 'OnTouch_'. try 'OnTouch' later.
snprintf(name, ARRAYLENGTH(name), "%s::%s", nd->exname, script->config.ontouch_name);
- return npc_event(sd,name,1);
+ return npc->event(sd,name,1);
}
int npc_ontouch2_event(struct map_session_data *sd, struct npc_data *nd)
@@ -160,7 +134,7 @@ int npc_ontouch2_event(struct map_session_data *sd, struct npc_data *nd)
return 0;
snprintf(name, ARRAYLENGTH(name), "%s::%s", nd->exname, script->config.ontouch2_name);
- return npc_event(sd,name,2);
+ return npc->event(sd,name,2);
}
/*==========================================
@@ -179,13 +153,13 @@ int npc_enable_sub(struct block_list *bl, va_list ap)
if (nd->option&OPTION_INVISIBLE)
return 1;
- if( npc_ontouch_event(sd,nd) > 0 && npc_ontouch2_event(sd,nd) > 0 )
+ if( npc->ontouch_event(sd,nd) > 0 && npc->ontouch2_event(sd,nd) > 0 )
{ // failed to run OnTouch event, so just click the npc
if (sd->npc_id != 0)
return 0;
pc_stop_walking(sd,1);
- npc_click(sd,nd);
+ npc->click(sd,nd);
}
}
return 0;
@@ -196,7 +170,7 @@ int npc_enable_sub(struct block_list *bl, va_list ap)
*------------------------------------------*/
int npc_enable(const char* name, int flag)
{
- struct npc_data* nd = npc_name2id(name);
+ struct npc_data* nd = npc->name2id(name);
if ( nd == NULL ) {
ShowError("npc_enable: Attempted to %s a non-existing NPC '%s' (flag=%d).\n", (flag&3) ? "show" : "hide", name, flag);
@@ -224,7 +198,7 @@ int npc_enable(const char* name, int flag)
clif->changeoption(&nd->bl);
if( flag&3 && (nd->u.scr.xs >= 0 || nd->u.scr.ys >= 0) ) //check if player standing on a OnTouchArea
- iMap->foreachinarea( npc_enable_sub, nd->bl.m, nd->bl.x-nd->u.scr.xs, nd->bl.y-nd->u.scr.ys, nd->bl.x+nd->u.scr.xs, nd->bl.y+nd->u.scr.ys, BL_PC, nd );
+ iMap->foreachinarea( npc->enable_sub, nd->bl.m, nd->bl.x-nd->u.scr.xs, nd->bl.y-nd->u.scr.ys, nd->bl.x+nd->u.scr.xs, nd->bl.y+nd->u.scr.ys, BL_PC, nd );
return 0;
}
@@ -234,7 +208,7 @@ int npc_enable(const char* name, int flag)
*------------------------------------------*/
struct npc_data* npc_name2id(const char* name)
{
- return (struct npc_data *) strdb_get(npcname_db, name);
+ return (struct npc_data *) strdb_get(npc->name_db, name);
}
/**
* For the Secure NPC Timeout option (check config/Secure.h) [RR]
@@ -277,7 +251,7 @@ int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t dat
clif->scriptclear(sd,sd->npc_id);
sd->npc_idle_timer = INVALID_TIMER;
} else //Create a new instance of ourselves to continue
- sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0);
+ sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc->secure_timeout_timer,sd->bl.id,0);
return 0;
}
#endif
@@ -317,7 +291,7 @@ int npc_event_dequeue(struct map_session_data* sd)
/**
* @see DBCreateData
*/
-static DBData npc_event_export_create(DBKey key, va_list args)
+DBData npc_event_export_create(DBKey key, va_list args)
{
struct linkdb_node** head_ptr;
CREATE(head_ptr, struct linkdb_node*, 1);
@@ -329,7 +303,7 @@ static DBData npc_event_export_create(DBKey key, va_list args)
* exports a npc event label
* called from npc_parse_script
*------------------------------------------*/
-static int npc_event_export(struct npc_data *nd, int i)
+int npc_event_export(struct npc_data *nd, int i)
{
char* lname = nd->u.scr.label_list[i].name;
int pos = nd->u.scr.label_list[i].pos;
@@ -338,14 +312,14 @@ static int npc_event_export(struct npc_data *nd, int i)
struct linkdb_node **label_linkdb = NULL;
char buf[EVENT_NAME_LENGTH];
snprintf(buf, ARRAYLENGTH(buf), "%s::%s", nd->exname, lname);
- if (strdb_exists(ev_db, buf)) // There was already another event of the same name?
+ if (strdb_exists(npc->ev_db, buf)) // There was already another event of the same name?
return 1;
// generate the data and insert it
CREATE(ev, struct event_data, 1);
ev->nd = nd;
ev->pos = pos;
- strdb_put(ev_db, buf, ev);
- label_linkdb = strdb_ensure(ev_label_db, lname, npc_event_export_create);
+ strdb_put(npc->ev_db, buf, ev);
+ label_linkdb = strdb_ensure(npc->ev_label_db, lname, npc->event_export_create);
linkdb_insert(label_linkdb, nd, ev);
}
return 0;
@@ -373,7 +347,7 @@ void npc_event_doall_sub(void *key, void *data, va_list ap)
if(rid) { // a player may only have 1 script running at the same time
char buf[EVENT_NAME_LENGTH];
snprintf(buf, ARRAYLENGTH(buf), "%s::%s", ev->nd->exname, name);
- npc_event_sub(iMap->id2sd(rid), ev, buf);
+ npc->event_sub(iMap->id2sd(rid), ev, buf);
}
else {
script->run(ev->nd->u.scr.script, ev->pos, rid, ev->nd->bl.id);
@@ -386,10 +360,10 @@ void npc_event_doall_sub(void *key, void *data, va_list ap)
int npc_event_do(const char* name)
{
if( name[0] == ':' && name[1] == ':' ) {
- return npc_event_doall(name+2); // skip leading "::"
+ return npc->event_doall(name+2); // skip leading "::"
}
else {
- struct event_data *ev = strdb_get(ev_db, name);
+ struct event_data *ev = strdb_get(npc->ev_db, name);
if (ev) {
script->run(ev->nd->u.scr.script, ev->pos, 0, ev->nd->bl.id);
return 1;
@@ -402,19 +376,19 @@ int npc_event_do(const char* name)
int npc_event_doall_id(const char* name, int rid)
{
int c = 0;
- struct linkdb_node **label_linkdb = strdb_get(ev_label_db, name);
+ struct linkdb_node **label_linkdb = strdb_get(npc->ev_label_db, name);
if (label_linkdb == NULL)
return 0;
- linkdb_foreach(label_linkdb, npc_event_doall_sub, &c, name, rid);
+ linkdb_foreach(label_linkdb, npc->event_doall_sub, &c, name, rid);
return c;
}
// runs the specified event (global only)
int npc_event_doall(const char* name)
{
- return npc_event_doall_id(name, 0);
+ return npc->event_doall_id(name, 0);
}
/*==========================================
@@ -447,23 +421,23 @@ int npc_event_do_clock(int tid, unsigned int tick, int id, intptr_t data)
}
sprintf(buf,"OnMinute%02d",t->tm_min);
- c += npc_event_doall(buf);
+ c += npc->event_doall(buf);
sprintf(buf,"OnClock%02d%02d",t->tm_hour,t->tm_min);
- c += npc_event_doall(buf);
+ c += npc->event_doall(buf);
sprintf(buf,"On%s%02d%02d",day,t->tm_hour,t->tm_min);
- c += npc_event_doall(buf);
+ c += npc->event_doall(buf);
}
if (t->tm_hour != ev_tm_b.tm_hour) {
sprintf(buf,"OnHour%02d",t->tm_hour);
- c += npc_event_doall(buf);
+ c += npc->event_doall(buf);
}
if (t->tm_mday != ev_tm_b.tm_mday) {
sprintf(buf,"OnDay%02d%02d",t->tm_mon+1,t->tm_mday);
- c += npc_event_doall(buf);
+ c += npc->event_doall(buf);
}
memcpy(&ev_tm_b,t,sizeof(ev_tm_b));
@@ -475,9 +449,9 @@ int npc_event_do_clock(int tid, unsigned int tick, int id, intptr_t data)
*------------------------------------------*/
void npc_event_do_oninit(void)
{
- ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs."CL_CLL"\n", npc_event_doall("OnInit"));
+ ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs."CL_CLL"\n", npc->event_doall("OnInit"));
- iTimer->add_timer_interval(iTimer->gettick()+100,npc_event_do_clock,0,0,1000);
+ iTimer->add_timer_interval(iTimer->gettick()+100,npc->event_do_clock,0,0,1000);
}
/*==========================================
@@ -538,7 +512,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data)
if( ted->rid && !(sd = iMap->id2sd(ted->rid)) )
{
ShowError("npc_timerevent: Attached player not found.\n");
- ers_free(timer_event_ers, ted);
+ ers_free(npc->timer_event_ers, ted);
return 0;
}
@@ -563,9 +537,9 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data)
next = nd->u.scr.timer_event[ ted->next ].timer - nd->u.scr.timer_event[ ted->next - 1 ].timer;
ted->time += next;
if( sd )
- sd->npc_timer_id = iTimer->add_timer(tick+next,npc_timerevent,id,(intptr_t)ted);
+ sd->npc_timer_id = iTimer->add_timer(tick+next,npc->timerevent,id,(intptr_t)ted);
else
- nd->u.scr.timerid = iTimer->add_timer(tick+next,npc_timerevent,id,(intptr_t)ted);
+ nd->u.scr.timerid = iTimer->add_timer(tick+next,npc->timerevent,id,(intptr_t)ted);
}
else
{
@@ -574,7 +548,7 @@ int npc_timerevent(int tid, unsigned int tick, int id, intptr_t data)
else
nd->u.scr.timerid = INVALID_TIMER;
- ers_free(timer_event_ers, ted);
+ ers_free(npc->timer_event_ers, ted);
}
// Run the script
@@ -619,20 +593,20 @@ int npc_timerevent_start(struct npc_data* nd, int rid)
int next;
struct timer_event_data *ted;
// Arrange for the next event
- ted = ers_alloc(timer_event_ers, struct timer_event_data);
+ ted = ers_alloc(npc->timer_event_ers, struct timer_event_data);
ted->next = j; // Set event index
ted->time = nd->u.scr.timer_event[j].timer;
next = nd->u.scr.timer_event[j].timer - nd->u.scr.timer;
if( sd )
{
ted->rid = sd->bl.id; // Attach only the player if attachplayerrid was used.
- sd->npc_timer_id = iTimer->add_timer(tick+next,npc_timerevent,nd->bl.id,(intptr_t)ted);
+ sd->npc_timer_id = iTimer->add_timer(tick+next,npc->timerevent,nd->bl.id,(intptr_t)ted);
}
else
{
ted->rid = 0;
nd->u.scr.timertick = tick; // Set when timer is started
- nd->u.scr.timerid = iTimer->add_timer(tick+next,npc_timerevent,nd->bl.id,(intptr_t)ted);
+ nd->u.scr.timerid = iTimer->add_timer(tick+next,npc->timerevent,nd->bl.id,(intptr_t)ted);
}
} else if (!sd) {
@@ -667,8 +641,8 @@ int npc_timerevent_stop(struct npc_data* nd)
{
td = iTimer->get_timer(*tid);
if( td && td->data )
- ers_free(timer_event_ers, (void*)td->data);
- iTimer->delete_timer(*tid,npc_timerevent);
+ ers_free(npc->timer_event_ers, (void*)td->data);
+ iTimer->delete_timer(*tid,npc->timerevent);
*tid = INVALID_TIMER;
}
@@ -701,7 +675,7 @@ void npc_timerevent_quit(struct map_session_data* sd)
// Delete timer
nd = (struct npc_data *)iMap->id2bl(td->id);
ted = (struct timer_event_data*)td->data;
- iTimer->delete_timer(sd->npc_timer_id, npc_timerevent);
+ iTimer->delete_timer(sd->npc_timer_id, npc->timerevent);
sd->npc_timer_id = INVALID_TIMER;
// Execute OnTimerQuit
@@ -711,7 +685,7 @@ void npc_timerevent_quit(struct map_session_data* sd)
struct event_data *ev;
snprintf(buf, ARRAYLENGTH(buf), "%s::OnTimerQuit", nd->exname);
- ev = (struct event_data*)strdb_get(ev_db, buf);
+ ev = (struct event_data*)strdb_get(npc->ev_db, buf);
if( ev && ev->nd != nd )
{
ShowWarning("npc_timerevent_quit: Unable to execute \"OnTimerQuit\", two NPCs have the same event name [%s]!\n",buf);
@@ -740,7 +714,7 @@ void npc_timerevent_quit(struct map_session_data* sd)
nd->u.scr.timertick = old_tick;
}
}
- ers_free(timer_event_ers, ted);
+ ers_free(npc->timer_event_ers, ted);
}
/*==========================================
@@ -780,9 +754,9 @@ int npc_settimerevent_tick(struct npc_data* nd, int newtimer)
// Check if timer is started
flag = (nd->u.scr.timerid != INVALID_TIMER || nd->u.scr.timertick);
- if( flag ) npc_timerevent_stop(nd);
+ if( flag ) npc->timerevent_stop(nd);
nd->u.scr.timer = newtimer;
- if( flag ) npc_timerevent_start(nd, -1);
+ if( flag ) npc->timerevent_start(nd, -1);
nd->u.scr.rid = old_rid;
return 0;
@@ -807,7 +781,7 @@ int npc_event_sub(struct map_session_data* sd, struct event_data* ev, const char
if( ev->nd->option&OPTION_INVISIBLE )
{
//Disabled npc, shouldn't trigger event.
- npc_event_dequeue(sd);
+ npc->event_dequeue(sd);
return 2;
}
script->run(ev->nd->u.scr.script,ev->pos,sd->bl.id,ev->nd->bl.id);
@@ -819,7 +793,7 @@ int npc_event_sub(struct map_session_data* sd, struct event_data* ev, const char
*------------------------------------------*/
int npc_event(struct map_session_data* sd, const char* eventname, int ontouch)
{
- struct event_data* ev = (struct event_data*)strdb_get(ev_db, eventname);
+ struct event_data* ev = (struct event_data*)strdb_get(npc->ev_db, eventname);
struct npc_data *nd;
nullpo_ret(sd);
@@ -840,7 +814,7 @@ int npc_event(struct map_session_data* sd, const char* eventname, int ontouch)
break;
}
- return npc_event_sub(sd,ev,eventname);
+ return npc->event_sub(sd,ev,eventname);
}
/*==========================================
@@ -865,7 +839,7 @@ int npc_touch_areanpc_sub(struct block_list *bl, va_list ap)
if( pc_id == sd->bl.id )
return 0;
- npc_event(sd,name,1);
+ npc->event(sd,name,1);
return 1;
}
@@ -894,7 +868,7 @@ int npc_touchnext_areanpc(struct map_session_data* sd, bool leavemap)
nd->touching_id = sd->touching_id = 0;
snprintf(name, ARRAYLENGTH(name), "%s::%s", nd->exname, script->config.ontouch_name);
- iMap->forcountinarea(npc_touch_areanpc_sub,nd->bl.m,nd->bl.x - xs,nd->bl.y - ys,nd->bl.x + xs,nd->bl.y + ys,1,BL_PC,sd->bl.id,name);
+ iMap->forcountinarea(npc->touch_areanpc_sub,nd->bl.m,nd->bl.x - xs,nd->bl.y - ys,nd->bl.x + xs,nd->bl.y + ys,1,BL_PC,sd->bl.id,name);
}
return 0;
}
@@ -969,16 +943,16 @@ int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y)
break;
}
- if( npc_ontouch_event(sd,map[m].npc[i]) > 0 && npc_ontouch2_event(sd,map[m].npc[i]) > 0 )
+ if( npc->ontouch_event(sd,map[m].npc[i]) > 0 && npc->ontouch2_event(sd,map[m].npc[i]) > 0 )
{ // failed to run OnTouch event, so just click the npc
- struct unit_data *ud = unit_bl2ud(&sd->bl);
+ struct unit_data *ud = unit->bl2ud(&sd->bl);
if( ud && ud->walkpath.path_pos < ud->walkpath.path_len )
{ // Since walktimer always == INVALID_TIMER at this time, we stop walking manually. [Inkfish]
clif->fixpos(&sd->bl);
ud->walkpath.path_pos = ud->walkpath.path_len;
}
sd->areanpc_id = map[m].npc[i]->bl.id;
- npc_click(sd,map[m].npc[i]);
+ npc->click(sd,map[m].npc[i]);
}
break;
}
@@ -1021,14 +995,14 @@ int npc_touch_areanpc2(struct mob_data *md)
xs = iMap->mapindex2mapid(map[m].npc[i]->u.warp.mapindex);
if( m < 0 )
break; // Cannot Warp between map servers
- if( unit_warp(&md->bl, xs, map[m].npc[i]->u.warp.x, map[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 )
+ if( unit->warp(&md->bl, xs, map[m].npc[i]->u.warp.x, map[m].npc[i]->u.warp.y, CLR_OUTSIGHT) == 0 )
return 1; // Warped
break;
case SCRIPT:
if( map[m].npc[i]->bl.id == md->areanpc_id )
break; // Already touch this NPC
snprintf(eventname, ARRAYLENGTH(eventname), "%s::OnTouchNPC", map[m].npc[i]->exname);
- if( (ev = (struct event_data*)strdb_get(ev_db, eventname)) == NULL || ev->nd == NULL )
+ if( (ev = (struct event_data*)strdb_get(npc->ev_db, eventname)) == NULL || ev->nd == NULL )
break; // No OnTouchNPC Event
md->areanpc_id = map[m].npc[i]->bl.id;
id = md->bl.id; // Stores Unique ID
@@ -1134,7 +1108,7 @@ struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* b
*------------------------------------------*/
int npc_globalmessage(const char* name, const char* mes)
{
- struct npc_data* nd = npc_name2id(name);
+ struct npc_data* nd = npc->name2id(name);
char temp[100];
if (!nd)
@@ -1185,7 +1159,7 @@ int npc_click(struct map_session_data* sd, struct npc_data* nd)
}
if(!nd) return 1;
- if ((nd = npc_checknear(sd,&nd->bl)) == NULL)
+ if ((nd = npc->checknear(sd,&nd->bl)) == NULL)
return 1;
//Hidden/Disabled npc.
if (nd->class_ < 0 || nd->option&(OPTION_INVISIBLE|OPTION_HIDE))
@@ -1202,7 +1176,7 @@ int npc_click(struct map_session_data* sd, struct npc_data* nd)
script->run(nd->u.scr.script,0,sd->bl.id,nd->bl.id);
break;
case TOMB:
- run_tomb(sd,nd);
+ npc->run_tomb(sd,nd);
break;
}
@@ -1225,9 +1199,9 @@ int npc_scriptcont(struct map_session_data* sd, int id, bool closing)
return 1;
}
- if(id != fake_nd->bl.id) { // Not item script
- if ((npc_checknear(sd,iMap->id2bl(id))) == NULL){
- ShowWarning("npc_scriptcont: failed npc_checknear test.\n");
+ if(id != npc->fake_nd->bl.id) { // Not item script
+ if ((npc->checknear(sd,iMap->id2bl(id))) == NULL){
+ ShowWarning("npc_scriptcont: failed npc->checknear test.\n");
return 1;
}
}
@@ -1264,7 +1238,7 @@ int npc_buysellsel(struct map_session_data* sd, int id, int type)
nullpo_retr(1, sd);
- if ((nd = npc_checknear(sd,iMap->id2bl(id))) == NULL)
+ if ((nd = npc->checknear(sd,iMap->id2bl(id))) == NULL)
return 1;
if (nd->subtype!=SHOP) {
@@ -1322,7 +1296,7 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
if( j == nd->u.shop.count || nd->u.shop.shop_item[j].value <= 0 )
return 5;
- if( !itemdb_isstackable(nameid) && amount > 1 )
+ if( !itemdb->isstackable(nameid) && amount > 1 )
{
ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n", sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid);
amount = item_list[i*2+0] = 1;
@@ -1362,7 +1336,7 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
memset(&item_tmp,0,sizeof(item_tmp));
- if( !pet_create_egg(sd,nameid) )
+ if( !pet->create_egg(sd,nameid) )
{
item_tmp.nameid = nameid;
item_tmp.identify = 1;
@@ -1374,7 +1348,7 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
}
//npc_buylist for script-controlled shops.
-static int npc_buylist_sub(struct map_session_data* sd, int n, unsigned short* item_list, struct npc_data* nd)
+int npc_buylist_sub(struct map_session_data* sd, int n, unsigned short* item_list, struct npc_data* nd)
{
char npc_ev[EVENT_NAME_LENGTH];
int i;
@@ -1393,7 +1367,7 @@ static int npc_buylist_sub(struct map_session_data* sd, int n, unsigned short* i
// invoke event
snprintf(npc_ev, ARRAYLENGTH(npc_ev), "%s::OnBuyItem", nd->exname);
- npc_event(sd, npc_ev, 0);
+ npc->event(sd, npc_ev, 0);
return 0;
}
@@ -1428,7 +1402,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po
if( nd->u.shop.shop_item[i].value <= 0 )
return 5;
- if(!itemdb_isstackable(nameid) && amount > 1)
+ if(!itemdb->isstackable(nameid) && amount > 1)
{
ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n",
sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid);
@@ -1466,7 +1440,7 @@ int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int po
pc->paycash(sd, price, points);
- if( !pet_create_egg(sd, nameid) )
+ if( !pet->create_egg(sd, nameid) )
{
struct item item_tmp;
memset(&item_tmp, 0, sizeof(struct item));
@@ -1492,7 +1466,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
nullpo_retr(3, sd);
nullpo_retr(3, item_list);
- nd = npc_checknear(sd,iMap->id2bl(sd->npc_shopid));
+ nd = npc->checknear(sd,iMap->id2bl(sd->npc_shopid));
if( nd == NULL )
return 3;
if( nd->subtype != SHOP )
@@ -1521,7 +1495,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
if( !itemdb->exists(nameid) )
return 3; // item no longer in itemdb
- if( !itemdb_isstackable(nameid) && amount > 1 ) {
+ if( !itemdb->isstackable(nameid) && amount > 1 ) {
//Exploit? You can't buy more than 1 of equipment types o.O
ShowWarning("Player %s (%d:%d) sent a hexed packet trying to buy %d of nonstackable item %d!\n",
sd->status.name, sd->status.account_id, sd->status.char_id, amount, nameid);
@@ -1552,7 +1526,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
}
if( nd->master_nd != NULL ) //Script-based shops.
- return npc_buylist_sub(sd,n,item_list,nd->master_nd);
+ return npc->buylist_sub(sd,n,item_list,nd->master_nd);
if( z > (double)sd->status.zeny )
return 1; // Not enough Zeny
@@ -1569,7 +1543,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
struct item item_tmp;
if (itemdb_type(nameid) == IT_PETEGG)
- pet_create_egg(sd, nameid);
+ pet->create_egg(sd, nameid);
else {
memset(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid = nameid;
@@ -1597,7 +1571,7 @@ int npc_buylist(struct map_session_data* sd, int n, unsigned short* item_list)
/// npc_selllist for script-controlled shops
-static int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short* item_list, struct npc_data* nd)
+int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short* item_list, struct npc_data* nd)
{
char npc_ev[EVENT_NAME_LENGTH];
char card_slot[NAME_LENGTH];
@@ -1631,7 +1605,7 @@ static int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short*
script->setarray_pc(sd, "@sold_nameid", i, (void*)(intptr_t)sd->status.inventory[idx].nameid, &key_nameid);
script->setarray_pc(sd, "@sold_quantity", i, (void*)(intptr_t)item_list[i*2+1], &key_amount);
- if( itemdb_isequip(sd->status.inventory[idx].nameid) )
+ if( itemdb->isequip(sd->status.inventory[idx].nameid) )
{// process equipment based information into the arrays
script->setarray_pc(sd, "@sold_refine", i, (void*)(intptr_t)sd->status.inventory[idx].refine, &key_refine);
script->setarray_pc(sd, "@sold_attribute", i, (void*)(intptr_t)sd->status.inventory[idx].attribute, &key_attribute);
@@ -1647,7 +1621,7 @@ static int npc_selllist_sub(struct map_session_data* sd, int n, unsigned short*
// invoke event
snprintf(npc_ev, ARRAYLENGTH(npc_ev), "%s::OnSellItem", nd->exname);
- npc_event(sd, npc_ev, 0);
+ npc->event(sd, npc_ev, 0);
return 0;
}
@@ -1665,7 +1639,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list)
nullpo_retr(1, sd);
nullpo_retr(1, item_list);
- if( ( nd = npc_checknear(sd, iMap->id2bl(sd->npc_shopid)) ) == NULL || nd->subtype != SHOP ) {
+ if( ( nd = npc->checknear(sd, iMap->id2bl(sd->npc_shopid)) ) == NULL || nd->subtype != SHOP ) {
return 1;
}
@@ -1698,7 +1672,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list)
}
if( nd->master_nd ) { // Script-controlled shops
- return npc_selllist_sub(sd, n, item_list, nd->master_nd);
+ return npc->selllist_sub(sd, n, item_list, nd->master_nd);
}
// delete items
@@ -1709,7 +1683,7 @@ int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list)
amount = item_list[i*2+1];
if( sd->inventory_data[idx]->type == IT_PETEGG && sd->status.inventory[idx].card[0] == CARD0_PET ) {
- if( search_petDB_index(sd->status.inventory[idx].nameid, PET_EGG) >= 0 ) {
+ if( pet->search_petDB_index(sd->status.inventory[idx].nameid, PET_EGG) >= 0 ) {
intif->delete_petdata(MakeDWord(sd->status.inventory[idx].card[1], sd->status.inventory[idx].card[2]));
}
}
@@ -1748,7 +1722,7 @@ int npc_remove_map(struct npc_data* nd) {
return 1; //Not assigned to a map.
m = nd->bl.m;
clif->clearunit_area(&nd->bl,CLR_RESPAWN);
- npc_unsetcells(nd);
+ npc->unsetcells(nd);
iMap->delblock(&nd->bl);
//Remove npc from map[].npc list. [Skotlex]
ARR_FIND( 0, map[m].npc_num, i, map[m].npc[i] == nd );
@@ -1763,13 +1737,13 @@ int npc_remove_map(struct npc_data* nd) {
/**
* @see DBApply
*/
-static int npc_unload_ev(DBKey key, DBData *data, va_list ap)
+int npc_unload_ev(DBKey key, DBData *data, va_list ap)
{
struct event_data* ev = DB->data2ptr(data);
char* npcname = va_arg(ap, char *);
if(strcmp(ev->nd->exname,npcname)==0){
- db_remove(ev_db, key);
+ db_remove(npc->ev_db, key);
return 1;
}
return 0;
@@ -1778,7 +1752,7 @@ static int npc_unload_ev(DBKey key, DBData *data, va_list ap)
/**
* @see DBApply
*/
-static int npc_unload_ev_label(DBKey key, DBData *data, va_list ap)
+int npc_unload_ev_label(DBKey key, DBData *data, va_list ap)
{
struct linkdb_node **label_linkdb = DB->data2ptr(data);
struct npc_data* nd = va_arg(ap, struct npc_data *);
@@ -1790,20 +1764,20 @@ static int npc_unload_ev_label(DBKey key, DBData *data, va_list ap)
//Chk if npc matches src_id, then unload.
//Sub-function used to find duplicates.
-static int npc_unload_dup_sub(struct npc_data* nd, va_list args)
+int npc_unload_dup_sub(struct npc_data* nd, va_list args)
{
int src_id;
src_id = va_arg(args, int);
if (nd->src_id == src_id)
- npc_unload(nd, true);
+ npc->unload(nd, true);
return 0;
}
//Removes all npcs that are duplicates of the passed one. [Skotlex]
void npc_unload_duplicates(struct npc_data* nd)
{
- iMap->map_foreachnpc(npc_unload_dup_sub,nd->bl.id);
+ iMap->map_foreachnpc(npc->unload_dup_sub,nd->bl.id);
}
//Removes an npc from map and db.
@@ -1811,26 +1785,26 @@ void npc_unload_duplicates(struct npc_data* nd)
int npc_unload(struct npc_data* nd, bool single) {
nullpo_ret(nd);
- npc_remove_map(nd);
+ npc->remove_map(nd);
iMap->deliddb(&nd->bl);
if( single )
- strdb_remove(npcname_db, nd->exname);
+ strdb_remove(npc->name_db, nd->exname);
if (nd->chat_id) // remove npc chatroom object and kick users
chat->deletenpcchat(nd);
#ifdef PCRE_SUPPORT
- npc_chat_finalize(nd); // deallocate npc PCRE data structures
+ npc_chat->finalize(nd); // deallocate npc PCRE data structures
#endif
if( single && nd->path ) {
struct npc_path_data* npd = NULL;
if( nd->path && nd->path != npc_last_ref ) {
- npd = strdb_get(npc_path_db, nd->path);
+ npd = strdb_get(npc->path_db, nd->path);
}
if( npd && --npd->references == 0 ) {
- strdb_remove(npc_path_db, nd->path);/* remove from db */
+ strdb_remove(npc->path_db, nd->path);/* remove from db */
aFree(nd->path);/* remove now that no other instances exist */
}
}
@@ -1842,8 +1816,8 @@ int npc_unload(struct npc_data* nd, bool single) {
struct block_list* bl;
if( single ) {
- ev_db->foreach(ev_db,npc_unload_ev,nd->exname); //Clean up all events related
- ev_label_db->foreach(ev_label_db,npc_unload_ev_label,nd);
+ npc->ev_db->foreach(npc->ev_db,npc->unload_ev,nd->exname); //Clean up all events related
+ npc->ev_label_db->foreach(npc->ev_label_db,npc->unload_ev_label,nd);
}
iter = mapit_geteachpc();
@@ -1856,8 +1830,8 @@ int npc_unload(struct npc_data* nd, bool single) {
continue;
if( td && td->data )
- ers_free(timer_event_ers, (void*)td->data);
- iTimer->delete_timer(sd->npc_timer_id, npc_timerevent);
+ ers_free(npc->timer_event_ers, (void*)td->data);
+ iTimer->delete_timer(sd->npc_timer_id, npc->timerevent);
sd->npc_timer_id = INVALID_TIMER;
}
}
@@ -1867,8 +1841,8 @@ int npc_unload(struct npc_data* nd, bool single) {
const struct TimerData *td;
td = iTimer->get_timer(nd->u.scr.timerid);
if (td && td->data)
- ers_free(timer_event_ers, (void*)td->data);
- iTimer->delete_timer(nd->u.scr.timerid, npc_timerevent);
+ ers_free(npc->timer_event_ers, (void*)td->data);
+ iTimer->delete_timer(nd->u.scr.timerid, npc->timerevent);
}
if (nd->u.scr.timer_event)
aFree(nd->u.scr.timer_event);
@@ -1888,7 +1862,7 @@ int npc_unload(struct npc_data* nd, bool single) {
guild->flag_remove(nd);
}
- if( nd->ud != &npc_base_ud ) {
+ if( nd->ud != &npc->base_ud ) {
aFree(nd->ud);
nd->ud = NULL;
}
@@ -1903,9 +1877,9 @@ int npc_unload(struct npc_data* nd, bool single) {
//
/// Clears the npc source file list
-static void npc_clearsrcfile(void)
+void npc_clearsrcfile(void)
{
- struct npc_src_list* file = npc_src_files;
+ struct npc_src_list* file = npc->src_files;
struct npc_src_list* file_tofree;
while( file != NULL )
@@ -1914,7 +1888,7 @@ static void npc_clearsrcfile(void)
file = file->next;
aFree(file_tofree);
}
- npc_src_files = NULL;
+ npc->src_files = NULL;
}
/// Adds a npc source file (or removes all)
@@ -1925,12 +1899,12 @@ void npc_addsrcfile(const char* name)
if( strcmpi(name, "clear") == 0 )
{
- npc_clearsrcfile();
+ npc->clearsrcfile();
return;
}
// prevent multiple insert of source files
- file = npc_src_files;
+ file = npc->src_files;
while( file != NULL )
{
if( strcmp(name, file->name) == 0 )
@@ -1943,7 +1917,7 @@ void npc_addsrcfile(const char* name)
file->next = NULL;
safestrncpy(file->name, name, strlen(name) + 1);
if( file_prev == NULL )
- npc_src_files = file;
+ npc->src_files = file;
else
file_prev->next = file;
}
@@ -1951,12 +1925,12 @@ void npc_addsrcfile(const char* name)
/// Removes a npc source file (or all)
void npc_delsrcfile(const char* name)
{
- struct npc_src_list* file = npc_src_files;
+ struct npc_src_list* file = npc->src_files;
struct npc_src_list* file_prev = NULL;
if( strcmpi(name, "all") == 0 )
{
- npc_clearsrcfile();
+ npc->clearsrcfile();
return;
}
@@ -1964,8 +1938,8 @@ void npc_delsrcfile(const char* name)
{
if( strcmp(file->name, name) == 0 )
{
- if( npc_src_files == file )
- npc_src_files = file->next;
+ if( npc->src_files == file )
+ npc->src_files = file->next;
else
file_prev->next = file->next;
aFree(file);
@@ -1978,7 +1952,7 @@ void npc_delsrcfile(const char* name)
/// Parses and sets the name and exname of a npc.
/// Assumes that m, x and y are already set in nd.
-static void npc_parsename(struct npc_data* nd, const char* name, const char* start, const char* buffer, const char* filepath)
+void npc_parsename(struct npc_data* nd, const char* name, const char* start, const char* buffer, const char* filepath)
{
const char* p;
struct npc_data* dnd;// duplicate npc
@@ -2013,7 +1987,7 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta
safestrncpy(nd->exname, newname, sizeof(nd->exname));
}
- if( (dnd=npc_name2id(nd->exname)) != NULL ) {// duplicate unique name, generate new one
+ if( (dnd=npc->name2id(nd->exname)) != NULL ) {// duplicate unique name, generate new one
char this_mapname[32];
char other_mapname[32];
int i = 0;
@@ -2021,7 +1995,7 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta
do {
++i;
snprintf(newname, ARRAYLENGTH(newname), "%d_%d_%d_%d", i, nd->bl.m, nd->bl.x, nd->bl.y);
- } while( npc_name2id(newname) != NULL );
+ } while( npc->name2id(newname) != NULL );
strcpy(this_mapname, (nd->bl.m==-1?"(not on a map)":mapindex_id2name(map[nd->bl.m].index)));
strcpy(other_mapname, (dnd->bl.m==-1?"(not on a map)":mapindex_id2name(map[dnd->bl.m].index)));
@@ -2035,9 +2009,9 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta
if( npc_last_path != filepath ) {
struct npc_path_data * npd = NULL;
- if( !(npd = strdb_get(npc_path_db,filepath) ) ) {
+ if( !(npd = strdb_get(npc->path_db,filepath) ) ) {
CREATE(npd, struct npc_path_data, 1);
- strdb_put(npc_path_db, filepath, npd);
+ strdb_put(npc->path_db, filepath, npd);
CREATE(npd->path, char, strlen(filepath)+1);
safestrncpy(npd->path, filepath, strlen(filepath)+1);
@@ -2064,7 +2038,7 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short
struct npc_data *nd;
CREATE(nd, struct npc_data, 1);
- nd->bl.id = npc_get_new_npc_id();
+ nd->bl.id = npc->get_new_npc_id();
iMap->addnpc(from_mapid, nd);
nd->bl.prev = nd->bl.next = NULL;
nd->bl.m = from_mapid;
@@ -2072,13 +2046,13 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short
nd->bl.y = from_y;
safestrncpy(nd->exname, name, ARRAYLENGTH(nd->exname));
- if (npc_name2id(nd->exname) != NULL)
+ if (npc->name2id(nd->exname) != NULL)
flag = 1;
if (flag == 1)
snprintf(nd->exname, ARRAYLENGTH(nd->exname), "warp_%d_%d_%d", from_mapid, from_x, from_y);
- for( i = 0; npc_name2id(nd->exname) != NULL; ++i )
+ for( i = 0; npc->name2id(nd->exname) != NULL; ++i )
snprintf(nd->exname, ARRAYLENGTH(nd->exname), "warp%d_%d_%d_%d", i, from_mapid, from_x, from_y);
safestrncpy(nd->name, nd->exname, ARRAYLENGTH(nd->name));
@@ -2095,19 +2069,19 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short
nd->u.warp.ys = xs;
nd->bl.type = BL_NPC;
nd->subtype = WARP;
- npc_setcells(nd);
+ npc->setcells(nd);
iMap->addblock(&nd->bl);
iStatus->set_viewdata(&nd->bl, nd->class_);
- nd->ud = &npc_base_ud;
+ nd->ud = &npc->base_ud;
if( map[nd->bl.m].users )
clif->spawn(&nd->bl);
- strdb_put(npcname_db, nd->exname, nd);
+ strdb_put(npc->name_db, nd->exname, nd);
return nd;
}
/// Parses a warp npc.
-static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
+const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
{
int x, y, xs, ys, to_x, to_y, m;
unsigned short i;
@@ -2138,13 +2112,13 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
CREATE(nd, struct npc_data, 1);
- nd->bl.id = npc_get_new_npc_id();
+ nd->bl.id = npc->get_new_npc_id();
iMap->addnpc(m, nd);
nd->bl.prev = nd->bl.next = NULL;
nd->bl.m = m;
nd->bl.x = x;
nd->bl.y = y;
- npc_parsename(nd, w3, start, buffer, filepath);
+ npc->parsename(nd, w3, start, buffer, filepath);
if (!battle_config.warp_point_debug)
nd->class_ = WARP_CLASS;
@@ -2160,19 +2134,19 @@ static const char* npc_parse_warp(char* w1, char* w2, char* w3, char* w4, const
npc_warp++;
nd->bl.type = BL_NPC;
nd->subtype = WARP;
- npc_setcells(nd);
+ npc->setcells(nd);
iMap->addblock(&nd->bl);
iStatus->set_viewdata(&nd->bl, nd->class_);
- nd->ud = &npc_base_ud;
+ nd->ud = &npc->base_ud;
if( map[nd->bl.m].users )
clif->spawn(&nd->bl);
- strdb_put(npcname_db, nd->exname, nd);
+ strdb_put(npc->name_db, nd->exname, nd);
return strchr(start,'\n');// continue
}
/// Parses a shop/cashshop npc.
-static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
+const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
{
//TODO: could be rewritten to NOT need this temp array [ultramage]
#define MAX_SHOPITEM 100
@@ -2263,8 +2237,8 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
nd->bl.m = m;
nd->bl.x = x;
nd->bl.y = y;
- nd->bl.id = npc_get_new_npc_id();
- npc_parsename(nd, w3, start, buffer, filepath);
+ nd->bl.id = npc->get_new_npc_id();
+ npc->parsename(nd, w3, start, buffer, filepath);
nd->class_ = m==-1?-1:atoi(w4);
nd->speed = 200;
@@ -2275,14 +2249,14 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
iMap->addnpc(m,nd);
iMap->addblock(&nd->bl);
iStatus->set_viewdata(&nd->bl, nd->class_);
- nd->ud = &npc_base_ud;
+ nd->ud = &npc->base_ud;
nd->dir = dir;
if( map[nd->bl.m].users )
clif->spawn(&nd->bl);
} else {// 'floating' shop?
iMap->addiddb(&nd->bl);
}
- strdb_put(npcname_db, nd->exname, nd);
+ strdb_put(npc->name_db, nd->exname, nd);
return strchr(start,'\n');// continue
}
@@ -2318,7 +2292,7 @@ void npc_convertlabel_db(struct npc_label_list* label_list, const char *filepath
}
// Skip the contents of a script.
-static const char* npc_skip_script(const char* start, const char* buffer, const char* filepath)
+const char* npc_skip_script(const char* start, const char* buffer, const char* filepath)
{
const char* p;
int curly_count;
@@ -2379,7 +2353,7 @@ static const char* npc_skip_script(const char* start, const char* buffer, const
/// -%TAB%script%TAB%<NPC Name>%TAB%-1,{<code>}
/// <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,{<code>}
/// <map name>,<x>,<y>,<facing>%TAB%script%TAB%<NPC Name>%TAB%<sprite id>,<triggerX>,<triggerY>,{<code>}
-static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, bool runOnInit) {
+const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath, bool runOnInit) {
int x, y, dir = 0, m, xs = 0, ys = 0, class_ = 0; // [Valaris] thanks to fov
char mapname[32];
struct script_code *scriptroot;
@@ -2416,7 +2390,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
}
++script_start;
- end = npc_skip_script(script_start, buffer, filepath);
+ end = npc->skip_script(script_start, buffer, filepath);
if( end == NULL )
return NULL;// (simple) parse error, don't continue
@@ -2426,7 +2400,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
if( script->label_count ) {
CREATE(label_list,struct npc_label_list,script->label_count);
label_list_num = script->label_count;
- npc_convertlabel_db(label_list,filepath);
+ npc->convertlabel_db(label_list,filepath);
}
CREATE(nd, struct npc_data, 1);
@@ -2447,8 +2421,8 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
nd->bl.m = m;
nd->bl.x = x;
nd->bl.y = y;
- npc_parsename(nd, w3, start, buffer, filepath);
- nd->bl.id = npc_get_new_npc_id();
+ npc->parsename(nd, w3, start, buffer, filepath);
+ nd->bl.id = npc->get_new_npc_id();
nd->class_ = class_;
nd->speed = 200;
nd->u.scr.script = scriptroot;
@@ -2461,9 +2435,9 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
if( m >= 0 ) {
iMap->addnpc(m, nd);
- nd->ud = &npc_base_ud;
+ nd->ud = &npc->base_ud;
nd->dir = dir;
- npc_setcells(nd);
+ npc->setcells(nd);
iMap->addblock(&nd->bl);
if( class_ >= 0 ) {
iStatus->set_viewdata(&nd->bl, nd->class_);
@@ -2474,16 +2448,16 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
// we skip iMap->addnpc, but still add it to the list of ID's
iMap->addiddb(&nd->bl);
}
- strdb_put(npcname_db, nd->exname, nd);
+ strdb_put(npc->name_db, nd->exname, nd);
//-----------------------------------------
// Loop through labels to export them as necessary
for (i = 0; i < nd->u.scr.label_list_num; i++) {
- if (npc_event_export(nd, i)) {
+ if (npc->event_export(nd, i)) {
ShowWarning("npc_parse_script : duplicate event %s::%s (%s)\n",
nd->exname, nd->u.scr.label_list[i].name, filepath);
}
- npc_timerevent_export(nd, i);
+ npc->timerevent_export(nd, i);
}
nd->u.scr.timerid = INVALID_TIMER;
@@ -2494,7 +2468,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
snprintf(evname, ARRAYLENGTH(evname), "%s::OnInit", nd->exname);
- if( ( ev = (struct event_data*)strdb_get(ev_db, evname) ) ) {
+ if( ( ev = (struct event_data*)strdb_get(npc->ev_db, evname) ) ) {
//Execute OnInit
script->run(nd->u.scr.script,ev->pos,0,nd->bl.id);
@@ -2536,7 +2510,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
}
safestrncpy(srcname, w2+10, length-10);
- dnd = npc_name2id(srcname);
+ dnd = npc->name2id(srcname);
if( dnd == NULL) {
ShowError("npc_parse_script: original npc not found for duplicate in file '%s', line '%d' : %s\n", filepath, strline(buffer,start-buffer), srcname);
return end;// next line, try to continue
@@ -2576,8 +2550,8 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
nd->bl.m = m;
nd->bl.x = x;
nd->bl.y = y;
- npc_parsename(nd, w3, start, buffer, filepath);
- nd->bl.id = npc_get_new_npc_id();
+ npc->parsename(nd, w3, start, buffer, filepath);
+ nd->bl.id = npc->get_new_npc_id();
nd->class_ = class_;
nd->speed = 200;
nd->src_id = src_id;
@@ -2617,9 +2591,9 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
//Add the npc to its location
if( m >= 0 ) {
iMap->addnpc(m, nd);
- nd->ud = &npc_base_ud;
+ nd->ud = &npc->base_ud;
nd->dir = dir;
- npc_setcells(nd);
+ npc->setcells(nd);
iMap->addblock(&nd->bl);
if( class_ >= 0 ) {
iStatus->set_viewdata(&nd->bl, nd->class_);
@@ -2630,7 +2604,7 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
// we skip iMap->addnpc, but still add it to the list of ID's
iMap->addiddb(&nd->bl);
}
- strdb_put(npcname_db, nd->exname, nd);
+ strdb_put(npc->name_db, nd->exname, nd);
if( type != SCRIPT )
return end;
@@ -2638,11 +2612,11 @@ const char* npc_parse_duplicate(char* w1, char* w2, char* w3, char* w4, const ch
//-----------------------------------------
// Loop through labels to export them as necessary
for (i = 0; i < nd->u.scr.label_list_num; i++) {
- if (npc_event_export(nd, i)) {
+ if (npc->event_export(nd, i)) {
ShowWarning("npc_parse_duplicate : duplicate event %s::%s (%s)\n",
nd->exname, nd->u.scr.label_list[i].name, filepath);
}
- npc_timerevent_export(nd, i);
+ npc->timerevent_export(nd, i);
}
nd->u.scr.timerid = INVALID_TIMER;
@@ -2657,7 +2631,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) {
return 1;
snprintf(newname, ARRAYLENGTH(newname), "dup_%d_%d", map[m].instance_id, snd->bl.id);
- if( npc_name2id(newname) != NULL ) { // Name already in use
+ if( npc->name2id(newname) != NULL ) { // Name already in use
ShowError("npc_duplicate4instance: the npcname (%s) is already in use while trying to duplicate npc %s in instance %d.\n", newname, snd->exname, map[m].instance_id);
return 1;
}
@@ -2673,7 +2647,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) {
}
CREATE(wnd, struct npc_data, 1);
- wnd->bl.id = npc_get_new_npc_id();
+ wnd->bl.id = npc->get_new_npc_id();
iMap->addnpc(m, wnd);
wnd->bl.prev = wnd->bl.next = NULL;
wnd->bl.m = m;
@@ -2690,13 +2664,13 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) {
wnd->u.warp.ys = snd->u.warp.ys;
wnd->bl.type = BL_NPC;
wnd->subtype = WARP;
- npc_setcells(wnd);
+ npc->setcells(wnd);
iMap->addblock(&wnd->bl);
iStatus->set_viewdata(&wnd->bl, wnd->class_);
- wnd->ud = &npc_base_ud;
+ wnd->ud = &npc->base_ud;
if( map[wnd->bl.m].users )
clif->spawn(&wnd->bl);
- strdb_put(npcname_db, wnd->exname, wnd);
+ strdb_put(npc->name_db, wnd->exname, wnd);
} else {
static char w1[50], w2[50], w3[50], w4[50];
const char* stat_buf = "- call from instancing subsystem -\n";
@@ -2710,7 +2684,7 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) {
else
snprintf(w4, sizeof(w4), "%d", snd->class_);
- npc_parse_duplicate(w1, w2, w3, w4, stat_buf, stat_buf, "INSTANCING");
+ npc->parse_duplicate(w1, w2, w3, w4, stat_buf, stat_buf, "INSTANCING");
}
return 0;
@@ -2750,7 +2724,7 @@ int npc_unsetcells_sub(struct block_list* bl, va_list ap) {
struct npc_data *nd = (struct npc_data*)bl;
int id = va_arg(ap,int);
if (nd->bl.id == id) return 0;
- npc_setcells(nd);
+ npc->setcells(nd);
return 1;
}
@@ -2782,7 +2756,7 @@ void npc_unsetcells(struct npc_data* nd) {
map[m].setcell(m, j, i, CELL_NPC, false);
//Re-deploy NPC cells for other nearby npcs.
- iMap->foreachinarea( npc_unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id );
+ iMap->foreachinarea( npc->unsetcells_sub, m, x0, y0, x1, y1, BL_NPC, nd->bl.id );
}
void npc_movenpc(struct npc_data* nd, int16 x, int16 y)
@@ -2833,7 +2807,7 @@ void npc_setclass(struct npc_data* nd, short class_)
// @commands (script based)
int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const char* message, const char* eventname)
{
- struct event_data* ev = (struct event_data*)strdb_get(ev_db, eventname);
+ struct event_data* ev = (struct event_data*)strdb_get(npc->ev_db, eventname);
struct npc_data *nd;
struct script_state *st;
int i = 0, j = 0, k = 0;
@@ -2859,7 +2833,7 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
}
if( ev->nd->option&OPTION_INVISIBLE ) { // Disabled npc, shouldn't trigger event.
- npc_event_dequeue(sd);
+ npc->event_dequeue(sd);
return 2;
}
@@ -2894,7 +2868,7 @@ int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const c
/// Parses a function.
/// function%TAB%script%TAB%<function name>%TAB%{<code>}
-static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
+const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
{
DBMap* func_db;
DBData old_data;
@@ -2911,7 +2885,7 @@ static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, co
}
++script_start;
- end = npc_skip_script(script_start,buffer,filepath);
+ end = npc->skip_script(script_start,buffer,filepath);
if( end == NULL )
return NULL;// (simple) parse error, don't continue
@@ -2938,36 +2912,36 @@ static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, co
* Parse Mob 2 - Actually Spawns Mob
* [Wizputer]
*------------------------------------------*/
-void npc_parse_mob2(struct spawn_data* mob)
+void npc_parse_mob2(struct spawn_data* mobspawn)
{
int i;
- for( i = mob->active; i < mob->num; ++i ) {
- struct mob_data* md = mob_spawn_dataset(mob);
- md->spawn = mob;
+ for( i = mobspawn->active; i < mobspawn->num; ++i ) {
+ struct mob_data* md = mob->spawn_dataset(mobspawn);
+ md->spawn = mobspawn;
md->spawn->active++;
- mob_spawn(md);
+ mob->spawn(md);
}
}
-static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
+const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath)
{
int num, class_, m,x,y,xs,ys, i,j;
int mob_lv = -1, ai = -1, size = -1;
char mapname[32], mobname[NAME_LENGTH];
- struct spawn_data mob, *data;
+ struct spawn_data mobspawn, *data;
struct mob_db* db;
- memset(&mob, 0, sizeof(struct spawn_data));
+ memset(&mobspawn, 0, sizeof(struct spawn_data));
- mob.state.boss = !strcmpi(w2,"boss_monster");
+ mobspawn.state.boss = !strcmpi(w2,"boss_monster");
// w1=<map name>,<x>,<y>,<xs>,<ys>
// w3=<mob name>{,<mob level>}
// w4=<mob id>,<amount>,<delay1>,<delay2>,<event>{,<mob size>,<mob ai>}
if( sscanf(w1, "%31[^,],%d,%d,%d,%d", mapname, &x, &y, &xs, &ys) < 3
|| sscanf(w3, "%23[^,],%d", mobname, &mob_lv) < 1
- || sscanf(w4, "%d,%d,%u,%u,%127[^,],%d,%d[^\t\r\n]", &class_, &num, &mob.delay1, &mob.delay2, mob.eventname, &size, &ai) < 2 )
+ || sscanf(w4, "%d,%d,%u,%u,%127[^,],%d,%d[^\t\r\n]", &class_, &num, &mobspawn.delay1, &mobspawn.delay2, mobspawn.eventname, &size, &ai) < 2 )
{
ShowError("npc_parse_mob: Invalid mob definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
return strchr(start,'\n');// skip and continue
@@ -2980,16 +2954,16 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c
m = iMap->mapname2mapid(mapname);
if( m < 0 )//Not loaded on this map-server instance.
return strchr(start,'\n');// skip and continue
- mob.m = (unsigned short)m;
+ mobspawn.m = (unsigned short)m;
- if( x < 0 || x >= map[mob.m].xs || y < 0 || y >= map[mob.m].ys )
+ if( x < 0 || x >= map[mobspawn.m].xs || y < 0 || y >= map[mobspawn.m].ys )
{
- ShowError("npc_parse_mob: Spawn coordinates out of range: %s (%d,%d), map size is (%d,%d) - %s %s (file '%s', line '%d').\n", map[mob.m].name, x, y, (map[mob.m].xs-1), (map[mob.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer));
+ ShowError("npc_parse_mob: Spawn coordinates out of range: %s (%d,%d), map size is (%d,%d) - %s %s (file '%s', line '%d').\n", map[mobspawn.m].name, x, y, (map[mobspawn.m].xs-1), (map[mobspawn.m].ys-1), w1, w3, filepath, strline(buffer,start-buffer));
return strchr(start,'\n');// skip and continue
}
// check monster ID if exists!
- if( mobdb_checkid(class_) == 0 )
+ if( mob->db_checkid(class_) == 0 )
{
ShowError("npc_parse_mob: Unknown mob ID %d (file '%s', line '%d').\n", class_, filepath, strline(buffer,start-buffer));
return strchr(start,'\n');// skip and continue
@@ -3001,15 +2975,15 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c
return strchr(start,'\n');// skip and continue
}
- if( (mob.state.size < 0 || mob.state.size > 2) && size != -1 )
+ if( (mobspawn.state.size < 0 || mobspawn.state.size > 2) && size != -1 )
{
- ShowError("npc_parse_mob: Invalid size number %d for mob ID %d (file '%s', line '%d').\n", mob.state.size, class_, filepath, strline(buffer, start - buffer));
+ ShowError("npc_parse_mob: Invalid size number %d for mob ID %d (file '%s', line '%d').\n", mobspawn.state.size, class_, filepath, strline(buffer, start - buffer));
return strchr(start, '\n');
}
- if( (mob.state.ai < 0 || mob.state.ai > 4) && ai != -1 )
+ if( (mobspawn.state.ai < 0 || mobspawn.state.ai > 4) && ai != -1 )
{
- ShowError("npc_parse_mob: Invalid ai %d for mob ID %d (file '%s', line '%d').\n", mob.state.ai, class_, filepath, strline(buffer, start - buffer));
+ ShowError("npc_parse_mob: Invalid ai %d for mob ID %d (file '%s', line '%d').\n", mobspawn.state.ai, class_, filepath, strline(buffer, start - buffer));
return strchr(start, '\n');
}
@@ -3019,58 +2993,58 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c
return strchr(start, '\n');
}
- mob.num = (unsigned short)num;
- mob.active = 0;
- mob.class_ = (short) class_;
- mob.x = (unsigned short)x;
- mob.y = (unsigned short)y;
- mob.xs = (signed short)xs;
- mob.ys = (signed short)ys;
+ mobspawn.num = (unsigned short)num;
+ mobspawn.active = 0;
+ mobspawn.class_ = (short) class_;
+ mobspawn.x = (unsigned short)x;
+ mobspawn.y = (unsigned short)y;
+ mobspawn.xs = (signed short)xs;
+ mobspawn.ys = (signed short)ys;
if (mob_lv > 0 && mob_lv <= MAX_LEVEL)
- mob.level = mob_lv;
+ mobspawn.level = mob_lv;
if (size > 0 && size <= 2)
- mob.state.size = size;
+ mobspawn.state.size = size;
if (ai > 0 && ai <= 4)
- mob.state.ai = ai;
+ mobspawn.state.ai = ai;
- if (mob.num > 1 && battle_config.mob_count_rate != 100) {
- if ((mob.num = mob.num * battle_config.mob_count_rate / 100) < 1)
- mob.num = 1;
+ if (mobspawn.num > 1 && battle_config.mob_count_rate != 100) {
+ if ((mobspawn.num = mobspawn.num * battle_config.mob_count_rate / 100) < 1)
+ mobspawn.num = 1;
}
- if (battle_config.force_random_spawn || (mob.x == 0 && mob.y == 0))
+ if (battle_config.force_random_spawn || (mobspawn.x == 0 && mobspawn.y == 0))
{ //Force a random spawn anywhere on the map.
- mob.x = mob.y = 0;
- mob.xs = mob.ys = -1;
+ mobspawn.x = mobspawn.y = 0;
+ mobspawn.xs = mobspawn.ys = -1;
}
- if(mob.delay1>0xfffffff || mob.delay2>0xfffffff) {
- ShowError("npc_parse_mob: Invalid spawn delays %u %u (file '%s', line '%d').\n", mob.delay1, mob.delay2, filepath, strline(buffer,start-buffer));
+ if(mobspawn.delay1>0xfffffff || mobspawn.delay2>0xfffffff) {
+ ShowError("npc_parse_mob: Invalid spawn delays %u %u (file '%s', line '%d').\n", mobspawn.delay1, mobspawn.delay2, filepath, strline(buffer,start-buffer));
return strchr(start,'\n');// skip and continue
}
//Use db names instead of the spawn file ones.
if(battle_config.override_mob_names==1)
- strcpy(mob.name,"--en--");
+ strcpy(mobspawn.name,"--en--");
else if (battle_config.override_mob_names==2)
- strcpy(mob.name,"--ja--");
+ strcpy(mobspawn.name,"--ja--");
else
- safestrncpy(mob.name, mobname, sizeof(mob.name));
+ safestrncpy(mobspawn.name, mobname, sizeof(mobspawn.name));
//Verify dataset.
- if( !mob_parse_dataset(&mob) )
+ if( !mob->parse_dataset(&mobspawn) )
{
ShowError("npc_parse_mob: Invalid dataset for monster ID %d (file '%s', line '%d').\n", class_, filepath, strline(buffer,start-buffer));
return strchr(start,'\n');// skip and continue
}
//Update mob spawn lookup database
- db = mob_db(class_);
+ db = mob->db(class_);
for( i = 0; i < ARRAYLENGTH(db->spawn); ++i )
{
- if (map[mob.m].index == db->spawn[i].mapindex)
+ if (map[mobspawn.m].index == db->spawn[i].mapindex)
{ //Update total
- db->spawn[i].qty += mob.num;
+ db->spawn[i].qty += mobspawn.num;
//Re-sort list
for( j = i; j > 0 && db->spawn[j-1].qty < db->spawn[i].qty; --j );
if( j != i )
@@ -3083,18 +3057,18 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c
}
break;
}
- if (mob.num > db->spawn[i].qty)
+ if (mobspawn.num > db->spawn[i].qty)
{ //Insert into list
memmove(&db->spawn[i+1], &db->spawn[i], sizeof(db->spawn) -(i+1)*sizeof(db->spawn[0]));
- db->spawn[i].mapindex = map[mob.m].index;
- db->spawn[i].qty = mob.num;
+ db->spawn[i].mapindex = map[mobspawn.m].index;
+ db->spawn[i].qty = mobspawn.num;
break;
}
}
//Now that all has been validated. We allocate the actual memory that the re-spawn data will use.
data = (struct spawn_data*)aMalloc(sizeof(struct spawn_data));
- memcpy(data, &mob, sizeof(struct spawn_data));
+ memcpy(data, &mobspawn, sizeof(struct spawn_data));
// spawn / cache the new mobs
if( battle_config.dynamic_mobs && iMap->addmobtolist(data->m, data) >= 0 ) {
@@ -3105,11 +3079,11 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c
// (usually shouldn't occur when map server is just starting,
// but not the case when we do @reloadscript
if( map[data->m].users > 0 ) {
- npc_parse_mob2(data);
+ npc->parse_mob2(data);
}
} else {
data->state.dynamic = false;
- npc_parse_mob2(data);
+ npc->parse_mob2(data);
npc_delay_mob += data->num;
}
@@ -3600,7 +3574,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit)
ShowError("npc_parsesrcfile: Unknown map '%s' in file '%s', line '%d'. Skipping line...\n", mapname, filepath, strline(buffer,p-buffer));
if( strcasecmp(w2,"script") == 0 && count > 3 )
{
- if((p = npc_skip_script(p,buffer,filepath)) == NULL)
+ if((p = npc->skip_script(p,buffer,filepath)) == NULL)
{
break;
}
@@ -3613,7 +3587,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit)
{// "mapname" is not assigned to this server, we must skip the script info...
if( strcasecmp(w2,"script") == 0 && count > 3 )
{
- if((p = npc_skip_script(p,buffer,filepath)) == NULL)
+ if((p = npc->skip_script(p,buffer,filepath)) == NULL)
{
break;
}
@@ -3625,7 +3599,7 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit)
ShowError("npc_parsesrcfile: Unknown coordinates ('%d', '%d') for map '%s' in file '%s', line '%d'. Skipping line...\n", x, y, mapname, filepath, strline(buffer,p-buffer));
if( strcasecmp(w2,"script") == 0 && count > 3 )
{
- if((p = npc_skip_script(p,buffer,filepath)) == NULL)
+ if((p = npc->skip_script(p,buffer,filepath)) == NULL)
{
break;
}
@@ -3637,30 +3611,30 @@ void npc_parsesrcfile(const char* filepath, bool runOnInit)
if( strcasecmp(w2,"warp") == 0 && count > 3 )
{
- p = npc_parse_warp(w1,w2,w3,w4, p, buffer, filepath);
+ p = npc->parse_warp(w1,w2,w3,w4, p, buffer, filepath);
}
else if( (!strcasecmp(w2,"shop") || !strcasecmp(w2,"cashshop")) && count > 3 )
{
- p = npc_parse_shop(w1,w2,w3,w4, p, buffer, filepath);
+ p = npc->parse_shop(w1,w2,w3,w4, p, buffer, filepath);
}
else if( strcasecmp(w2,"script") == 0 && count > 3 )
{
if( strcasecmp(w1,"function") == 0 )
- p = npc_parse_function(w1, w2, w3, w4, p, buffer, filepath);
+ p = npc->parse_function(w1, w2, w3, w4, p, buffer, filepath);
else
- p = npc_parse_script(w1,w2,w3,w4, p, buffer, filepath,runOnInit);
+ p = npc->parse_script(w1,w2,w3,w4, p, buffer, filepath,runOnInit);
}
else if( (i=0, sscanf(w2,"duplicate%n",&i), (i > 0 && w2[i] == '(')) && count > 3 )
{
- p = npc_parse_duplicate(w1,w2,w3,w4, p, buffer, filepath);
+ p = npc->parse_duplicate(w1,w2,w3,w4, p, buffer, filepath);
}
else if( (strcmpi(w2,"monster") == 0 || strcmpi(w2,"boss_monster") == 0) && count > 3 )
{
- p = npc_parse_mob(w1, w2, w3, w4, p, buffer, filepath);
+ p = npc->parse_mob(w1, w2, w3, w4, p, buffer, filepath);
}
else if( strcmpi(w2,"mapflag") == 0 && count >= 3 )
{
- p = npc_parse_mapflag(w1, w2, trim(w3), trim(w4), p, buffer, filepath);
+ p = npc->parse_mapflag(w1, w2, trim(w3), trim(w4), p, buffer, filepath);
}
else
{
@@ -3683,7 +3657,7 @@ int npc_script_event(struct map_session_data* sd, enum npce_event type)
return 0;
}
for (i = 0; i<script_event[type].event_count; i++)
- npc_event_sub(sd,script_event[type].event[i],script_event[type].event_name[i]);
+ npc->event_sub(sd,script_event[type].event[i],script_event[type].event_name[i]);
return i;
}
@@ -3714,7 +3688,7 @@ void npc_read_event_script(void)
safestrncpy(name+2,config[i].event_name,62);
script_event[i].event_count = 0;
- iter = db_iterator(ev_db);
+ iter = db_iterator(npc->ev_db);
for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) )
{
const char* p = key.str;
@@ -3747,7 +3721,7 @@ void npc_read_event_script(void)
/**
* @see DBApply
*/
-static int npc_path_db_clear_sub(DBKey key, DBData *data, va_list args)
+int npc_path_db_clear_sub(DBKey key, DBData *data, va_list args)
{
struct npc_path_data *npd = DB->data2ptr(data);
if (npd->path)
@@ -3758,7 +3732,7 @@ static int npc_path_db_clear_sub(DBKey key, DBData *data, va_list args)
/**
* @see DBApply
*/
-static int ev_label_db_clear_sub(DBKey key, DBData *data, va_list args)
+int npc_ev_label_db_clear_sub(DBKey key, DBData *data, va_list args)
{
struct linkdb_node **label_linkdb = DB->data2ptr(data);
linkdb_final(label_linkdb); // linked data (struct event_data*) is freed when clearing ev_db
@@ -3776,11 +3750,11 @@ int npc_reload(void) {
/* clear guild flag cache */
guild->flags_clear();
- npc_path_db->clear(npc_path_db, npc_path_db_clear_sub);
+ npc->path_db->clear(npc->path_db, npc->path_db_clear_sub);
- db_clear(npcname_db);
- db_clear(ev_db);
- ev_label_db->clear(ev_label_db, ev_label_db_clear_sub);
+ db_clear(npc->name_db);
+ db_clear(npc->ev_db);
+ npc->ev_label_db->clear(npc->ev_label_db, npc->ev_label_db_clear_sub);
npc_last_npd = NULL;
npc_last_path = NULL;
@@ -3792,11 +3766,11 @@ int npc_reload(void) {
for( bl = (struct block_list*)mapit->first(iter); mapit->exists(iter); bl = (struct block_list*)mapit->next(iter) ) {
switch(bl->type) {
case BL_NPC:
- if( bl->id != fake_nd->bl.id )// don't remove fake_nd
- npc_unload((struct npc_data *)bl, false);
+ if( bl->id != npc->fake_nd->bl.id )// don't remove fake_nd
+ npc->unload((struct npc_data *)bl, false);
break;
case BL_MOB:
- unit_free(bl,CLR_OUTSIGHT);
+ unit->free(bl,CLR_OUTSIGHT);
break;
}
}
@@ -3821,7 +3795,7 @@ int npc_reload(void) {
}
// clear mob spawn lookup index
- mob_clear_spawninfo();
+ mob->clear_spawninfo();
npc_warp = npc_shop = npc_script = 0;
npc_mob = npc_cache_mob = npc_delay_mob = 0;
@@ -3831,9 +3805,9 @@ int npc_reload(void) {
//TODO: the following code is copy-pasted from do_init_npc(); clean it up
// Reloading npcs now
- for (nsl = npc_src_files; nsl; nsl = nsl->next) {
+ for (nsl = npc->src_files; nsl; nsl = nsl->next) {
ShowStatus("Loading NPC file: %s"CL_CLL"\r", nsl->name);
- npc_parsesrcfile(nsl->name,false);
+ npc->parsesrcfile(nsl->name,false);
}
ShowInfo ("Done loading '"CL_WHITE"%d"CL_RESET"' NPCs:"CL_CLL"\n"
"\t-'"CL_WHITE"%d"CL_RESET"' Warps\n"
@@ -3852,69 +3826,69 @@ int npc_reload(void) {
iMap->zone_init();
- npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */
+ npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */
//Re-read the NPC Script Events cache.
- npc_read_event_script();
+ npc->read_event_script();
/* refresh guild castle flags on both woe setups */
- npc_event_doall("OnAgitInit");
- npc_event_doall("OnAgitInit2");
+ npc->event_doall("OnAgitInit");
+ npc->event_doall("OnAgitInit2");
//Execute the OnInit event for freshly loaded npcs. [Skotlex]
- ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n",npc_event_doall("OnInit"));
+ ShowStatus("Event '"CL_WHITE"OnInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n",npc->event_doall("OnInit"));
// Execute rest of the startup events if connected to char-server. [Lance]
if(!intif->CheckForCharServer()){
- ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInit"));
- ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc_event_doall("OnInterIfInitOnce"));
+ ShowStatus("Event '"CL_WHITE"OnInterIfInit"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc->event_doall("OnInterIfInit"));
+ ShowStatus("Event '"CL_WHITE"OnInterIfInitOnce"CL_RESET"' executed with '"CL_WHITE"%d"CL_RESET"' NPCs.\n", npc->event_doall("OnInterIfInitOnce"));
}
return 0;
}
//Unload all npc in the given file
bool npc_unloadfile( const char* path ) {
- DBIterator * iter = db_iterator(npcname_db);
+ DBIterator * iter = db_iterator(npc->name_db);
struct npc_data* nd = NULL;
bool found = false;
for( nd = dbi_first(iter); dbi_exists(iter); nd = dbi_next(iter) ) {
if( nd->path && strcasecmp(nd->path,path) == 0 ) {
found = true;
- npc_unload_duplicates(nd);/* unload any npcs which could duplicate this but be in a different file */
- npc_unload(nd, true);
+ npc->unload_duplicates(nd);/* unload any npcs which could duplicate this but be in a different file */
+ npc->unload(nd, true);
}
}
dbi_destroy(iter);
if( found ) /* refresh event cache */
- npc_read_event_script();
+ npc->read_event_script();
return found;
}
void do_clear_npc(void) {
- db_clear(npcname_db);
- db_clear(ev_db);
- ev_label_db->clear(ev_label_db, ev_label_db_clear_sub);
+ db_clear(npc->name_db);
+ db_clear(npc->ev_db);
+ npc->ev_label_db->clear(npc->ev_label_db, npc->ev_label_db_clear_sub);
}
/*==========================================
* Destructor
*------------------------------------------*/
int do_final_npc(void) {
- db_destroy(ev_db);
- ev_label_db->destroy(ev_label_db, ev_label_db_clear_sub);
- db_destroy(npcname_db);
- npc_path_db->destroy(npc_path_db, npc_path_db_clear_sub);
- ers_destroy(timer_event_ers);
- npc_clearsrcfile();
+ db_destroy(npc->ev_db);
+ npc->ev_label_db->destroy(npc->ev_label_db, npc->ev_label_db_clear_sub);
+ db_destroy(npc->name_db);
+ npc->path_db->destroy(npc->path_db, npc->path_db_clear_sub);
+ ers_destroy(npc->timer_event_ers);
+ npc->clearsrcfile();
return 0;
}
-static void npc_debug_warps_sub(struct npc_data* nd)
+void npc_debug_warps_sub(struct npc_data* nd)
{
int16 m;
if (nd->bl.type != BL_NPC || nd->subtype != WARP || nd->bl.m < 0)
@@ -3945,7 +3919,7 @@ static void npc_debug_warps(void)
int16 m, i;
for (m = 0; m < iMap->map_num; m++)
for (i = 0; i < map[m].npc_num; i++)
- npc_debug_warps_sub(map[m].npc[i]);
+ npc->debug_warps_sub(map[m].npc[i]);
}
/*==========================================
@@ -3956,14 +3930,14 @@ int do_init_npc(void)
struct npc_src_list *file;
int i;
- memset(&npc_base_ud, 0, sizeof( struct unit_data) );
- npc_base_ud.bl = NULL;
- npc_base_ud.walktimer = INVALID_TIMER;
- npc_base_ud.skilltimer = INVALID_TIMER;
- npc_base_ud.attacktimer = INVALID_TIMER;
- npc_base_ud.attackabletime =
- npc_base_ud.canact_tick =
- npc_base_ud.canmove_tick = iTimer->gettick();
+ memset(&npc->base_ud, 0, sizeof( struct unit_data) );
+ npc->base_ud.bl = NULL;
+ npc->base_ud.walktimer = INVALID_TIMER;
+ npc->base_ud.skilltimer = INVALID_TIMER;
+ npc->base_ud.attacktimer = INVALID_TIMER;
+ npc->base_ud.attackabletime =
+ npc->base_ud.canact_tick =
+ npc->base_ud.canmove_tick = iTimer->gettick();
//Stock view data for normal npcs.
memset(&npc_viewdb, 0, sizeof(npc_viewdb));
@@ -3974,12 +3948,12 @@ int do_init_npc(void)
for( i = MAX_NPC_CLASS2_START; i < MAX_NPC_CLASS2_END; i++ )
npc_viewdb2[i - MAX_NPC_CLASS2_START].class_ = i;
- ev_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, EVENT_NAME_LENGTH);
- ev_label_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, NAME_LENGTH);
- npcname_db = strdb_alloc(DB_OPT_BASE, NAME_LENGTH);
- npc_path_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, 0);
+ npc->ev_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, EVENT_NAME_LENGTH);
+ npc->ev_label_db = stridb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, NAME_LENGTH);
+ npc->name_db = strdb_alloc(DB_OPT_BASE, NAME_LENGTH);
+ npc->path_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA, 0);
- timer_event_ers = ers_new(sizeof(struct timer_event_data),"clif.c::timer_event_ers",ERS_OPT_NONE);
+ npc->timer_event_ers = ers_new(sizeof(struct timer_event_data),"clif.c::timer_event_ers",ERS_OPT_NONE);
npc_last_npd = NULL;
npc_last_path = NULL;
@@ -3987,9 +3961,9 @@ int do_init_npc(void)
// process all npc files
ShowStatus("Loading NPCs...\r");
- for( file = npc_src_files; file != NULL; file = file->next ) {
+ for( file = npc->src_files; file != NULL; file = file->next ) {
ShowStatus("Loading NPC file: %s"CL_CLL"\r", file->name);
- npc_parsesrcfile(file->name,false);
+ npc->parsesrcfile(file->name,false);
}
ShowInfo ("Done loading '"CL_WHITE"%d"CL_RESET"' NPCs:"CL_CLL"\n"
"\t-'"CL_WHITE"%d"CL_RESET"' Warps\n"
@@ -4004,35 +3978,35 @@ int do_init_npc(void)
iMap->zone_init();
- npc->motd = npc_name2id("HerculesMOTD"); /* [Ind/Hercules] */
+ npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */
// set up the events cache
memset(script_event, 0, sizeof(script_event));
- npc_read_event_script();
+ npc->read_event_script();
//Debug function to locate all endless loop warps.
if (battle_config.warp_point_debug)
- npc_debug_warps();
+ npc->debug_warps();
- iTimer->add_timer_func_list(npc_event_do_clock,"npc_event_do_clock");
- iTimer->add_timer_func_list(npc_timerevent,"npc_timerevent");
+ iTimer->add_timer_func_list(npc->event_do_clock,"npc_event_do_clock");
+ iTimer->add_timer_func_list(npc->timerevent,"npc_timerevent");
// Init dummy NPC
- fake_nd = (struct npc_data *)aCalloc(1,sizeof(struct npc_data));
- fake_nd->bl.m = -1;
- fake_nd->bl.id = npc_get_new_npc_id();
- fake_nd->class_ = -1;
- fake_nd->speed = 200;
- strcpy(fake_nd->name,"FAKE_NPC");
- memcpy(fake_nd->exname, fake_nd->name, 9);
+ npc->fake_nd = (struct npc_data *)aCalloc(1,sizeof(struct npc_data));
+ npc->fake_nd->bl.m = -1;
+ npc->fake_nd->bl.id = npc->get_new_npc_id();
+ npc->fake_nd->class_ = -1;
+ npc->fake_nd->speed = 200;
+ strcpy(npc->fake_nd->name,"FAKE_NPC");
+ memcpy(npc->fake_nd->exname, npc->fake_nd->name, 9);
npc_script++;
- fake_nd->bl.type = BL_NPC;
- fake_nd->subtype = SCRIPT;
+ npc->fake_nd->bl.type = BL_NPC;
+ npc->fake_nd->subtype = SCRIPT;
- strdb_put(npcname_db, fake_nd->exname, fake_nd);
- fake_nd->u.scr.timerid = INVALID_TIMER;
- iMap->addiddb(&fake_nd->bl);
+ strdb_put(npc->name_db, npc->fake_nd->exname, npc->fake_nd);
+ npc->fake_nd->u.scr.timerid = INVALID_TIMER;
+ iMap->addiddb(&npc->fake_nd->bl);
// End of initialization
return 0;
@@ -4041,4 +4015,101 @@ void npc_defaults(void) {
npc = &npc_s;
npc->motd = NULL;
+ npc->ev_db = NULL;
+ npc->ev_label_db = NULL;
+ npc->name_db = NULL;
+ npc->path_db = NULL;
+ npc->timer_event_ers = NULL;
+ npc->fake_nd = NULL;
+ npc->src_files = NULL;
+ /* */
+ npc->init = do_init_npc;
+ npc->final = do_final_npc;
+ /* */
+ npc->get_new_npc_id = npc_get_new_npc_id;
+ npc->get_viewdata = npc_get_viewdata;
+ npc->isnear_sub = npc_isnear_sub;
+ npc->isnear = npc_isnear;
+ npc->ontouch_event = npc_ontouch_event;
+ npc->ontouch2_event = npc_ontouch2_event;
+ npc->enable_sub = npc_enable_sub;
+ npc->enable = npc_enable;
+ npc->name2id = npc_name2id;
+ npc->event_dequeue = npc_event_dequeue;
+ npc->event_export_create = npc_event_export_create;
+ npc->event_export = npc_event_export;
+ npc->event_sub = npc_event_sub;
+ npc->event_doall_sub = npc_event_doall_sub;
+ npc->event_do = npc_event_do;
+ npc->event_doall_id = npc_event_doall_id;
+ npc->event_doall = npc_event_doall;
+ npc->event_do_clock = npc_event_do_clock;
+ npc->event_do_oninit = npc_event_do_oninit;
+ npc->timerevent_export = npc_timerevent_export;
+ npc->timerevent = npc_timerevent;
+ npc->timerevent_start = npc_timerevent_start;
+ npc->timerevent_stop = npc_timerevent_stop;
+ npc->timerevent_quit = npc_timerevent_quit;
+ npc->gettimerevent_tick = npc_gettimerevent_tick;
+ npc->settimerevent_tick = npc_settimerevent_tick;
+ npc->event = npc_event;
+ npc->touch_areanpc_sub = npc_touch_areanpc_sub;
+ npc->touchnext_areanpc = npc_touchnext_areanpc;
+ npc->touch_areanpc = npc_touch_areanpc;
+ npc->touch_areanpc2 = npc_touch_areanpc2;
+ npc->check_areanpc = npc_check_areanpc;
+ npc->checknear = npc_checknear;
+ npc->globalmessage = npc_globalmessage;
+ npc->run_tomb = run_tomb;
+ npc->click = npc_click;
+ npc->scriptcont = npc_scriptcont;
+ npc->buysellsel = npc_buysellsel;
+ npc->cashshop_buylist = npc_cashshop_buylist;
+ npc->buylist_sub = npc_buylist_sub;
+ npc->cashshop_buy = npc_cashshop_buy;
+ npc->buylist = npc_buylist;
+ npc->selllist_sub = npc_selllist_sub;
+ npc->selllist = npc_selllist;
+ npc->remove_map = npc_remove_map;
+ npc->unload_ev = npc_unload_ev;
+ npc->unload_ev_label = npc_unload_ev_label;
+ npc->unload_dup_sub = npc_unload_dup_sub;
+ npc->unload_duplicates = npc_unload_duplicates;
+ npc->unload = npc_unload;
+ npc->clearsrcfile = npc_clearsrcfile;
+ npc->addsrcfile = npc_addsrcfile;
+ npc->delsrcfile = npc_delsrcfile;
+ npc->parsename = npc_parsename;
+ npc->add_warp = npc_add_warp;
+ npc->parse_warp = npc_parse_warp;
+ npc->parse_shop = npc_parse_shop;
+ npc->convertlabel_db = npc_convertlabel_db;
+ npc->skip_script = npc_skip_script;
+ npc->parse_script = npc_parse_script;
+ npc->parse_duplicate = npc_parse_duplicate;
+ npc->duplicate4instance = npc_duplicate4instance;
+ npc->setcells = npc_setcells;
+ npc->unsetcells_sub = npc_unsetcells_sub;
+ npc->unsetcells = npc_unsetcells;
+ npc->movenpc = npc_movenpc;
+ npc->setdisplayname = npc_setdisplayname;
+ npc->setclass = npc_setclass;
+ npc->do_atcmd_event = npc_do_atcmd_event;
+ npc->parse_function = npc_parse_function;
+ npc->parse_mob2 = npc_parse_mob2;
+ npc->parse_mob = npc_parse_mob;
+ npc->parse_mapflag = npc_parse_mapflag;
+ npc->parsesrcfile = npc_parsesrcfile;
+ npc->script_event = npc_script_event;
+ npc->read_event_script = npc_read_event_script;
+ npc->path_db_clear_sub = npc_path_db_clear_sub;
+ npc->ev_label_db_clear_sub = npc_ev_label_db_clear_sub;
+ npc->reload = npc_reload;
+ npc->unloadfile = npc_unloadfile;
+ npc->do_clear_npc = do_clear_npc;
+ npc->debug_warps_sub = npc_debug_warps_sub;
+ npc->debug_warps = npc_debug_warps;
+#ifdef SECURE_NPCTIMEOUT
+ npc->secure_timeout_timer = npc_rr_secure_timeout_timer;
+#endif
}
diff --git a/src/map/npc.h b/src/map/npc.h
index 48c27b297..6c1ca0972 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -12,8 +12,6 @@ struct block_list;
struct npc_data;
struct view_data;
-struct unit_data npc_base_ud;
-
struct npc_timerevent_list {
int timer,pos;
};
@@ -82,8 +80,7 @@ struct npc_data {
#define START_NPC_NUM 110000000
-enum actor_classes
-{
+enum actor_classes {
WARP_CLASS = 45,
HIDDEN_WARP_CLASS = 139,
WARP_DEBUG_CLASS = 722,
@@ -101,10 +98,6 @@ enum actor_classes
//Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001)
#define npcdb_checkid(id) ( ( (id) >= 46 && (id) <= 125) || (id) == HIDDEN_WARP_CLASS || ( (id) > 400 && (id) < MAX_NPC_CLASS ) || (id) == INVISIBLE_CLASS || ( (id) > MAX_NPC_CLASS2_START && (id) < MAX_NPC_CLASS2_END ) )
-#ifdef PCRE_SUPPORT
-void npc_chat_finalize(struct npc_data* nd);
-#endif
-
//Script NPC events.
enum npce_event {
NPCE_LOGIN,
@@ -117,89 +110,184 @@ enum npce_event {
NPCE_KILLNPC,
NPCE_MAX
};
-struct view_data* npc_get_viewdata(int class_);
-int npc_chat_sub(struct block_list* bl, va_list ap);
-int npc_event_dequeue(struct map_session_data* sd);
-int npc_event(struct map_session_data* sd, const char* eventname, int ontouch);
-int npc_touch_areanpc(struct map_session_data* sd, int16 m, int16 x, int16 y);
-int npc_touch_areanpc2(struct mob_data *md); // [Skotlex]
-int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range);
-int npc_touchnext_areanpc(struct map_session_data* sd,bool leavemap);
-int npc_click(struct map_session_data* sd, struct npc_data* nd);
-int npc_scriptcont(struct map_session_data* sd, int id, bool closing);
-struct npc_data* npc_checknear(struct map_session_data* sd, struct block_list* bl);
-int npc_buysellsel(struct map_session_data* sd, int id, int type);
-int npc_buylist(struct map_session_data* sd,int n, unsigned short* item_list);
-int npc_selllist(struct map_session_data* sd, int n, unsigned short* item_list);
-void npc_parse_mob2(struct spawn_data* mob);
-const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char* start, const char* buffer, const char* filepath);
-struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y);
-int npc_globalmessage(const char* name,const char* mes);
-
-void npc_setcells(struct npc_data* nd);
-void npc_unsetcells(struct npc_data* nd);
-void npc_movenpc(struct npc_data* nd, int16 x, int16 y);
-int npc_enable(const char* name, int flag);
-void npc_setdisplayname(struct npc_data* nd, const char* newname);
-void npc_setclass(struct npc_data* nd, short class_);
-struct npc_data* npc_name2id(const char* name);
-bool npc_isnear(struct block_list * bl);
-
-int npc_get_new_npc_id(void);
-
-void npc_addsrcfile(const char* name);
-void npc_delsrcfile(const char* name);
-void npc_parsesrcfile(const char* filepath, bool runOnInit);
-void do_clear_npc(void);
-int do_final_npc(void);
-int do_init_npc(void);
-void npc_event_do_oninit(void);
-int npc_do_ontimer(int npc_id, int option);
-
-int npc_event_do(const char* name);
-int npc_event_doall(const char* name);
-int npc_event_doall_id(const char* name, int rid);
-
-int npc_timerevent_start(struct npc_data* nd, int rid);
-int npc_timerevent_stop(struct npc_data* nd);
-void npc_timerevent_quit(struct map_session_data* sd);
-int npc_gettimerevent_tick(struct npc_data* nd);
-int npc_settimerevent_tick(struct npc_data* nd, int newtimer);
-int npc_remove_map(struct npc_data* nd);
-void npc_unload_duplicates (struct npc_data* nd);
-int npc_unload(struct npc_data* nd, bool single);
-int npc_reload(void);
-void npc_read_event_script(void);
-int npc_script_event(struct map_session_data* sd, enum npce_event type);
-
-int npc_duplicate4instance(struct npc_data *snd, int16 m);
-int npc_cashshop_buy(struct map_session_data *sd, int nameid, int amount, int points);
-
-extern struct npc_data* fake_nd;
-
-int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, unsigned short* item_list);
-
-/**
- * For the Secure NPC Timeout option (check config/Secure.h) [RR]
- **/
-#ifdef SECURE_NPCTIMEOUT
- int npc_rr_secure_timeout_timer(int tid, unsigned int tick, int id, intptr_t data);
-#endif
-// @commands (script-based)
-int npc_do_atcmd_event(struct map_session_data* sd, const char* command, const char* message, const char* eventname);
+// linked list of npc source files
+struct npc_src_list {
+ struct npc_src_list* next;
+ char name[4]; // dynamic array, the structure is allocated with extra bytes (string length)
+};
+
+struct event_data {
+ struct npc_data *nd;
+ int pos;
+};
-bool npc_unloadfile( const char* path );
+struct npc_path_data {
+ char* path;
+ unsigned short references;
+};
-/* npc.c interface (barely started/WIP) */
+/* npc.c interface */
struct npc_interface {
/* */
struct npc_data *motd;
+ DBMap *ev_db; // const char* event_name -> struct event_data*
+ DBMap *ev_label_db; // const char* label_name (without leading "::") -> struct linkdb_node** (key: struct npc_data*; data: struct event_data*)
+ DBMap *name_db; // const char* npc_name -> struct npc_data*
+ DBMap *path_db;
+ struct eri *timer_event_ers; //For the npc timer data. [Skotlex]
+ struct npc_data *fake_nd;
+ struct npc_src_list *src_files;
+ struct unit_data base_ud;
/* */
-} npc_s;
+ int (*init) (void);
+ int (*final) (void);
+ /* */
+ int (*get_new_npc_id) (void);
+ struct view_data* (*get_viewdata) (int class_);
+ int (*isnear_sub) (struct block_list *bl, va_list args);
+ bool (*isnear) (struct block_list *bl);
+ int (*ontouch_event) (struct map_session_data *sd, struct npc_data *nd);
+ int (*ontouch2_event) (struct map_session_data *sd, struct npc_data *nd);
+ int (*enable_sub) (struct block_list *bl, va_list ap);
+ int (*enable) (const char *name, int flag);
+ struct npc_data* (*name2id) (const char *name);
+ int (*event_dequeue) (struct map_session_data *sd);
+ DBData (*event_export_create) (DBKey key, va_list args);
+ int (*event_export) (struct npc_data *nd, int i);
+ int (*event_sub) (struct map_session_data *sd, struct event_data *ev, const char *eventname);
+ void (*event_doall_sub) (void *key, void *data, va_list ap);
+ int (*event_do) (const char *name);
+ int (*event_doall_id) (const char *name, int rid);
+ int (*event_doall) (const char *name);
+ int (*event_do_clock) (int tid, unsigned int tick, int id, intptr_t data);
+ void (*event_do_oninit) (void);
+ int (*timerevent_export) (struct npc_data *nd, int i);
+ int (*timerevent) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*timerevent_start) (struct npc_data *nd, int rid);
+ int (*timerevent_stop) (struct npc_data *nd);
+ void (*timerevent_quit) (struct map_session_data *sd);
+ int (*gettimerevent_tick) (struct npc_data *nd);
+ int (*settimerevent_tick) (struct npc_data *nd, int newtimer);
+ int (*event) (struct map_session_data *sd, const char *eventname, int ontouch);
+ int (*touch_areanpc_sub) (struct block_list *bl, va_list ap);
+ int (*touchnext_areanpc) (struct map_session_data *sd, bool leavemap);
+ int (*touch_areanpc) (struct map_session_data *sd, int16 m, int16 x, int16 y);
+ int (*touch_areanpc2) (struct mob_data *md);
+ int (*check_areanpc) (int flag, int16 m, int16 x, int16 y, int16 range);
+ struct npc_data* (*checknear) (struct map_session_data *sd, struct block_list *bl);
+ int (*globalmessage) (const char *name, const char *mes);
+ void (*run_tomb) (struct map_session_data *sd, struct npc_data *nd);
+ int (*click) (struct map_session_data *sd, struct npc_data *nd);
+ int (*scriptcont) (struct map_session_data *sd, int id, bool closing);
+ int (*buysellsel) (struct map_session_data *sd, int id, int type);
+ int (*cashshop_buylist) (struct map_session_data *sd, int points, int count, unsigned short *item_list);
+ int (*buylist_sub) (struct map_session_data *sd, int n, unsigned short *item_list, struct npc_data *nd);
+ int (*cashshop_buy) (struct map_session_data *sd, int nameid, int amount, int points);
+ int (*buylist) (struct map_session_data *sd, int n, unsigned short *item_list);
+ int (*selllist_sub) (struct map_session_data *sd, int n, unsigned short *item_list, struct npc_data *nd);
+ int (*selllist) (struct map_session_data *sd, int n, unsigned short *item_list);
+ int (*remove_map) (struct npc_data *nd);
+ int (*unload_ev) (DBKey key, DBData *data, va_list ap);
+ int (*unload_ev_label) (DBKey key, DBData *data, va_list ap);
+ int (*unload_dup_sub) (struct npc_data *nd, va_list args);
+ void (*unload_duplicates) (struct npc_data *nd);
+ int (*unload) (struct npc_data *nd, bool single);
+ void (*clearsrcfile) (void);
+ void (*addsrcfile) (const char *name);
+ void (*delsrcfile) (const char *name);
+ void (*parsename) (struct npc_data *nd, const char *name, const char *start, const char *buffer, const char *filepath);
+ struct npc_data* (*add_warp) (char *name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y);
+ const char* (*parse_warp) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath);
+ const char* (*parse_shop) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath);
+ void (*convertlabel_db) (struct npc_label_list *label_list, const char *filepath);
+ const char* (*skip_script) (const char *start, const char *buffer, const char *filepath);
+ const char* (*parse_script) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath, bool runOnInit);
+ const char* (*parse_duplicate) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath);
+ int (*duplicate4instance) (struct npc_data *snd, int16 m);
+ void (*setcells) (struct npc_data *nd);
+ int (*unsetcells_sub) (struct block_list *bl, va_list ap);
+ void (*unsetcells) (struct npc_data *nd);
+ void (*movenpc) (struct npc_data *nd, int16 x, int16 y);
+ void (*setdisplayname) (struct npc_data *nd, const char *newname);
+ void (*setclass) (struct npc_data *nd, short class_);
+ int (*do_atcmd_event) (struct map_session_data *sd, const char *command, const char *message, const char *eventname);
+ const char* (*parse_function) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath);
+ void (*parse_mob2) (struct spawn_data *mob);
+ const char* (*parse_mob) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath);
+ const char* (*parse_mapflag) (char *w1, char *w2, char *w3, char *w4, const char *start, const char *buffer, const char *filepath);
+ void (*parsesrcfile) (const char *filepath, bool runOnInit);
+ int (*script_event) (struct map_session_data *sd, enum npce_event type);
+ void (*read_event_script) (void);
+ int (*path_db_clear_sub) (DBKey key, DBData *data, va_list args);
+ int (*ev_label_db_clear_sub) (DBKey key, DBData *data, va_list args);
+ int (*reload) (void);
+ bool (*unloadfile) (const char *path);
+ void (*do_clear_npc) (void);
+ void (*debug_warps_sub) (struct npc_data *nd);
+ void (*debug_warps) (void);
+ /**
+ * For the Secure NPC Timeout option (check config/Secure.h) [RR]
+ **/
+#ifdef SECURE_NPCTIMEOUT
+ int (*secure_timeout_timer) (int tid, unsigned int tick, int id, intptr_t data);
+#endif
+};
struct npc_interface *npc;
void npc_defaults(void);
+
+/* comes from npc_chat.c */
+#ifdef PCRE_SUPPORT
+#include "../../3rdparty/pcre/include/pcre.h"
+/* Structure containing all info associated with a single pattern block */
+struct pcrematch_entry {
+ struct pcrematch_entry* next;
+ char* pattern;
+ pcre* pcre_;
+ pcre_extra* pcre_extra_;
+ char* label;
+};
+
+/* A set of patterns that can be activated and deactived with a single command */
+struct pcrematch_set {
+ struct pcrematch_set* prev;
+ struct pcrematch_set* next;
+ struct pcrematch_entry* head;
+ int setid;
+};
+
+/*
+ * Entire data structure hung off a NPC
+ *
+ * The reason I have done it this way (a void * in npc_data and then
+ * this) was to reduce the number of patches that needed to be applied
+ * to a ragnarok distribution to bring this code online. I
+ * also wanted people to be able to grab this one file to get updates
+ * without having to do a large number of changes.
+ */
+struct npc_parse {
+ struct pcrematch_set* active;
+ struct pcrematch_set* inactive;
+};
+
+struct npc_chat_interface {
+ int (*sub) (struct block_list* bl, va_list ap);
+ void (*finalize) (struct npc_data* nd);
+ void (*def_pattern) (struct npc_data* nd, int setid, const char* pattern, const char* label);
+ struct pcrematch_entry* (*create_pcrematch_entry) (struct pcrematch_set* set);
+ void (*delete_pcreset) (struct npc_data* nd, int setid);
+ void (*deactivate_pcreset) (struct npc_data* nd, int setid);
+ void (*activate_pcreset) (struct npc_data* nd, int setid);
+ struct pcrematch_set* (*lookup_pcreset) (struct npc_data* nd, int setid);
+ void (*finalize_pcrematch_entry) (struct pcrematch_entry* e);
+};
+
+struct npc_chat_interface *npc_chat;
+
+void npc_chat_defaults(void);
+#endif
+
#endif /* _NPC_H_ */
diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c
index f6459e1ae..848347888 100644
--- a/src/map/npc_chat.c
+++ b/src/map/npc_chat.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <stdarg.h>
+struct npc_chat_interface npc_chat_s;
/**
* Written by MouseJstr in a vision... (2/21/2005)
@@ -70,37 +71,6 @@
* deletes a pset
*/
-/* Structure containing all info associated with a single pattern block */
-struct pcrematch_entry {
- struct pcrematch_entry* next;
- char* pattern;
- pcre* pcre_;
- pcre_extra* pcre_extra_;
- char* label;
-};
-
-/* A set of patterns that can be activated and deactived with a single command */
-struct pcrematch_set {
- struct pcrematch_set* prev;
- struct pcrematch_set* next;
- struct pcrematch_entry* head;
- int setid;
-};
-
-/*
- * Entire data structure hung off a NPC
- *
- * The reason I have done it this way (a void * in npc_data and then
- * this) was to reduce the number of patches that needed to be applied
- * to a ragnarok distribution to bring this code online. I
- * also wanted people to be able to grab this one file to get updates
- * without having to do a large number of changes.
- */
-struct npc_parse {
- struct pcrematch_set* active;
- struct pcrematch_set* inactive;
-};
-
/**
* delete everythign associated with a entry
@@ -118,7 +88,7 @@ void finalize_pcrematch_entry(struct pcrematch_entry* e)
/**
* Lookup (and possibly create) a new set of patterns by the set id
*/
-static struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid)
+struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid)
{
struct pcrematch_set *pcreset;
struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
@@ -159,7 +129,7 @@ static struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid)
*
* if the setid does not exist, this will silently return
*/
-static void activate_pcreset(struct npc_data* nd, int setid)
+void activate_pcreset(struct npc_data* nd, int setid)
{
struct pcrematch_set *pcreset;
struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
@@ -192,7 +162,7 @@ static void activate_pcreset(struct npc_data* nd, int setid)
*
* if the setid does not exist, this will silently return
*/
-static void deactivate_pcreset(struct npc_data* nd, int setid)
+void deactivate_pcreset(struct npc_data* nd, int setid)
{
struct pcrematch_set *pcreset;
struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
@@ -200,7 +170,7 @@ static void deactivate_pcreset(struct npc_data* nd, int setid)
return; // Nothing to deactivate...
if (setid == -1) {
while(npcParse->active != NULL)
- deactivate_pcreset(nd, npcParse->active->setid);
+ npc_chat->deactivate_pcreset(nd, npcParse->active->setid);
return;
}
pcreset = npcParse->active;
@@ -228,7 +198,7 @@ static void deactivate_pcreset(struct npc_data* nd, int setid)
/**
* delete a set of patterns.
*/
-static void delete_pcreset(struct npc_data* nd, int setid)
+void delete_pcreset(struct npc_data* nd, int setid)
{
int active = 1;
struct pcrematch_set *pcreset;
@@ -268,7 +238,7 @@ static void delete_pcreset(struct npc_data* nd, int setid)
while (pcreset->head) {
struct pcrematch_entry* n = pcreset->head->next;
- finalize_pcrematch_entry(pcreset->head);
+ npc_chat->finalize_pcrematch_entry(pcreset->head);
aFree(pcreset->head); // Cleanin' the last ones.. [Lance]
pcreset->head = n;
}
@@ -279,7 +249,7 @@ static void delete_pcreset(struct npc_data* nd, int setid)
/**
* create a new pattern entry
*/
-static struct pcrematch_entry* create_pcrematch_entry(struct pcrematch_set* set)
+struct pcrematch_entry* create_pcrematch_entry(struct pcrematch_set* set)
{
struct pcrematch_entry * e = (struct pcrematch_entry *) aCalloc(sizeof(struct pcrematch_entry), 1);
struct pcrematch_entry * last = set->head;
@@ -313,8 +283,8 @@ void npc_chat_def_pattern(struct npc_data* nd, int setid, const char* pattern, c
const char *err;
int erroff;
- struct pcrematch_set * s = lookup_pcreset(nd, setid);
- struct pcrematch_entry *e = create_pcrematch_entry(s);
+ struct pcrematch_set * s = npc_chat->lookup_pcreset(nd, setid);
+ struct pcrematch_entry *e = npc_chat->create_pcrematch_entry(s);
e->pattern = aStrdup(pattern);
e->label = aStrdup(label);
e->pcre_ = pcre_compile(pattern, PCRE_CASELESS, &err, &erroff, NULL);
@@ -334,10 +304,10 @@ void npc_chat_finalize(struct npc_data* nd)
return;
while(npcParse->active)
- delete_pcreset(nd, npcParse->active->setid);
+ npc_chat->delete_pcreset(nd, npcParse->active->setid);
while(npcParse->inactive)
- delete_pcreset(nd, npcParse->inactive->setid);
+ npc_chat->delete_pcreset(nd, npcParse->inactive->setid);
// Additional cleaning up [Lance]
aFree(npcParse);
@@ -390,7 +360,7 @@ int npc_chat_sub(struct block_list* bl, va_list ap)
lst = nd->u.scr.label_list;
ARR_FIND(0, nd->u.scr.label_list_num, i, strncmp(lst[i].name, e->label, sizeof(lst[i].name)) == 0);
if (i == nd->u.scr.label_list_num) {
- ShowWarning("Unable to find label: %s\n", e->label);
+ ShowWarning("npc_chat_sub: Unable to find label: %s\n", e->label);
return 0;
}
@@ -405,47 +375,56 @@ int npc_chat_sub(struct block_list* bl, va_list ap)
}
// Various script builtins used to support these functions
-
-int buildin_defpattern(struct script_state* st)
-{
- int setid = script->conv_num(st,& (st->stack->stack_data[st->start+2]));
- const char* pattern = script->conv_str(st,& (st->stack->stack_data[st->start+3]));
- const char* label = script->conv_str(st,& (st->stack->stack_data[st->start+4]));
+BUILDIN(defpattern) {
+ int setid = script_getnum(st,2);
+ const char* pattern = script_getstr(st,3);
+ const char* label = script_getstr(st,4);
struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid);
- npc_chat_def_pattern(nd, setid, pattern, label);
-
- return 1;
+ npc_chat->def_pattern(nd, setid, pattern, label);
+
+ return true;
}
-int buildin_activatepset(struct script_state* st)
-{
- int setid = script->conv_num(st,& (st->stack->stack_data[st->start+2]));
+BUILDIN(activatepset) {
+ int setid = script_getnum(st,2);
struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid);
- activate_pcreset(nd, setid);
-
- return 1;
+ npc_chat->activate_pcreset(nd, setid);
+
+ return true;
}
-int buildin_deactivatepset(struct script_state* st)
-{
- int setid = script->conv_num(st,& (st->stack->stack_data[st->start+2]));
+BUILDIN(deactivatepset) {
+ int setid = script_getnum(st,2);
struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid);
- deactivate_pcreset(nd, setid);
+ npc_chat->deactivate_pcreset(nd, setid);
- return 1;
+ return true;
}
-int buildin_deletepset(struct script_state* st)
-{
- int setid = script->conv_num(st,& (st->stack->stack_data[st->start+2]));
+BUILDIN(deletepset) {
+ int setid = script_getnum(st,2);
struct npc_data* nd = (struct npc_data *)iMap->id2bl(st->oid);
- delete_pcreset(nd, setid);
-
- return 1;
+ npc_chat->delete_pcreset(nd, setid);
+
+ return true;
+}
+
+void npc_chat_defaults(void) {
+ npc_chat = &npc_chat_s;
+
+ npc_chat->sub = npc_chat_sub;
+ npc_chat->finalize = npc_chat_finalize;
+ npc_chat->def_pattern = npc_chat_def_pattern;
+ npc_chat->create_pcrematch_entry = create_pcrematch_entry;
+ npc_chat->delete_pcreset = delete_pcreset;
+ npc_chat->deactivate_pcreset = deactivate_pcreset;
+ npc_chat->activate_pcreset = activate_pcreset;
+ npc_chat->lookup_pcreset = lookup_pcreset;
+ npc_chat->finalize_pcrematch_entry = finalize_pcrematch_entry;
}
#endif //PCRE_SUPPORT
diff --git a/src/map/path.c b/src/map/path.c
index 32a4189bb..2de3eab00 100644
--- a/src/map/path.c
+++ b/src/map/path.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/cbasetypes.h"
#include "../common/db.h"
@@ -23,6 +24,8 @@
#define DIR_SOUTH 4
#define DIR_EAST 8
+struct path_interface path_s;
+
/// @name Structures and defines for A* pathfinding
/// @{
@@ -458,3 +461,12 @@ unsigned int distance(int dx, int dy)
return (dx<dy?dy:dx);
#endif
}
+void path_defaults(void) {
+ path = &path_s;
+
+ path->blownpos = path_blownpos;
+ path->search_long = path_search_long;
+ path->search = path_search;
+ path->check_distance = check_distance;
+ path->distance = distance;
+}
diff --git a/src/map/path.h b/src/map/path.h
index 5bc551dc9..e872c8877 100644
--- a/src/map/path.h
+++ b/src/map/path.h
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _PATH_H_
#define _PATH_H_
@@ -22,25 +23,27 @@ struct shootpath_data {
int y[MAX_WALKPATH];
};
-// calculates destination cell for knockback
-int path_blownpos(int16 m,int16 x0,int16 y0,int16 dx,int16 dy,int count);
-
-// tries to find a walkable path
-bool path_search(struct walkpath_data *wpd,int16 m,int16 x0,int16 y0,int16 x1,int16 y1,int flag,cell_chk cell);
-
-// tries to find a shootable path
-bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16 x1,int16 y1,cell_chk cell);
-
+#define check_distance_bl(bl1, bl2, distance) path->check_distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y, distance)
+#define check_distance_blxy(bl, x1, y1, distance) path->check_distance((bl)->x-(x1), (bl)->y-(y1), distance)
+#define check_distance_xy(x0, y0, x1, y1, distance) path->check_distance((x0)-(x1), (y0)-(y1), distance)
+
+#define distance_bl(bl1, bl2) path->distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y)
+#define distance_blxy(bl, x1, y1) path->distance((bl)->x-(x1), (bl)->y-(y1))
+#define distance_xy(x0, y0, x1, y1) path->distance((x0)-(x1), (y0)-(y1))
+
+struct path_interface {
+ // calculates destination cell for knockback
+ int (*blownpos) (int16 m, int16 x0, int16 y0, int16 dx, int16 dy, int count);
+ // tries to find a walkable path
+ bool (*search) (struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int flag, cell_chk cell);
+ // tries to find a shootable path
+ bool (*search_long) (struct shootpath_data *spd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, cell_chk cell);
+ int (*check_distance) (int dx, int dy, int distance);
+ unsigned int (*distance) (int dx, int dy);
+};
-// distance related functions
-int check_distance(int dx, int dy, int distance);
-#define check_distance_bl(bl1, bl2, distance) check_distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y, distance)
-#define check_distance_blxy(bl, x1, y1, distance) check_distance((bl)->x-(x1), (bl)->y-(y1), distance)
-#define check_distance_xy(x0, y0, x1, y1, distance) check_distance((x0)-(x1), (y0)-(y1), distance)
+struct path_interface *path;
-unsigned int distance(int dx, int dy);
-#define distance_bl(bl1, bl2) distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y)
-#define distance_blxy(bl, x1, y1) distance((bl)->x-(x1), (bl)->y-(y1))
-#define distance_xy(x0, y0, x1, y1) distance((x0)-(x1), (y0)-(y1))
+void path_defaults(void);
#endif /* _PATH_H_ */
diff --git a/src/map/pc.c b/src/map/pc.c
index d2740c76a..995687170 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -648,7 +648,7 @@ int pc_equippoint(struct map_session_data *sd,int n)
if(!sd->inventory_data[n])
return 0;
- if (!itemdb_isequip2(sd->inventory_data[n]))
+ if (!itemdb->isequip2(sd->inventory_data[n]))
return 0; //Not equippable by players.
ep = sd->inventory_data[n]->equip;
@@ -1078,7 +1078,7 @@ bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_tim
//Set here because we need the inventory data for weapon sprite parsing.
iStatus->set_viewdata(&sd->bl, sd->status.class_);
- unit_dataset(&sd->bl);
+ unit->dataset(&sd->bl);
sd->guild_x = -1;
sd->guild_y = -1;
@@ -1330,7 +1330,7 @@ int pc_reg_received(struct map_session_data *sd)
}
if( npc->motd ) /* [Ind/Hercules] */
- script->run(npc->motd->u.scr.script, 0, sd->bl.id, fake_nd->bl.id);
+ script->run(npc->motd->u.scr.script, 0, sd->bl.id, npc->fake_nd->bl.id);
return 1;
}
@@ -3695,7 +3695,7 @@ int pc_checkadditem(struct map_session_data *sd,int nameid,int amount)
data = itemdb->search(nameid);
- if(!itemdb_isstackable2(data))
+ if(!itemdb->isstackable2(data))
return ADDITEM_NEW;
if( data->stack.inventory && amount > data->stack.amount )
@@ -3941,7 +3941,7 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
i = MAX_INVENTORY;
- if( itemdb_isstackable2(data) && item_data->expire_time == 0 )
+ if( itemdb->isstackable2(data) && item_data->expire_time == 0 )
{ // Stackable | Non Rental
for( i = 0; i < MAX_INVENTORY; i++ )
{
@@ -3972,8 +3972,8 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
clif->additem(sd,i,amount,0);
}
#ifdef NSI_UNIQUE_ID
- if( !itemdb_isstackable2(data) && !item_data->unique_id )
- sd->status.inventory[i].unique_id = itemdb_unique_id(0,0);
+ if( !itemdb->isstackable2(data) && !item_data->unique_id )
+ sd->status.inventory[i].unique_id = itemdb->unique_id(0,0);
#endif
logs->pick_pc(sd, log_type, amount, &sd->status.inventory[i],sd->inventory_data[i]);
@@ -4472,7 +4472,7 @@ int pc_useitem(struct map_session_data *sd,int n) {
script->current_item_id = nameid;
- script->run(item_script,0,sd->bl.id,fake_nd->bl.id);
+ script->run(item_script,0,sd->bl.id,npc->fake_nd->bl.id);
script->current_item_id = 0;
script->potion_flag = 0;
@@ -4513,7 +4513,7 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
return 1;
i = MAX_CART;
- if( itemdb_isstackable2(data) && !item_data->expire_time )
+ if( itemdb->isstackable2(data) && !item_data->expire_time )
{
ARR_FIND( 0, MAX_CART, i,
sd->status.cart[i].nameid == item_data->nameid &&
@@ -4727,7 +4727,7 @@ int pc_steal_item(struct map_session_data *sd,struct block_list *bl, uint16 skil
memset(&tmp_item,0,sizeof(tmp_item));
tmp_item.nameid = itemid;
tmp_item.amount = 1;
- tmp_item.identify = itemdb_isidentified2(data);
+ tmp_item.identify = itemdb->isidentified2(data);
flag = pc->additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER);
//TODO: Should we disable stealing when the item you stole couldn't be added to your inventory? Perhaps players will figure out a way to exploit this behaviour otherwise?
@@ -4870,7 +4870,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
struct hQueue *queue;
if( (queue = script->queue(sd->queues[i])) && queue->onMapChange[0] != '\0' ) {
pc->setregstr(sd, script->add_str("QMapChangeTo"), map[m].name);
- npc_event(sd, queue->onMapChange, 0);
+ npc->event(sd, queue->onMapChange, 0);
}
}
@@ -4904,7 +4904,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
skill->clear_unitgroup(&sd->bl);
party->send_dot_remove(sd); //minimap dot fix [Kevin]
guild->send_dot_remove(sd);
- bg_send_dot_remove(sd);
+ bg->send_dot_remove(sd);
if (sd->regen.state.gc)
sd->regen.state.gc = 0;
// make sure vending is allowed here
@@ -4926,10 +4926,10 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
return 2;
if (sd->npc_id)
- npc_event_dequeue(sd);
- npc_script_event(sd, NPCE_LOGOUT);
+ npc->event_dequeue(sd);
+ npc->script_event(sd, NPCE_LOGOUT);
//remove from map, THEN change x/y coordinates
- unit_remove_map_pc(sd,clrtype);
+ unit->remove_map_pc(sd,clrtype);
sd->mapindex = mapindex;
sd->bl.x=x;
sd->bl.y=y;
@@ -4938,7 +4938,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
chrif->changemapserver(sd, ip, (short)port);
//Free session data from this map server [Kevin]
- unit_free_pc(sd);
+ unit->free_pc(sd);
return 0;
}
@@ -4961,7 +4961,7 @@ int pc_setpos(struct map_session_data* sd, unsigned short mapindex, int x, int y
}
if(sd->bl.prev != NULL){
- unit_remove_map_pc(sd,clrtype);
+ unit->remove_map_pc(sd,clrtype);
clif->changemap(sd,m,x,y); // [MouseJstr]
} else if(sd->state.active)
//Tag player for rewarping after map-loading is done. [Skotlex]
@@ -5726,9 +5726,9 @@ int pc_follow_timer(int tid, unsigned int tick, int id, intptr_t data)
if (sd->bl.prev != NULL && tbl->prev != NULL &&
sd->ud.skilltimer == INVALID_TIMER && sd->ud.attacktimer == INVALID_TIMER && sd->ud.walktimer == INVALID_TIMER)
{
- if((sd->bl.m == tbl->m) && unit_can_reach_bl(&sd->bl,tbl, AREA_SIZE, 0, NULL, NULL)) {
+ if((sd->bl.m == tbl->m) && unit->can_reach_bl(&sd->bl,tbl, AREA_SIZE, 0, NULL, NULL)) {
if (!check_distance_bl(&sd->bl, tbl, 5))
- unit_walktobl(&sd->bl, tbl, 5, 0);
+ unit->walktobl(&sd->bl, tbl, 5, 0);
} else
pc->setpos(sd, map_id2index(tbl->m), tbl->x, tbl->y, CLR_TELEPORT);
}
@@ -5749,7 +5749,7 @@ int pc_stop_following (struct map_session_data *sd)
sd->followtarget = -1;
sd->ud.target_to = 0;
- unit_stop_walking(&sd->bl, 1);
+ unit->stop_walking(&sd->bl, 1);
return 0;
}
@@ -5809,7 +5809,7 @@ int pc_checkbaselevelup(struct map_session_data *sd) {
sc_start(&sd->bl,iStatus->skill2sc(AL_BLESSING),100,10,600000);
}
clif->misceffect(&sd->bl,0);
- npc_script_event(sd, NPCE_BASELVUP); //LORDALFA - LVLUPEVENT
+ npc->script_event(sd, NPCE_BASELVUP); //LORDALFA - LVLUPEVENT
if(sd->status.party_id)
party->send_levelup(sd);
@@ -5858,7 +5858,7 @@ int pc_checkjoblevelup(struct map_session_data *sd)
if (pc->checkskill(sd, SG_DEVIL) && !pc->nextjobexp(sd))
clif->status_change(&sd->bl,SI_DEVIL1, 1, 0, 0, 0, 1); //Permanent blind effect from SG_DEVIL.
- npc_script_event(sd, NPCE_JOBLVUP);
+ npc->script_event(sd, NPCE_JOBLVUP);
return 1;
}
@@ -6652,7 +6652,7 @@ void pc_respawn(struct map_session_data* sd, clr_type clrtype)
{
if( !pc_isdead(sd) )
return; // not applicable
- if( sd->bg_id && bg_member_respawn(sd) )
+ if( sd->bg_id && bg->member_respawn(sd) )
return; // member revived by battleground
pc->setstand(sd);
@@ -6696,7 +6696,7 @@ void pc_damage(struct map_session_data *sd,struct block_list *src,unsigned int h
}
if( sd->status.pet_id > 0 && sd->pd && battle_config.pet_damage_support )
- pet_target_check(sd,src,1);
+ pet->target_check(sd,src,1);
if( sd->status.ele_id > 0 )
elemental->set_target(sd,src);
@@ -6722,13 +6722,13 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
if(sd->status.pet_id > 0 && sd->pd) {
struct pet_data *pd = sd->pd;
if( !map[sd->bl.m].flag.noexppenalty ) {
- pet_set_intimate(pd, pd->pet.intimate - pd->petDB->die);
+ pet->set_intimate(pd, pd->pet.intimate - pd->petDB->die);
if( pd->pet.intimate < 0 )
pd->pet.intimate = 0;
clif->send_petdata(sd,sd->pd,1,pd->pet.intimate);
}
if( sd->pd->target_id ) // Unlock all targets...
- pet_unlocktarget(sd->pd);
+ pet->unlocktarget(sd->pd);
}
if (sd->status.hom_id > 0){
@@ -6751,24 +6751,24 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
}
if (sd->npc_id && sd->st && sd->st->state != RUN)
- npc_event_dequeue(sd);
+ npc->event_dequeue(sd);
pc_setglobalreg(sd,"PC_DIE_COUNTER",sd->die_counter+1);
pc->setparam(sd, SP_KILLERRID, src?src->id:0);
if( sd->bg_id ) {/* TODO: purge when bgqueue is deemed ok */
- struct battleground_data *bg;
- if( (bg = bg_team_search(sd->bg_id)) != NULL && bg->die_event[0] )
- npc_event(sd, bg->die_event, 0);
+ struct battleground_data *bgd;
+ if( (bgd = bg->team_search(sd->bg_id)) != NULL && bgd->die_event[0] )
+ npc->event(sd, bgd->die_event, 0);
}
for( i = 0; i < sd->queues_count; i++ ) {
struct hQueue *queue;
if( (queue = script->queue(sd->queues[i])) && queue->onDeath[0] != '\0' )
- npc_event(sd, queue->onDeath, 0);
+ npc->event(sd, queue->onDeath, 0);
}
- npc_script_event(sd,NPCE_DIE);
+ npc->script_event(sd,NPCE_DIE);
// Clear anything NPC-related when you die and was interacting with one.
if (sd->npc_id || sd->npc_shopid) {
@@ -6813,7 +6813,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
{
struct mob_data *md=(struct mob_data *)src;
if(md->target_id==sd->bl.id)
- mob_unlocktarget(md,tick);
+ mob->unlocktarget(md,tick);
if(battle_config.mobs_level_up && md->status.hp &&
(unsigned int)md->level < pc->maxbaselv(sd) &&
!md->guardian_data && !md->special_state.ai// Guardians/summons should not level. [Skotlex]
@@ -6846,7 +6846,7 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
if (src && src->type == BL_PC) {
struct map_session_data *ssd = (struct map_session_data *)src;
pc->setparam(ssd, SP_KILLEDRID, sd->bl.id);
- npc_script_event(ssd, NPCE_KILLPC);
+ npc->script_event(ssd, NPCE_KILLPC);
if (battle_config.pk_mode&2) {
ssd->status.manner -= 5;
@@ -7032,8 +7032,8 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
iTimer->add_timer(tick+1, pc_respawn_timer, sd->bl.id, 0);
return 1|8;
} else if( sd->bg_id ) {
- struct battleground_data *bg = bg_team_search(sd->bg_id);
- if( bg && bg->mapindex > 0 ) { // Respawn by BG
+ struct battleground_data *bgd = bg->team_search(sd->bg_id);
+ if( bgd && bgd->mapindex > 0 ) { // Respawn by BG
iTimer->add_timer(tick+1000, pc_respawn_timer, sd->bl.id, 0);
return 1|8;
}
@@ -8327,7 +8327,7 @@ static int pc_eventtimer(int tid, unsigned int tick, int id, intptr_t data)
{
sd->eventtimer[i] = INVALID_TIMER;
sd->eventcount--;
- npc_event(sd,p,0);
+ npc->event(sd,p,0);
}
else
ShowError("pc_eventtimer: no such event timer\n");
@@ -8770,7 +8770,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
//OnEquip script [Skotlex]
if (id) {
if (id->equip_script)
- script->run(id->equip_script,0,sd->bl.id,fake_nd->bl.id);
+ script->run(id->equip_script,0,sd->bl.id,npc->fake_nd->bl.id);
if(itemdb_isspecial(sd->status.inventory[n].card[0]))
; //No cards
else {
@@ -8780,7 +8780,7 @@ int pc_equipitem(struct map_session_data *sd,int n,int req_pos)
continue;
if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) {
if( data->equip_script )
- script->run(data->equip_script,0,sd->bl.id,fake_nd->bl.id);
+ script->run(data->equip_script,0,sd->bl.id,npc->fake_nd->bl.id);
}
}
}
@@ -8937,7 +8937,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
//OnUnEquip script [Skotlex]
if (sd->inventory_data[n]) {
if (sd->inventory_data[n]->unequip_script)
- script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,fake_nd->bl.id);
+ script->run(sd->inventory_data[n]->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id);
if(itemdb_isspecial(sd->status.inventory[n].card[0]))
; //No cards
else {
@@ -8948,7 +8948,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int flag) {
if ( ( data = itemdb->exists(sd->status.inventory[n].card[i]) ) != NULL ) {
if( data->unequip_script )
- script->run(data->unequip_script,0,sd->bl.id,fake_nd->bl.id);
+ script->run(data->unequip_script,0,sd->bl.id,npc->fake_nd->bl.id);
}
}
diff --git a/src/map/pc.h b/src/map/pc.h
index 231f369d8..c8e7e17d5 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -645,8 +645,8 @@ enum equip_pos {
// Rune Knight Dragon
#define pc_isridingdragon(sd) ( (sd)->sc.option&OPTION_DRAGON )
-#define pc_stop_walking(sd, type) unit_stop_walking(&(sd)->bl, type)
-#define pc_stop_attack(sd) unit_stop_attack(&(sd)->bl)
+#define pc_stop_walking(sd, type) unit->stop_walking(&(sd)->bl, type)
+#define pc_stop_attack(sd) unit->stop_attack(&(sd)->bl)
//Weapon check considering dual wielding.
#define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \
diff --git a/src/map/pet.c b/src/map/pet.c
index ae8216fc2..8498517ef 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -34,14 +34,10 @@
#include <stdlib.h>
#include <string.h>
+struct pet_interface pet_s;
#define MIN_PETTHINKTIME 100
-struct s_pet_db pet_db[MAX_PET_DB];
-
-static struct eri *item_drop_ers; //For loot drops delay structures.
-static struct eri *item_drop_list_ers;
-
int pet_hungry_val(struct pet_data *pd)
{
nullpo_ret(pd);
@@ -74,16 +70,16 @@ void pet_set_intimate(struct pet_data *pd, int value)
int pet_create_egg(struct map_session_data *sd, int item_id)
{
- int pet_id = search_petDB_index(item_id, PET_EGG);
+ int pet_id = pet->search_petDB_index(item_id, PET_EGG);
if (pet_id < 0) return 0; //No pet egg here.
if (!pc->inventoryblank(sd)) return 0; // Inventory full
- sd->catch_target_class = pet_db[pet_id].class_;
+ sd->catch_target_class = pet->db[pet_id].class_;
intif->create_pet(sd->status.account_id, sd->status.char_id,
- (short)pet_db[pet_id].class_,
- (short)mob_db(pet_db[pet_id].class_)->lv,
- (short)pet_db[pet_id].EggID, 0,
- (short)pet_db[pet_id].intimate,
- 100, 0, 1, pet_db[pet_id].jname);
+ (short)pet->db[pet_id].class_,
+ (short)mob->db(pet->db[pet_id].class_)->lv,
+ (short)pet->db[pet_id].EggID, 0,
+ (short)pet->db[pet_id].intimate,
+ 100, 0, 1, pet->db[pet_id].jname);
return 1;
}
@@ -121,9 +117,9 @@ int pet_attackskill(struct pet_data *pd, int target_id)
inf = skill->get_inf(pd->a_skill->id);
if (inf & INF_GROUND_SKILL)
- unit_skilluse_pos(&pd->bl, bl->x, bl->y, pd->a_skill->id, pd->a_skill->lv);
+ unit->skilluse_pos(&pd->bl, bl->x, bl->y, pd->a_skill->id, pd->a_skill->lv);
else //Offensive self skill? Could be stuff like GX.
- unit_skilluse_id(&pd->bl,(inf&INF_SELF_SKILL?pd->bl.id:bl->id), pd->a_skill->id, pd->a_skill->lv);
+ unit->skilluse_id(&pd->bl,(inf&INF_SELF_SKILL?pd->bl.id:bl->id), pd->a_skill->id, pd->a_skill->lv);
return 1; //Skill invoked.
}
return 0;
@@ -187,12 +183,12 @@ int pet_sc_check(struct map_session_data *sd, int type)
|| pd->recovery->type != type )
return 1;
- pd->recovery->timer = iTimer->add_timer(iTimer->gettick()+pd->recovery->delay*1000,pet_recovery_timer,sd->bl.id,0);
+ pd->recovery->timer = iTimer->add_timer(iTimer->gettick()+pd->recovery->delay*1000,pet->recovery_timer,sd->bl.id,0);
return 0;
}
-static int pet_hungry(int tid, unsigned int tick, int id, intptr_t data)
+int pet_hungry(int tid, unsigned int tick, int id, intptr_t data)
{
struct map_session_data *sd;
struct pet_data *pd;
@@ -220,7 +216,7 @@ static int pet_hungry(int tid, unsigned int tick, int id, intptr_t data)
{
pet_stop_attack(pd);
pd->pet.hungry = 0;
- pet_set_intimate(pd, pd->pet.intimate - battle_config.pet_hungry_friendly_decrease);
+ pet->set_intimate(pd, pd->pet.intimate - battle_config.pet_hungry_friendly_decrease);
if( pd->pet.intimate <= 0 )
{
pd->pet.intimate = 0;
@@ -237,7 +233,7 @@ static int pet_hungry(int tid, unsigned int tick, int id, intptr_t data)
interval = pd->petDB->hungry_delay;
if(interval <= 0)
interval = 1;
- pd->pet_hungry_timer = iTimer->add_timer(tick+interval,pet_hungry,sd->bl.id,0);
+ pd->pet_hungry_timer = iTimer->add_timer(tick+interval,pet->hungry,sd->bl.id,0);
return 0;
}
@@ -248,14 +244,14 @@ int search_petDB_index(int key,int type)
for( i = 0; i < MAX_PET_DB; i++ )
{
- if(pet_db[i].class_ <= 0)
+ if(pet->db[i].class_ <= 0)
continue;
switch(type) {
- case PET_CLASS: if(pet_db[i].class_ == key) return i; break;
- case PET_CATCH: if(pet_db[i].itemID == key) return i; break;
- case PET_EGG: if(pet_db[i].EggID == key) return i; break;
- case PET_EQUIP: if(pet_db[i].AcceID == key) return i; break;
- case PET_FOOD: if(pet_db[i].FoodID == key) return i; break;
+ case PET_CLASS: if(pet->db[i].class_ == key) return i; break;
+ case PET_CATCH: if(pet->db[i].itemID == key) return i; break;
+ case PET_EGG: if(pet->db[i].EggID == key) return i; break;
+ case PET_EQUIP: if(pet->db[i].AcceID == key) return i; break;
+ case PET_FOOD: if(pet->db[i].FoodID == key) return i; break;
default:
return -1;
}
@@ -267,14 +263,14 @@ int pet_hungry_timer_delete(struct pet_data *pd)
{
nullpo_ret(pd);
if(pd->pet_hungry_timer != INVALID_TIMER) {
- iTimer->delete_timer(pd->pet_hungry_timer,pet_hungry);
+ iTimer->delete_timer(pd->pet_hungry_timer,pet->hungry);
pd->pet_hungry_timer = INVALID_TIMER;
}
return 1;
}
-static int pet_performance(struct map_session_data *sd, struct pet_data *pd)
+int pet_performance(struct map_session_data *sd, struct pet_data *pd)
{
int val;
@@ -287,16 +283,16 @@ static int pet_performance(struct map_session_data *sd, struct pet_data *pd)
pet_stop_walking(pd,2000<<8);
clif->send_petdata(NULL, pd, 4, rnd()%val + 1);
- pet_lootitem_drop(pd,NULL);
+ pet->lootitem_drop(pd,NULL);
return 1;
}
-static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd)
+int pet_return_egg(struct map_session_data *sd, struct pet_data *pd)
{
struct item tmp_item;
int flag;
- pet_lootitem_drop(pd,sd);
+ pet->lootitem_drop(pd,sd);
memset(&tmp_item,0,sizeof(tmp_item));
tmp_item.nameid = pd->petDB->EggID;
tmp_item.identify = 1;
@@ -309,7 +305,7 @@ static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd)
iMap->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
pd->pet.incuvate = 1;
- unit_free(&pd->bl,CLR_OUTSIGHT);
+ unit->free(&pd->bl,CLR_OUTSIGHT);
status_calc_pc(sd,0);
sd->status.pet_id = 0;
@@ -317,7 +313,7 @@ static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd)
return 1;
}
-int pet_data_init(struct map_session_data *sd, struct s_pet *pet)
+int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo)
{
struct pet_data *pd;
int i=0,interval=0;
@@ -326,43 +322,43 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *pet)
Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd);
- if(sd->status.account_id != pet->account_id || sd->status.char_id != pet->char_id) {
+ if(sd->status.account_id != petinfo->account_id || sd->status.char_id != petinfo->char_id) {
sd->status.pet_id = 0;
return 1;
}
- if (sd->status.pet_id != pet->pet_id) {
+ if (sd->status.pet_id != petinfo->pet_id) {
if (sd->status.pet_id) {
//Wrong pet?? Set incuvate to no and send it back for saving.
- pet->incuvate = 1;
- intif->save_petdata(sd->status.account_id,pet);
+ petinfo->incuvate = 1;
+ intif->save_petdata(sd->status.account_id,petinfo);
sd->status.pet_id = 0;
return 1;
}
//The pet_id value was lost? odd... restore it.
- sd->status.pet_id = pet->pet_id;
+ sd->status.pet_id = petinfo->pet_id;
}
- i = search_petDB_index(pet->class_,PET_CLASS);
+ i = pet->search_petDB_index(petinfo->class_,PET_CLASS);
if(i < 0) {
sd->status.pet_id = 0;
return 1;
}
sd->pd = pd = (struct pet_data *)aCalloc(1,sizeof(struct pet_data));
pd->bl.type = BL_PET;
- pd->bl.id = npc_get_new_npc_id();
+ pd->bl.id = npc->get_new_npc_id();
pd->msd = sd;
- pd->petDB = &pet_db[i];
- pd->db = mob_db(pet->class_);
- memcpy(&pd->pet, pet, sizeof(struct s_pet));
- iStatus->set_viewdata(&pd->bl, pet->class_);
- unit_dataset(&pd->bl);
+ pd->petDB = &pet->db[i];
+ pd->db = mob->db(petinfo->class_);
+ memcpy(&pd->pet, petinfo, sizeof(struct s_pet));
+ iStatus->set_viewdata(&pd->bl, petinfo->class_);
+ unit->dataset(&pd->bl);
pd->ud.dir = sd->ud.dir;
pd->bl.m = sd->bl.m;
pd->bl.x = sd->bl.x;
pd->bl.y = sd->bl.y;
- unit_calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
+ unit->calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
pd->bl.x = pd->ud.to_x;
pd->bl.y = pd->ud.to_y;
@@ -372,7 +368,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *pet)
pd->last_thinktime = iTimer->gettick();
pd->state.skillbonus = 0;
if( battle_config.pet_status_support )
- script->run(pet_db[i].pet_script,0,sd->bl.id,0);
+ script->run(pet->db[i].pet_script,0,sd->bl.id,0);
if( pd->petDB && pd->petDB->equip_script )
status_calc_pc(sd,0);
@@ -382,31 +378,31 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *pet)
interval = pd->petDB->hungry_delay;
if( interval <= 0 )
interval = 1;
- pd->pet_hungry_timer = iTimer->add_timer(iTimer->gettick() + interval, pet_hungry, sd->bl.id, 0);
+ pd->pet_hungry_timer = iTimer->add_timer(iTimer->gettick() + interval, pet->hungry, sd->bl.id, 0);
return 0;
}
-int pet_birth_process(struct map_session_data *sd, struct s_pet *pet)
+int pet_birth_process(struct map_session_data *sd, struct s_pet *petinfo)
{
nullpo_retr(1, sd);
Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd);
- if(sd->status.pet_id && pet->incuvate == 1) {
+ if(sd->status.pet_id && petinfo->incuvate == 1) {
sd->status.pet_id = 0;
return 1;
}
- pet->incuvate = 0;
- pet->account_id = sd->status.account_id;
- pet->char_id = sd->status.char_id;
- sd->status.pet_id = pet->pet_id;
- if(pet_data_init(sd, pet)) {
+ petinfo->incuvate = 0;
+ petinfo->account_id = sd->status.account_id;
+ petinfo->char_id = sd->status.char_id;
+ sd->status.pet_id = petinfo->pet_id;
+ if(pet->data_init(sd, petinfo)) {
sd->status.pet_id = 0;
return 1;
}
- intif->save_petdata(sd->status.account_id,pet);
+ intif->save_petdata(sd->status.account_id,petinfo);
if (iMap->save_settings&8)
chrif->save(sd,0); //is it REALLY Needed to save the char for hatching a pet? [Skotlex]
@@ -447,10 +443,10 @@ int pet_recv_petdata(int account_id,struct s_pet *p,int flag)
sd->status.pet_id = 0;
return 1;
}
- if (!pet_birth_process(sd,p)) //Pet hatched. Delete egg.
+ if (!pet->birth_process(sd,p)) //Pet hatched. Delete egg.
pc->delitem(sd,i,1,0,0,LOG_TYPE_OTHER);
} else {
- pet_data_init(sd,p);
+ pet->data_init(sd,p);
if(sd->pd && sd->bl.prev != NULL) {
iMap->addblock(&sd->pd->bl);
clif->spawn(&sd->pd->bl);
@@ -507,7 +503,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id)
//FIXME: delete taming item here, if this was an item-invoked capture and the item was flagged as delay-consume [ultramage]
- i = search_petDB_index(md->class_,PET_CLASS);
+ i = pet->search_petDB_index(md->class_,PET_CLASS);
//catch_target_class == 0 is used for universal lures (except bosses for now). [Skotlex]
if (sd->catch_target_class == 0 && !(md->status.mode&MD_BOSS))
sd->catch_target_class = md->class_;
@@ -518,7 +514,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id)
return 1;
}
- pet_catch_rate = (pet_db[i].capture + (sd->status.base_level - md->level)*30 + sd->battle_status.luk*20)*(200 - get_percentage(md->status.hp, md->status.max_hp))/100;
+ pet_catch_rate = (pet->db[i].capture + (sd->status.base_level - md->level)*30 + sd->battle_status.luk*20)*(200 - get_percentage(md->status.hp, md->status.max_hp))/100;
if(pet_catch_rate < 1) pet_catch_rate = 1;
if(battle_config.pet_catch_rate != 100)
@@ -526,11 +522,11 @@ int pet_catch_process2(struct map_session_data* sd, int target_id)
if(rnd()%10000 < pet_catch_rate)
{
- unit_remove_map(&md->bl,CLR_OUTSIGHT);
+ unit->remove_map(&md->bl,CLR_OUTSIGHT,ALC_MARK);
status_kill(&md->bl);
clif->pet_roulette(sd,1);
- intif->create_pet(sd->status.account_id,sd->status.char_id,pet_db[i].class_,mob_db(pet_db[i].class_)->lv,
- pet_db[i].EggID,0,pet_db[i].intimate,100,0,1,pet_db[i].jname);
+ intif->create_pet(sd->status.account_id,sd->status.char_id,pet->db[i].class_,mob->db(pet->db[i].class_)->lv,
+ pet->db[i].EggID,0,pet->db[i].intimate,100,0,1,pet->db[i].jname);
}
else
{
@@ -554,7 +550,7 @@ int pet_get_egg(int account_id,int pet_id,int flag)
if(sd == NULL)
return 0;
- i = search_petDB_index(sd->catch_target_class,PET_CLASS);
+ i = pet->search_petDB_index(sd->catch_target_class,PET_CLASS);
sd->catch_target_class = -1;
if(i < 0) {
@@ -563,7 +559,7 @@ int pet_get_egg(int account_id,int pet_id,int flag)
}
memset(&tmp_item,0,sizeof(tmp_item));
- tmp_item.nameid = pet_db[i].EggID;
+ tmp_item.nameid = pet->db[i].EggID;
tmp_item.identify = 1;
tmp_item.card[0] = CARD0_PET;
tmp_item.card[1] = GetWord(pet_id,0);
@@ -577,10 +573,6 @@ int pet_get_egg(int account_id,int pet_id,int flag)
return 1;
}
-static int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd);
-static int pet_food(struct map_session_data *sd, struct pet_data *pd);
-static int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap);
-
int pet_menu(struct map_session_data *sd,int menunum)
{
struct item_data *egg_id;
@@ -605,16 +597,16 @@ int pet_menu(struct map_session_data *sd,int menunum)
clif->send_petstatus(sd);
break;
case 1:
- pet_food(sd, sd->pd);
+ pet->food(sd, sd->pd);
break;
case 2:
- pet_performance(sd, sd->pd);
+ pet->performance(sd, sd->pd);
break;
case 3:
- pet_return_egg(sd, sd->pd);
+ pet->return_egg(sd, sd->pd);
break;
case 4:
- pet_unequipitem(sd, sd->pd);
+ pet->unequipitem(sd, sd->pd);
break;
}
return 0;
@@ -684,18 +676,18 @@ int pet_equipitem(struct map_session_data *sd,int index)
if (pd->s_skill && pd->s_skill->timer == INVALID_TIMER)
{
if (pd->s_skill->id)
- pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000, pet_skill_support_timer, sd->bl.id, 0);
+ pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000, pet->skill_support_timer, sd->bl.id, 0);
else
- pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000, pet_heal_timer, sd->bl.id, 0);
+ pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000, pet->heal_timer, sd->bl.id, 0);
}
if (pd->bonus && pd->bonus->timer == INVALID_TIMER)
- pd->bonus->timer=iTimer->add_timer(tick+pd->bonus->delay*1000, pet_skill_bonus_timer, sd->bl.id, 0);
+ pd->bonus->timer=iTimer->add_timer(tick+pd->bonus->delay*1000, pet->skill_bonus_timer, sd->bl.id, 0);
}
return 0;
}
-static int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd)
+int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd)
{
struct item tmp_item;
int nameid,flag;
@@ -724,14 +716,14 @@ static int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd)
if( pd->s_skill && pd->s_skill->timer != INVALID_TIMER )
{
if( pd->s_skill->id )
- iTimer->delete_timer(pd->s_skill->timer, pet_skill_support_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet->skill_support_timer);
else
- iTimer->delete_timer(pd->s_skill->timer, pet_heal_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet->heal_timer);
pd->s_skill->timer = INVALID_TIMER;
}
if( pd->bonus && pd->bonus->timer != INVALID_TIMER )
{
- iTimer->delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
+ iTimer->delete_timer(pd->bonus->timer, pet->skill_bonus_timer);
pd->bonus->timer = INVALID_TIMER;
}
}
@@ -739,7 +731,7 @@ static int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd)
return 0;
}
-static int pet_food(struct map_session_data *sd, struct pet_data *pd)
+int pet_food(struct map_session_data *sd, struct pet_data *pd)
{
int i,k;
@@ -752,7 +744,7 @@ static int pet_food(struct map_session_data *sd, struct pet_data *pd)
pc->delitem(sd,i,1,0,0,LOG_TYPE_CONSUME);
if( pd->pet.hungry > 90 )
- pet_set_intimate(pd, pd->pet.intimate - pd->petDB->r_full);
+ pet->set_intimate(pd, pd->pet.intimate - pd->petDB->r_full);
else
{
if( battle_config.pet_friendly_rate != 100 )
@@ -765,7 +757,7 @@ static int pet_food(struct map_session_data *sd, struct pet_data *pd)
if( k <= 0 )
k = 1;
}
- pet_set_intimate(pd, pd->pet.intimate + k);
+ pet->set_intimate(pd, pd->pet.intimate + k);
}
if( pd->pet.intimate <= 0 )
{
@@ -787,13 +779,13 @@ static int pet_food(struct map_session_data *sd, struct pet_data *pd)
return 0;
}
-static int pet_randomwalk(struct pet_data *pd,unsigned int tick)
+int pet_randomwalk(struct pet_data *pd,unsigned int tick)
{
nullpo_ret(pd);
Assert((pd->msd == 0) || (pd->msd->pd == pd));
- if(DIFF_TICK(pd->next_walktime,tick) < 0 && unit_can_move(&pd->bl)) {
+ if(DIFF_TICK(pd->next_walktime,tick) < 0 && unit->can_move(&pd->bl)) {
const int retrycount=20;
int i,x,y,c,d=12-pd->move_fail_count;
if(d<5) d=5;
@@ -801,7 +793,7 @@ static int pet_randomwalk(struct pet_data *pd,unsigned int tick)
int r=rnd();
x=pd->bl.x+r%(d*2+1)-d;
y=pd->bl.y+r/(d*2+1)%(d*2+1)-d;
- if(iMap->getcell(pd->bl.m,x,y,CELL_CHKPASS) && unit_walktoxy(&pd->bl,x,y,0)){
+ if(iMap->getcell(pd->bl.m,x,y,CELL_CHKPASS) && unit->walktoxy(&pd->bl,x,y,0)){
pd->move_fail_count=0;
break;
}
@@ -828,7 +820,7 @@ static int pet_randomwalk(struct pet_data *pd,unsigned int tick)
return 0;
}
-static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, unsigned int tick)
+int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, unsigned int tick)
{
struct block_list *target = NULL;
@@ -847,14 +839,14 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
if(pd->pet.intimate <= 0) {
//Pet should just... well, random walk.
- pet_randomwalk(pd,tick);
+ pet->randomwalk(pd,tick);
return 0;
}
if (!check_distance_bl(&sd->bl, &pd->bl, pd->db->range3)) {
//Master too far, chase.
if(pd->target_id)
- pet_unlocktarget(pd);
+ pet->unlocktarget(pd);
if(pd->ud.walktimer != INVALID_TIMER && pd->ud.target == sd->bl.id)
return 0; //Already walking to him
if (DIFF_TICK(tick, pd->ud.canmove_tick) < 0)
@@ -862,8 +854,8 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
pd->status.speed = (sd->battle_status.speed>>1);
if(pd->status.speed <= 0)
pd->status.speed = 1;
- if (!unit_walktobl(&pd->bl, &sd->bl, 3, 0))
- pet_randomwalk(pd,tick);
+ if (!unit->walktobl(&pd->bl, &sd->bl, 3, 0))
+ pet->randomwalk(pd,tick);
return 0;
}
@@ -881,13 +873,13 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
!check_distance_bl(&pd->bl, target, pd->db->range3))
{
target = NULL;
- pet_unlocktarget(pd);
+ pet->unlocktarget(pd);
}
}
if(!target && pd->loot && pd->msd && pc->has_permission(pd->msd, PC_PERM_TRADE) && pd->loot->count < pd->loot->max && DIFF_TICK(tick,pd->ud.canact_tick)>0) {
//Use half the pet's range of sight.
- iMap->foreachinrange(pet_ai_sub_hard_lootsearch,&pd->bl,
+ iMap->foreachinrange(pet->ai_sub_hard_lootsearch,&pd->bl,
pd->db->range2/2, BL_ITEM,pd,&target);
}
@@ -899,9 +891,9 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
if(pd->ud.walktimer != INVALID_TIMER && check_distance_blxy(&sd->bl, pd->ud.to_x,pd->ud.to_y, 3))
return 0; //Already walking to him
- unit_calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
- if(!unit_walktoxy(&pd->bl,pd->ud.to_x,pd->ud.to_y,0))
- pet_randomwalk(pd,tick);
+ unit->calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir);
+ if(!unit->walktoxy(&pd->bl,pd->ud.to_x,pd->ud.to_y,0))
+ pet->randomwalk(pd,tick);
return 0;
}
@@ -914,17 +906,17 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
{ //enemy targetted
if(!battle->check_range(&pd->bl,target,pd->status.rhw.range))
{ //Chase
- if(!unit_walktobl(&pd->bl, target, pd->status.rhw.range, 2))
- pet_unlocktarget(pd); //Unreachable target.
+ if(!unit->walktobl(&pd->bl, target, pd->status.rhw.range, 2))
+ pet->unlocktarget(pd); //Unreachable target.
return 0;
}
//Continuous attack.
- unit_attack(&pd->bl, pd->target_id, 1);
+ unit->attack(&pd->bl, pd->target_id, 1);
} else { //Item Targeted, attempt loot
if (!check_distance_bl(&pd->bl, target, 1))
{ //Out of range
- if(!unit_walktobl(&pd->bl, target, 1, 1)) //Unreachable target.
- pet_unlocktarget(pd);
+ if(!unit->walktobl(&pd->bl, target, 1, 1)) //Unreachable target.
+ pet->unlocktarget(pd);
return 0;
} else{
struct flooritem_data *fitem = (struct flooritem_data *)target;
@@ -934,29 +926,29 @@ static int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, uns
iMap->clearflooritem(target);
}
//Target is unlocked regardless of whether it was picked or not.
- pet_unlocktarget(pd);
+ pet->unlocktarget(pd);
}
}
return 0;
}
-static int pet_ai_sub_foreachclient(struct map_session_data *sd,va_list ap)
+int pet_ai_sub_foreachclient(struct map_session_data *sd,va_list ap)
{
unsigned int tick = va_arg(ap,unsigned int);
if(sd->status.pet_id && sd->pd)
- pet_ai_sub_hard(sd->pd,sd,tick);
+ pet->ai_sub_hard(sd->pd,sd,tick);
return 0;
}
-static int pet_ai_hard(int tid, unsigned int tick, int id, intptr_t data)
+int pet_ai_hard(int tid, unsigned int tick, int id, intptr_t data)
{
- iMap->map_foreachpc(pet_ai_sub_foreachclient,tick);
+ iMap->map_foreachpc(pet->ai_sub_foreachclient,tick);
return 0;
}
-static int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
+int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
{
struct pet_data* pd;
struct flooritem_data *fitem = (struct flooritem_data *)bl;
@@ -971,7 +963,7 @@ static int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
if(sd_charid && sd_charid != pd->msd->status.char_id)
return 0;
- if(unit_can_reach_bl(&pd->bl,bl, pd->db->range2, 1, NULL, NULL) &&
+ if(unit->can_reach_bl(&pd->bl,bl, pd->db->range2, 1, NULL, NULL) &&
((*target) == NULL || //New target closer than previous one.
!check_distance_bl(&pd->bl, *target, distance_bl(&pd->bl, bl))))
{
@@ -983,7 +975,7 @@ static int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
return 0;
}
-static int pet_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data)
+int pet_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data)
{
struct item_drop_list *list;
struct item_drop *ditem, *ditem_prev;
@@ -995,9 +987,9 @@ static int pet_delay_item_drop(int tid, unsigned int tick, int id, intptr_t data
list->first_charid,list->second_charid,list->third_charid,0);
ditem_prev = ditem;
ditem = ditem->next;
- ers_free(item_drop_ers, ditem_prev);
+ ers_free(pet->item_drop_ers, ditem_prev);
}
- ers_free(item_drop_list_ers, list);
+ ers_free(pet->item_drop_list_ers, list);
return 0;
}
@@ -1009,7 +1001,7 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
struct item *it;
if(!pd || !pd->loot || !pd->loot->count)
return 0;
- dlist = ers_alloc(item_drop_list_ers, struct item_drop_list);
+ dlist = ers_alloc(pet->item_drop_list_ers, struct item_drop_list);
dlist->m = pd->bl.m;
dlist->x = pd->bl.x;
dlist->y = pd->bl.y;
@@ -1023,14 +1015,14 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
if(sd){
if((flag = pc->additem(sd,it,it->amount,LOG_TYPE_PICKDROP_PLAYER))){
clif->additem(sd,0,0,flag);
- ditem = ers_alloc(item_drop_ers, struct item_drop);
+ ditem = ers_alloc(pet->item_drop_ers, struct item_drop);
memcpy(&ditem->item_data, it, sizeof(struct item));
ditem->next = dlist->item;
dlist->item = ditem;
}
}
else {
- ditem = ers_alloc(item_drop_ers, struct item_drop);
+ ditem = ers_alloc(pet->item_drop_ers, struct item_drop);
memcpy(&ditem->item_data, it, sizeof(struct item));
ditem->next = dlist->item;
dlist->item = ditem;
@@ -1043,9 +1035,9 @@ int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
pd->ud.canact_tick = iTimer->gettick()+10000; //prevent picked up during 10*1000ms
if (dlist->item)
- iTimer->add_timer(iTimer->gettick()+540,pet_delay_item_drop,0,(intptr_t)dlist);
+ iTimer->add_timer(iTimer->gettick()+540,pet->delay_item_drop,0,(intptr_t)dlist);
else
- ers_free(item_drop_list_ers, dlist);
+ ers_free(pet->item_drop_list_ers, dlist);
return 1;
}
@@ -1087,7 +1079,7 @@ int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data)
status_calc_pc(sd, 0);
}
// wait for the next timer
- pd->bonus->timer=iTimer->add_timer(tick+timer,pet_skill_bonus_timer,sd->bl.id,0);
+ pd->bonus->timer=iTimer->add_timer(tick+timer,pet->skill_bonus_timer,sd->bl.id,0);
return 0;
}
@@ -1146,14 +1138,14 @@ int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data)
(rate = get_percentage(status->hp, status->max_hp)) > pd->s_skill->hp ||
(rate = (pd->ud.skilltimer != INVALID_TIMER)) //Another skill is in effect
) { //Wait (how long? 1 sec for every 10% of remaining)
- pd->s_skill->timer=iTimer->add_timer(iTimer->gettick()+(rate>10?rate:10)*100,pet_heal_timer,sd->bl.id,0);
+ pd->s_skill->timer=iTimer->add_timer(iTimer->gettick()+(rate>10?rate:10)*100,pet->heal_timer,sd->bl.id,0);
return 0;
}
pet_stop_attack(pd);
pet_stop_walking(pd,1);
clif->skill_nodamage(&pd->bl,&sd->bl,AL_HEAL,pd->s_skill->lv,1);
iStatus->heal(&sd->bl, pd->s_skill->lv,0, 0);
- pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000,pet_heal_timer,sd->bl.id,0);
+ pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0);
return 0;
}
@@ -1180,7 +1172,7 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data)
if (DIFF_TICK(pd->ud.canact_tick, tick) > 0)
{ //Wait until the pet can act again.
- pd->s_skill->timer=iTimer->add_timer(pd->ud.canact_tick,pet_skill_support_timer,sd->bl.id,0);
+ pd->s_skill->timer=iTimer->add_timer(pd->ud.canact_tick,pet->skill_support_timer,sd->bl.id,0);
return 0;
}
@@ -1189,24 +1181,24 @@ int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data)
(rate = get_percentage(status->hp, status->max_hp)) > pd->s_skill->hp ||
(rate = (pd->ud.skilltimer != INVALID_TIMER)) //Another skill is in effect
) { //Wait (how long? 1 sec for every 10% of remaining)
- pd->s_skill->timer=iTimer->add_timer(tick+(rate>10?rate:10)*100,pet_skill_support_timer,sd->bl.id,0);
+ pd->s_skill->timer=iTimer->add_timer(tick+(rate>10?rate:10)*100,pet->skill_support_timer,sd->bl.id,0);
return 0;
}
pet_stop_attack(pd);
pet_stop_walking(pd,1);
- pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000,pet_skill_support_timer,sd->bl.id,0);
+ pd->s_skill->timer=iTimer->add_timer(tick+pd->s_skill->delay*1000,pet->skill_support_timer,sd->bl.id,0);
if (skill->get_inf(pd->s_skill->id) & INF_GROUND_SKILL)
- unit_skilluse_pos(&pd->bl, sd->bl.x, sd->bl.y, pd->s_skill->id, pd->s_skill->lv);
+ unit->skilluse_pos(&pd->bl, sd->bl.x, sd->bl.y, pd->s_skill->id, pd->s_skill->lv);
else
- unit_skilluse_id(&pd->bl, sd->bl.id, pd->s_skill->id, pd->s_skill->lv);
+ unit->skilluse_id(&pd->bl, sd->bl.id, pd->s_skill->id, pd->s_skill->lv);
return 0;
}
/*==========================================
* Pet read db data
- * pet_db.txt
- * pet_db2.txt
+ * pet->db.txt
+ * pet->db2.txt
*------------------------------------------*/
int read_petdb()
{
@@ -1217,20 +1209,20 @@ int read_petdb()
// Remove any previous scripts in case reloaddb was invoked.
for( j = 0; j < MAX_PET_DB; j++ )
{
- if( pet_db[j].pet_script )
+ if( pet->db[j].pet_script )
{
- script->free_code(pet_db[j].pet_script);
- pet_db[j].pet_script = NULL;
+ script->free_code(pet->db[j].pet_script);
+ pet->db[j].pet_script = NULL;
}
- if( pet_db[j].equip_script )
+ if( pet->db[j].equip_script )
{
- script->free_code(pet_db[j].equip_script);
- pet_db[j].pet_script = NULL;
+ script->free_code(pet->db[j].equip_script);
+ pet->db[j].pet_script = NULL;
}
}
// clear database
- memset(pet_db,0,sizeof(pet_db));
+ memset(pet->db,0,sizeof(pet->db));
j = 0; // entry counter
for( i = 0; i < ARRAYLENGTH(filename); i++ )
@@ -1305,41 +1297,41 @@ int read_petdb()
if( (nameid = atoi(str[0])) <= 0 )
continue;
- if( !mobdb_checkid(nameid) )
+ if( !mob->db_checkid(nameid) )
{
ShowWarning("pet_db reading: Invalid mob-class %d, pet not read.\n", nameid);
continue;
}
- pet_db[j].class_ = nameid;
- safestrncpy(pet_db[j].name,str[1],NAME_LENGTH);
- safestrncpy(pet_db[j].jname,str[2],NAME_LENGTH);
- pet_db[j].itemID=atoi(str[3]);
- pet_db[j].EggID=atoi(str[4]);
- pet_db[j].AcceID=atoi(str[5]);
- pet_db[j].FoodID=atoi(str[6]);
- pet_db[j].fullness=atoi(str[7]);
- pet_db[j].hungry_delay=atoi(str[8])*1000;
- pet_db[j].r_hungry=atoi(str[9]);
- if( pet_db[j].r_hungry <= 0 )
- pet_db[j].r_hungry=1;
- pet_db[j].r_full=atoi(str[10]);
- pet_db[j].intimate=atoi(str[11]);
- pet_db[j].die=atoi(str[12]);
- pet_db[j].capture=atoi(str[13]);
- pet_db[j].speed=atoi(str[14]);
- pet_db[j].s_perfor=(char)atoi(str[15]);
- pet_db[j].talk_convert_class=atoi(str[16]);
- pet_db[j].attack_rate=atoi(str[17]);
- pet_db[j].defence_attack_rate=atoi(str[18]);
- pet_db[j].change_target_rate=atoi(str[19]);
- pet_db[j].pet_script = NULL;
- pet_db[j].equip_script = NULL;
+ pet->db[j].class_ = nameid;
+ safestrncpy(pet->db[j].name,str[1],NAME_LENGTH);
+ safestrncpy(pet->db[j].jname,str[2],NAME_LENGTH);
+ pet->db[j].itemID=atoi(str[3]);
+ pet->db[j].EggID=atoi(str[4]);
+ pet->db[j].AcceID=atoi(str[5]);
+ pet->db[j].FoodID=atoi(str[6]);
+ pet->db[j].fullness=atoi(str[7]);
+ pet->db[j].hungry_delay=atoi(str[8])*1000;
+ pet->db[j].r_hungry=atoi(str[9]);
+ if( pet->db[j].r_hungry <= 0 )
+ pet->db[j].r_hungry=1;
+ pet->db[j].r_full=atoi(str[10]);
+ pet->db[j].intimate=atoi(str[11]);
+ pet->db[j].die=atoi(str[12]);
+ pet->db[j].capture=atoi(str[13]);
+ pet->db[j].speed=atoi(str[14]);
+ pet->db[j].s_perfor=(char)atoi(str[15]);
+ pet->db[j].talk_convert_class=atoi(str[16]);
+ pet->db[j].attack_rate=atoi(str[17]);
+ pet->db[j].defence_attack_rate=atoi(str[18]);
+ pet->db[j].change_target_rate=atoi(str[19]);
+ pet->db[j].pet_script = NULL;
+ pet->db[j].equip_script = NULL;
if( *str[20] )
- pet_db[j].pet_script = script->parse(str[20], filename[i], lines, 0);
+ pet->db[j].pet_script = script->parse(str[20], filename[i], lines, 0);
if( *str[21] )
- pet_db[j].equip_script = script->parse(str[21], filename[i], lines, 0);
+ pet->db[j].equip_script = script->parse(str[21], filename[i], lines, 0);
j++;
entries++;
@@ -1358,19 +1350,19 @@ int read_petdb()
*------------------------------------------*/
int do_init_pet(void)
{
- read_petdb();
+ pet->read_db();
- item_drop_ers = ers_new(sizeof(struct item_drop),"pet.c::item_drop_ers",ERS_OPT_NONE);
- item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"pet.c::item_drop_list_ers",ERS_OPT_NONE);
+ pet->item_drop_ers = ers_new(sizeof(struct item_drop),"pet.c::item_drop_ers",ERS_OPT_NONE);
+ pet->item_drop_list_ers = ers_new(sizeof(struct item_drop_list),"pet.c::item_drop_list_ers",ERS_OPT_NONE);
- iTimer->add_timer_func_list(pet_hungry,"pet_hungry");
- iTimer->add_timer_func_list(pet_ai_hard,"pet_ai_hard");
- iTimer->add_timer_func_list(pet_skill_bonus_timer,"pet_skill_bonus_timer"); // [Valaris]
- iTimer->add_timer_func_list(pet_delay_item_drop,"pet_delay_item_drop");
- iTimer->add_timer_func_list(pet_skill_support_timer, "pet_skill_support_timer"); // [Skotlex]
- iTimer->add_timer_func_list(pet_recovery_timer,"pet_recovery_timer"); // [Valaris]
- iTimer->add_timer_func_list(pet_heal_timer,"pet_heal_timer"); // [Valaris]
- iTimer->add_timer_interval(iTimer->gettick()+MIN_PETTHINKTIME,pet_ai_hard,0,0,MIN_PETTHINKTIME);
+ iTimer->add_timer_func_list(pet->hungry,"pet_hungry");
+ iTimer->add_timer_func_list(pet->ai_hard,"pet_ai_hard");
+ iTimer->add_timer_func_list(pet->skill_bonus_timer,"pet_skill_bonus_timer"); // [Valaris]
+ iTimer->add_timer_func_list(pet->delay_item_drop,"pet_delay_item_drop");
+ iTimer->add_timer_func_list(pet->skill_support_timer, "pet_skill_support_timer"); // [Skotlex]
+ iTimer->add_timer_func_list(pet->recovery_timer,"pet_recovery_timer"); // [Valaris]
+ iTimer->add_timer_func_list(pet->heal_timer,"pet_heal_timer"); // [Valaris]
+ iTimer->add_timer_interval(iTimer->gettick()+MIN_PETTHINKTIME,pet->ai_hard,0,0,MIN_PETTHINKTIME);
return 0;
}
@@ -1380,18 +1372,68 @@ int do_final_pet(void)
int i;
for( i = 0; i < MAX_PET_DB; i++ )
{
- if( pet_db[i].pet_script )
+ if( pet->db[i].pet_script )
{
- script->free_code(pet_db[i].pet_script);
- pet_db[i].pet_script = NULL;
+ script->free_code(pet->db[i].pet_script);
+ pet->db[i].pet_script = NULL;
}
- if( pet_db[i].equip_script )
+ if( pet->db[i].equip_script )
{
- script->free_code(pet_db[i].equip_script);
- pet_db[i].equip_script = NULL;
+ script->free_code(pet->db[i].equip_script);
+ pet->db[i].equip_script = NULL;
}
}
- ers_destroy(item_drop_ers);
- ers_destroy(item_drop_list_ers);
+ ers_destroy(pet->item_drop_ers);
+ ers_destroy(pet->item_drop_list_ers);
return 0;
}
+void pet_defaults(void) {
+ pet = &pet_s;
+
+ memset(pet->db,0,sizeof(pet->db));
+ pet->item_drop_ers = NULL;
+ pet->item_drop_list_ers = NULL;
+
+ /* */
+ pet->init = do_init_pet;
+ pet->final = do_final_pet;
+
+ /* */
+ pet->hungry_val = pet_hungry_val;
+ pet->set_intimate = pet_set_intimate;
+ pet->create_egg = pet_create_egg;
+ pet->unlocktarget = pet_unlocktarget;
+ pet->attackskill = pet_attackskill;
+ pet->target_check = pet_target_check;
+ pet->sc_check = pet_sc_check;
+ pet->hungry = pet_hungry;
+ pet->search_petDB_index = search_petDB_index;
+ pet->hungry_timer_delete = pet_hungry_timer_delete;
+ pet->performance = pet_performance;
+ pet->return_egg = pet_return_egg;
+ pet->data_init = pet_data_init;
+ pet->birth_process = pet_birth_process;
+ pet->recv_petdata = pet_recv_petdata;
+ pet->select_egg = pet_select_egg;
+ pet->catch_process1 = pet_catch_process1;
+ pet->catch_process2 = pet_catch_process2;
+ pet->get_egg = pet_get_egg;
+ pet->unequipitem = pet_unequipitem;
+ pet->food = pet_food;
+ pet->ai_sub_hard_lootsearch = pet_ai_sub_hard_lootsearch;
+ pet->menu = pet_menu;
+ pet->change_name = pet_change_name;
+ pet->change_name_ack = pet_change_name_ack;
+ pet->equipitem = pet_equipitem;
+ pet->randomwalk = pet_randomwalk;
+ pet->ai_sub_hard = pet_ai_sub_hard;
+ pet->ai_sub_foreachclient = pet_ai_sub_foreachclient;
+ pet->ai_hard = pet_ai_hard;
+ pet->delay_item_drop = pet_delay_item_drop;
+ pet->lootitem_drop = pet_lootitem_drop;
+ pet->skill_bonus_timer = pet_skill_bonus_timer;
+ pet->recovery_timer = pet_recovery_timer;
+ pet->heal_timer = pet_heal_timer;
+ pet->skill_support_timer = pet_skill_support_timer;
+ pet->read_db = read_petdb;
+}
diff --git a/src/map/pet.h b/src/map/pet.h
index b46f55229..b0e7cec6d 100644
--- a/src/map/pet.h
+++ b/src/map/pet.h
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _PET_H_
#define _PET_H_
@@ -30,7 +31,6 @@ struct s_pet_db {
struct script_code *equip_script;
struct script_code *pet_script;
};
-extern struct s_pet_db pet_db[MAX_PET_DB];
enum { PET_CLASS,PET_CATCH,PET_EGG,PET_EQUIP,PET_FOOD };
@@ -98,39 +98,58 @@ struct pet_data {
struct map_session_data *msd;
};
+#define pet_stop_walking(pd, type) unit->stop_walking(&(pd)->bl, type)
+#define pet_stop_attack(pd) unit->stop_attack(&(pd)->bl)
+
+struct pet_interface {
+ struct s_pet_db db[MAX_PET_DB];
+ struct eri *item_drop_ers; //For loot drops delay structures.
+ struct eri *item_drop_list_ers;
+ /* */
+ int (*init) (void);
+ int (*final) (void);
+ /* */
+ int (*hungry_val) (struct pet_data *pd);
+ void (*set_intimate) (struct pet_data *pd, int value);
+ int (*create_egg) (struct map_session_data *sd, int item_id);
+ int (*unlocktarget) (struct pet_data *pd);
+ int (*attackskill) (struct pet_data *pd, int target_id);
+ int (*target_check) (struct map_session_data *sd, struct block_list *bl, int type);
+ int (*sc_check) (struct map_session_data *sd, int type);
+ int (*hungry) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*search_petDB_index) (int key, int type);
+ int (*hungry_timer_delete) (struct pet_data *pd);
+ int (*performance) (struct map_session_data *sd, struct pet_data *pd);
+ int (*return_egg) (struct map_session_data *sd, struct pet_data *pd);
+ int (*data_init) (struct map_session_data *sd, struct s_pet *pet);
+ int (*birth_process) (struct map_session_data *sd, struct s_pet *pet);
+ int (*recv_petdata) (int account_id, struct s_pet *p, int flag);
+ int (*select_egg) (struct map_session_data *sd, short egg_index);
+ int (*catch_process1) (struct map_session_data *sd, int target_class);
+ int (*catch_process2) (struct map_session_data *sd, int target_id);
+ int (*get_egg) (int account_id, int pet_id, int flag);
+ int (*unequipitem) (struct map_session_data *sd, struct pet_data *pd);
+ int (*food) (struct map_session_data *sd, struct pet_data *pd);
+ int (*ai_sub_hard_lootsearch) (struct block_list *bl, va_list ap);
+ int (*menu) (struct map_session_data *sd, int menunum);
+ int (*change_name) (struct map_session_data *sd, char *name);
+ int (*change_name_ack) (struct map_session_data *sd, char *name, int flag);
+ int (*equipitem) (struct map_session_data *sd, int index);
+ int (*randomwalk) (struct pet_data *pd, unsigned int tick);
+ int (*ai_sub_hard) (struct pet_data *pd, struct map_session_data *sd, unsigned int tick);
+ int (*ai_sub_foreachclient) (struct map_session_data *sd, va_list ap);
+ int (*ai_hard) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*delay_item_drop) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*lootitem_drop) (struct pet_data *pd, struct map_session_data *sd);
+ int (*skill_bonus_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*recovery_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*heal_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*skill_support_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*read_db) ();
+};
+struct pet_interface *pet;
-int pet_create_egg(struct map_session_data *sd, int item_id);
-int pet_hungry_val(struct pet_data *pd);
-void pet_set_intimate(struct pet_data *pd, int value);
-int pet_target_check(struct map_session_data *sd,struct block_list *bl,int type);
-int pet_unlocktarget(struct pet_data *pd);
-int pet_sc_check(struct map_session_data *sd, int type); //Skotlex
-int search_petDB_index(int key,int type);
-int pet_hungry_timer_delete(struct pet_data *pd);
-int pet_data_init(struct map_session_data *sd, struct s_pet *pet);
-int pet_birth_process(struct map_session_data *sd, struct s_pet *pet);
-int pet_recv_petdata(int account_id,struct s_pet *p,int flag);
-int pet_select_egg(struct map_session_data *sd,short egg_index);
-int pet_catch_process1(struct map_session_data *sd,int target_class);
-int pet_catch_process2(struct map_session_data *sd,int target_id);
-int pet_get_egg(int account_id,int pet_id,int flag);
-int pet_menu(struct map_session_data *sd,int menunum);
-int pet_change_name(struct map_session_data *sd,char *name);
-int pet_change_name_ack(struct map_session_data *sd, char* name, int flag);
-int pet_equipitem(struct map_session_data *sd,int index);
-int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd);
-int pet_attackskill(struct pet_data *pd, int target_id);
-int pet_skill_support_timer(int tid, unsigned int tick, int id, intptr_t data); // [Skotlex]
-int pet_skill_bonus_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris]
-int pet_recovery_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris]
-int pet_heal_timer(int tid, unsigned int tick, int id, intptr_t data); // [Valaris]
-
-#define pet_stop_walking(pd, type) unit_stop_walking(&(pd)->bl, type)
-#define pet_stop_attack(pd) unit_stop_attack(&(pd)->bl)
-
-int read_petdb(void);
-int do_init_pet(void);
-int do_final_pet(void);
+void pet_defaults(void);
#endif /* _PET_H_ */
diff --git a/src/map/quest.c b/src/map/quest.c
index cf78430a4..9055b61fe 100644
--- a/src/map/quest.c
+++ b/src/map/quest.c
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#include "../common/cbasetypes.h"
#include "../common/socket.h"
@@ -32,14 +33,13 @@
#include <time.h>
-struct s_quest_db quest_db[MAX_QUEST_DB];
-
+struct quest_interface quest_s;
int quest_search_db(int quest_id)
{
int i;
- ARR_FIND(0, MAX_QUEST_DB,i,quest_id == quest_db[i].id);
+ ARR_FIND(0, MAX_QUEST_DB,i,quest_id == quest->db[i].id);
if( i == MAX_QUEST_DB )
return -1;
@@ -74,13 +74,13 @@ int quest_add(TBL_PC * sd, int quest_id)
return 1;
}
- if( quest_check(sd, quest_id, HAVEQUEST) >= 0 )
+ if( quest->check(sd, quest_id, HAVEQUEST) >= 0 )
{
ShowError("quest_add: Character %d already has quest %d.\n", sd->status.char_id, quest_id);
return -1;
}
- if( (j = quest_search_db(quest_id)) < 0 )
+ if( (j = quest->search_db(quest_id)) < 0 )
{
ShowError("quest_add: quest %d not found in DB.\n", quest_id);
return -1;
@@ -91,9 +91,9 @@ int quest_add(TBL_PC * sd, int quest_id)
memmove(sd->quest_index+i+1, sd->quest_index+i, sizeof(int)*(sd->num_quests-sd->avail_quests));
memset(&sd->quest_log[i], 0, sizeof(struct quest));
- sd->quest_log[i].quest_id = quest_db[j].id;
- if( quest_db[j].time )
- sd->quest_log[i].time = (unsigned int)(time(NULL) + quest_db[j].time);
+ sd->quest_log[i].quest_id = quest->db[j].id;
+ if( quest->db[j].time )
+ sd->quest_log[i].time = (unsigned int)(time(NULL) + quest->db[j].time);
sd->quest_log[i].state = Q_ACTIVE;
sd->quest_index[i] = j;
@@ -114,19 +114,19 @@ int quest_change(TBL_PC * sd, int qid1, int qid2)
int i, j;
- if( quest_check(sd, qid2, HAVEQUEST) >= 0 )
+ if( quest->check(sd, qid2, HAVEQUEST) >= 0 )
{
ShowError("quest_change: Character %d already has quest %d.\n", sd->status.char_id, qid2);
return -1;
}
- if( quest_check(sd, qid1, HAVEQUEST) < 0 )
+ if( quest->check(sd, qid1, HAVEQUEST) < 0 )
{
ShowError("quest_change: Character %d doesn't have quest %d.\n", sd->status.char_id, qid1);
return -1;
}
- if( (j = quest_search_db(qid2)) < 0 )
+ if( (j = quest->search_db(qid2)) < 0 )
{
ShowError("quest_change: quest %d not found in DB.\n",qid2);
return -1;
@@ -140,9 +140,9 @@ int quest_change(TBL_PC * sd, int qid1, int qid2)
}
memset(&sd->quest_log[i], 0, sizeof(struct quest));
- sd->quest_log[i].quest_id = quest_db[j].id;
- if( quest_db[j].time )
- sd->quest_log[i].time = (unsigned int)(time(NULL) + quest_db[j].time);
+ sd->quest_log[i].quest_id = quest->db[j].id;
+ if( quest->db[j].time )
+ sd->quest_log[i].time = (unsigned int)(time(NULL) + quest->db[j].time);
sd->quest_log[i].state = Q_ACTIVE;
sd->quest_index[i] = j;
@@ -205,7 +205,7 @@ int quest_update_objective_sub(struct block_list *bl, va_list ap)
if( sd->status.party_id != party )
return 0;
- quest_update_objective(sd, mob);
+ quest->update_objective(sd, mob);
return 1;
}
@@ -219,7 +219,7 @@ void quest_update_objective(TBL_PC * sd, int mob) {
continue;
for( j = 0; j < MAX_QUEST_OBJECTIVES; j++ )
- if( quest_db[sd->quest_index[i]].mob[j] == mob && sd->quest_log[i].count[j] < quest_db[sd->quest_index[i]].count[j] ) {
+ if( quest->db[sd->quest_index[i]].mob[j] == mob && sd->quest_log[i].count[j] < quest->db[sd->quest_index[i]].count[j] ) {
sd->quest_log[i].count[j]++;
sd->save_quest = true;
clif->quest_update_objective(sd,&sd->quest_log[i],sd->quest_index[i]);
@@ -275,7 +275,7 @@ int quest_check(TBL_PC * sd, int quest_id, quest_check_type type) {
case HUNTING: {
if( sd->quest_log[i].state == 0 || sd->quest_log[i].state == 1 ) {
int j;
- ARR_FIND(0, MAX_QUEST_OBJECTIVES, j, sd->quest_log[i].count[j] < quest_db[sd->quest_index[i]].count[j]);
+ ARR_FIND(0, MAX_QUEST_OBJECTIVES, j, sd->quest_log[i].count[j] < quest->db[sd->quest_index[i]].count[j]);
if( j == MAX_QUEST_OBJECTIVES )
return 2;
if( sd->quest_log[i].time < (unsigned int)time(NULL) )
@@ -331,20 +331,20 @@ int quest_read_db(void) {
if(str[0]==NULL)
continue;
- memset(&quest_db[k], 0, sizeof(quest_db[0]));
+ memset(&quest->db[k], 0, sizeof(quest->db[0]));
- quest_db[k].id = atoi(str[0]);
- quest_db[k].time = atoi(str[1]);
+ quest->db[k].id = atoi(str[0]);
+ quest->db[k].time = atoi(str[1]);
for( i = 0; i < MAX_QUEST_OBJECTIVES; i++ ) {
- quest_db[k].mob[i] = atoi(str[2*i+2]);
- quest_db[k].count[i] = atoi(str[2*i+3]);
+ quest->db[k].mob[i] = atoi(str[2*i+2]);
+ quest->db[k].count[i] = atoi(str[2*i+3]);
- if( !quest_db[k].mob[i] || !quest_db[k].count[i] )
+ if( !quest->db[k].mob[i] || !quest->db[k].count[i] )
break;
}
- quest_db[k].num_objectives = i;
+ quest->db[k].num_objectives = i;
k++;
}
@@ -354,10 +354,30 @@ int quest_read_db(void) {
}
void do_init_quest(void) {
- quest_read_db();
+ quest->read_db();
}
void do_reload_quest(void) {
- memset(&quest_db, 0, sizeof(quest_db));
- quest_read_db();
+ memset(&quest->db, 0, sizeof(quest->db));
+ quest->read_db();
+}
+
+void quest_defaults(void) {
+ quest = &quest_s;
+
+ memset(&quest->db, 0, sizeof(quest->db));
+ /* */
+ quest->init = do_init_quest;
+ quest->reload = do_reload_quest;
+ /* */
+ quest->search_db = quest_search_db;
+ quest->pc_login = quest_pc_login;
+ quest->add = quest_add;
+ quest->change = quest_change;
+ quest->delete = quest_delete;
+ quest->update_objective_sub = quest_update_objective_sub;
+ quest->update_objective = quest_update_objective;
+ quest->update_status = quest_update_status;
+ quest->check = quest_check;
+ quest->read_db = quest_read_db;
}
diff --git a/src/map/quest.h b/src/map/quest.h
index 7f638a54c..85c987f54 100644
--- a/src/map/quest.h
+++ b/src/map/quest.h
@@ -1,5 +1,6 @@
-// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
-// For more information, see LICENCE in the main folder
+// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
+// See the LICENSE file
+// Portions Copyright (c) Athena Dev Teams
#ifndef _QUEST_H_
#define _QUEST_H_
@@ -12,23 +13,29 @@ struct s_quest_db {
int num_objectives;
//char name[NAME_LENGTH];
};
-extern struct s_quest_db quest_db[MAX_QUEST_DB];
typedef enum quest_check_type { HAVEQUEST, PLAYTIME, HUNTING } quest_check_type;
-int quest_pc_login(TBL_PC * sd);
-
-int quest_add(TBL_PC * sd, int quest_id);
-int quest_delete(TBL_PC * sd, int quest_id);
-int quest_change(TBL_PC * sd, int qid1, int qid2);
-int quest_update_objective_sub(struct block_list *bl, va_list ap);
-void quest_update_objective(TBL_PC * sd, int mob);
-int quest_update_status(TBL_PC * sd, int quest_id, quest_state status);
-int quest_check(TBL_PC * sd, int quest_id, quest_check_type type);
+struct quest_interface {
+ struct s_quest_db db[MAX_QUEST_DB];
+ /* */
+ void (*init) (void);
+ void (*reload) (void);
+ /* */
+ int (*search_db) (int quest_id);
+ int (*pc_login) (TBL_PC *sd);
+ int (*add) (TBL_PC *sd, int quest_id);
+ int (*change) (TBL_PC *sd, int qid1, int qid2);
+ int (*delete) (TBL_PC *sd, int quest_id);
+ int (*update_objective_sub) (struct block_list *bl, va_list ap);
+ void (*update_objective) (TBL_PC *sd, int mob);
+ int (*update_status) (TBL_PC *sd, int quest_id, quest_state status);
+ int (*check) (TBL_PC *sd, int quest_id, quest_check_type type);
+ int (*read_db) (void);
+};
-int quest_search_db(int quest_id);
+struct quest_interface *quest;
-void do_init_quest();
-void do_reload_quest(void);
+void quest_defaults(void);
#endif
diff --git a/src/map/script.c b/src/map/script.c
index 3e2347123..7ac638848 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -63,6 +63,7 @@
#include <setjmp.h>
#include <errno.h>
+
#define FETCH(n, t) \
if( script_hasdata(st,n) ) \
(t)=script_getnum(st,n);
@@ -2340,7 +2341,7 @@ void get_val(struct script_state* st, struct script_data* data)
data->u.str = pc->readregstr(sd, data->u.num);
break;
case '$':
- data->u.str = mapreg_readregstr(data->u.num);
+ data->u.str = mapreg->readregstr(data->u.num);
break;
case '#':
if( name[1] == '#' )
@@ -2395,7 +2396,7 @@ void get_val(struct script_state* st, struct script_data* data)
data->u.num = pc->readreg(sd, data->u.num);
break;
case '$':
- data->u.num = mapreg_readreg(data->u.num);
+ data->u.num = mapreg->readreg(data->u.num);
break;
case '#':
if( name[1] == '#' )
@@ -2458,7 +2459,7 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
case '@':
return pc->setregstr(sd, num, str);
case '$':
- return mapreg_setregstr(num, str);
+ return mapreg->setregstr(num, str);
case '#':
return (name[1] == '#') ?
pc_setaccountreg2str(sd, name, str) :
@@ -2505,7 +2506,7 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
case '@':
return pc->setreg(sd, num, val);
case '$':
- return mapreg_setreg(num, val);
+ return mapreg->setreg(num, val);
case '#':
return (name[1] == '#') ?
pc_setaccountreg2(sd, name, val) :
@@ -3380,11 +3381,11 @@ static void script_detach_state(struct script_state* st, bool dequeue_event)
* We're done with this NPC session, so we cancel the timer (if existent) and move on
**/
if( sd->npc_idle_timer != INVALID_TIMER ) {
- iTimer->delete_timer(sd->npc_idle_timer,npc_rr_secure_timeout_timer);
+ iTimer->delete_timer(sd->npc_idle_timer,npc->secure_timeout_timer);
sd->npc_idle_timer = INVALID_TIMER;
}
#endif
- npc_event_dequeue(sd);
+ npc->event_dequeue(sd);
}
} else if(st->bk_st) { // rid was set to 0, before detaching the script state
ShowError("script_detach_state: Found previous script state without attached player (rid=%d, oid=%d, state=%d, bk_npcid=%d)\n", st->bk_st->rid, st->bk_st->oid, st->bk_st->state, st->bk_npcid);
@@ -3420,7 +3421,7 @@ void script_attach_state(struct script_state* st) {
**/
#ifdef SECURE_NPCTIMEOUT
if( sd->npc_idle_timer == INVALID_TIMER )
- sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc_rr_secure_timeout_timer,sd->bl.id,0);
+ sd->npc_idle_timer = iTimer->add_timer(iTimer->gettick() + (SECURE_NPCTIMEOUT_INTERVAL*1000),npc->secure_timeout_timer,sd->bl.id,0);
sd->npc_idle_tick = iTimer->gettick();
#endif
}
@@ -3794,7 +3795,7 @@ void do_final_script(void) {
dbi_destroy(iter);
- mapreg_final();
+ mapreg->final();
script->userfunc_db->destroy(script->userfunc_db, db_script_free_code_sub);
script->autobonus_db->destroy(script->autobonus_db, db_script_free_code_sub);
@@ -3863,7 +3864,7 @@ void do_init_script(void) {
script->parse_builtin();
read_constdb();
- mapreg_init();
+ mapreg->init();
}
int script_reload(void) {
@@ -3893,7 +3894,7 @@ int script_reload(void) {
db_clear(script->st_db);
- mapreg_reload();
+ mapreg->reload();
itemdb->force_name_constants();
@@ -5758,7 +5759,7 @@ BUILDIN(checkweight)
// item is already in inventory, but there is still space for the requested amount
break;
case ADDITEM_NEW:
- if( itemdb_isstackable(nameid) ) {// stackable
+ if( itemdb->isstackable(nameid) ) {// stackable
amount2++;
if( slots < amount2 ) {
script_pushint(st,0);
@@ -5863,7 +5864,7 @@ BUILDIN(checkweight2)
// item is already in inventory, but there is still space for the requested amount
break;
case ADDITEM_NEW:
- if( itemdb_isstackable(nameid) ){// stackable
+ if( itemdb->isstackable(nameid) ){// stackable
amount2++;
if( slots < amount2 )
fail = 1;
@@ -5931,7 +5932,7 @@ BUILDIN(getitem)
if(!flag)
it.identify=1;
else
- it.identify=itemdb_isidentified2(item_data);
+ it.identify=itemdb->isidentified2(item_data);
if( script_hasdata(st,4) )
sd=iMap->id2sd(script_getnum(st,4)); // <Account ID>
@@ -5942,7 +5943,7 @@ BUILDIN(getitem)
return true;
//Check if it's stackable.
- if (!itemdb_isstackable(nameid))
+ if (!itemdb->isstackable(nameid))
get_count = 1;
else
get_count = amount;
@@ -5950,7 +5951,7 @@ BUILDIN(getitem)
for (i = 0; i < amount; i += get_count)
{
// if not pet egg
- if (!pet_create_egg(sd, nameid))
+ if (!pet->create_egg(sd, nameid))
{
if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT)))
{
@@ -6040,7 +6041,7 @@ BUILDIN(getitem2)
item_tmp.card[3]=(short)c4;
//Check if it's stackable.
- if (!itemdb_isstackable(nameid))
+ if (!itemdb->isstackable(nameid))
get_count = 1;
else
get_count = amount;
@@ -6048,7 +6049,7 @@ BUILDIN(getitem2)
for (i = 0; i < amount; i += get_count)
{
// if not pet egg
- if (!pet_create_egg(sd, nameid))
+ if (!pet->create_egg(sd, nameid))
{
if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT)))
{
@@ -6156,7 +6157,7 @@ BUILDIN(getnameditem)
}else
nameid = script->conv_num(st,data);
- if(!itemdb->exists(nameid)/* || itemdb_isstackable(nameid)*/)
+ if(!itemdb->exists(nameid)/* || itemdb->isstackable(nameid)*/)
{ //Even though named stackable items "could" be risky, they are required for certain quests.
script_pushint(st,0);
return true;
@@ -6274,7 +6275,7 @@ BUILDIN(makeitem)
if(!flag)
item_tmp.identify=1;
else
- item_tmp.identify=itemdb_isidentified2(item_data);
+ item_tmp.identify=itemdb->isidentified2(item_data);
iMap->addflooritem(&item_tmp,amount,m,x,y,0,0,0,0);
@@ -6664,7 +6665,7 @@ BUILDIN(getnpcid)
if( script_hasdata(st,3) )
{// unique npc name
- if( ( nd = npc_name2id(script_getstr(st,3)) ) == NULL )
+ if( ( nd = npc->name2id(script_getstr(st,3)) ) == NULL )
{
ShowError("buildin_getnpcid: No such NPC '%s'.\n", script_getstr(st,3));
script_pushint(st,0);
@@ -6730,19 +6731,19 @@ BUILDIN(getpartymember)
if(p->party.member[i].account_id){
switch (type) {
case 2:
- mapreg_setreg(reference_uid(script->add_str("$@partymemberaid"), j),p->party.member[i].account_id);
+ mapreg->setreg(reference_uid(script->add_str("$@partymemberaid"), j),p->party.member[i].account_id);
break;
case 1:
- mapreg_setreg(reference_uid(script->add_str("$@partymembercid"), j),p->party.member[i].char_id);
+ mapreg->setreg(reference_uid(script->add_str("$@partymembercid"), j),p->party.member[i].char_id);
break;
default:
- mapreg_setregstr(reference_uid(script->add_str("$@partymembername$"), j),p->party.member[i].name);
+ mapreg->setregstr(reference_uid(script->add_str("$@partymembername$"), j),p->party.member[i].name);
}
j++;
}
}
}
- mapreg_setreg(script->add_str("$@partymembercount"),j);
+ mapreg->setreg(script->add_str("$@partymembercount"),j);
return true;
}
@@ -8349,17 +8350,17 @@ BUILDIN(makepet)
if( sd == NULL )
return true;
- pet_id = search_petDB_index(id, PET_CLASS);
+ pet_id = pet->search_petDB_index(id, PET_CLASS);
if (pet_id < 0)
- pet_id = search_petDB_index(id, PET_EGG);
+ pet_id = pet->search_petDB_index(id, PET_EGG);
if (pet_id >= 0 && sd) {
- sd->catch_target_class = pet_db[pet_id].class_;
+ sd->catch_target_class = pet->db[pet_id].class_;
intif->create_pet(
sd->status.account_id, sd->status.char_id,
- (short)pet_db[pet_id].class_, (short)mob_db(pet_db[pet_id].class_)->lv,
- (short)pet_db[pet_id].EggID, 0, (short)pet_db[pet_id].intimate,
- 100, 0, 1, pet_db[pet_id].jname);
+ (short)pet->db[pet_id].class_, (short)mob->db(pet->db[pet_id].class_)->lv,
+ (short)pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate,
+ 100, 0, 1, pet->db[pet_id].jname);
}
return true;
@@ -8484,7 +8485,7 @@ BUILDIN(monster)
}
}
- if (class_ >= 0 && !mobdb_checkid(class_))
+ if (class_ >= 0 && !mob->db_checkid(class_))
{
ShowWarning("buildin_monster: Attempted to spawn non-existing monster class %d\n", class_);
return false;
@@ -8509,7 +8510,7 @@ BUILDIN(monster)
}
}
- mob_id = mob_once_spawn(sd, m, x, y, str, class_, amount, event, size, ai);
+ mob_id = mob->once_spawn(sd, m, x, y, str, class_, amount, event, size, ai);
script_pushint(st, mob_id);
return true;
}
@@ -8520,30 +8521,30 @@ BUILDIN(getmobdrops)
{
int class_ = script_getnum(st,2);
int i, j = 0;
- struct mob_db *mob;
+ struct mob_db *monster;
- if( !mobdb_checkid(class_) )
+ if( !mob->db_checkid(class_) )
{
script_pushint(st, 0);
return true;
}
- mob = mob_db(class_);
+ monster = mob->db(class_);
for( i = 0; i < MAX_MOB_DROP; i++ )
{
- if( mob->dropitem[i].nameid < 1 )
+ if( monster->dropitem[i].nameid < 1 )
continue;
- if( itemdb->exists(mob->dropitem[i].nameid) == NULL )
+ if( itemdb->exists(monster->dropitem[i].nameid) == NULL )
continue;
- mapreg_setreg(reference_uid(script->add_str("$@MobDrop_item"), j), mob->dropitem[i].nameid);
- mapreg_setreg(reference_uid(script->add_str("$@MobDrop_rate"), j), mob->dropitem[i].p);
+ mapreg->setreg(reference_uid(script->add_str("$@MobDrop_item"), j), monster->dropitem[i].nameid);
+ mapreg->setreg(reference_uid(script->add_str("$@MobDrop_rate"), j), monster->dropitem[i].p);
j++;
}
- mapreg_setreg(script->add_str("$@MobDrop_count"), j);
+ mapreg->setreg(script->add_str("$@MobDrop_count"), j);
script_pushint(st, 1);
return true;
@@ -8607,7 +8608,7 @@ BUILDIN(areamonster)
}
}
- mob_id = mob_once_spawn_area(sd, m, x0, y0, x1, y1, str, class_, amount, event, size, ai);
+ mob_id = mob->once_spawn_area(sd, m, x0, y0, x1, y1, str, class_, amount, event, size, ai);
script_pushint(st, mob_id);
return true;
@@ -8761,7 +8762,7 @@ BUILDIN(clone)
master_id = 0;
}
if (sd) //Return ID of newly crafted clone.
- script_pushint(st,mob_clone_spawn(sd, m, x, y, event, master_id, mode, flag, 1000*duration));
+ script_pushint(st,mob->clone_spawn(sd, m, x, y, event, master_id, mode, flag, 1000*duration));
else //Failed to create clone.
script_pushint(st,0);
@@ -8780,7 +8781,7 @@ BUILDIN(doevent)
}
check_event(st, event);
- npc_event(sd, event, 0);
+ npc->event(sd, event, 0);
return true;
}
/*==========================================
@@ -8789,7 +8790,7 @@ BUILDIN(donpcevent)
{
const char* event = script_getstr(st,2);
check_event(st, event);
- if( !npc_event_do(event) ) {
+ if( !npc->event_do(event) ) {
struct npc_data * nd = iMap->id2nd(st->oid);
ShowDebug("NPCEvent '%s' not found! (source: %s)\n",event,nd?nd->name:"Unknown");
script_pushint(st, 0);
@@ -8802,12 +8803,12 @@ BUILDIN(donpcevent)
/// basically a specialized 'donpcevent', with the event specified as two arguments instead of one
BUILDIN(cmdothernpc) // Added by RoVeRT
{
- const char* npc = script_getstr(st,2);
+ const char* npc_name = script_getstr(st,2);
const char* command = script_getstr(st,3);
char event[EVENT_NAME_LENGTH];
- snprintf(event, sizeof(event), "%s::OnCommand%s", npc, command);
+ snprintf(event, sizeof(event), "%s::OnCommand%s", npc_name, command);
check_event(st, event);
- npc_event_do(event);
+ npc->event_do(event);
return true;
}
@@ -8871,7 +8872,7 @@ BUILDIN(initnpctimer)
if( script_hasdata(st,3) )
{ //Two arguments: NPC name and attach flag.
- nd = npc_name2id(script_getstr(st, 2));
+ nd = npc->name2id(script_getstr(st, 2));
flag = script_getnum(st,3);
}
else if( script_hasdata(st,2) )
@@ -8880,7 +8881,7 @@ BUILDIN(initnpctimer)
data = script_getdata(st,2);
script->get_val(st,data);
if( data_isstring(data) ) //NPC name
- nd = npc_name2id(script->conv_str(st, data));
+ nd = npc->name2id(script->conv_str(st, data));
else if( data_isint(data) ) //Flag
{
nd = (struct npc_data *)iMap->id2bl(st->oid);
@@ -8906,8 +8907,8 @@ BUILDIN(initnpctimer)
}
nd->u.scr.timertick = 0;
- npc_settimerevent_tick(nd,0);
- npc_timerevent_start(nd, st->rid);
+ npc->settimerevent_tick(nd,0);
+ npc->timerevent_start(nd, st->rid);
return true;
}
/*==========================================
@@ -8919,7 +8920,7 @@ BUILDIN(startnpctimer)
if( script_hasdata(st,3) )
{ //Two arguments: NPC name and attach flag.
- nd = npc_name2id(script_getstr(st, 2));
+ nd = npc->name2id(script_getstr(st, 2));
flag = script_getnum(st,3);
}
else if( script_hasdata(st,2) )
@@ -8928,7 +8929,7 @@ BUILDIN(startnpctimer)
data = script_getdata(st,2);
script->get_val(st,data);
if( data_isstring(data) ) //NPC name
- nd = npc_name2id(script->conv_str(st, data));
+ nd = npc->name2id(script->conv_str(st, data));
else if( data_isint(data) ) //Flag
{
nd = (struct npc_data *)iMap->id2bl(st->oid);
@@ -8953,7 +8954,7 @@ BUILDIN(startnpctimer)
nd->u.scr.rid = sd->bl.id;
}
- npc_timerevent_start(nd, st->rid);
+ npc->timerevent_start(nd, st->rid);
return true;
}
/*==========================================
@@ -8965,7 +8966,7 @@ BUILDIN(stopnpctimer)
if( script_hasdata(st,3) )
{ //Two arguments: NPC name and attach flag.
- nd = npc_name2id(script_getstr(st, 2));
+ nd = npc->name2id(script_getstr(st, 2));
flag = script_getnum(st,3);
}
else if( script_hasdata(st,2) )
@@ -8974,7 +8975,7 @@ BUILDIN(stopnpctimer)
data = script_getdata(st,2);
script->get_val(st,data);
if( data_isstring(data) ) //NPC name
- nd = npc_name2id(script->conv_str(st, data));
+ nd = npc->name2id(script->conv_str(st, data));
else if( data_isint(data) ) //Flag
{
nd = (struct npc_data *)iMap->id2bl(st->oid);
@@ -8994,7 +8995,7 @@ BUILDIN(stopnpctimer)
if( flag ) //Detach
nd->u.scr.rid = 0;
- npc_timerevent_stop(nd);
+ npc->timerevent_stop(nd);
return true;
}
/*==========================================
@@ -9007,7 +9008,7 @@ BUILDIN(getnpctimer)
int val = 0;
if( script_hasdata(st,3) )
- nd = npc_name2id(script_getstr(st,3));
+ nd = npc->name2id(script_getstr(st,3));
else
nd = (struct npc_data *)iMap->id2bl(st->oid);
@@ -9020,7 +9021,7 @@ BUILDIN(getnpctimer)
switch( type )
{
- case 0: val = npc_gettimerevent_tick(nd); break;
+ case 0: val = npc->gettimerevent_tick(nd); break;
case 1:
if( nd->u.scr.rid )
{
@@ -9050,7 +9051,7 @@ BUILDIN(setnpctimer)
tick = script_getnum(st,2);
if( script_hasdata(st,3) )
- nd = npc_name2id(script_getstr(st,3));
+ nd = npc->name2id(script_getstr(st,3));
else
nd = (struct npc_data *)iMap->id2bl(st->oid);
@@ -9061,7 +9062,7 @@ BUILDIN(setnpctimer)
return false;
}
- npc_settimerevent_tick(nd,tick);
+ npc->settimerevent_tick(nd,tick);
script_pushint(st,0);
return true;
}
@@ -9106,7 +9107,7 @@ BUILDIN(detachnpctimer)
struct npc_data *nd;
if( script_hasdata(st,2) )
- nd = npc_name2id(script_getstr(st,2));
+ nd = npc->name2id(script_getstr(st,2));
else
nd = (struct npc_data *)iMap->id2bl(st->oid);
@@ -9169,7 +9170,7 @@ BUILDIN(announce) {
if (fontColor)
intif->broadcast2(mes, (int)strlen(mes)+1, strtol(fontColor, (char **)NULL, 0), fontType, fontSize, fontAlign, fontY);
else
- intif->broadcast(mes, (int)strlen(mes)+1, flag&(BC_SOURCE_MASK|BC_TARGET_MASK));
+ intif->broadcast(mes, (int)strlen(mes)+1, flag&BC_COLOR_MASK);
}
return true;
}
@@ -9246,7 +9247,7 @@ BUILDIN(mapannounce)
return true;
iMap->foreachinmap(buildin_announce_sub, m, BL_PC,
- mes, strlen(mes)+1, flag&(BC_SOURCE_MASK|BC_TARGET_MASK), fontColor, fontType, fontSize, fontAlign, fontY);
+ mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY);
return true;
}
/*==========================================
@@ -9271,7 +9272,7 @@ BUILDIN(areaannounce)
return true;
iMap->foreachinarea(buildin_announce_sub, m, x0, y0, x1, y1, BL_PC,
- mes, strlen(mes)+1, flag&(BC_SOURCE_MASK|BC_TARGET_MASK), fontColor, fontType, fontSize, fontAlign, fontY);
+ mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY);
return true;
}
@@ -9465,7 +9466,7 @@ BUILDIN(enablenpc)
{
const char *str;
str=script_getstr(st,2);
- npc_enable(str,1);
+ npc->enable(str,1);
return true;
}
/*==========================================
@@ -9474,7 +9475,7 @@ BUILDIN(disablenpc)
{
const char *str;
str=script_getstr(st,2);
- npc_enable(str,0);
+ npc->enable(str,0);
return true;
}
@@ -9484,7 +9485,7 @@ BUILDIN(hideoffnpc)
{
const char *str;
str=script_getstr(st,2);
- npc_enable(str,2);
+ npc->enable(str,2);
return true;
}
/*==========================================
@@ -9493,7 +9494,7 @@ BUILDIN(hideonnpc)
{
const char *str;
str=script_getstr(st,2);
- npc_enable(str,4);
+ npc->enable(str,4);
return true;
}
@@ -9760,7 +9761,7 @@ BUILDIN(catchpet)
if( sd == NULL )
return true;
- pet_catch_process1(sd,pet_id);
+ pet->catch_process1(sd,pet_id);
return true;
}
@@ -10034,7 +10035,7 @@ BUILDIN(globalmes)
name=nd->name; //use current npc name
}
- npc_globalmessage(name,mes); // broadcast to all players connected
+ npc->globalmessage(name,mes); // broadcast to all players connected
return true;
}
@@ -10073,7 +10074,7 @@ BUILDIN(delwaitingroom)
{
struct npc_data* nd;
if( script_hasdata(st,2) )
- nd = npc_name2id(script_getstr(st, 2));
+ nd = npc->name2id(script_getstr(st, 2));
else
nd = (struct npc_data *)iMap->id2bl(st->oid);
if( nd != NULL )
@@ -10091,7 +10092,7 @@ BUILDIN(waitingroomkickall)
struct chat_data* cd;
if( script_hasdata(st,2) )
- nd = npc_name2id(script_getstr(st,2));
+ nd = npc->name2id(script_getstr(st,2));
else
nd = (struct npc_data *)iMap->id2bl(st->oid);
@@ -10110,7 +10111,7 @@ BUILDIN(enablewaitingroomevent)
struct chat_data* cd;
if( script_hasdata(st,2) )
- nd = npc_name2id(script_getstr(st, 2));
+ nd = npc->name2id(script_getstr(st, 2));
else
nd = (struct npc_data *)iMap->id2bl(st->oid);
@@ -10129,7 +10130,7 @@ BUILDIN(disablewaitingroomevent)
struct chat_data *cd;
if( script_hasdata(st,2) )
- nd = npc_name2id(script_getstr(st, 2));
+ nd = npc->name2id(script_getstr(st, 2));
else
nd = (struct npc_data *)iMap->id2bl(st->oid);
@@ -10160,7 +10161,7 @@ BUILDIN(getwaitingroomstate)
type = script_getnum(st,2);
if( script_hasdata(st,3) )
- nd = npc_name2id(script_getstr(st, 3));
+ nd = npc->name2id(script_getstr(st, 3));
else
nd = (struct npc_data *)iMap->id2bl(st->oid);
@@ -10239,7 +10240,7 @@ BUILDIN(warpwaitingpc)
pc->payzeny(sd, cd->zeny, LOG_TYPE_NPC, NULL);
}
- mapreg_setreg(reference_uid(script->add_str("$@warpwaitingpc"), i), sd->bl.id);
+ mapreg->setreg(reference_uid(script->add_str("$@warpwaitingpc"), i), sd->bl.id);
if( strcmp(map_name,"Random") == 0 )
pc->randomwarp(sd,CLR_TELEPORT);
@@ -10248,7 +10249,7 @@ BUILDIN(warpwaitingpc)
else
pc->setpos(sd, mapindex_name2id(map_name), x, y, CLR_OUTSIGHT);
}
- mapreg_setreg(script->add_str("$@warpwaitingpcnum"), i);
+ mapreg->setreg(script->add_str("$@warpwaitingpcnum"), i);
return true;
}
@@ -10489,7 +10490,7 @@ BUILDIN(setmapflag)
char empty[1] = "\0";
char params[MAP_ZONE_MAPFLAG_LENGTH];
memcpy(params, val2, MAP_ZONE_MAPFLAG_LENGTH);
- npc_parse_mapflag(map[m].name, empty, zone, params, empty, empty, empty);
+ npc->parse_mapflag(map[m].name, empty, zone, params, empty, empty, empty);
}
break;
case MF_NOCOMMAND: map[m].nocommand = (val <= 0) ? 100 : val; break;
@@ -10745,7 +10746,7 @@ BUILDIN(emotion)
} else
if( script_hasdata(st,4) )
{
- TBL_NPC *nd = npc_name2id(script_getstr(st,4));
+ TBL_NPC *nd = npc->name2id(script_getstr(st,4));
if(nd)
clif->emotion(&nd->bl,type);
}
@@ -11371,7 +11372,7 @@ BUILDIN(strmobinfo)
int num=script_getnum(st,2);
int class_=script_getnum(st,3);
- if(!mobdb_checkid(class_))
+ if(!mob->db_checkid(class_))
{
if (num < 3) //requested a string
script_pushconststr(st,"");
@@ -11381,13 +11382,13 @@ BUILDIN(strmobinfo)
}
switch (num) {
- case 1: script_pushstrcopy(st,mob_db(class_)->name); break;
- case 2: script_pushstrcopy(st,mob_db(class_)->jname); break;
- case 3: script_pushint(st,mob_db(class_)->lv); break;
- case 4: script_pushint(st,mob_db(class_)->status.max_hp); break;
- case 5: script_pushint(st,mob_db(class_)->status.max_sp); break;
- case 6: script_pushint(st,mob_db(class_)->base_exp); break;
- case 7: script_pushint(st,mob_db(class_)->job_exp); break;
+ case 1: script_pushstrcopy(st,mob->db(class_)->name); break;
+ case 2: script_pushstrcopy(st,mob->db(class_)->jname); break;
+ case 3: script_pushint(st,mob->db(class_)->lv); break;
+ case 4: script_pushint(st,mob->db(class_)->status.max_hp); break;
+ case 5: script_pushint(st,mob->db(class_)->status.max_sp); break;
+ case 6: script_pushint(st,mob->db(class_)->base_exp); break;
+ case 7: script_pushint(st,mob->db(class_)->job_exp); break;
default:
script_pushint(st,0);
break;
@@ -11435,7 +11436,7 @@ BUILDIN(guardian)
}
check_event(st, evt);
- script_pushint(st, mob_spawn_guardian(map,x,y,str,class_,evt,guardian,has_index));
+ script_pushint(st, mob->spawn_guardian(map,x,y,str,class_,evt,guardian,has_index));
return true;
}
@@ -11694,7 +11695,7 @@ BUILDIN(petskillbonus)
if (pd->bonus)
{ //Clear previous bonus
if (pd->bonus->timer != INVALID_TIMER)
- iTimer->delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
+ iTimer->delete_timer(pd->bonus->timer, pet->skill_bonus_timer);
} else //init
pd->bonus = (struct pet_bonus *) aMalloc(sizeof(struct pet_bonus));
@@ -11710,7 +11711,7 @@ BUILDIN(petskillbonus)
if (battle_config.pet_equip_required && pd->pet.equip == 0)
pd->bonus->timer = INVALID_TIMER;
else
- pd->bonus->timer = iTimer->add_timer(iTimer->gettick()+pd->bonus->delay*1000, pet_skill_bonus_timer, sd->bl.id, 0);
+ pd->bonus->timer = iTimer->add_timer(iTimer->gettick()+pd->bonus->delay*1000, pet->skill_bonus_timer, sd->bl.id, 0);
return true;
}
@@ -11737,7 +11738,7 @@ BUILDIN(petloot)
pd = sd->pd;
if (pd->loot != NULL)
{ //Release whatever was there already and reallocate memory
- pet_lootitem_drop(pd, pd->msd);
+ pet->lootitem_drop(pd, pd->msd);
aFree(pd->loot->item);
}
else
@@ -11827,7 +11828,7 @@ BUILDIN(disguise)
id = script_getnum(st,2);
- if (mobdb_checkid(id) || npcdb_checkid(id)) {
+ if (mob->db_checkid(id) || npcdb_checkid(id)) {
pc->disguise(sd, id);
script_pushint(st,id);
} else
@@ -11878,7 +11879,7 @@ BUILDIN(misceffect)
int type;
type=script_getnum(st,2);
- if(st->oid && st->oid != fake_nd->bl.id) {
+ if(st->oid && st->oid != npc->fake_nd->bl.id) {
struct block_list *bl = iMap->id2bl(st->oid);
if (bl)
clif->specialeffect(bl,type,AREA);
@@ -12064,7 +12065,7 @@ BUILDIN(petrecovery)
if (pd->recovery)
{ //Halt previous bonus
if (pd->recovery->timer != INVALID_TIMER)
- iTimer->delete_timer(pd->recovery->timer, pet_recovery_timer);
+ iTimer->delete_timer(pd->recovery->timer, pet->recovery_timer);
} else //Init
pd->recovery = (struct pet_recovery *)aMalloc(sizeof(struct pet_recovery));
@@ -12092,9 +12093,9 @@ BUILDIN(petheal)
if (pd->s_skill->timer != INVALID_TIMER)
{
if (pd->s_skill->id)
- iTimer->delete_timer(pd->s_skill->timer, pet_skill_support_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet->skill_support_timer);
else
- iTimer->delete_timer(pd->s_skill->timer, pet_heal_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet->heal_timer);
}
} else //init memory
pd->s_skill = (struct pet_skill_support *) aMalloc(sizeof(struct pet_skill_support));
@@ -12110,7 +12111,7 @@ BUILDIN(petheal)
if (battle_config.pet_equip_required && pd->pet.equip == 0)
pd->s_skill->timer = INVALID_TIMER;
else
- pd->s_skill->timer = iTimer->add_timer(iTimer->gettick()+pd->s_skill->delay*1000,pet_heal_timer,sd->bl.id,0);
+ pd->s_skill->timer = iTimer->add_timer(iTimer->gettick()+pd->s_skill->delay*1000,pet->heal_timer,sd->bl.id,0);
return true;
}
@@ -12186,9 +12187,9 @@ BUILDIN(petskillsupport)
if (pd->s_skill->timer != INVALID_TIMER)
{
if (pd->s_skill->id)
- iTimer->delete_timer(pd->s_skill->timer, pet_skill_support_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet->skill_support_timer);
else
- iTimer->delete_timer(pd->s_skill->timer, pet_heal_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet->heal_timer);
}
} else //init memory
pd->s_skill = (struct pet_skill_support *) aMalloc(sizeof(struct pet_skill_support));
@@ -12203,7 +12204,7 @@ BUILDIN(petskillsupport)
if (battle_config.pet_equip_required && pd->pet.equip == 0)
pd->s_skill->timer = INVALID_TIMER;
else
- pd->s_skill->timer = iTimer->add_timer(iTimer->gettick()+pd->s_skill->delay*1000,pet_skill_support_timer,sd->bl.id,0);
+ pd->s_skill->timer = iTimer->add_timer(iTimer->gettick()+pd->s_skill->delay*1000,pet->skill_support_timer,sd->bl.id,0);
return true;
}
@@ -12260,7 +12261,7 @@ BUILDIN(specialeffect)
if( script_hasdata(st,4) )
{
- TBL_NPC *nd = npc_name2id(script_getstr(st,4));
+ TBL_NPC *nd = npc->name2id(script_getstr(st,4));
if(nd)
clif->specialeffect(&nd->bl, type, target);
}
@@ -12569,19 +12570,19 @@ BUILDIN(jump_zero)
*------------------------------------------*/
BUILDIN(movenpc) {
TBL_NPC *nd = NULL;
- const char *npc;
+ const char *npc_name;
int x,y;
- npc = script_getstr(st,2);
+ npc_name = script_getstr(st,2);
x = script_getnum(st,3);
y = script_getnum(st,4);
- if ((nd = npc_name2id(npc)) == NULL)
+ if ((nd = npc->name2id(npc_name)) == NULL)
return -1;
if (script_hasdata(st,5))
nd->dir = script_getnum(st,5) % 8;
- npc_movenpc(nd, x, y);
+ npc->movenpc(nd, x, y);
return true;
}
@@ -12634,7 +12635,7 @@ BUILDIN(npcspeed) {
nd = (struct npc_data *)iMap->id2bl(st->oid);
if( nd ) {
- unit_bl2ud2(&nd->bl); // ensure nd->ud is safe to edit
+ unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit
nd->speed = speed;
nd->ud->state.speed_changed = 1;
}
@@ -12650,13 +12651,13 @@ BUILDIN(npcwalkto) {
y=script_getnum(st,3);
if( nd ) {
- unit_bl2ud2(&nd->bl); // ensure nd->ud is safe to edit
+ unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit
if (!nd->status.hp) {
status_calc_npc(nd, true);
} else {
status_calc_npc(nd, false);
}
- unit_walktoxy(&nd->bl,x,y,0);
+ unit->walktoxy(&nd->bl,x,y,0);
}
return true;
@@ -12666,8 +12667,8 @@ BUILDIN(npcstop) {
struct npc_data *nd = (struct npc_data *)iMap->id2bl(st->oid);
if( nd ) {
- unit_bl2ud2(&nd->bl); // ensure nd->ud is safe to edit
- unit_stop_walking(&nd->bl,1|4);
+ unit->bl2ud2(&nd->bl); // ensure nd->ud is safe to edit
+ unit->stop_walking(&nd->bl,1|4);
}
return true;
@@ -12796,7 +12797,7 @@ BUILDIN(getmapxy)
if( script_hasdata(st,6) )
{
struct npc_data *nd;
- nd=npc_name2id(script_getstr(st,6));
+ nd=npc->name2id(script_getstr(st,6));
if (nd)
bl = &nd->bl;
} else //In case the origin is not an npc?
@@ -12931,14 +12932,14 @@ BUILDIN(summon)
clif->skill_poseffect(&sd->bl,AM_CALLHOMUN,1,sd->bl.x,sd->bl.y,tick);
- md = mob_once_spawn_sub(&sd->bl, sd->bl.m, sd->bl.x, sd->bl.y, str, _class, event, SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(&sd->bl, sd->bl.m, sd->bl.x, sd->bl.y, str, _class, event, SZ_SMALL, AI_NONE);
if (md) {
md->master_id=sd->bl.id;
md->special_state.ai = AI_ATTACK;
if( md->deletetimer != INVALID_TIMER )
- iTimer->delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = iTimer->add_timer(tick+(timeout>0?timeout*1000:60000),mob_timer_delete,md->bl.id,0);
- mob_spawn (md); //Now it is ready for spawning.
+ iTimer->delete_timer(md->deletetimer, mob->timer_delete);
+ md->deletetimer = iTimer->add_timer(tick+(timeout>0?timeout*1000:60000),mob->timer_delete,md->bl.id,0);
+ mob->spawn (md); //Now it is ready for spawning.
clif->specialeffect(&md->bl,344,AREA);
sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
}
@@ -13219,7 +13220,7 @@ BUILDIN(autoequip)
return false;
}
- if( !itemdb_isequip2(item_data) )
+ if( !itemdb->isequip2(item_data) )
{
ShowError("buildin_autoequip: Item '%d' cannot be equipped.\n", nameid);
return false;
@@ -14082,7 +14083,7 @@ BUILDIN(setnpcdisplay)
return false;
}
- nd = npc_name2id(name);
+ nd = npc->name2id(name);
if( nd == NULL )
{// not found
script_pushint(st,1);
@@ -14091,7 +14092,7 @@ BUILDIN(setnpcdisplay)
// update npc
if( newname )
- npc_setdisplayname(nd, newname);
+ npc->setdisplayname(nd, newname);
if( size != -1 && size != (int)nd->size )
nd->size = size;
@@ -14099,7 +14100,7 @@ BUILDIN(setnpcdisplay)
size = -1;
if( class_ != -1 && nd->class_ != class_ )
- npc_setclass(nd, class_);
+ npc->setclass(nd, class_);
else if( size != -1 )
{ // Required to update the visual size
clif->clearunit_area(&nd->bl, CLR_OUTSIGHT);
@@ -14383,7 +14384,7 @@ BUILDIN(callshop)
shopname = script_getstr(st, 2);
if( script_hasdata(st,3) )
flag = script_getnum(st,3);
- nd = npc_name2id(shopname);
+ nd = npc->name2id(shopname);
if( !nd || nd->bl.type != BL_NPC || (nd->subtype != SHOP && nd->subtype != CASHSHOP) )
{
ShowError("buildin_callshop: Shop [%s] not found (or NPC is not shop type)\n", shopname);
@@ -14398,8 +14399,8 @@ BUILDIN(callshop)
switch( flag )
{
- case 1: npc_buysellsel(sd,nd->bl.id,0); break; //Buy window
- case 2: npc_buysellsel(sd,nd->bl.id,1); break; //Sell window
+ case 1: npc->buysellsel(sd,nd->bl.id,0); break; //Buy window
+ case 2: npc->buysellsel(sd,nd->bl.id,1); break; //Sell window
default: clif->npcbuysell(sd,nd->bl.id); break; //Show menu
}
}
@@ -14414,7 +14415,7 @@ BUILDIN(callshop)
BUILDIN(npcshopitem)
{
const char* npcname = script_getstr(st, 2);
- struct npc_data* nd = npc_name2id(npcname);
+ struct npc_data* nd = npc->name2id(npcname);
int n, i;
int amount;
@@ -14443,7 +14444,7 @@ BUILDIN(npcshopitem)
BUILDIN(npcshopadditem)
{
const char* npcname = script_getstr(st,2);
- struct npc_data* nd = npc_name2id(npcname);
+ struct npc_data* nd = npc->name2id(npcname);
int n, i;
int amount;
@@ -14472,7 +14473,7 @@ BUILDIN(npcshopadditem)
BUILDIN(npcshopdelitem)
{
const char* npcname = script_getstr(st,2);
- struct npc_data* nd = npc_name2id(npcname);
+ struct npc_data* nd = npc->name2id(npcname);
unsigned int nameid;
int n, i;
int amount;
@@ -14511,7 +14512,7 @@ BUILDIN(npcshopdelitem)
BUILDIN(npcshopattach)
{
const char* npcname = script_getstr(st,2);
- struct npc_data* nd = npc_name2id(npcname);
+ struct npc_data* nd = npc->name2id(npcname);
int flag = 1;
if( script_hasdata(st,3) )
@@ -14611,11 +14612,11 @@ BUILDIN(setitemscript)
*------------------------------------------*/
BUILDIN(getmonsterinfo)
{
- struct mob_db *mob;
+ struct mob_db *monster;
int mob_id;
mob_id = script_getnum(st,2);
- if (!mobdb_checkid(mob_id)) {
+ if (!mob->db_checkid(mob_id)) {
ShowError("buildin_getmonsterinfo: Wrong Monster ID: %i\n", mob_id);
if ( !script_getnum(st,3) ) //requested a string
script_pushconststr(st,"null");
@@ -14623,31 +14624,31 @@ BUILDIN(getmonsterinfo)
script_pushint(st,-1);
return -1;
}
- mob = mob_db(mob_id);
+ monster = mob->db(mob_id);
switch ( script_getnum(st,3) ) {
- case 0: script_pushstrcopy(st,mob->jname); break;
- case 1: script_pushint(st,mob->lv); break;
- case 2: script_pushint(st,mob->status.max_hp); break;
- case 3: script_pushint(st,mob->base_exp); break;
- case 4: script_pushint(st,mob->job_exp); break;
- case 5: script_pushint(st,mob->status.rhw.atk); break;
- case 6: script_pushint(st,mob->status.rhw.atk2); break;
- case 7: script_pushint(st,mob->status.def); break;
- case 8: script_pushint(st,mob->status.mdef); break;
- case 9: script_pushint(st,mob->status.str); break;
- case 10: script_pushint(st,mob->status.agi); break;
- case 11: script_pushint(st,mob->status.vit); break;
- case 12: script_pushint(st,mob->status.int_); break;
- case 13: script_pushint(st,mob->status.dex); break;
- case 14: script_pushint(st,mob->status.luk); break;
- case 15: script_pushint(st,mob->status.rhw.range); break;
- case 16: script_pushint(st,mob->range2); break;
- case 17: script_pushint(st,mob->range3); break;
- case 18: script_pushint(st,mob->status.size); break;
- case 19: script_pushint(st,mob->status.race); break;
- case 20: script_pushint(st,mob->status.def_ele); break;
- case 21: script_pushint(st,mob->status.mode); break;
- case 22: script_pushint(st,mob->mexp); break;
+ case 0: script_pushstrcopy(st,monster->jname); break;
+ case 1: script_pushint(st,monster->lv); break;
+ case 2: script_pushint(st,monster->status.max_hp); break;
+ case 3: script_pushint(st,monster->base_exp); break;
+ case 4: script_pushint(st,monster->job_exp); break;
+ case 5: script_pushint(st,monster->status.rhw.atk); break;
+ case 6: script_pushint(st,monster->status.rhw.atk2); break;
+ case 7: script_pushint(st,monster->status.def); break;
+ case 8: script_pushint(st,monster->status.mdef); break;
+ case 9: script_pushint(st,monster->status.str); break;
+ case 10: script_pushint(st,monster->status.agi); break;
+ case 11: script_pushint(st,monster->status.vit); break;
+ case 12: script_pushint(st,monster->status.int_); break;
+ case 13: script_pushint(st,monster->status.dex); break;
+ case 14: script_pushint(st,monster->status.luk); break;
+ case 15: script_pushint(st,monster->status.rhw.range); break;
+ case 16: script_pushint(st,monster->range2); break;
+ case 17: script_pushint(st,monster->range3); break;
+ case 18: script_pushint(st,monster->status.size); break;
+ case 19: script_pushint(st,monster->status.race); break;
+ case 20: script_pushint(st,monster->status.def_ele); break;
+ case 21: script_pushint(st,monster->status.mode); break;
+ case 22: script_pushint(st,monster->mexp); break;
default: script_pushint(st,-1); //wrong Index
}
return true;
@@ -14917,15 +14918,15 @@ BUILDIN(unitwalk) {
}
if( bl->type == BL_NPC ) {
- unit_bl2ud2(bl); // ensure the ((TBL_NPC*)bl)->ud is safe to edit
+ unit->bl2ud2(bl); // ensure the ((TBL_NPC*)bl)->ud is safe to edit
}
if( script_hasdata(st,4) ) {
int x = script_getnum(st,3);
int y = script_getnum(st,4);
- script_pushint(st, unit_walktoxy(bl,x,y,0));// We'll use harder calculations.
+ script_pushint(st, unit->walktoxy(bl,x,y,0));// We'll use harder calculations.
} else {
int map_id = script_getnum(st,3);
- script_pushint(st, unit_walktobl(bl,iMap->id2bl(map_id),65025,1));
+ script_pushint(st, unit->walktobl(bl,iMap->id2bl(map_id),65025,1));
}
return true;
@@ -14971,8 +14972,8 @@ BUILDIN(unitwarp) {
map = iMap->mapname2mapid(mapname);
if( map >= 0 && bl != NULL ) {
- unit_bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit
- script_pushint(st, unit_warp(bl,map,x,y,CLR_OUTSIGHT));
+ unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit
+ script_pushint(st, unit->warp(bl,map,x,y,CLR_OUTSIGHT));
} else {
script_pushint(st, 0);
}
@@ -15038,7 +15039,7 @@ BUILDIN(unitattack)
script_pushint(st, 0);
return false;
}
- script_pushint(st, unit_walktobl(unit_bl, target_bl, 65025, 2));
+ script_pushint(st, unit->walktobl(unit_bl, target_bl, 65025, 2));
return true;
}
@@ -15054,9 +15055,9 @@ BUILDIN(unitstop) {
bl = iMap->id2bl(unit_id);
if( bl != NULL )
{
- unit_bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit
- unit_stop_attack(bl);
- unit_stop_walking(bl,4);
+ unit->bl2ud2(bl); // ensure ((TBL_NPC*)bl)->ud is safe to edit
+ unit->stop_attack(bl);
+ unit->stop_walking(bl,4);
if( bl->type == BL_MOB )
((TBL_MOB*)bl)->target_id = 0;
}
@@ -15138,7 +15139,7 @@ BUILDIN(unitskilluseid)
status_calc_npc(((TBL_NPC*)bl), false);
}
}
- unit_skilluse_id(bl, target_id, skill_id, skill_lv);
+ unit->skilluse_id(bl, target_id, skill_id, skill_lv);
}
return true;
@@ -15173,7 +15174,7 @@ BUILDIN(unitskillusepos)
status_calc_npc(((TBL_NPC*)bl), false);
}
}
- unit_skilluse_pos(bl, skill_x, skill_y, skill_id, skill_lv);
+ unit->skilluse_pos(bl, skill_x, skill_y, skill_id, skill_lv);
}
return true;
@@ -15245,7 +15246,7 @@ BUILDIN(awake) {
struct script_state *tst;
struct npc_data* nd;
- if( ( nd = npc_name2id(script_getstr(st, 2)) ) == NULL ) {
+ if( ( nd = npc->name2id(script_getstr(st, 2)) ) == NULL ) {
ShowError("awake: NPC \"%s\" not found\n", script_getstr(st, 2));
return false;
}
@@ -15308,7 +15309,7 @@ BUILDIN(getvariableofnpc)
return false;
}
- nd = npc_name2id(script_getstr(st,3));
+ nd = npc->name2id(script_getstr(st,3));
if( nd == NULL || nd->subtype != SCRIPT || nd->u.scr.script == NULL )
{// NPC not found or has no script
ShowError("script:getvariableofnpc: can't find npc %s\n", script_getstr(st,3));
@@ -15644,7 +15645,7 @@ BUILDIN(setquest)
struct map_session_data *sd = script_rid2sd(st);
nullpo_ret(sd);
- quest_add(sd, script_getnum(st, 2));
+ quest->add(sd, script_getnum(st, 2));
return true;
}
@@ -15653,7 +15654,7 @@ BUILDIN(erasequest)
struct map_session_data *sd = script_rid2sd(st);
nullpo_ret(sd);
- quest_delete(sd, script_getnum(st, 2));
+ quest->delete(sd, script_getnum(st, 2));
return true;
}
@@ -15662,7 +15663,7 @@ BUILDIN(completequest)
struct map_session_data *sd = script_rid2sd(st);
nullpo_ret(sd);
- quest_update_status(sd, script_getnum(st, 2), Q_COMPLETE);
+ quest->update_status(sd, script_getnum(st, 2), Q_COMPLETE);
return true;
}
@@ -15671,7 +15672,7 @@ BUILDIN(changequest)
struct map_session_data *sd = script_rid2sd(st);
nullpo_ret(sd);
- quest_change(sd, script_getnum(st, 2),script_getnum(st, 3));
+ quest->change(sd, script_getnum(st, 2),script_getnum(st, 3));
return true;
}
@@ -15685,7 +15686,7 @@ BUILDIN(checkquest)
if( script_hasdata(st, 3) )
type = (quest_check_type)script_getnum(st, 3);
- script_pushint(st, quest_check(sd, script_getnum(st, 2), type));
+ script_pushint(st, quest->check(sd, script_getnum(st, 2), type));
return true;
}
@@ -15720,7 +15721,7 @@ BUILDIN(waitingroom2bg)
struct map_session_data *sd;
if( script_hasdata(st,7) )
- nd = npc_name2id(script_getstr(st,7));
+ nd = npc->name2id(script_getstr(st,7));
else
nd = (struct npc_data *)iMap->id2bl(st->oid);
@@ -15746,7 +15747,7 @@ BUILDIN(waitingroom2bg)
ev = script_getstr(st,5); // Logout Event
dev = script_getstr(st,6); // Die Event
- if( (bg_id = bg_create(mapindex, x, y, ev, dev)) == 0 )
+ if( (bg_id = bg->create(mapindex, x, y, ev, dev)) == 0 )
{ // Creation failed
script_pushint(st,0);
return true;
@@ -15755,13 +15756,13 @@ BUILDIN(waitingroom2bg)
n = cd->users;
for( i = 0; i < n && i < MAX_BG_MEMBERS; i++ )
{
- if( (sd = cd->usersd[i]) != NULL && bg_team_join(bg_id, sd) )
- mapreg_setreg(reference_uid(script->add_str("$@arenamembers"), i), sd->bl.id);
+ if( (sd = cd->usersd[i]) != NULL && bg->team_join(bg_id, sd) )
+ mapreg->setreg(reference_uid(script->add_str("$@arenamembers"), i), sd->bl.id);
else
- mapreg_setreg(reference_uid(script->add_str("$@arenamembers"), i), 0);
+ mapreg->setreg(reference_uid(script->add_str("$@arenamembers"), i), 0);
}
- mapreg_setreg(script->add_str("$@arenamembersnum"), i);
+ mapreg->setreg(script->add_str("$@arenamembersnum"), i);
script_pushint(st,bg_id);
return true;
}
@@ -15781,7 +15782,7 @@ BUILDIN(waitingroom2bg_single)
x = script_getnum(st,4);
y = script_getnum(st,5);
- nd = npc_name2id(script_getstr(st,6));
+ nd = npc->name2id(script_getstr(st,6));
if( nd == NULL || (cd = (struct chat_data *)iMap->id2bl(nd->chat_id)) == NULL || cd->users <= 0 )
return true;
@@ -15789,7 +15790,7 @@ BUILDIN(waitingroom2bg_single)
if( (sd = cd->usersd[0]) == NULL )
return true;
- if( bg_team_join(bg_id, sd) )
+ if( bg->team_join(bg_id, sd) )
{
pc->setpos(sd, mapindex, x, y, CLR_TELEPORT);
script_pushint(st,1);
@@ -15802,15 +15803,15 @@ BUILDIN(waitingroom2bg_single)
BUILDIN(bg_team_setxy)
{
- struct battleground_data *bg;
+ struct battleground_data *bgd;
int bg_id;
bg_id = script_getnum(st,2);
- if( (bg = bg_team_search(bg_id)) == NULL )
+ if( (bgd = bg->team_search(bg_id)) == NULL )
return true;
- bg->x = script_getnum(st,3);
- bg->y = script_getnum(st,4);
+ bgd->x = script_getnum(st,3);
+ bgd->y = script_getnum(st,4);
return true;
}
@@ -15825,7 +15826,7 @@ BUILDIN(bg_warp)
return true; // Invalid Map
x = script_getnum(st,4);
y = script_getnum(st,5);
- bg_team_warp(bg_id, mapindex, x, y);
+ bg->team_warp(bg_id, mapindex, x, y);
return true;
}
@@ -15842,7 +15843,7 @@ BUILDIN(bg_monster)
class_ = script_getnum(st,7);
if( script_hasdata(st,8) ) evt = script_getstr(st,8);
check_event(st, evt);
- script_pushint(st, mob_spawn_bg(map,x,y,str,class_,evt,bg_id));
+ script_pushint(st, mob->spawn_bg(map,x,y,str,class_,evt,bg_id));
return true;
}
@@ -15872,14 +15873,14 @@ BUILDIN(bg_leave)
if( sd == NULL || !sd->bg_id )
return true;
- bg_team_leave(sd,0);
+ bg->team_leave(sd,0);
return true;
}
BUILDIN(bg_destroy)
{
int bg_id = script_getnum(st,2);
- bg_team_delete(bg_id);
+ bg->team_delete(bg_id);
return true;
}
@@ -15889,13 +15890,13 @@ BUILDIN(bg_getareausers)
int16 m, x0, y0, x1, y1;
int bg_id;
int i = 0, c = 0;
- struct battleground_data *bg = NULL;
+ struct battleground_data *bgd = NULL;
struct map_session_data *sd;
bg_id = script_getnum(st,2);
str = script_getstr(st,3);
- if( (bg = bg_team_search(bg_id)) == NULL || (m = iMap->mapname2mapid(str)) < 0 )
+ if( (bgd = bg->team_search(bg_id)) == NULL || (m = iMap->mapname2mapid(str)) < 0 )
{
script_pushint(st,0);
return true;
@@ -15908,7 +15909,7 @@ BUILDIN(bg_getareausers)
for( i = 0; i < MAX_BG_MEMBERS; i++ )
{
- if( (sd = bg->members[i].sd) == NULL )
+ if( (sd = bgd->members[i].sd) == NULL )
continue;
if( sd->bl.m != m || sd->bl.x < x0 || sd->bl.y < y0 || sd->bl.x > x1 || sd->bl.y > y1 )
continue;
@@ -15937,11 +15938,11 @@ BUILDIN(bg_updatescore)
BUILDIN(bg_get_data)
{
- struct battleground_data *bg;
+ struct battleground_data *bgd;
int bg_id = script_getnum(st,2),
type = script_getnum(st,3);
- if( (bg = bg_team_search(bg_id)) == NULL )
+ if( (bgd = bg->team_search(bg_id)) == NULL )
{
script_pushint(st,0);
return true;
@@ -15949,7 +15950,7 @@ BUILDIN(bg_get_data)
switch( type )
{
- case 0: script_pushint(st, bg->count); break;
+ case 0: script_pushint(st, bgd->count); break;
default:
ShowError("script:bg_get_data: unknown data identifier %d\n", type);
break;
@@ -16138,7 +16139,7 @@ BUILDIN(instance_announce) {
for( i = 0; i < instances[instance_id].num_map; i++ )
iMap->foreachinmap(buildin_announce_sub, instances[instance_id].map[i], BL_PC,
- mes, strlen(mes)+1, flag&(BC_SOURCE_MASK|BC_TARGET_MASK), fontColor, fontType, fontSize, fontAlign, fontY);
+ mes, strlen(mes)+1, flag&BC_COLOR_MASK, fontColor, fontType, fontSize, fontAlign, fontY);
return true;
}
@@ -16154,7 +16155,7 @@ BUILDIN(instance_npcname) {
else if( st->instance_id >= 0 )
instance_id = st->instance_id;
- if( instance_id >= 0 && (nd = npc_name2id(str)) != NULL ) {
+ if( instance_id >= 0 && (nd = npc->name2id(str)) != NULL ) {
static char npcname[NAME_LENGTH];
snprintf(npcname, sizeof(npcname), "dup_%d_%d", instance_id, nd->bl.id);
script_pushconststr(st,npcname);
@@ -16372,12 +16373,12 @@ static int buildin_mobuseskill_sub(struct block_list *bl,va_list ap)
return 0;
if( md->ud.skilltimer != INVALID_TIMER ) // Cancel the casting skill.
- unit_skillcastcancel(bl,0);
+ unit->skillcastcancel(bl,0);
if( skill->get_casttype(skill_id) == CAST_GROUND )
- unit_skilluse_pos2(&md->bl, tbl->x, tbl->y, skill_id, skill_lv, casttime, cancel);
+ unit->skilluse_pos2(&md->bl, tbl->x, tbl->y, skill_id, skill_lv, casttime, cancel);
else
- unit_skilluse_id2(&md->bl, tbl->id, skill_id, skill_lv, casttime, cancel);
+ unit->skilluse_id2(&md->bl, tbl->id, skill_id, skill_lv, casttime, cancel);
clif->emotion(&md->bl, emotion);
@@ -16474,7 +16475,7 @@ BUILDIN(pushpc)
dx = dirx[dir];
dy = diry[dir];
- unit_blown(&sd->bl, dx, dy, cells, 0);
+ unit->blown(&sd->bl, dx, dy, cells, 0);
return true;
}
@@ -17036,16 +17037,16 @@ BUILDIN(getrandgroupitem) {
nameid = itemdb->group_item(data->group);
it.nameid = nameid;
- it.identify = itemdb_isidentified(nameid);
+ it.identify = itemdb->isidentified(nameid);
- if (!itemdb_isstackable(nameid))
+ if (!itemdb->isstackable(nameid))
get_count = 1;
else
get_count = count;
for (i = 0; i < count; i += get_count) {
// if not pet egg
- if (!pet_create_egg(sd, nameid)) {
+ if (!pet->create_egg(sd, nameid)) {
if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT))) {
clif->additem(sd, 0, 0, flag);
if( pc->candrop(sd,&it) )
@@ -17139,9 +17140,9 @@ BUILDIN(npcskill)
}
if (skill->get_inf(skill_id)&INF_GROUND_SKILL) {
- unit_skilluse_pos(&nd->bl, sd->bl.x, sd->bl.y, skill_id, skill_level);
+ unit->skilluse_pos(&nd->bl, sd->bl.x, sd->bl.y, skill_id, skill_level);
} else {
- unit_skilluse_id(&nd->bl, sd->bl.id, skill_id, skill_level);
+ unit->skilluse_id(&nd->bl, sd->bl.id, skill_id, skill_level);
}
return true;
@@ -17544,7 +17545,7 @@ BUILDIN(bg_create_team) {
x = script_getnum(st,3);
y = script_getnum(st,4);
- if( (bg_id = bg_create(mapindex, x, y, ev, dev)) == 0 ) { // Creation failed
+ if( (bg_id = bg->create(mapindex, x, y, ev, dev)) == 0 ) { // Creation failed
script_pushint(st,-1);
} else
script_pushint(st,bg_id);
@@ -17567,7 +17568,7 @@ BUILDIN(bg_join_team) {
if( !sd )
script_pushint(st, 1);
else
- script_pushint(st,bg_team_join(team_id, sd)?0:1);
+ script_pushint(st,bg->team_join(team_id, sd)?0:1);
return true;
}
diff --git a/src/map/skill.c b/src/map/skill.c
index d9df0b869..6ec9d2fec 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -543,7 +543,7 @@ int skillnotok (uint16 skill_id, struct map_session_data *sd)
break;
case MC_VENDING:
case ALL_BUYING_STORE:
- if( npc_isnear(&sd->bl) ) {
+ if( npc->isnear(&sd->bl) ) {
// uncomment for more verbose message.
//char output[150];
//sprintf(output, msg_txt(662), battle_config.min_npc_vendchat_distance);
@@ -863,7 +863,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
break;
case WZ_FIREPILLAR:
- unit_set_walkdelay(bl, tick, skill->get_time2(skill_id, skill_lv), 1);
+ unit->set_walkdelay(bl, tick, skill->get_time2(skill_id, skill_lv), 1);
break;
case MG_FROSTDIVER:
@@ -1447,7 +1447,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
}
if( sd && sd->ed && sc && !iStatus->isdead(bl) && !skill_id ){
- struct unit_data *ud = unit_bl2ud(src);
+ struct unit_data *ud = unit->bl2ud(src);
if( sc->data[SC_WILD_STORM_OPTION] )
temp = sc->data[SC_WILD_STORM_OPTION]->val2;
@@ -1559,7 +1559,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
}
sd->state.autocast = 0;
//Set canact delay. [Skotlex]
- ud = unit_bl2ud(src);
+ ud = unit->bl2ud(src);
if (ud) {
rate = skill->delay_fix(src, temp, skill_lv);
if (DIFF_TICK(ud->canact_tick, tick + rate) < 0){
@@ -1594,21 +1594,21 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, uint
dstmd && !(tstatus->mode&MD_BOSS) &&
(rnd()%10000 < sd->bonus.classchange))
{
- struct mob_db *mob;
+ struct mob_db *monster;
int class_;
temp = 0;
do {
do {
class_ = rnd() % MAX_MOB_DB;
- } while (!mobdb_checkid(class_));
+ } while (!mob->db_checkid(class_));
rate = rnd() % 1000000;
- mob = mob_db(class_);
+ monster = mob->db(class_);
} while (
- (mob->status.mode&(MD_BOSS|MD_PLANT) || mob->summonper[0] <= rate) &&
+ (monster->status.mode&(MD_BOSS|MD_PLANT) || monster->summonper[0] <= rate) &&
(temp++) < 2000);
if (temp < 2000)
- mob_class_change(dstmd,class_);
+ mob->class_change(dstmd,class_);
}
return 0;
@@ -1900,7 +1900,7 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list *
}
dstsd->state.autocast = 0;
//Set canact delay. [Skotlex]
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if (ud) {
rate = skill->delay_fix(bl, skill_id, skill_lv);
if (DIFF_TICK(ud->canact_tick, tick + rate) < 0){
@@ -2103,7 +2103,7 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in
dy = -diry[dir];
}
- return unit_blown(target, dx, dy, count, flag); // send over the proper flag
+ return unit->blown(target, dx, dy, count, flag); // send over the proper flag
}
@@ -2338,7 +2338,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
sce->timer = iTimer->add_timer(tick+sce->val4, iStatus->change_timer, src->id, SC_COMBOATTACK);
break;
}
- unit_cancel_combo(src); // Cancel combo wait
+ unit->cancel_combo(src); // Cancel combo wait
break;
default:
if( src == dsrc ) // Ground skills are exceptions. [Inkfish]
@@ -2617,7 +2617,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
if (dmg.dmg_lv >= ATK_MISS && (type = skill->get_walkdelay(skill_id, skill_lv)) > 0) {
//Skills with can't walk delay also stop normal attacking for that
//duration when the attack connects. [Skotlex]
- struct unit_data *ud = unit_bl2ud(src);
+ struct unit_data *ud = unit->bl2ud(src);
if (ud && DIFF_TICK(ud->attackabletime, tick + type) < 0)
ud->attackabletime = tick + type;
}
@@ -2650,7 +2650,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
case SR_KNUCKLEARROW:
case GN_WALLOFTHORN:
case EL_FIRE_MANTLE:
- dir = unit_getdir(bl);// backwards
+ dir = unit->getdir(bl);// backwards
break;
// This ensures the storm randomly pushes instead of exactly a cell backwards per official mechanics.
case WZ_STORMGUST:
@@ -2688,7 +2688,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds
}
break;
case GN_WALLOFTHORN:
- unit_stop_walking(bl,1);
+ unit->stop_walking(bl,1);
skill->blown(dsrc,bl,dmg.blewcount,dir, 0x2 );
clif->fixpos(bl);
break;
@@ -3037,7 +3037,7 @@ int skill_check_condition_mercenary(struct block_list *bl, int skill_id, int lv,
if( !type )
switch( state ) {
case ST_MOVE_ENABLE:
- if( !unit_can_move(bl) ) {
+ if( !unit->can_move(bl) ) {
clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
return 0;
}
@@ -3086,7 +3086,7 @@ int skill_area_sub_count (struct block_list *src, struct block_list *target, uin
*------------------------------------------*/
int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
struct block_list *src = iMap->id2bl(id),*target;
- struct unit_data *ud = unit_bl2ud(src);
+ struct unit_data *ud = unit->bl2ud(src);
struct skill_timerskill *skl;
int range;
@@ -3116,11 +3116,11 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
switch(skl->skill_id) {
case RG_INTIMIDATE:
- if (unit_warp(src,-1,-1,-1,CLR_TELEPORT) == 0) {
+ if (unit->warp(src,-1,-1,-1,CLR_TELEPORT) == 0) {
short x,y;
iMap->search_freecell(src, 0, &x, &y, 1, 1, 0);
if (target != src && !iStatus->isdead(target))
- unit_warp(target, -1, x, y, CLR_TELEPORT);
+ unit->warp(target, -1, x, y, CLR_TELEPORT);
}
break;
case BA_FROSTJOKER:
@@ -3193,11 +3193,11 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
break;
case SC_FATALMENACE:
if( src == target ) // Casters Part
- unit_warp(src, -1, skl->x, skl->y, 3);
+ unit->warp(src, -1, skl->x, skl->y, 3);
else { // Target's Part
short x = skl->x, y = skl->y;
iMap->search_freecell(NULL, target->m, &x, &y, 2, 2, 1);
- unit_warp(target,-1,x,y,3);
+ unit->warp(target,-1,x,y,3);
}
break;
case LG_MOONSLASHER:
@@ -3241,7 +3241,7 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
case SC_ESCAPE:
if( skl->type < 4+skl->skill_lv ){
clif->skill_damage(src,src,tick,0,0,-30000,1,skl->skill_id,skl->skill_lv,5);
- skill->blown(src,src,1,unit_getdir(src),0);
+ skill->blown(src,src,1,unit->getdir(src),0);
skill->addtimerskill(src,tick+80,src->id,0,0,skl->skill_id,skl->skill_lv,skl->type+1,0);
}
break;
@@ -3266,12 +3266,12 @@ int skill_timerskill(int tid, unsigned int tick, int id, intptr_t data) {
case WZ_METEOR:
if( skl->type >= 0 ) {
int x = skl->type>>16, y = skl->type&0xFFFF;
- if( path_search_long(NULL, src->m, src->x, src->y, x, y, CELL_CHKWALL) )
+ if( path->search_long(NULL, src->m, src->x, src->y, x, y, CELL_CHKWALL) )
skill->unitsetting(src,skl->skill_id,skl->skill_lv,x,y,skl->flag);
- if( path_search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) )
+ if( path->search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) )
clif->skill_poseffect(src,skl->skill_id,skl->skill_lv,skl->x,skl->y,tick);
}
- else if( path_search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) )
+ else if( path->search_long(NULL, src->m, src->x, src->y, skl->x, skl->y, CELL_CHKWALL) )
skill->unitsetting(src,skl->skill_id,skl->skill_lv,skl->x,skl->y,skl->flag);
break;
case GN_CRAZYWEED_ATK: {
@@ -3300,7 +3300,7 @@ int skill_addtimerskill (struct block_list *src, unsigned int tick, int target,
nullpo_retr(1, src);
if (src->prev == NULL)
return 0;
- ud = unit_bl2ud(src);
+ ud = unit->bl2ud(src);
nullpo_retr(1, ud);
ARR_FIND( 0, MAX_SKILLTIMERSKILL, i, ud->skilltimerskill[i] == 0 );
@@ -3328,7 +3328,7 @@ int skill_cleartimerskill (struct block_list *src)
int i;
struct unit_data *ud;
nullpo_ret(src);
- ud = unit_bl2ud(src);
+ ud = unit->bl2ud(src);
nullpo_ret(ud);
for(i=0;i<MAX_SKILLTIMERSKILL;i++) {
@@ -3574,21 +3574,21 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
case KN_CHARGEATK: {
- bool path = path_search_long(NULL, src->m, src->x, src->y, bl->x, bl->y,CELL_CHKWALL);
+ bool path_exists = path->search_long(NULL, src->m, src->x, src->y, bl->x, bl->y,CELL_CHKWALL);
unsigned int dist = distance_bl(src, bl);
uint8 dir = iMap->calc_dir(bl, src->x, src->y);
// teleport to target (if not on WoE grounds)
- if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit_movepos(src, bl->x, bl->y, 0, 1) )
+ if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 0, 1) )
clif->slide(src, bl->x, bl->y);
// cause damage and knockback if the path to target was a straight one
- if( path ) {
+ if( path_exists ) {
skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, dist);
skill->blown(src, bl, dist, dir, 0);
//HACK: since knockback officially defaults to the left, the client also turns to the left... therefore,
// make the caster look in the direction of the target
- unit_setdir(src, (dir+4)%8);
+ unit->setdir(src, (dir+4)%8);
}
}
@@ -3626,12 +3626,12 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
case RG_BACKSTAP:
{
- uint8 dir = iMap->calc_dir(src, bl->x, bl->y), t_dir = unit_getdir(bl);
+ uint8 dir = iMap->calc_dir(src, bl->x, bl->y), t_dir = unit->getdir(bl);
if ((!check_distance_bl(src, bl, 0) && !iMap->check_dir(dir, t_dir)) || bl->type == BL_SKILL) {
status_change_end(src, SC_HIDING, INVALID_TIMER);
skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag);
dir = dir < 4 ? dir+4 : dir-4; // change direction [Celest]
- unit_setdir(bl,dir);
+ unit->setdir(bl,dir);
}
else if (sd)
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
@@ -3691,7 +3691,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
else if( dir == 7 || dir < 2 ) y = i;
else y = 0;
if( (mbl == src || (!map_flag_gvg2(src->m) && !map[src->m].flag.battleground) ) && // only NJ_ISSEN don't have slide effect in GVG
- unit_movepos(src, mbl->x+x, mbl->y+y, 1, 1) ) {
+ unit->movepos(src, mbl->x+x, mbl->y+y, 1, 1) ) {
clif->slide(src, src->x, src->y);
clif->fixpos(src);
clif->spiritball(src);
@@ -3830,7 +3830,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
c = skill->get_blewcount(skill_id,skill_lv);
// keep moving target in the direction that src is looking, square by square
for(i=0;i<c;i++){
- if (!skill->blown(src,bl,1,(unit_getdir(src)+4)%8,0x1))
+ if (!skill->blown(src,bl,1,(unit->getdir(src)+4)%8,0x1))
break; //Can't knockback
skill_area_temp[0] = iMap->foreachinrange(skill->area_sub, bl, skill->get_splash(skill_id, skill_lv), BL_CHAR, src, skill_id, skill_lv, tick, flag|BCT_ENEMY, skill->area_sub_count);
if( skill_area_temp[0] > 1 ) break; // collision
@@ -4073,17 +4073,17 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
{ //You don't move on GVG grounds.
short x, y;
iMap->search_freecell(bl, 0, &x, &y, 1, 1, 0);
- if (unit_movepos(src, x, y, 0, 0))
+ if (unit->movepos(src, x, y, 0, 0))
clif->slide(src,src->x,src->y);
}
status_change_end(src, SC_HIDING, INVALID_TIMER);
skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
break;
case RK_PHANTOMTHRUST:
- unit_setdir(src,iMap->calc_dir(src, bl->x, bl->y));
+ unit->setdir(src,iMap->calc_dir(src, bl->x, bl->y));
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- skill->blown(src,bl,distance_bl(src,bl)-1,unit_getdir(src),0);
+ skill->blown(src,bl,distance_bl(src,bl)-1,unit->getdir(src),0);
if( battle->check_target(src,bl,BCT_ENEMY) > 0 )
skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
break;
@@ -4100,7 +4100,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
else if( dir == 7 || dir < 2 ) y = -2;
else y = 0;
- if( unit_movepos(src, bl->x+x, bl->y+y, 1, 1) )
+ if( unit->movepos(src, bl->x+x, bl->y+y, 1, 1) )
{
clif->slide(src,bl->x+x,bl->y+y);
clif->fixpos(src); // the official server send these two packts.
@@ -4257,7 +4257,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
case WL_FROSTMISTY:
// Doesn't deal damage through non-shootable walls.
- if( path_search(NULL,src->m,src->x,src->y,bl->x,bl->y,1,CELL_CHKWALL) )
+ if( path->search(NULL,src->m,src->x,src->y,bl->x,bl->y,1,CELL_CHKWALL) )
skill->attack(BF_MAGIC,src,src,bl,skill_id,skill_lv,tick,flag|SD_ANIMATION);
break;
case WL_HELLINFERNO:
@@ -4270,7 +4270,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
short y[8]={1,1,0,-1,-1,-1,0,1};
uint8 dir = iMap->calc_dir(bl, src->x, src->y);
- if( unit_movepos(src, bl->x+x[dir], bl->y+y[dir], 1, 1) )
+ if( unit->movepos(src, bl->x+x[dir], bl->y+y[dir], 1, 1) )
{
clif->slide(src, bl->x+x[dir], bl->y+y[dir]);
clif->fixpos(src);
@@ -4279,7 +4279,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
}
case RA_WUGBITE:
- if( path_search(NULL,src->m,src->x,src->y,bl->x,bl->y,1,CELL_CHKNOREACH) ) {
+ if( path->search(NULL,src->m,src->x,src->y,bl->x,bl->y,1,CELL_CHKNOREACH) ) {
skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
}else if( sd && skill_id == RA_WUGBITE ) // Only RA_WUGBITE has the skill fail message.
clif->skill_fail(sd, skill_id, USESKILL_FAIL_LEVEL, 0);
@@ -4350,7 +4350,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
}
break;
case LG_PINPOINTATTACK:
- if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit_movepos(src, bl->x, bl->y, 1, 1) )
+ if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) )
clif->slide(src,bl->x,bl->y);
skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
break;
@@ -4375,7 +4375,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
break;
case SR_KNUCKLEARROW:
- if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit_movepos(src, bl->x, bl->y, 1, 1) ) {
+ if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground && unit->movepos(src, bl->x, bl->y, 1, 1) ) {
clif->slide(src,bl->x,bl->y);
clif->fixpos(src); // Aegis send this packet too.
}
@@ -4523,7 +4523,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
skill->attack(BF_WEAPON, src, src, bl, skill_id, skill_lv, tick, flag);
break;
case MH_TINDER_BREAKER:
- if (unit_movepos(src, bl->x, bl->y, 1, 1)) {
+ if (unit->movepos(src, bl->x, bl->y, 1, 1)) {
#if PACKETVER >= 20111005
clif->snap(src, bl->x, bl->y);
#else
@@ -4600,7 +4600,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
return 0;// not found
}
- ud = unit_bl2ud(src);
+ ud = unit->bl2ud(src);
if( ud == NULL )
{
ShowDebug("skill_castend_id: ud == NULL (tid=%d, id=%d)\n", tid, id);
@@ -4615,7 +4615,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
return 0;
}
- if(ud->skill_id != SA_CASTCANCEL && ud->skill_id != SO_SPELLFIST) {// otherwise handled in unit_skillcastcancel()
+ if(ud->skill_id != SA_CASTCANCEL && ud->skill_id != SO_SPELLFIST) {// otherwise handled in unit->skillcastcancel()
if( ud->skilltimer != tid ) {
ShowError("skill_castend_id: Timer mismatch %d!=%d!\n", ud->skilltimer, tid);
ud->skilltimer = INVALID_TIMER;
@@ -4668,7 +4668,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
}
if(ud->skill_id == RG_BACKSTAP) {
- uint8 dir = iMap->calc_dir(src,target->x,target->y),t_dir = unit_getdir(target);
+ uint8 dir = iMap->calc_dir(src,target->x,target->y),t_dir = unit->getdir(target);
if(check_distance_bl(src, target, 0) || iMap->check_dir(dir,t_dir)) {
break;
}
@@ -4681,7 +4681,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
}
if( ud->skill_id == RA_WUGSTRIKE ){
- if( !path_search(NULL,src->m,src->x,src->y,target->x,target->y,1,CELL_CHKNOREACH))
+ if( !path->search(NULL,src->m,src->x,src->y,target->x,target->y,1,CELL_CHKNOREACH))
break;
}
@@ -4769,7 +4769,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
skill->consume_requirement(sd,ud->skill_id,ud->skill_lv,1);
}
#ifdef OFFICIAL_WALKPATH
- if( !path_search_long(NULL, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL) )
+ if( !path->search_long(NULL, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL) )
break;
#endif
if( (src->type == BL_MER || src->type == BL_HOM) && !skill->check_condition_mercenary(src, ud->skill_id, ud->skill_lv, 1) )
@@ -4782,7 +4782,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
}
if (ud->walktimer != INVALID_TIMER && ud->skill_id != TK_RUN && ud->skill_id != RA_WUGDASH)
- unit_stop_walking(src,1);
+ unit->stop_walking(src,1);
if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) )
ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv); //Tests show wings don't overwrite the delay but skill scrolls do. [Inkfish]
@@ -4819,7 +4819,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
}
}
if (skill->get_state(ud->skill_id) != ST_MOVE_ENABLE)
- unit_set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1);
+ unit->set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1);
if(battle_config.skill_log && battle_config.skill_log&src->type)
ShowInfo("Type %d, ID %d skill castend id [id =%d, lv=%d, target ID %d]\n",
@@ -4886,7 +4886,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
if( dir > 2 && dir < 6 ) y = -2;
else if( dir == 7 || dir < 2 ) y = 2;
else y = 0;
- if (unit_movepos(src, src->x+x, src->y+y, 1, 1))
+ if (unit->movepos(src, src->x+x, src->y+y, 1, 1))
{ //Display movement + animation.
clif->slide(src,src->x,src->y);
clif->spiritball(src);
@@ -5217,14 +5217,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
else
{// mob-casted
- struct unit_data *ud = unit_bl2ud(src);
+ struct unit_data *ud = unit->bl2ud(src);
int inf = skill->get_inf(abra_skill_id);
if (!ud) break;
if (inf&INF_SELF_SKILL || inf&INF_SUPPORT_SKILL) {
if (src->type == BL_PET)
bl = (struct block_list*)((TBL_PET*)src)->msd;
if (!bl) bl = src;
- unit_skilluse_id(src, bl->id, abra_skill_id, abra_skill_lv);
+ unit->skilluse_id(src, bl->id, abra_skill_id, abra_skill_lv);
} else { //Assume offensive skills
int target_id = 0;
if (ud->target)
@@ -5238,9 +5238,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if (skill->get_casttype(abra_skill_id) == CAST_GROUND) {
bl = iMap->id2bl(target_id);
if (!bl) bl = src;
- unit_skilluse_pos(src, bl->x, bl->y, abra_skill_id, abra_skill_lv);
+ unit->skilluse_pos(src, bl->x, bl->y, abra_skill_id, abra_skill_lv);
} else
- unit_skilluse_id(src, target_id, abra_skill_id, abra_skill_lv);
+ unit->skilluse_id(src, target_id, abra_skill_id, abra_skill_lv);
}
}
}
@@ -5272,7 +5272,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
case SA_SUMMONMONSTER:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- if (sd) mob_once_spawn(sd, src->m, src->x, src->y," --ja--", -1, 1, "", SZ_SMALL, AI_NONE);
+ if (sd) mob->once_spawn(sd, src->m, src->x, src->y," --ja--", -1, 1, "", SZ_SMALL, AI_NONE);
break;
case SA_LEVELUP:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
@@ -5296,9 +5296,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
}
- class_ = skill_id==SA_MONOCELL?1002:mob_get_random_id(4, 1, 0);
+ class_ = skill_id==SA_MONOCELL?1002:mob->get_random_id(4, 1, 0);
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- mob_class_change(dstmd,class_);
+ mob->class_change(dstmd,class_);
if( tsc && dstmd->status.mode&MD_BOSS )
{
const enum sc_type scs[] = { SC_QUAGMIRE, SC_PROVOKE, SC_ROKISWEIL, SC_GRAVITATION, SC_NJ_SUITON, SC_NOEQUIPWEAPON, SC_NOEQUIPSHIELD, SC_NOEQUIPARMOR, SC_NOEQUIPHELM, SC_BLADESTOP };
@@ -5330,9 +5330,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case SA_TAMINGMONSTER:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
if (sd && dstmd) {
- ARR_FIND( 0, MAX_PET_DB, i, dstmd->class_ == pet_db[i].class_ );
+ ARR_FIND( 0, MAX_PET_DB, i, dstmd->class_ == pet->db[i].class_ );
if( i < MAX_PET_DB )
- pet_catch_process1(sd, dstmd->class_);
+ pet->catch_process1(sd, dstmd->class_);
}
break;
@@ -5474,10 +5474,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
case TK_JUMPKICK:
- /* Check if the target is an enemy; if not, skill should fail so the character doesn't unit_movepos (exploitable) */
+ /* Check if the target is an enemy; if not, skill should fail so the character doesn't unit->movepos (exploitable) */
if( battle->check_target(src, bl, BCT_ENEMY) > 0 )
{
- if( unit_movepos(src, bl->x, bl->y, 1, 1) )
+ if( unit->movepos(src, bl->x, bl->y, 1, 1) )
{
skill->attack(BF_WEAPON,src,src,bl,skill_id,skill_lv,tick,flag);
clif->slide(src,bl->x,bl->y);
@@ -5685,7 +5685,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
}
- id = mob_get_random_id(0,0xF, sd->status.base_level);
+ id = mob->get_random_id(0,0xF, sd->status.base_level);
if (!id) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
break;
@@ -5726,7 +5726,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
iMap->freeblock_unlock();
return 0;
}
- unit_skillcastcancel(bl, 2);
+ unit->skillcastcancel(bl, 2);
if( tsc && tsc->count )
{
@@ -5740,7 +5740,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( dstmd )
{
dstmd->state.provoke_flag = src->id;
- mob_target(dstmd, src, skill->get_range2(src,skill_id,skill_lv));
+ mob->target(dstmd, src, skill->get_range2(src,skill_id,skill_lv));
}
break;
@@ -5840,7 +5840,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
} else if (dstmd && !(tstatus->mode&MD_BOSS) && rnd() % 100 < 20)
{ // check if target is a monster and not a Boss, for the 20% chance to absorb 2 SP per monster's level [Reddozen]
i = 2 * dstmd->level;
- mob_target(dstmd,src,0);
+ mob->target(dstmd,src,0);
}
if (i) iStatus->heal(src, 0, i, 3);
clif->skill_nodamage(src,bl,skill_id,skill_lv,i?1:0);
@@ -6069,7 +6069,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
iMap->freeblock_unlock();
return 0;
}
- clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit_getdir(bl),0,0,0));
+ clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit->getdir(bl),0,0,0));
if (sd) // If the client receives a skill-use packet inmediately before a walkok packet, it will discard the walk packet! [Skotlex]
clif->walkok(sd); // So aegis has to resend the walk ok.
break;
@@ -6152,7 +6152,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if(pc->steal_coin(sd,bl))
{
dstmd->state.provoke_flag = src->id;
- mob_target(dstmd, src, skill->get_range2(src,skill_id,skill_lv));
+ mob->target(dstmd, src, skill->get_range2(src,skill_id,skill_lv));
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
}
@@ -6238,7 +6238,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
if(dstmd)
- mob_unlocktarget(dstmd,tick);
+ mob->unlocktarget(dstmd,tick);
break;
// Mercenary Supportive Skills
@@ -6364,12 +6364,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
else
clif->skill_warppoint(sd,skill_id,skill_lv, (unsigned short)-1,sd->status.save_point.map,0,0);
} else
- unit_warp(bl,-1,-1,-1,CLR_TELEPORT);
+ unit->warp(bl,-1,-1,-1,CLR_TELEPORT);
break;
case NPC_EXPULSION:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- unit_warp(bl,-1,-1,-1,CLR_TELEPORT);
+ unit->warp(bl,-1,-1,-1,CLR_TELEPORT);
break;
case AL_HOLYWATER:
@@ -6704,12 +6704,12 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case TF_BACKSLIDING: //This is the correct implementation as per packet logging information. [Skotlex]
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),unit_getdir(bl),0);
+ skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),unit->getdir(bl),0);
break;
case TK_HIGHJUMP:
{
- int x,y, dir = unit_getdir(src);
+ int x,y, dir = unit->getdir(src);
//Fails on noteleport maps, except for GvG and BG maps [Skotlex]
if( map[src->m].flag.noteleport &&
@@ -6725,7 +6725,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
clif->skill_nodamage(src,bl,TK_HIGHJUMP,skill_lv,1);
if(!iMap->count_oncell(src->m,x,y,BL_PC|BL_NPC|BL_MOB) && iMap->getcell(src->m,x,y,CELL_CHKREACH)) {
clif->slide(src,x,y);
- unit_movepos(src, x, y, 1, 0);
+ unit->movepos(src, x, y, 1, 0);
}
}
break;
@@ -6733,7 +6733,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case SA_CASTCANCEL:
case SO_SPELLFIST:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- unit_skillcastcancel(src,1);
+ unit->skillcastcancel(src,1);
if(sd) {
int sp = skill->get_sp(sd->skill_id_old,sd->skill_lv_old);
if( skill_id == SO_SPELLFIST ){
@@ -6756,7 +6756,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
iStatus->heal(bl,0,sp,2);
status_percent_damage(bl, src, 0, -20, false); //20% max SP damage.
} else {
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
int bl_skill_id=0,bl_skill_lv=0,hp = 0;
if (!ud || ud->skilltimer == INVALID_TIMER)
break; //Nothing to cancel.
@@ -6773,7 +6773,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
hp = tstatus->max_hp/50; //Recover 2% HP [Skotlex]
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- unit_skillcastcancel(bl,0);
+ unit->skillcastcancel(bl,0);
sp = skill->get_sp(bl_skill_id,bl_skill_lv);
status_zap(bl, hp, sp);
@@ -6872,14 +6872,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NPC_PROVOCATION:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- if (md) mob_unlocktarget(md, tick);
+ if (md) mob->unlocktarget(md, tick);
break;
case NPC_KEEPING:
case NPC_BARRIER:
{
int skill_time = skill->get_time(skill_id,skill_lv);
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
if (clif->skill_nodamage(src,bl,skill_id,skill_lv,
sc_start(bl,type,100,skill_lv,skill_time))
&& ud) { //Disable attacking/acting/moving for skill's duration.
@@ -6915,17 +6915,17 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NPC_SUMMONSLAVE:
case NPC_SUMMONMONSTER:
if(md && md->skill_idx >= 0)
- mob_summonslave(md,md->db->skill[md->skill_idx].val,skill_lv,skill_id);
+ mob->summonslave(md,md->db->skill[md->skill_idx].val,skill_lv,skill_id);
break;
case NPC_CALLSLAVE:
- mob_warpslave(src,MOB_SLAVEDISTANCE);
+ mob->warpslave(src,MOB_SLAVEDISTANCE);
break;
case NPC_RANDOMMOVE:
if (md) {
md->next_walktime = tick - 1;
- mob_randomwalk(md,tick);
+ mob->randomwalk(md,tick);
}
break;
@@ -6948,17 +6948,17 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
(tbl = battle->get_targeted(mbl)) == NULL)
break;
md->state.provoke_flag = tbl->id;
- mob_target(md, tbl, sstatus->rhw.range);
+ mob->target(md, tbl, sstatus->rhw.range);
}
break;
case NPC_RUN:
{
const int mask[8][2] = {{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1}};
- uint8 dir = (bl == src)?unit_getdir(src):iMap->calc_dir(src,bl->x,bl->y); //If cast on self, run forward, else run away.
- unit_stop_attack(src);
+ uint8 dir = (bl == src)?unit->getdir(src):iMap->calc_dir(src,bl->x,bl->y); //If cast on self, run forward, else run away.
+ unit->stop_attack(src);
//Run skillv tiles overriding the can-move check.
- if (unit_walktoxy(src, src->x + skill_lv * mask[dir][0], src->y + skill_lv * mask[dir][1], 2) && md)
+ if (unit->walktoxy(src, src->x + skill_lv * mask[dir][0], src->y + skill_lv * mask[dir][1], 2) && md)
md->state.skillstate = MSS_WALK; //Otherwise it isn't updated in the ai.
}
break;
@@ -6966,10 +6966,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NPC_TRANSFORMATION:
case NPC_METAMORPHOSIS:
if(md && md->skill_idx >= 0) {
- int class_ = mob_random_class (md->db->skill[md->skill_idx].val,0);
+ int class_ = mob->random_class (md->db->skill[md->skill_idx].val,0);
if (skill_lv > 1) //Multiply the rest of mobs. [Skotlex]
- mob_summonslave(md,md->db->skill[md->skill_idx].val,skill_lv-1,skill_id);
- if (class_) mob_class_change(md, class_);
+ mob->summonslave(md,md->db->skill[md->skill_idx].val,skill_lv-1,skill_id);
+ if (class_) mob->class_change(md, class_);
}
break;
@@ -6988,7 +6988,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
//If mode gets set by NPC_EMOTION then the target should be reset [Playtester]
if(skill_id == NPC_EMOTION && md->db->skill[md->skill_idx].val[1])
- mob_unlocktarget(md,tick);
+ mob->unlocktarget(md,tick);
if(md->db->skill[md->skill_idx].val[1] || md->db->skill[md->skill_idx].val[2])
sc_start4(src, type, 100, skill_lv,
@@ -7152,7 +7152,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case BD_ENCORE:
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
if(sd)
- unit_skilluse_id(src,src->id,sd->skill_id_dance,sd->skill_lv_dance);
+ unit->skilluse_id(src,src->id,sd->skill_id_dance,sd->skill_lv_dance);
break;
case AS_SPLASHER:
@@ -7198,7 +7198,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
return 0;
}
- unit_skillcastcancel(bl,0);
+ unit->skillcastcancel(bl,0);
if(tsc && tsc->count){
status_change_end(bl, SC_FREEZE, INVALID_TIMER);
@@ -7208,7 +7208,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
if(dstmd)
- mob_target(dstmd,src,skill->get_range2(src,skill_id,skill_lv));
+ mob->target(dstmd,src,skill->get_range2(src,skill_id,skill_lv));
}
break;
@@ -7361,7 +7361,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case 5: // 2000HP heal, random teleported
iStatus->heal(src, 2000, 0, 0);
if( !map_flag_vs(bl->m) )
- unit_warp(bl, -1,-1,-1, CLR_TELEPORT);
+ unit->warp(bl, -1,-1,-1, CLR_TELEPORT);
break;
case 6: // random 2 other effects
if (count == -1)
@@ -7605,10 +7605,10 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if (hd)
skill->blockhomun_start(hd, skill_id, skill->get_time2(skill_id,skill_lv));
- if (unit_movepos(src,bl->x,bl->y,0,0)) {
+ if (unit->movepos(src,bl->x,bl->y,0,0)) {
clif->skill_nodamage(src,src,skill_id,skill_lv,1); // Homunc
clif->slide(src,bl->x,bl->y) ;
- if (unit_movepos(bl,x,y,0,0))
+ if (unit->movepos(bl,x,y,0,0))
{
clif->skill_nodamage(bl,bl,skill_id,skill_lv,1); // Master
clif->slide(bl,x,y) ;
@@ -8233,7 +8233,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
return 0;
}
if( sd && pc_isridingwug(sd) ) {
- clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit_getdir(bl),0,0,1));
+ clif->skill_nodamage(src,bl,skill_id,skill_lv,sc_start4(bl,type,100,skill_lv,unit->getdir(bl),0,0,1));
clif->walkok(sd);
}
break;
@@ -8249,7 +8249,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
case NC_F_SIDESLIDE:
case NC_B_SIDESLIDE:
{
- uint8 dir = (skill_id == NC_F_SIDESLIDE) ? (unit_getdir(src)+4)%8 : unit_getdir(src);
+ uint8 dir = (skill_id == NC_F_SIDESLIDE) ? (unit->getdir(src)+4)%8 : unit->getdir(src);
skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),dir,0);
clif->slide(src,src->x,src->y);
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
@@ -8560,8 +8560,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( is_boss(bl) ) break;
if( sc_start2(bl, type, 100, skill_lv, src->id, skill->get_time(skill_id, skill_lv))) {
if( bl->type == BL_MOB )
- mob_unlocktarget((TBL_MOB*)bl,iTimer->gettick());
- unit_stop_attack(bl);
+ mob->unlocktarget((TBL_MOB*)bl,iTimer->gettick());
+ unit->stop_attack(bl);
clif->bladestop(src, bl->id, 1);
iMap->freeblock_unlock();
return 1;
@@ -8796,14 +8796,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
sd->skillitemlv = improv_skill_lv;
clif->item_skill(sd, improv_skill_id, improv_skill_lv);
} else {
- struct unit_data *ud = unit_bl2ud(src);
+ struct unit_data *ud = unit->bl2ud(src);
int inf = skill->get_inf(improv_skill_id);
if (!ud) break;
if (inf&INF_SELF_SKILL || inf&INF_SUPPORT_SKILL) {
if (src->type == BL_PET)
bl = (struct block_list*)((TBL_PET*)src)->msd;
if (!bl) bl = src;
- unit_skilluse_id(src, bl->id, improv_skill_id, improv_skill_lv);
+ unit->skilluse_id(src, bl->id, improv_skill_id, improv_skill_lv);
} else {
int target_id = 0;
if (ud->target)
@@ -8817,9 +8817,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if (skill->get_casttype(improv_skill_id) == CAST_GROUND) {
bl = iMap->id2bl(target_id);
if (!bl) bl = src;
- unit_skilluse_pos(src, bl->x, bl->y, improv_skill_id, improv_skill_lv);
+ unit->skilluse_pos(src, bl->x, bl->y, improv_skill_id, improv_skill_lv);
} else
- unit_skilluse_id(src, target_id, improv_skill_id, improv_skill_lv);
+ unit->skilluse_id(src, target_id, improv_skill_id, improv_skill_lv);
}
}
}
@@ -9041,7 +9041,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if( !script )
break;
if( dstsd )
- script->run(scriptroot,0,dstsd->bl.id,fake_nd->bl.id);
+ script->run(scriptroot,0,dstsd->bl.id,npc->fake_nd->bl.id);
else
script->run(scriptroot,0,src->id,0);
}
@@ -9147,18 +9147,18 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
if(sd){
struct mob_data *md;
- md = mob_once_spawn_sub(src, src->m, src->x, src->y, iStatus->get_name(src), 2308, "", SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(src, src->m, src->x, src->y, iStatus->get_name(src), 2308, "", SZ_SMALL, AI_NONE);
if( md )
{
md->master_id = src->id;
md->special_state.ai = AI_ZANZOU;
if( md->deletetimer != INVALID_TIMER )
- iTimer->delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0);
- mob_spawn( md );
+ iTimer->delete_timer(md->deletetimer, mob->timer_delete);
+ md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0);
+ mob->spawn( md );
pc->setinvincibletimer(sd,500);// unlock target lock
clif->skill_nodamage(src,bl,skill_id,skill_lv,1);
- skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),unit_getdir(bl),0);
+ skill->blown(src,bl,skill->get_blewcount(skill_id,skill_lv),unit->getdir(bl),0);
}
}
break;
@@ -9198,11 +9198,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
}
- if (unit_movepos(src, bl->x, bl->y, 0, 0)) {
+ if (unit->movepos(src, bl->x, bl->y, 0, 0)) {
clif->skill_nodamage(src, src, skill_id, skill_lv, 1);
clif->slide(src, bl->x, bl->y) ;
sc_start(src, SC_CONFUSION, 25, skill_lv, skill->get_time(skill_id, skill_lv));
- if ( !is_boss(bl) && unit_stop_walking(&sd->bl, 1) && unit_movepos(bl, x, y, 0, 0) )
+ if ( !is_boss(bl) && unit->stop_walking(&sd->bl, 1) && unit->movepos(bl, x, y, 0, 0) )
{
if( dstsd && pc_issit(dstsd) )
pc->setstand(dstsd);
@@ -9334,13 +9334,13 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
break;
for(i=0; i<qty[skill_lv - 1]; i++){ //easy way
- md = mob_once_spawn_sub(src, src->m, src->x, src->y, iStatus->get_name(src), summons[skill_lv - 1], "", SZ_SMALL, AI_ATTACK);
+ md = mob->once_spawn_sub(src, src->m, src->x, src->y, iStatus->get_name(src), summons[skill_lv - 1], "", SZ_SMALL, AI_ATTACK);
if (md) {
md->master_id = src->id;
if (md->deletetimer != INVALID_TIMER)
- iTimer->delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = iTimer->add_timer(iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0);
- mob_spawn(md); //Now it is ready for spawning.
+ iTimer->delete_timer(md->deletetimer, mob->timer_delete);
+ md->deletetimer = iTimer->add_timer(iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0);
+ mob->spawn(md); //Now it is ready for spawning.
sc_start4(&md->bl, SC_MODECHANGE, 100, 1, 0, MD_CANATTACK|MD_AGGRESSIVE, 0, 60000);
}
}
@@ -9362,8 +9362,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
}
if (dstmd) { //Mob skill event for no damage skills (damage ones are handled in battle_calc_damage) [Skotlex]
- mob_log_damage(dstmd, src, 0); //Log interaction (counts as 'attacker' for the exp bonus)
- mobskill_event(dstmd, src, tick, MSC_SKILLUSED|(skill_id<<16));
+ mob->log_damage(dstmd, src, 0); //Log interaction (counts as 'attacker' for the exp bonus)
+ mob->skill_event(dstmd, src, tick, MSC_SKILLUSED|(skill_id<<16));
}
if( sd && !(flag&1) ) { // ensure that the skill last-cast tick is recorded
@@ -9389,7 +9389,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data)
struct block_list* src = iMap->id2bl(id);
int maxcount;
struct map_session_data *sd;
- struct unit_data *ud = unit_bl2ud(src);
+ struct unit_data *ud = unit->bl2ud(src);
struct mob_data *md;
nullpo_ret(ud);
@@ -9485,7 +9485,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data)
src->type, src->id, ud->skill_id, ud->skill_lv, ud->skillx, ud->skilly);
if (ud->walktimer != INVALID_TIMER)
- unit_stop_walking(src,1);
+ unit->stop_walking(src,1);
if( !sd || sd->skillitem != ud->skill_id || skill->get_delay(ud->skill_id,ud->skill_lv) )
ud->canact_tick = tick + skill->delay_fix(src, ud->skill_id, ud->skill_lv);
@@ -9511,7 +9511,7 @@ int skill_castend_pos(int tid, unsigned int tick, int id, intptr_t data)
// break;
// }
// }
- unit_set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1);
+ unit->set_walkdelay(src, tick, battle_config.default_walk_delay+skill->get_walkdelay(ud->skill_id, ud->skill_lv), 1);
status_change_end(src,SC_CAMOUFLAGE, INVALID_TIMER);// only normal attack and auto cast skills benefit from its bonuses
iMap->freeblock_lock();
skill->castend_pos2(src,ud->skillx,ud->skilly,ud->skill_id,ud->skill_lv,tick,0);
@@ -9941,7 +9941,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
tmpx = x - area + rnd()%(area * 2 + 1);
tmpy = y - area + rnd()%(area * 2 + 1);
- if( i == 0 && path_search_long(NULL, src->m, src->x, src->y, tmpx, tmpy, CELL_CHKWALL) )
+ if( i == 0 && path->search_long(NULL, src->m, src->x, src->y, tmpx, tmpy, CELL_CHKWALL) )
clif->skill_poseffect(src,skill_id,skill_lv,tmpx,tmpy,tick);
if( i > 0 )
@@ -9969,7 +9969,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
return 0; // not to consume item.
case MO_BODYRELOCATION:
- if (unit_movepos(src, x, y, 1, 1)) {
+ if (unit->movepos(src, x, y, 1, 1)) {
#if PACKETVER >= 20111005
clif->snap(src, src->x, src->y);
#else
@@ -9981,7 +9981,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
break;
case NJ_SHADOWJUMP:
if( !map_flag_gvg2(src->m) && !map[src->m].flag.battleground ) { //You don't move on GVG grounds.
- unit_movepos(src, x, y, 1, 0);
+ unit->movepos(src, x, y, 1, 0);
clif->slide(src,x,y);
}
status_change_end(src, SC_HIDING, INVALID_TIMER);
@@ -9995,14 +9995,14 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
struct mob_data *md;
// Correct info, don't change any of this! [celest]
- md = mob_once_spawn_sub(src, src->m, x, y, iStatus->get_name(src), class_, "", SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(src, src->m, x, y, iStatus->get_name(src), class_, "", SZ_SMALL, AI_NONE);
if (md) {
md->master_id = src->id;
md->special_state.ai = (skill_id == AM_SPHEREMINE) ? AI_SPHERE : AI_FLORA;
if( md->deletetimer != INVALID_TIMER )
- iTimer->delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id,skill_lv), mob_timer_delete, md->bl.id, 0);
- mob_spawn (md); //Now it is ready for spawning.
+ iTimer->delete_timer(md->deletetimer, mob->timer_delete);
+ md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id,skill_lv), mob->timer_delete, md->bl.id, 0);
+ mob->spawn (md); //Now it is ready for spawning.
}
}
break;
@@ -10093,16 +10093,16 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
if (rnd()%100 < 50) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
} else {
- TBL_MOB* md = mob_once_spawn_sub(src, src->m, x, y, "--ja--",(skill_lv < 2 ? 1084+rnd()%2 : 1078+rnd()%6),"", SZ_SMALL, AI_NONE);
+ TBL_MOB* md = mob->once_spawn_sub(src, src->m, x, y, "--ja--",(skill_lv < 2 ? 1084+rnd()%2 : 1078+rnd()%6),"", SZ_SMALL, AI_NONE);
int i;
if (!md) break;
if ((i = skill->get_time(skill_id, skill_lv)) > 0)
{
if( md->deletetimer != INVALID_TIMER )
- iTimer->delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = iTimer->add_timer (tick + i, mob_timer_delete, md->bl.id, 0);
+ iTimer->delete_timer(md->deletetimer, mob->timer_delete);
+ md->deletetimer = iTimer->add_timer (tick + i, mob->timer_delete, md->bl.id, 0);
}
- mob_spawn (md);
+ mob->spawn (md);
}
}
break;
@@ -10228,15 +10228,15 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
int class_ = 2042;
struct mob_data *md;
- md = mob_once_spawn_sub(src, src->m, x, y, iStatus->get_name(src), class_, "", SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(src, src->m, x, y, iStatus->get_name(src), class_, "", SZ_SMALL, AI_NONE);
if( md )
{
md->master_id = src->id;
md->special_state.ai = AI_FLORA;
if( md->deletetimer != INVALID_TIMER )
- iTimer->delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob_timer_delete, md->bl.id, 0);
- mob_spawn( md );
+ iTimer->delete_timer(md->deletetimer, mob->timer_delete);
+ md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(skill_id, skill_lv), mob->timer_delete, md->bl.id, 0);
+ mob->spawn( md );
}
}
break;
@@ -10248,7 +10248,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
case SC_FEINTBOMB:
skill->unitsetting(src,skill_id,skill_lv,x,y,0); // Set bomb on current Position
clif->skill_nodamage(src,src,skill_id,skill_lv,1);
- if( skill->blown(src,src,6,unit_getdir(src),0) )
+ if( skill->blown(src,src,6,unit->getdir(src),0) )
skill->castend_nodamage_id(src,src,TF_HIDING,1,tick,0x2);
break;
@@ -10312,7 +10312,7 @@ int skill_castend_pos2(struct block_list* src, int x, int y, uint16 skill_id, ui
break;
case GN_FIRE_EXPANSION: {
int i;
- struct unit_data *ud = unit_bl2ud(src);
+ struct unit_data *ud = unit->bl2ud(src);
if( !ud ) break;
@@ -10486,11 +10486,11 @@ int skill_icewall_block(struct block_list *bl,va_list ap) {
if( !md->target_id || ( target = iMap->id2bl(md->target_id) ) == NULL )
return 0;
- if( path_search_long(NULL,bl->m,bl->x,bl->y,target->x,target->y,CELL_CHKICEWALL) )
+ if( path->search_long(NULL,bl->m,bl->x,bl->y,target->x,target->y,CELL_CHKICEWALL) )
return 0;
if( !check_distance_bl(bl, target, status_get_range(bl) ) ) {
- mob_unlocktarget(md,iTimer->gettick());
+ mob->unlocktarget(md,iTimer->gettick());
mob_stop_walking(md,1);
}
@@ -10894,7 +10894,7 @@ struct skill_unit_group* skill_unitsetting (struct block_list *src, uint16 skill
if( !group->state.song_dance && !iMap->getcell(src->m,ux,uy,CELL_CHKREACH) )
continue; // don't place skill units on walls (except for songs/dances/encores)
- if( battle_config.skill_wall_check && skill->get_unit_flag(skill_id)&UF_PATHCHECK && !path_search_long(NULL,src->m,ux,uy,x,y,CELL_CHKWALL) )
+ if( battle_config.skill_wall_check && skill->get_unit_flag(skill_id)&UF_PATHCHECK && !path->search_long(NULL,src->m,ux,uy,x,y,CELL_CHKWALL) )
continue; // no path between cell and center of casting.
switch( skill_id ) {
@@ -11093,7 +11093,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned
} else if(bl->type == BL_MOB && battle_config.mob_warp&2) {
int16 m = iMap->mapindex2mapid(sg->val3);
if (m < 0) break; //Map not available on this map-server.
- unit_warp(bl,m,sg->val2>>16,sg->val2&0xffff,CLR_TELEPORT);
+ unit->warp(bl,m,sg->val2>>16,sg->val2&0xffff,CLR_TELEPORT);
}
}
break;
@@ -11182,7 +11182,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned
break;
if (ss == bl) //Also needed to prevent infinite loop crash.
break;
- skill->blown(ss,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit_getdir(bl),0);
+ skill->blown(ss,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit->getdir(bl),0);
break;
case UNT_WALLOFTHORN:
@@ -11399,7 +11399,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
case UNT_SKIDTRAP:
{
- skill->blown(&src->bl,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit_getdir(bl),0);
+ skill->blown(&src->bl,bl,skill->get_blewcount(sg->skill_id,sg->skill_lv),unit->getdir(bl),0);
sg->unit_id = UNT_USED_TRAPS;
clif->changetraplook(&src->bl, UNT_USED_TRAPS);
sg->limit=DIFF_TICK(tick,sg->tick)+1500;
@@ -11415,7 +11415,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
if( td )
sec = DIFF_TICK(td->tick, tick);
if( sg->unit_id == UNT_MANHOLE || battle_config.skill_trap_type || !map_flag_gvg2(src->bl.m) ) {
- unit_movepos(bl, src->bl.x, src->bl.y, 0, 0);
+ unit->movepos(bl, src->bl.x, src->bl.y, 0, 0);
clif->fixpos(bl);
}
sg->val2 = bl->id;
@@ -11644,7 +11644,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
int i = battle->check_target(&src->bl, bl, BCT_ENEMY);
if( i > 0 && !(status_get_mode(bl)&MD_BOSS) )
{ // knock-back any enemy except Boss
- skill->blown(&src->bl, bl, 2, unit_getdir(bl), 0);
+ skill->blown(&src->bl, bl, 2, unit->getdir(bl), 0);
clif->fixpos(bl);
}
@@ -11720,7 +11720,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
if( tsd && !map[bl->m].flag.noteleport )
pc->randomwarp(tsd,3);
else if( bl->type == BL_MOB && battle_config.mob_warp&8 )
- unit_warp(bl,-1,-1,-1,3);
+ unit->warp(bl,-1,-1,-1,3);
break;
case UNT_REVERBERATION:
@@ -11851,21 +11851,21 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
distance_xy(src->bl.x, src->bl.y, bl->x, bl->y) <= range)// don't consider outer bounderies
sc_start(bl, type, 100, sg->skill_lv, sec);
- if( unit_is_walking(bl) && // wait until target stop walking
+ if( unit->is_walking(bl) && // wait until target stop walking
( tsc && tsc->data[type] && tsc->data[type]->val4 >= tsc->data[type]->val3-range ))
break;
if( tsc && ( !tsc->data[type] || (tsc->data[type] && tsc->data[type]->val4 < 1 ) ) )
break;
- if( unit_is_walking(bl) &&
+ if( unit->is_walking(bl) &&
distance_xy(src->bl.x, src->bl.y, bl->x, bl->y) > range )// going outside of boundaries? then force it to stop
- unit_stop_walking(bl,1);
+ unit->stop_walking(bl,1);
- if( !unit_is_walking(bl) &&
+ if( !unit->is_walking(bl) &&
distance_xy(src->bl.x, src->bl.y, bl->x, bl->y) <= range && // only snap if the target is inside the range or
src->bl.x != bl->x && src->bl.y != bl->y){// diagonal position parallel to VE's center
- unit_movepos(bl, src->bl.x, src->bl.y, 0, 0);
+ unit->movepos(bl, src->bl.x, src->bl.y, 0, 0);
clif->fixpos(bl);
}
}
@@ -11917,7 +11917,7 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns
}
if (bl->type == BL_MOB && ss != bl)
- mobskill_event((TBL_MOB*)bl, ss, tick, MSC_SKILLUSED|(skill_id<<16));
+ mob->skill_event((TBL_MOB*)bl, ss, tick, MSC_SKILLUSED|(skill_id<<16));
return skill_id;
}
@@ -12193,7 +12193,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) {
switch(skill_id) {
case PR_BENEDICTIO: {
uint8 dir = iMap->calc_dir(&sd->bl,tsd->bl.x,tsd->bl.y);
- dir = (unit_getdir(&sd->bl) + dir)%8; //This adjusts dir to account for the direction the sd is facing.
+ dir = (unit->getdir(&sd->bl) + dir)%8; //This adjusts dir to account for the direction the sd is facing.
if ((tsd->class_&MAPID_BASEMASK) == MAPID_ACOLYTE && (dir == 2 || dir == 6) //Must be standing to the left/right of Priest.
&& sd->status.sp >= 10)
p_sd[(*c)++]=tsd->bl.id;
@@ -12217,7 +12217,7 @@ int skill_check_condition_char_sub (struct block_list *bl, va_list ap) {
default: //Warning: Assuming Ensemble Dance/Songs for code speed. [Skotlex]
{
uint16 skill_lv;
- if(pc_issit(tsd) || !unit_can_move(&tsd->bl))
+ if(pc_issit(tsd) || !unit->can_move(&tsd->bl))
return 0;
if (sd->status.sex != tsd->status.sex &&
(tsd->class_&MAPID_UPPERMASK) == MAPID_BARDDANCER &&
@@ -12546,7 +12546,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
return 0;
}
}
- else if( !unit_can_move(&sd->bl) )
+ else if( !unit->can_move(&sd->bl) )
{ //Placed here as ST_MOVE_ENABLE should not apply if rooted or on a combo. [Skotlex]
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
@@ -12590,7 +12590,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
return 0;
}
if(sc->data[SC_COMBOATTACK]->val1 != skill_id && !( sd && sd->status.base_level >= 90 && pc->famerank(sd->status.char_id, MAPID_TAEKWON) )) { //Cancel combo wait.
- unit_cancel_combo(&sd->bl);
+ unit->cancel_combo(&sd->bl);
return 0;
}
break; //Combo ready.
@@ -12633,7 +12633,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
break;
case CG_HERMODE:
- if(!npc_check_areanpc(1,sd->bl.m,sd->bl.x,sd->bl.y,skill->get_splash(skill_id, skill_lv)))
+ if(!npc->check_areanpc(1,sd->bl.m,sd->bl.x,sd->bl.y,skill->get_splash(skill_id, skill_lv)))
{
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
@@ -12938,7 +12938,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
break;
case SR_CURSEDCIRCLE:
if (map_flag_gvg2(sd->bl.m)) {
- if (iMap->foreachinrange(mob_count_sub, &sd->bl, skill->get_splash(skill_id, skill_lv), BL_MOB,
+ if (iMap->foreachinrange(mob->count_sub, &sd->bl, skill->get_splash(skill_id, skill_lv), BL_MOB,
MOBID_EMPERIUM, MOBID_GUARIDAN_STONE1, MOBID_GUARIDAN_STONE2)) {
char output[128];
sprintf(output, "You're too close to a stone or emperium to do this skill");
@@ -13093,7 +13093,7 @@ int skill_check_condition_castbegin(struct map_session_data* sd, uint16 skill_id
if (sc && sc->data[SC_COMBOATTACK] && sc->data[SC_COMBOATTACK]->val1 == skill_id)
sd->ud.canmove_tick = iTimer->gettick(); //When using a combo, cancel the can't move delay to enable the skill. [Skotlex]
- if (!unit_can_move(&sd->bl)) {
+ if (!unit->can_move(&sd->bl)) {
clif->skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
return 0;
}
@@ -14614,7 +14614,7 @@ int skill_attack_area (struct block_list *bl, va_list ap)
*------------------------------------------*/
int skill_clear_group (struct block_list *bl, int flag)
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
struct skill_unit_group *group[MAX_SKILLUNITGROUP];
int i, count=0;
@@ -14653,7 +14653,7 @@ int skill_clear_group (struct block_list *bl, int flag)
* Returns the first element field found [Skotlex]
*------------------------------------------*/
struct skill_unit_group *skill_locate_element_field(struct block_list *bl) {
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
int i;
nullpo_ret(bl);
if (!ud) return NULL;
@@ -14859,7 +14859,7 @@ int skill_cell_overlap(struct block_list *bl, va_list ap) {
int skill_chastle_mob_changetarget(struct block_list *bl,va_list ap)
{
struct mob_data* md;
- struct unit_data*ud = unit_bl2ud(bl);
+ struct unit_data*ud = unit->bl2ud(bl);
struct block_list *from_bl;
struct block_list *to_bl;
md = (struct mob_data*)bl;
@@ -15247,7 +15247,7 @@ static int skill_get_new_group_id(void)
struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count, uint16 skill_id, uint16 skill_lv, int unit_id, int limit, int interval)
{
- struct unit_data* ud = unit_bl2ud( src );
+ struct unit_data* ud = unit->bl2ud( src );
struct skill_unit_group* group;
int i;
@@ -15276,7 +15276,7 @@ struct skill_unit_group* skill_initunitgroup (struct block_list* src, int count,
group->src_id = src->id;
group->party_id = iStatus->get_party_id(src);
group->guild_id = iStatus->get_guild_id(src);
- group->bg_id = bg_team_get_id(src);
+ group->bg_id = bg->team_get_id(src);
group->group_id = skill_get_new_group_id();
group->unit = (struct skill_unit *)aCalloc(count,sizeof(struct skill_unit));
group->unit_count = count;
@@ -15318,7 +15318,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin
}
src=iMap->id2bl(group->src_id);
- ud = unit_bl2ud(src);
+ ud = unit->bl2ud(src);
if(!src || !ud) {
ShowError("skill_delunitgroup: Group's source not found! (src_id: %d skill_id: %d)\n", group->src_id, group->skill_id);
return 0;
@@ -15442,7 +15442,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin
*------------------------------------------*/
int skill_clear_unitgroup (struct block_list *src)
{
- struct unit_data *ud = unit_bl2ud(src);
+ struct unit_data *ud = unit->bl2ud(src);
nullpo_ret(ud);
@@ -15464,7 +15464,7 @@ struct skill_unit_group_tickset *skill_unitgrouptickset_search (struct block_lis
if (group->interval==-1)
return NULL;
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if (!ud) return NULL;
set = ud->skillunittick;
@@ -16125,7 +16125,7 @@ int skill_produce_mix (struct map_session_data *sd, uint16 skill_id, int nameid,
}while( j>=0 && x>0 );
}
- if( (equip = (itemdb_isequip(nameid) && skill_id != GN_CHANGEMATERIAL && skill_id != GN_MAKEBOMB )) )
+ if( (equip = (itemdb->isequip(nameid) && skill_id != GN_CHANGEMATERIAL && skill_id != GN_MAKEBOMB )) )
wlv = itemdb_wlv(nameid);
if(!equip) {
switch(skill_id){
@@ -16726,14 +16726,14 @@ int skill_magicdecoy(struct map_session_data *sd, int nameid) {
class_ = (nameid == 990 || nameid == 991) ? 2043 + nameid - 990 : (nameid == 992) ? 2046 : 2045;
- md = mob_once_spawn_sub(&sd->bl, sd->bl.m, x, y, sd->status.name, class_, "", SZ_SMALL, AI_NONE);
+ md = mob->once_spawn_sub(&sd->bl, sd->bl.m, x, y, sd->status.name, class_, "", SZ_SMALL, AI_NONE);
if( md ) {
md->master_id = sd->bl.id;
md->special_state.ai = AI_FLORA;
if( md->deletetimer != INVALID_TIMER )
- iTimer->delete_timer(md->deletetimer, mob_timer_delete);
- md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(NC_MAGICDECOY,skill_id), mob_timer_delete, md->bl.id, 0);
- mob_spawn(md);
+ iTimer->delete_timer(md->deletetimer, mob->timer_delete);
+ md->deletetimer = iTimer->add_timer (iTimer->gettick() + skill->get_time(NC_MAGICDECOY,skill_id), mob->timer_delete, md->bl.id, 0);
+ mob->spawn(md);
md->status.matk_min = md->status.matk_max = 250 + (50 * skill_id);
}
diff --git a/src/map/status.c b/src/map/status.c
index c280d80b8..ee5d4bfd5 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -1225,7 +1225,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
if(sc->data[SC_KAGEMUSYA] && --(sc->data[SC_KAGEMUSYA]->val3) <= 0)
status_change_end(target, SC_KAGEMUSYA, INVALID_TIMER);
}
- unit_skillcastcancel(target, 2);
+ unit->skillcastcancel(target, 2);
}
status->hp-= hp;
@@ -1246,20 +1246,20 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
switch (target->type) {
case BL_PC: pc->damage((TBL_PC*)target,src,hp,sp); break;
- case BL_MOB: mob_damage((TBL_MOB*)target, src, hp); break;
+ case BL_MOB: mob->damage((TBL_MOB*)target, src, hp); break;
case BL_HOM: homun->damaged((TBL_HOM*)target); break;
case BL_MER: mercenary->heal((TBL_MER*)target,hp,sp); break;
case BL_ELEM: elemental->heal((TBL_ELEM*)target,hp,sp); break;
}
if( src && target->type == BL_PC && (((TBL_PC*)target)->disguise) > 0 ) {// stop walking when attacked in disguise to prevent walk-delay bug
- unit_stop_walking( target, 1 );
+ unit->stop_walking( target, 1 );
}
if( status->hp || (flag&8) )
{ //Still lives or has been dead before this damage.
if (walkdelay)
- unit_set_walkdelay(target, iTimer->gettick(), walkdelay, 0);
+ unit->set_walkdelay(target, iTimer->gettick(), walkdelay, 0);
return (int)(hp+sp);
}
@@ -1271,7 +1271,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
//&4: Also delete object from memory.
switch (target->type) {
case BL_PC: flag = pc->dead((TBL_PC*)target,src); break;
- case BL_MOB: flag = mob_dead((TBL_MOB*)target, src, flag&4?3:0); break;
+ case BL_MOB: flag = mob->dead((TBL_MOB*)target, src, flag&4?3:0); break;
case BL_HOM: flag = homun->dead((TBL_HOM*)target); break;
case BL_MER: flag = mercenary->dead((TBL_MER*)target); break;
case BL_ELEM: flag = elemental->dead((TBL_ELEM*)target); break;
@@ -1339,13 +1339,13 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp,
iStatus->change_clear(target,0);
if(flag&4) //Delete from memory. (also invokes map removal code)
- unit_free(target,CLR_DEAD);
+ unit->free(target,CLR_DEAD);
else if(flag&2) //remove from map
- unit_remove_map(target,CLR_DEAD);
+ unit->remove_map(target,CLR_DEAD,ALC_MARK);
else { //Some death states that would normally be handled by unit_remove_map
- unit_stop_attack(target);
- unit_stop_walking(target,1);
- unit_skillcastcancel(target,0);
+ unit->stop_attack(target);
+ unit->stop_walking(target,1);
+ unit->skillcastcancel(target,0);
clif->clearunit_area(target,CLR_DEAD);
skill->unit_move(target,iTimer->gettick(),4);
skill->cleartimerskill(target);
@@ -1420,7 +1420,7 @@ int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag)
// send hp update to client
switch(bl->type) {
case BL_PC: pc->heal((TBL_PC*)bl,hp,sp,flag&2?1:0); break;
- case BL_MOB: mob_heal((TBL_MOB*)bl,hp); break;
+ case BL_MOB: mob->heal((TBL_MOB*)bl,hp); break;
case BL_HOM: homun->healed((TBL_HOM*)bl); break;
case BL_MER: mercenary->heal((TBL_MER*)bl,hp,sp); break;
case BL_ELEM: elemental->heal((TBL_ELEM*)bl,hp,sp); break;
@@ -1525,7 +1525,7 @@ int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per
switch (bl->type) {
case BL_PC: pc->revive((TBL_PC*)bl, hp, sp); break;
- case BL_MOB: mob_revive((TBL_MOB*)bl, hp); break;
+ case BL_MOB: mob->revive((TBL_MOB*)bl, hp); break;
case BL_HOM: homun->revive((TBL_HOM*)bl, hp, sp); break;
}
@@ -1628,8 +1628,8 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
return 0;
if (sc->data[SC_DC_WINKCHARM] && target && !flag) { //Prevents skill usage
- if( unit_bl2ud(src) && (unit_bl2ud(src))->walktimer == INVALID_TIMER )
- unit_walktobl(src, iMap->id2bl(sc->data[SC_DC_WINKCHARM]->val2), 3, 1);
+ if( unit->bl2ud(src) && (unit->bl2ud(src))->walktimer == INVALID_TIMER )
+ unit->walktobl(src, iMap->id2bl(sc->data[SC_DC_WINKCHARM]->val2), 3, 1);
clif->emotion(src, E_LV);
return 0;
}
@@ -2088,7 +2088,7 @@ int status_calc_mob_(struct mob_data* md, bool first)
if (flag&16 && mbl)
{ //Max HP setting from Summon Flora/marine Sphere
- struct unit_data *ud = unit_bl2ud(mbl);
+ struct unit_data *ud = unit->bl2ud(mbl);
//Remove special AI when this is used by regular mobs.
if (mbl->type == BL_MOB && !((TBL_MOB*)mbl)->special_state.ai)
md->special_state.ai = 0;
@@ -3743,7 +3743,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
}
if(flag&SCB_SPEED) {
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
status->speed = status_calc_speed(bl, sc, b_status->speed);
//Re-walk to adjust speed (we do not check if walktimer != INVALID_TIMER
@@ -3798,9 +3798,9 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag)
status->mode = status_calc_mode(bl, sc, b_status->mode);
//Since mode changed, reset their state.
if (!(status->mode&MD_CANATTACK))
- unit_stop_attack(bl);
+ unit->stop_attack(bl);
if (!(status->mode&MD_CANMOVE))
- unit_stop_walking(bl,1);
+ unit->stop_walking(bl,1);
}
// No status changes alter these yet.
@@ -5858,7 +5858,7 @@ struct status_data *status_get_status_data(struct block_list *bl)
case BL_HOM: return &((TBL_HOM*)bl)->battle_status;
case BL_MER: return &((TBL_MER*)bl)->battle_status;
case BL_ELEM: return &((TBL_ELEM*)bl)->battle_status;
- case BL_NPC: return ((mobdb_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : &dummy_status);
+ case BL_NPC: return ((mob->db_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : &dummy_status);
default:
return &dummy_status;
}
@@ -5874,7 +5874,7 @@ struct status_data *status_get_base_status(struct block_list *bl)
case BL_HOM: return &((TBL_HOM*)bl)->base_status;
case BL_MER: return &((TBL_MER*)bl)->base_status;
case BL_ELEM: return &((TBL_ELEM*)bl)->base_status;
- case BL_NPC: return ((mobdb_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : NULL);
+ case BL_NPC: return ((mob->db_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : NULL);
default:
return NULL;
}
@@ -5883,7 +5883,7 @@ defType status_get_def(struct block_list *bl) {
struct unit_data *ud;
struct status_data *status = iStatus->get_status_data(bl);
int def = status?status->def:0;
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if (ud && ud->skilltimer != INVALID_TIMER)
def -= def * skill->get_castdef(ud->skill_id)/100;
@@ -6071,10 +6071,10 @@ void status_set_viewdata(struct block_list *bl, int class_)
{
struct view_data* vd;
nullpo_retv(bl);
- if (mobdb_checkid(class_) || mob_is_clone(class_))
- vd = mob_get_viewdata(class_);
+ if (mob->db_checkid(class_) || mob->is_clone(class_))
+ vd = mob->get_viewdata(class_);
else if (npcdb_checkid(class_) || (bl->type == BL_NPC && class_ == WARP_CLASS))
- vd = npc_get_viewdata(class_);
+ vd = npc->get_viewdata(class_);
else if (homdb_checkid(class_))
vd = homun->get_viewdata(class_);
else if (mercenary->class(class_))
@@ -7554,7 +7554,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_HANBOK:
if (!vd) return 0;
//Store previous values as they could be removed.
- unit_stop_attack(bl);
+ unit->stop_attack(bl);
break;
case SC_NOCHAT:
// [GodLesZ] FIXME: is this correct? a hardcoded interval of 60sec? what about configuration ?_?
@@ -7585,7 +7585,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
if( val2 && bl->type == BL_MOB ) {
struct block_list* src = iMap->id2bl(val2);
if( src )
- mob_log_damage((TBL_MOB*)bl,src,diff);
+ mob->log_damage((TBL_MOB*)bl,src,diff);
}
status_zap(bl, diff, 0);
}
@@ -7867,7 +7867,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
if( val3 && bl->type == BL_MOB ) {
struct block_list* src = iMap->id2bl(val3);
if( src )
- mob_log_damage((TBL_MOB*)bl,src,status->hp - 1);
+ mob->log_damage((TBL_MOB*)bl,src,status->hp - 1);
}
status_zap(bl, status->hp-1, val2?0:status->sp);
return 1;
@@ -7914,11 +7914,11 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
//val3: When set, this combo time should NOT delay attack/movement
//val3: TK: Last used kick
//val4: TK: Combo time
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
if (ud && !val3) {
tick += 300 * battle_config.combo_delay_rate/100;
ud->attackabletime = iTimer->gettick()+tick;
- unit_set_walkdelay(bl, iTimer->gettick(), tick, 1);
+ unit->set_walkdelay(bl, iTimer->gettick(), tick, 1);
}
val3 = 0;
val4 = tick;
@@ -8363,7 +8363,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
if( pc_iswug(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_WUG);
if( pc_isridingwug(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_WUGRIDER);
if( pc_isfalcon(sd) ) pc->setoption(sd, sd->sc.option&~OPTION_FALCON);
- if( sd->status.pet_id > 0 ) pet_menu(sd, 3);
+ if( sd->status.pet_id > 0 ) pet->menu(sd, 3);
if( homun_alive(sd->hd) ) homun->vaporize(sd,1);
if( sd->md ) mercenary->delete(sd->md,3);
}
@@ -8498,7 +8498,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
break;
case SC_UNLIMITED_HUMMING_VOICE:
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
if( ud == NULL ) return 0;
ud->state.skillcastcancel = 0;
val3 = 15 - (2 * val2);
@@ -8794,7 +8794,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
val4 = tick / tick_time;
break;
case SC_MONSTER_TRANSFORM:
- if( !mobdb_checkid(val1) )
+ if( !mob->db_checkid(val1) )
val1 = 1002; // default poring
val_flag |= 1;
break;
@@ -8861,9 +8861,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
status_change_end(bl, SC_DANCING, INVALID_TIMER);
// Cancel cast when get status [LuzZza]
if (battle_config.sc_castcancel&bl->type)
- unit_skillcastcancel(bl, 0);
+ unit->skillcastcancel(bl, 0);
case SC_WHITEIMPRISON:
- unit_stop_attack(bl);
+ unit->stop_attack(bl);
case SC_STOP:
case SC_CONFUSION:
case SC_RG_CCONFINE_M:
@@ -8882,11 +8882,11 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_KYOUGAKU:
case SC_NEEDLE_OF_PARALYZE:
case SC_DEATHBOUND:
- unit_stop_walking(bl,1);
+ unit->stop_walking(bl,1);
break;
case SC_ANKLESNARE:
if( battle_config.skill_trap_type || !map_flag_gvg(bl->m) )
- unit_stop_walking(bl,1);
+ unit->stop_walking(bl,1);
break;
case SC_HIDING:
case SC_CLOAKING:
@@ -8895,11 +8895,11 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
case SC_WEIGHTOVER90:
case SC_CAMOUFLAGE:
case SC_SIREN:
- unit_stop_attack(bl);
+ unit->stop_attack(bl);
break;
case SC_SILENCE:
if (battle_config.sc_castcancel&bl->type)
- unit_skillcastcancel(bl, 0);
+ unit->skillcastcancel(bl, 0);
break;
/* */
case SC_ITEMSCRIPT:
@@ -9133,7 +9133,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
status_calc_bl(bl,calc_flag);
if(sd && sd->pd)
- pet_sc_check(sd, type); //Skotlex: Pet Status Effect Healing
+ pet->sc_check(sd, type); //Skotlex: Pet Status Effect Healing
switch (type) {
case SC_BERSERK:
@@ -9148,9 +9148,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
break;
case SC_RUN:
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
if( ud )
- ud->state.running = unit_run(bl);
+ ud->state.running = unit->run(bl);
}
break;
case SC_CASH_BOSS_ALARM:
@@ -9167,9 +9167,9 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
**/
case SC_WUGDASH:
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
if( ud )
- ud->state.running = unit_wugdash(bl, sd);
+ ud->state.running = unit->wugdash(bl, sd);
}
break;
case SC_COMBOATTACK:
@@ -9214,7 +9214,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val
}
if( opt_flag&2 && sd && sd->touching_id )
- npc_touchnext_areanpc(sd,false); // run OnTouch_ on next char in range
+ npc->touchnext_areanpc(sd,false); // run OnTouch_ on next char in range
return 1;
}
@@ -9365,14 +9365,14 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
break;
case SC_RUN:
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
bool begin_spurt = true;
if (ud) {
if(!ud->state.running)
begin_spurt = false;
ud->state.running = 0;
if (ud->walktimer != INVALID_TIMER)
- unit_stop_walking(bl,1);
+ unit->stop_walking(bl,1);
}
if (begin_spurt && sce->val1 >= 7 &&
DIFF_TICK(iTimer->gettick(), sce->val4) <= 1000 &&
@@ -9681,11 +9681,11 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
break;
case SC_WUGDASH:
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
if (ud) {
ud->state.running = 0;
if (ud->walktimer != -1)
- unit_stop_walking(bl,1);
+ unit->stop_walking(bl,1);
}
}
break;
@@ -9982,7 +9982,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
skill->unit_move(bl,iTimer->gettick(),1);
if(opt_flag&2 && sd && iMap->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC))
- npc_touch_areanpc(sd,bl->m,bl->x,bl->y); //Trigger on-touch event.
+ npc->touch_areanpc(sd,bl->m,bl->x,bl->y); //Trigger on-touch event.
ers_free(sc_data_ers, sce);
return 1;
@@ -10131,8 +10131,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
case SC_STONE:
if(sc->opt1 == OPT1_STONEWAIT && sce->val3) {
sce->val4 = 0;
- unit_stop_walking(bl,1);
- unit_stop_attack(bl);
+ unit->stop_walking(bl,1);
+ unit->stop_attack(bl);
sc->opt1 = OPT1_STONE;
clif->changeoption(bl);
sc_timer_next(1000+tick,iStatus->change_timer, bl->id, data );
@@ -10156,7 +10156,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( sce->val2 && bl->type == BL_MOB ) {
struct block_list* src = iMap->id2bl(sce->val2);
if( src )
- mob_log_damage((TBL_MOB*)bl,src,sce->val4);
+ mob->log_damage((TBL_MOB*)bl,src,sce->val4);
}
iMap->freeblock_lock();
status_zap(bl, sce->val4, 0);
@@ -10192,7 +10192,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
int hp = rnd()%600 + 200;
struct block_list* src = iMap->id2bl(sce->val2);
if( src && bl && bl->type == BL_MOB ) {
- mob_log_damage((TBL_MOB*)bl,src,sd||hp<status->hp?hp:status->hp-1);
+ mob->log_damage((TBL_MOB*)bl,src,sd||hp<status->hp?hp:status->hp-1);
}
iMap->freeblock_lock();
status_fix_damage(src, bl, sd||hp<status->hp?hp:status->hp-1, 1);
@@ -10392,7 +10392,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( --(sce->val4) > 0 ) {
int damage = status->max_hp/100; // {Target VIT x (New Poison Research Skill Level - 3)} + (Target HP/100)
damage += status->vit * (sce->val1 - 3);
- unit_skillcastcancel(bl,2);
+ unit->skillcastcancel(bl,2);
iMap->freeblock_lock();
iStatus->damage(bl, bl, damage, 0, clif->damage(bl,bl,tick,status_get_amotion(bl),status_get_dmotion(bl)+500,damage,1,0,0), 1);
if( sc->data[type] ) {
@@ -10420,8 +10420,8 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
if( !flag ) { // Random Skill Cast
if (sd && !pc_issit(sd)) { //can't cast if sit
int mushroom_skill_id = 0, i;
- unit_stop_attack(bl);
- unit_skillcastcancel(bl,1);
+ unit->stop_attack(bl);
+ unit->skillcastcancel(bl,1);
do {
i = rnd() % MAX_SKILL_MAGICMUSHROOM_DB;
mushroom_skill_id = skill_magicmushroom_db[i].skill_id;
@@ -10618,7 +10618,7 @@ int status_change_timer(int tid, unsigned int tick, int id, intptr_t data)
iMap->freeblock_lock();
damage = sce->val3;
iStatus->damage(src, bl, damage, 0, clif->damage(bl,bl,tick,status->amotion,status->dmotion+200,damage,1,0,0), 1);
- unit_skillcastcancel(bl,1);
+ unit->skillcastcancel(bl,1);
if ( sc->data[type] ) {
sc_timer_next(1000 + tick, iStatus->change_timer, bl->id, data);
}
@@ -11299,7 +11299,7 @@ static int status_natural_heal(struct block_list* bl, va_list args)
if (flag && regen->state.overweight)
flag=0;
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if (flag&(RGN_HP|RGN_SHP|RGN_SSP) && ud && ud->walktimer != INVALID_TIMER)
{
diff --git a/src/map/storage.c b/src/map/storage.c
index 81d746cc8..2fe7607c3 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -152,7 +152,7 @@ int storage_additem(struct map_session_data* sd, struct item* item_data, int amo
return 1;
}
- if( itemdb_isstackable2(data) )
+ if( itemdb->isstackable2(data) )
{//Stackable
for( i = 0; i < MAX_STORAGE; i++ )
{
@@ -448,7 +448,7 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
return 1;
}
- if(itemdb_isstackable2(data)){ //Stackable
+ if(itemdb->isstackable2(data)){ //Stackable
for(i=0;i<MAX_GUILD_STORAGE;i++){
if(compare_item(&stor->items[i], item_data)) {
if( amount > MAX_AMOUNT - stor->items[i].amount || ( data->stack.guildstorage && amount > data->stack.amount - stor->items[i].amount ) )
diff --git a/src/map/trade.c b/src/map/trade.c
index 9bf63c428..3134fa3e4 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -261,7 +261,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd)
data = itemdb->search(inventory[n].nameid);
i = MAX_INVENTORY;
- if (itemdb_isstackable2(data)) { //Stackable item.
+ if (itemdb->isstackable2(data)) { //Stackable item.
for(i = 0; i < MAX_INVENTORY; i++)
if (inventory2[i].nameid == inventory[n].nameid &&
inventory2[i].card[0] == inventory[n].card[0] && inventory2[i].card[1] == inventory[n].card[1] &&
@@ -292,7 +292,7 @@ int trade_check(struct map_session_data *sd, struct map_session_data *tsd)
// search if it's possible to add item (for full inventory)
data = itemdb->search(inventory2[n].nameid);
i = MAX_INVENTORY;
- if (itemdb_isstackable2(data)) {
+ if (itemdb->isstackable2(data)) {
for(i = 0; i < MAX_INVENTORY; i++)
if (inventory[i].nameid == inventory2[n].nameid &&
inventory[i].card[0] == inventory2[n].card[0] && inventory[i].card[1] == inventory2[n].card[1] &&
diff --git a/src/map/unit.c b/src/map/unit.c
index d3f72421d..0551baaea 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -45,6 +45,8 @@
const short dirx[8]={0,-1,-1,-1,0,1,1,1};
const short diry[8]={1,1,0,-1,-1,-1,0,1};
+struct unit_interface unit_s;
+
/**
* Returns the unit_data for the given block_list. If the object is using
* shared unit_data (i.e. in case of BL_NPC), it returns the shared data.
@@ -71,17 +73,17 @@ struct unit_data* unit_bl2ud(struct block_list *bl) {
* @return a pointer to the given object's unit_data
*/
struct unit_data* unit_bl2ud2(struct block_list *bl) {
- if( bl && bl->type == BL_NPC && ((struct npc_data*)bl)->ud == &npc_base_ud ) {
+ if( bl && bl->type == BL_NPC && ((struct npc_data*)bl)->ud == &npc->base_ud ) {
struct npc_data *nd = (struct npc_data *)bl;
nd->ud = NULL;
CREATE(nd->ud, struct unit_data, 1);
- unit_dataset(&nd->bl);
+ unit->dataset(&nd->bl);
}
- return unit_bl2ud(bl);
+ return unit->bl2ud(bl);
}
-static int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data);
-static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data);
+int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data);
+int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data);
int unit_walktoxy_sub(struct block_list *bl)
{
@@ -90,10 +92,10 @@ int unit_walktoxy_sub(struct block_list *bl)
struct unit_data *ud = NULL;
nullpo_retr(1, bl);
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if(ud == NULL) return 0;
- if( !path_search(&wpd,bl->m,bl->x,bl->y,ud->to_x,ud->to_y,ud->state.walk_easy,CELL_CHKNOPASS) )
+ if( !path->search(&wpd,bl->m,bl->x,bl->y,ud->to_x,ud->to_y,ud->state.walk_easy,CELL_CHKNOPASS) )
return 0;
memcpy(&ud->walkpath,&wpd,sizeof(wpd));
@@ -131,11 +133,11 @@ int unit_walktoxy_sub(struct block_list *bl)
else
i = iStatus->get_speed(bl);
if( i > 0)
- ud->walktimer = iTimer->add_timer(iTimer->gettick()+i,unit_walktoxy_timer,bl->id,i);
+ ud->walktimer = iTimer->add_timer(iTimer->gettick()+i,unit->walktoxy_timer,bl->id,i);
return 1;
}
-static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data)
+int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data)
{
int i;
int x,y,dx,dy;
@@ -152,7 +154,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
sd = BL_CAST(BL_PC, bl);
md = BL_CAST(BL_MOB, bl);
mrd = BL_CAST(BL_MER, bl);
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if(ud == NULL) return 0;
@@ -178,7 +180,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
dy = diry[(int)dir];
if(iMap->getcell(bl->m,x+dx,y+dy,CELL_CHKNOPASS))
- return unit_walktoxy_sub(bl);
+ return unit->walktoxy_sub(bl);
//Refresh view for all those we lose sight
iMap->foreachinmovearea(clif->outsight, bl, AREA_SIZE, dx, dy, sd?BL_ALL:BL_PC, bl);
@@ -198,9 +200,9 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
if(sd) {
if( sd->touching_id )
- npc_touchnext_areanpc(sd,false);
+ npc->touchnext_areanpc(sd,false);
if(iMap->getcell(bl->m,x,y,CELL_CHKNPC)) {
- npc_touch_areanpc(sd,bl->m,x,y);
+ npc->touch_areanpc(sd,bl->m,x,y);
if (bl->prev == NULL) //Script could have warped char, abort remaining of the function.
return 0;
} else
@@ -216,7 +218,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
else if (DIFF_TICK(iTimer->gettick(), sd->md->masterteleport_timer) > 3000)
{
sd->md->masterteleport_timer = 0;
- unit_warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT );
+ unit->warp( &sd->md->bl, sd->bl.m, sd->bl.x, sd->bl.y, CLR_TELEPORT );
}
}
else if( sd->md )
@@ -226,7 +228,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
}
} else if (md) {
if( iMap->getcell(bl->m,x,y,CELL_CHKNPC) ) {
- if( npc_touch_areanpc2(md) ) return 0; // Warped
+ if( npc->touch_areanpc2(md) ) return 0; // Warped
} else
md->areanpc_id = 0;
if (md->min_chase > md->db->range3) md->min_chase--;
@@ -234,7 +236,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
//But avoid triggering on stop-walk calls.
if(tid != INVALID_TIMER &&
!(ud->walk_count%WALK_SKILL_INTERVAL) &&
- mobskill_use(md, tick, -1))
+ mob->skill_use(md, tick, -1))
{
if (!(ud->skill_id == NPC_SELFDESTRUCTION && ud->skilltimer != INVALID_TIMER))
{ //Skill used, abort walking
@@ -257,7 +259,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
else if (DIFF_TICK(iTimer->gettick(), mrd->masterteleport_timer) > 3000)
{
mrd->masterteleport_timer = 0;
- unit_warp( bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT );
+ unit->warp( bl, mrd->master->bl.id, mrd->master->bl.x, mrd->master->bl.y, CLR_TELEPORT );
}
}
else
@@ -270,7 +272,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
return 0;
if(ud->state.change_walk_target)
- return unit_walktoxy_sub(bl);
+ return unit->walktoxy_sub(bl);
ud->walkpath.path_pos++;
if(ud->walkpath.path_pos>=ud->walkpath.path_len)
@@ -281,12 +283,12 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
i = iStatus->get_speed(bl);
if(i > 0) {
- ud->walktimer = iTimer->add_timer(tick+i,unit_walktoxy_timer,id,i);
+ ud->walktimer = iTimer->add_timer(tick+i,unit->walktoxy_timer,id,i);
if( md && DIFF_TICK(tick,md->dmgtick) < 3000 )//not required not damaged recently
clif->move(ud);
} else if(ud->state.running) {
//Keep trying to run.
- if ( !(unit_run(bl) || unit_wugdash(bl,sd)) )
+ if ( !(unit->run(bl) || unit->wugdash(bl,sd)) )
ud->state.running = 0;
}
else if (ud->target_to) {
@@ -295,7 +297,7 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
if (!tbl || !iStatus->check_visibility(bl, tbl)) { //Cancel chase.
ud->to_x = bl->x;
ud->to_y = bl->y;
- if (tbl && bl->type == BL_MOB && mob_warpchase((TBL_MOB*)bl, tbl) )
+ if (tbl && bl->type == BL_MOB && mob->warpchase((TBL_MOB*)bl, tbl) )
return 0;
ud->target_to = 0;
return 0;
@@ -307,10 +309,10 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
//only need this one for syncing purposes. [Skotlex]
ud->target_to = 0;
clif->fixpos(bl);
- unit_attack(bl, tbl->id, ud->state.attack_continue);
+ unit->attack(bl, tbl->id, ud->state.attack_continue);
}
} else { //Update chase-path
- unit_walktobl(bl, tbl, ud->chaserange, ud->state.walk_easy|(ud->state.attack_continue?2:0));
+ unit->walktobl(bl, tbl, ud->chaserange, ud->state.walk_easy|(ud->state.attack_continue?2:0));
return 0;
}
}
@@ -321,13 +323,13 @@ static int unit_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data
return 0;
}
-static int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data)
+int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, intptr_t data)
{
struct block_list *bl = iMap->id2bl(id);
if (!bl || bl->prev == NULL)
return 0;
- unit_walktoxy(bl, (short)((data>>16)&0xffff), (short)(data&0xffff), 0);
+ unit->walktoxy(bl, (short)((data>>16)&0xffff), (short)(data&0xffff), 0);
return 1;
}
@@ -343,15 +345,15 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
nullpo_ret(bl);
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if( ud == NULL) return 0;
- if (!path_search(&wpd, bl->m, bl->x, bl->y, x, y, flag&1, CELL_CHKNOPASS)) // Count walk path cells
+ if (!path->search(&wpd, bl->m, bl->x, bl->y, x, y, flag&1, CELL_CHKNOPASS)) // Count walk path cells
return 0;
#ifdef OFFICIAL_WALKPATH
- if( !path_search_long(NULL, bl->m, bl->x, bl->y, x, y, CELL_CHKNOPASS) // Check if there is an obstacle between
+ if( !path->search_long(NULL, bl->m, bl->x, bl->y, x, y, CELL_CHKNOPASS) // Check if there is an obstacle between
&& (wpd.path_len > (battle_config.max_walk_path/17)*14) // Official number of walkable cells is 14 if and only if there is an obstacle between. [malufett]
&& (bl->type != BL_NPC) ) // If type is a NPC, please disregard.
return 0;
@@ -362,17 +364,17 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
if (flag&4 && DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0 &&
DIFF_TICK(ud->canmove_tick, iTimer->gettick()) < 2000)
{ // Delay walking command. [Skotlex]
- iTimer->add_timer(ud->canmove_tick+1, unit_delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF));
+ iTimer->add_timer(ud->canmove_tick+1, unit->delay_walktoxy_timer, bl->id, (x<<16)|(y&0xFFFF));
return 1;
}
- if(!(flag&2) && (!(status_get_mode(bl)&MD_CANMOVE) || !unit_can_move(bl)))
+ if(!(flag&2) && (!(status_get_mode(bl)&MD_CANMOVE) || !unit->can_move(bl)))
return 0;
ud->state.walk_easy = flag&1;
ud->to_x = x;
ud->to_y = y;
- unit_set_target(ud, 0);
+ unit->set_target(ud, 0);
sc = iStatus->get_sc(bl);
if (sc && sc->data[SC_CONFUSION]) //Randomize the target position
@@ -380,17 +382,17 @@ int unit_walktoxy( struct block_list *bl, short x, short y, int flag)
if(ud->walktimer != INVALID_TIMER) {
// When you come to the center of the grid because the change of destination while you're walking right now
- // Call a function from a timer unit_walktoxy_sub
+ // Call a function from a timer unit->walktoxy_sub
ud->state.change_walk_target = 1;
return 1;
}
if(ud->attacktimer != INVALID_TIMER) {
- iTimer->delete_timer( ud->attacktimer, unit_attack_timer );
+ iTimer->delete_timer( ud->attacktimer, unit->attack_timer );
ud->attacktimer = INVALID_TIMER;
}
- return unit_walktoxy_sub(bl);
+ return unit->walktoxy_sub(bl);
}
//To set Mob's CHASE/FOLLOW states (shouldn't be done if there's no path to reach)
@@ -402,18 +404,18 @@ static inline void set_mobstate(struct block_list* bl, int flag)
md->state.skillstate = md->state.aggressive ? MSS_FOLLOW : MSS_RUSH;
}
-static int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data)
+int unit_walktobl_sub(int tid, unsigned int tick, int id, intptr_t data)
{
struct block_list *bl = iMap->id2bl(id);
- struct unit_data *ud = bl?unit_bl2ud(bl):NULL;
+ struct unit_data *ud = bl?unit->bl2ud(bl):NULL;
if (ud && ud->walktimer == INVALID_TIMER && ud->target == data)
{
if (DIFF_TICK(ud->canmove_tick, tick) > 0) //Keep waiting?
- iTimer->add_timer(ud->canmove_tick+1, unit_walktobl_sub, id, data);
- else if (unit_can_move(bl))
+ iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, id, data);
+ else if (unit->can_move(bl))
{
- if (unit_walktoxy_sub(bl))
+ if (unit->walktoxy_sub(bl))
set_mobstate(bl, ud->state.attack_continue);
}
}
@@ -430,13 +432,13 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
nullpo_ret(bl);
nullpo_ret(tbl);
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if( ud == NULL) return 0;
if (!(status_get_mode(bl)&MD_CANMOVE))
return 0;
- if (!unit_can_reach_bl(bl, tbl, distance_bl(bl, tbl)+1, flag&1, &ud->to_x, &ud->to_y)) {
+ if (!unit->can_reach_bl(bl, tbl, distance_bl(bl, tbl)+1, flag&1, &ud->to_x, &ud->to_y)) {
ud->to_x = bl->x;
ud->to_y = bl->y;
ud->target_to = 0;
@@ -447,7 +449,7 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
ud->target_to = tbl->id;
ud->chaserange = range; //Note that if flag&2, this SHOULD be attack-range
ud->state.attack_continue = flag&2?1:0; //Chase to attack.
- unit_set_target(ud, 0);
+ unit->set_target(ud, 0);
sc = iStatus->get_sc(bl);
if (sc && sc->data[SC_CONFUSION]) //Randomize the target position
@@ -461,19 +463,19 @@ int unit_walktobl(struct block_list *bl, struct block_list *tbl, int range, int
if(DIFF_TICK(ud->canmove_tick, iTimer->gettick()) > 0)
{ //Can't move, wait a bit before invoking the movement.
- iTimer->add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->target);
+ iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target);
return 1;
}
- if(!unit_can_move(bl))
+ if(!unit->can_move(bl))
return 0;
if(ud->attacktimer != INVALID_TIMER) {
- iTimer->delete_timer( ud->attacktimer, unit_attack_timer );
+ iTimer->delete_timer( ud->attacktimer, unit->attack_timer );
ud->attacktimer = INVALID_TIMER;
}
- if (unit_walktoxy_sub(bl)) {
+ if (unit->walktoxy_sub(bl)) {
set_mobstate(bl, flag&2);
return 1;
}
@@ -490,7 +492,7 @@ int unit_run(struct block_list *bl)
if (!(sc && sc->data[SC_RUN]))
return 0;
- if (!unit_can_move(bl)) {
+ if (!unit->can_move(bl)) {
status_change_end(bl, SC_RUN, INVALID_TIMER);
return 0;
}
@@ -520,30 +522,30 @@ int unit_run(struct block_list *bl)
clif->sc_load(bl,bl->id,AREA,SI_TING,0,0,0);
//Set running to 0 beforehand so status_change_end knows not to enable spurt [Kevin]
- unit_bl2ud(bl)->state.running = 0;
+ unit->bl2ud(bl)->state.running = 0;
status_change_end(bl, SC_RUN, INVALID_TIMER);
- skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit_getdir(bl),0);
+ skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit->getdir(bl),0);
clif->fixpos(bl); //Why is a clif->slide (skill->blown) AND a fixpos needed? Ask Aegis.
clif->sc_end(bl,bl->id,AREA,SI_TING);
return 0;
}
- if (unit_walktoxy(bl, to_x, to_y, 1))
+ if (unit->walktoxy(bl, to_x, to_y, 1))
return 1;
//There must be an obstacle nearby. Attempt walking one cell at a time.
do {
to_x -= dir_x;
to_y -= dir_y;
- } while (--i > 0 && !unit_walktoxy(bl, to_x, to_y, 1));
+ } while (--i > 0 && !unit->walktoxy(bl, to_x, to_y, 1));
if ( i == 0 ) {
// copy-paste from above
clif->sc_load(bl,bl->id,AREA,SI_TING,0,0,0);
//Set running to 0 beforehand so status_change_end knows not to enable spurt [Kevin]
- unit_bl2ud(bl)->state.running = 0;
+ unit->bl2ud(bl)->state.running = 0;
status_change_end(bl, SC_RUN, INVALID_TIMER);
- skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit_getdir(bl),0);
+ skill->blown(bl,bl,skill->get_blewcount(TK_RUN,lv),unit->getdir(bl),0);
clif->fixpos(bl);
clif->sc_end(bl,bl->id,AREA,SI_TING);
return 0;
@@ -563,7 +565,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) {
nullpo_ret(sd);
nullpo_ret(bl);
- if (!unit_can_move(bl)) {
+ if (!unit->can_move(bl)) {
status_change_end(bl,SC_WUGDASH,INVALID_TIMER);
return 0;
}
@@ -588,7 +590,7 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) {
if(to_x == bl->x && to_y == bl->y) {
- unit_bl2ud(bl)->state.running = 0;
+ unit->bl2ud(bl)->state.running = 0;
status_change_end(bl,SC_WUGDASH,INVALID_TIMER);
if( sd ){
@@ -597,15 +599,15 @@ int unit_wugdash(struct block_list *bl, struct map_session_data *sd) {
}
return 0;
}
- if (unit_walktoxy(bl, to_x, to_y, 1))
+ if (unit->walktoxy(bl, to_x, to_y, 1))
return 1;
do {
to_x -= dir_x;
to_y -= dir_y;
- } while (--i > 0 && !unit_walktoxy(bl, to_x, to_y, 1));
+ } while (--i > 0 && !unit->walktoxy(bl, to_x, to_y, 1));
if (i==0) {
- unit_bl2ud(bl)->state.running = 0;
+ unit->bl2ud(bl)->state.running = 0;
status_change_end(bl,SC_WUGDASH,INVALID_TIMER);
if( sd ){
@@ -623,7 +625,7 @@ int unit_escape(struct block_list *bl, struct block_list *target, short dist)
uint8 dir = iMap->calc_dir(target, bl->x, bl->y);
while( dist > 0 && iMap->getcell(bl->m, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], CELL_CHKNOREACH) )
dist--;
- return ( dist > 0 && unit_walktoxy(bl, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], 0) );
+ return ( dist > 0 && unit->walktoxy(bl, bl->x + dist*dirx[dir], bl->y + dist*diry[dir], 0) );
}
//Instant warp function.
@@ -636,14 +638,14 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool
nullpo_ret(bl);
sd = BL_CAST(BL_PC, bl);
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if( ud == NULL) return 0;
- unit_stop_walking(bl,1);
- unit_stop_attack(bl);
+ unit->stop_walking(bl,1);
+ unit->stop_attack(bl);
- if( checkpath && (iMap->getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) )
+ if( checkpath && (iMap->getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path->search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) )
return 0; // unreachable
ud->to_x = dst_x;
@@ -665,9 +667,9 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool
if(sd) {
if( sd->touching_id )
- npc_touchnext_areanpc(sd,false);
+ npc->touchnext_areanpc(sd,false);
if(iMap->getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) {
- npc_touch_areanpc(sd,bl->m,bl->x,bl->y);
+ npc->touch_areanpc(sd,bl->m,bl->x,bl->y);
if (bl->prev == NULL) //Script could have warped char, abort remaining of the function.
return 0;
} else
@@ -677,13 +679,13 @@ int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool
{ // Check if pet needs to be teleported. [Skotlex]
int flag = 0;
struct block_list* bl = &sd->pd->bl;
- if( !checkpath && !path_search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,0,CELL_CHKNOPASS) )
+ if( !checkpath && !path->search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,0,CELL_CHKNOPASS) )
flag = 1;
else if (!check_distance_bl(&sd->bl, bl, AREA_SIZE)) //Too far, teleport.
flag = 2;
if( flag )
{
- unit_movepos(bl,sd->bl.x,sd->bl.y, 0, 0);
+ unit->movepos(bl,sd->bl.x,sd->bl.y, 0, 0);
clif->slide(bl,bl->x,bl->y);
}
}
@@ -695,7 +697,7 @@ int unit_setdir(struct block_list *bl,unsigned char dir)
{
struct unit_data *ud;
nullpo_ret(bl );
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if (!ud) return 0;
ud->dir = dir;
if (bl->type == BL_PC)
@@ -710,7 +712,7 @@ uint8 unit_getdir(struct block_list *bl) {
if( bl->type == BL_NPC )
return ((TBL_NPC*)bl)->dir;
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if (!ud) return 0;
return ud->dir;
}
@@ -729,13 +731,13 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
sd = BL_CAST(BL_PC, bl);
su = BL_CAST(BL_SKILL, bl);
- result = path_blownpos(bl->m, bl->x, bl->y, dx, dy, count);
+ result = path->blownpos(bl->m, bl->x, bl->y, dx, dy, count);
nx = result>>16;
ny = result&0xffff;
if(!su) {
- unit_stop_walking(bl, 0);
+ unit->stop_walking(bl, 0);
}
if( sd ) {
@@ -763,17 +765,17 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag)
if(sd) {
if(sd->touching_id) {
- npc_touchnext_areanpc(sd, false);
+ npc->touchnext_areanpc(sd, false);
}
if(iMap->getcell(bl->m, bl->x, bl->y, CELL_CHKNPC)) {
- npc_touch_areanpc(sd, bl->m, bl->x, bl->y);
+ npc->touch_areanpc(sd, bl->m, bl->x, bl->y);
} else {
sd->areanpc_id = 0;
}
}
}
- count = distance(dx, dy);
+ count = path->distance(dx, dy);
}
return count; // return amount of knocked back cells
@@ -786,7 +788,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
{
struct unit_data *ud;
nullpo_ret(bl);
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if(bl->prev==NULL || !ud)
return 1;
@@ -832,7 +834,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
if (bl->type == BL_PC) //Use pc_setpos
return pc->setpos((TBL_PC*)bl, map_id2index(m), x, y, type);
- if (!unit_remove_map(bl, type))
+ if (!unit->remove_map(bl, type, ALC_MARK))
return 3;
if (bl->m != m && battle_config.clear_unit_onwarp &&
@@ -865,14 +867,14 @@ int unit_stop_walking(struct block_list *bl,int type)
unsigned int tick;
nullpo_ret(bl);
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
if(!ud || ud->walktimer == INVALID_TIMER)
return 0;
//NOTE: We are using timer data after deleting it because we know the
//iTimer->delete_timer function does not messes with it. If the function's
//behaviour changes in the future, this code could break!
td = iTimer->get_timer(ud->walktimer);
- iTimer->delete_timer(ud->walktimer, unit_walktoxy_timer);
+ iTimer->delete_timer(ud->walktimer, unit->walktoxy_timer);
ud->walktimer = INVALID_TIMER;
ud->state.change_walk_target = 0;
tick = iTimer->gettick();
@@ -880,7 +882,7 @@ int unit_stop_walking(struct block_list *bl,int type)
|| (type&0x04 && td && DIFF_TICK(td->tick, tick) <= td->data/2) //Enough time has passed to cover half-cell
) {
ud->walkpath.path_len = ud->walkpath.path_pos+1;
- unit_walktoxy_timer(INVALID_TIMER, tick, bl->id, ud->walkpath.path_pos);
+ unit->walktoxy_timer(INVALID_TIMER, tick, bl->id, ud->walkpath.path_pos);
}
if(type&0x01)
@@ -903,7 +905,7 @@ int unit_stop_walking(struct block_list *bl,int type)
int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv)
{
- return unit_skilluse_id2(
+ return unit->skilluse_id2(
src, target_id, skill_id, skill_lv,
skill->cast_fix(src, skill_id, skill_lv),
skill->get_castcancel(skill_id)
@@ -912,7 +914,7 @@ int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uin
int unit_is_walking(struct block_list *bl)
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
nullpo_ret(bl);
if(!ud) return 0;
return (ud->walktimer != INVALID_TIMER);
@@ -927,7 +929,7 @@ int unit_can_move(struct block_list *bl) {
struct status_change *sc;
nullpo_ret(bl);
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
sc = iStatus->get_sc(bl);
sd = BL_CAST(BL_PC, bl);
@@ -1013,10 +1015,10 @@ int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data)
if(sd && pc_isridingwug(sd))
clif->skill_nodamage(ud->bl,ud->bl,RA_WUGDASH,ud->skill_lv,
- sc_start4(ud->bl,iStatus->skill2sc(RA_WUGDASH),100,ud->skill_lv,unit_getdir(ud->bl),0,0,1));
+ sc_start4(ud->bl,iStatus->skill2sc(RA_WUGDASH),100,ud->skill_lv,unit->getdir(ud->bl),0,0,1));
else
clif->skill_nodamage(ud->bl,ud->bl,TK_RUN,ud->skill_lv,
- sc_start4(ud->bl,iStatus->skill2sc(TK_RUN),100,ud->skill_lv,unit_getdir(ud->bl),0,0,0));
+ sc_start4(ud->bl,iStatus->skill2sc(TK_RUN),100,ud->skill_lv,unit->getdir(ud->bl),0,0,0));
if (sd) clif->walkok(sd);
@@ -1032,7 +1034,7 @@ int unit_resume_running(int tid, unsigned int tick, int id, intptr_t data)
*------------------------------------------*/
int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type)
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
if (delay <= 0 || !ud) return 0;
/**
@@ -1046,7 +1048,7 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int
return 0;
} else {
//Don't set walk delays when already trapped.
- if (!unit_can_move(bl))
+ if (!unit->can_move(bl))
return 0;
}
ud->canmove_tick = tick + delay;
@@ -1054,18 +1056,18 @@ int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int
{ //Stop walking, if chasing, readjust timers.
if (delay == 1)
{ //Minimal delay (walk-delay) disabled. Just stop walking.
- unit_stop_walking(bl,4);
+ unit->stop_walking(bl,4);
} else {
//Resume running after can move again [Kevin]
if(ud->state.running)
{
- iTimer->add_timer(ud->canmove_tick, unit_resume_running, bl->id, (intptr_t)ud);
+ iTimer->add_timer(ud->canmove_tick, unit->resume_running, bl->id, (intptr_t)ud);
}
else
{
- unit_stop_walking(bl,2|4);
+ unit->stop_walking(bl,2|4);
if(ud->target)
- iTimer->add_timer(ud->canmove_tick+1, unit_walktobl_sub, bl->id, ud->target);
+ iTimer->add_timer(ud->canmove_tick+1, unit->walktobl_sub, bl->id, ud->target);
}
}
}
@@ -1087,7 +1089,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
return 0; //Do not continue source is dead
sd = BL_CAST(BL_PC, src);
- ud = unit_bl2ud(src);
+ ud = unit->bl2ud(src);
if(ud == NULL) return 0;
sc = iStatus->get_sc(src);
@@ -1157,7 +1159,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
if( !target || src->m != target->m || !src->prev || !target->prev )
return 0;
- if( battle_config.ksprotection && sd && mob_ksprotected(src, target) )
+ if( battle_config.ksprotection && sd && mob->ksprotected(src, target) )
return 0;
//Normally not needed because clif.c checks for it, but the at/char/script commands don't! [Skotlex]
@@ -1234,7 +1236,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
//(these are supposed to always have the same range as your attack)
if( src->id != target_id && (!temp || ud->attacktimer == INVALID_TIMER) ) {
if( skill->get_state(ud->skill_id) == ST_MOVE_ENABLE ) {
- if( !unit_can_reach_bl(src, target, range + 1, 1, NULL, NULL) )
+ if( !unit->can_reach_bl(src, target, range + 1, 1, NULL, NULL) )
return 0; // Walk-path check failed.
} else if( src->type == BL_MER && skill_id == MA_REMOVETRAP ) {
if( !battle->check_range(battle->get_master(src), target, range + 1) )
@@ -1245,7 +1247,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
}
if (!temp) //Stop attack on non-combo skills [Skotlex]
- unit_stop_attack(src);
+ unit->stop_attack(src);
else if(ud->attacktimer != INVALID_TIMER) //Elsewise, delay current attack sequence
ud->attackabletime = tick + status_get_adelay(src);
@@ -1349,7 +1351,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
}
if(!ud->state.running) //need TK_RUN or WUGDASH handler to be done before that, see bugreport:6026
- unit_stop_walking(src,1);// eventhough this is not how official works but this will do the trick. bugreport:6829
+ unit->stop_walking(src,1);// eventhough this is not how official works but this will do the trick. bugreport:6829
// in official this is triggered even if no cast time.
clif->skillcasting(src, src->id, target_id, 0,0, skill_id, skill->get_ele(skill_id, skill_lv), casttime);
@@ -1358,7 +1360,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
if (sd && target->type == BL_MOB)
{
TBL_MOB *md = (TBL_MOB*)target;
- mobskill_event(md, src, tick, -1); //Cast targetted skill event.
+ mob->skill_event(md, src, tick, -1); //Cast targetted skill event.
if (tstatus->mode&(MD_CASTSENSOR_IDLE|MD_CASTSENSOR_CHASE) &&
battle->check_target(target, src, BCT_ENEMY) > 0)
{
@@ -1430,7 +1432,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv)
{
- return unit_skilluse_pos2(
+ return unit->skilluse_pos2(
src, skill_x, skill_y, skill_id, skill_lv,
skill->cast_fix(src, skill_id, skill_lv),
skill->get_castcancel(skill_id)
@@ -1452,7 +1454,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
if(iStatus->isdead(src)) return 0;
sd = BL_CAST(BL_PC, src);
- ud = unit_bl2ud(src);
+ ud = unit->bl2ud(src);
if(ud == NULL) return 0;
if(ud->skilltimer != INVALID_TIMER) //Normally not needed since clif.c checks for it, but at/char/script commands don't! [Skotlex]
@@ -1501,12 +1503,12 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
range = skill->get_range2(src, skill_id, skill_lv); // Skill cast distance from database
if( skill->get_state(ud->skill_id) == ST_MOVE_ENABLE ) {
- if( !unit_can_reach_bl(src, &bl, range + 1, 1, NULL, NULL) )
+ if( !unit->can_reach_bl(src, &bl, range + 1, 1, NULL, NULL) )
return 0; //Walk-path check failed.
} else if( !battle->check_range(src, &bl, range + 1) )
return 0; //Arrow-path check failed.
- unit_stop_attack(src);
+ unit->stop_attack(src);
// moved here to prevent Suffragium from ending if skill fails
#ifndef RENEWAL_CAST
@@ -1550,7 +1552,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
}
}
- unit_stop_walking(src,1);
+ unit->stop_walking(src,1);
// in official this is triggered even if no cast time.
clif->skillcasting(src, src->id, 0, skill_x, skill_y, skill_id, skill->get_ele(skill_id, skill_lv), casttime);
if( casttime > 0 ) {
@@ -1575,9 +1577,9 @@ int unit_set_target(struct unit_data* ud, int target_id)
nullpo_ret(ud);
if( ud->target != target_id ) {
- if( ud->target && (target = iMap->id2bl(ud->target)) && (ux = unit_bl2ud(target)) && ux->target_count > 0 )
+ if( ud->target && (target = iMap->id2bl(ud->target)) && (ux = unit->bl2ud(target)) && ux->target_count > 0 )
ux->target_count --;
- if( target_id && (target = iMap->id2bl(target_id)) && (ux = unit_bl2ud(target)) )
+ if( target_id && (target = iMap->id2bl(target_id)) && (ux = unit->bl2ud(target)) )
ux->target_count ++;
}
@@ -1587,31 +1589,31 @@ int unit_set_target(struct unit_data* ud, int target_id)
int unit_stop_attack(struct block_list *bl)
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
nullpo_ret(bl);
if(!ud || ud->attacktimer == INVALID_TIMER)
return 0;
- iTimer->delete_timer( ud->attacktimer, unit_attack_timer );
+ iTimer->delete_timer( ud->attacktimer, unit->attack_timer );
ud->attacktimer = INVALID_TIMER;
- unit_set_target(ud, 0);
+ unit->set_target(ud, 0);
return 0;
}
//Means current target is unattackable. For now only unlocks mobs.
int unit_unattackable(struct block_list *bl)
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
if (ud) {
ud->state.attack_continue = 0;
- unit_set_target(ud, 0);
+ unit->set_target(ud, 0);
}
if(bl->type == BL_MOB)
- mob_unlocktarget((struct mob_data*)bl, iTimer->gettick()) ;
+ mob->unlocktarget((struct mob_data*)bl, iTimer->gettick()) ;
else if(bl->type == BL_PET)
- pet_unlocktarget((struct pet_data*)bl);
+ pet->unlocktarget((struct pet_data*)bl);
return 0;
}
@@ -1624,31 +1626,31 @@ int unit_attack(struct block_list *src,int target_id,int continuous)
struct block_list *target;
struct unit_data *ud;
- nullpo_ret(ud = unit_bl2ud(src));
+ nullpo_ret(ud = unit->bl2ud(src));
target = iMap->id2bl(target_id);
if( target==NULL || iStatus->isdead(target) ) {
- unit_unattackable(src);
+ unit->unattackable(src);
return 1;
}
if( src->type == BL_PC ) {
TBL_PC* sd = (TBL_PC*)src;
if( target->type == BL_NPC ) { // monster npcs [Valaris]
- npc_click(sd,(TBL_NPC*)target); // submitted by leinsirk10 [Celest]
+ npc->click(sd,(TBL_NPC*)target); // submitted by leinsirk10 [Celest]
return 0;
}
if( pc_is90overweight(sd) || pc_isridingwug(sd) ) { // overweight or mounted on warg - stop attacking
- unit_stop_attack(src);
+ unit->stop_attack(src);
return 0;
}
}
if( battle->check_target(src,target,BCT_ENEMY) <= 0 || !iStatus->check_skilluse(src, target, 0, 0) ) {
- unit_unattackable(src);
+ unit->unattackable(src);
return 1;
}
ud->state.attack_continue = continuous;
- unit_set_target(ud, target_id);
+ unit->set_target(ud, target_id);
if (continuous) //If you're to attack continously, set to auto-case character
ud->chaserange = status_get_range(src);
@@ -1663,9 +1665,9 @@ int unit_attack(struct block_list *src,int target_id,int continuous)
if(DIFF_TICK(ud->attackabletime, iTimer->gettick()) > 0)
//Do attack next time it is possible. [Skotlex]
- ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit_attack_timer,src->id,0);
+ ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0);
else //Attack NOW.
- unit_attack_timer(INVALID_TIMER, iTimer->gettick(), src->id, 0);
+ unit->attack_timer(INVALID_TIMER, iTimer->gettick(), src->id, 0);
return 0;
}
@@ -1679,7 +1681,7 @@ int unit_cancel_combo(struct block_list *bl)
if (!status_change_end(bl, SC_COMBOATTACK, INVALID_TIMER))
return 0; //Combo wasn't active.
- ud = unit_bl2ud(bl);
+ ud = unit->bl2ud(bl);
nullpo_ret(ud);
ud->attackabletime = iTimer->gettick() + status_get_amotion(bl);
@@ -1687,8 +1689,8 @@ int unit_cancel_combo(struct block_list *bl)
if (ud->attacktimer == INVALID_TIMER)
return 1; //Nothing more to do.
- iTimer->delete_timer(ud->attacktimer, unit_attack_timer);
- ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit_attack_timer,bl->id,0);
+ iTimer->delete_timer(ud->attacktimer, unit->attack_timer);
+ ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,bl->id,0);
return 1;
}
/*==========================================
@@ -1701,7 +1703,7 @@ bool unit_can_reach_pos(struct block_list *bl,int x,int y, int easy)
if (bl->x == x && bl->y == y) //Same place
return true;
- return path_search(NULL,bl->m,bl->x,bl->y,x,y,easy,CELL_CHKNOREACH);
+ return path->search(NULL,bl->m,bl->x,bl->y,x,y,easy,CELL_CHKNOREACH);
}
/*==========================================
@@ -1739,7 +1741,7 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range,
if (x) *x = tbl->x-dx;
if (y) *y = tbl->y-dy;
- return path_search(NULL,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CELL_CHKNOREACH);
+ return path->search(NULL,bl->m,bl->x,bl->y,tbl->x-dx,tbl->y-dy,easy,CELL_CHKNOREACH);
}
/*==========================================
* Calculates position of Pet/Mercenary/Homunculus/Elemental
@@ -1747,7 +1749,7 @@ bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range,
int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir)
{
int dx, dy, x, y, i, k;
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
nullpo_ret(ud);
if(dir > 7)
@@ -1762,11 +1764,11 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir)
x = tx + dx;
y = ty + dy;
- if( !unit_can_reach_pos(bl, x, y, 0) )
+ if( !unit->can_reach_pos(bl, x, y, 0) )
{
if( dx > 0 ) x--; else if( dx < 0 ) x++;
if( dy > 0 ) y--; else if( dy < 0 ) y++;
- if( !unit_can_reach_pos(bl, x, y, 0) )
+ if( !unit->can_reach_pos(bl, x, y, 0) )
{
for( i = 0; i < 12; i++ )
{
@@ -1775,20 +1777,20 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir)
dy = -diry[k] * 2;
x = tx + dx;
y = ty + dy;
- if( unit_can_reach_pos(bl, x, y, 0) )
+ if( unit->can_reach_pos(bl, x, y, 0) )
break;
else
{
if( dx > 0 ) x--; else if( dx < 0 ) x++;
if( dy > 0 ) y--; else if( dy < 0 ) y++;
- if( unit_can_reach_pos(bl, x, y, 0) )
+ if( unit->can_reach_pos(bl, x, y, 0) )
break;
}
}
if( i == 12 )
{
x = tx; y = tx; // Exactly Master Position
- if( !unit_can_reach_pos(bl, x, y, 0) )
+ if( !unit->can_reach_pos(bl, x, y, 0) )
return 1;
}
}
@@ -1802,7 +1804,7 @@ int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir)
/*==========================================
* Continuous Attack (function timer)
*------------------------------------------*/
-static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick)
+int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int tick)
{
struct block_list *target;
struct unit_data *ud;
@@ -1811,7 +1813,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
struct mob_data *md = NULL;
int range;
- if( (ud=unit_bl2ud(src))==NULL )
+ if( (ud=unit->bl2ud(src))==NULL )
return 0;
if( ud->attacktimer != tid )
{
@@ -1830,14 +1832,14 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
if( iStatus->isdead(src) || iStatus->isdead(target) ||
battle->check_target(src,target,BCT_ENEMY) <= 0 || !iStatus->check_skilluse(src, target, 0, 0)
#ifdef OFFICIAL_WALKPATH
- || !path_search_long(NULL, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL)
+ || !path->search_long(NULL, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL)
#endif
)
return 0; // can't attack under these conditions
if( src->m != target->m )
{
- if( src->type == BL_MOB && mob_warpchase((TBL_MOB*)src, target) )
+ if( src->type == BL_MOB && mob->warpchase((TBL_MOB*)src, target) )
return 1; // Follow up.
return 0;
}
@@ -1855,7 +1857,7 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
if( ud->state.attack_continue ) {
if( DIFF_TICK(ud->canact_tick, ud->attackabletime) > 0 )
ud->attackabletime = ud->canact_tick;
- ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit_attack_timer,src->id,0);
+ ud->attacktimer=iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0);
}
return 1;
}
@@ -1863,20 +1865,20 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
sstatus = iStatus->get_status_data(src);
range = sstatus->rhw.range + 1;
- if( unit_is_walking(target) )
+ if( unit->is_walking(target) )
range++; //Extra range when chasing
if( !check_distance_bl(src,target,range) ) { //Chase if required.
if(sd)
clif->movetoattack(sd,target);
else if(ud->state.attack_continue)
- unit_walktobl(src,target,ud->chaserange,ud->state.walk_easy|2);
+ unit->walktobl(src,target,ud->chaserange,ud->state.walk_easy|2);
return 1;
}
if( !battle->check_range(src,target,range) ) {
//Within range, but no direct line of attack
if( ud->state.attack_continue ) {
if(ud->chaserange > 2) ud->chaserange-=2;
- unit_walktobl(src,target,ud->chaserange,ud->state.walk_easy|2);
+ unit->walktobl(src,target,ud->chaserange,ud->state.walk_easy|2);
}
return 1;
}
@@ -1890,24 +1892,24 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
ud->dir = iMap->calc_dir(src, target->x,target->y );
}
if(ud->walktimer != INVALID_TIMER)
- unit_stop_walking(src,1);
+ unit->stop_walking(src,1);
if(md) {
- if (mobskill_use(md,tick,-1))
+ if (mob->skill_use(md,tick,-1))
return 1;
if (sstatus->mode&MD_ASSIST && DIFF_TICK(md->last_linktime, tick) < MIN_MOBLINKTIME)
{ // Link monsters nearby [Skotlex]
md->last_linktime = tick;
- iMap->foreachinrange(mob_linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick);
+ iMap->foreachinrange(mob->linksearch, src, md->db->range2, BL_MOB, md->class_, target, tick);
}
}
- if(src->type == BL_PET && pet_attackskill((TBL_PET*)src, target->id))
+ if(src->type == BL_PET && pet->attackskill((TBL_PET*)src, target->id))
return 1;
iMap->freeblock_lock();
ud->attacktarget_lv = battle->weapon_attack(src,target,tick,0);
if(sd && sd->status.pet_id > 0 && sd->pd && battle_config.pet_attack_support)
- pet_target_check(sd,target,0);
+ pet->target_check(sd,target,0);
iMap->freeblock_unlock();
/**
* Applied when you're unable to attack (e.g. out of ammo)
@@ -1919,24 +1921,24 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, unsigned int t
ud->attackabletime = tick + sstatus->adelay;
// You can't move if you can't attack neither.
if (src->type&battle_config.attack_walk_delay)
- unit_set_walkdelay(src, tick, sstatus->amotion, 1);
+ unit->set_walkdelay(src, tick, sstatus->amotion, 1);
}
if(ud->state.attack_continue) {
if( src->type == BL_PC )
((TBL_PC*)src)->idletime = last_tick;
- ud->attacktimer = iTimer->add_timer(ud->attackabletime,unit_attack_timer,src->id,0);
+ ud->attacktimer = iTimer->add_timer(ud->attackabletime,unit->attack_timer,src->id,0);
}
return 1;
}
-static int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data)
+int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data)
{
struct block_list *bl;
bl = iMap->id2bl(id);
- if(bl && unit_attack_timer_sub(bl, tid, tick) == 0)
- unit_unattackable(bl);
+ if(bl && unit->attack_timer_sub(bl, tid, tick) == 0)
+ unit->unattackable(bl);
return 0;
}
@@ -1948,7 +1950,7 @@ static int unit_attack_timer(int tid, unsigned int tick, int id, intptr_t data)
int unit_skillcastcancel(struct block_list *bl,int type)
{
struct map_session_data *sd = NULL;
- struct unit_data *ud = unit_bl2ud( bl);
+ struct unit_data *ud = unit->bl2ud( bl);
unsigned int tick=iTimer->gettick();
int ret=0, skill_id;
@@ -2004,7 +2006,7 @@ int unit_skillcastcancel(struct block_list *bl,int type)
// unit_data initialization process
void unit_dataset(struct block_list *bl) {
struct unit_data *ud;
- nullpo_retv(ud = unit_bl2ud(bl));
+ nullpo_retv(ud = unit->bl2ud(bl));
memset( ud, 0, sizeof( struct unit_data) );
ud->bl = bl;
@@ -2022,7 +2024,7 @@ void unit_dataset(struct block_list *bl) {
int unit_counttargeted(struct block_list* bl)
{
struct unit_data* ud;
- if( bl && (ud = unit_bl2ud(bl)) )
+ if( bl && (ud = unit->bl2ud(bl)) )
return ud->target_count;
return 0;
}
@@ -2067,9 +2069,9 @@ int unit_changeviewsize(struct block_list *bl,short size)
* Otherwise it is assumed bl is being warped.
* On-Kill specific stuff is not performed here, look at iStatus->damage for that.
*------------------------------------------*/
-int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, int line, const char* func)
+int unit_remove_map(struct block_list *bl, clr_type clrtype, const char* file, int line, const char* func)
{
- struct unit_data *ud = unit_bl2ud(bl);
+ struct unit_data *ud = unit->bl2ud(bl);
struct status_change *sc = iStatus->get_sc(bl);
nullpo_ret(ud);
@@ -2078,14 +2080,14 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
iMap->freeblock_lock();
- unit_set_target(ud, 0);
+ unit->set_target(ud, 0);
if (ud->walktimer != INVALID_TIMER)
- unit_stop_walking(bl,0);
+ unit->stop_walking(bl,0);
if (ud->attacktimer != INVALID_TIMER)
- unit_stop_attack(bl);
+ unit->stop_attack(bl);
if (ud->skilltimer != INVALID_TIMER)
- unit_skillcastcancel(bl,0);
+ unit->skillcastcancel(bl,0);
// Do not reset can-act delay. [Skotlex]
ud->attackabletime = ud->canmove_tick /*= ud->canact_tick*/ = iTimer->gettick();
@@ -2158,7 +2160,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
if(sd->menuskill_id)
sd->menuskill_id = sd->menuskill_val = 0;
if( sd->touching_id )
- npc_touchnext_areanpc(sd,true);
+ npc->touchnext_areanpc(sd,true);
// Check if warping and not changing the map.
if ( sd->state.warping && !sd->state.changemap ) {
@@ -2183,7 +2185,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
}
party->send_dot_remove(sd);//minimap dot fix [Kevin]
guild->send_dot_remove(sd);
- bg_send_dot_remove(sd);
+ bg->send_dot_remove(sd);
if( map[bl->m].users <= 0 || sd->state.debug_remove_map )
{// this is only place where map users is decreased, if the mobs were removed too soon then this function was executed too many times [FlavioJS]
@@ -2233,10 +2235,10 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
case BL_PET: {
struct pet_data *pd = (struct pet_data*)bl;
if( pd->pet.intimate <= 0 && !(pd->msd && !pd->msd->state.active) )
- { //If logging out, this is deleted on unit_free
+ { //If logging out, this is deleted on unit->free
clif->clearunit_area(bl,clrtype);
iMap->delblock(bl);
- unit_free(bl,CLR_OUTSIGHT);
+ unit->free(bl,CLR_OUTSIGHT);
iMap->freeblock_unlock();
return 0;
}
@@ -2247,11 +2249,11 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
struct homun_data *hd = (struct homun_data *)bl;
ud->canact_tick = ud->canmove_tick; //It appears HOM do reset the can-act tick.
if( !hd->homunculus.intimacy && !(hd->master && !hd->master->state.active) )
- { //If logging out, this is deleted on unit_free
+ { //If logging out, this is deleted on unit->free
clif->emotion(bl, E_SOB);
clif->clearunit_area(bl,clrtype);
iMap->delblock(bl);
- unit_free(bl,CLR_OUTSIGHT);
+ unit->free(bl,CLR_OUTSIGHT);
iMap->freeblock_unlock();
return 0;
}
@@ -2264,7 +2266,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
{
clif->clearunit_area(bl,clrtype);
iMap->delblock(bl);
- unit_free(bl,CLR_OUTSIGHT);
+ unit->free(bl,CLR_OUTSIGHT);
iMap->freeblock_unlock();
return 0;
}
@@ -2277,7 +2279,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
{
clif->clearunit_area(bl,clrtype);
iMap->delblock(bl);
- unit_free(bl,0);
+ unit->free(bl,0);
iMap->freeblock_unlock();
return 0;
}
@@ -2297,27 +2299,27 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype)
{
- unit_remove_map(&sd->bl,clrtype);
+ unit->remove_map(&sd->bl,clrtype,ALC_MARK);
if (clrtype == CLR_TELEPORT) clrtype = CLR_OUTSIGHT; //CLR_TELEPORT is the warp from logging out, but pets/homunc need to just 'vanish' instead of showing the warping out animation.
if(sd->pd)
- unit_remove_map(&sd->pd->bl, clrtype);
+ unit->remove_map(&sd->pd->bl, clrtype, ALC_MARK);
if(homun_alive(sd->hd))
- unit_remove_map(&sd->hd->bl, clrtype);
+ unit->remove_map(&sd->hd->bl, clrtype, ALC_MARK);
if(sd->md)
- unit_remove_map(&sd->md->bl, clrtype);
+ unit->remove_map(&sd->md->bl, clrtype, ALC_MARK);
if(sd->ed)
- unit_remove_map(&sd->ed->bl, clrtype);
+ unit->remove_map(&sd->ed->bl, clrtype, ALC_MARK);
}
void unit_free_pc(struct map_session_data *sd)
{
- if (sd->pd) unit_free(&sd->pd->bl,CLR_OUTSIGHT);
- if (sd->hd) unit_free(&sd->hd->bl,CLR_OUTSIGHT);
- if (sd->md) unit_free(&sd->md->bl,CLR_OUTSIGHT);
- if (sd->ed) unit_free(&sd->ed->bl,CLR_OUTSIGHT);
- unit_free(&sd->bl,CLR_TELEPORT);
+ if (sd->pd) unit->free(&sd->pd->bl,CLR_OUTSIGHT);
+ if (sd->hd) unit->free(&sd->hd->bl,CLR_OUTSIGHT);
+ if (sd->md) unit->free(&sd->md->bl,CLR_OUTSIGHT);
+ if (sd->ed) unit->free(&sd->ed->bl,CLR_OUTSIGHT);
+ unit->free(&sd->bl,CLR_TELEPORT);
}
/*==========================================
@@ -2326,12 +2328,12 @@ void unit_free_pc(struct map_session_data *sd)
*------------------------------------------*/
int unit_free(struct block_list *bl, clr_type clrtype)
{
- struct unit_data *ud = unit_bl2ud( bl );
+ struct unit_data *ud = unit->bl2ud( bl );
nullpo_ret(ud);
iMap->freeblock_lock();
if( bl->prev ) //Players are supposed to logout with a "warp" effect.
- unit_remove_map(bl, clrtype);
+ unit->remove_map(bl, clrtype, ALC_MARK);
switch( bl->type ) {
case BL_PC:
@@ -2421,7 +2423,7 @@ int unit_free(struct block_list *bl, clr_type clrtype)
{
struct pet_data *pd = (struct pet_data*)bl;
struct map_session_data *sd = pd->msd;
- pet_hungry_timer_delete(pd);
+ pet->hungry_timer_delete(pd);
if( pd->a_skill )
{
aFree(pd->a_skill);
@@ -2431,9 +2433,9 @@ int unit_free(struct block_list *bl, clr_type clrtype)
{
if (pd->s_skill->timer != INVALID_TIMER) {
if (pd->s_skill->id)
- iTimer->delete_timer(pd->s_skill->timer, pet_skill_support_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet->skill_support_timer);
else
- iTimer->delete_timer(pd->s_skill->timer, pet_heal_timer);
+ iTimer->delete_timer(pd->s_skill->timer, pet->heal_timer);
}
aFree(pd->s_skill);
pd->s_skill = NULL;
@@ -2441,20 +2443,20 @@ int unit_free(struct block_list *bl, clr_type clrtype)
if( pd->recovery )
{
if(pd->recovery->timer != INVALID_TIMER)
- iTimer->delete_timer(pd->recovery->timer, pet_recovery_timer);
+ iTimer->delete_timer(pd->recovery->timer, pet->recovery_timer);
aFree(pd->recovery);
pd->recovery = NULL;
}
if( pd->bonus )
{
if (pd->bonus->timer != INVALID_TIMER)
- iTimer->delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
+ iTimer->delete_timer(pd->bonus->timer, pet->skill_bonus_timer);
aFree(pd->bonus);
pd->bonus = NULL;
}
if( pd->loot )
{
- pet_lootitem_drop(pd,sd);
+ pet->lootitem_drop(pd,sd);
if (pd->loot->item)
aFree(pd->loot->item);
aFree (pd->loot);
@@ -2476,12 +2478,12 @@ int unit_free(struct block_list *bl, clr_type clrtype)
struct mob_data *md = (struct mob_data*)bl;
if( md->spawn_timer != INVALID_TIMER )
{
- iTimer->delete_timer(md->spawn_timer,mob_delayspawn);
+ iTimer->delete_timer(md->spawn_timer,mob->delayspawn);
md->spawn_timer = INVALID_TIMER;
}
if( md->deletetimer != INVALID_TIMER )
{
- iTimer->delete_timer(md->deletetimer,mob_timer_delete);
+ iTimer->delete_timer(md->deletetimer,mob->timer_delete);
md->deletetimer = INVALID_TIMER;
}
if( md->lootitem )
@@ -2523,10 +2525,10 @@ int unit_free(struct block_list *bl, clr_type clrtype)
aFree(md->base_status);
md->base_status = NULL;
}
- if( mob_is_clone(md->class_) )
- mob_clone_delete(md);
+ if( mob->is_clone(md->class_) )
+ mob->clone_delete(md);
if( md->tomb_nid )
- mvptomb_destroy(md);
+ mob->mvptomb_destroy(md);
break;
}
case BL_HOM:
@@ -2590,17 +2592,67 @@ int unit_free(struct block_list *bl, clr_type clrtype)
return 0;
}
-int do_init_unit(void)
-{
- iTimer->add_timer_func_list(unit_attack_timer, "unit_attack_timer");
- iTimer->add_timer_func_list(unit_walktoxy_timer,"unit_walktoxy_timer");
- iTimer->add_timer_func_list(unit_walktobl_sub, "unit_walktobl_sub");
- iTimer->add_timer_func_list(unit_delay_walktoxy_timer,"unit_delay_walktoxy_timer");
+int do_init_unit(void) {
+ iTimer->add_timer_func_list(unit->attack_timer, "unit_attack_timer");
+ iTimer->add_timer_func_list(unit->walktoxy_timer,"unit_walktoxy_timer");
+ iTimer->add_timer_func_list(unit->walktobl_sub, "unit_walktobl_sub");
+ iTimer->add_timer_func_list(unit->delay_walktoxy_timer,"unit_delay_walktoxy_timer");
return 0;
}
-int do_final_unit(void)
-{
+int do_final_unit(void) {
// nothing to do
return 0;
}
+
+void unit_defaults(void) {
+ unit = &unit_s;
+
+ unit->init = do_init_unit;
+ unit->final = do_final_unit;
+ /* */
+ unit->bl2ud = unit_bl2ud;
+ unit->bl2ud2 = unit_bl2ud2;
+ unit->attack_timer = unit_attack_timer;
+ unit->walktoxy_timer = unit_walktoxy_timer;
+ unit->walktoxy_sub = unit_walktoxy_sub;
+ unit->delay_walktoxy_timer = unit_delay_walktoxy_timer;
+ unit->walktoxy = unit_walktoxy;
+ unit->walktobl_sub = unit_walktobl_sub;
+ unit->walktobl = unit_walktobl;
+ unit->run = unit_run;
+ unit->wugdash = unit_wugdash;
+ unit->escape = unit_escape;
+ unit->movepos = unit_movepos;
+ unit->setdir = unit_setdir;
+ unit->getdir = unit_getdir;
+ unit->blown = unit_blown;
+ unit->warp = unit_warp;
+ unit->stop_walking = unit_stop_walking;
+ unit->skilluse_id = unit_skilluse_id;
+ unit->is_walking = unit_is_walking;
+ unit->can_move = unit_can_move;
+ unit->resume_running = unit_resume_running;
+ unit->set_walkdelay = unit_set_walkdelay;
+ unit->skilluse_id2 = unit_skilluse_id2;
+ unit->skilluse_pos = unit_skilluse_pos;
+ unit->skilluse_pos2 = unit_skilluse_pos2;
+ unit->set_target = unit_set_target;
+ unit->stop_attack = unit_stop_attack;
+ unit->unattackable = unit_unattackable;
+ unit->attack = unit_attack;
+ unit->cancel_combo = unit_cancel_combo;
+ unit->can_reach_pos = unit_can_reach_pos;
+ unit->can_reach_bl = unit_can_reach_bl;
+ unit->calc_pos = unit_calc_pos;
+ unit->attack_timer_sub = unit_attack_timer_sub;
+ unit->skillcastcancel = unit_skillcastcancel;
+ unit->dataset = unit_dataset;
+ unit->counttargeted = unit_counttargeted;
+ unit->fixdamage = unit_fixdamage;
+ unit->changeviewsize = unit_changeviewsize;
+ unit->remove_map = unit_remove_map;
+ unit->remove_map_pc = unit_remove_map_pc;
+ unit->free_pc = unit_free_pc;
+ unit->free = unit_free;
+}
diff --git a/src/map/unit.h b/src/map/unit.h
index b743fc8cb..be7b789d9 100644
--- a/src/map/unit.h
+++ b/src/map/unit.h
@@ -68,79 +68,61 @@ struct view_data {
unsigned dead_sit : 2;
};
-// PC, MOB, PET に共通する処理を1つにまとめる計画
-
-// 歩行開始
-// 戻り値は、0 ( 成功 ), 1 ( 失敗 )
-int unit_walktoxy( struct block_list *bl, short x, short y, int easy);
-int unit_walktobl( struct block_list *bl, struct block_list *target, int range, int easy);
-int unit_run(struct block_list *bl);
-int unit_calc_pos(struct block_list *bl, int tx, int ty, uint8 dir);
-
-// 歩行停止
-// typeは以下の組み合わせ :
-// 1: 位置情報の送信( この関数の後に位置情報を送信する場合は不要 )
-// 2: ダメージディレイ有り
-// 4: 不明(MOBのみ?)
-int unit_stop_walking(struct block_list *bl,int type);
-int unit_can_move(struct block_list *bl);
-int unit_is_walking(struct block_list *bl);
-int unit_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type);
-
-int unit_escape(struct block_list *bl, struct block_list *target, short dist);
-// 位置の強制移動(吹き飛ばしなど)
-int unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath);
-int unit_warp(struct block_list *bl, short map, short x, short y, clr_type type);
-int unit_setdir(struct block_list *bl,unsigned char dir);
-uint8 unit_getdir(struct block_list *bl);
-int unit_blown(struct block_list* bl, int dx, int dy, int count, int flag);
-
-// そこまで歩行でたどり着けるかの判定
-bool unit_can_reach_pos(struct block_list *bl,int x,int y,int easy);
-bool unit_can_reach_bl(struct block_list *bl,struct block_list *tbl, int range, int easy, short *x, short *y);
-
-// 攻撃関連
-int unit_stop_attack(struct block_list *bl);
-int unit_attack(struct block_list *src,int target_id,int continuous);
-int unit_cancel_combo(struct block_list *bl);
-
-// スキル使用
-int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv);
-int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv);
-
-// スキル使用( 補正済みキャスト時間、キャンセル不可設定付き )
-int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel);
-int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel);
-
-// 詠唱キャンセル
-int unit_skillcastcancel(struct block_list *bl,int type);
-
-int unit_counttargeted(struct block_list *bl);
-int unit_set_target(struct unit_data* ud, int target_id);
-
-// unit_data の初期化処理
-void unit_dataset(struct block_list *bl);
+extern const short dirx[8];
+extern const short diry[8];
-int unit_fixdamage(struct block_list *src,struct block_list *target,unsigned int tick,int sdelay,int ddelay,int64 damage,int div,int type,int64 damage2);
-// その他
-struct unit_data* unit_bl2ud(struct block_list *bl);
-struct unit_data* unit_bl2ud2(struct block_list *bl);
-void unit_remove_map_pc(struct map_session_data *sd, clr_type clrtype);
-void unit_free_pc(struct map_session_data *sd);
-#define unit_remove_map(bl,clrtype) unit_remove_map_(bl,clrtype,__FILE__,__LINE__,__func__)
-int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, int line, const char* func);
-int unit_free(struct block_list *bl, clr_type clrtype);
-int unit_changeviewsize(struct block_list *bl,short size);
+struct unit_interface {
+ int (*init) (void);
+ int (*final) (void);
+ /* */
+ struct unit_data* (*bl2ud) (struct block_list *bl);
+ struct unit_data* (*bl2ud2) (struct block_list *bl);
+ int (*attack_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*walktoxy_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*walktoxy_sub) (struct block_list *bl);
+ int (*delay_walktoxy_timer) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*walktoxy) (struct block_list *bl, short x, short y, int flag);
+ int (*walktobl_sub) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*walktobl) (struct block_list *bl, struct block_list *tbl, int range, int flag);
+ int (*run) (struct block_list *bl);
+ int (*wugdash) (struct block_list *bl, struct map_session_data *sd);
+ int (*escape) (struct block_list *bl, struct block_list *target, short dist);
+ int (*movepos) (struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath);
+ int (*setdir) (struct block_list *bl, unsigned char dir);
+ uint8 (*getdir) (struct block_list *bl);
+ int (*blown) (struct block_list *bl, int dx, int dy, int count, int flag);
+ int (*warp) (struct block_list *bl, short m, short x, short y, clr_type type);
+ int (*stop_walking) (struct block_list *bl, int type);
+ int (*skilluse_id) (struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv);
+ int (*is_walking) (struct block_list *bl);
+ int (*can_move) (struct block_list *bl);
+ int (*resume_running) (int tid, unsigned int tick, int id, intptr_t data);
+ int (*set_walkdelay) (struct block_list *bl, unsigned int tick, int delay, int type);
+ int (*skilluse_id2) (struct block_list *src, int target_id, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel);
+ int (*skilluse_pos) (struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv);
+ int (*skilluse_pos2) (struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel);
+ int (*set_target) (struct unit_data *ud, int target_id);
+ int (*stop_attack) (struct block_list *bl);
+ int (*unattackable) (struct block_list *bl);
+ int (*attack) (struct block_list *src, int target_id, int continuous);
+ int (*cancel_combo) (struct block_list *bl);
+ bool (*can_reach_pos) (struct block_list *bl, int x, int y, int easy);
+ bool (*can_reach_bl) (struct block_list *bl, struct block_list *tbl, int range, int easy, short *x, short *y);
+ int (*calc_pos) (struct block_list *bl, int tx, int ty, uint8 dir);
+ int (*attack_timer_sub) (struct block_list *src, int tid, unsigned int tick);
+ int (*skillcastcancel) (struct block_list *bl, int type);
+ void (*dataset) (struct block_list *bl);
+ int (*counttargeted) (struct block_list *bl);
+ int (*fixdamage) (struct block_list *src, struct block_list *target, unsigned int tick, int sdelay, int ddelay, int64 damage, int div, int type, int64 damage2);
+ int (*changeviewsize) (struct block_list *bl, short size);
+ int (*remove_map) (struct block_list *bl, clr_type clrtype, const char *file, int line, const char *func);
+ void (*remove_map_pc) (struct map_session_data *sd, clr_type clrtype);
+ void (*free_pc) (struct map_session_data *sd);
+ int (*free) (struct block_list *bl, clr_type clrtype);
+};
-// 初期化ルーチン
-int do_init_unit(void);
-int do_final_unit(void);
-/**
- * Ranger
- **/
-int unit_wugdash(struct block_list *bl, struct map_session_data *sd);
+struct unit_interface *unit;
-extern const short dirx[8];
-extern const short diry[8];
+void unit_defaults(void);
#endif /* _UNIT_H_ */
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 4e4851bc5..e3043a668 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -33,4 +33,4 @@ if( INSTALL_COMPONENT_RUNTIME )
endif( INSTALL_COMPONENT_RUNTIME )
set( TARGET_LIST ${TARGET_LIST} sample CACHE INTERNAL "" )
message( STATUS "Creating target sample - done" )
-endif( BUILD_PLUGIN_sample ) \ No newline at end of file
+endif( BUILD_PLUGIN_sample )
diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in
index 98f18f4d4..5ed421abf 100644
--- a/src/plugins/Makefile.in
+++ b/src/plugins/Makefile.in
@@ -9,7 +9,7 @@ CC = @CC@
export CC
#####################################################################
-.PHONY : all $(PLUGINS) sample db2sql clean help
+.PHONY: all $(PLUGINS) sample db2sql clean help
all: $(PLUGINS)
diff --git a/src/plugins/db2sql.c b/src/plugins/db2sql.c
index 5cb8d52a2..ebd2a9ee5 100644
--- a/src/plugins/db2sql.c
+++ b/src/plugins/db2sql.c
@@ -135,4 +135,4 @@ HPExport void plugin_init (void) {
strlib = GET_SYMBOL("strlib");
HPMi->addCPCommand("server:tools:db2sql",CPCMD_A(db2sql));
-} \ No newline at end of file
+}
diff --git a/src/plugins/sample.c b/src/plugins/sample.c
index 4a8402560..4f9e34f74 100644
--- a/src/plugins/sample.c
+++ b/src/plugins/sample.c
@@ -141,4 +141,4 @@ HPExport void server_online (void) {
/* run when server is shutting down */
HPExport void plugin_final (void) {
ShowInfo ("%s says ~Bye world\n",pinfo.name);
-} \ No newline at end of file
+}
diff --git a/src/test/Makefile.in b/src/test/Makefile.in
index 56cbfefc9..f17c43202 100644
--- a/src/test/Makefile.in
+++ b/src/test/Makefile.in
@@ -1,20 +1,22 @@
COMMON_H = $(shell ls ../common/*.h)
+CONFIG_H = $(shell ls ../config/*.h ../config/*/*.h)
-MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o
-MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h
-MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar
+MT19937AR_D = ../../3rdparty/mt19937ar
+MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
+MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
+MT19937AR_INCLUDE = -I$(MT19937AR_D)
-LIBCONFIG_OBJ = ../../3rdparty/libconfig/libconfig.o ../../3rdparty/libconfig/grammar.o \
- ../../3rdparty/libconfig/scanctx.o ../../3rdparty/libconfig/scanner.o ../../3rdparty/libconfig/strbuf.o
-LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/grammar.h \
- ../../3rdparty/libconfig/parsectx.h ../../3rdparty/libconfig/scanctx.h ../../3rdparty/libconfig/scanner.h \
- ../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h
-LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig
+LIBCONFIG_D = ../../3rdparty/libconfig
+LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
+ scanner.o strbuf.o)
+LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
+ scanctx.h scanner.h strbuf.h wincompat.h)
+LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
TEST_SPINLOCK_OBJ=obj/test_spinlock.o
TEST_SPINLOCK_H=
-TEST_SPINLOCK_DEPENDS=obj $(TEST_SPINLOCK_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ)
+TEST_SPINLOCK_DEPENDS=$(TEST_SPINLOCK_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ)
@SET_MAKE@
@@ -22,7 +24,7 @@ CC = @CC@
export CC
#####################################################################
-.PHONY :all test_spinlock
+.PHONY: all test_spinlock
all: test_spinlock
@@ -46,19 +48,23 @@ test_spinlock: $(TEST_SPINLOCK_DEPENDS)
# login object files
-obj/%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H)
+obj/%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj
@echo " CC $<"
@$(CC) @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
../common/obj_all/common.a:
+ @echo " MAKE $@"
@$(MAKE) -C ../common sql
../common/obj_sql/common_sql.a:
+ @echo " MAKE $@"
@$(MAKE) -C ../common sql
$(MT19937AR_OBJ):
- @$(MAKE) -C ../../3rdparty/mt19937ar
+ @echo " MAKE $@"
+ @$(MAKE) -C $(MT19937AR_D)
$(LIBCONFIG_OBJ):
- @$(MAKE) -C ../../3rdparty/libconfig
+ @echo " MAKE $@"
+ @$(MAKE) -C $(LIBCONFIG_D)
diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in
index de4607dc3..4fa527ffc 100644
--- a/src/tool/Makefile.in
+++ b/src/tool/Makefile.in
@@ -1,19 +1,18 @@
-COMMON_OBJ = ../common/obj_all/minicore.o ../common/obj_all/malloc.o \
- ../common/obj_all/showmsg.o ../common/obj_all/strlib.o \
- ../common/obj_all/utils.o ../common/obj_all/des.o ../common/obj_all/grfio.o ../common/obj_all/miniconsole.o
-COMMON_H = ../common/core.h ../common/mmo.h \
- ../common/malloc.h ../common/showmsg.h ../common/strlib.h \
- ../common/utils.h ../common/cbasetypes.h ../common/des.h ../common/grfio.h ../common/console.h ../config/renewal.h
-
-LIBCONFIG_OBJ = ../../3rdparty/libconfig/libconfig.o ../../3rdparty/libconfig/grammar.o \
- ../../3rdparty/libconfig/scanctx.o ../../3rdparty/libconfig/scanner.o ../../3rdparty/libconfig/strbuf.o
-LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/grammar.h \
- ../../3rdparty/libconfig/parsectx.h ../../3rdparty/libconfig/scanctx.h ../../3rdparty/libconfig/scanner.h \
- ../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h
-LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig
-
-OTHER_H = ../config/renewal.h
+COMMON_D = ../common
+COMMON_OBJ = $(addprefix $(COMMON_D)/obj_all/, des.o grfio.o malloc.o \
+ miniconsole.o minicore.o showmsg.o strlib.o utils.o)
+COMMON_H = $(addprefix $(COMMON_D)/, cbasetypes.h console.h core.h des.h \
+ grfio.h malloc.h mmo.h showmsg.h strlib.h utils.h)
+
+LIBCONFIG_D = ../../3rdparty/libconfig
+LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
+ scanner.o strbuf.o)
+LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
+ scanctx.h scanner.h strbuf.h wincompat.h)
+LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
+
+CONFIG_H = $(shell ls ../config/*.h ../config/*/*.h)
MAPCACHE_OBJ = obj_all/mapcache.o
@@ -23,11 +22,11 @@ CC = @CC@
export CC
#####################################################################
-.PHONY : all mapcache clean help
+.PHONY: all mapcache clean help
all: mapcache
-mapcache: obj_all $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ)
+mapcache: $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ)
@echo " LD $@"
@$(CC) @LDFLAGS@ $(LIBCONFIG_INCLUDE) -o ../../mapcache@EXEEXT@ $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) @LIBS@
@@ -48,16 +47,19 @@ obj_all:
@echo " MKDIR obj_all"
@-mkdir obj_all
-obj_all/%.o: %.c $(COMMON_H) $(OTHER_H) $(LIBCONFIG_H)
+obj_all/%.o: %.c $(COMMON_H) $(CONFIG_H) $(LIBCONFIG_H) | obj_all
@echo " CC $<"
@$(CC) @CFLAGS@ $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing common object files
../common/obj_all/%.o:
+ @echo " MAKE $@"
@$(MAKE) -C ../common sql
../common/obj_all/mini%.o:
+ @echo " MAKE $@"
@$(MAKE) -C ../common sql
$(LIBCONFIG_OBJ):
- @$(MAKE) -C ../../3rdparty/libconfig
+ @echo " MAKE $@"
+ @$(MAKE) -C $(LIBCONFIG_D)
diff --git a/tools/mapreg-converter.php b/tools/mapreg-converter.php
index 3d548554a..ef5cc791c 100644
--- a/tools/mapreg-converter.php
+++ b/tools/mapreg-converter.php
@@ -35,4 +35,4 @@
}
fprintf(STDERR, "done.".PHP_EOL);
-?> \ No newline at end of file
+?>