From 5245e666a09df5f401c1329bf5ee1fc1b09b1d16 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Thu, 20 Sep 2007 11:09:36 +0000 Subject: * Merged the tmpsql branch: - Abstraction for the sql code (sql.c/h). - New configure script and makefiles. - Restored txt zeny logging code. (r10814) - Rewrote mapserver's sql code - itemdb, mobdb, mapreg, logs. (r10814) - Fixed a precedence issue (&& and ) in char_sql/char.c. (r10833) - Improved db reading code a bit for consistency. (r11077) - Added separate atcommand for mail deletion. (r11077) - Corrected a few messages that said "new" instead of "unread". (r11077) - Broadcast (*) messages now use "*" as the target's name (not ""). (r11077) - Moved StringBuf code from utils.c/h to strlib.c/h. (r11084 r11117) - Some misc login server cleanups (reformatting etc). (r11136) - Corrected/modified some header entries. (r11141 r11147 11148) - Adjusted VS project files. (r11147) - Adjusted the way the sql charserver does item saving. (r11192) - Corrected usage of reserved keyword 'friend' in mmo.h. (r11192) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11245 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/tool/Makefile.in | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/tool/Makefile.in (limited to 'src/tool/Makefile.in') diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in new file mode 100644 index 000000000..7c0d1e1ee --- /dev/null +++ b/src/tool/Makefile.in @@ -0,0 +1,28 @@ +##################################################################### +.PHONY : all adduser convert mapcache clean help + +all: adduser convert mapcache + +adduser: + @CC@ -o ../../tools/adduser@EXEEXT@ adduser.c + +convert: + @CC@ -o ../../tools/convert@EXEEXT@ convert.c + +mapcache: + @CC@ -c -o grfio.o grfio.c + @CC@ -o ../../mapcache@EXEEXT@ mapcache.c grfio.o -lz + +clean: + rm -rf *.o ../../tools/adduser@EXEEXT@ ../../tools/convert@EXEEXT@ ../../mapcache@EXEEXT@ + +help: + @echo "possible targets are 'adduser' 'convert' 'mapcache' 'all' 'clean' 'help'" + @echo "'adduser' - ???" + @echo "'convert' - ???" + @echo "'mapcache' - mapcache generator" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" + +##################################################################### -- cgit v1.2.3-70-g09d2 From 17222f8fdc6cb6f17efe391cbab0c357a5f93081 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Mon, 26 Nov 2007 22:36:30 +0000 Subject: * Normalized makefiles: - 3 sections: variables, public targets, private/support targets - object files always in a *_OBJ variable - header files always in a *_H variable - object files always generated to an obj* subfolder - all Makefiles can be executed individually, calling other makefiles if necessary - generic object targets when possible git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11812 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 11 +++- src/char/Makefile.in | 29 ++++----- src/char_sql/Makefile.in | 39 ++++++++----- src/common/Makefile.in | 57 +++++++----------- src/ladmin/Makefile.in | 26 +++++++-- src/login/Makefile.in | 21 +++++-- src/login_sql/Makefile.in | 23 ++++++-- src/map/Makefile.in | 133 ++++++++++++++---------------------------- src/plugins/Makefile.in | 34 +++++------ src/tool/Makefile.in | 14 +++-- src/txt-converter/Makefile.in | 58 ++++++++++++------ 11 files changed, 230 insertions(+), 215 deletions(-) (limited to 'src/tool/Makefile.in') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index b0dffd272..937ea74ea 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,8 +4,15 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/11/26 - * Fixed buildin_query_sql using Sql_Query instead of Sql_QueryStr, making - all %f,%d,... be processed. (fixes bureport:218) [FlavioJS] + * Normalized makefiles: + - 3 sections: variables, public targets, private/support targets + - object files always in a *_OBJ variable + - header files always in a *_H variable + - object files always generated to an obj* subfolder + - all Makefiles can be executed individually, calling other makefiles if necessary + - generic object targets when possible + * Fixed buildin_query_sql using Sql_Query instead of Sql_QueryStr, + wrongly processing all %f,%d,... (fixes bureport:218) [FlavioJS] * Fixed guild expulsion not working correctly [ultramage] * Fixed a memory leak in mail_savemessage (src\char_sql\int_mail.c). [FlavioJS] 2007/11/25 diff --git a/src/char/Makefile.in b/src/char/Makefile.in index 78d2cb2c8..334265819 100644 --- a/src/char/Makefile.in +++ b/src/char/Makefile.in @@ -1,3 +1,4 @@ + COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ @@ -9,18 +10,22 @@ COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/strlib.h ../common/grfio.h \ ../common/mapindex.h ../common/ers.h -CHAR_OBJ = char.o inter.o int_party.o int_guild.o int_storage.o int_status.o int_pet.o int_homun.o +CHAR_OBJ = obj/char.o obj/inter.o obj/int_party.o obj/int_guild.o \ + obj/int_storage.o obj/int_status.o obj/int_pet.o obj/int_homun.o +CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_status.h int_pet.h int_homun.h + +@SET_MAKE@ ##################################################################### .PHONY : all char-server clean help all: char-server -char-server: $(CHAR_OBJ) $(COMMON_OBJ) +char-server: obj $(CHAR_OBJ) $(COMMON_OBJ) @CC@ @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) @LIBS@ clean: - rm -f *.o ../../char-server@EXEEXT@ + rm -rf *.o obj ../../char-server@EXEEXT@ help: @echo "possible targets are 'char-server' 'all' 'clean' 'help'" @@ -31,16 +36,12 @@ help: ##################################################################### -%.o: %.c - @CC@ @CFLAGS@ -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj: + -mkdir obj -# DO NOT DELETE +obj/%.o: %.c $(CHAR_H) $(COMMON_H) + @CC@ @CFLAGS@ -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -char.o: char.c char.h inter.h int_pet.h $(COMMON_H) -inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h char.h $(COMMON_H) -int_party.o: int_party.c int_party.h inter.h char.h $(COMMON_H) -int_guild.o: int_guild.c int_guild.h int_storage.h inter.h char.h $(COMMON_H) -int_storage.o: int_storage.c int_storage.h int_guild.h inter.h char.h $(COMMON_H) -int_status.o: int_status.c int_status.h char.h $(COMMON_H) -int_pet.o: int_pet.c int_pet.h inter.h char.h $(COMMON_H) -int_homun.o: int_homun.c int_homun.h inter.h char.h $(COMMON_H) +# missing common object files +../common/obj/%.o: + @$(MAKE) -C ../common txt diff --git a/src/char_sql/Makefile.in b/src/char_sql/Makefile.in index 685d4286d..8162511d5 100644 --- a/src/char_sql/Makefile.in +++ b/src/char_sql/Makefile.in @@ -1,33 +1,41 @@ + COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ ../common/obj/strlib.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o ../common/obj_sql/sql.o + ../common/obj/mapindex.o ../common/obj/ers.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ ../common/malloc.h ../common/showmsg.h ../common/utils.h \ ../common/strlib.h ../common/grfio.h \ - ../common/mapindex.h ../common/ers.h ../common/sql.h + ../common/mapindex.h ../common/ers.h + +COMMON_SQL_OBJ = ../common/obj_sql/sql.o +COMMON_H = ../common/sql.h -CHAR_OBJ = char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o int_homun.o int_mail.o +CHAR_OBJ = obj/char.o obj/inter.o obj/int_party.o obj/int_guild.o \ + obj/int_storage.o obj/int_pet.o obj/int_homun.o obj/int_mail.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 HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - CHAR_SERVER_SQL_DEPENDS=$(CHAR_OBJ) $(COMMON_OBJ) + CHAR_SERVER_SQL_DEPENDS=obj $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) else CHAR_SERVER_SQL_DEPENDS=needs_mysql endif +@SET_MAKE@ + ##################################################################### .PHONY : all char-server_sql clean help all: char-server_sql char-server_sql: $(CHAR_SERVER_SQL_DEPENDS) - @CC@ @LDFLAGS@ -o ../../char-server_sql@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) @LIBS@ @MYSQL_LIBS@ + @CC@ @LDFLAGS@ -o ../../char-server_sql@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) @LIBS@ @MYSQL_LIBS@ clean: - rm -f *.o ../../char-server_sql@EXEEXT@ + rm -rf *.o obj ../../char-server_sql@EXEEXT@ help: @echo "possible targets are 'char-server_sql' 'all' 'clean' 'help'" @@ -42,16 +50,15 @@ needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 -%.o: %.c +obj: + -mkdir obj + +obj/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -# DO NOT DELETE +# missing common object files +../common/obj/%.o: + @$(MAKE) -C ../common sql -char.o: char.c char.h $(COMMON_H) -inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h $(COMMON_H) -int_party.o: int_party.c int_party.h inter.h $(COMMON_H) -int_guild.o: int_guild.c int_guild.h inter.h $(COMMON_H) -int_storage.o: int_storage.c int_storage.h char.h $(COMMON_H) -int_pet.o: int_pet.c int_pet.h inter.h char.h $(COMMON_H) -int_homun.o: int_homun.c int_homun.h inter.h char.h $(COMMON_H) -int_mail.o: int_mail.c int_mail.h inter.h char.h $(COMMON_H) \ No newline at end of file +../common/obj_sql/%.o: + @$(MAKE) -C ../common sql diff --git a/src/common/Makefile.in b/src/common/Makefile.in index 94f42a956..89bb8a75a 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -1,18 +1,33 @@ + +COMMON_OBJ = obj/core.o obj/socket.o obj/timer.o obj/db.o obj/plugins.o obj/lock.o \ + obj/nullpo.o obj/malloc.o obj/showmsg.o obj/strlib.o obj/utils.o \ + obj/grfio.o obj/mapindex.o obj/ers.o obj/md5calc.o \ + obj/minicore.o obj/minisocket.o obj/minimalloc.o +COMMON_H = svnversion.h mmo.h plugin.h version.h \ + core.h socket.h timer.h db.h plugins.h lock.h \ + nullpo.h malloc.h showmsg.h strlib.h utils.h \ + grfio.h mapindex.h ers.h md5calc.h + +COMMON_SQL_OBJ = obj_sql/sql.o +COMMON_SQL_H = sql.h + HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) ALL_DEPENDS=txt sql - SQL_DEPENDS=txt obj_sql common_sql + SQL_DEPENDS=common common_sql else ALL_TARGET=txt SQL_DEPENDS=needs_mysql endif +@SET_MAKE@ + ##################################################################### .PHONY : all txt sql clean help all: $(ALL_DEPENDS) -txt: obj common +txt: common sql: $(SQL_DEPENDS) @@ -39,21 +54,18 @@ obj: obj_sql: -mkdir obj_sql -common: obj/core.o obj/socket.o obj/timer.o obj/db.o obj/plugins.o obj/lock.o \ - obj/nullpo.o obj/malloc.o obj/showmsg.o obj/strlib.o obj/utils.o \ - obj/grfio.o obj/minicore.o obj/minisocket.o obj/minimalloc.o \ - obj/mapindex.o obj/ers.o obj/md5calc.o +common: obj $(COMMON_OBJ) -common_sql: obj_sql/sql.o +common_sql: obj_sql $(COMMON_SQL_OBJ) -obj/%.o: %.c +obj/%.o: %.c $(COMMON_H) @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj/mini%.o: %.c +obj/mini%.o: %.c $(COMMON_H) @CC@ @CFLAGS@ -DMINICORE @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj_sql/%.o: %.c +obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< @@ -68,28 +80,3 @@ else svnversion.h: @printf "\n" > svnversion.h endif - -obj/minicore.o: core.c core.h -obj/minisocket.o: socket.c socket.h -obj/minimalloc.o: malloc.c malloc.h - -# DO NOT DELETE - -obj/core.o: core.c core.h showmsg.h svnversion.h -obj/db.o: db.c db.h showmsg.h ers.h -obj/ers.o: ers.c ers.h cbasetypes.h -obj/grfio.o: grfio.c grfio.h -obj/lock.o: lock.c lock.h showmsg.h -obj/malloc.o: malloc.c malloc.h showmsg.h -obj/mapindex.o: mapindex.c mapindex.h -obj/md5calc.o: md5calc.c md5calc.h -obj/nullpo.o: nullpo.c nullpo.h showmsg.h -obj/plugins.o: plugins.c plugins.h plugin.h -obj/showmsg.o: showmsg.c showmsg.h -obj/socket.o: socket.c socket.h mmo.h showmsg.h plugins.h -obj/strlib.o: strlib.c strlib.h utils.h -obj/timer.o: timer.c timer.h showmsg.h -obj/utils.o: utils.c utils.h malloc.h showmsg.h mmo.h -obj_sql/sql.o: sql.c sql.h cbasetypes.h malloc.h showmsg.h utils.h -mmo.h: cbasetypes.h - @touch mmo.h diff --git a/src/ladmin/Makefile.in b/src/ladmin/Makefile.in index f1f7bff23..87cc2ad49 100644 --- a/src/ladmin/Makefile.in +++ b/src/ladmin/Makefile.in @@ -1,20 +1,26 @@ + COMMON_OBJ = ../common/obj/minicore.o ../common/obj/minisocket.o ../common/obj/timer.o \ ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o \ ../common/obj/utils.o ../common/obj/md5calc.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ ../common/version.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h \ - ../common/utils.h ../common/md5calc.h + ../common/utils.h ../common/md5calc.h ../common/cbasetypes.h + +LADMIN_OBJ = obj/ladmin.o +LADMIN_H = ladmin.h + +@SET_MAKE@ ##################################################################### .PHONY : all ladmin clean help all: ladmin -ladmin: ladmin.o $(COMMON_OBJ) - @CC@ @LDFLAGS@ -o ../../ladmin@EXEEXT@ ladmin.o $(COMMON_OBJ) @LIBS@ +ladmin: obj $(LADMIN_OBJ) $(COMMON_OBJ) + @CC@ @LDFLAGS@ -o ../../ladmin@EXEEXT@ $(LADMIN_OBJ) $(COMMON_OBJ) @LIBS@ clean: - rm -f *.o ../../ladmin@EXEEXT@ + rm -rf *.o obj ../../ladmin@EXEEXT@ help: @echo "possible targets are 'ladmin' 'all' 'clean' 'help'" @@ -25,7 +31,15 @@ help: ##################################################################### -# DO NOT DELETE +obj: + -mkdir obj -ladmin.o: ladmin.c ladmin.h $(COMMON_H) +obj/%.o: %.c $(LADMIN_H) $(COMMON_H) @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + +# missing common object files +../common/obj/%.o: + @$(MAKE) -C ../common txt + +../common/obj/mini%.o: + @$(MAKE) -C ../common txt diff --git a/src/login/Makefile.in b/src/login/Makefile.in index c0fdcc8e3..187a3eaf0 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -1,3 +1,4 @@ + COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ @@ -9,16 +10,21 @@ COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/grfio.h ../common/mapindex.h \ ../common/ers.h ../common/md5calc.h +LOGIN_OBJ = obj/login.o +LOGIN_H = login.h + +@SET_MAKE@ + ##################################################################### .PHONY : all login-server clean help all: login-server -login-server: login.o $(COMMON_OBJ) - @CC@ @LDFLAGS@ -o ../../login-server@EXEEXT@ login.o $(COMMON_OBJ) @LIBS@ +login-server: obj $(LOGIN_OBJ) $(COMMON_OBJ) + @CC@ @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_OBJ) $(COMMON_OBJ) @LIBS@ clean: - rm -f *.o ../../login-server@EXEEXT@ + rm -rf *.o obj ../../login-server@EXEEXT@ help: @echo "possible targets are 'login-server' 'all' 'clean' 'help'" @@ -29,7 +35,12 @@ help: ##################################################################### -# DO NOT DELETE +obj: + -mkdir obj -login.o: login.c login.h $(COMMON_H) +obj/%.o: %.c $(LOGIN_H) $(COMMON_H) @CC@ @CFLAGS@ -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + +# missing common object files +../common/obj/%.o: + @$(MAKE) -C ../common sql diff --git a/src/login_sql/Makefile.in b/src/login_sql/Makefile.in index d10b49b5f..22a1437b3 100644 --- a/src/login_sql/Makefile.in +++ b/src/login_sql/Makefile.in @@ -9,23 +9,28 @@ COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/grfio.h ../common/mapindex.h \ ../common/ers.h ../common/md5calc.h ../common/sql.h +LOGIN_OBJ = obj/login.o +LOGIN_H = login.h + HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - LOGIN_SERVER_SQL_DEPENDS=login.o $(COMMON_OBJ) + LOGIN_SERVER_SQL_DEPENDS=obj $(LOGIN_OBJ) $(COMMON_OBJ) else LOGIN_SERVER_SQL_DEPENDS=needs_mysql endif +@SET_MAKE@ + ##################################################################### .PHONY : all login-server_sql clean help all: login-server_sql login-server_sql: $(LOGIN_SERVER_SQL_DEPENDS) - @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ login.o $(COMMON_OBJ) @LIBS@ @MYSQL_LIBS@ + @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_OBJ) $(COMMON_OBJ) @LIBS@ @MYSQL_LIBS@ clean: - rm -f *.o ../../login-server_sql@EXEEXT@ + rm -rf *.o obj ../../login-server_sql@EXEEXT@ help: @echo "possible targets are 'login-server_sql' 'all' 'clean' 'help'" @@ -40,7 +45,15 @@ needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 -# DO NOT DELETE +obj: + -mkdir obj -login.o: login.c login.h $(COMMON_H) +obj/%.o: %.c $(LOGIN_H) $(COMMON_H) @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + +# missing common object files +../common/obj/%.o: + @$(MAKE) -C ../common sql + +../common/obj_sql/%.o: + @$(MAKE) -C ../common sql diff --git a/src/map/Makefile.in b/src/map/Makefile.in index 1be112d9a..31c0fc3f1 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -1,8 +1,33 @@ +COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ + ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ + ../common/obj/nullpo.o ../common/obj/malloc.o ../common/obj/showmsg.o \ + ../common/obj/utils.o ../common/obj/strlib.o ../common/obj/grfio.o \ + ../common/obj/mapindex.o ../common/obj/ers.o +COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h \ + ../common/db.h ../common/plugins.h ../common/lock.h \ + ../common/nullpo.h ../common/malloc.h ../common/showmsg.h \ + ../common/utils.h ../common/strlib.h ../common/grfio.h \ + ../common/mapindex.h ../common/ers.h + +COMMON_SQL_OBJ = ../common/obj_sql/sql.o +COMMON_SQL_H = ../common/sql.h + +MAP_OBJ = obj/map.o obj/chrif.o obj/clif.o obj/pc.o obj/status.o obj/npc.o \ + obj/npc_chat.o obj/chat.o obj/path.o obj/itemdb.o obj/mob.o obj/script.o \ + obj/storage.o obj/skill.o obj/atcommand.o obj/charcommand.o obj/battle.o \ + obj/intif.o obj/trade.o obj/party.o obj/vending.o obj/guild.o obj/pet.o \ + obj/log.o obj/mail.o obj/date.o obj/irc.o obj/unit.o obj/mercenary.o +MAP_H = map.h chrif.h clif.h pc.h status.h npc.h \ + chat.h itemdb.h mob.h script.h \ + storage.h skill.h atcommand.h charcommand.h battle.h \ + intif.h trade.h party.h vending.h guild.h pet.h \ + log.h mail.h date.h irc.h unit.h mercenary.h + HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) ALL_DEPENDS=txt sql - SQL_DEPENDS=obj_sql map-server_sql + SQL_DEPENDS=map-server_sql else ALL_TARGET=txt SQL_DEPENDS=needs_mysql @@ -15,18 +40,19 @@ else PCRE_CFLAGS= endif +@SET_MAKE@ ##################################################################### .PHONY : all txt sql clean help all: $(ALL_DEPENDS) -txt: obj_txt map-server +txt: map-server sql: $(SQL_DEPENDS) clean: - rm -rf *.o ../../map-server@EXEEXT@ ../../map-server_sql@EXEEXT@ obj_txt obj_sql + rm -rf *.o obj_txt obj_sql ../../map-server@EXEEXT@ ../../map-server_sql@EXEEXT@ help: ifeq ($(HAVE_MYSQL),yes) @@ -46,103 +72,30 @@ needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 +# object directories obj_txt: -mkdir obj_txt obj_sql: -mkdir obj_sql -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/nullpo.o ../common/obj/malloc.o ../common/obj/showmsg.o \ - ../common/obj/utils.o ../common/obj/strlib.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o - -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h \ - ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/nullpo.h ../common/malloc.h ../common/showmsg.h \ - ../common/utils.h ../common/strlib.h ../common/grfio.h \ - ../common/mapindex.h ../common/ers.h - -COMMON_SQL_OBJ = $(COMMON_OBJ) ../common/obj_sql/sql.o - -COMMON_SQL_H = $(COMMON_H) ../common/sql.h - -MAP_OBJ = obj/map.o obj/chrif.o obj/clif.o obj/pc.o obj/status.o obj/npc.o \ - obj/npc_chat.o obj/chat.o obj/path.o obj/itemdb.o obj/mob.o obj/script.o \ - obj/storage.o obj/skill.o obj/atcommand.o obj/charcommand.o obj/battle.o \ - obj/intif.o obj/trade.o obj/party.o obj/vending.o obj/guild.o obj/pet.o \ - obj/log.o obj/mail.o obj/date.o obj/irc.o obj/unit.o obj/mercenary.o - -map-server: $(MAP_OBJ:obj/%=obj_txt/%) $(COMMON_OBJ) +# executables +map-server: obj_txt $(MAP_OBJ:obj/%=obj_txt/%) $(COMMON_OBJ) @CC@ @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_OBJ:obj/%=obj_txt/%) $(COMMON_OBJ) @LIBS@ @PCRE_LIBS@ -map-server_sql: $(MAP_OBJ:obj/%=obj_sql/%) $(COMMON_SQL_OBJ) - @CC@ @LDFLAGS@ -o ../../map-server_sql@EXEEXT@ $(MAP_OBJ:obj/%=obj_sql/%) $(COMMON_SQL_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ +map-server_sql: obj_sql $(MAP_OBJ:obj/%=obj_sql/%) $(COMMON_OBJ) $(COMMON_SQL_OBJ) + @CC@ @LDFLAGS@ -o ../../map-server_sql@EXEEXT@ $(MAP_OBJ:obj/%=obj_sql/%) $(COMMON_OBJ) $(COMMON_SQL_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ -obj_txt/%.o: %.c +# map object files +obj_txt/%.o: %.c $(MAP_H) $(COMMON_H) @CC@ @CFLAGS@ $(PCRE_CFLAGS) -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj_sql/%.o: %.c +obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(COMMON_SQL_H) @CC@ @CFLAGS@ $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -# DO NOT DELETE - -obj_txt/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h irc.h $(COMMON_H) -obj_txt/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h $(COMMON_H) -obj_txt/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h irc.h $(COMMON_H) -obj_txt/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h $(COMMON_H) -obj_txt/status.o: status.c pc.h map.h clif.h status.h mob.h itemdb.h battle.h skill.h script.h pet.h guild.h $(COMMON_H) -obj_txt/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) -obj_txt/npc_chat.o: npc_chat.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_H) -obj_txt/chat.o: chat.c map.h clif.h pc.h chat.h $(COMMON_H) -obj_txt/path.o: path.c map.h battle.h $(COMMON_H) -obj_txt/itemdb.o: itemdb.c map.h battle.h itemdb.h $(COMMON_H) -obj_txt/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h date.h irc.h $(COMMON_H) -obj_txt/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h irc.h $(COMMON_H) -obj_txt/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h $(COMMON_H) -obj_txt/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h date.h $(COMMON_H) -obj_txt/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) -obj_txt/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h $(COMMON_H) -obj_txt/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h $(COMMON_H) -obj_txt/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h $(COMMON_H) -obj_txt/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h $(COMMON_H) -obj_txt/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h irc.h $(COMMON_H) -obj_txt/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h $(COMMON_H) -obj_txt/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h $(COMMON_H) -obj_txt/log.o: log.c log.h map.h $(COMMON_H) -obj_txt/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_H) -obj_txt/date.o: date.c date.h $(COMMON_H) -obj_txt/irc.o: irc.c irc.h map.h pc.h $(COMMON_H) -obj_txt/unit.o: unit.c unit.h $(COMMON_H) -obj_txt/mercenary.o: mercenary.c mercenary.h $(COMMON_H) - -obj_sql/map.o: map.c map.h chrif.h clif.h npc.h pc.h mob.h chat.h skill.h itemdb.h storage.h party.h pet.h atcommand.h log.h irc.h $(COMMON_SQL_H) -obj_sql/chrif.o: chrif.c map.h battle.h chrif.h clif.h intif.h pc.h npc.h $(COMMON_SQL_H) -obj_sql/clif.o: clif.c map.h chrif.h clif.h mob.h intif.h pc.h npc.h itemdb.h chat.h script.h storage.h party.h guild.h atcommand.h pet.h charcommand.h $(COMMON_SQL_H) -obj_sql/pc.o: pc.c map.h clif.h intif.h pc.h npc.h mob.h itemdb.h battle.h skill.h script.h party.h guild.h pet.h trade.h storage.h chat.h vending.h log.h $(COMMON_SQL_H) -obj_sql/status.o: status.c pc.h map.h clif.h status.h mob.h itemdb.h battle.h skill.h script.h pet.h guild.h $(COMMON_SQL_H) -obj_sql/npc.o: npc.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_SQL_H) -obj_sql/npc_chat.o: npc_chat.c map.h npc.h clif.h pc.h script.h mob.h itemdb.h battle.h $(COMMON_SQL_H) -obj_sql/chat.o: chat.c map.h clif.h pc.h chat.h $(COMMON_SQL_H) -obj_sql/path.o: path.c map.h battle.h $(COMMON_SQL_H) -obj_sql/itemdb.o: itemdb.c map.h battle.h itemdb.h $(COMMON_SQL_H) -obj_sql/mob.o: mob.c map.h clif.h intif.h pc.h mob.h skill.h battle.h npc.h itemdb.h log.h date.h irc.h $(COMMON_SQL_H) -obj_sql/script.o: script.c itemdb.h map.h pc.h mob.h clif.h intif.h npc.h script.h storage.h skill.h pet.h battle.h log.h irc.h $(COMMON_SQL_H) -obj_sql/storage.o: storage.c itemdb.h pc.h clif.h intif.h storage.h guild.h $(COMMON_SQL_H) -obj_sql/skill.o: skill.c skill.h map.h clif.h pc.h mob.h battle.h itemdb.h script.h log.h date.h $(COMMON_SQL_H) -obj_sql/atcommand.o: atcommand.c atcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_SQL_H) -obj_sql/battle.o: battle.c battle.h skill.h map.h mob.h pc.h pet.h guild.h $(COMMON_SQL_H) -obj_sql/intif.o: intif.c intif.h chrif.h clif.h party.h guild.h storage.h map.h battle.h pet.h $(COMMON_SQL_H) -obj_sql/trade.o: trade.c trade.h clif.h itemdb.h map.h pc.h npc.h log.h $(COMMON_SQL_H) -obj_sql/party.o: party.c party.h clif.h intif.h pc.h map.h battle.h $(COMMON_SQL_H) -obj_sql/vending.o: vending.c vending.h clif.h itemdb.h map.h pc.h log.h irc.h $(COMMON_SQL_H) -obj_sql/guild.o: guild.c guild.h storage.h battle.h clif.h intif.h pc.h npc.h map.h irc.h $(COMMON_SQL_H) -obj_sql/pet.o: pet.c pet.h map.h clif.h chrif.h intif.h pc.h itemdb.h battle.h mob.h npc.h script.h $(COMMON_SQL_H) -obj_sql/mail.o: mail.c mail.h $(COMMON_SQL_H) -obj_sql/log.o: log.c log.h map.h $(COMMON_SQL_H) -obj_sql/charcommand.o: charcommand.c charcommand.h itemdb.h pc.h map.h skill.h clif.h mob.h intif.h battle.h storage.h guild.h pet.h log.h $(COMMON_SQL_H) -obj_sql/date.o: date.c date.h $(COMMON_SQL_H) -obj_sql/irc.o: irc.c irc.h map.h pc.h $(COMMON_SQL_H) -obj_sql/unit.o: unit.c unit.h $(COMMON_SQL_H) -obj_sql/mercenary.o: mercenary.c mercenary.h $(COMMON_SQL_H) +# missing common object files +../common/obj/%.o: + @$(MAKE) -C ../common txt + +../common/obj_sql/%.o: + @$(MAKE) -C ../common sql diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in index 769771aca..00493a7c9 100644 --- a/src/plugins/Makefile.in +++ b/src/plugins/Makefile.in @@ -1,8 +1,13 @@ -@SET_MAKE@ + +COMMON_OBJ = ../common/obj/showmsg.o ../common/obj/utils.o ../common/obj/strlib.o \ + ../common/obj/minimalloc.o +COMMON_H = ../common/plugin.h ../common/cbasetypes.h \ + ../common/showmsg.h ../common/utils.h ../common/strlib.h \ + ../common/malloc.h PLUGINS = sample sig pid gui upnp console -COMMON_H = ../common/plugin.h ../common/cbasetypes.h +@SET_MAKE@ ##################################################################### .PHONY : all $(PLUGINS) clean help @@ -41,27 +46,18 @@ help: %@DLLEXT@: %.c @CC@ @CFLAGS@ @CPPFLAGS@ -shared -o ../../plugins/$@ $< -sig@DLLEXT@: sig.c - @$(MAKE) -C ../common txt - @CC@ @CFLAGS@ @CPPFLAGS@ -shared -o ../../plugins/$@ $< \ - ../common/obj/showmsg.o ../common/obj/utils.o ../common/obj/strlib.o \ - ../common/obj/minimalloc.o - gui@DLLEXT@: ../../plugins/gui.conf upnp@DLLEXT@: ../../plugins/upnp.conf +sig@DLLEXT@: sig.c $(COMMON_OBJ) + @CC@ @CFLAGS@ @CPPFLAGS@ -shared -o ../../plugins/$@ $< $(COMMON_OBJ) + ../../plugins/%.conf: %.txt cp -r $< $@ -../../plugins/gui.conf: gui.txt -../../plugins/upnp.conf: upnp.txt - -# DO NOT DELETE +# missing common object files +../common/obj/%.o: ../common/%.c $(COMMON_H) + @$(MAKE) -C ../common txt -sample@DLLEXT@: sample.c $(COMMON_H) -sig@DLLEXT@: sig.c $(COMMON_H) -pid@DLLEXT@: pid.c $(COMMON_H) -gui@DLLEXT@: gui.c $(COMMON_H) -#TODO where is upnp.c? [FlavioJS] -#upnp@DLLEXT@: upnp.c $(COMMON_H) -console@DLLEXT@: console.c $(COMMON_H) +../common/obj/mini%.o: ../common/%.c $(COMMON_H) + @$(MAKE) -C ../common txt diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 7c0d1e1ee..277ff4c68 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -1,3 +1,6 @@ + +@SET_MAKE@ + ##################################################################### .PHONY : all adduser convert mapcache clean help @@ -9,12 +12,12 @@ adduser: convert: @CC@ -o ../../tools/convert@EXEEXT@ convert.c -mapcache: - @CC@ -c -o grfio.o grfio.c - @CC@ -o ../../mapcache@EXEEXT@ mapcache.c grfio.o -lz +mapcache: obj + @CC@ -c -o obj/grfio.o grfio.c + @CC@ -o ../../mapcache@EXEEXT@ mapcache.c obj/grfio.o -lz clean: - rm -rf *.o ../../tools/adduser@EXEEXT@ ../../tools/convert@EXEEXT@ ../../mapcache@EXEEXT@ + rm -rf *.o obj ../../tools/adduser@EXEEXT@ ../../tools/convert@EXEEXT@ ../../mapcache@EXEEXT@ help: @echo "possible targets are 'adduser' 'convert' 'mapcache' 'all' 'clean' 'help'" @@ -26,3 +29,6 @@ help: @echo "'help' - outputs this message" ##################################################################### + +obj: + -mkdir obj diff --git a/src/txt-converter/Makefile.in b/src/txt-converter/Makefile.in index 31d593743..59d3a6641 100644 --- a/src/txt-converter/Makefile.in +++ b/src/txt-converter/Makefile.in @@ -1,25 +1,42 @@ -LOGIN_CONVERTER_OBJ = login-converter.o ../common/obj/minicore.o \ + +LOGIN_CONVERTER_OBJ = obj_login/login-converter.o ../common/obj/minicore.o \ ../common/obj/malloc.o ../common/obj/strlib.o ../common/obj/showmsg.o \ ../common/obj/utils.o ../common/obj/ers.o ../common/obj/db.o \ ../common/obj_sql/sql.o -CHAR_CONVERTER_OBJ = char-converter.o ../common/obj/minicore.o \ +LOGIN_CONVERTER_H = ../common/cbasetypes.h ../common/mmo.h ../common/core.h \ + ../common/malloc.h ../common/strlib.h ../common/showmsg.h \ + ../common/utils.h ../common/ers.h ../common/db.h \ + ../common/sql.h + +CHAR_CONVERTER_OBJ = obj_char/char-converter.o \ + obj_char/txt-char.o obj_char/txt-int_pet.o obj_char/txt-int_storage.o obj_char/txt-inter.o \ + obj_char/txt-int_party.o obj_char/txt-int_guild.o \ + obj_char/sql-char.o obj_char/sql-int_pet.o obj_char/sql-int_storage.o \ + obj_char/sql-inter.o obj_char/sql-int_party.o obj_char/sql-int_guild.o \ + ../common/obj/minicore.o \ ../common/obj/malloc.o ../common/obj/strlib.o ../common/obj/showmsg.o \ ../common/obj/utils.o ../common/obj/ers.o ../common/obj/mapindex.o \ - ../common/obj_sql/sql.o \ - obj_txt/char.o obj_txt/int_pet.o obj_txt/int_storage.o obj_txt/inter.o \ - obj_txt/int_party.o obj_txt/int_guild.o \ - obj_sql/char.o obj_sql/int_pet.o obj_sql/int_storage.o \ - obj_sql/inter.o obj_sql/int_party.o obj_sql/int_guild.o + ../common/obj_sql/sql.o +CHAR_CONVERTER_H = ../char/char.h ../char/int_pet.h ../char/int_storage.h ../char/inter.h \ + ../char/int_party.h ../char/int_guild.h \ + ../char_sql/char.h ../char_sql/int_pet.h ../char_sql/int_storage.h \ + ../char_sql/inter.h ../char_sql/int_party.h ../char_sql/int_guild.h \ + ../common/cbasetypes.h ../common/mmo.h ../common/core.h \ + ../common/malloc.h ../common/strlib.h ../common/showmsg.h \ + ../common/utils.h ../common/ers.h ../common/mapindex.h \ + ../common/sql.h HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - LOGIN_CONVERTER_DEPENDS=$(LOGIN_CONVERTER_OBJ) - CHAR_CONVERTER_DEPENDS=obj $(CHAR_CONVERTER_OBJ) + LOGIN_CONVERTER_DEPENDS=obj_login $(LOGIN_CONVERTER_OBJ) + CHAR_CONVERTER_DEPENDS=obj_char $(CHAR_CONVERTER_OBJ) else LOGIN_CONVERTER_DEPENDS=needs_mysql CHAR_CONVERTER_DEPENDS=needs_mysql endif +@SET_MAKE@ + ##################################################################### .PHONY : all login-converter char-converter clean help @@ -32,7 +49,7 @@ char-converter: $(CHAR_CONVERTER_DEPENDS) @CC@ @LDFLAGS@ -o ../../tools/char-converter@EXEEXT@ $(CHAR_CONVERTER_OBJ) @LIBS@ @MYSQL_LIBS@ clean: - rm -rf *.o obj_txt obj_sql ../../tools/login-converter@EXEEXT@ ../../tools/char-converter@EXEEXT@ + rm -rf *.o obj_login obj_char ../../tools/login-converter@EXEEXT@ ../../tools/char-converter@EXEEXT@ help: @echo "possible targets are 'login-converter' 'char-converter' 'all' 'clean' 'help'" @@ -48,21 +65,24 @@ needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 -obj: - -mkdir obj_txt - -mkdir obj_sql +obj_login: + -mkdir obj_login +obj_char: + -mkdir obj_char -# DO NOT DELETE +obj_login/%.o: %.c $(LOGIN_CONVERTER_H) + @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $< -%.o: %.c +obj_char/%.o: %.c $(CHAR_CONVERTER_H) @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $< -obj_txt/%.o: ../char/%.c +obj_char/txt-%.o: ../char/%.c $(CHAR_CONVERTER_H) @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $< -obj_sql/%.o: ../char_sql/%.c +obj_char/sql-%.o: ../char_sql/%.c $(CHAR_CONVERTER_H) @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $< -char-converter.o: char-converter.c -login-converter.o: login-converter.c +# missing common object files +../common/obj/%.o: + @$(MAKE) -C ../common sql -- cgit v1.2.3-70-g09d2 From d157481db8a77069628b6186b9a31ea6267854ee Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Fri, 30 Nov 2007 00:17:26 +0000 Subject: * Random cleanup/documentation. * Made common/Makefile get the svn version from the src directory, not src/common. * Added a warning message to the install and uninstall targets. * Renamed all obj directories to obj_all, obj_txt or obj_sql in the makefiles (if an obj/ directory exists, BSD make enters it before reading the makefile) (run ./configure to update your makefiles, and don't forget to do 'make clean' before updating) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11844 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 6 ++++ Makefile.in | 2 ++ src/char/Makefile.in | 26 +++++++-------- src/char_sql/Makefile.in | 26 +++++++-------- src/common/Makefile.in | 22 ++++++------ src/ladmin/Makefile.in | 22 ++++++------ src/login/Makefile.in | 24 ++++++------- src/login_sql/Makefile.in | 27 +++++++-------- src/map/Makefile.in | 32 +++++++++--------- src/map/clif.c | 78 +++++++++++++++++++++++++++++++------------ src/map/clif.h | 6 ++-- src/map/pc.c | 12 +++---- src/plugins/Makefile.in | 8 ++--- src/tool/Makefile.in | 12 +++---- src/txt-converter/Makefile.in | 17 ++++++---- 15 files changed, 184 insertions(+), 136 deletions(-) (limited to 'src/tool/Makefile.in') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 00c951714..a73ad7cb9 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,12 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2007/11/29 + * Random cleanup/documentation. + * Made common/Makefile get the svn version from the src directory, not src/common. + * Added a warning message to the install and uninstall targets. + * Renamed all obj directories to obj_all, obj_txt or obj_sql in the + makefiles (if an obj/ directory exists, BSD make enters it before + reading the makefile) [FlavioJS] * Allowed disguising while riding a peco-peco (this does not seem to cause problems anymore). * The pvp rank packet is no longer sent to other players when disguised, as diff --git a/Makefile.in b/Makefile.in index 2c1b0a95e..aa47001a1 100644 --- a/Makefile.in +++ b/Makefile.in @@ -139,6 +139,7 @@ needs_mysql: # 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/eathena/bin/) $(shell mkdir -p /opt/eathena/etc/eathena/) $(shell mkdir -p /opt/eathena/var/log/eathena/) @@ -162,6 +163,7 @@ bin-clean: $(shell rm /opt/eathena/bin/ladmin) 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/eathena/bin/save) $(shell rm /opt/eathena/bin/db) diff --git a/src/char/Makefile.in b/src/char/Makefile.in index 334265819..359e19b01 100644 --- a/src/char/Makefile.in +++ b/src/char/Makefile.in @@ -1,17 +1,17 @@ -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/strlib.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o +COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_all/timer.o \ + ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ + ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/utils.o \ + ../common/obj_all/strlib.o ../common/obj_all/grfio.o \ + ../common/obj_all/mapindex.o ../common/obj_all/ers.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ ../common/malloc.h ../common/showmsg.h ../common/utils.h \ ../common/strlib.h ../common/grfio.h \ ../common/mapindex.h ../common/ers.h -CHAR_OBJ = obj/char.o obj/inter.o obj/int_party.o obj/int_guild.o \ - obj/int_storage.o obj/int_status.o obj/int_pet.o obj/int_homun.o +CHAR_OBJ = obj_txt/char.o obj_txt/inter.o obj_txt/int_party.o obj_txt/int_guild.o \ + obj_txt/int_storage.o obj_txt/int_status.o obj_txt/int_pet.o obj_txt/int_homun.o CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_status.h int_pet.h int_homun.h @SET_MAKE@ @@ -21,11 +21,11 @@ CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_status.h int_p all: char-server -char-server: obj $(CHAR_OBJ) $(COMMON_OBJ) +char-server: obj_txt $(CHAR_OBJ) $(COMMON_OBJ) @CC@ @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) @LIBS@ clean: - rm -rf *.o obj ../../char-server@EXEEXT@ + rm -rf *.o obj_txt ../../char-server@EXEEXT@ help: @echo "possible targets are 'char-server' 'all' 'clean' 'help'" @@ -36,12 +36,12 @@ help: ##################################################################### -obj: - -mkdir obj +obj_txt: + -mkdir obj_txt -obj/%.o: %.c $(CHAR_H) $(COMMON_H) +obj_txt/%.o: %.c $(CHAR_H) $(COMMON_H) @CC@ @CFLAGS@ -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files -../common/obj/%.o: +../common/obj_all/%.o: @$(MAKE) -C ../common txt diff --git a/src/char_sql/Makefile.in b/src/char_sql/Makefile.in index 8162511d5..819ddec18 100644 --- a/src/char_sql/Makefile.in +++ b/src/char_sql/Makefile.in @@ -1,9 +1,9 @@ -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/strlib.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o +COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_all/timer.o \ + ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ + ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/utils.o \ + ../common/obj_all/strlib.o ../common/obj_all/grfio.o \ + ../common/obj_all/mapindex.o ../common/obj_all/ers.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ ../common/malloc.h ../common/showmsg.h ../common/utils.h \ @@ -13,13 +13,13 @@ COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h COMMON_SQL_OBJ = ../common/obj_sql/sql.o COMMON_H = ../common/sql.h -CHAR_OBJ = obj/char.o obj/inter.o obj/int_party.o obj/int_guild.o \ - obj/int_storage.o obj/int_pet.o obj/int_homun.o obj/int_mail.o +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 CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h int_mail.h HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - CHAR_SERVER_SQL_DEPENDS=obj $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) + CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) else CHAR_SERVER_SQL_DEPENDS=needs_mysql endif @@ -35,7 +35,7 @@ char-server_sql: $(CHAR_SERVER_SQL_DEPENDS) @CC@ @LDFLAGS@ -o ../../char-server_sql@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) @LIBS@ @MYSQL_LIBS@ clean: - rm -rf *.o obj ../../char-server_sql@EXEEXT@ + rm -rf *.o obj_sql ../../char-server_sql@EXEEXT@ help: @echo "possible targets are 'char-server_sql' 'all' 'clean' 'help'" @@ -50,14 +50,14 @@ needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 -obj: - -mkdir obj +obj_sql: + -mkdir obj_sql -obj/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) +obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files -../common/obj/%.o: +../common/obj_all/%.o: @$(MAKE) -C ../common sql ../common/obj_sql/%.o: diff --git a/src/common/Makefile.in b/src/common/Makefile.in index 89bb8a75a..bda9e1911 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -1,8 +1,8 @@ -COMMON_OBJ = obj/core.o obj/socket.o obj/timer.o obj/db.o obj/plugins.o obj/lock.o \ - obj/nullpo.o obj/malloc.o obj/showmsg.o obj/strlib.o obj/utils.o \ - obj/grfio.o obj/mapindex.o obj/ers.o obj/md5calc.o \ - obj/minicore.o obj/minisocket.o obj/minimalloc.o +COMMON_OBJ = obj_all/core.o obj_all/socket.o obj_all/timer.o obj_all/db.o obj_all/plugins.o obj_all/lock.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 COMMON_H = svnversion.h mmo.h plugin.h version.h \ core.h socket.h timer.h db.h plugins.h lock.h \ nullpo.h malloc.h showmsg.h strlib.h utils.h \ @@ -32,7 +32,7 @@ txt: common sql: $(SQL_DEPENDS) clean: - rm -rf *.o obj obj_sql svnversion.h + rm -rf *.o obj_all obj_sql svnversion.h help: @echo "possible targets are 'txt' 'sql' 'all' 'clean' 'help'" @@ -48,21 +48,21 @@ needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 -obj: - -mkdir obj +obj_all: + -mkdir obj_all obj_sql: -mkdir obj_sql -common: obj $(COMMON_OBJ) +common: obj_all $(COMMON_OBJ) common_sql: obj_sql $(COMMON_SQL_OBJ) -obj/%.o: %.c $(COMMON_H) +obj_all/%.o: %.c $(COMMON_H) @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< -obj/mini%.o: %.c $(COMMON_H) +obj_all/mini%.o: %.c $(COMMON_H) @CC@ @CFLAGS@ -DMINICORE @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) @@ -74,7 +74,7 @@ HAVESVN = $(shell which svnversion) ifeq ($(findstring /,$(HAVESVN)), /) svnversion.h: @printf "#define SVNVERSION " > svnversion.h - @svnversion . >> svnversion.h + @svnversion .. >> svnversion.h @printf "\n" >> svnversion.h else svnversion.h: diff --git a/src/ladmin/Makefile.in b/src/ladmin/Makefile.in index 87cc2ad49..4703dded1 100644 --- a/src/ladmin/Makefile.in +++ b/src/ladmin/Makefile.in @@ -1,12 +1,12 @@ -COMMON_OBJ = ../common/obj/minicore.o ../common/obj/minisocket.o ../common/obj/timer.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o \ - ../common/obj/utils.o ../common/obj/md5calc.o +COMMON_OBJ = ../common/obj_all/minicore.o ../common/obj_all/minisocket.o ../common/obj_all/timer.o \ + ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/strlib.o \ + ../common/obj_all/utils.o ../common/obj_all/md5calc.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ ../common/version.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h \ ../common/utils.h ../common/md5calc.h ../common/cbasetypes.h -LADMIN_OBJ = obj/ladmin.o +LADMIN_OBJ = obj_all/ladmin.o LADMIN_H = ladmin.h @SET_MAKE@ @@ -16,11 +16,11 @@ LADMIN_H = ladmin.h all: ladmin -ladmin: obj $(LADMIN_OBJ) $(COMMON_OBJ) +ladmin: obj_all $(LADMIN_OBJ) $(COMMON_OBJ) @CC@ @LDFLAGS@ -o ../../ladmin@EXEEXT@ $(LADMIN_OBJ) $(COMMON_OBJ) @LIBS@ clean: - rm -rf *.o obj ../../ladmin@EXEEXT@ + rm -rf *.o obj_all ../../ladmin@EXEEXT@ help: @echo "possible targets are 'ladmin' 'all' 'clean' 'help'" @@ -31,15 +31,15 @@ help: ##################################################################### -obj: - -mkdir obj +obj_all: + -mkdir obj_all -obj/%.o: %.c $(LADMIN_H) $(COMMON_H) +obj_all/%.o: %.c $(LADMIN_H) $(COMMON_H) @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files -../common/obj/%.o: +../common/obj_all/%.o: @$(MAKE) -C ../common txt -../common/obj/mini%.o: +../common/obj_all/mini%.o: @$(MAKE) -C ../common txt diff --git a/src/login/Makefile.in b/src/login/Makefile.in index 4bdfb5935..0c194fac4 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -1,16 +1,16 @@ -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/strlib.o ../common/obj/grfio.o ../common/obj/mapindex.o \ - ../common/obj/ers.o ../common/obj/md5calc.o +COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_all/timer.o \ + ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ + ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/utils.o \ + ../common/obj_all/strlib.o ../common/obj_all/grfio.o ../common/obj_all/mapindex.o \ + ../common/obj_all/ers.o ../common/obj_all/md5calc.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ ../common/grfio.h ../common/mapindex.h \ ../common/ers.h ../common/md5calc.h -LOGIN_OBJ = obj/login.o obj/admin.o +LOGIN_OBJ = obj_txt/login.o obj_txt/admin.o LOGIN_H = login.h @SET_MAKE@ @@ -20,11 +20,11 @@ LOGIN_H = login.h all: login-server -login-server: obj $(LOGIN_OBJ) $(COMMON_OBJ) +login-server: obj_txt $(LOGIN_OBJ) $(COMMON_OBJ) @CC@ @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_OBJ) $(COMMON_OBJ) @LIBS@ clean: - rm -rf *.o obj ../../login-server@EXEEXT@ + rm -rf *.o obj_txt ../../login-server@EXEEXT@ help: @echo "possible targets are 'login-server' 'all' 'clean' 'help'" @@ -35,12 +35,12 @@ help: ##################################################################### -obj: - -mkdir obj +obj_txt: + -mkdir obj_txt -obj/%.o: %.c $(LOGIN_H) $(COMMON_H) +obj_txt/%.o: %.c $(LOGIN_H) $(COMMON_H) @CC@ @CFLAGS@ -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files -../common/obj/%.o: +../common/obj_all/%.o: @$(MAKE) -C ../common sql diff --git a/src/login_sql/Makefile.in b/src/login_sql/Makefile.in index 22a1437b3..72d23b183 100644 --- a/src/login_sql/Makefile.in +++ b/src/login_sql/Makefile.in @@ -1,20 +1,21 @@ -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/utils.o \ - ../common/obj/strlib.o ../common/obj/grfio.o ../common/obj/mapindex.o \ - ../common/obj/ers.o ../common/obj/md5calc.o ../common/obj_sql/sql.o + +COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_all/timer.o \ + ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ + ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/utils.o \ + ../common/obj_all/strlib.o ../common/obj_all/grfio.o ../common/obj_all/mapindex.o \ + ../common/obj_all/ers.o ../common/obj_all/md5calc.o ../common/obj_sql/sql.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ ../common/grfio.h ../common/mapindex.h \ - ../common/ers.h ../common/md5calc.h ../common/sql.h + ../common/ers.h ../common/md5calc.h ../common/sql.h -LOGIN_OBJ = obj/login.o +LOGIN_OBJ = obj_sql/login.o LOGIN_H = login.h HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - LOGIN_SERVER_SQL_DEPENDS=obj $(LOGIN_OBJ) $(COMMON_OBJ) + LOGIN_SERVER_SQL_DEPENDS=obj_sql $(LOGIN_OBJ) $(COMMON_OBJ) else LOGIN_SERVER_SQL_DEPENDS=needs_mysql endif @@ -30,7 +31,7 @@ login-server_sql: $(LOGIN_SERVER_SQL_DEPENDS) @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_OBJ) $(COMMON_OBJ) @LIBS@ @MYSQL_LIBS@ clean: - rm -rf *.o obj ../../login-server_sql@EXEEXT@ + rm -rf *.o obj_sql ../../login-server_sql@EXEEXT@ help: @echo "possible targets are 'login-server_sql' 'all' 'clean' 'help'" @@ -45,14 +46,14 @@ needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 -obj: - -mkdir obj +obj_sql: + -mkdir obj_sql -obj/%.o: %.c $(LOGIN_H) $(COMMON_H) +obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files -../common/obj/%.o: +../common/obj_all/%.o: @$(MAKE) -C ../common sql ../common/obj_sql/%.o: diff --git a/src/map/Makefile.in b/src/map/Makefile.in index 31c0fc3f1..355086127 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -1,9 +1,9 @@ -COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o \ - ../common/obj/db.o ../common/obj/plugins.o ../common/obj/lock.o \ - ../common/obj/nullpo.o ../common/obj/malloc.o ../common/obj/showmsg.o \ - ../common/obj/utils.o ../common/obj/strlib.o ../common/obj/grfio.o \ - ../common/obj/mapindex.o ../common/obj/ers.o +COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_all/timer.o \ + ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ + ../common/obj_all/nullpo.o ../common/obj_all/malloc.o ../common/obj_all/showmsg.o \ + ../common/obj_all/utils.o ../common/obj_all/strlib.o ../common/obj_all/grfio.o \ + ../common/obj_all/mapindex.o ../common/obj_all/ers.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h \ ../common/db.h ../common/plugins.h ../common/lock.h \ ../common/nullpo.h ../common/malloc.h ../common/showmsg.h \ @@ -13,11 +13,13 @@ COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h \ COMMON_SQL_OBJ = ../common/obj_sql/sql.o COMMON_SQL_H = ../common/sql.h -MAP_OBJ = obj/map.o obj/chrif.o obj/clif.o obj/pc.o obj/status.o obj/npc.o \ - obj/npc_chat.o obj/chat.o obj/path.o obj/itemdb.o obj/mob.o obj/script.o \ - obj/storage.o obj/skill.o obj/atcommand.o obj/charcommand.o obj/battle.o \ - obj/intif.o obj/trade.o obj/party.o obj/vending.o obj/guild.o obj/pet.o \ - obj/log.o obj/mail.o obj/date.o obj/irc.o obj/unit.o obj/mercenary.o +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 charcommand.o battle.o \ + intif.o trade.o party.o vending.o guild.o pet.o \ + log.o mail.o date.o irc.o unit.o mercenary.o +MAP_TXT_OBJ = $(MAP_OBJ:%=obj_txt/%) +MAP_SQL_OBJ = $(MAP_OBJ:%=obj_sql/%) MAP_H = map.h chrif.h clif.h pc.h status.h npc.h \ chat.h itemdb.h mob.h script.h \ storage.h skill.h atcommand.h charcommand.h battle.h \ @@ -80,11 +82,11 @@ obj_sql: -mkdir obj_sql # executables -map-server: obj_txt $(MAP_OBJ:obj/%=obj_txt/%) $(COMMON_OBJ) - @CC@ @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_OBJ:obj/%=obj_txt/%) $(COMMON_OBJ) @LIBS@ @PCRE_LIBS@ +map-server: obj_txt $(MAP_TXT_OBJ) $(COMMON_OBJ) + @CC@ @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_TXT_OBJ) $(COMMON_OBJ) @LIBS@ @PCRE_LIBS@ -map-server_sql: obj_sql $(MAP_OBJ:obj/%=obj_sql/%) $(COMMON_OBJ) $(COMMON_SQL_OBJ) - @CC@ @LDFLAGS@ -o ../../map-server_sql@EXEEXT@ $(MAP_OBJ:obj/%=obj_sql/%) $(COMMON_OBJ) $(COMMON_SQL_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ +map-server_sql: obj_sql $(MAP_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) + @CC@ @LDFLAGS@ -o ../../map-server_sql@EXEEXT@ $(MAP_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ # map object files obj_txt/%.o: %.c $(MAP_H) $(COMMON_H) @@ -94,7 +96,7 @@ obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(COMMON_SQL_H) @CC@ @CFLAGS@ $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files -../common/obj/%.o: +../common/obj_all/%.o: @$(MAKE) -C ../common txt ../common/obj_sql/%.o: diff --git a/src/map/clif.c b/src/map/clif.c index 5f59bda74..2a45b1b79 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -4396,35 +4396,44 @@ void clif_skill_warppoint(struct map_session_data* sd, short skill_num, short sk else sd->menuskill_val = skill_lv; } -/*========================================== - * メモ応答 - *------------------------------------------*/ -int clif_skill_memo(struct map_session_data *sd,int flag) + +/// Memo message. +/// type=0 : "Saved location as a Memo Point for Warp skill." in color 0xFFFF00 (cyan) +/// type=1 : "Skill Level is not high enough." in color 0x0000FF (red) +/// type=2 : "You haven't learned Warp." in color 0x0000FF (red) +/// +/// @param sd Who receives the message +/// @param type What message +void clif_skill_memomessage(struct map_session_data* sd, int type) { int fd; - nullpo_retr(0, sd); + nullpo_retv(sd); fd=sd->fd; - WFIFOHEAD(fd,packet_len(0x11e)); WFIFOW(fd,0)=0x11e; - WFIFOB(fd,2)=flag; + WFIFOB(fd,2)=type; WFIFOSET(fd,packet_len(0x11e)); - return 0; } -int clif_skill_teleportmessage(struct map_session_data *sd,int flag) + +/// Teleport message. +/// type=0 : "Unable to Teleport in this area" in color 0xFFFF00 (cyan) +/// type=1 : "Saved point cannot be memorized." in color 0x0000FF (red) +/// +/// @param sd Who receives the message +/// @param type What message +void clif_skill_teleportmessage(struct map_session_data *sd, int type) { int fd; - nullpo_retr(0, sd); + nullpo_retv(sd); fd=sd->fd; WFIFOHEAD(fd,packet_len(0x189)); WFIFOW(fd,0)=0x189; - WFIFOW(fd,2)=flag; + WFIFOW(fd,2)=type; WFIFOSET(fd,packet_len(0x189)); - return 0; } /*========================================== @@ -4700,18 +4709,43 @@ int clif_resurrection(struct block_list *bl,int type) return 0; } -/*========================================== - * PVP実装?(仮) - *------------------------------------------*/ -int clif_set0199(int fd,int type) +/// Sets the map mode. +/// +/// mode=1 : pvp mode +/// mode=2 : unknown mode (pk?) +/// mode=3 : gvg mode +/// mode=4 : message "You are in a PK area. Please beware of sudden attacks." in color 0x9B9BFF (light red) +/// mode=5 : pvp mode +/// mode=other : ? +void clif_set0199(struct map_session_data* sd, int mode) { + int fd; + + nullpo_retv(sd); + + fd=sd->fd; WFIFOHEAD(fd,packet_len(0x199)); WFIFOW(fd,0)=0x199; - WFIFOW(fd,2)=type; + WFIFOW(fd,2)=mode; WFIFOSET(fd,packet_len(0x199)); +} - return 0; +#if 0 +/// Set the map mode? +/// Differs from the behaviour of clif_set0199 with unknown consequences. +void clif_set01D6(struct map_session_data* sd, int mode) +{ + int fd; + + nullpo_retv(sd); + + fd=sd->fd; + WFIFOHEAD(fd,packet_len(0x1D6)); + WFIFOW(fd,0)=0x1D6; + WFIFOW(fd,2)=mode; + WFIFOSET(fd,packet_len(0x1D6)); } +#endif /*========================================== * PVP実装?(仮) @@ -7762,15 +7796,15 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) sd->pvp_won = 0; sd->pvp_lost = 0; } - clif_set0199(fd,1); + clif_set0199(sd,1); } else // set flag, if it's a duel [LuzZza] if(sd->duel_group) - clif_set0199(fd,1); + clif_set0199(sd,1); if (map[sd->bl.m].flag.gvg_dungeon) { - clif_set0199(fd,1); //TODO: Figure out the real packet to send here. + clif_set0199(sd,1); //TODO: Figure out the real packet to send here. if (!sd->pvp_point) { sd->pvp_point = 5; //Need to die twice to be warped out. @@ -7780,7 +7814,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) } if(map_flag_gvg(sd->bl.m)) - clif_set0199(fd,3); + clif_set0199(sd,3); // info about nearby objects // must use foreachinarea (CIRCULAR_AREA interferes with foreachinrange) diff --git a/src/map/clif.h b/src/map/clif.h index a1246f97a..b68645da9 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -213,8 +213,8 @@ int clif_skill_nodamage(struct block_list *src,struct block_list *dst,int skill_ int clif_skill_poseffect(struct block_list *src,int skill_id,int val,int x,int y,int tick); int clif_skill_estimation(struct map_session_data *sd,struct block_list *dst); void clif_skill_warppoint(struct map_session_data* sd, short skill_num, short skill_lv, unsigned short map1, unsigned short map2, unsigned short map3, unsigned short map4); -int clif_skill_memo(struct map_session_data *sd,int flag); -int clif_skill_teleportmessage(struct map_session_data *sd,int flag); +void clif_skill_memomessage(struct map_session_data* sd, int type); +void clif_skill_teleportmessage(struct map_session_data* sd, int type); int clif_skill_produce_mix_list(struct map_session_data *sd, int trigger); int clif_produceeffect(struct map_session_data* sd,int flag,int nameid); @@ -331,7 +331,7 @@ void clif_MainChatMessage(const char* message); //luzza int clif_announce(struct block_list *bl, const char* mes, int len, unsigned long color, int flag); int clif_heal(int fd,int type,int val); int clif_resurrection(struct block_list *bl,int type); -int clif_set0199(int fd,int type); +void clif_set0199(struct map_session_data* sd, int mode); int clif_pvpset(struct map_session_data *sd, int pvprank, int pvpnum,int type); int clif_send0199(int map,int type); void clif_refine(int fd, int fail, int index, int val); diff --git a/src/map/pc.c b/src/map/pc.c index fc39ea88d..852d06e5e 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -3603,11 +3603,11 @@ int pc_memo(struct map_session_data* sd, int pos) // check required skill level skill = pc_checkskill(sd, AL_WARP); if( skill < 1 ) { - clif_skill_memo(sd,2); // "You haven't learned Warp." + clif_skill_memomessage(sd,2); // "You haven't learned Warp." return 0; } if( skill < 2 || skill - 2 < pos ) { - clif_skill_memo(sd,1); // "Skill Level is not high enough." + clif_skill_memomessage(sd,1); // "Skill Level is not high enough." return 0; } @@ -3624,7 +3624,7 @@ int pc_memo(struct map_session_data* sd, int pos) sd->status.memo_point[pos].x = sd->bl.x; sd->status.memo_point[pos].y = sd->bl.y; - clif_skill_memo(sd, 0); + clif_skill_memomessage(sd, 0); return 1; } @@ -7173,7 +7173,7 @@ int duel_create(struct map_session_data* sd, const unsigned int maxpl) strcpy(output, msg_txt(372)); // " -- Duel has been created (@invite/@leave) --" clif_disp_onlyself(sd, output, strlen(output)); - clif_set0199(sd->fd, 1); + clif_set0199(sd, 1); //clif_misceffect2(&sd->bl, 159); return i; } @@ -7220,7 +7220,7 @@ int duel_leave(const unsigned int did, struct map_session_data* sd) sd->duel_group = 0; duel_savetime(sd); - clif_set0199(sd->fd, 0); + clif_set0199(sd, 0); return 0; } @@ -7237,7 +7237,7 @@ int duel_accept(const unsigned int did, struct map_session_data* sd) sprintf(output, msg_txt(376), sd->status.name); clif_disp_message(&sd->bl, output, strlen(output), DUEL_WOS); - clif_set0199(sd->fd, 1); + clif_set0199(sd, 1); //clif_misceffect2(&sd->bl, 159); return 0; } diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in index 00493a7c9..7019fadd8 100644 --- a/src/plugins/Makefile.in +++ b/src/plugins/Makefile.in @@ -1,6 +1,6 @@ -COMMON_OBJ = ../common/obj/showmsg.o ../common/obj/utils.o ../common/obj/strlib.o \ - ../common/obj/minimalloc.o +COMMON_OBJ = ../common/obj_all/showmsg.o ../common/obj_all/utils.o ../common/obj_all/strlib.o \ + ../common/obj_all/minimalloc.o COMMON_H = ../common/plugin.h ../common/cbasetypes.h \ ../common/showmsg.h ../common/utils.h ../common/strlib.h \ ../common/malloc.h @@ -56,8 +56,8 @@ sig@DLLEXT@: sig.c $(COMMON_OBJ) cp -r $< $@ # missing common object files -../common/obj/%.o: ../common/%.c $(COMMON_H) +../common/obj_all/%.o: ../common/%.c $(COMMON_H) @$(MAKE) -C ../common txt -../common/obj/mini%.o: ../common/%.c $(COMMON_H) +../common/obj_all/mini%.o: ../common/%.c $(COMMON_H) @$(MAKE) -C ../common txt diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 277ff4c68..f1d688a7d 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -12,12 +12,12 @@ adduser: convert: @CC@ -o ../../tools/convert@EXEEXT@ convert.c -mapcache: obj - @CC@ -c -o obj/grfio.o grfio.c - @CC@ -o ../../mapcache@EXEEXT@ mapcache.c obj/grfio.o -lz +mapcache: obj_mapcache + @CC@ -c -o obj_mapcache/grfio.o grfio.c + @CC@ -o ../../mapcache@EXEEXT@ mapcache.c obj_mapcache/grfio.o -lz clean: - rm -rf *.o obj ../../tools/adduser@EXEEXT@ ../../tools/convert@EXEEXT@ ../../mapcache@EXEEXT@ + rm -rf *.o obj_mapcache ../../tools/adduser@EXEEXT@ ../../tools/convert@EXEEXT@ ../../mapcache@EXEEXT@ help: @echo "possible targets are 'adduser' 'convert' 'mapcache' 'all' 'clean' 'help'" @@ -30,5 +30,5 @@ help: ##################################################################### -obj: - -mkdir obj +obj_mapcache: + -mkdir obj_mapcache diff --git a/src/txt-converter/Makefile.in b/src/txt-converter/Makefile.in index 59d3a6641..c90a6a4b2 100644 --- a/src/txt-converter/Makefile.in +++ b/src/txt-converter/Makefile.in @@ -1,7 +1,7 @@ -LOGIN_CONVERTER_OBJ = obj_login/login-converter.o ../common/obj/minicore.o \ - ../common/obj/malloc.o ../common/obj/strlib.o ../common/obj/showmsg.o \ - ../common/obj/utils.o ../common/obj/ers.o ../common/obj/db.o \ +LOGIN_CONVERTER_OBJ = obj_login/login-converter.o ../common/obj_all/minicore.o \ + ../common/obj_all/malloc.o ../common/obj_all/strlib.o ../common/obj_all/showmsg.o \ + ../common/obj_all/utils.o ../common/obj_all/ers.o ../common/obj_all/db.o \ ../common/obj_sql/sql.o LOGIN_CONVERTER_H = ../common/cbasetypes.h ../common/mmo.h ../common/core.h \ ../common/malloc.h ../common/strlib.h ../common/showmsg.h \ @@ -13,9 +13,9 @@ CHAR_CONVERTER_OBJ = obj_char/char-converter.o \ obj_char/txt-int_party.o obj_char/txt-int_guild.o \ obj_char/sql-char.o obj_char/sql-int_pet.o obj_char/sql-int_storage.o \ obj_char/sql-inter.o obj_char/sql-int_party.o obj_char/sql-int_guild.o \ - ../common/obj/minicore.o \ - ../common/obj/malloc.o ../common/obj/strlib.o ../common/obj/showmsg.o \ - ../common/obj/utils.o ../common/obj/ers.o ../common/obj/mapindex.o \ + ../common/obj_all/minicore.o \ + ../common/obj_all/malloc.o ../common/obj_all/strlib.o ../common/obj_all/showmsg.o \ + ../common/obj_all/utils.o ../common/obj_all/ers.o ../common/obj_all/mapindex.o \ ../common/obj_sql/sql.o CHAR_CONVERTER_H = ../char/char.h ../char/int_pet.h ../char/int_storage.h ../char/inter.h \ ../char/int_party.h ../char/int_guild.h \ @@ -84,5 +84,8 @@ obj_char/sql-%.o: ../char_sql/%.c $(CHAR_CONVERTER_H) @CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $< # missing common object files -../common/obj/%.o: +../common/obj_all/%.o: + @$(MAKE) -C ../common sql + +../common/obj_sql/%.o: @$(MAKE) -C ../common sql -- cgit v1.2.3-70-g09d2 From 49e9510c432987393d10ec1b8b1c2d416c9feb42 Mon Sep 17 00:00:00 2001 From: ultramage Date: Wed, 26 Mar 2008 10:37:45 +0000 Subject: Adjusted eAthena code to compile cleanly in C++ mode. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12436 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 4 +- src/char/char.c | 38 ++--- src/char/int_guild.c | 44 +++--- src/char/int_homun.c | 17 +- src/char/int_party.c | 21 +-- src/char/int_pet.c | 6 +- src/char/int_status.c | 15 +- src/char/int_storage.c | 8 +- src/char/inter.c | 48 +++--- src/char_sql/char.c | 40 ++--- src/char_sql/int_auction.c | 4 +- src/char_sql/int_guild.c | 6 +- src/char_sql/int_homun.c | 2 +- src/char_sql/int_mail.c | 4 +- src/char_sql/int_party.c | 4 +- src/char_sql/inter.c | 29 ++-- src/common/db.c | 35 +++-- src/common/mmo.h | 6 +- src/common/plugin.h | 3 + src/common/plugins.c | 49 +++--- src/common/plugins.h | 7 +- src/common/strlib.c | 2 +- src/common/strlib.h | 6 +- src/common/timer.h | 2 +- src/login/login.c | 14 +- src/login_sql/login.c | 20 +-- src/map/atcommand.c | 9 +- src/map/battle.c | 27 ++-- src/map/battle.h | 7 +- src/map/chrif.c | 7 +- src/map/clif.c | 104 +++++++------ src/map/clif.h | 12 +- src/map/guild.c | 28 ++-- src/map/intif.c | 8 +- src/map/itemdb.c | 10 +- src/map/log.c | 4 +- src/map/log.h | 4 +- src/map/map.c | 18 +-- src/map/map.h | 5 +- src/map/mercenary.c | 2 +- src/map/mercenary.h | 11 +- src/map/mob.c | 16 +- src/map/npc.c | 16 +- src/map/party.c | 8 +- src/map/pc.c | 26 ++-- src/map/pc.h | 52 ++++--- src/map/pet.h | 79 +++++----- src/map/script.c | 102 ++++++------ src/map/script.h | 4 +- src/map/skill.c | 135 ++++++++-------- src/map/status.c | 74 ++++----- src/map/status.h | 10 +- src/map/storage.c | 8 +- src/tool/Makefile.in | 12 +- src/tool/adduser.c | 9 +- src/tool/convert.c | 300 ------------------------------------ src/txt-converter/login-converter.c | 9 +- vcproj-9/char-server_sql.vcproj | 9 +- vcproj-9/char-server_txt.vcproj | 9 +- vcproj-9/ladmin.vcproj | 7 +- vcproj-9/login-server_sql.vcproj | 9 +- vcproj-9/login-server_txt.vcproj | 10 +- vcproj-9/map-server_sql.vcproj | 11 +- vcproj-9/map-server_txt.vcproj | 11 +- vcproj-9/mapcache.vcproj | 7 +- vcproj-9/txt-converter-char.vcproj | 7 +- vcproj-9/txt-converter-login.vcproj | 7 +- 67 files changed, 682 insertions(+), 955 deletions(-) delete mode 100644 src/tool/convert.c (limited to 'src/tool/Makefile.in') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 3405a3651..c17590a29 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,8 +3,10 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2008/03/26 + * Adjusted eAthena code to compile cleanly in C++ mode. 2008/03/24 - * Reorganized the contents of the mapserver's header files. + * Reorganized the contents of the mapserver's header files. [ultramage] - map.h is no longer a generic dumping spot of all the shared structs, and instead, each such structure now resides in its logical component - map.h now only holds mostly map-related things (needs more cleaning) diff --git a/src/char/char.c b/src/char/char.c index 76dad5203..566cd1e21 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -287,7 +287,7 @@ int search_character_online(int aid, int cid) { //Look for online character. struct online_char_data* character; - character = idb_get(online_char_db, aid); + character = (struct online_char_data*)idb_get(online_char_db, aid); if(character && character->char_id == cid && character->server > -1) @@ -297,7 +297,7 @@ int search_character_online(int aid, int cid) static void * create_online_char_data(DBKey key, va_list args) { struct online_char_data* character; - character = aCalloc(1, sizeof(struct online_char_data)); + character = (struct online_char_data*)aCalloc(1, sizeof(struct online_char_data)); character->account_id = key.i; character->char_id = -1; character->server = -1; @@ -327,7 +327,7 @@ void set_char_online(int map_id, int char_id, int account_id) } } - character = idb_ensure(online_char_db, account_id, create_online_char_data); + character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data); if (online_check && character->char_id != -1 && character->server > -1 && character->server != map_id) { //char == 99 <- Character logging in, so someone has logged in while one @@ -362,7 +362,7 @@ void set_char_offline(int char_id, int account_id) { struct online_char_data* character; - if ((character = idb_get(online_char_db, account_id)) != NULL) + if ((character = (struct online_char_data*)idb_get(online_char_db, account_id)) != NULL) { //We don't free yet to avoid aCalloc/aFree spamming during char change. [Skotlex] if( character->server > -1 ) server[character->server].users--; @@ -1911,7 +1911,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd) return; } - if( online_check && (character = idb_get(online_char_db, sd->account_id)) != NULL ) + if( online_check && (character = (struct online_char_data*)idb_get(online_char_db, sd->account_id)) != NULL ) { // check if character is not online already. [Skotlex] if (character->server > -1) { //Character already online. KICK KICK KICK @@ -2301,7 +2301,7 @@ int parse_fromlogin(int fd) if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2)) return 0; { - unsigned char buf[32000]; + unsigned char buf[32000]; //FIXME: this will crash if (gm_account != NULL) aFree(gm_account); CREATE(gm_account, struct gm_account, (RFIFOW(fd,2) - 4)/5); @@ -2330,7 +2330,7 @@ int parse_fromlogin(int fd) { struct online_char_data* character; int aid = RFIFOL(fd,2); - if ((character = idb_get(online_char_db, aid)) != NULL) + if ((character = (struct online_char_data*)idb_get(online_char_db, aid)) != NULL) { //Kick out this player. if (character->server > -1) { //Kick it from the map server it is on. @@ -2434,10 +2434,10 @@ int char_parse_Registry(int account_id, int char_id, unsigned char *buf, int buf if(i >= char_num) //Character not found? return 1; for(j=0,p=0;jserver > -1 && character->server != id) { ShowNotice("Set map user: Character (%d:%d) marked on map server %d, but map server %d claims to have (%d:%d) online!\n", @@ -2863,7 +2863,7 @@ int parse_frommap(int fd) memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus)); WFIFOSET(map_fd, WFIFOW(map_fd,2)); - data = idb_ensure(online_char_db, RFIFOL(fd,2), create_online_char_data); + data = (struct online_char_data*)idb_ensure(online_char_db, RFIFOL(fd,2), create_online_char_data); data->char_id = char_data->char_id; data->server = map_id; //Update server where char is. @@ -3134,7 +3134,7 @@ int parse_frommap(int fd) if (data->count != count) { data->count = count; - data->data = aRealloc(data->data, count*sizeof(struct status_change_data)); + data->data = (struct status_change_data*)aRealloc(data->data, count*sizeof(struct status_change_data)); } for (i = 0; i < count; i++) memcpy (&data->data[i], RFIFOP(fd, 14+i*sizeof(struct status_change_data)), sizeof(struct status_change_data)); @@ -3237,7 +3237,7 @@ int parse_char(int fd) { if (sd != NULL) { - struct online_char_data* data = idb_get(online_char_db, sd->account_id); + struct online_char_data* data = (struct online_char_data*)idb_get(online_char_db, sd->account_id); if (!data || data->server == -1) //If it is not in any server, send it offline. [Skotlex] set_char_offline(99,sd->account_id); if (data && data->fd == fd) @@ -3631,8 +3631,8 @@ int parse_char(int fd) if (RFIFOREST(fd) < 60) return 0; { - char* l_user = RFIFOP(fd,2); - char* l_pass = RFIFOP(fd,26); + char* l_user = (char*)RFIFOP(fd,2); + char* l_pass = (char*)RFIFOP(fd,26); l_user[23] = '\0'; l_pass[23] = '\0'; ARR_FIND( 0, MAX_MAP_SERVERS, i, server[i].fd <= 0 ); @@ -3899,7 +3899,7 @@ int ping_login_server(int tid, unsigned int tick, int id, int data) static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, int data) { struct online_char_data* character; - if ((character = idb_get(online_char_db, id)) != NULL && character->waiting_disconnect == tid) + if ((character = (struct online_char_data*)idb_get(online_char_db, id)) != NULL && character->waiting_disconnect == tid) { //Mark it offline due to timeout. character->waiting_disconnect = -1; set_char_offline(character->char_id, character->account_id); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index ac15b9a0a..e8379c130 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -485,7 +485,7 @@ void inter_guild_final() struct guild *inter_guild_search(int guild_id) { - return idb_get(guild_db, guild_id); + return (struct guild*)idb_get(guild_db, guild_id); } // ギルドデータのセーブ @@ -504,7 +504,7 @@ int inter_guild_save() } iter = guild_db->iterator(guild_db); - for( g = iter->first(iter,NULL); iter->exists(iter); g = iter->next(iter,NULL) ) + for( g = (struct guild*)iter->first(iter,NULL); iter->exists(iter); g = (struct guild*)iter->next(iter,NULL) ) { char line[16384]; inter_guild_tostr(line, g); @@ -522,7 +522,7 @@ int inter_guild_save() } iter = castle_db->iterator(castle_db); - for( gc = iter->first(iter,NULL); iter->exists(iter); gc = iter->next(iter,NULL) ) + for( gc = (struct guild_castle*)iter->first(iter,NULL); iter->exists(iter); gc = (struct guild_castle*)iter->next(iter,NULL) ) { char line[16384]; inter_guildcastle_tostr(line, gc); @@ -542,7 +542,7 @@ struct guild* search_guildname(char *str) struct guild* g; iter = guild_db->iterator(guild_db); - for( g = iter->first(iter,NULL); iter->exists(iter); g = iter->next(iter,NULL) ) + for( g = (struct guild*)iter->first(iter,NULL); iter->exists(iter); g = (struct guild*)iter->next(iter,NULL) ) { if (strcmpi(g->name, str) == 0) break; @@ -933,7 +933,7 @@ int mapif_guild_castle_alldataload(int fd) WFIFOHEAD(fd, 4 + MAX_GUILDCASTLE*sizeof(struct guild_castle)); WFIFOW(fd,0) = 0x3842; iter = castle_db->iterator(castle_db); - for( gc = iter->first(iter,NULL); iter->exists(iter); gc = iter->next(iter,NULL) ) + for( gc = (struct guild_castle*)iter->first(iter,NULL); iter->exists(iter); gc = (struct guild_castle*)iter->next(iter,NULL) ) { memcpy(WFIFOP(fd,len), gc, sizeof(struct guild_castle)); len += sizeof(struct guild_castle); @@ -1025,7 +1025,7 @@ int mapif_parse_GuildInfo(int fd, int guild_id) { struct guild *g; - g = idb_get(guild_db, guild_id); + g = (struct guild*)idb_get(guild_db, guild_id); if (g != NULL){ guild_calcinfo(g); mapif_guild_info(fd, g); @@ -1041,7 +1041,7 @@ int mapif_parse_GuildAddMember(int fd, int guild_id, struct guild_member *m) struct guild *g; int i; - g = idb_get(guild_db, guild_id); + g = (struct guild*)idb_get(guild_db, guild_id); if (g == NULL) { mapif_guild_memberadded(fd, guild_id, m->account_id, m->char_id, 1); return 0; @@ -1066,7 +1066,7 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in { int i, j; - struct guild* g = idb_get(guild_db, guild_id); + struct guild* g = (struct guild*)idb_get(guild_db, guild_id); if( g == NULL ) { //TODO @@ -1112,7 +1112,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, struct guild *g; int i, sum, c; - g = idb_get(guild_db, guild_id); + g = (struct guild*)idb_get(guild_db, guild_id); if (g == NULL) return 0; @@ -1168,7 +1168,7 @@ int mapif_parse_BreakGuild(int fd, int guild_id) { struct guild *g; - g = idb_get(guild_db, guild_id); + g = (struct guild*)idb_get(guild_db, guild_id); if(g == NULL) return 0; @@ -1195,7 +1195,7 @@ int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const char struct guild *g; short dw = *((short *)data); - g = idb_get(guild_db, guild_id); + g = (struct guild*)idb_get(guild_db, guild_id); if (g == NULL) return 0; @@ -1223,7 +1223,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int int i; struct guild *g; - g = idb_get(guild_db, guild_id); + g = (struct guild*)idb_get(guild_db, guild_id); if(g == NULL) return 0; @@ -1304,7 +1304,7 @@ int inter_guild_sex_changed(int guild_id,int account_id,int char_id, int gender) // ギルド役職名変更要求 int mapif_parse_GuildPosition(int fd, int guild_id, int idx, struct guild_position *p) { - struct guild *g = idb_get(guild_db, guild_id); + struct guild *g = (struct guild*)idb_get(guild_db, guild_id); if (g == NULL || idx < 0 || idx >= MAX_GUILDPOSITION) { return 0; @@ -1319,7 +1319,7 @@ int mapif_parse_GuildPosition(int fd, int guild_id, int idx, struct guild_positi // ギルドスキルアップ要求 int mapif_parse_GuildSkillUp(int fd, int guild_id, int skill_num, int account_id) { - struct guild *g = idb_get(guild_db, guild_id); + struct guild *g = (struct guild*)idb_get(guild_db, guild_id); int idx = skill_num - GD_SKILLBASE; if (g == NULL || idx < 0 || idx >= MAX_GUILDSKILL) @@ -1361,8 +1361,8 @@ int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_ struct guild *g[2]; int j, i; - g[0] = idb_get(guild_db, guild_id1); - g[1] = idb_get(guild_db, guild_id2); + g[0] = (struct guild*)idb_get(guild_db, guild_id1); + g[1] = (struct guild*)idb_get(guild_db, guild_id2); if(g[0] && g[1]==NULL && (flag&0x8)) //Requested to remove an alliance with a not found guild. return mapif_parse_GuildDeleteAlliance(g[0], guild_id2, @@ -1400,7 +1400,7 @@ int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char * { struct guild *g; - g = idb_get(guild_db, guild_id); + g = (struct guild*)idb_get(guild_db, guild_id); if (g == NULL) return 0; memcpy(g->mes1, mes1, 60); @@ -1414,7 +1414,7 @@ int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char { struct guild *g; - g = idb_get(guild_db, guild_id); + g = (struct guild*)idb_get(guild_db, guild_id); if (g == NULL) return 0; memcpy(g->emblem_data, data, len); @@ -1426,7 +1426,7 @@ int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char int mapif_parse_GuildCastleDataLoad(int fd, int castle_id, int index) { - struct guild_castle *gc = idb_get(castle_db, castle_id); + struct guild_castle *gc = (struct guild_castle*)idb_get(castle_db, castle_id); if (gc == NULL) { return mapif_guild_castle_dataload(castle_id, 0, 0); @@ -1460,7 +1460,7 @@ int mapif_parse_GuildCastleDataLoad(int fd, int castle_id, int index) int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value) { - struct guild_castle *gc= idb_get(castle_db, castle_id); + struct guild_castle *gc = (struct guild_castle*)idb_get(castle_db, castle_id); if (gc == NULL) return mapif_guild_castle_datasave(castle_id, index, value); @@ -1469,7 +1469,7 @@ int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value) case 1: if (gc->guild_id != value) { int gid = (value) ? value : gc->guild_id; - struct guild *g = idb_get(guild_db, gid); + struct guild *g = (struct guild*)idb_get(guild_db, gid); if(log_inter) inter_log("guild %s (id=%d) %s castle id=%d\n", (g) ? g->name : "??", gid, (value) ? "occupy" : "abandon", castle_id); @@ -1507,7 +1507,7 @@ int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value) int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int len) { - struct guild *g = idb_get(guild_db, guild_id); + struct guild *g = (struct guild*)idb_get(guild_db, guild_id); struct guild_member gm; int pos; diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 49434cd90..d547b60f7 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -175,7 +175,7 @@ int inter_homun_save() int inter_homun_delete(int hom_id) { struct s_homunculus *p; - p = idb_get(homun_db,hom_id); + p = (struct s_homunculus*)idb_get(homun_db,hom_id); if( p == NULL) return 0; idb_remove(homun_db,hom_id); @@ -255,7 +255,6 @@ int mapif_rename_homun_ack(int fd, int account_id, int char_id, int flag, char * int mapif_create_homun(int fd) { struct s_homunculus *p; - RFIFOHEAD(fd); p= (struct s_homunculus *) aCalloc(sizeof(struct s_homunculus), 1); if(p==NULL){ ShowFatalError("int_homun: out of memory !\n"); @@ -274,10 +273,9 @@ int mapif_load_homun(int fd) { struct s_homunculus *p; int account_id; - RFIFOHEAD(fd); account_id = RFIFOL(fd,2); - p= idb_get(homun_db,RFIFOL(fd,6)); + p = (struct s_homunculus*)idb_get(homun_db,RFIFOL(fd,6)); if(p==NULL) { mapif_homun_noinfo(fd,account_id); return 0; @@ -300,7 +298,7 @@ int mapif_save_homun(int fd,int account_id,struct s_homunculus *data) if (data->hom_id == 0) data->hom_id = homun_newid++; hom_id = data->hom_id; - p= idb_ensure(homun_db,hom_id,create_homun); + p = (struct s_homunculus*)idb_ensure(homun_db,hom_id,create_homun); memcpy(p,data,sizeof(struct s_homunculus)); mapif_save_homun_ack(fd,account_id,1); return 0; @@ -336,27 +334,24 @@ int mapif_rename_homun(int fd, int account_id, int char_id, char *name){ int mapif_parse_SaveHomun(int fd) { - RFIFOHEAD(fd); mapif_save_homun(fd,RFIFOL(fd,4),(struct s_homunculus *)RFIFOP(fd,8)); return 0; } int mapif_parse_DeleteHomun(int fd) { - RFIFOHEAD(fd); mapif_delete_homun(fd,RFIFOL(fd,2)); return 0; } -int mapif_parse_RenameHomun(int fd){ - RFIFOHEAD(fd); - mapif_rename_homun(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOP(fd, 10)); +int mapif_parse_RenameHomun(int fd) +{ + mapif_rename_homun(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), (char*)RFIFOP(fd, 10)); return 0; } int inter_homun_parse_frommap(int fd) { - RFIFOHEAD(fd); switch(RFIFOW(fd,0)){ case 0x3090: mapif_create_homun(fd); break; case 0x3091: mapif_load_homun(fd); break; diff --git a/src/char/int_party.c b/src/char/int_party.c index 64facec47..f0668a820 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -505,10 +505,11 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part } // パ?ティ情報要求 -int mapif_parse_PartyInfo(int fd, int party_id) { +int mapif_parse_PartyInfo(int fd, int party_id) +{ struct party_data *p; - p = idb_get(party_db, party_id); + p = (struct party_data*)idb_get(party_db, party_id); if (p != NULL) mapif_party_info(fd, &p->party); else { @@ -525,7 +526,7 @@ int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member struct party_data *p; int i; - p = idb_get(party_db, party_id); + p = (struct party_data*)idb_get(party_db, party_id); if( p == NULL || p->size == MAX_PARTY ) { mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1); return 0; @@ -557,11 +558,12 @@ int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member } // パ?ティ?設定?更要求 -int mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, int exp, int item) { +int mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, int exp, int item) +{ struct party_data *p; int flag = 0; - p = idb_get(party_db, party_id); + p = (struct party_data*)idb_get(party_db, party_id); if (p == NULL) return 0; @@ -576,11 +578,12 @@ int mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, int exp, } // パ?ティ?退要求 -int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id) { +int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id) +{ struct party_data *p; int i,lv; - p = idb_get(party_db, party_id); + p = (struct party_data*)idb_get(party_db, party_id); if (!p) return 0; for(i = 0; i < MAX_PARTY; i++) { @@ -610,7 +613,7 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id struct party_data *p; int i; - p = idb_get(party_db, party_id); + p = (struct party_data*)idb_get(party_db, party_id); if (p == NULL) return 0; @@ -682,7 +685,7 @@ int mapif_parse_PartyLeaderChange(int fd,int party_id,int account_id,int char_id struct party_data *p; int i; - p = idb_get(party_db, party_id); + p = (struct party_data*)idb_get(party_db, party_id); if (p == NULL) return 0; diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 59c705620..41d61fbc3 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -145,7 +145,7 @@ int inter_pet_save() int inter_pet_delete(int pet_id) { struct s_pet *p; - p = idb_get(pet_db,pet_id); + p = (struct s_pet*)idb_get(pet_db,pet_id); if( p == NULL) return 1; else { @@ -267,7 +267,7 @@ int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet int mapif_load_pet(int fd,int account_id,int char_id,int pet_id) { struct s_pet *p; - p= idb_get(pet_db,pet_id); + p = (struct s_pet*)idb_get(pet_db,pet_id); if(p!=NULL) { if(p->incuvate == 1) { p->account_id = p->char_id = 0; @@ -304,7 +304,7 @@ int mapif_save_pet(int fd,int account_id,struct s_pet *data) pet_id = data->pet_id; if (pet_id == 0) pet_id = data->pet_id = pet_newid++; - p= idb_ensure(pet_db,pet_id,create_pet); + p = (struct s_pet*)idb_ensure(pet_db,pet_id,create_pet); if(data->hungry < 0) data->hungry = 0; else if(data->hungry > 100) diff --git a/src/char/int_status.c b/src/char/int_status.c index 29886d45c..bf5d94155 100644 --- a/src/char/int_status.c +++ b/src/char/int_status.c @@ -15,9 +15,10 @@ static DBMap* scdata_db = NULL; // int char_id -> struct scdata* char scdata_txt[1024]="save/scdata.txt"; //By [Skotlex] #ifdef ENABLE_SC_SAVING -static void* create_scdata(DBKey key, va_list args) { +static void* create_scdata(DBKey key, va_list args) +{ struct scdata *data; - data = aCalloc(1, sizeof(struct scdata)); + data = (struct scdata*)aCalloc(1, sizeof(struct scdata)); data->account_id = va_arg(args, int); data->char_id = key.i; return data; @@ -28,9 +29,7 @@ static void* create_scdata(DBKey key, va_list args) { *------------------------------------------*/ struct scdata* status_search_scdata(int aid, int cid) { - struct scdata *data; - data = scdata_db->ensure(scdata_db, i2key(cid), create_scdata, aid); - return data; + return (struct scdata*)scdata_db->ensure(scdata_db, i2key(cid), create_scdata, aid); } /*========================================== @@ -39,7 +38,7 @@ struct scdata* status_search_scdata(int aid, int cid) *------------------------------------------*/ void status_delete_scdata(int aid, int cid) { - struct scdata *scdata = idb_remove(scdata_db, cid); + struct scdata* scdata = (struct scdata*)idb_remove(scdata_db, cid); if (scdata) { if (scdata->data) @@ -71,7 +70,7 @@ static int inter_scdata_fromstr(char *line, struct scdata *sc_data) if (sc_data->count < 1) return 0; - sc_data->data = aCalloc(sc_data->count, sizeof (struct status_change_data)); + sc_data->data = (struct status_change_data*)aCalloc(sc_data->count, sizeof (struct status_change_data)); for (i = 0; i < sc_data->count; i++) { @@ -106,7 +105,7 @@ void status_load_scdata(const char* filename) if (inter_scdata_fromstr(line, sc)) { sd_count++; sc_count+= sc->count; - sc = idb_put(scdata_db, sc->char_id, sc); + sc = (struct scdata*)idb_put(scdata_db, sc->char_id, sc); if (sc) { ShowError("Duplicate entry in %s for character %d\n", filename, sc->char_id); if (sc->data) aFree(sc->data); diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 4aefd231b..5ae51b833 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -169,7 +169,7 @@ static void* create_storage(DBKey key, va_list args) { struct storage *account2storage(int account_id) { struct storage *s; - s= idb_ensure(storage_db, account_id, create_storage); + s = (struct storage*)idb_ensure(storage_db, account_id, create_storage); return s; } @@ -184,7 +184,7 @@ struct guild_storage *guild2storage(int guild_id) { struct guild_storage *gs = NULL; if(inter_guild_search(guild_id) != NULL) - gs= idb_ensure(guild_storage_db, guild_id, create_guildstorage); + gs = (struct guild_storage*)idb_ensure(guild_storage_db, guild_id, create_guildstorage); return gs; } @@ -319,7 +319,7 @@ int inter_guild_storage_save() // 倉庫データ削除 int inter_storage_delete(int account_id) { - struct storage *s = idb_get(storage_db,account_id); + struct storage *s = (struct storage*)idb_get(storage_db,account_id); if(s) { int i; for(i=0;istorage_amount;i++){ @@ -334,7 +334,7 @@ int inter_storage_delete(int account_id) // ギルド倉庫データ削除 int inter_guild_storage_delete(int guild_id) { - struct guild_storage *gs = idb_get(guild_storage_db,guild_id); + struct guild_storage *gs = (struct guild_storage*)idb_get(guild_storage_db,guild_id); if(gs) { int i; for(i=0;istorage_amount;i++){ diff --git a/src/char/inter.c b/src/char/inter.c index 8472d36d1..bb4b86367 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -359,7 +359,8 @@ int mapif_wis_fail(int fd, char *src) { } // Wisp/page transmission result to map-server -int mapif_wis_end(struct WisData *wd, int flag) { +int mapif_wis_end(struct WisData *wd, int flag) +{ unsigned char buf[27]; WBUFW(buf, 0) = 0x3802; @@ -370,22 +371,17 @@ int mapif_wis_end(struct WisData *wd, int flag) { return 0; } -// アカウント変数送信 -int mapif_account_reg(int fd, unsigned char *src) { - unsigned char *buf = aCalloc(1,WBUFW(src,2)); - - memcpy(WBUFP(buf,0),src,WBUFW(src,2)); - WBUFW(buf, 0) = 0x3804; - mapif_sendallwos(fd, buf, WBUFW(buf,2)); - - aFree(buf); - - return 0; +// Account registry transfer to map-server +static void mapif_account_reg(int fd, unsigned char *src) +{ + WBUFW(src,0)=0x3804; //NOTE: writing to RFIFO + mapif_sendallwos(fd, src, WBUFW(src,2)); } // アカウント変数要求返信 -int mapif_account_reg_reply(int fd,int account_id, int char_id) { - struct accreg *reg = idb_get(accreg_db,account_id); +int mapif_account_reg_reply(int fd,int account_id, int char_id) +{ + struct accreg *reg = (struct accreg*)idb_get(accreg_db,account_id); WFIFOHEAD(fd, ACCOUNT_REG_NUM * 288+ 13); WFIFOW(fd,0) = 0x3804; @@ -397,8 +393,8 @@ int mapif_account_reg_reply(int fd,int account_id, int char_id) { } else { int i, p; for (p=13,i = 0; i < reg->reg_num; i++) { - p+= sprintf(WFIFOP(fd,p), "%s", reg->reg[i].str)+1; //We add 1 to consider the '\0' in place. - p+= sprintf(WFIFOP(fd,p), "%s", reg->reg[i].value)+1; + p+= sprintf((char*)WFIFOP(fd,p), "%s", reg->reg[i].str)+1; //We add 1 to consider the '\0' in place. + p+= sprintf((char*)WFIFOP(fd,p), "%s", reg->reg[i].value)+1; } WFIFOW(fd,2)=p; } @@ -443,7 +439,7 @@ int check_ttl_wisdata(void) { wis_delnum = 0; wis_db->foreach(wis_db, check_ttl_wisdata_sub, tick); for(i = 0; i < wis_delnum; i++) { - struct WisData *wd = idb_get(wis_db, wis_dellist[i]); + struct WisData *wd = (struct WisData*)idb_get(wis_db, wis_dellist[i]); ShowWarning("inter: wis data id=%d time out : from %s to %s\n", wd->id, wd->src, wd->dst); // removed. not send information after a timeout. Just no answer for the player //mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target @@ -505,7 +501,7 @@ int mapif_parse_WisRequest(int fd) { // search if character exists before to ask all map-servers char_status = search_character_byname(name); if (char_status == NULL) - return mapif_wis_fail(fd, RFIFOP(fd, 4)); + return mapif_wis_fail(fd, (char*)RFIFOP(fd, 4)); // Character exists. // to be sure of the correct name, rewrite it @@ -513,19 +509,19 @@ int mapif_parse_WisRequest(int fd) { strncpy(name, char_status->name, NAME_LENGTH); // if source is destination, don't ask other servers. if (strcmp((char*)RFIFOP(fd,4),name) == 0) - return mapif_wis_fail(fd, RFIFOP(fd, 4)); + return mapif_wis_fail(fd, (char*)RFIFOP(fd, 4)); //Look for online character. fd2 = search_character_online(char_status->account_id, char_status->char_id); if (fd2 >= 0) { //Character online, send whisper. - wd = mapif_create_whisper(fd, RFIFOP(fd, 4), RFIFOP(fd,28), RFIFOP(fd,52), RFIFOW(fd,2)-52); + wd = mapif_create_whisper(fd, (char*)RFIFOP(fd, 4), (char*)RFIFOP(fd,28), (char*)RFIFOP(fd,52), RFIFOW(fd,2)-52); if (!wd) return 1; idb_put(wis_db, wd->id, wd); mapif_wis_message2(wd, fd2); return 0; } //Not found. - return mapif_wis_fail(fd, RFIFOP(fd, 4)); + return mapif_wis_fail(fd, (char*)RFIFOP(fd,4)); } // Wisp/page transmission result @@ -535,7 +531,7 @@ int mapif_parse_WisReply(int fd) { RFIFOHEAD(fd); id = RFIFOL(fd,2); flag = RFIFOB(fd,6); - wd = idb_get(wis_db, id); + wd = (struct WisData*)idb_get(wis_db, id); if (wd == NULL) return 0; // This wisp was probably suppress before, because it was timeout or because of target was found on another map-server @@ -583,13 +579,13 @@ int mapif_parse_Registry(int fd) { default: //Error? return 1; } - reg = idb_ensure(accreg_db, RFIFOL(fd,4), create_accreg); + reg = (struct accreg*)idb_ensure(accreg_db, RFIFOL(fd,4), create_accreg); for(j=0,p=13;jreg[j].str,&len); + sscanf((char*)RFIFOP(fd,p), "%31c%n",reg->reg[j].str,&len); reg->reg[j].str[len]='\0'; p +=len+1; //+1 to skip the '\0' between strings. - sscanf(RFIFOP(fd,p), "%255c%n",reg->reg[j].value,&len); + sscanf((char*)RFIFOP(fd,p), "%255c%n",reg->reg[j].value,&len); reg->reg[j].value[len]='\0'; p +=len+1; } @@ -636,7 +632,7 @@ int mapif_parse_NameChangeRequest(int fd) account_id = RFIFOL(fd, 2); char_id = RFIFOL(fd, 6); type = RFIFOB(fd, 10); - name = RFIFOP(fd, 11); + name = (char*)RFIFOP(fd, 11); // Check Authorised letters/symbols in the name if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised diff --git a/src/char_sql/char.c b/src/char_sql/char.c index 9112265da..ab243e217 100644 --- a/src/char_sql/char.c +++ b/src/char_sql/char.c @@ -232,7 +232,7 @@ void set_char_online(int map_id, int char_id, int account_id) } } - character = idb_ensure(online_char_db, account_id, create_online_char_data); + character = (struct online_char_data*)idb_ensure(online_char_db, account_id, create_online_char_data); if (online_check && character->char_id != -1 && character->server > -1 && character->server != map_id) { //char == 99 <- Character logging in, so someone has logged in while one @@ -257,7 +257,7 @@ void set_char_online(int map_id, int char_id, int account_id) if (char_id != 99) { //Set char online in guild cache. If char is in memory, use the guild id on it, otherwise seek it. struct mmo_charstatus *cp; - cp = idb_get(char_db_,char_id); + cp = (struct mmo_charstatus*)idb_get(char_db_,char_id); inter_guild_CharOnline(char_id, cp?cp->guild_id:-1); } if (login_fd > 0 && !session[login_fd]->flag.eof) @@ -281,7 +281,7 @@ void set_char_offline(int char_id, int account_id) } else { - struct mmo_charstatus* cp = idb_get(char_db_,char_id); + struct mmo_charstatus* cp = (struct mmo_charstatus*)idb_get(char_db_,char_id); inter_guild_CharOffline(char_id, cp?cp->guild_id:-1); if (cp) idb_remove(char_db_,char_id); @@ -290,7 +290,7 @@ void set_char_offline(int char_id, int account_id) Sql_ShowDebug(sql_handle); } - if ((character = idb_get(online_char_db, account_id)) != NULL) + if ((character = (struct online_char_data*)idb_get(online_char_db, account_id)) != NULL) { //We don't free yet to avoid aCalloc/aFree spamming during char change. [Skotlex] if( character->server > -1 ) server[character->server].users--; @@ -442,9 +442,9 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p) if (char_id!=p->char_id) return 0; #ifndef TXT_SQL_CONVERT - cp = idb_ensure(char_db_, char_id, create_charstatus); + cp = (struct mmo_charstatus*)idb_ensure(char_db_, char_id, create_charstatus); #else - cp = aCalloc(1, sizeof(struct mmo_charstatus)); + cp = (struct mmo_charstatus*)aCalloc(1, sizeof(struct mmo_charstatus)); #endif StringBuf_Init(&buf); @@ -1141,7 +1141,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything SqlStmt_Free(stmt); StringBuf_Destroy(&buf); - cp = idb_ensure(char_db_, char_id, create_charstatus); + cp = (struct mmo_charstatus*)idb_ensure(char_db_, char_id, create_charstatus); memcpy(cp, p, sizeof(struct mmo_charstatus)); return 1; } @@ -1613,7 +1613,7 @@ static void char_auth_ok(int fd, struct char_session_data *sd) return; } - if( online_check && (character = idb_get(online_char_db, sd->account_id)) != NULL ) + if( online_check && (character = (struct online_char_data*)idb_get(online_char_db, sd->account_id)) != NULL ) { // check if character is not online already. [Skotlex] if (character->server > -1) { //Character already online. KICK KICK KICK @@ -1898,7 +1898,7 @@ int parse_fromlogin(int fd) return 0; if(!char_gm_read) { - unsigned char buf[32000]; + unsigned char buf[32000]; //FIXME: this will crash if (gm_account != NULL) aFree(gm_account); gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1); @@ -1926,7 +1926,7 @@ int parse_fromlogin(int fd) { struct online_char_data* character; int aid = RFIFOL(fd,2); - if ((character = idb_get(online_char_db, aid)) != NULL) + if ((character = (struct online_char_data*)idb_get(online_char_db, aid)) != NULL) { //Kick out this player. if( character->server > -1 ) { //Kick it from the map server it is on. @@ -2118,7 +2118,7 @@ int char_send_fame_list(int fd) void char_update_fame_list(int type, int index, int fame) { - char buf[9]; + unsigned char buf[8]; WBUFW(buf,0) = 0x2b22; WBUFB(buf,2) = type; WBUFB(buf,3) = index; @@ -2346,7 +2346,7 @@ int parse_frommap(int fd) for(i = 0; i < server[id].users; i++) { aid = RFIFOL(fd,6+i*8); cid = RFIFOL(fd,6+i*8+4); - character = idb_ensure(online_char_db, aid, create_online_char_data); + character = (struct online_char_data*)idb_ensure(online_char_db, aid, create_online_char_data); if (character->server > -1 && character->server != id) { ShowNotice("Set map user: Character (%d:%d) marked on map server %d, but map server %d claims to have (%d:%d) online!\n", @@ -2375,7 +2375,7 @@ int parse_frommap(int fd) } //Check account only if this ain't final save. Final-save goes through because of the char-map reconnect if (RFIFOB(fd,12) || ( - (character = idb_get(online_char_db, aid)) != NULL && + (character = (struct online_char_data*)idb_get(online_char_db, aid)) != NULL && character->char_id == cid)) { struct mmo_charstatus char_dat; @@ -2435,7 +2435,7 @@ int parse_frommap(int fd) if (map_id >= 0) map_fd = server[map_id].fd; //Char should just had been saved before this packet, so this should be safe. [Skotlex] - char_data = uidb_get(char_db_,RFIFOL(fd,14)); + char_data = (struct mmo_charstatus*)uidb_get(char_db_,RFIFOL(fd,14)); if (char_data == NULL) { //Really shouldn't happen. mmo_char_fromsql(RFIFOL(fd,14), &char_dat, true); @@ -2460,7 +2460,7 @@ int parse_frommap(int fd) memcpy(WFIFOP(map_fd,20), char_data, sizeof(struct mmo_charstatus)); WFIFOSET(map_fd, WFIFOW(map_fd,2)); - data = idb_ensure(online_char_db, RFIFOL(fd,2), create_online_char_data); + data = (struct online_char_data*)idb_ensure(online_char_db, RFIFOL(fd,2), create_online_char_data); data->char_id = char_data->char_id; data->server = map_id; //Update server where char is. @@ -2683,7 +2683,7 @@ int parse_frommap(int fd) char esc_motd[sizeof(motd)*2+1]; char esc_server_name[sizeof(server_name)*2+1]; - strncpy(motd, RFIFOP(fd,10), 255); //First copy it to make sure the motd fits. + strncpy(motd, (char*)RFIFOP(fd,10), 255); //First copy it to make sure the motd fits. motd[255] = '\0'; Sql_EscapeString(sql_handle, esc_motd, motd); Sql_EscapeString(sql_handle, esc_server_name, server_name); @@ -2851,7 +2851,7 @@ int parse_char(int fd) { if (sd != NULL) { // already authed client - struct online_char_data* data = idb_get(online_char_db, sd->account_id); + struct online_char_data* data = (struct online_char_data*)idb_get(online_char_db, sd->account_id); if (!data || data->server == -1) //If it is not in any server, send it offline. [Skotlex] set_char_offline(99,sd->account_id); if (data && data->fd == fd) @@ -3202,8 +3202,8 @@ int parse_char(int fd) if (RFIFOREST(fd) < 60) return 0; { - char* l_user = RFIFOP(fd,2); - char* l_pass = RFIFOP(fd,26); + char* l_user = (char*)RFIFOP(fd,2); + char* l_pass = (char*)RFIFOP(fd,26); l_user[23] = '\0'; l_pass[23] = '\0'; ARR_FIND( 0, MAX_MAP_SERVERS, i, server[i].fd <= 0 ); @@ -3466,7 +3466,7 @@ int ping_login_server(int tid, unsigned int tick, int id, int data) static int chardb_waiting_disconnect(int tid, unsigned int tick, int id, int data) { struct online_char_data* character; - if ((character = idb_get(online_char_db, id)) != NULL && character->waiting_disconnect == tid) + if ((character = (struct online_char_data*)idb_get(online_char_db, id)) != NULL && character->waiting_disconnect == tid) { //Mark it offline due to timeout. character->waiting_disconnect = -1; set_char_offline(character->char_id, character->account_id); diff --git a/src/char_sql/int_auction.c b/src/char_sql/int_auction.c index 15b316bb8..84f0ff424 100644 --- a/src/char_sql/int_auction.c +++ b/src/char_sql/int_auction.c @@ -30,7 +30,7 @@ static int auction_count(int char_id, bool buy) DBKey key; iter = auction_db_->iterator(auction_db_); - for( auction = iter->first(iter,&key); iter->exists(iter); auction = iter->next(iter,&key) ) + for( auction = (struct auction_data*)iter->first(iter,&key); iter->exists(iter); auction = (struct auction_data*)iter->next(iter,&key) ) { if( (buy && auction->buyer_id == char_id) || (!buy && auction->seller_id == char_id) ) i++; @@ -262,7 +262,7 @@ static void mapif_parse_Auction_requestlist(int fd) memcpy(searchtext, RFIFOP(fd,16), NAME_LENGTH); iter = auction_db_->iterator(auction_db_); - for( auction = iter->first(iter,&key); iter->exists(iter); auction = iter->next(iter,&key) ) + for( auction = (struct auction_data*)iter->first(iter,&key); iter->exists(iter); auction = (struct auction_data*)iter->next(iter,&key) ) { if( (type == 0 && auction->type != IT_ARMOR && auction->type != IT_PETARMOR) || (type == 1 && auction->type != IT_WEAPON) || diff --git a/src/char_sql/int_guild.c b/src/char_sql/int_guild.c index 93b915886..3ff05ddf1 100644 --- a/src/char_sql/int_guild.c +++ b/src/char_sql/int_guild.c @@ -59,7 +59,7 @@ static int guild_save_timer(int tid, unsigned int tick, int id, int data) state = 1; iter = guild_db_->iterator(guild_db_); - for( g = iter->first(iter,&key); iter->exists(iter); g = iter->next(iter,&key) ) + for( g = (struct guild*)iter->first(iter,&key); iter->exists(iter); g = (struct guild*)iter->next(iter,&key) ) { if( state == 0 && g->guild_id == last_id ) state++; //Save next guild in the list. @@ -374,7 +374,7 @@ struct guild * inter_guild_fromsql(int guild_id) if( guild_id <= 0 ) return NULL; - g = idb_get(guild_db_, guild_id); + g = (struct guild*)idb_get(guild_db_, guild_id); if( g ) return g; @@ -1852,7 +1852,7 @@ int mapif_parse_GuildCastleDataSave(int fd,int castle_id,int index,int value) case 1: if( gc.guild_id!=value ){ int gid=(value)?value:gc.guild_id; - struct guild *g=idb_get(guild_db_, gid); + struct guild *g = (struct guild*)idb_get(guild_db_, gid); if(log_inter) inter_log("guild %s (id=%d) %s castle id=%d\n", (g)?g->name:"??" ,gid, (value)?"occupy":"abandon", castle_id); diff --git a/src/char_sql/int_homun.c b/src/char_sql/int_homun.c index 4e596ef28..591ab219d 100644 --- a/src/char_sql/int_homun.c +++ b/src/char_sql/int_homun.c @@ -302,7 +302,7 @@ int inter_homunculus_parse_frommap(int fd){ case 0x3091: mapif_load_homunculus(fd); break; case 0x3092: mapif_save_homunculus(fd, RFIFOW(fd,4), (struct s_homunculus*) RFIFOP(fd, 8)); break; case 0x3093: mapif_delete_homunculus(fd); break; // doesn't need to be parse, very simple packet... - case 0x3094: mapif_rename_homun(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOP(fd, 10)); break; + case 0x3094: mapif_rename_homun(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), (char*)RFIFOP(fd, 10)); break; default: return 0; } diff --git a/src/char_sql/int_mail.c b/src/char_sql/int_mail.c index 86a076b0d..963647200 100644 --- a/src/char_sql/int_mail.c +++ b/src/char_sql/int_mail.c @@ -53,7 +53,7 @@ static int mail_fromsql(int char_id, struct mail_data* md) Sql_GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH); Sql_GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH); Sql_GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data); - Sql_GetData(sql_handle, 8, &data, NULL); msg->status = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data); Sql_GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data); item = &msg->item; Sql_GetData(sql_handle,10, &data, NULL); item->amount = (short)atoi(data); @@ -169,7 +169,7 @@ static bool mail_loadmessage(int mail_id, struct mail_message* msg) Sql_GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH); Sql_GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH); Sql_GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data); - Sql_GetData(sql_handle, 8, &data, NULL); msg->status = atoi(data); + Sql_GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data); Sql_GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data); Sql_GetData(sql_handle,10, &data, NULL); msg->item.amount = (short)atoi(data); Sql_GetData(sql_handle,11, &data, NULL); msg->item.nameid = atoi(data); diff --git a/src/char_sql/int_party.c b/src/char_sql/int_party.c index a51b8def0..a4769ebd6 100644 --- a/src/char_sql/int_party.c +++ b/src/char_sql/int_party.c @@ -211,7 +211,7 @@ struct party_data *inter_party_fromsql(int party_id) return NULL; //Load from memory - p = idb_get(party_db_, party_id); + p = (struct party_data*)idb_get(party_db_, party_id); if( p != NULL ) return p; @@ -498,7 +498,7 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part } } - p= aCalloc(1, sizeof(struct party_data)); + p = (struct party_data*)aCalloc(1, sizeof(struct party_data)); memcpy(p->party.name,name,NAME_LENGTH); p->party.exp=0; diff --git a/src/char_sql/inter.c b/src/char_sql/inter.c index 089e93740..4f856211d 100644 --- a/src/char_sql/inter.c +++ b/src/char_sql/inter.c @@ -485,8 +485,9 @@ int mapif_wis_message(struct WisData *wd) return 0; } + // Wis sending result -int mapif_wis_end(struct WisData *wd,int flag) +int mapif_wis_end(struct WisData *wd, int flag) { unsigned char buf[27]; @@ -497,15 +498,11 @@ int mapif_wis_end(struct WisData *wd,int flag) return 0; } -int mapif_account_reg(int fd,unsigned char *src) +// Account registry transfer to map-server +static void mapif_account_reg(int fd, unsigned char *src) { -// unsigned char buf[WBUFW(src,2)]; <- Hey, can this really be done? [Skotlex] - unsigned char *buf = aCalloc(1,WBUFW(src,2)); // [Lance] - Skot... Dynamic allocation is better :D - memcpy(WBUFP(buf,0),src,WBUFW(src,2)); - WBUFW(buf, 0)=0x3804; - mapif_sendallwos(fd, buf, WBUFW(buf,2)); - aFree(buf); - return 0; + WBUFW(src,0)=0x3804; //NOTE: writing to RFIFO + mapif_sendallwos(fd, src, WBUFW(src,2)); } // Send the requested account_reg @@ -524,8 +521,8 @@ int mapif_account_reg_reply(int fd,int account_id,int char_id, int type) }else{ int i,p; for (p=13,i = 0; i < reg->reg_num && p < 5000; i++) { - p+= sprintf(WFIFOP(fd,p), "%s", reg->reg[i].str)+1; //We add 1 to consider the '\0' in place. - p+= sprintf(WFIFOP(fd,p), "%s", reg->reg[i].value)+1; + p+= sprintf((char*)WFIFOP(fd,p), "%s", reg->reg[i].str)+1; //We add 1 to consider the '\0' in place. + p+= sprintf((char*)WFIFOP(fd,p), "%s", reg->reg[i].value)+1; } WFIFOW(fd,2)=p; if (p>= 5000) @@ -605,7 +602,7 @@ int check_ttl_wisdata(void) wis_delnum = 0; wis_db->foreach(wis_db, check_ttl_wisdata_sub, tick); for(i = 0; i < wis_delnum; i++) { - struct WisData *wd = idb_get(wis_db, wis_dellist[i]); + struct WisData *wd = (struct WisData*)idb_get(wis_db, wis_dellist[i]); ShowWarning("inter: wis data id=%d time out : from %s to %s\n", wd->id, wd->src, wd->dst); // removed. not send information after a timeout. Just no answer for the player //mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target @@ -710,7 +707,7 @@ int mapif_parse_WisReply(int fd) id = RFIFOL(fd,2); flag = RFIFOB(fd,6); - wd = idb_get(wis_db, id); + wd = (struct WisData*)idb_get(wis_db, id); if (wd == NULL) return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server @@ -755,10 +752,10 @@ int mapif_parse_Registry(int fd) return 1; } for(j=0,p=13;jreg[j].str,&len); + sscanf((char*)RFIFOP(fd,p), "%31c%n",reg->reg[j].str,&len); reg->reg[j].str[len]='\0'; p +=len+1; //+1 to skip the '\0' between strings. - sscanf(RFIFOP(fd,p), "%255c%n",reg->reg[j].value,&len); + sscanf((char*)RFIFOP(fd,p), "%255c%n",reg->reg[j].value,&len); reg->reg[j].value[len]='\0'; p +=len+1; } @@ -802,7 +799,7 @@ int mapif_parse_NameChangeRequest(int fd) account_id = RFIFOL(fd,2); char_id = RFIFOL(fd,6); type = RFIFOB(fd,10); - name = RFIFOP(fd,11); + name = (char*)RFIFOP(fd,11); // Check Authorised letters/symbols in the name if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised diff --git a/src/common/db.c b/src/common/db.c index 77d3b7b2e..07adf73f1 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -106,6 +106,16 @@ */ #define HASH_SIZE (256+27) +/** + * The color of individual nodes. + * @private + * @see struct dbn + */ +typedef enum node_color { + RED, + BLACK +} node_color; + /** * A node in a RED-BLACK tree of the database. * @param parent Parent node @@ -127,7 +137,7 @@ typedef struct dbn { DBKey key; void *data; // Other - enum {RED, BLACK} color; + node_color color; unsigned deleted : 1; } *DBNode; @@ -503,7 +513,7 @@ static void db_rebalance_erase(DBNode node, DBNode *root) y->parent = node->parent; // switch colors { - int tmp = y->color; + node_color tmp = y->color; y->color = node->color; node->color = tmp; } @@ -2112,7 +2122,7 @@ static DBType db_obj_type(DBMap* self) DBType type; DB_COUNTSTAT(db_type); - if (db == NULL) return -1; // nullpo candidate - TODO what should this return? + if (db == NULL) return (DBType)-1; // nullpo candidate - TODO what should this return? db_free_lock(db); type = db->type; @@ -2176,7 +2186,7 @@ DBOptions db_fix_options(DBType type, DBOptions options) switch (type) { case DB_INT: case DB_UINT: // Numeric database, do nothing with the keys - return options&~(DB_OPT_DUP_KEY|DB_OPT_RELEASE_KEY); + return (DBOptions)(options&~(DB_OPT_DUP_KEY|DB_OPT_RELEASE_KEY)); default: ShowError("db_fix_options: Unknown database type %u with options %x\n", type, options); @@ -2512,10 +2522,11 @@ void db_final(void) } // Link DB System - jAthena -void linkdb_insert( struct linkdb_node** head, void *key, void* data) { +void linkdb_insert( struct linkdb_node** head, void *key, void* data) +{ struct linkdb_node *node; if( head == NULL ) return ; - node = aMalloc( sizeof(struct linkdb_node) ); + node = (struct linkdb_node*)aMalloc( sizeof(struct linkdb_node) ); if( *head == NULL ) { // first node *head = node; @@ -2532,7 +2543,8 @@ void linkdb_insert( struct linkdb_node** head, void *key, void* data) { node->data = data; } -void* linkdb_search( struct linkdb_node** head, void *key) { +void* linkdb_search( struct linkdb_node** head, void *key) +{ int n = 0; struct linkdb_node *node; if( head == NULL ) return NULL; @@ -2556,7 +2568,8 @@ void* linkdb_search( struct linkdb_node** head, void *key) { return NULL; } -void* linkdb_erase( struct linkdb_node** head, void *key) { +void* linkdb_erase( struct linkdb_node** head, void *key) +{ struct linkdb_node *node; if( head == NULL ) return NULL; node = *head; @@ -2577,7 +2590,8 @@ void* linkdb_erase( struct linkdb_node** head, void *key) { return NULL; } -void linkdb_replace( struct linkdb_node** head, void *key, void *data ) { +void linkdb_replace( struct linkdb_node** head, void *key, void *data ) +{ int n = 0; struct linkdb_node *node; if( head == NULL ) return ; @@ -2603,7 +2617,8 @@ void linkdb_replace( struct linkdb_node** head, void *key, void *data ) { linkdb_insert( head, key, data ); } -void linkdb_final( struct linkdb_node** head ) { +void linkdb_final( struct linkdb_node** head ) +{ struct linkdb_node *node, *node2; if( head == NULL ) return ; node = *head; diff --git a/src/common/mmo.h b/src/common/mmo.h index 0d3ef44a6..845b73a7b 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -256,11 +256,11 @@ struct mmo_charstatus { bool show_equip; }; -enum mail_status { +typedef enum mail_status { MAIL_NEW, MAIL_UNREAD, MAIL_READ, -}; +} mail_status; struct mail_message { unsigned int id; @@ -271,7 +271,7 @@ struct mail_message { char title[MAIL_TITLE_LENGTH]; char body[MAIL_BODY_LENGTH]; - enum mail_status status; + mail_status status; unsigned int timestamp; // marks when the message was sent int zeny; diff --git a/src/common/plugin.h b/src/common/plugin.h index 8aef934d0..fd01be762 100644 --- a/src/common/plugin.h +++ b/src/common/plugin.h @@ -80,6 +80,9 @@ typedef void Plugin_Event_Func(void); #define PLUGIN_INFO struct _Plugin_Info plugin_info #define PLUGIN_EVENTS_TABLE struct _Plugin_Event_Table plugin_event_table[] + +#ifndef _PLUGINS_H_ void** plugin_call_table; +#endif #endif /* _PLUGIN_H_ */ diff --git a/src/common/plugins.c b/src/common/plugins.c index 58ab60b74..01a6194cd 100644 --- a/src/common/plugins.c +++ b/src/common/plugins.c @@ -38,6 +38,7 @@ Plugin* plugin_head = NULL; static Plugin_Info default_info = { "Unknown", PLUGIN_ALL, "0", PLUGIN_VERSION, "Unknown" }; +void** plugin_call_table; static size_t call_table_size = 0; static size_t max_call_table = 0; @@ -196,7 +197,7 @@ Plugin* plugin_open(const char* filename) // Retrieve plugin information plugin->state = 0; // initialising - DLL_SYM(info, plugin->dll, "plugin_info"); + info = (Plugin_Info*)DLL_SYM(plugin->dll, "plugin_info"); // For high priority plugins (those that are explicitly loaded from the conf file) // we'll ignore them even (could be a 3rd party dll file) if( !info ) @@ -225,20 +226,20 @@ Plugin* plugin_open(const char* filename) plugin->filename = aStrdup(filename); // Initialise plugin call table (For exporting procedures) - DLL_SYM(procs, plugin->dll, "plugin_call_table"); + procs = (void**)DLL_SYM(plugin->dll, "plugin_call_table"); if( procs ) *procs = plugin_call_table; //else ShowDebug("plugin_open: plugin_call_table not found\n"); // Register plugin events - DLL_SYM(events, plugin->dll, "plugin_event_table"); + events = (Plugin_Event_Table*)DLL_SYM(plugin->dll, "plugin_event_table"); if( events ){ int i = 0; //ShowDebug("plugin_open: parsing plugin_event_table\n"); while( events[i].func_name ){ if( strcmpi(events[i].event_name, EVENT_PLUGIN_TEST) == 0 ){ Plugin_Test_Func* test_func; - DLL_SYM(test_func, plugin->dll, events[i].func_name); + test_func = (Plugin_Test_Func*)DLL_SYM(plugin->dll, events[i].func_name); //ShowDebug("plugin_open: invoking "EVENT_PLUGIN_TEST" with %s()\n", events[i].func_name); if( test_func && test_func() == 0 ){ // plugin has failed test, disabling @@ -247,7 +248,7 @@ Plugin* plugin_open(const char* filename) } } else { Plugin_Event_Func* func; - DLL_SYM(func, plugin->dll, events[i].func_name); + func = (Plugin_Event_Func*)DLL_SYM(plugin->dll, events[i].func_name); if (func) register_plugin_event(func, events[i].event_name); } @@ -340,27 +341,27 @@ void plugins_init(void) register_plugin_func(EVENT_ATHENA_FINAL); // networking - export_symbol(RFIFOSKIP, SYMBOL_RFIFOSKIP); - export_symbol(WFIFOSET, SYMBOL_WFIFOSET); - export_symbol(do_close, SYMBOL_DELETE_SESSION); - export_symbol(session, SYMBOL_SESSION); - export_symbol(&fd_max, SYMBOL_FD_MAX); - export_symbol(addr_, SYMBOL_ADDR); + EXPORT_SYMBOL(RFIFOSKIP, SYMBOL_RFIFOSKIP); + EXPORT_SYMBOL(WFIFOSET, SYMBOL_WFIFOSET); + EXPORT_SYMBOL(do_close, SYMBOL_DELETE_SESSION); + EXPORT_SYMBOL(session, SYMBOL_SESSION); + EXPORT_SYMBOL(&fd_max, SYMBOL_FD_MAX); + EXPORT_SYMBOL(addr_, SYMBOL_ADDR); // timers - export_symbol(get_uptime, SYMBOL_GET_UPTIME); - export_symbol(delete_timer, SYMBOL_DELETE_TIMER); - export_symbol(add_timer_func_list, SYMBOL_ADD_TIMER_FUNC_LIST); - export_symbol(add_timer_interval, SYMBOL_ADD_TIMER_INTERVAL); - export_symbol(add_timer, SYMBOL_ADD_TIMER); - export_symbol((void*)get_svn_revision, SYMBOL_GET_SVN_REVISION); - export_symbol(gettick, SYMBOL_GETTICK); + EXPORT_SYMBOL(get_uptime, SYMBOL_GET_UPTIME); + EXPORT_SYMBOL(delete_timer, SYMBOL_DELETE_TIMER); + EXPORT_SYMBOL(add_timer_func_list, SYMBOL_ADD_TIMER_FUNC_LIST); + EXPORT_SYMBOL(add_timer_interval, SYMBOL_ADD_TIMER_INTERVAL); + EXPORT_SYMBOL(add_timer, SYMBOL_ADD_TIMER); + EXPORT_SYMBOL((void*)get_svn_revision, SYMBOL_GET_SVN_REVISION); + EXPORT_SYMBOL(gettick, SYMBOL_GETTICK); // core - export_symbol(parse_console, SYMBOL_PARSE_CONSOLE); - export_symbol(&runflag, SYMBOL_RUNFLAG); - export_symbol(arg_v, SYMBOL_ARG_V); - export_symbol(&arg_c, SYMBOL_ARG_C); - export_symbol(SERVER_NAME, SYMBOL_SERVER_NAME); - export_symbol(&SERVER_TYPE, SYMBOL_SERVER_TYPE); + EXPORT_SYMBOL(parse_console, SYMBOL_PARSE_CONSOLE); + EXPORT_SYMBOL(&runflag, SYMBOL_RUNFLAG); + EXPORT_SYMBOL(arg_v, SYMBOL_ARG_V); + EXPORT_SYMBOL(&arg_c, SYMBOL_ARG_C); + EXPORT_SYMBOL(SERVER_NAME, SYMBOL_SERVER_NAME); + EXPORT_SYMBOL(&SERVER_TYPE, SYMBOL_SERVER_TYPE); load_priority = 1; plugins_config_read(PLUGIN_CONF_FILENAME); diff --git a/src/common/plugins.h b/src/common/plugins.h index b4235e72d..9d93bcaa6 100644 --- a/src/common/plugins.h +++ b/src/common/plugins.h @@ -17,7 +17,7 @@ #define WIN32_LEAN_AND_MEAN #include #define DLL_OPEN(x) LoadLibrary(x) - #define DLL_SYM(x,y,z) (FARPROC)(x) = GetProcAddress(y,z) + #define DLL_SYM(x,y) GetProcAddress(x,y) #define DLL_CLOSE(x) FreeLibrary(x) char *DLL_ERROR(void); @@ -28,7 +28,7 @@ #include #define DLL_OPEN(x) dlopen(x,RTLD_NOW) - #define DLL_SYM(x,y,z) (x) = (void *)dlsym(y,z) + #define DLL_SYM(x,y) dlsym(x,y) #define DLL_CLOSE(x) dlclose(x) #define DLL_ERROR dlerror @@ -60,7 +60,8 @@ int register_plugin_event(Plugin_Event_Func* func, char* name); int plugin_event_trigger(char* name); int export_symbol(void* var, size_t offset); -#define EXPORT_SYMBOL(s) export_symbol((s), -1); +#define EXPORT_SYMBOL(s,o) export_symbol((void*)(s),(o)); +#define EXPORT_SYMBOL2(s) EXPORT_SYMBOL((s), -1); Plugin* plugin_open(const char* filename); void plugin_load(const char* filename); diff --git a/src/common/strlib.c b/src/common/strlib.c index b65bc0c55..5b53a29da 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -241,7 +241,7 @@ char* _strtok_r(char *s1, const char *s2, char **lasts) } #endif -#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) +#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(CYGWIN) /* Find the length of STRING, but scan at most MAXLEN characters. If no '\0' terminator is found in that many characters, return MAXLEN. */ size_t strnlen (const char* string, size_t maxlen) diff --git a/src/common/strlib.h b/src/common/strlib.h index d1fb20d49..004fe6375 100644 --- a/src/common/strlib.h +++ b/src/common/strlib.h @@ -24,7 +24,7 @@ const char *stristr(const char *haystack, const char *needle); char* _strtok_r(char* s1, const char* s2, char** lasts); #endif -#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) +#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(CYGWIN) size_t strnlen (const char* string, size_t maxlen); #endif @@ -49,7 +49,7 @@ int strline(const char* str, size_t pos); /// Bitfield determining the behaviour of sv_parse. -enum e_svopt +typedef enum e_svopt { // default: no escapes and no line terminator SV_NOESCAPE_NOTERMINATE = 0, @@ -59,7 +59,7 @@ enum e_svopt SV_TERMINATE_LF = 2, SV_TERMINATE_CRLF = 4, SV_TERMINATE_CR = 8, -}; +} e_svopt; /// Other escape sequences supported by the C compiler. #define SV_ESCAPE_C_SUPPORTED "abtnvfr\?\"'\\" diff --git a/src/common/timer.h b/src/common/timer.h index 7eedb689e..9c9d5c2b1 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -51,7 +51,7 @@ int add_timer_func_list(TimerFunc func, char* name); unsigned long get_uptime(void); unsigned int calc_times(void); -int do_timer(); +int do_timer(unsigned int tick); void timer_init(void); void timer_final(void); diff --git a/src/login/login.c b/src/login/login.c index 2931c87cb..7051ffb5e 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -131,7 +131,7 @@ void add_online_user(int char_server, int account_id) struct online_login_data* p; if( !login_config.online_check ) return; - p = idb_ensure(online_db, account_id, create_online_user); + p = (struct online_login_data*)idb_ensure(online_db, account_id, create_online_user); p->char_server = char_server; if( p->waiting_disconnect != -1 ) { @@ -154,7 +154,7 @@ void remove_online_user(int account_id) static int waiting_disconnect_timer(int tid, unsigned int tick, int id, int data) { - struct online_login_data* p = idb_get(online_db, id); + struct online_login_data* p = (struct online_login_data*)idb_get(online_db, id); if( p != NULL && p->waiting_disconnect == id ) { p->waiting_disconnect = -1; @@ -1122,7 +1122,7 @@ int mmo_auth(struct mmo_account* account, int fd) else safestrncpy(user_password, account->passwd, NAME_LENGTH); - if( !check_password(session[fd]->session_data, account->passwdenc, user_password, auth_dat[i].pass) ) + if( !check_password((struct login_session_data*)session[fd]->session_data, account->passwdenc, user_password, auth_dat[i].pass) ) { ShowNotice("Invalid password (account: %s, pass: %s, received pass: %s, ip: %s)\n", account->userid, auth_dat[i].pass, (account->passwdenc) ? "[MD5]" : account->passwd, ip); return 1; // 1 = Incorrect Password @@ -1150,7 +1150,7 @@ int mmo_auth(struct mmo_account* account, int fd) if( login_config.online_check ) { - struct online_login_data* data = idb_get(online_db,auth_dat[i].account_id); + struct online_login_data* data = (struct online_login_data*)idb_get(online_db,auth_dat[i].account_id); if( data ) {// account is already marked as online! if( data->char_server > -1 ) @@ -1456,8 +1456,8 @@ int parse_fromchar(int fd) char actual_email[40]; char new_email[40]; int account_id = RFIFOL(fd,2); - safestrncpy(actual_email, RFIFOP(fd,6), 40); remove_control_chars(actual_email); - safestrncpy(new_email, RFIFOP(fd,46), 40); remove_control_chars(new_email); + safestrncpy(actual_email, (char*)RFIFOP(fd,6), 40); remove_control_chars(actual_email); + safestrncpy(new_email, (char*)RFIFOP(fd,46), 40); remove_control_chars(new_email); RFIFOSKIP(fd, 86); if( e_mail_check(actual_email) == 0 ) @@ -1696,7 +1696,7 @@ int parse_fromchar(int fd) users = RFIFOW(fd,4); for (i = 0; i < users; i++) { aid = RFIFOL(fd,6+i*4); - p = idb_ensure(online_db, aid, create_online_user); + p = (struct online_login_data*)idb_ensure(online_db, aid, create_online_user); p->char_server = id; if (p->waiting_disconnect != -1) { diff --git a/src/login_sql/login.c b/src/login_sql/login.c index fddb4b248..57ec484cb 100644 --- a/src/login_sql/login.c +++ b/src/login_sql/login.c @@ -104,7 +104,7 @@ void add_online_user(int char_server, int account_id) struct online_login_data* p; if( !login_config.online_check ) return; - p = idb_ensure(online_db, account_id, create_online_user); + p = (struct online_login_data*)idb_ensure(online_db, account_id, create_online_user); p->char_server = char_server; if( p->waiting_disconnect != -1 ) { @@ -127,7 +127,7 @@ void remove_online_user(int account_id) static int waiting_disconnect_timer(int tid, unsigned int tick, int id, int data) { - struct online_login_data* p = idb_get(online_db, id); + struct online_login_data* p = (struct online_login_data*)idb_get(online_db, id); if( p != NULL && p->waiting_disconnect == id ) { p->waiting_disconnect = -1; @@ -531,7 +531,7 @@ int mmo_auth(struct mmo_account* account, int fd) else safestrncpy(user_password, account->passwd, NAME_LENGTH); - if( !check_password(session[fd]->session_data, account->passwdenc, user_password, password) ) + if( !check_password((struct login_session_data*)session[fd]->session_data, account->passwdenc, user_password, password) ) { ShowInfo("Invalid password (account: '%s', pass: '%s', received pass: '%s', ip: %s)\n", esc_userid, password, (account->passwdenc) ? "[MD5]" : user_password, ip); @@ -552,7 +552,7 @@ int mmo_auth(struct mmo_account* account, int fd) if( login_config.online_check ) { - struct online_login_data* data = idb_get(online_db, account->account_id); + struct online_login_data* data = (struct online_login_data*)idb_get(online_db, account->account_id); if( data ) {// account is already marked as online! if( data->char_server > -1 ) @@ -817,8 +817,8 @@ int parse_fromchar(int fd) char actual_email[40]; char new_email[40]; int account_id = RFIFOL(fd,2); - safestrncpy(actual_email, RFIFOP(fd,6), 40); - safestrncpy(new_email, RFIFOP(fd,46), 40); + safestrncpy(actual_email, (char*)RFIFOP(fd,6), 40); + safestrncpy(new_email, (char*)RFIFOP(fd,46), 40); RFIFOSKIP(fd, 86); if( e_mail_check(actual_email) == 0 ) @@ -997,17 +997,17 @@ int parse_fromchar(int fd) SqlStmt_ShowDebug(stmt); for( i = 0, off = 13; i < ACCOUNT_REG2_NUM && off < RFIFOW(fd,2); ++i ) { - uint8* p; + char* p; size_t len; // str - p = (uint8*)RFIFOP(fd,off); + p = (char*)RFIFOP(fd,off); len = strlen(p); SqlStmt_BindParam(stmt, 0, SQLDT_STRING, p, len); off += len + 1; // value - p = (uint8*)RFIFOP(fd,off); + p = (char*)RFIFOP(fd,off); len = strlen(p); SqlStmt_BindParam(stmt, 1, SQLDT_STRING, p, len); off += len + 1; @@ -1067,7 +1067,7 @@ int parse_fromchar(int fd) users = RFIFOW(fd,4); for (i = 0; i < users; i++) { aid = RFIFOL(fd,6+i*4); - p = idb_ensure(online_db, aid, create_online_user); + p = (struct online_login_data*)idb_ensure(online_db, aid, create_online_user); p->char_server = id; if (p->waiting_disconnect != -1) { diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 233376655..38de48e57 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -2394,7 +2394,7 @@ int atcommand_monster(const int fd, struct map_session_data* sd, const char* com ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)\n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y); count = 0; - range = (int)sqrt(number) +2; // calculation of an odd number (+ 4 area around) + range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0); k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, ""); @@ -5365,7 +5365,7 @@ int atcommand_effect(const int fd, struct map_session_data* sd, const char* comm return -1; } - clif_specialeffect(&sd->bl, type, flag); + clif_specialeffect(&sd->bl, type, (send_target)flag); clif_displaymessage(fd, msg_txt(229)); // Your effect has changed. return 0; } @@ -6997,9 +6997,8 @@ int atcommand_mobinfo(const int fd, struct map_session_data* sd, const char* com *------------------------------------------*/ int atshowmobs_timer(int tid, unsigned int tick, int id, int data) { - struct map_session_data *sd; - - if (!session[id] || (sd = session[id]->session_data) == NULL) + struct map_session_data* sd = map_id2sd(id); + if( sd == NULL ) return 0; clif_viewpoint(sd, 1, 2, 0, 0, data, 0xFFFFFF); diff --git a/src/map/battle.c b/src/map/battle.c index 6a60ea0a9..ae0c9d4a0 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -2754,11 +2754,11 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t int skillv; struct Damage wd; - nullpo_retr(0, src); - nullpo_retr(0, target); + nullpo_retr(ATK_NONE, src); + nullpo_retr(ATK_NONE, target); if (src->prev == NULL || target->prev == NULL) - return 0; + return ATK_NONE; sd = BL_CAST(BL_PC, src); tsd = BL_CAST(BL_PC, target); @@ -2782,7 +2782,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t damage = sd->equip_index[EQI_AMMO]; if (damage<0) { clif_arrow_fail(sd,0); - return 0; + return ATK_NONE; } //Ammo check by Ishizu-chan if (sd->inventory_data[damage]) @@ -2790,7 +2790,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t case W_BOW: if (sd->inventory_data[damage]->look != A_ARROW) { clif_arrow_fail(sd,0); - return 0; + return ATK_NONE; } break; case W_REVOLVER: @@ -2799,13 +2799,13 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t case W_SHOTGUN: if (sd->inventory_data[damage]->look != A_BULLET) { clif_arrow_fail(sd,0); - return 0; + return ATK_NONE; } break; case W_GRENADE: if (sd->inventory_data[damage]->look != A_GRENADE) { clif_arrow_fail(sd,0); - return 0; + return ATK_NONE; } break; } @@ -2831,7 +2831,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t clif_damage(src, target, tick, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS. status_change_end(target,SC_AUTOCOUNTER,-1); skill_attack(BF_WEAPON,target,target,src,KN_AUTOCOUNTER,skilllv,tick,0); - return 0; + return ATK_NONE; } } if (tsc->data[SC_BLADESTOP_WAIT] && !is_boss(src)) { @@ -2843,7 +2843,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t clif_damage(src, target, tick, sstatus->amotion, 1, 0, 1, 0, 0); //Display MISS. clif_bladestop(target,src,1); sc_start4(target, SC_BLADESTOP, 100, skilllv, 0, 0,(int)src, duration); - return 0; + return ATK_NONE; } } } @@ -2857,15 +2857,18 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t status_change_end(src,SC_SKILLRATE_UP,-1); } if (rand()%100 < triple_rate) - return skill_attack(BF_WEAPON,src,src,target,MO_TRIPLEATTACK,skillv,tick,0); + //FIXME: invalid return type! + return (damage_lv)skill_attack(BF_WEAPON,src,src,target,MO_TRIPLEATTACK,skillv,tick,0); } if (sc) { if (sc->data[SC_SACRIFICE]) - return skill_attack(BF_WEAPON,src,src,target,PA_SACRIFICE,sc->data[SC_SACRIFICE]->val1,tick,0); + //FIXME: invalid return type! + return (damage_lv)skill_attack(BF_WEAPON,src,src,target,PA_SACRIFICE,sc->data[SC_SACRIFICE]->val1,tick,0); if (sc->data[SC_MAGICALATTACK]) - return skill_attack(BF_MAGIC,src,src,target,NPC_MAGICALATTACK,sc->data[SC_MAGICALATTACK]->val1,tick,0); + //FIXME: invalid return type! + return (damage_lv)skill_attack(BF_MAGIC,src,src,target,NPC_MAGICALATTACK,sc->data[SC_MAGICALATTACK]->val1,tick,0); } wd = battle_calc_weapon_attack(src, target, 0, 0, flag); diff --git a/src/map/battle.h b/src/map/battle.h index 287b4ed61..c6c2eb2e9 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -5,11 +5,12 @@ #define _BATTLE_H_ // state of a single attack attempt; used in flee/def penalty calculations when mobbed -enum damage_lv { - ATK_LUCKY=1, // attack was lucky-dodged +typedef enum damage_lv { + ATK_NONE, // not an attack + ATK_LUCKY, // attack was lucky-dodged ATK_FLEE, // attack was dodged ATK_DEF // attack connected -}; +} damage_lv; // ダメージ struct Damage { diff --git a/src/map/chrif.c b/src/map/chrif.c index 7194819cf..7ef032f16 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -106,8 +106,9 @@ int other_mapserver_count=0; //Holds count of how many other map servers are onl //This define should spare writing the check in every function. [Skotlex] #define chrif_check(a) { if(!chrif_isconnected()) return a; } -struct auth_node* chrif_search(int account_id) { - return idb_get(auth_db, account_id); +struct auth_node* chrif_search(int account_id) +{ + return (struct auth_node*)idb_get(auth_db, account_id); } struct auth_node* chrif_auth_check(int account_id, int char_id, enum sd_state state) { @@ -1234,7 +1235,7 @@ int chrif_load_scdata(int fd) for (i = 0; i < count; i++) { data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data)); - status_change_start(&sd->bl, data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15); + status_change_start(&sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, 15); } #endif return 0; diff --git a/src/map/clif.c b/src/map/clif.c index a91c8d9ca..532d42ff1 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -678,7 +678,7 @@ static int clif_clearunit_delayed_sub(int tid, unsigned int tick, int id, int da int clif_clearunit_delayed(struct block_list* bl, unsigned int tick) { struct block_list *tbl; - tbl = aMalloc(sizeof (struct block_list)); + tbl = (struct block_list*)aMalloc(sizeof (struct block_list)); memcpy (tbl, bl, sizeof (struct block_list)); add_timer(tick, clif_clearunit_delayed_sub, (int)tbl, 0); return 0; @@ -1009,21 +1009,18 @@ static void clif_weather_check(struct map_session_data *sd) } } -int clif_weather(int m) +void clif_weather(int m) { - int i; - + struct s_mapiterator* iter; struct map_session_data *sd=NULL; - for(i = 0; i < fd_max; i++) { - if (session[i] && session[i]->func_parse == clif_parse && - (sd = session[i]->session_data) != NULL && - sd->state.active && sd->bl.m == m) { + iter = mapit_getallusers(); + for( sd = (struct map_session_data*)mapit_first(iter); mapit_exists(iter); sd = (struct map_session_data*)mapit_next(iter) ) + { + if( sd->bl.m == m ) clif_weather_check(sd); - } } - - return 0; + mapit_free(iter); } int clif_spawn(struct block_list *bl) @@ -2488,9 +2485,8 @@ void clif_changetraplook(struct block_list *bl,int val) } -//For the stupid cloth-dye bug. Resends the given view data -//to the area specified by bl. -void clif_refreshlook(struct block_list *bl,int id,int type,int val,int area) +//For the stupid cloth-dye bug. Resends the given view data to the area specified by bl. +void clif_refreshlook(struct block_list *bl,int id,int type,int val,enum send_target target) { unsigned char buf[32]; #if PACKETVER < 4 @@ -2498,14 +2494,14 @@ void clif_refreshlook(struct block_list *bl,int id,int type,int val,int area) WBUFL(buf,2)=id; WBUFB(buf,6)=type; WBUFB(buf,7)=val; - clif_send(buf,packet_len(0xc3),bl,area); + clif_send(buf,packet_len(0xc3),bl,target); #else WBUFW(buf,0)=0x1d7; WBUFL(buf,2)=id; WBUFB(buf,6)=type; WBUFW(buf,7)=val; WBUFW(buf,9)=0; - clif_send(buf,packet_len(0x1d7),bl,area); + clif_send(buf,packet_len(0x1d7),bl,target); #endif return; } @@ -6485,9 +6481,9 @@ int clif_guild_expulsion(struct map_session_data *sd,const char *name,const char nullpo_retr(0, sd); WBUFW(buf, 0)=0x15c; - safestrncpy(WBUFP(buf, 2),name,NAME_LENGTH); - safestrncpy(WBUFP(buf,26),mes,40); - safestrncpy(WBUFP(buf,66),"",NAME_LENGTH); // account name (not used for security reasons) + safestrncpy((char*)WBUFP(buf, 2),name,NAME_LENGTH); + safestrncpy((char*)WBUFP(buf,26),mes,40); + safestrncpy((char*)WBUFP(buf,66),"",NAME_LENGTH); // account name (not used for security reasons) clif_send(buf,packet_len(0x15c),&sd->bl,GUILD); return 0; } @@ -6512,9 +6508,9 @@ int clif_guild_expulsionlist(struct map_session_data *sd) for(i=c=0;iexpulsion[i]; if(e->account_id>0){ - safestrncpy(WFIFOP(fd,4 + c*88),e->name,NAME_LENGTH); - safestrncpy(WFIFOP(fd,4 + c*88+24),"",24); // account name (not used for security reasons) - safestrncpy(WFIFOP(fd,4 + c*88+48),e->mes,40); + safestrncpy((char*)WFIFOP(fd,4 + c*88),e->name,NAME_LENGTH); + safestrncpy((char*)WFIFOP(fd,4 + c*88+24),"",24); // account name (not used for security reasons) + safestrncpy((char*)WFIFOP(fd,4 + c*88+48),e->mes,40); c++; } } @@ -8263,7 +8259,7 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd) /*========================================== * *------------------------------------------*/ -void clif_changed_dir(struct block_list *bl, int type) +void clif_changed_dir(struct block_list *bl, enum send_target target) { unsigned char buf[64]; @@ -8272,7 +8268,8 @@ void clif_changed_dir(struct block_list *bl, int type) WBUFW(buf,6) = bl->type==BL_PC?((TBL_PC*)bl)->head_dir:0; WBUFB(buf,8) = unit_getdir(bl); - clif_send(buf, packet_len(0x9c), bl, type); + clif_send(buf, packet_len(0x9c), bl, target); + if (disguised(bl)) { WBUFL(buf,2) = -bl->id; WBUFW(buf,6) = 0; @@ -9005,10 +9002,13 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd) return; } - if(battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 1){ - trade_traderequest(sd,t_sd); - } else + if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 1) + { clif_skill_fail(sd,1,0,0); + return; + } + + trade_traderequest(sd,t_sd); } /*========================================== @@ -9712,19 +9712,24 @@ void clif_parse_StoragePassword(int fd, struct map_session_data *sd) /*========================================== - * パーティを作る + * Party creation request + * S 00f9 .24S + * S 01e8 .24S .B .B *------------------------------------------*/ void clif_parse_CreateParty(int fd, struct map_session_data *sd) { if(map[sd->bl.m].flag.partylock) - { //Guild locked. + {// Party locked. clif_displaymessage(fd, msg_txt(227)); return; } - if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7) { - party_create(sd,(char*)RFIFOP(fd,2),0,0); - } else + if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 7 ) + { clif_skill_fail(sd,1,0,4); + return; + } + + party_create(sd,(char*)RFIFOP(fd,2),0,0); } /*========================================== @@ -9733,33 +9738,38 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd) void clif_parse_CreateParty2(int fd, struct map_session_data *sd) { if(map[sd->bl.m].flag.partylock) - { //Guild locked. + {// Party locked. clif_displaymessage(fd, msg_txt(227)); return; } - if (battle_config.basic_skill_check == 0 || pc_checkskill(sd,NV_BASIC) >= 7) - party_create(sd,(char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27)); - else + if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 7 ) + { clif_skill_fail(sd,1,0,4); + return; + } + + party_create(sd,(char*)RFIFOP(fd,2),RFIFOB(fd,26),RFIFOB(fd,27)); } /*========================================== - * パーティに勧誘 + * Party invitation request + * S 00fc .L + * S 02c4 .24S *------------------------------------------*/ void clif_parse_PartyInvite(int fd, struct map_session_data *sd) { struct map_session_data *t_sd; if(map[sd->bl.m].flag.partylock) - { //Guild locked. + {// Party locked. clif_displaymessage(fd, msg_txt(227)); return; } t_sd = map_id2sd(RFIFOL(fd,2)); - // @noask [LuzZza] - if(t_sd && t_sd->state.noask) { + if(t_sd && t_sd->state.noask) + {// @noask [LuzZza] clif_noask_sub(sd, t_sd, 1); return; } @@ -9771,18 +9781,18 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) { struct map_session_data *t_sd; char *name = (char*)RFIFOP(fd,2); - name[NAME_LENGTH]='\0'; + name[NAME_LENGTH-1] = '\0'; if(map[sd->bl.m].flag.partylock) - { //Guild locked. + {// Party locked. clif_displaymessage(fd, msg_txt(227)); return; } t_sd = map_nick2sd(name); - // @noask [LuzZza] - if(t_sd && t_sd->state.noask) { + if(t_sd && t_sd->state.noask) + {// @noask [LuzZza] clif_noask_sub(sd, t_sd, 1); return; } @@ -11710,7 +11720,7 @@ void clif_Auction_openwindow(struct map_session_data *sd) WFIFOSET(fd,12); } -void clif_Auction_results(struct map_session_data *sd, short count, short pages, unsigned char *buf) +void clif_Auction_results(struct map_session_data *sd, short count, short pages, uint8 *buf) { int i, fd = sd->fd, len = sizeof(struct auction_data); struct auction_data auction; @@ -11729,7 +11739,7 @@ void clif_Auction_results(struct map_session_data *sd, short count, short pages, k = 12 + (i * 83); WFIFOL(fd,k) = auction.auction_id; - safestrncpy(WFIFOP(fd,4+k), auction.seller_name, NAME_LENGTH); + safestrncpy((char*)WFIFOP(fd,4+k), auction.seller_name, NAME_LENGTH); if( (item = itemdb_search(auction.item.nameid)) != NULL && item->view_id > 0 ) WFIFOW(fd,28+k) = item->view_id; @@ -11748,7 +11758,7 @@ void clif_Auction_results(struct map_session_data *sd, short count, short pages, WFIFOW(fd,45+k) = auction.item.card[3]; WFIFOL(fd,47+k) = auction.price; WFIFOL(fd,51+k) = auction.buynow; - safestrncpy(WFIFOP(fd,55+k), auction.buyer_name, NAME_LENGTH); + safestrncpy((char*)WFIFOP(fd,55+k), auction.buyer_name, NAME_LENGTH); WFIFOL(fd,79+k) = auction.timestamp; } WFIFOSET(fd, 12 + (count * 83)); diff --git a/src/map/clif.h b/src/map/clif.h index 8c48b7277..d0a4fe4b4 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -56,7 +56,7 @@ struct s_packet_db { extern struct s_packet_db packet_db[MAX_PACKET_VER+1][MAX_PACKET_DB+1]; // local define -enum send_target { +typedef enum send_target { ALL_CLIENT, ALL_SAMEMAP, AREA, // area @@ -82,7 +82,7 @@ enum send_target { DUEL_WOS, CHAT_MAINCHAT, // everyone on main chat SELF, -}; +} send_target; int clif_setip(const char* ip); void clif_setbindip(const char* ip); @@ -132,7 +132,7 @@ void clif_sitting(struct block_list* bl); void clif_standing(struct block_list* bl); void clif_changelook(struct block_list *bl,int type,int val); // area void clif_changetraplook(struct block_list *bl,int val); // area -void clif_refreshlook(struct block_list *bl,int id,int type,int val,int area); //area specified in 'area' +void clif_refreshlook(struct block_list *bl,int id,int type,int val,enum send_target target); //area specified in 'target' int clif_arrowequip(struct map_session_data *sd,int val); //self int clif_arrow_fail(struct map_session_data *sd,int type); //self int clif_arrow_create_list(struct map_session_data *sd); //self @@ -262,7 +262,7 @@ int clif_item_skill(struct map_session_data *sd,int skillid,int skilllv); int clif_mvp_effect(struct map_session_data *sd); int clif_mvp_item(struct map_session_data *sd,int nameid); int clif_mvp_exp(struct map_session_data *sd, unsigned int exp); -void clif_changed_dir(struct block_list *bl, int area); +void clif_changed_dir(struct block_list *bl, enum send_target target); // vending void clif_openvendingreq(struct map_session_data* sd, int num); @@ -355,7 +355,7 @@ void clif_friendslist_reqack(struct map_session_data *sd, struct map_session_dat // [Valaris] int clif_mob_hp(struct mob_data *md); -int clif_weather(int m); // [Valaris] +void clif_weather(int m); // [Valaris] int clif_specialeffect(struct block_list* bl, int type, enum send_target target); // special effects [Valaris] void clif_specialeffect_single(struct block_list* bl, int type, int fd); int clif_message(struct block_list *bl, const char* msg); // messages (from mobs/npcs) [Valaris] @@ -409,7 +409,7 @@ void clif_Mail_refreshinbox(struct map_session_data *sd); void clif_Mail_getattachment(int fd, uint8 flag); // AUCTION SYSTEM void clif_Auction_openwindow(struct map_session_data *sd); -void clif_Auction_results(struct map_session_data *sd, short count, short pages, unsigned char *buf); +void clif_Auction_results(struct map_session_data *sd, short count, short pages, uint8 *buf); void clif_Auction_message(int fd, unsigned char flag); void clif_Auction_close(int fd, unsigned char flag); void clif_parse_Auction_cancelreg(int fd, struct map_session_data *sd); diff --git a/src/map/guild.c b/src/map/guild.c index ed35aaccb..8413c5c37 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -223,7 +223,7 @@ static int guild_read_castledb(void) /// lookup: guild id -> guild* struct guild* guild_search(int guild_id) { - return idb_get(guild_db,guild_id); + return (struct guild*)idb_get(guild_db,guild_id); } /// lookup: guild name -> guild* @@ -232,7 +232,7 @@ struct guild* guild_searchname(char* str) struct guild* g; DBIterator* iter = guild_db->iterator(guild_db); - for( g = iter->first(iter,NULL); iter->exists(iter); g = iter->next(iter,NULL) ) + for( g = (struct guild*)iter->first(iter,NULL); iter->exists(iter); g = (struct guild*)iter->next(iter,NULL) ) { if( strcmpi(g->name, str) == 0 ) break; @@ -245,7 +245,7 @@ struct guild* guild_searchname(char* str) /// lookup: castle id -> castle* struct guild_castle* guild_castle_search(int gcid) { - return idb_get(castle_db,gcid); + return (struct guild_castle*)idb_get(castle_db,gcid); } /// lookup: map index -> castle* @@ -254,7 +254,7 @@ struct guild_castle* guild_mapindex2gc(short mapindex) struct guild_castle* gc; DBIterator* iter = castle_db->iterator(castle_db); - for( gc = iter->first(iter,NULL); iter->exists(iter); gc = iter->next(iter,NULL) ) + for( gc = (struct guild_castle*)iter->first(iter,NULL); iter->exists(iter); gc = (struct guild_castle*)iter->next(iter,NULL) ) { if( gc->mapindex == mapindex ) break; @@ -460,7 +460,7 @@ int guild_npc_request_info(int guild_id,const char *event) ev=(struct eventlist *)aCalloc(sizeof(struct eventlist),1); memcpy(ev->name,event,strlen(event)); //The one in the db becomes the next event from this. - ev->next=idb_put(guild_infoevent_db,guild_id,ev); + ev->next = (struct eventlist*)idb_put(guild_infoevent_db,guild_id,ev); } return guild_request_info(guild_id); @@ -521,7 +521,8 @@ int guild_recv_info(struct guild *sg) nullpo_retr(0, sg); - if((g=idb_get(guild_db,sg->guild_id))==NULL){ + if((g = (struct guild*)idb_get(guild_db,sg->guild_id))==NULL) + { guild_new = true; g=(struct guild *)aCalloc(1,sizeof(struct guild)); idb_put(guild_db,sg->guild_id,g); @@ -588,7 +589,8 @@ int guild_recv_info(struct guild *sg) } // イベントの発生 - if( (ev=idb_remove(guild_infoevent_db,sg->guild_id))!=NULL ){ + if( (ev = (struct eventlist*)idb_remove(guild_infoevent_db,sg->guild_id))!=NULL ) + { while(ev){ npc_event_do(ev->name); ev2=ev->next; @@ -1141,7 +1143,7 @@ unsigned int guild_payexp(struct map_session_data *sd,unsigned int exp) exp = (unsigned int) exp * per / 100; //Otherwise tax everything. - c = guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd); + c = (struct guild_expcache*)guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd); if (c->exp > UINT_MAX - exp) c->exp = UINT_MAX; @@ -1161,7 +1163,7 @@ int guild_getexp(struct map_session_data *sd,int exp) if (sd->status.guild_id == 0 || (g = guild_search(sd->status.guild_id)) == NULL) return 0; - c = guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd); + c = (struct guild_expcache*)guild_expcache_db->ensure(guild_expcache_db, i2key(sd->status.char_id), create_expcache, sd); if (c->exp > UINT_MAX - exp) c->exp = UINT_MAX; else @@ -1676,10 +1678,10 @@ int guild_addcastleinfoevent(int castle_id,int index,const char *name) if( name==NULL || *name==0 ) return 0; - ev=(struct eventlist *)aMalloc(sizeof(struct eventlist)); + ev = (struct eventlist *)aMalloc(sizeof(struct eventlist)); memcpy(ev->name,name,sizeof(ev->name)); //The next event becomes whatever was currently stored. - ev->next= idb_put(guild_castleinfoevent_db,code,ev); + ev->next = (struct eventlist *)idb_put(guild_castleinfoevent_db,code,ev); return 0; } @@ -1720,7 +1722,9 @@ int guild_castledataloadack(int castle_id,int index,int value) ShowError("guild_castledataloadack ERROR!! (Not found index=%d)\n", index); return 0; } - if( (ev=idb_remove(guild_castleinfoevent_db,code))!=NULL ){ + + if( (ev = (struct eventlist *)idb_remove(guild_castleinfoevent_db,code))!=NULL ) + { while(ev){ npc_event_do(ev->name); ev2=ev->next; diff --git a/src/map/intif.c b/src/map/intif.c index 51bbd740b..b0013aa52 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -585,7 +585,7 @@ int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const cha WFIFOL(inter_fd, 6) = account_id; WFIFOL(inter_fd,10) = char_id; WFIFOB(inter_fd,14) = flag; - safestrncpy(WFIFOP(inter_fd,15),mes,40); + safestrncpy((char*)WFIFOP(inter_fd,15),mes,40); WFIFOSET(inter_fd,55); return 0; } @@ -1702,12 +1702,14 @@ int intif_Auction_requestlist(int char_id, short type, int price, const char* se static void intif_parse_Auction_results(int fd) { struct map_session_data *sd = map_charid2sd(RFIFOL(fd,4)); - short count = RFIFOW(fd,8), pages = RFIFOW(fd,10); + short count = RFIFOW(fd,8); + short pages = RFIFOW(fd,10); + uint8* data = RFIFOP(fd,12); if( sd == NULL ) return; - clif_Auction_results(sd, count, pages, (char *)RFIFOP(fd,12)); + clif_Auction_results(sd, count, pages, data); } int intif_Auction_register(struct auction_data *auction) diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 7d2623fce..d8c767dc8 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -176,7 +176,7 @@ struct item_data* itemdb_exists(int nameid) if( nameid >= 0 && nameid < ARRAYLENGTH(itemdb_array) ) return itemdb_array[nameid]; - item = idb_get(itemdb_other,nameid); + item = (struct item_data*)idb_get(itemdb_other,nameid); if( item == &dummy_item ) return NULL;// dummy data, doesn't exist return item; @@ -279,16 +279,16 @@ struct item_data* itemdb_load(int nameid) if( id == NULL ) { key.i = nameid; - id = itemdb_array[nameid] = create_item_data(key, NULL); + id = itemdb_array[nameid] = (struct item_data*)create_item_data(key, NULL); } return id; } - id = idb_ensure(itemdb_other, nameid, create_item_data); + id = (struct item_data*)idb_ensure(itemdb_other, nameid, create_item_data); if( id == &dummy_item ) {// Remove dummy_item, replace by real data. key.i = nameid; - id = create_item_data(key, NULL); + id = (struct item_data*)create_item_data(key, NULL); idb_put(itemdb_other, nameid, id); } return id; @@ -314,7 +314,7 @@ struct item_data* itemdb_search(int nameid) key.i = nameid; return (struct item_data*)return_dummy_data(key, NULL); } - return idb_ensure(itemdb_other,nameid,return_dummy_data); + return (struct item_data*)idb_ensure(itemdb_other,nameid,return_dummy_data); } /*========================================== diff --git a/src/map/log.c b/src/map/log.c index 0483b6387..5cafcf719 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -426,9 +426,9 @@ int log_config_read(char *cfgName) if(sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) { if(strcmpi(w1,"enable_logs") == 0) { - log_config.enable_logs = (atoi(w2)); + log_config.enable_logs = (log_what)atoi(w2); if (log_config.enable_logs&1) //Log everything. - log_config.enable_logs=0xFFFFFFFF; + log_config.enable_logs = LOG_ALL; } else if(strcmpi(w1,"sql_logs") == 0) { log_config.sql_logs = (bool)atoi(w2); //start of common filter settings diff --git a/src/map/log.h b/src/map/log.h index 758bebd71..9745ce1f0 100644 --- a/src/map/log.h +++ b/src/map/log.h @@ -24,7 +24,7 @@ int log_mvpdrop(struct map_session_data *sd, int monster_id, int *log_mvp); int log_config_read(char *cfgName); -enum log_what { +typedef enum log_what { LOG_ALL = 0xFFF, LOG_TRADES = 0x002, LOG_VENDING = 0x004, @@ -36,7 +36,7 @@ enum log_what { LOG_USED_ITEMS = 0x100, // used by player LOG_MVP_PRIZE = 0x200, LOG_COMMAND_ITEMS = 0x400 // created/deleted through @/# commands -}; +} log_what; extern struct Log_Config { enum log_what enable_logs; diff --git a/src/map/map.c b/src/map/map.c index 83f6b855e..33a5343c4 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -951,7 +951,7 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int m,int x0,int y if (length) { //Adjust final position to fit in the given area. //TODO: Find an alternate method which does not requires a square root calculation. - k = (int)sqrt(magnitude2); + k = (int)sqrt((float)magnitude2); mx1 = x0 + (x1 - x0)*length/k; my1 = y0 + (y1 - y0)*length/k; len_limit = MAGNITUDE2(x0,y0, mx1,my1); @@ -1449,7 +1449,7 @@ void map_addnickdb(int charid, const char* nick) if( map_charid2sd(charid) ) return;// already online - p = idb_ensure(nick_db, charid, create_charid2nick); + p = (struct charid2nick*)idb_ensure(nick_db, charid, create_charid2nick); safestrncpy(p->nick, nick, sizeof(p->nick)); while( p->requests ) @@ -1471,7 +1471,7 @@ void map_delnickdb(int charid, const char* name) struct charid_request* req; struct map_session_data* sd; - p = idb_remove(nick_db, charid); + p = (struct charid2nick*)idb_remove(nick_db, charid); if( p == NULL ) return; @@ -1734,7 +1734,7 @@ struct block_list * map_id2bl(int id) if(id >= 0 && id < ARRAYLENGTH(objects)) bl = objects[id]; else - bl = idb_get(id_db,id); + bl = (struct block_list*)idb_get(id_db,id); return bl; } @@ -2149,7 +2149,7 @@ int map_random_dir(struct block_list *bl, short *x, short *y) short yi = *y-bl->y; short i=0, j; int dist2 = xi*xi + yi*yi; - short dist = (short)sqrt(dist2); + short dist = (short)sqrt((float)dist2); short segment; if (dist < 1) dist =1; @@ -2158,7 +2158,7 @@ int map_random_dir(struct block_list *bl, short *x, short *y) j = rand()%8; //Pick a random direction segment = 1+(rand()%dist); //Pick a random interval from the whole vector in that direction xi = bl->x + segment*dirx[j]; - segment = (short)sqrt(dist2 - segment*segment); //The complement of the previously picked segment + segment = (short)sqrt((float)(dist2 - segment*segment)); //The complement of the previously picked segment yi = bl->y + segment*diry[j]; } while ( (map_getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH)) @@ -2385,7 +2385,7 @@ int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port) { struct map_data_other_server *mdos; - mdos = uidb_get(map_db,(unsigned int)mapindex); + mdos = (struct map_data_other_server*)uidb_get(map_db,(unsigned int)mapindex); if(!mdos || mdos->cell) //Map either does not exists or is a local map. return 0; @@ -2432,8 +2432,8 @@ int map_readfromcache(struct map_data *m, FILE *fp) m->ys = info.ys; size = info.xs*info.ys; - buf = aMalloc(info.len); // temp buffer to read the zipped map - buf2 = aMalloc(size); // temp buffer to unpack the data + buf = (unsigned char*)aMalloc(info.len); // temp buffer to read the zipped map + buf2 = (unsigned char*)aMalloc(size); // temp buffer to unpack the data CREATE(m->cell, struct mapcell, size); fread(buf, info.len, 1, fp); diff --git a/src/map/map.h b/src/map/map.h index bf168b20c..1dbc4581a 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -176,11 +176,12 @@ enum bl_type { BL_SKILL = 0x020, BL_NPC = 0x040, BL_CHAT = 0x080, + + BL_ALL = 0xFFF, }; //For common mapforeach calls. Since pets cannot be affected, they aren't included here yet. #define BL_CHAR (BL_PC|BL_MOB|BL_HOM) -#define BL_ALL 0xfff enum npc_subtype { WARP, SHOP, SCRIPT, CASHSHOP }; @@ -228,6 +229,7 @@ struct block_list { enum bl_type type; }; + // Mob List Held in memory for Dynamic Mobs [Wizputer] // Expanded to specify all mob-related spawn data by [Skotlex] struct spawn_data { @@ -248,6 +250,7 @@ struct spawn_data { + struct flooritem_data { struct block_list bl; unsigned char subx,suby; diff --git a/src/map/mercenary.c b/src/map/mercenary.c index 039a7f446..66658a1d9 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -606,7 +606,7 @@ int merc_hom_alloc(struct map_session_data *sd, struct s_homunculus *hom) intif_homunculus_requestdelete(hom->hom_id); return 1; } - sd->hd = hd = aCalloc(1,sizeof(struct homun_data)); + 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(); diff --git a/src/map/mercenary.h b/src/map/mercenary.h index 2e90786cd..88692b4d1 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -7,18 +7,21 @@ #include "status.h" // struct status_data, struct status_change #include "unit.h" // struct unit_data +struct h_stats { + unsigned int HP, SP; + unsigned short str, agi, vit, int_, dex, luk; +}; + struct s_homunculus_db { int base_class, evo_class; char name[NAME_LENGTH]; - struct h_stats { - unsigned int HP, SP; - unsigned short str, agi, vit, int_, dex, luk; - } base, gmin, gmax, emin, emax; + struct h_stats base, gmin, gmax, emin, emax; int foodID ; int baseASPD ; long hungryDelay ; unsigned char element, race, base_size, evo_size; }; + extern struct s_homunculus_db homuncumlus_db[MAX_HOMUNCULUS_CLASS]; enum { HOMUNCULUS_CLASS, HOMUNCULUS_FOOD }; enum { diff --git a/src/map/mob.c b/src/map/mob.c index bd9ed5d43..6463c2103 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -209,7 +209,7 @@ int mob_parse_dataset(struct spawn_data *data) *------------------------------------------*/ struct mob_data* mob_spawn_dataset(struct spawn_data *data) { - struct mob_data *md = aCalloc(1, sizeof(struct mob_data)); + struct mob_data *md = (struct mob_data*)aCalloc(1, sizeof(struct mob_data)); md->bl.id= npc_get_new_npc_id(); md->bl.type = BL_MOB; md->bl.m = data->m; @@ -419,7 +419,7 @@ int mob_once_spawn(struct map_session_data* sd, int m, short x, short y, const c struct guild_castle* gc = guild_mapindex2gc(map[m].index); struct guild* g = gc?guild_search(gc->guild_id):NULL; if(gc) { - md->guardian_data = aCalloc(1, sizeof(struct guardian_data)); + md->guardian_data = (struct guardian_data*)aCalloc(1, sizeof(struct guardian_data)); md->guardian_data->castle = gc; md->guardian_data->number = MAX_GUARDIANS; md->guardian_data->guild_id = gc->guild_id; @@ -586,7 +586,7 @@ void mob_barricade_get(struct map_session_data *sd) return; iter = barricade_db->iterator(barricade_db); - for( barricade = iter->first(iter,&key); iter->exists(iter); barricade = iter->next(iter,&key) ) + for( barricade = (struct barricade_data *)iter->first(iter,&key); iter->exists(iter); barricade = (struct barricade_data *)iter->next(iter,&key) ) { if( sd->bl.m != barricade->m ) continue; @@ -655,7 +655,7 @@ void mod_barricade_clearall(void) int i; iter = barricade_db->iterator(barricade_db); - for( barricade = iter->first(iter,&key); iter->exists(iter); barricade = iter->next(iter,&key) ) + for( barricade = (struct barricade_data *)iter->first(iter,&key); iter->exists(iter); barricade = (struct barricade_data *)iter->next(iter,&key) ) { for( i = 0; i < barricade->count; i++ ) { @@ -789,8 +789,8 @@ int mob_spawn_guardian(const char* mapname, short x, short y, const char* mobnam } } - md= mob_spawn_dataset(&data); - md->guardian_data = aCalloc(1, sizeof(struct guardian_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; md->guardian_data->castle = gc; @@ -3539,7 +3539,7 @@ static bool mob_parse_dbrow(char** str) } if (mob_db_data[class_] == NULL) - mob_db_data[class_] = aCalloc(1, sizeof (struct mob_db)); + mob_db_data[class_] = (struct mob_db*)aCalloc(1, sizeof (struct mob_db)); db = mob_db_data[class_]; status = &db->status; @@ -4379,7 +4379,7 @@ 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] = aCalloc(1, sizeof (struct mob_db)); //This mob is used for random spawns + 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)); item_drop_list_ers = ers_new(sizeof(struct item_drop_list)); diff --git a/src/map/npc.c b/src/map/npc.c index 09f101983..51c95cee0 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -113,7 +113,7 @@ int npc_enable_sub(struct block_list *bl, va_list ap) int npc_enable(const char* name, int flag) { - struct npc_data* nd = strdb_get(npcname_db, name); + struct npc_data* nd = (struct npc_data*)strdb_get(npcname_db, name); if (nd==NULL) return 0; @@ -559,7 +559,7 @@ void npc_timerevent_quit(struct map_session_data* sd) char buf[NAME_LENGTH*2+3]; struct event_data *ev; snprintf(buf, ARRAYLENGTH(buf), "%s::OnTimerQuit", nd->exname); - ev = strdb_get(ev_db, buf); + ev = (struct event_data*)strdb_get(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); ev = NULL; @@ -659,7 +659,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 mob_kill) { - struct event_data* ev = strdb_get(ev_db, eventname); + struct event_data* ev = (struct event_data*)strdb_get(ev_db, eventname); struct npc_data *nd; int xs,ys; char mobevent[100]; @@ -676,7 +676,7 @@ int npc_event(struct map_session_data* sd, const char* eventname, int mob_kill) if (mob_kill) { strcpy( mobevent, eventname); strcat( mobevent, "::OnMyMobDead"); - ev = strdb_get(ev_db, mobevent); + ev = (struct event_data*)strdb_get(ev_db, mobevent); if (ev == NULL || (nd = ev->nd) == NULL) { ShowError("npc_event: (mob_kill) event not found [%s]\n", mobevent); return 0; @@ -2331,7 +2331,7 @@ static const char* npc_parse_mob(char* w1, char* w2, char* w3, char* w4, const c //Now that all has been validated. We allocate the actual memory //that the re-spawn data will use. - data = aMalloc(sizeof(struct spawn_data)); + data = (struct spawn_data*)aMalloc(sizeof(struct spawn_data)); memcpy(data, &mob, sizeof(struct spawn_data)); if( !battle_config.dynamic_mobs ) { @@ -2632,7 +2632,7 @@ void npc_parsesrcfile(const char* filepath) lines++; // w1w2w3w4 - count = sv_parse(p, len+buffer-p, 0, '\t', pos, ARRAYLENGTH(pos), SV_TERMINATE_LF|SV_TERMINATE_CRLF); + count = sv_parse(p, len+buffer-p, 0, '\t', pos, ARRAYLENGTH(pos), (e_svopt)(SV_TERMINATE_LF|SV_TERMINATE_CRLF)); if( count < 0 ) { ShowError("npc_parsesrcfile: Parse error in file '%s', line '%d'. Stopping...\n", filepath, strline(buffer,p-buffer)); @@ -2810,7 +2810,7 @@ int npc_reload(void) //Remove all npcs/mobs. [Skotlex] iter = mapit_geteachiddb(); - for( bl = mapit_first(iter); mapit_exists(iter); bl = mapit_next(iter) ) + for( bl = (struct block_list*)mapit_first(iter); mapit_exists(iter); bl = (struct block_list*)mapit_next(iter) ) { switch(bl->type) { case BL_NPC: @@ -2954,7 +2954,7 @@ int do_init_npc(void) for( i = 1; i < MAX_NPC_CLASS; i++ ) npc_viewdb[i].class_ = i; - ev_db = strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1); + ev_db = strdb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA),2*NAME_LENGTH+2+1); npcname_db = strdb_alloc(DB_OPT_BASE,NAME_LENGTH); timer_event_ers = ers_new(sizeof(struct timer_event_data)); diff --git a/src/map/party.c b/src/map/party.c index 8e97d1f05..2d81e155c 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -86,7 +86,7 @@ struct party_data* party_search(int party_id) { if(!party_id) return NULL; - return idb_get(party_db,party_id); + return (struct party_data*)idb_get(party_db,party_id); } /// Party data lookup using party name. @@ -95,7 +95,7 @@ struct party_data* party_searchname(const char* str) struct party_data* p; DBIterator* iter = party_db->iterator(party_db); - for( p = iter->first(iter,NULL); iter->exists(iter); p = iter->next(iter,NULL) ) + for( p = (struct party_data*)iter->first(iter,NULL); iter->exists(iter); p = (struct party_data*)iter->next(iter,NULL) ) { if( strncmpi(p->party.name,str,NAME_LENGTH) == 0 ) break; @@ -235,7 +235,7 @@ int party_recv_info(struct party *sp) nullpo_retr(0, sp); - p= idb_ensure(party_db, sp->party_id, create_party); + p = (struct party_data*)idb_ensure(party_db, sp->party_id, create_party); if (!p->party.party_id) //party just received. { party_new = true; @@ -726,7 +726,7 @@ int party_send_xy_timer(int tid,unsigned int tick,int id,int data) DBIterator* iter = party_db->iterator(party_db); // for each existing party, - for( p = iter->first(iter,NULL); iter->exists(iter); p = iter->next(iter,NULL) ) + for( p = (struct party_data*)iter->first(iter,NULL); iter->exists(iter); p = (struct party_data*)iter->next(iter,NULL) ) { int i; // for each member of this party, diff --git a/src/map/pc.c b/src/map/pc.c index 86d9f186d..838de158d 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1339,7 +1339,7 @@ void pc_autoscript_clear(struct s_autoscript *scripts, int max) memset(scripts, 0, i*sizeof(struct s_autoscript)); } -static int pc_bonus_autospell_del(struct s_autospell *spell, int max, short id, short lv, short rate, short card_id) +static int pc_bonus_autospell_del(struct s_autospell* spell, int max, short id, short lv, short rate, short card_id) { int i, j; for(i=max-1; i>=0 && !spell[i].id; i--); @@ -1405,7 +1405,7 @@ static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, shor return 1; } -static int pc_bonus_addeff(struct s_addeffect* effect, int max, short id, short rate, short arrow_rate, unsigned char flag) +static int pc_bonus_addeff(struct s_addeffect* effect, int max, enum sc_type id, short rate, short arrow_rate, unsigned char flag) { int i; if (!(flag&(ATF_SHORT|ATF_LONG))) @@ -2081,7 +2081,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) ShowWarning("pc_bonus2 (Add Effect): %d is not supported.\n", type2); break; } - pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), type2, + pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2, sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, 0); break; case SP_ADDEFF2: @@ -2089,7 +2089,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) ShowWarning("pc_bonus2 (Add Effect2): %d is not supported.\n", type2); break; } - pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), type2, + pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2, sd->state.lr_flag!=2?val:0, sd->state.lr_flag==2?val:0, ATF_SELF); break; case SP_RESEFF: @@ -2304,7 +2304,7 @@ int pc_bonus2(struct map_session_data *sd,int type,int type2,int val) break; } if(sd->state.lr_flag != 2) - pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), type2, val, 0, 0); + pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, val, 0, 0); break; case SP_SKILL_ATK: if(sd->state.lr_flag == 2) @@ -2548,7 +2548,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) ShowWarning("pc_bonus3 (Add Effect): %d is not supported.\n", type2); break; } - pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), type2, + pc_bonus_addeff(sd->addeff, ARRAYLENGTH(sd->addeff), (sc_type)type2, sd->state.lr_flag!=2?type3:0, sd->state.lr_flag==2?type3:0, val); break; @@ -2558,7 +2558,7 @@ int pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) break; } if(sd->state.lr_flag != 2) - pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), type2, type3, 0, val); + pc_bonus_addeff(sd->addeff2, ARRAYLENGTH(sd->addeff2), (sc_type)type2, type3, 0, val); break; default: @@ -3757,7 +3757,7 @@ int pc_checkskill(struct map_session_data *sd,int skill_id) *------------------------------------------*/ int pc_checkallowskill(struct map_session_data *sd) { - const int scw_list[] = { + const enum sc_type scw_list[] = { SC_TWOHANDQUICKEN, SC_ONEHAND, SC_AURABLADE, @@ -3767,7 +3767,7 @@ int pc_checkallowskill(struct map_session_data *sd) SC_ADRENALINE2, SC_GATLINGFEVER }; - const int scs_list[] = { + const enum sc_type scs_list[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD @@ -5624,12 +5624,12 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper) if ((b_class&&MAPID_UPPERMASK) != (sd->class_&MAPID_UPPERMASK)) { //Things to remove when changing class tree. const int class_ = pc_class2idx(sd->status.class_); - int id; + short id; for(i = 0; i < MAX_SKILL_TREE && (id = skill_tree[class_][i].id) > 0; i++) { //Remove status specific to your current tree skills. - id = status_skill2sc(id); - if (id > SC_COMMON_MAX && sd->sc.data[id]) - status_change_end(&sd->bl, id, -1); + enum sc_type sc = status_skill2sc(id); + if (sc > SC_COMMON_MAX && sd->sc.data[sc]) + status_change_end(&sd->bl, sc, -1); } } diff --git a/src/map/pc.h b/src/map/pc.h index a7d30d1ce..245ecd686 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -45,6 +45,26 @@ struct weapon_data { } add_dmg[MAX_PC_BONUS]; }; +struct s_autospell { + short id, lv, rate, card_id, flag; +}; + +struct s_addeffect { + enum sc_type id; + short rate, arrow_rate; + unsigned char flag; +}; + +struct s_add_drop { + short id, group; + int race, rate; +}; + +struct s_autoscript { + unsigned short rate, flag; + struct script_code *script; +}; + struct map_session_data { struct block_list bl; struct unit_data ud; @@ -185,13 +205,8 @@ struct map_session_data { short sp_gain_race[RC_MAX]; // zeroed arrays end here. // zeroed structures start here - struct s_autospell{ - short id, lv, rate, card_id, flag; - } autospell[15], autospell2[15]; - struct s_addeffect{ - short id, rate, arrow_rate; - unsigned char flag; - } addeff[MAX_PC_BONUS], addeff2[MAX_PC_BONUS]; + struct s_autospell autospell[15], autospell2[15]; + struct s_addeffect addeff[MAX_PC_BONUS], addeff2[MAX_PC_BONUS]; struct { //skillatk raises bonus dmg% of skills, skillheal increases heal%, skillblown increases bonus blewcount for some skills. unsigned short id; short val; @@ -203,22 +218,15 @@ struct map_session_data { } hp_loss, sp_loss, hp_regen, sp_regen; struct { short class_, rate; - } add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS], - add_mdmg[MAX_PC_BONUS]; - struct s_add_drop { - short id, group; - int race, rate; - } add_drop[MAX_PC_BONUS]; + } add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS], add_mdmg[MAX_PC_BONUS]; + struct s_add_drop add_drop[MAX_PC_BONUS]; struct { int nameid; int rate; } itemhealrate[MAX_PC_BONUS]; // zeroed structures end here // manually zeroed structures start here. - struct s_autoscript { - unsigned short rate, flag; - struct script_code *script; - } autoscript[10], autoscript2[10]; //Auto script on attack, when attacked + struct s_autoscript autoscript[10], autoscript2[10]; //Auto script on attack, when attacked // manually zeroed structures end here. // zeroed vars start here. int arrow_atk,arrow_ele,arrow_cri,arrow_hit; @@ -382,15 +390,15 @@ enum weapon_type { W_DOUBLE_SA, // sword + axe }; -enum { +enum ammo_type { A_ARROW = 1, - A_DAGGER, //2 + A_DAGGER, //2 A_BULLET, //3 A_SHELL, //4 A_GRENADE, //5 A_SHURIKEN, //6 A_KUNAI //7 -} ammo_type; +}; //Equip position constants enum equip_pos { @@ -415,7 +423,7 @@ enum equip_pos { //Equip indexes constants. (eg: sd->equip_index[EQI_AMMO] returns the index //where the arrows are equipped) -enum { +enum equip_index { EQI_ACC_L = 0, EQI_ACC_R, EQI_SHOES, @@ -428,7 +436,7 @@ enum { EQI_HAND_R, EQI_AMMO, EQI_MAX -} equip_index_enum; +}; struct duel { int members_count; diff --git a/src/map/pet.h b/src/map/pet.h index eeb48f018..86b9080eb 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -33,6 +33,43 @@ extern struct s_pet_db pet_db[MAX_PET_DB]; enum { PET_CLASS,PET_CATCH,PET_EGG,PET_EQUIP,PET_FOOD }; +struct pet_recovery { //Stat recovery + enum sc_type type; //Status Change id + unsigned short delay; //How long before curing (secs). + int timer; +}; + +struct pet_bonus { + unsigned short type; //bStr, bVit? + unsigned short val; //Qty + unsigned short duration; //in secs + unsigned short delay; //Time before recasting (secs) + int timer; +}; + +struct pet_skill_attack { //Attack Skill + unsigned short id; + unsigned short lv; + unsigned short div_; //0 = Normal skill. >0 = Fixed damage (lv), fixed div_. + unsigned short rate; //Base chance of skill ocurrance (10 = 10% of attacks) + unsigned short bonusrate; //How being 100% loyal affects cast rate (10 = At 1000 intimacy->rate+10% +}; + +struct pet_skill_support { //Support Skill + unsigned short id; + unsigned short lv; + unsigned short hp; //Max HP% for skill to trigger (50 -> 50% for Magnificat) + unsigned short sp; //Max SP% for skill to trigger (100 = no check) + unsigned short delay; //Time (secs) between being able to recast. + int timer; +}; + +struct pet_loot { + struct item *item; + unsigned short count; + unsigned short weight; + unsigned short max; +}; struct pet_data { struct block_list bl; @@ -51,43 +88,11 @@ struct pet_data { unsigned int next_walktime,last_thinktime; short rate_fix; //Support rate as modified by intimacy (1000 = 100%) [Skotlex] - struct pet_recovery { //Stat recovery - unsigned short type; //Status Change id - unsigned short delay; //How long before curing (secs). - int timer; - } *recovery; //[Valaris] / Reimplemented by [Skotlex] - - struct pet_bonus { - unsigned short type; //bStr, bVit? - unsigned short val; //Qty - unsigned short duration; //in secs - unsigned short delay; //Time before recasting (secs) - int timer; - } *bonus; //[Valaris] / Reimplemented by [Skotlex] - - struct pet_skill_attack { //Attack Skill - unsigned short id; - unsigned short lv; - unsigned short div_; //0 = Normal skill. >0 = Fixed damage (lv), fixed div_. - unsigned short rate; //Base chance of skill ocurrance (10 = 10% of attacks) - unsigned short bonusrate; //How being 100% loyal affects cast rate (10 = At 1000 intimacy->rate+10% - } *a_skill; //[Skotlex] - - struct pet_skill_support { //Support Skill - unsigned short id; - unsigned short lv; - unsigned short hp; //Max HP% for skill to trigger (50 -> 50% for Magnificat) - unsigned short sp; //Max SP% for skill to trigger (100 = no check) - unsigned short delay; //Time (secs) between being able to recast. - int timer; - } *s_skill; //[Skotlex] - - struct pet_loot { - struct item *item; - unsigned short count; - unsigned short weight; - unsigned short max; - } *loot; //[Valaris] / Rewritten by [Skotlex] + struct pet_recovery* recovery; + struct pet_bonus* bonus; + struct pet_skill_attack* a_skill; + struct pet_skill_support* s_skill; + struct pet_loot* loot; struct map_session_data *msd; }; diff --git a/src/map/script.c b/src/map/script.c index 9aa292e63..339afb495 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -30,6 +30,7 @@ #include "mercenary.h" //[orn] #include "intif.h" #include "skill.h" +#include "status.h" #include "chat.h" #include "battle.h" #include "party.h" @@ -251,14 +252,16 @@ char mapregsql_db_index[32] = "index"; char mapregsql_db_value[32] = "value"; #endif -int get_com(unsigned char *script,int *pos); +c_op get_com(unsigned char *script,int *pos); int get_num(unsigned char *script,int *pos); -struct script_function { +typedef struct script_function { int (*func)(struct script_state *st); const char *name; const char *arg; -} buildin_func[]; +} script_function; + +extern script_function buildin_func[]; static struct linkdb_node *sleep_db; #define not_server_variable(prefix) ( (prefix) != '$' && (prefix) != '.') @@ -1851,7 +1854,7 @@ void script_error(const char *src,const char *file,int start_line, const char *e const char *linestart[5] = { NULL, NULL, NULL, NULL, NULL }; for(p=src;p && *p;line++){ - char *lineend=strchr(p,'\n'); + const char *lineend=strchr(p,'\n'); if(lineend==NULL || error_posref ? data->ref: name[1] == '@' ? st->stack->var_function:// instance/scope variable &st->script->script_vars;// npc variable - data->u.str = linkdb_search(n, (void*)reference_getuid(data)); + data->u.str = (char*)linkdb_search(n, (void*)reference_getuid(data)); } break; default: @@ -2234,7 +2237,7 @@ void get_val(struct script_state* st, struct script_data* data) return; } -void push_val2(struct script_stack* stack, int type, int val, struct linkdb_node** ref); +void push_val2(struct script_stack* stack, enum c_op type, int val, struct linkdb_node** ref); /// Retrieves the value of a reference identified by uid (variable, constant, param) /// The value is left in the top of the stack and needs to be removed manually. @@ -2271,7 +2274,7 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, char* name, con char* p; struct linkdb_node** n; n = (ref) ? ref : (name[1] == '@') ? st->stack->var_function : &st->script->script_vars; - p = linkdb_erase(n, (void*)num); + p = (char*)linkdb_erase(n, (void*)num); if (p) aFree(p); if (str[0]) linkdb_insert(n, (void*)num, aStrdup(str)); } @@ -2423,7 +2426,7 @@ void stack_expand(struct script_stack* stack) #define push_val(stack,type,val) push_val2(stack, type, val, NULL) /// Pushes a value into the stack (with reference) -void push_val2(struct script_stack* stack, int type, int val, struct linkdb_node** ref) +void push_val2(struct script_stack* stack, enum c_op type, int val, struct linkdb_node** ref) { if( stack->sp >= stack->sp_max ) stack_expand(stack); @@ -2434,7 +2437,7 @@ void push_val2(struct script_stack* stack, int type, int val, struct linkdb_node } /// Pushes a string into the stack -void push_str(struct script_stack* stack, int type, char* str) +void push_str(struct script_stack* stack, enum c_op type, char* str) { if( stack->sp >= stack->sp_max ) stack_expand(stack); @@ -2549,35 +2552,18 @@ void script_free_code(struct script_code* code) /*========================================== * コマンドの読み取り *------------------------------------------*/ -static int unget_com_data=-1; -int get_com(unsigned char *script,int *pos) +c_op get_com(unsigned char *script,int *pos) { - int i,j; - if(unget_com_data>=0){ - i=unget_com_data; - unget_com_data=-1; - return i; - } + int i = 0, j = 0; + if(script[*pos]>=0x80){ return C_INT; } - i=0; j=0; while(script[*pos]>=0x40){ i=script[(*pos)++]<st; } else { - st = aCalloc(sizeof(struct script_state), 1); + st = (struct script_state*)aCalloc(sizeof(struct script_state), 1); // the script is different, make new script_state and stack - st->stack = aMalloc (sizeof(struct script_stack)); + st->stack = (struct script_stack*)aMalloc (sizeof(struct script_stack)); st->stack->sp=0; st->stack->sp_max=64; st->stack->stack_data = (struct script_data *)aCalloc(st->stack->sp_max,sizeof(st->stack->stack_data[0])); st->stack->defsp = st->stack->sp; - st->stack->var_function = aCalloc(1, sizeof(struct linkdb_node*)); + st->stack->var_function = (struct linkdb_node**)aCalloc(1, sizeof(struct linkdb_node*)); st->state = RUN; st->script = rootscript; } @@ -3056,7 +3042,6 @@ int run_script_timer(int tid, unsigned int tick, int id, int data) *------------------------------------------*/ void run_script_main(struct script_state *st) { - int c; int cmdcount=script_config.check_cmdcount; int gotocount=script_config.check_gotocount; TBL_PC *sd; @@ -3084,8 +3069,9 @@ void run_script_main(struct script_state *st) } else if(st->state != END) st->state = RUN; - while(st->state == RUN){ - c= get_com(st->script->script_buf,&st->pos); + while(st->state == RUN) + { + enum c_op c = get_com(st->script->script_buf,&st->pos); switch(c){ case C_EOL: if( stack->sp != stack->defsp ) @@ -3623,7 +3609,7 @@ int do_init_script() mapreg_db= idb_alloc(DB_OPT_BASE); mapregstr_db=idb_alloc(DB_OPT_RELEASE_DATA); userfunc_db=strdb_alloc(DB_OPT_DUP_KEY,0); - scriptlabel_db=strdb_alloc(DB_OPT_DUP_KEY|DB_OPT_ALLOW_NULL_DATA,50); + scriptlabel_db=strdb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_ALLOW_NULL_DATA),50); script_load_mapreg(); @@ -4039,7 +4025,7 @@ BUILDIN_FUNC(callfunc) struct script_code *scr, *oldscr; const char* str = script_getstr(st,2); - scr = strdb_get(userfunc_db, str); + scr = (struct script_code*)strdb_get(userfunc_db, str); if( !scr ) { ShowError("script:callfunc: function not found! [%s]\n", str); @@ -8097,12 +8083,12 @@ BUILDIN_FUNC(hideonnpc) BUILDIN_FUNC(sc_start) { struct block_list* bl; - int type; + enum sc_type type; int tick; int val1; int val4 = 0; - type = script_getnum(st,2); + type = (sc_type)script_getnum(st,2); tick = script_getnum(st,3); val1 = script_getnum(st,4); if( script_hasdata(st,5) ) @@ -8110,7 +8096,7 @@ BUILDIN_FUNC(sc_start) else bl = map_id2bl(st->rid); - if( tick == 0 && val1 > 0 && type >= 0 && type < SC_MAX && status_sc2skill(type) != 0 ) + if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0 ) {// When there isn't a duration specified, try to get it from the skill_db tick = skill_get_time(status_sc2skill(type), val1); } @@ -8124,6 +8110,7 @@ BUILDIN_FUNC(sc_start) if( bl ) status_change_start(bl, type, 10000, val1, 0, 0, val4, tick, 2); + return 0; } @@ -8133,13 +8120,13 @@ BUILDIN_FUNC(sc_start) BUILDIN_FUNC(sc_start2) { struct block_list* bl; - int type; + enum sc_type type; int tick; int val1; int val4 = 0; int rate; - type = script_getnum(st,2); + type = (sc_type)script_getnum(st,2); tick = script_getnum(st,3); val1 = script_getnum(st,4); rate = script_getnum(st,5); @@ -8148,7 +8135,7 @@ BUILDIN_FUNC(sc_start2) else bl = map_id2bl(st->rid); - if( tick == 0 && val1 > 0 && type >= 0 && type < SC_MAX && status_sc2skill(type) != 0 ) + if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0 ) {// When there isn't a duration specified, try to get it from the skill_db tick = skill_get_time(status_sc2skill(type), val1); } @@ -8172,14 +8159,14 @@ BUILDIN_FUNC(sc_start2) BUILDIN_FUNC(sc_start4) { struct block_list* bl; - int type; + enum sc_type type; int tick; int val1; int val2; int val3; int val4; - type = script_getnum(st,2); + type = (sc_type)script_getnum(st,2); tick = script_getnum(st,3); val1 = script_getnum(st,4); val2 = script_getnum(st,5); @@ -8190,7 +8177,7 @@ BUILDIN_FUNC(sc_start4) else bl = map_id2bl(st->rid); - if( tick == 0 && val1 > 0 && type >= 0 && type < SC_MAX && status_sc2skill(type) != 0 ) + if( tick == 0 && val1 > 0 && type > SC_NONE && type < SC_MAX && status_sc2skill(type) != 0 ) {// When there isn't a duration specified, try to get it from the skill_db tick = skill_get_time(status_sc2skill(type), val1); } @@ -8235,7 +8222,7 @@ BUILDIN_FUNC(sc_end) if (!sce) return 0; //This should help status_change_end force disabling the SC in case it has no limit. sce->val1 = sce->val2 = sce->val3 = sce->val4 = 0; - status_change_end(bl, type, INVALID_TIMER); + status_change_end(bl, (sc_type)type, INVALID_TIMER); } else status_change_clear(bl, 2);// remove all effects return 0; @@ -8257,7 +8244,7 @@ BUILDIN_FUNC(getscrate) bl = map_id2bl(st->rid); if (bl) - rate = status_get_sc_def(bl,type, 10000, 10000, 0); + rate = status_get_sc_def(bl, (sc_type)type, 10000, 10000, 0); script_pushint(st,rate); return 0; @@ -9193,7 +9180,7 @@ BUILDIN_FUNC(getcastlename) { const char* mapname = mapindex_getmapname(script_getstr(st,2),NULL); struct guild_castle* gc = guild_mapname2gc(mapname); - char* name = (gc) ? gc->castle_name : ""; + const char* name = (gc) ? gc->castle_name : ""; script_pushstrcopy(st,name); return 0; } @@ -10309,9 +10296,8 @@ BUILDIN_FUNC(petrecovery) } else //Init pd->recovery = (struct pet_recovery *)aMalloc(sizeof(struct pet_recovery)); - pd->recovery->type=script_getnum(st,2); + pd->recovery->type=(sc_type)script_getnum(st,2); pd->recovery->delay=script_getnum(st,3); - pd->recovery->timer=-1; return 0; @@ -10484,11 +10470,13 @@ BUILDIN_FUNC(npcskilleffect) BUILDIN_FUNC(specialeffect) { struct block_list *bl=map_id2bl(st->oid); + int type = script_getnum(st,2); + enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA; if(bl==NULL) return 0; - clif_specialeffect(bl,script_getnum(st,2), (script_hasdata(st,3)?script_getnum(st,3):AREA)); + clif_specialeffect(bl, type, target); return 0; } @@ -10496,11 +10484,13 @@ BUILDIN_FUNC(specialeffect) BUILDIN_FUNC(specialeffect2) { TBL_PC *sd=script_rid2sd(st); + int type = script_getnum(st,2); + enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA; if(sd==NULL) return 0; - clif_specialeffect(&sd->bl,script_getnum(st,2), (script_hasdata(st,3)?script_getnum(st,3):AREA)); + clif_specialeffect(&sd->bl, type, target); return 0; } @@ -11651,7 +11641,7 @@ BUILDIN_FUNC(checkcell) const char *map = script_getstr(st, 2); m = mapindex_name2id(map); if(m){ - script_pushint(st,map_getcell(m, script_getnum(st,3), script_getnum(st,4),script_getnum(st,5))); + script_pushint(st,map_getcell(m, script_getnum(st,3), script_getnum(st,4),(cell_chk)script_getnum(st,5))); } else { script_pushint(st,0); } @@ -11831,7 +11821,7 @@ BUILDIN_FUNC(escape_sql) str = script_getstr(st,2); len = strlen(str); - esc_str = aMallocA(len*2+1); + esc_str = (char*)aMallocA(len*2+1); #if defined(TXT_ONLY) jstrescapecpy(esc_str, str); #else diff --git a/src/map/script.h b/src/map/script.h index b9e5fdb01..943ce3a4d 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -25,7 +25,7 @@ extern struct Script_Config { const char *joblvup_event_name; } script_config; -enum c_op { +typedef enum c_op { C_NOP, // end of script/no value (nil) C_POS, C_INT, // number @@ -63,7 +63,7 @@ enum c_op { C_NOT, // ~ a C_R_SHIFT, // a >> b C_L_SHIFT // a << b -}; +} c_op; struct script_data { enum c_op type; diff --git a/src/map/skill.c b/src/map/skill.c index 3095874f4..df5c8deff 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -408,6 +408,7 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int struct status_data *sstatus, *tstatus; struct status_change *sc, *tsc; + enum sc_type status; int skill; int rate; @@ -523,9 +524,9 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int break; case AS_GRIMTOOTH: - skill = dstsd?SC_SLOWDOWN:SC_STOP; - if (!tsc->data[skill]) - sc_start(bl,skill,100,skilllv,skill_get_time2(skillid, skilllv)); + status = dstsd?SC_SLOWDOWN:SC_STOP; + if (!tsc->data[status]) + sc_start(bl,status,100,skilllv,skill_get_time2(skillid, skilllv)); break; case WZ_FIREPILLAR: @@ -705,9 +706,9 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int break; case LK_JOINTBEAT: - skill = status_skill2sc(skillid); + status = status_skill2sc(skillid); if (tsc->jb_flag) { - sc_start2(bl,skill,(5*skilllv+5),skilllv,tsc->jb_flag&BREAK_FLAGS,skill_get_time2(skillid,skilllv)); + sc_start2(bl,status,(5*skilllv+5),skilllv,tsc->jb_flag&BREAK_FLAGS,skill_get_time2(skillid,skilllv)); tsc->jb_flag = 0; } break; @@ -807,7 +808,8 @@ int skill_additional_effect (struct block_list* src, struct block_list *bl, int skillid != CR_REFLECTSHIELD && skillid != ASC_BREAKER ){ //Trigger status effects - int i, type; + enum sc_type type; + int i; for(i=0; i < ARRAYLENGTH(sd->addeff) && sd->addeff[i].flag; i++) { rate = sd->addeff[i].rate; @@ -998,7 +1000,8 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * if(dstsd && attack_type&BF_WEAPON) { //Counter effects. - int i, type, time; + enum sc_type type; + int i, time; for(i=0; i < ARRAYLENGTH(dstsd->addeff2) && dstsd->addeff2[i].flag; i++) { rate = dstsd->addeff2[i].rate; @@ -1104,9 +1107,9 @@ int skill_counter_additional_effect (struct block_list* src, struct block_list * --------------------------------------------------------------------------*/ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, int flag) { - const int where_list[4] = {EQP_WEAPON, EQP_ARMOR, EQP_SHIELD, EQP_HELM}; - const int scatk[4] = {SC_STRIPWEAPON, SC_STRIPARMOR, SC_STRIPSHIELD, SC_STRIPHELM}; - const int scdef[4] = {SC_CP_WEAPON, SC_CP_ARMOR, SC_CP_SHIELD, SC_CP_HELM}; + const int where_list[4] = {EQP_WEAPON, EQP_ARMOR, EQP_SHIELD, EQP_HELM}; + const enum sc_type scatk[4] = {SC_STRIPWEAPON, SC_STRIPARMOR, SC_STRIPSHIELD, SC_STRIPHELM}; + const enum sc_type scdef[4] = {SC_CP_WEAPON, SC_CP_ARMOR, SC_CP_SHIELD, SC_CP_HELM}; struct status_change *sc = status_get_sc(bl); int i,j; TBL_PC *sd; @@ -1188,9 +1191,9 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in int skill_strip_equip(struct block_list *bl, unsigned short where, int rate, int lv, int time) { struct status_change *sc; - const int pos[4] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HELM}; - const int sc_atk[4] = {SC_STRIPWEAPON, SC_STRIPSHIELD, SC_STRIPARMOR, SC_STRIPHELM}; - const int sc_def[4] = {SC_CP_WEAPON, SC_CP_SHIELD, SC_CP_ARMOR, SC_CP_HELM}; + const int pos[4] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HELM}; + const enum sc_type sc_atk[4] = {SC_STRIPWEAPON, SC_STRIPSHIELD, SC_STRIPARMOR, SC_STRIPHELM}; + const enum sc_type sc_def[4] = {SC_CP_WEAPON, SC_CP_SHIELD, SC_CP_ARMOR, SC_CP_HELM}; int i; if (rand()%100 >= rate) @@ -2810,7 +2813,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in struct status_change_entry *tsce; struct mob_data *md; struct mob_data *dstmd; - int i,type; + int i; + enum sc_type type; if(skillid > 0 && skilllv <= 0) return 0; // celest @@ -3109,9 +3113,9 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in mob_class_change(dstmd,class_); if( tsc && dstmd->status.mode&MD_BOSS ) { - const int scs[] = { SC_QUAGMIRE, SC_PROVOKE, SC_ROKISWEIL, SC_GRAVITATION, SC_SUITON, SC_STRIPWEAPON, SC_STRIPSHIELD, SC_STRIPARMOR, SC_STRIPHELM, SC_BLADESTOP }; + const enum sc_type scs[] = { SC_QUAGMIRE, SC_PROVOKE, SC_ROKISWEIL, SC_GRAVITATION, SC_SUITON, SC_STRIPWEAPON, SC_STRIPSHIELD, SC_STRIPARMOR, SC_STRIPHELM, SC_BLADESTOP }; for (i = SC_COMMON_MIN; i <= SC_COMMON_MAX; i++) - if (tsc->data[i]) status_change_end(bl, i, -1); + if (tsc->data[i]) status_change_end(bl, (sc_type)i, -1); for (i = 0; i < ARRAYLENGTH(scs); i++) if (tsc->data[scs[i]]) status_change_end(bl, scs[i], -1); } @@ -3153,7 +3157,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in case CG_MARIONETTE: { struct status_change *sc= status_get_sc(src); - int type2 = SC_MARIONETTE2; + enum sc_type type2 = SC_MARIONETTE2; if(sc && tsc){ if (!sc->data[type] && !tsc->data[type2]) { @@ -4020,32 +4024,36 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in case RG_STRIPARMOR: case RG_STRIPHELM: case ST_FULLSTRIP: + { + unsigned short location = 0; i = 5+2*skilllv; if (sstatus->dex > tstatus->dex) i += (sstatus->dex - tstatus->dex)/5; + switch (skillid) { case RG_STRIPWEAPON: - type = EQP_WEAPON; + location = EQP_WEAPON; break; case RG_STRIPSHIELD: - type = EQP_SHIELD; + location = EQP_SHIELD; break; case RG_STRIPARMOR: - type = EQP_ARMOR; + location = EQP_ARMOR; break; case RG_STRIPHELM: - type = EQP_HELM; + location = EQP_HELM; break; case ST_FULLSTRIP: - type = EQP_WEAPON|EQP_SHIELD|EQP_ARMOR|EQP_HELM; + location = EQP_WEAPON|EQP_SHIELD|EQP_ARMOR|EQP_HELM; break; } //Note that Full Strip autospell doesn't use a duration if (!clif_skill_nodamage(src,bl,skillid,skilllv, - skill_strip_equip(bl, type, i, skilllv, + skill_strip_equip(bl, location, i, skilllv, sd&&skillid==ST_FULLSTRIP&&!pc_checkskill(sd, skillid)?0:skill_get_time(skillid,skilllv))) && sd) clif_skill_fail(sd,skillid,0,0); //Nothing stripped. + } break; case AM_BERSERKPITCHER: @@ -4139,7 +4147,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in case AM_CP_ARMOR: case AM_CP_HELM: { - int scid = SC_STRIPWEAPON + (skillid - AM_CP_WEAPON); + enum sc_type scid = (sc_type)(SC_STRIPWEAPON + (skillid - AM_CP_WEAPON)); if(tsc && tsc->data[scid]) status_change_end(bl, scid, -1 ); clif_skill_nodamage(src,bl,skillid,skilllv, @@ -4192,7 +4200,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in } if(status_isimmune(bl) || !tsc || !tsc->count) break; - for(i=0;idata[i]) continue; switch (i) { @@ -4217,7 +4226,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in continue; } if(i==SC_BERSERK) tsc->data[i]->val2=0; //Mark a dispelled berserk to avoid setting hp to 100 by setting hp penalty to 0. - status_change_end(bl,i,-1); + status_change_end(bl,(sc_type)i,-1); } break; } @@ -4446,7 +4455,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in if (i > SC_ASPDPOTION3) i = SC_ASPDPOTION3; clif_skill_nodamage(src,bl,skillid,skilllv, - sc_start(bl,i,100,skilllv,skilllv * 60000)); + sc_start(bl,(sc_type)i,100,skilllv,skilllv * 60000)); } break; @@ -4764,8 +4773,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in } for (i=0; i<4; i++) { if(tsc->data[SC_STRIPWEAPON + i]) - status_change_end(bl, SC_STRIPWEAPON + i, -1 ); - sc_start(bl,SC_CP_WEAPON + i,100,skilllv,skilltime); + status_change_end(bl, (sc_type)(SC_STRIPWEAPON + i), -1 ); + sc_start(bl,(sc_type)(SC_CP_WEAPON + i),100,skilllv,skilltime); } clif_skill_nodamage(src,bl,skillid,skilllv,1); } @@ -4831,7 +4840,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in break; case 7: // stop freeze or stoned { - int sc[] = { SC_STOP, SC_FREEZE, SC_STONE }; + enum sc_type sc[] = { SC_STOP, SC_FREEZE, SC_STONE }; sc_start(bl,sc[rand()%3],100,skilllv,skill_get_time2(skillid,skilllv)); } break; @@ -5120,7 +5129,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in case NPC_DRAGONFEAR: if (flag&1) { - const int sc[] = { SC_STUN, SC_CURSE, SC_SILENCE, SC_BLEEDING }; + const enum sc_type sc[] = { SC_STUN, SC_CURSE, SC_SILENCE, SC_BLEEDING }; i = rand()%ARRAYLENGTH(sc); sc_start(bl,sc[i],100,skilllv,skill_get_time2(skillid,i+1)); } else { @@ -5528,7 +5537,8 @@ int skill_castend_pos2(struct block_list* src, int x, int y, int skillid, int sk struct status_change* sc; struct status_change_entry *sce; struct skill_unit_group* sg; - int i,type; + enum sc_type type; + int i; //if(skilllv <= 0) return 0; if(skillid > 0 && skilllv <= 0) return 0; // celest @@ -6491,7 +6501,8 @@ static int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, un struct block_list *ss; struct status_change *sc; struct status_change_entry *sce; - int type,skillid; + enum sc_type type; + int skillid; nullpo_retr(0, src); nullpo_retr(0, bl); @@ -6651,7 +6662,8 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns struct status_data *tstatus, *sstatus; struct status_change *tsc, *sc; struct skill_unit_group_tickset *ts; - int type, skillid; + enum sc_type type; + int skillid; int diff=0; nullpo_retr(0, src); @@ -6926,60 +6938,61 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns break; if (battle_check_target(ss,bl,BCT_PARTY)>0) { // Support Effect only on party, not guild + int heal; int i = rand()%13; // Positive buff count - type = skill_get_time2(sg->skill_id, sg->skill_lv); //Duration + int time = skill_get_time2(sg->skill_id, sg->skill_lv); //Duration switch (i) { case 0: // Heal 1~9999 HP - type = rand() %9999+1; - clif_skill_nodamage(ss,bl,AL_HEAL,type,1); - status_heal(bl,type,0,0); + heal = rand() %9999+1; + clif_skill_nodamage(ss,bl,AL_HEAL,heal,1); + status_heal(bl,heal,0,0); break; case 1: // End all negative status status_change_clear_buffs(bl,2); if (tsd) clif_gospel_info(tsd, 0x15); break; case 2: // Immunity to all status - sc_start(bl,SC_SCRESIST,100,100,type); + sc_start(bl,SC_SCRESIST,100,100,time); if (tsd) clif_gospel_info(tsd, 0x16); break; case 3: // MaxHP +100% - sc_start(bl,SC_INCMHPRATE,100,100,type); + sc_start(bl,SC_INCMHPRATE,100,100,time); if (tsd) clif_gospel_info(tsd, 0x17); break; case 4: // MaxSP +100% - sc_start(bl,SC_INCMSPRATE,100,100,type); + sc_start(bl,SC_INCMSPRATE,100,100,time); if (tsd) clif_gospel_info(tsd, 0x18); break; case 5: // All stats +20 - sc_start(bl,SC_INCALLSTATUS,100,20,type); + sc_start(bl,SC_INCALLSTATUS,100,20,time); if (tsd) clif_gospel_info(tsd, 0x19); break; case 6: // Level 10 Blessing - sc_start(bl,SC_BLESSING,100,10,type); + sc_start(bl,SC_BLESSING,100,10,time); break; case 7: // Level 10 Increase AGI - sc_start(bl,SC_INCREASEAGI,100,10,type); + sc_start(bl,SC_INCREASEAGI,100,10,time); break; case 8: // Enchant weapon with Holy element - sc_start(bl,SC_ASPERSIO,100,1,type); + sc_start(bl,SC_ASPERSIO,100,1,time); if (tsd) clif_gospel_info(tsd, 0x1c); break; case 9: // Enchant armor with Holy element - sc_start(bl,SC_BENEDICTIO,100,1,type); + sc_start(bl,SC_BENEDICTIO,100,1,time); if (tsd) clif_gospel_info(tsd, 0x1d); break; case 10: // DEF +25% - sc_start(bl,SC_INCDEFRATE,100,25,type); + sc_start(bl,SC_INCDEFRATE,100,25,time); if (tsd) clif_gospel_info(tsd, 0x1e); break; case 11: // ATK +100% - sc_start(bl,SC_INCATKRATE,100,100,type); + sc_start(bl,SC_INCATKRATE,100,100,time); if (tsd) clif_gospel_info(tsd, 0x1f); break; case 12: // HIT/Flee +50 - sc_start(bl,SC_INCHIT,100,50,type); - sc_start(bl,SC_INCFLEE,100,50,type); + sc_start(bl,SC_INCHIT,100,50,time); + sc_start(bl,SC_INCFLEE,100,50,time); if (tsd) clif_gospel_info(tsd, 0x20); break; } @@ -6987,35 +7000,35 @@ int skill_unit_onplace_timer (struct skill_unit *src, struct block_list *bl, uns else if (battle_check_target(&src->bl,bl,BCT_ENEMY)>0) { // Offensive Effect int i = rand()%9; // Negative buff count - type = skill_get_time2(sg->skill_id, sg->skill_lv); + int time = skill_get_time2(sg->skill_id, sg->skill_lv); switch (i) { case 0: // Deal 1~9999 damage skill_attack(BF_MISC,ss,&src->bl,bl,sg->skill_id,sg->skill_lv,tick,0); break; case 1: // Curse - sc_start(bl,SC_CURSE,100,1,type); + sc_start(bl,SC_CURSE,100,1,time); break; case 2: // Blind - sc_start(bl,SC_BLIND,100,1,type); + sc_start(bl,SC_BLIND,100,1,time); break; case 3: // Poison - sc_start(bl,SC_POISON,100,1,type); + sc_start(bl,SC_POISON,100,1,time); break; case 4: // Level 10 Provoke - sc_start(bl,SC_PROVOKE,100,10,type); + sc_start(bl,SC_PROVOKE,100,10,time); break; case 5: // DEF -100% - sc_start(bl,SC_INCDEFRATE,100,-100,type); + sc_start(bl,SC_INCDEFRATE,100,-100,time); break; case 6: // ATK -100% - sc_start(bl,SC_INCATKRATE,100,-100,type); + sc_start(bl,SC_INCATKRATE,100,-100,time); break; case 7: // Flee -100% - sc_start(bl,SC_INCFLEERATE,100,-100,type); + sc_start(bl,SC_INCFLEERATE,100,-100,time); break; case 8: // Speed/ASPD -25% - sc_start4(bl,SC_GOSPEL,100,1,0,0,BCT_ENEMY,type); + sc_start4(bl,SC_GOSPEL,100,1,0,0,BCT_ENEMY,time); break; } } @@ -7063,7 +7076,7 @@ int skill_unit_onout (struct skill_unit *src, struct block_list *bl, unsigned in struct skill_unit_group *sg; struct status_change *sc; struct status_change_entry *sce; - int type; + enum sc_type type; nullpo_retr(0, src); nullpo_retr(0, bl); @@ -7110,7 +7123,7 @@ static int skill_unit_onleft (int skill_id, struct block_list *bl, unsigned int { struct status_change *sc; struct status_change_entry *sce; - int type; + enum sc_type type; sc = status_get_sc(bl); if (sc && !sc->count) diff --git a/src/map/status.c b/src/map/status.c index a87e2cbc4..47d2617b6 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -60,22 +60,22 @@ int current_equip_card_id; //To prevent card-stacking (from jA) [Skotlex] //we need it for new cards 15 Feb 2005, to check if the combo cards are insrerted into the CURRENT weapon only //to avoid cards exploits -static int SkillStatusChangeTable[MAX_SKILL]; // skill -> status -static int StatusIconChangeTable[SC_MAX]; // status -> icon -unsigned long StatusChangeFlagTable[SC_MAX]; // status -> flags -static int StatusSkillChangeTable[SC_MAX]; // status -> skill +static sc_type SkillStatusChangeTable[MAX_SKILL]; // skill -> status +static int StatusIconChangeTable[SC_MAX]; // status -> icon +unsigned long StatusChangeFlagTable[SC_MAX]; // status -> flags +static int StatusSkillChangeTable[SC_MAX]; // status -> skill -int status_skill2sc(int skill) +sc_type status_skill2sc(int skill) { int sk = skill_get_index(skill); if( sk == 0 ) { ShowError("status_skill2sc: Unsupported skill id %d\n", skill); - return -1; + return SC_NONE; } return SkillStatusChangeTable[sk]; } -int status_sc2skill(int sc) +int status_sc2skill(sc_type sc) { if( sc < 0 || sc >= SC_MAX ) { ShowError("status_skill2sc: Unsupported status change id %d\n", sc); @@ -87,7 +87,7 @@ int status_sc2skill(int sc) #define add_sc(skill,sc) set_sc(skill,sc,SI_BLANK,SCB_NONE) -static void set_sc(int skill, int sc, int icon, unsigned int flag) +static void set_sc(int skill, sc_type sc, int icon, unsigned int flag) { int sk = skill_get_index(skill); if( sk == 0 ) { @@ -105,7 +105,7 @@ static void set_sc(int skill, int sc, int icon, unsigned int flag) StatusIconChangeTable[sc] = icon; StatusChangeFlagTable[sc] |= flag; - if( SkillStatusChangeTable[sk] == -1 ) + if( SkillStatusChangeTable[sk] == SC_NONE ) SkillStatusChangeTable[sk] = sc; } @@ -115,7 +115,7 @@ void initChangeTables(void) for (i = 0; i < SC_MAX; i++) StatusIconChangeTable[i] = SI_BLANK; for (i = 0; i < MAX_SKILL; i++) - SkillStatusChangeTable[i] = -1; + SkillStatusChangeTable[i] = SC_NONE; memset(StatusSkillChangeTable, 0, sizeof(StatusSkillChangeTable)); memset(StatusChangeFlagTable, 0, sizeof(StatusChangeFlagTable)); @@ -407,21 +407,21 @@ void initChangeTables(void) set_sc( GD_REGENERATION , SC_REGENERATION , SI_BLANK , SCB_REGEN ); // Storing the target job rather than simply SC_SPIRIT simplifies code later on. - SkillStatusChangeTable[SL_ALCHEMIST] = MAPID_ALCHEMIST, - SkillStatusChangeTable[SL_MONK] = MAPID_MONK, - SkillStatusChangeTable[SL_STAR] = MAPID_STAR_GLADIATOR, - SkillStatusChangeTable[SL_SAGE] = MAPID_SAGE, - SkillStatusChangeTable[SL_CRUSADER] = MAPID_CRUSADER, - SkillStatusChangeTable[SL_SUPERNOVICE] = MAPID_SUPER_NOVICE, - SkillStatusChangeTable[SL_KNIGHT] = MAPID_KNIGHT, - SkillStatusChangeTable[SL_WIZARD] = MAPID_WIZARD, - SkillStatusChangeTable[SL_PRIEST] = MAPID_PRIEST, - SkillStatusChangeTable[SL_BARDDANCER] = MAPID_BARDDANCER, - SkillStatusChangeTable[SL_ROGUE] = MAPID_ROGUE, - SkillStatusChangeTable[SL_ASSASIN] = MAPID_ASSASSIN, - SkillStatusChangeTable[SL_BLACKSMITH] = MAPID_BLACKSMITH, - SkillStatusChangeTable[SL_HUNTER] = MAPID_HUNTER, - SkillStatusChangeTable[SL_SOULLINKER] = MAPID_SOUL_LINKER, + SkillStatusChangeTable[SL_ALCHEMIST] = (sc_type)MAPID_ALCHEMIST, + SkillStatusChangeTable[SL_MONK] = (sc_type)MAPID_MONK, + SkillStatusChangeTable[SL_STAR] = (sc_type)MAPID_STAR_GLADIATOR, + SkillStatusChangeTable[SL_SAGE] = (sc_type)MAPID_SAGE, + SkillStatusChangeTable[SL_CRUSADER] = (sc_type)MAPID_CRUSADER, + SkillStatusChangeTable[SL_SUPERNOVICE] = (sc_type)MAPID_SUPER_NOVICE, + SkillStatusChangeTable[SL_KNIGHT] = (sc_type)MAPID_KNIGHT, + SkillStatusChangeTable[SL_WIZARD] = (sc_type)MAPID_WIZARD, + SkillStatusChangeTable[SL_PRIEST] = (sc_type)MAPID_PRIEST, + SkillStatusChangeTable[SL_BARDDANCER] = (sc_type)MAPID_BARDDANCER, + SkillStatusChangeTable[SL_ROGUE] = (sc_type)MAPID_ROGUE, + SkillStatusChangeTable[SL_ASSASIN] = (sc_type)MAPID_ASSASSIN, + SkillStatusChangeTable[SL_BLACKSMITH] = (sc_type)MAPID_BLACKSMITH, + SkillStatusChangeTable[SL_HUNTER] = (sc_type)MAPID_HUNTER, + SkillStatusChangeTable[SL_SOULLINKER] = (sc_type)MAPID_SOUL_LINKER, //Status that don't have a skill associated. StatusIconChangeTable[SC_WEIGHT50] = SI_WEIGHT50; @@ -1350,7 +1350,7 @@ int status_calc_mob(struct mob_data* md, int first) return 0; } if (!md->base_status) - md->base_status = aCalloc(1, sizeof(struct status_data)); + md->base_status = (struct status_data*)aCalloc(1, sizeof(struct status_data)); status = md->base_status; memcpy(status, &md->db->status, sizeof(struct status_data)); @@ -4603,7 +4603,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val sc = status_get_sc(bl); status = status_get_status_data(bl); - if( type < 0 || type >= SC_MAX ) + if( type <= SC_NONE || type >= SC_MAX ) { ShowError("status_change_start: invalid status change (%d)!\n", type); return 0; @@ -5581,8 +5581,8 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val { //Try to inherit the status from the Crusader [Skotlex] //Ideally, we should calculate the remaining time and use that, but we'll trust that //once the Crusader's status changes, it will reflect on the others. - const int types[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD, SC_ENDURE }; - int type2; + const enum sc_type types[] = { SC_AUTOGUARD, SC_DEFENDER, SC_REFLECTSHIELD, SC_ENDURE }; + enum sc_type type2; int i = map_flag_gvg(bl->m)?2:3; while (i >= 0) { type2 = types[i]; @@ -6166,7 +6166,7 @@ int status_change_start(struct block_list* bl,enum sc_type type,int rate,int val int status_change_clear(struct block_list* bl, int type) { struct status_change* sc; - enum sc_type i; + int i; sc = status_get_sc(bl); @@ -6200,7 +6200,7 @@ int status_change_clear(struct block_list* bl, int type) continue; } - status_change_end(bl, i, INVALID_TIMER); + status_change_end(bl, (sc_type)i, INVALID_TIMER); if( type == 1 && sc->data[i] ) { //If for some reason status_change_end decides to still keep the status when quitting. [Skotlex] @@ -6442,7 +6442,7 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid) case SC_MARIONETTE2: /// Marionette target if (sce->val1) { // check for partner and end their marionette status as well - int type2 = (type == SC_MARIONETTE) ? SC_MARIONETTE2 : SC_MARIONETTE; + enum sc_type type2 = (type == SC_MARIONETTE) ? SC_MARIONETTE2 : SC_MARIONETTE; struct block_list *pbl = map_id2bl(sce->val1); struct status_change* sc2 = pbl?status_get_sc(pbl):NULL; @@ -6728,7 +6728,7 @@ int kaahi_heal_timer(int tid, unsigned int tick, int id, int data) *------------------------------------------*/ int status_change_timer(int tid, unsigned int tick, int id, int data) { - enum sc_type type = data; + enum sc_type type = (sc_type)data; struct block_list *bl; struct map_session_data *sd; struct status_data *status; @@ -7074,7 +7074,7 @@ int status_change_timer_sub(struct block_list* bl, va_list ap) struct block_list* src = va_arg(ap,struct block_list*); struct status_change_entry* sce = va_arg(ap,struct status_change_entry*); - enum sc_type type = va_arg(ap,enum sc_type); + enum sc_type type = (sc_type)va_arg(ap,int); //gcc: enum args get promoted to int unsigned int tick = va_arg(ap,unsigned int); if (status_isdead(bl)) @@ -7129,7 +7129,7 @@ int status_change_timer_sub(struct block_list* bl, va_list ap) *------------------------------------------*/ int status_change_clear_buffs (struct block_list* bl, int type) { - enum sc_type i; + int i; struct status_change *sc= status_get_sc(bl); if (!sc || !sc->count) @@ -7139,7 +7139,7 @@ int status_change_clear_buffs (struct block_list* bl, int type) for( i = SC_COMMON_MIN; i <= SC_COMMON_MAX; i++ ) { if(sc->data[i]) - status_change_end(bl,i,-1); + status_change_end(bl,(sc_type)i,-1); } for( i = SC_COMMON_MAX+1; i < SC_MAX; i++ ) @@ -7206,7 +7206,7 @@ int status_change_clear_buffs (struct block_list* bl, int type) continue; break; } - status_change_end(bl,i,-1); + status_change_end(bl,(sc_type)i,-1); } return 0; } diff --git a/src/map/status.h b/src/map/status.h index 52274b66f..5011eada5 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -18,7 +18,9 @@ extern unsigned long StatusChangeFlagTable[]; // Status changes listing. These code are for use by the server. -enum sc_type { +typedef enum sc_type { + SC_NONE = -1, + //First we enumerate common status ailments which are often used around. SC_STONE = 0, SC_COMMON_MIN = 0, // begin @@ -290,7 +292,7 @@ enum sc_type { SC_SPCOST_RATE, SC_COMMONSC_RESIST, SC_MAX, //Automatically updated max, used in for's to check we are within bounds. -}; +} sc_type; //Numerates the Number for the status changes (client-dependent), imported from jA enum si_type { @@ -683,8 +685,8 @@ struct status_change { }; // for looking up associated data -int status_skill2sc(int skill); -int status_sc2skill(int sc); +sc_type status_skill2sc(int skill); +int status_sc2skill(sc_type sc); int status_damage(struct block_list *src,struct block_list *target,int hp,int sp, int walkdelay, int flag); //Define for standard HP damage attacks. diff --git a/src/map/storage.c b/src/map/storage.c index 06c052d74..c2e4bf5f7 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -106,13 +106,13 @@ static void* create_storage(DBKey key, va_list args) } struct storage *account2storage(int account_id) { - return idb_ensure(storage_db,account_id,create_storage); + return (struct storage*)idb_ensure(storage_db,account_id,create_storage); } // Just to ask storage, without creation struct storage *account2storage2(int account_id) { - return idb_get(storage_db, account_id); + return (struct storage*)idb_get(storage_db, account_id); } int storage_delete(int account_id) @@ -141,7 +141,7 @@ int storage_storageopen(struct map_session_data *sd) return 1; } - if((stor = idb_get(storage_db,sd->status.account_id)) == NULL) + if((stor = (struct storage*)idb_get(storage_db,sd->status.account_id)) == NULL) { //Request storage. intif_request_storage(sd->status.account_id); return 2; @@ -478,7 +478,7 @@ struct guild_storage *guild2storage(int guild_id) struct guild_storage *guild2storage2(int guild_id) { //For just locating a storage without creating one. [Skotlex] - return idb_get(guild_storage_db,guild_id); + return (struct guild_storage*)idb_get(guild_storage_db,guild_id); } int guild_storage_delete(int guild_id) diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index f1d688a7d..efe3383ac 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -2,27 +2,23 @@ @SET_MAKE@ ##################################################################### -.PHONY : all adduser convert mapcache clean help +.PHONY : all adduser mapcache clean help -all: adduser convert mapcache +all: adduser mapcache adduser: @CC@ -o ../../tools/adduser@EXEEXT@ adduser.c -convert: - @CC@ -o ../../tools/convert@EXEEXT@ convert.c - mapcache: obj_mapcache @CC@ -c -o obj_mapcache/grfio.o grfio.c @CC@ -o ../../mapcache@EXEEXT@ mapcache.c obj_mapcache/grfio.o -lz clean: - rm -rf *.o obj_mapcache ../../tools/adduser@EXEEXT@ ../../tools/convert@EXEEXT@ ../../mapcache@EXEEXT@ + rm -rf *.o obj_mapcache ../../tools/adduser@EXEEXT@ ../../mapcache@EXEEXT@ help: - @echo "possible targets are 'adduser' 'convert' 'mapcache' 'all' 'clean' 'help'" + @echo "possible targets are 'adduser' 'mapcache' 'all' 'clean' 'help'" @echo "'adduser' - ???" - @echo "'convert' - ???" @echo "'mapcache' - mapcache generator" @echo "'all' - builds all above targets" @echo "'clean' - cleans builds and objects" diff --git a/src/tool/adduser.c b/src/tool/adduser.c index 8e7c5f0c2..2c7461930 100644 --- a/src/tool/adduser.c +++ b/src/tool/adduser.c @@ -9,19 +9,20 @@ #include #include #include +#include char *account_txt = "../save/account.txt"; //----------------------------------------------------- // Function to suppress control characters in a string. //----------------------------------------------------- -int remove_control_chars(unsigned char *str) +int remove_control_chars(char* str) { int i; int change = 0; for(i = 0; str[i]; i++) { - if (str[i] < 32) { + if (iscntrl((unsigned char)(str[i]))) { str[i] = '_'; change = 1; } @@ -64,7 +65,7 @@ int main(int argc, char *argv[]) } } } - close(FPaccin); + fclose(FPaccin); printf("File exists.\n"); printf("Don't create an account if the login-server is online!!!\n"); @@ -96,7 +97,7 @@ int main(int argc, char *argv[]) FPaccout = fopen(account_txt, "r+"); fseek(FPaccout, 0, SEEK_END); fprintf(FPaccout, "%i %s %s - %s -\r\n", next_id, username, password, sex); - close(FPaccout); + fclose(FPaccout); printf("Account added.\n"); } diff --git a/src/tool/convert.c b/src/tool/convert.c deleted file mode 100644 index 671a49fb7..000000000 --- a/src/tool/convert.c +++ /dev/null @@ -1,300 +0,0 @@ -// (c) eAthena Dev Team - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include -#include -#include - -#define MAX_INVENTORY 100 -#define MAX_CART 100 -#define MAX_SKILL 350 -#define GLOBAL_REG_NUM 16 - -struct item { - int id; - short nameid; - short amount; - short equip; - char identify; - char refine; - char attribute; - short card[4]; -}; -struct point{ - char map[16]; - short x,y; -}; -struct skill { - unsigned short id,lv,flag; -}; -struct global_reg { - char str[16]; - int value; -}; - -struct mmo_charstatus { - int char_id; - int account_id; - int base_exp,job_exp,zeny; - - short class; - short status_point,skill_point; - short hp,max_hp,sp,max_sp; - short option,karma,manner; - short hair,hair_color,clothes_color; - int party_id,guild_id,pet_id; - - short weapon,shield; - short head_top,head_mid,head_bottom; - - char name[24]; - unsigned char base_level,job_level; - unsigned char str,agi,vit,int_,dex,luk,slot,sex; - - struct point last_point,save_point,memo_point[3]; - struct item inventory[MAX_INVENTORY],cart[MAX_CART]; - struct skill skill[MAX_SKILL]; - int global_reg_num; - struct global_reg global_reg[GLOBAL_REG_NUM]; -}; - -int mmo_char_tostr(char *str,struct mmo_charstatus *p) -{ - int i; - sprintf(str,"%d\t%d,%d\t%s\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" - "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" - "\t%s,%d,%d\t%s,%d,%d", - p->char_id,p->account_id,p->slot,p->name, // - p->class,p->base_level,p->job_level, - p->base_exp,p->job_exp,p->zeny, - p->hp,p->max_hp,p->sp,p->max_sp, - p->str,p->agi,p->vit,p->int_,p->dex,p->luk, - p->status_point,p->skill_point, - p->option,p->karma,p->manner, // - p->party_id,p->guild_id,p->pet_id, - p->hair,p->hair_color,p->clothes_color, - p->weapon,p->shield,p->head_top,p->head_mid,p->head_bottom, - p->last_point.map,p->last_point.x,p->last_point.y, // - p->save_point.map,p->save_point.x,p->save_point.y - ); - strcat(str,"\t"); - for(i=0;i<3;i++) - if(p->memo_point[i].map[0]){ - sprintf(str+strlen(str),"%s,%d,%d",p->memo_point[i].map,p->memo_point[i].x,p->memo_point[i].y); - } - strcat(str,"\t"); - for(i=0;iinventory[i].nameid){ - sprintf(str+strlen(str),"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ", - p->inventory[i].id,p->inventory[i].nameid,p->inventory[i].amount,p->inventory[i].equip, - p->inventory[i].identify,p->inventory[i].refine,p->inventory[i].attribute, - p->inventory[i].card[0],p->inventory[i].card[1],p->inventory[i].card[2],p->inventory[i].card[3]); - } - strcat(str,"\t"); - for(i=0;icart[i].nameid){ - sprintf(str+strlen(str),"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ", - p->cart[i].id,p->cart[i].nameid,p->cart[i].amount,p->cart[i].equip, - p->cart[i].identify,p->cart[i].refine,p->cart[i].attribute, - p->cart[i].card[0],p->cart[i].card[1],p->cart[i].card[2],p->cart[i].card[3]); - } - strcat(str,"\t"); - for(i=0;iskill[i].id){ - sprintf(str+strlen(str),"%d,%d ",p->skill[i].id,p->skill[i].lv); - } - strcat(str,"\t"); - for(i=0;iglobal_reg_num;i++) - sprintf(str+strlen(str),"%s,%d ",p->global_reg[i].str,p->global_reg[i].value); - strcat(str,"\t"); - return 0; -} - -int mmo_char_fromstr(char *str,struct mmo_charstatus *p) -{ - int tmp_int[256]; - int set,next,len,i; - - set=sscanf(str,"%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d" - "\t%d,%d,%d\t%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d" - "\t%[^,],%d,%d\t%[^,],%d,%d%n", - &tmp_int[0],&tmp_int[1],&tmp_int[2],p->name, // - &tmp_int[3],&tmp_int[4],&tmp_int[5], - &tmp_int[6],&tmp_int[7],&tmp_int[8], - &tmp_int[9],&tmp_int[10],&tmp_int[11],&tmp_int[12], - &tmp_int[13],&tmp_int[14],&tmp_int[15],&tmp_int[16],&tmp_int[17],&tmp_int[18], - &tmp_int[19],&tmp_int[20], - &tmp_int[21],&tmp_int[22],&tmp_int[23], // - &tmp_int[24],&tmp_int[25], - &tmp_int[26],&tmp_int[27],&tmp_int[28], - &tmp_int[29],&tmp_int[30],&tmp_int[31],&tmp_int[32],&tmp_int[33], - p->last_point.map,&tmp_int[34],&tmp_int[35], // - p->save_point.map,&tmp_int[36],&tmp_int[37],&next - ); - p->char_id=tmp_int[0]; - p->account_id=tmp_int[1]; - p->slot=tmp_int[2]; - p->class=tmp_int[3]; - p->base_level=tmp_int[4]; - p->job_level=tmp_int[5]; - p->base_exp=tmp_int[6]; - p->job_exp=tmp_int[7]; - p->zeny=tmp_int[8]; - p->hp=tmp_int[9]; - p->max_hp=tmp_int[10]; - p->sp=tmp_int[11]; - p->max_sp=tmp_int[12]; - p->str=tmp_int[13]; - p->agi=tmp_int[14]; - p->vit=tmp_int[15]; - p->int_=tmp_int[16]; - p->dex=tmp_int[17]; - p->luk=tmp_int[18]; - p->status_point=tmp_int[19]; - p->skill_point=tmp_int[20]; - p->option=tmp_int[21]; - p->karma=tmp_int[22]; - p->manner=tmp_int[23]; - p->party_id=tmp_int[24]; - p->guild_id=tmp_int[25]; - p->pet_id=0; - p->hair=tmp_int[26]; - p->hair_color=tmp_int[27]; - p->clothes_color=tmp_int[28]; - p->weapon=tmp_int[29]; - p->shield=tmp_int[30]; - p->head_top=tmp_int[31]; - p->head_mid=tmp_int[32]; - p->head_bottom=tmp_int[33]; - p->last_point.x=tmp_int[34]; - p->last_point.y=tmp_int[35]; - p->save_point.x=tmp_int[36]; - p->save_point.y=tmp_int[37]; - if(set!=41) - return 0; - if(str[next]=='\n' || str[next]=='\r') - return 1; // 新規データ - next++; - for(i=0;str[next] && str[next]!='\t';i++){ - set=sscanf(str+next,"%[^,],%d,%d%n",p->memo_point[i].map,&tmp_int[0],&tmp_int[1],&len); - if(set!=3) - return 0; - p->memo_point[i].x=tmp_int[0]; - p->memo_point[i].y=tmp_int[1]; - next+=len; - if(str[next]==' ') - next++; - } - next++; - for(i=0;str[next] && str[next]!='\t';i++){ - set=sscanf(str+next,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", - &tmp_int[0],&tmp_int[1],&tmp_int[2],&tmp_int[3], - &tmp_int[4],&tmp_int[5],&tmp_int[6], - &tmp_int[7],&tmp_int[8],&tmp_int[9],&tmp_int[10],&len); - if(set!=11) - return 0; - p->inventory[i].id=tmp_int[0]; - p->inventory[i].nameid=tmp_int[1]; - p->inventory[i].amount=tmp_int[2]; - p->inventory[i].equip=tmp_int[3]; - p->inventory[i].identify=tmp_int[4]; - p->inventory[i].refine=tmp_int[5]; - p->inventory[i].attribute=tmp_int[6]; - p->inventory[i].card[0]=tmp_int[7]; - p->inventory[i].card[1]=tmp_int[8]; - p->inventory[i].card[2]=tmp_int[9]; - p->inventory[i].card[3]=tmp_int[10]; - next+=len; - if(str[next]==' ') - next++; - } - next++; - for(i=0;str[next] && str[next]!='\t';i++){ - set=sscanf(str+next,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n", - &tmp_int[0],&tmp_int[1],&tmp_int[2],&tmp_int[3], - &tmp_int[4],&tmp_int[5],&tmp_int[6], - &tmp_int[7],&tmp_int[8],&tmp_int[9],&tmp_int[10],&len); - if(set!=11) - return 0; - p->cart[i].id=tmp_int[0]; - p->cart[i].nameid=tmp_int[1]; - p->cart[i].amount=tmp_int[2]; - p->cart[i].equip=tmp_int[3]; - p->cart[i].identify=tmp_int[4]; - p->cart[i].refine=tmp_int[5]; - p->cart[i].attribute=tmp_int[6]; - p->cart[i].card[0]=tmp_int[7]; - p->cart[i].card[1]=tmp_int[8]; - p->cart[i].card[2]=tmp_int[9]; - p->cart[i].card[3]=tmp_int[10]; - next+=len; - if(str[next]==' ') - next++; - } - next++; - for(i=0;str[next] && str[next]!='\t';i++){ - set=sscanf(str+next,"%d,%d%n", - &tmp_int[0],&tmp_int[1],&len); - if(set!=2) - return 0; - p->skill[tmp_int[0]].id=tmp_int[0]; - p->skill[tmp_int[0]].lv=tmp_int[1]; - next+=len; - if(str[next]==' ') - next++; - } - next++; - for(i=0;str[next] && str[next]!='\t' && str[next]!='\n' && str[next]!='\r';i++){ //global_reg実装以前のathena.txt互換のため一応'\n'チェック - set=sscanf(str+next,"%[^,],%d%n", - p->global_reg[i].str,&p->global_reg[i].value,&len); - if(set!=2) - return 0; - next+=len; - if(str[next]==' ') - next++; - } - p->global_reg_num=i; - return 1; -} - -int mmo_char_convert(char *fname1,char *fname2) -{ - char line[65536]; - int ret; - struct mmo_charstatus char_dat; - FILE *ifp,*ofp; - - ifp=fopen(fname1,"r"); - ofp=fopen(fname2,"w"); - if(ifp==NULL) { - printf("file not found %s\n",fname1); - return 0; - } - if(ofp==NULL) { - printf("file open error %s\n",fname2); - return 0; - } - while(fgets(line, sizeof(line), ifp)) - { - memset(&char_dat,0,sizeof(struct mmo_charstatus)); - ret=mmo_char_fromstr(line,&char_dat); - if(ret){ - mmo_char_tostr(line,&char_dat); - fprintf(ofp,"%s\n",line); - } - } - fclose(ifp); - fclose(ofp); - return 0; -} - -int main(int argc,char *argv[]) -{ - if(argc < 3) { - printf("Usage: convert \n"); - exit(EXIT_SUCCESS); - } - mmo_char_convert(argv[1],argv[2]); - - return 0; -} diff --git a/src/txt-converter/login-converter.c b/src/txt-converter/login-converter.c index 6936ca782..b216ff8d2 100644 --- a/src/txt-converter/login-converter.c +++ b/src/txt-converter/login-converter.c @@ -34,11 +34,8 @@ char db_server_logindb[32] = "ragnarok"; int isGM(int account_id) { - struct gm_account *p; - p = idb_get(gm_account_db,account_id); - if( p == NULL) - return 0; - return p->level; + struct gm_account* p = (struct gm_account*)idb_get(gm_account_db,account_id); + return( p != NULL ) ? p->level : 0; } int read_gm_account() @@ -74,7 +71,7 @@ int read_gm_account() else { if(p->level > 99) p->level = 99; - p = idb_put(gm_account_db,p->account_id,p); + p = (struct gm_account*)idb_put(gm_account_db,p->account_id,p); if( p ) aFree(p);// old entry replaced gm_counter++; diff --git a/vcproj-9/char-server_sql.vcproj b/vcproj-9/char-server_sql.vcproj index bf882d8ae..b4d46301d 100644 --- a/vcproj-9/char-server_sql.vcproj +++ b/vcproj-9/char-server_sql.vcproj @@ -41,6 +41,7 @@ /> Date: Sat, 24 Jan 2009 19:38:48 +0000 Subject: * Changed the variables of the mapcache structs to fixed size equivalents. (64bit portability issue) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13483 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 1 + src/map/map.c | 17 +++++++----- src/tool/Makefile.in | 10 +++---- src/tool/mapcache.c | 74 +++++++++++++++++++++++++++------------------------- 4 files changed, 52 insertions(+), 50 deletions(-) (limited to 'src/tool/Makefile.in') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index c4e8905b0..3fd448b07 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2009/01/24 + * Changed the variables of the mapcache structs to fixed size equivalents. * Changed all uses of struct skill_unit_group* to group_id in status_change_entry's. [FlavioJS] 2009/01/23 * Changed npc_get_new_npc_id to ensure that it never returns invalid/used ids. [FlavioJS] diff --git a/src/map/map.c b/src/map/map.c index 03b095295..c732e2d55 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -136,16 +136,16 @@ struct charid2nick { // This is the main header found at the very beginning of the map cache struct map_cache_main_header { - unsigned long file_size; - unsigned short map_count; + uint32 file_size; + uint16 map_count; }; // This is the header appended before every compressed map cells info in the map cache struct map_cache_map_info { char name[MAP_NAME_LENGTH]; - short xs; - short ys; - long len; + int16 xs; + int16 ys; + int32 len; }; char map_cache_file[256]="db/map_cache.dat"; @@ -2694,9 +2694,12 @@ int map_readfromcache(struct map_data *m, FILE *fp) unsigned char *buf, *buf2; unsigned long size, xy; + if( info.xs <= 0 || info.ys <= 0 ) + return 0;// invalid + m->xs = info.xs; m->ys = info.ys; - size = info.xs*info.ys; + size = (unsigned long)info.xs*(unsigned long)info.ys; buf = (unsigned char*)aMalloc(info.len); // temp buffer to read the zipped map buf2 = (unsigned char*)aMalloc(size); // temp buffer to unpack the data @@ -2713,7 +2716,7 @@ int map_readfromcache(struct map_data *m, FILE *fp) return 1; } - return 0; + return 0;// not found } int map_addmap(char* mapname) diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index efe3383ac..78300a68c 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -9,12 +9,11 @@ all: adduser mapcache adduser: @CC@ -o ../../tools/adduser@EXEEXT@ adduser.c -mapcache: obj_mapcache - @CC@ -c -o obj_mapcache/grfio.o grfio.c - @CC@ -o ../../mapcache@EXEEXT@ mapcache.c obj_mapcache/grfio.o -lz +mapcache: + @CC@ -o ../../mapcache@EXEEXT@ mapcache.c grfio.c -lz clean: - rm -rf *.o obj_mapcache ../../tools/adduser@EXEEXT@ ../../mapcache@EXEEXT@ + rm -rf *.o ../../tools/adduser@EXEEXT@ ../../mapcache@EXEEXT@ help: @echo "possible targets are 'adduser' 'mapcache' 'all' 'clean' 'help'" @@ -25,6 +24,3 @@ help: @echo "'help' - outputs this message" ##################################################################### - -obj_mapcache: - -mkdir obj_mapcache diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index b696c6ee9..49e1826ab 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -9,6 +9,7 @@ #include #endif +#include "../common/cbasetypes.h" #include "grfio.h" #define MAP_NAME_LENGTH 12 @@ -26,23 +27,23 @@ unsigned long file_size; // Used internally, this structure contains the physical map cells struct map_data { - short xs; - short ys; + int16 xs; + int16 ys; unsigned char *cells; }; // This is the main header found at the very beginning of the file struct main_header { - unsigned long file_size; - unsigned short map_count; + uint32 file_size; + uint16 map_count; } header; // This is the header appended before every compressed map cells info struct map_info { char name[MAP_NAME_LENGTH]; - short xs; - short ys; - long len; + int16 xs; + int16 ys; + int32 len; }; @@ -50,55 +51,52 @@ struct map_info { * Big-endian compatibility functions * *************************************/ -// Converts a short (16 bits) from current machine order to little-endian -short MakeShortLE(short val) +// Converts an int16 from current machine order to little-endian +int16 MakeShortLE(int16 val) { unsigned char buf[2]; buf[0] = (unsigned char)( (val & 0x00FF) ); buf[1] = (unsigned char)( (val & 0xFF00) >> 0x08 ); - return *((short*)buf); + return *((int16*)buf); } -// Converts a long (32 bits) from current machine order to little-endian -long MakeLongLE(long val) +// Converts an int32 from current machine order to little-endian +int32 MakeLongLE(int32 val) { unsigned char buf[4]; buf[0] = (unsigned char)( (val & 0x000000FF) ); buf[1] = (unsigned char)( (val & 0x0000FF00) >> 0x08 ); buf[2] = (unsigned char)( (val & 0x00FF0000) >> 0x10 ); buf[3] = (unsigned char)( (val & 0xFF000000) >> 0x18 ); - return *((long*)buf); + return *((int32*)buf); } -// Reads an unsigned short (16 bits) in little-endian from the buffer -unsigned short GetUShort(const unsigned char *buf) +// Reads an uint16 in little-endian from the buffer +uint16 GetUShort(const unsigned char* buf) { - return ( ((unsigned short)(buf[0])) ) - |( ((unsigned short)(buf[1])) << 0x08 ); + return ( ((uint16)(buf[0])) ) + |( ((uint16)(buf[1])) << 0x08 ); } -// Reads a long (32 bits) in little-endian from the buffer -long GetLong(const unsigned char *buf) +// Reads an uint32 in little-endian from the buffer +uint32 GetULong(const unsigned char* buf) { - return ( ((long)(buf[0])) ) - |( ((long)(buf[1])) << 0x08 ) - |( ((long)(buf[2])) << 0x10 ) - |( ((long)(buf[3])) << 0x18 ); + return ( ((uint32)(buf[0])) ) + |( ((uint32)(buf[1])) << 0x08 ) + |( ((uint32)(buf[2])) << 0x10 ) + |( ((uint32)(buf[3])) << 0x18 ); } -// Reads an unsigned long (32 bits) in little-endian from the buffer -unsigned long GetULong(const unsigned char *buf) +// Reads an int32 in little-endian from the buffer +int32 GetLong(const unsigned char* buf) { - return ( ((unsigned long)(buf[0])) ) - |( ((unsigned long)(buf[1])) << 0x08 ) - |( ((unsigned long)(buf[2])) << 0x10 ) - |( ((unsigned long)(buf[3])) << 0x18 ); + return (int32)GetULong(buf); } // Reads a float (32 bits) from the buffer -float GetFloat(const unsigned char *buf) +float GetFloat(const unsigned char* buf) { - unsigned long val = GetULong(buf); + uint32 val = GetULong(buf); return *((float*)&val); } @@ -111,7 +109,7 @@ int read_map(char *name, struct map_data *m) int water_height; size_t xy, off, num_cells; float height; - unsigned long type; + uint32 type; // Open map GAT sprintf(filename,"data\\%s.gat", name); @@ -131,9 +129,13 @@ int read_map(char *name, struct map_data *m) water_height = NO_WATER; // Read map size and allocate needed memory - m->xs = (short)GetULong(gat+6); - m->ys = (short)GetULong(gat+10); - num_cells = (size_t)m->xs*m->ys; + m->xs = (int16)GetULong(gat+6); + m->ys = (int16)GetULong(gat+10); + if (m->xs <= 0 || m->ys <= 0) { + free(gat); + return 0; + } + num_cells = (size_t)m->xs*(size_t)m->ys; m->cells = (unsigned char *)malloc(num_cells); // Set cell properties @@ -165,7 +167,7 @@ void cache_map(char *name, struct map_data *m) unsigned char *write_buf; // Create an output buffer twice as big as the uncompressed map... this way we're sure it fits - len = m->xs*m->ys*2; + len = (unsigned long)m->xs*(unsigned long)m->ys*2; write_buf = (unsigned char *)malloc(len); // Compress the cells and get the compressed length encode_zip(write_buf, &len, m->cells, m->xs*m->ys); -- cgit v1.2.3-70-g09d2 From 296cc8b832aeed7932327017c4489874725f82f1 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Tue, 28 Dec 2010 13:26:35 +0000 Subject: * Removed unmaintained and broken 'adduser' tool (topic:262284). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14636 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 5 ++- readme/setup.html | 2 +- src/tool/Makefile.in | 12 ++---- src/tool/adduser.c | 103 --------------------------------------------------- 4 files changed, 9 insertions(+), 113 deletions(-) delete mode 100644 src/tool/adduser.c (limited to 'src/tool/Makefile.in') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 237805ca3..0ca19ac69 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,7 +1,10 @@ Date Added -2010/12/26 +2010/12/28 + * Removed unmaintained and broken 'adduser' tool (topic:262284). [Ai4rei] +2010/12/27 * Fixed skill_can_produce_mix not checking, whether or not the produced goods can actually be stored (bugreport:4674). [Ai4rei] +2010/12/26 * Reverted r14565, as the database version is already properly commented in source and is overwritten upon first sync of account.txt anyway. [Ai4rei] * Cleaned up script command checkweight. [Ai4rei] - Replaced some code parts with calls to pc_checkadditem and pc_inventoryblank (follow up to r13735). diff --git a/readme/setup.html b/readme/setup.html index 72b06c40e..c4463ef89 100644 --- a/readme/setup.html +++ b/readme/setup.html @@ -92,7 +92,7 @@ It's extremely easy to set up eAthena, just follow these simple steps.
  1. Edit motd.txt, grf-files.txt and the .conf files in your /conf/ folder as you see fit
  2. -
  3. If you want to add a user, run adduser.exe in the main eAthena directory before starting the server.
  4. +
  5. If you want to add a user, edit save/account.txt in the main eAthena directory before starting the server.
  6. Run runserver.bat or runserver-sql.bat (depending on which storage system you're using, or you could run login-server.exe, char-server.exe, and map-server.exe manually)
  7. Give people your IP address (can be found at http://www.whatismyip.com) to people to add in their sclientinfo.xml
  8. You're done!
  9. diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 78300a68c..61a54709d 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -2,22 +2,18 @@ @SET_MAKE@ ##################################################################### -.PHONY : all adduser mapcache clean help +.PHONY : all mapcache clean help -all: adduser mapcache - -adduser: - @CC@ -o ../../tools/adduser@EXEEXT@ adduser.c +all: mapcache mapcache: @CC@ -o ../../mapcache@EXEEXT@ mapcache.c grfio.c -lz clean: - rm -rf *.o ../../tools/adduser@EXEEXT@ ../../mapcache@EXEEXT@ + rm -rf *.o ../../mapcache@EXEEXT@ help: - @echo "possible targets are 'adduser' 'mapcache' 'all' 'clean' 'help'" - @echo "'adduser' - ???" + @echo "possible targets are 'mapcache' 'all' 'clean' 'help'" @echo "'mapcache' - mapcache generator" @echo "'all' - builds all above targets" @echo "'clean' - cleans builds and objects" diff --git a/src/tool/adduser.c b/src/tool/adduser.c deleted file mode 100644 index 5f4dfb6a5..000000000 --- a/src/tool/adduser.c +++ /dev/null @@ -1,103 +0,0 @@ -// (c) eAthena Dev Team - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -/* - This program adds an user to account.txt - Don't usr it When login-sever is working. -*/ - -#include -#include -#include -#include - -char *account_txt = "../save/account.txt"; - -//----------------------------------------------------- -// Function to suppress control characters in a string. -//----------------------------------------------------- -int remove_control_chars(char* str) -{ - int i; - int change = 0; - - for(i = 0; str[i]; i++) { - if (iscntrl((unsigned char)(str[i]))) { - str[i] = '_'; - change = 1; - } - } - - return change; -} - -int main(int argc, char *argv[]) -{ - char username[24]; - char password[24]; - char sex[2]; - - int next_id, id; - char line[1024]; - FILE *FPaccin,*FPaccout; - - // Check to see if account.txt exists. - printf("Checking if '%s' file exists...\n", account_txt); - FPaccin = fopen(account_txt, "r"); - if (FPaccin == NULL) { - printf("'%s' file not found!\n", account_txt); - printf("Run the setup wizard please.\n"); - exit(EXIT_SUCCESS); - } - - next_id = 2000000; - while(fgets(line, sizeof(line), FPaccin)) - { - if (line[0] == '/' && line[1] == '/') { continue; } - if (sscanf(line, "%d\t%%newid%%\n", &id) == 1) { - if (next_id < id) { - next_id = id; - } - } else { - sscanf(line,"%i%[^ ]", &id); - if (next_id <= id) { - next_id = id +1; - } - } - } - fclose(FPaccin); - printf("File exists.\n"); - - printf("Don't create an account if the login-server is online!!!\n"); - printf("If the login-server is online, press ctrl+C now to stop this software.\n"); - printf("\n"); - - strcpy(username, ""); - while (strlen(username) < 4 || strlen(username) > 23) { - printf("Enter an username (4-23 characters): "); - scanf("%s", username); - username[23] = 0; - remove_control_chars(username); - } - - strcpy(password, ""); - while (strlen(password) < 4 || strlen(password) > 23) { - printf("Enter a password (4-23 characters): "); - scanf("%s", password); - password[23] = 0; - remove_control_chars(password); - } - - strcpy(sex, ""); - while (strcmp(sex, "F") != 0 && strcmp(sex, "M") != 0) { - printf("Enter a gender (M for male, F for female): "); - scanf("%s", sex); - } - - FPaccout = fopen(account_txt, "r+"); - fseek(FPaccout, 0, SEEK_END); - fprintf(FPaccout, "%i %s %s - %s -\r\n", next_id, username, password, sex); - fclose(FPaccout); - - printf("Account added.\n"); -} -- cgit v1.2.3-70-g09d2 From 6c4ccacfc199765bb6837da08341f6c7f21464bf Mon Sep 17 00:00:00 2001 From: ai4rei Date: Sat, 1 Jan 2011 20:43:02 +0000 Subject: * Updates to map cache generator tool. - Removed unmaintained grfio library copy and made the tool use the one in /common instead (related r12726). - Updated makefile to use compile options/libraries determined by configure (bugreport:1109). - Fixed error messages from the tool and grfio library overlapping each other (bugreport:2403). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14646 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 5 + src/tool/Makefile.in | 28 +- src/tool/grfio.c | 844 --------------------------------------------- src/tool/grfio.h | 20 -- src/tool/mapcache.c | 58 ++-- vcproj-10/mapcache.vcxproj | 21 +- vcproj-7.1/mapcache.vcproj | 53 ++- vcproj-8/mapcache.vcproj | 66 +++- vcproj-9/mapcache.vcproj | 66 +++- 9 files changed, 248 insertions(+), 913 deletions(-) delete mode 100644 src/tool/grfio.c delete mode 100644 src/tool/grfio.h (limited to 'src/tool/Makefile.in') diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 12cbc86dc..9d90c550e 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -1,5 +1,10 @@ Date Added +2011/01/01 + * Updates to map cache generator tool. [Ai4rei] + - Removed unmaintained grfio library copy and made the tool use the one in /common instead (related r12726). + - Updated makefile to use compile options/libraries determined by configure (bugreport:1109). + - Fixed error messages from the tool and grfio library overlapping each other (bugreport:2403). 2010/12/31 * Pending trade requests no longer prevent a character from trading someone else instead (official). [Ai4rei] - This fixes trade window displaying wrong name when attempting to deal multiple characters (bugreport:344). diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 61a54709d..06813f843 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -1,4 +1,13 @@ +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/grfio.o +COMMON_H = ../common/core.h ../common/mmo.h ../common/version.h \ + ../common/malloc.h ../common/showmsg.h ../common/strlib.h \ + ../common/utils.h ../common/cbasetypes.h ../common/grfio.h + +MAPCACHE_OBJ = obj_all/mapcache.o + @SET_MAKE@ ##################################################################### @@ -6,11 +15,11 @@ all: mapcache -mapcache: - @CC@ -o ../../mapcache@EXEEXT@ mapcache.c grfio.c -lz +mapcache: obj_all $(MAPCACHE_OBJ) $(COMMON_OBJ) + @CC@ @LDFLAGS@ -o ../../mapcache@EXEEXT@ $(MAPCACHE_OBJ) $(COMMON_OBJ) @LIBS@ clean: - rm -rf *.o ../../mapcache@EXEEXT@ + rm -rf obj_all/*.o ../../mapcache@EXEEXT@ help: @echo "possible targets are 'mapcache' 'all' 'clean' 'help'" @@ -20,3 +29,16 @@ help: @echo "'help' - outputs this message" ##################################################################### + +obj_all: + -mkdir obj_all + +obj_all/%.o: %.c $(COMMON_H) + @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + +# missing common object files +../common/obj_all/%.o: + @$(MAKE) -C ../common txt + +../common/obj_all/mini%.o: + @$(MAKE) -C ../common txt diff --git a/src/tool/grfio.c b/src/tool/grfio.c deleted file mode 100644 index 26cfb636f..000000000 --- a/src/tool/grfio.c +++ /dev/null @@ -1,844 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#include -#include -#include -#include -#include // tolower() - -#include "grfio.h" -#include - - -#ifndef __WIN32 - #define strcmpi strcasecmp -#endif - - -//---------------------------- -// file entry table struct -//---------------------------- -typedef struct _FILELIST { - int srclen; // compressed size - int srclen_aligned; - int declen; // original size - int srcpos; // position of entry in grf - int next; // index of next filelist entry with same hash (-1: end of entry chain) - int cycle; - char type; - char fn[128-4*5]; // file name - char* fnd; // if the file was cloned, contains name of original file - char gentry; // read grf file select -} FILELIST; - -//gentry ... > 0 : data read from a grf file (gentry_table[gentry-1]) -//gentry ... 0 : data read from a local file (data directory) -//gentry ... < 0 : entry "-(gentry)" is marked for a local file check -// - if local file exists, gentry will be set to 0 (thus using the local file) -// - if local file doesn't exist, sign is inverted (thus using the original file inside a grf) -// (NOTE: this case is only used once (during startup) and only if GRFIO_LOCAL is enabled) -// (NOTE: probably meant to be used to override grf contents by files in the data directory) -//#define GRFIO_LOCAL - -// stores info about every loaded file -FILELIST* filelist = NULL; -int filelist_entrys = 0; -int filelist_maxentry = 0; - -// stores grf file names -char** gentry_table = NULL; -int gentry_entrys = 0; -int gentry_maxentry = 0; - -// the path to the data directory -char data_dir[1024] = ""; - -//---------------------------- -// file list hash table -//---------------------------- -int filelist_hash[256]; - -//---------------------------- -// grf decode data table -//---------------------------- -static unsigned char BitMaskTable[8] = { - 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 -}; - -static char BitSwapTable1[64] = { - 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, - 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, - 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, - 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7 -}; -static char BitSwapTable2[64] = { - 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, - 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, - 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, - 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25 -}; -static char BitSwapTable3[32] = { - 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, - 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 -}; - -static unsigned char NibbleData[4][64]={ - { - 0xef, 0x03, 0x41, 0xfd, 0xd8, 0x74, 0x1e, 0x47, 0x26, 0xef, 0xfb, 0x22, 0xb3, 0xd8, 0x84, 0x1e, - 0x39, 0xac, 0xa7, 0x60, 0x62, 0xc1, 0xcd, 0xba, 0x5c, 0x96, 0x90, 0x59, 0x05, 0x3b, 0x7a, 0x85, - 0x40, 0xfd, 0x1e, 0xc8, 0xe7, 0x8a, 0x8b, 0x21, 0xda, 0x43, 0x64, 0x9f, 0x2d, 0x14, 0xb1, 0x72, - 0xf5, 0x5b, 0xc8, 0xb6, 0x9c, 0x37, 0x76, 0xec, 0x39, 0xa0, 0xa3, 0x05, 0x52, 0x6e, 0x0f, 0xd9, - }, { - 0xa7, 0xdd, 0x0d, 0x78, 0x9e, 0x0b, 0xe3, 0x95, 0x60, 0x36, 0x36, 0x4f, 0xf9, 0x60, 0x5a, 0xa3, - 0x11, 0x24, 0xd2, 0x87, 0xc8, 0x52, 0x75, 0xec, 0xbb, 0xc1, 0x4c, 0xba, 0x24, 0xfe, 0x8f, 0x19, - 0xda, 0x13, 0x66, 0xaf, 0x49, 0xd0, 0x90, 0x06, 0x8c, 0x6a, 0xfb, 0x91, 0x37, 0x8d, 0x0d, 0x78, - 0xbf, 0x49, 0x11, 0xf4, 0x23, 0xe5, 0xce, 0x3b, 0x55, 0xbc, 0xa2, 0x57, 0xe8, 0x22, 0x74, 0xce, - }, { - 0x2c, 0xea, 0xc1, 0xbf, 0x4a, 0x24, 0x1f, 0xc2, 0x79, 0x47, 0xa2, 0x7c, 0xb6, 0xd9, 0x68, 0x15, - 0x80, 0x56, 0x5d, 0x01, 0x33, 0xfd, 0xf4, 0xae, 0xde, 0x30, 0x07, 0x9b, 0xe5, 0x83, 0x9b, 0x68, - 0x49, 0xb4, 0x2e, 0x83, 0x1f, 0xc2, 0xb5, 0x7c, 0xa2, 0x19, 0xd8, 0xe5, 0x7c, 0x2f, 0x83, 0xda, - 0xf7, 0x6b, 0x90, 0xfe, 0xc4, 0x01, 0x5a, 0x97, 0x61, 0xa6, 0x3d, 0x40, 0x0b, 0x58, 0xe6, 0x3d, - }, { - 0x4d, 0xd1, 0xb2, 0x0f, 0x28, 0xbd, 0xe4, 0x78, 0xf6, 0x4a, 0x0f, 0x93, 0x8b, 0x17, 0xd1, 0xa4, - 0x3a, 0xec, 0xc9, 0x35, 0x93, 0x56, 0x7e, 0xcb, 0x55, 0x20, 0xa0, 0xfe, 0x6c, 0x89, 0x17, 0x62, - 0x17, 0x62, 0x4b, 0xb1, 0xb4, 0xde, 0xd1, 0x87, 0xc9, 0x14, 0x3c, 0x4a, 0x7e, 0xa8, 0xe2, 0x7d, - 0xa0, 0x9f, 0xf6, 0x5c, 0x6a, 0x09, 0x8d, 0xf0, 0x0f, 0xe3, 0x53, 0x25, 0x95, 0x36, 0x28, 0xcb, - } -}; - -// little endian char array to uint conversion -static unsigned int getlong(unsigned char* p) -{ - return (p[0] | p[1] << 0x08 | p[2] << 0x10 | p[3] << 0x18); -} - -/*========================================== - * Grf data decode : Subs - *------------------------------------------*/ -static void NibbleSwap(unsigned char* Src, int len) -{ - for(;0>4) | (*Src<<4); - } -} - -static void BitConvert(unsigned char* Src, char* BitSwapTable) -{ - int lop,prm; - unsigned char tmp[8]; - memset(tmp,0,8); - for(lop=0;lop!=64;lop++) { - prm = BitSwapTable[lop]-1; - if (Src[(prm >> 3) & 7] & BitMaskTable[prm & 7]) { - tmp[(lop >> 3) & 7] |= BitMaskTable[lop & 7]; - } - } - memcpy(Src,tmp,8); -} - -static void BitConvert4(unsigned char* Src) -{ - int lop,prm; - unsigned char tmp[8]; - tmp[0] = ((Src[7]<<5) | (Src[4]>>3)) & 0x3f; // ..0 vutsr - tmp[1] = ((Src[4]<<1) | (Src[5]>>7)) & 0x3f; // ..srqpo n - tmp[2] = ((Src[4]<<5) | (Src[5]>>3)) & 0x3f; // ..o nmlkj - tmp[3] = ((Src[5]<<1) | (Src[6]>>7)) & 0x3f; // ..kjihg f - tmp[4] = ((Src[5]<<5) | (Src[6]>>3)) & 0x3f; // ..g fedcb - tmp[5] = ((Src[6]<<1) | (Src[7]>>7)) & 0x3f; // ..cba98 7 - tmp[6] = ((Src[6]<<5) | (Src[7]>>3)) & 0x3f; // ..8 76543 - tmp[7] = ((Src[7]<<1) | (Src[4]>>7)) & 0x3f; // ..43210 v - - for(lop=0;lop!=4;lop++) { - tmp[lop] = (NibbleData[lop][tmp[lop*2]] & 0xf0) - | (NibbleData[lop][tmp[lop*2+1]] & 0x0f); - } - - memset(tmp+4,0,4); - for(lop=0;lop!=32;lop++) { - prm = BitSwapTable3[lop]-1; - if (tmp[prm >> 3] & BitMaskTable[prm & 7]) { - tmp[(lop >> 3) + 4] |= BitMaskTable[lop & 7]; - } - } - Src[0] ^= tmp[4]; - Src[1] ^= tmp[5]; - Src[2] ^= tmp[6]; - Src[3] ^= tmp[7]; -} - -static void decode_des_etc(unsigned char* buf, size_t len, int type, int cycle) -{ - size_t lop,cnt=0; - if(cycle<3) cycle=3; - else if(cycle<5) cycle++; - else if(cycle<7) cycle+=9; - else cycle+=15; - - for(lop=0; lop*8 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - - stream.next_out = (Bytef*) dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - - err = inflateInit(&stream); - if (err != Z_OK) return err; - - err = inflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - inflateEnd(&stream); - return err == Z_OK ? Z_BUF_ERROR : err; - } - *destLen = stream.total_out; - - err = inflateEnd(&stream); - return err; -} - -int encode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) -{ - z_stream stream; - int err; - memset(&stream, 0, sizeof(stream)); - stream.next_in = (Bytef*)source; - stream.avail_in = (uInt)sourceLen; - /* Check for source > 64K on 16-bit machine: */ - if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; - - stream.next_out = (Bytef*) dest; - stream.avail_out = (uInt)*destLen; - if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; - - stream.zalloc = (alloc_func)0; - stream.zfree = (free_func)0; - - err = deflateInit(&stream,Z_DEFAULT_COMPRESSION); - if (err != Z_OK) return err; - - err = deflate(&stream, Z_FINISH); - if (err != Z_STREAM_END) { - inflateEnd(&stream); - return err == Z_OK ? Z_BUF_ERROR : err; - } - *destLen = stream.total_out; - - err = deflateEnd(&stream); - return err; -} - -unsigned long grfio_crc32 (const unsigned char* buf, unsigned int len) -{ - return crc32(crc32(0L, Z_NULL, 0), buf, len); -} - -/*********************************************************** - *** File List Subroutines *** - ***********************************************************/ - -// initializes the table that holds the first elements of all hash chains -static void hashinit(void) -{ - int i; - for (i = 0; i < 256; i++) - filelist_hash[i] = -1; -} - -// hashes a filename string into a number from {0..255} -static int filehash(char* fname) -{ - unsigned int hash = 0; - while(*fname) { - hash = ((hash<<1) + (hash>>7)*9 + (unsigned int)tolower((unsigned char)(*fname))); - fname++; - } - return hash & 255; -} - -// finds a FILELIST entry with the specified file name -static FILELIST* filelist_find(char* fname) -{ - int hash, index; - - if (!filelist) - return NULL; - - hash = filelist_hash[filehash(fname)]; - for (index = hash; index != -1; index = filelist[index].next) - if(!strcmpi(filelist[index].fn, fname)) - break; - - return (index >= 0) ? &filelist[index] : NULL; -} - -// returns the original file name -/* -char* grfio_find_file(char* fname) -{ - FILELIST *filelist = filelist_find(fname); - if (!filelist) return NULL; - return (!filelist->fnd ? filelist->fn : filelist->fnd); -} -*/ - -// adds a FILELIST entry into the list of loaded files -static FILELIST* filelist_add(FILELIST* entry) -{ - int hash; - - #define FILELIST_ADDS 1024 // number increment of file lists ` - - if (filelist_entrys >= filelist_maxentry) { - filelist = (FILELIST *)realloc(filelist, (filelist_maxentry + FILELIST_ADDS) * sizeof(FILELIST)); - memset(filelist + filelist_maxentry, '\0', FILELIST_ADDS * sizeof(FILELIST)); - filelist_maxentry += FILELIST_ADDS; - } - - memcpy (&filelist[filelist_entrys], entry, sizeof(FILELIST)); - - hash = filehash(entry->fn); - filelist[filelist_entrys].next = filelist_hash[hash]; - filelist_hash[hash] = filelist_entrys; - - filelist_entrys++; - - return &filelist[filelist_entrys - 1]; -} - -// adds a new FILELIST entry or overwrites an existing one -static FILELIST* filelist_modify(FILELIST* entry) -{ - FILELIST* fentry = filelist_find(entry->fn); - if (fentry != NULL) { - int tmp = fentry->next; - memcpy(fentry, entry, sizeof(FILELIST)); - fentry->next = tmp; - } else { - fentry = filelist_add(entry); - } - return fentry; -} - -// shrinks the file list array if too long -static void filelist_adjust(void) -{ - if (filelist == NULL) - return; - - if (filelist_entrys < filelist_maxentry) { - filelist = (FILELIST *)realloc(filelist, filelist_entrys * sizeof(FILELIST)); - filelist_maxentry = filelist_entrys; - } -} - -/*********************************************************** - *** Grfio Sobroutines *** - ***********************************************************/ - -// returns a file's size -/* -int grfio_size(char* fname) -{ - FILELIST* entry; - - entry = filelist_find(fname); - - if (entry == NULL || entry->gentry < 0) { // LocalFileCheck - char lfname[256], *p; - FILELIST lentry; - struct stat st; - - sprintf(lfname, "%s%s", data_dir, fname); - - for (p = &lfname[0]; *p != 0; p++) - if (*p=='\\') *p = '/'; - - if (stat(lfname, &st) == 0) { - strncpy(lentry.fn, fname, sizeof(lentry.fn) - 1); - lentry.fnd = NULL; - lentry.declen = st.st_size; - lentry.gentry = 0; // 0:LocalFile - entry = filelist_modify(&lentry); - } else if (entry == NULL) { - printf("%s not found (grfio_size)\n", fname); - return -1; - } - } - return entry->declen; -} -*/ - -// reads a file into a newly allocated buffer (from grf or data directory) -void* grfio_reads(char* fname, int* size) -{ - FILE* in; - FILELIST* entry; - unsigned char* buf2 = NULL; - - entry = filelist_find(fname); - - if (entry == NULL || entry->gentry <= 0) { // LocalFileCheck - char lfname[256], *p; - FILELIST lentry; - - sprintf(lfname, "%s%s", data_dir, fname); - - for (p = &lfname[0]; *p != 0; p++) - if (*p == '\\') *p = '/'; - - in = fopen(lfname, "rb"); - if (in != NULL) { - if (entry != NULL && entry->gentry == 0) { - lentry.declen = entry->declen; - } else { - fseek(in,0,SEEK_END); - lentry.declen = ftell(in); - } - fseek(in,0,SEEK_SET); - buf2 = (unsigned char *)malloc(lentry.declen + 1024); - fread(buf2, 1, lentry.declen, in); - fclose(in); - strncpy(lentry.fn, fname, sizeof(lentry.fn) - 1); - lentry.fnd = NULL; - lentry.gentry = 0; // 0:LocalFile - entry = filelist_modify(&lentry); - } else { - if (entry != NULL && entry->gentry < 0) { - entry->gentry = -entry->gentry; // local file checked - } else { - printf("%s not found (grfio_reads - local file %s)\n", fname, lfname); - return NULL; - } - } - } - if (entry != NULL && entry->gentry > 0) { // Archive[GRF] File Read - char* grfname = gentry_table[entry->gentry - 1]; - in = fopen(grfname, "rb"); - if(in != NULL) { - unsigned char *buf = (unsigned char *)malloc(entry->srclen_aligned + 1024); - fseek(in, entry->srcpos, 0); - fread(buf, 1, entry->srclen_aligned, in); - fclose(in); - buf2 = (unsigned char *)malloc(entry->declen + 1024); - if (entry->type == 1 || entry->type == 3 || entry->type == 5) { - uLongf len; - if (entry->cycle >= 0) - decode_des_etc(buf, entry->srclen_aligned, entry->cycle == 0, entry->cycle); - len = entry->declen; - decode_zip(buf2, &len, buf, entry->srclen); - if (len != (uLong)entry->declen) { - printf("decode_zip size mismatch err: %d != %d\n", (int)len, entry->declen); - free(buf); - free(buf2); - return NULL; - } - } else { - memcpy(buf2, buf, entry->declen); - } - free(buf); - } else { - printf("%s not found (grfio_reads - GRF file %s)\n", fname, grfname); - return NULL; - } - } - if (size != NULL && entry != NULL) - *size = entry->declen; - - return buf2; -} - -/*========================================== - * Resource filename decode - *------------------------------------------*/ -static char* decode_filename(unsigned char* buf, int len) -{ - int lop; - for(lop=0;lop> 8; - - if (grf_version == 0x01) { //****** Grf version 01xx ****** - list_size = grf_size - ftell(fp); - grf_filelist = (unsigned char *) malloc(list_size); - fread(grf_filelist,1,list_size,fp); - fclose(fp); - - entrys = getlong(grf_header+0x26) - getlong(grf_header+0x22) - 7; - - // Get an entry - for (entry = 0,ofs = 0; entry < entrys; entry++) { - int ofs2, srclen, srccount; - unsigned char type; - char* period_ptr; - FILELIST aentry; - - ofs2 = ofs+getlong(grf_filelist+ofs)+4; - type = grf_filelist[ofs2+12]; - if (type != 0) { // Directory Index ... skip - fname = decode_filename(grf_filelist+ofs+6, grf_filelist[ofs]-6); - if (strlen(fname) > sizeof(aentry.fn) - 1) { - printf("GRF file name %s is too long\n", fname); - free(grf_filelist); - exit(EXIT_FAILURE); - } - srclen = 0; - if ((period_ptr = strrchr(fname, '.')) != NULL) { - for(lop = 0; lop < 4; lop++) { - if (strcmpi(period_ptr, ".gnd\0.gat\0.act\0.str"+lop*5) == 0) - break; - } - srclen = getlong(grf_filelist+ofs2) - getlong(grf_filelist+ofs2+8) - 715; - if(lop == 4) { - for(lop = 10, srccount = 1; srclen >= lop; lop = lop * 10, srccount++); - } else { - srccount = 0; - } - } else { - srccount = 0; - } - - aentry.srclen = srclen; - aentry.srclen_aligned = getlong(grf_filelist+ofs2+4)-37579; - aentry.declen = getlong(grf_filelist+ofs2+8); - aentry.srcpos = getlong(grf_filelist+ofs2+13)+0x2e; - aentry.cycle = srccount; - aentry.type = type; - strncpy(aentry.fn, fname,sizeof(aentry.fn)-1); - aentry.fnd = NULL; -#ifdef GRFIO_LOCAL - aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck -#else - aentry.gentry = gentry+1; // With no first time LocalFileCheck -#endif - filelist_modify(&aentry); - } - ofs = ofs2 + 17; - } - free(grf_filelist); - - } else if (grf_version == 0x02) { //****** Grf version 02xx ****** - unsigned char eheader[8]; - unsigned char *rBuf; - uLongf rSize, eSize; - - fread(eheader,1,8,fp); - rSize = getlong(eheader); // Read Size - eSize = getlong(eheader+4); // Extend Size - - if ((long)rSize > grf_size-ftell(fp)) { - fclose(fp); - printf("Illegal data format: GRF compress entry size\n"); - return 4; - } - - rBuf = (unsigned char *)malloc(rSize); // Get a Read Size - grf_filelist = (unsigned char *)malloc(eSize); // Get a Extend Size - fread(rBuf,1,rSize,fp); - fclose(fp); - decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function - list_size = eSize; - free(rBuf); - - entrys = getlong(grf_header+0x26) - 7; - - // Get an entry - for(entry = 0, ofs = 0; entry < entrys; entry++) { - int ofs2, srclen, srccount, type; - FILELIST aentry; - - fname = (char*)(grf_filelist+ofs); - if (strlen(fname) > sizeof(aentry.fn)-1) { - printf("GRF file name %s is too long\n", fname); - free(grf_filelist); - exit(EXIT_FAILURE); - } - ofs2 = ofs + (int)strlen(fname)+1; - type = grf_filelist[ofs2+12]; - if (type == 1 || type == 3 || type == 5) { - srclen = getlong(grf_filelist+ofs2); - if (grf_filelist[ofs2+12] == 3) { - for (lop = 10, srccount = 1; srclen >= lop; lop = lop * 10, srccount++); - } else if (grf_filelist[ofs2+12] == 5) { - srccount = 0; - } else { // if (grf_filelist[ofs2+12]==1) { - srccount = -1; - } - - aentry.srclen = srclen; - aentry.srclen_aligned = getlong(grf_filelist+ofs2+4); - aentry.declen = getlong(grf_filelist+ofs2+8); - aentry.srcpos = getlong(grf_filelist+ofs2+13)+0x2e; - aentry.cycle = srccount; - aentry.type = type; - strncpy(aentry.fn,fname,sizeof(aentry.fn)-1); - aentry.fnd = NULL; -#ifdef GRFIO_LOCAL - aentry.gentry = -(gentry+1); // As Flag for making it a negative number carrying out the first time LocalFileCheck -#else - aentry.gentry = gentry+1; // With no first time LocalFileCheck -#endif - filelist_modify(&aentry); - } - ofs = ofs2 + 17; - } - free(grf_filelist); - - } else { //****** Grf Other version ****** - fclose(fp); - printf("GRF version %04x not supported\n",getlong(grf_header+0x2a)); - return 4; - } - - filelist_adjust(); // Unnecessary area release of filelist - - return 0; // 0:no error -} - -/*========================================== - * Grfio : Resource file check - *------------------------------------------*/ -static void grfio_resourcecheck(void) -{ - char w1[256], w2[256], src[256], dst[256], restable[256], line[256]; - char *ptr, *buf; - FILELIST* entry; - int size; - FILE* fp; - - // read resnametable from data directory and return if successful - sprintf(restable, "%sdata\\resnametable.txt", data_dir); - for (ptr = &restable[0]; *ptr != 0; ptr++) - if (*ptr == '\\') *ptr = '/'; - - fp = fopen(restable, "rb"); - if (fp) { - while(fgets(line, sizeof(line), fp)) - { - if (sscanf(line, "%[^#]#%[^#]#", w1, w2) == 2 && - // we only need the maps' GAT and RSW files - (strstr(w2, ".gat") || strstr(w2, ".rsw"))) - { - sprintf(src, "data\\%s", w1); - sprintf(dst, "data\\%s", w2); - entry = filelist_find(dst); - // create new entries reusing the original's info - if (entry != NULL) { - FILELIST fentry; - memcpy(&fentry, entry, sizeof(FILELIST)); - strncpy(fentry.fn, src, sizeof(fentry.fn) - 1); - fentry.fnd = strdup(dst); - filelist_modify(&fentry); - } - } - } - fclose(fp); - return; // we're done here! - } - - // read resnametable from loaded GRF's, only if it cannot be loaded from the data directory - buf = (char *)grfio_reads("data\\resnametable.txt", &size); - if (buf) { - buf[size] = 0; - - ptr = buf; - while (ptr - buf < size) { - if (sscanf(ptr, "%[^#]#%[^#]#", w1, w2) == 2 && - (strstr(w2, ".gat") || strstr(w2, ".rsw"))) - { - sprintf(src, "data\\%s", w1); - sprintf(dst, "data\\%s", w2); - entry = filelist_find(dst); - if (entry != NULL) { - FILELIST fentry; - memcpy(&fentry, entry, sizeof(FILELIST)); - strncpy(fentry.fn, src, sizeof(fentry.fn) - 1); - fentry.fnd = strdup(dst); - filelist_modify(&fentry); - } - } - ptr = strchr(ptr, '\n'); // Next line - if (!ptr) break; - ptr++; - } - free(buf); - return; - } - -} - -// reads a grf file and adds it to the list -static int grfio_add(char* fname) -{ - #define GENTRY_ADDS 4 // The number increment of gentry_table entries - - if (gentry_entrys >= gentry_maxentry) { - gentry_maxentry += GENTRY_ADDS; - gentry_table = (char**)realloc(gentry_table, gentry_maxentry * sizeof(char*)); - memset(gentry_table + (gentry_maxentry - GENTRY_ADDS), 0, sizeof(char*) * GENTRY_ADDS); - } - - gentry_table[gentry_entrys++] = strdup(fname); - - return grfio_entryread(fname, gentry_entrys - 1); -} - -// removes all entries -void grfio_final(void) -{ - if (filelist != NULL) { - int i; - for (i = 0; i < filelist_entrys; i++) - if (filelist[i].fnd != NULL) - free(filelist[i].fnd); - - free(filelist); - filelist = NULL; - } - filelist_entrys = filelist_maxentry = 0; - - if (gentry_table != NULL) { - int i; - for (i = 0; i < gentry_entrys; i++) - if (gentry_table[i] != NULL) - free(gentry_table[i]); - - free(gentry_table); - gentry_table = NULL; - } - gentry_entrys = gentry_maxentry = 0; -} - -/*========================================== - * Grfio : Initialize - *------------------------------------------*/ -void grfio_init(char* fname) -{ - FILE* data_conf; - char line[1024], w1[1024], w2[1024]; - int grf_num = 0; - - hashinit(); // hash table initialization - - data_conf = fopen(fname, "r"); - // It will read, if there is grf-files.txt. - if (data_conf) { - while(fgets(line, sizeof(line), data_conf)) - { - if (line[0] == '/' && line[1] == '/') - continue; - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) - continue; - // Entry table reading - if(strcmp(w1, "grf") == 0) // GRF file - grf_num += (grfio_add(w2) == 0); - else if(strcmp(w1,"data_dir") == 0) { // Data directory - strcpy(data_dir, w2); - printf("Use data directory %s\n", w2); - } - } - fclose(data_conf); - } // end of reading grf-files.txt - - if (grf_num == 0) { - printf("No GRF loaded, using default data directory\n"); - } - - // Unneccessary area release of filelist - filelist_adjust(); - - // Resource check - grfio_resourcecheck(); - - return; -} diff --git a/src/tool/grfio.h b/src/tool/grfio.h deleted file mode 100644 index 57439b16d..000000000 --- a/src/tool/grfio.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _GRFIO_H_ -#define _GRFIO_H_ - -void grfio_init(char*); // GRFIO Initialize -void grfio_final(void); // GRFIO Finalize -void* grfio_reads(char*,int*); // GRFIO data file read & size get -char *grfio_find_file(char *fname); - -#define grfio_read(fn) grfio_reads(fn, NULL) - -int grfio_size(char*); // GRFIO data file size get -unsigned long grfio_crc32(const unsigned char *buf, unsigned int len); - -int decode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); -int encode_zip(unsigned char *dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen); - -#endif /* _GRFIO_H_ */ diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 49e1826ab..f782331ca 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -1,6 +1,12 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder +#include "../common/cbasetypes.h" +#include "../common/grfio.h" +#include "../common/malloc.h" +#include "../common/mmo.h" +#include "../common/showmsg.h" + #include #include #include @@ -9,11 +15,6 @@ #include #endif -#include "../common/cbasetypes.h" -#include "grfio.h" - -#define MAP_NAME_LENGTH 12 -#define MAP_NAME_LENGTH_EXT 16 #define NO_WATER 1000000 char grf_list_file[256] = "conf/grf-files.txt"; @@ -124,7 +125,7 @@ int read_map(char *name, struct map_data *m) // Read water height if (rsw) { water_height = (int)GetFloat(rsw+166); - free(rsw); + aFree(rsw); } else water_height = NO_WATER; @@ -132,11 +133,11 @@ int read_map(char *name, struct map_data *m) m->xs = (int16)GetULong(gat+6); m->ys = (int16)GetULong(gat+10); if (m->xs <= 0 || m->ys <= 0) { - free(gat); + aFree(gat); return 0; } num_cells = (size_t)m->xs*(size_t)m->ys; - m->cells = (unsigned char *)malloc(num_cells); + m->cells = (unsigned char *)aMalloc(num_cells); // Set cell properties off = 14; @@ -154,7 +155,7 @@ int read_map(char *name, struct map_data *m) m->cells[xy] = (unsigned char)type; } - free(gat); + aFree(gat); return 1; } @@ -168,7 +169,7 @@ void cache_map(char *name, struct map_data *m) // Create an output buffer twice as big as the uncompressed map... this way we're sure it fits len = (unsigned long)m->xs*(unsigned long)m->ys*2; - write_buf = (unsigned char *)malloc(len); + write_buf = (unsigned char *)aMalloc(len); // Compress the cells and get the compressed length encode_zip(write_buf, &len, m->cells, m->xs*m->ys); @@ -185,8 +186,8 @@ void cache_map(char *name, struct map_data *m) header.file_size += sizeof(struct map_info) + len; header.map_count++; - free(write_buf); - free(m->cells); + aFree(write_buf); + aFree(m->cells); return; } @@ -245,7 +246,7 @@ void process_args(int argc, char *argv[]) } -int main(int argc, char *argv[]) +int do_init(int argc, char *argv[]) { FILE *list; char line[1024]; @@ -255,15 +256,15 @@ int main(int argc, char *argv[]) // Process the command-line arguments process_args(argc, argv); - printf("Initializing grfio with %s\n", grf_list_file); + ShowStatus("Initializing grfio with %s\n", grf_list_file); grfio_init(grf_list_file); // Attempt to open the map cache file and force rebuild if not found - printf("Opening map cache: %s\n", map_cache_file); + ShowStatus("Opening map cache: %s\n", map_cache_file); if(!rebuild) { map_cache_fp = fopen(map_cache_file, "rb"); if(map_cache_fp == NULL) { - printf("Existing map cache not found, forcing rebuild mode\n"); + ShowNotice("Existing map cache not found, forcing rebuild mode\n"); rebuild = 1; } else fclose(map_cache_fp); @@ -273,15 +274,15 @@ int main(int argc, char *argv[]) else map_cache_fp = fopen(map_cache_file, "r+b"); if(map_cache_fp == NULL) { - printf("Failure when opening map cache file %s\n", map_cache_file); + ShowError("Failure when opening map cache file %s\n", map_cache_file); exit(EXIT_FAILURE); } // Open the map list - printf("Opening map list: %s\n", map_list_file); + ShowStatus("Opening map list: %s\n", map_list_file); list = fopen(map_list_file, "r"); if(list == NULL) { - printf("Failure when opening maps list file %s\n", map_list_file); + ShowError("Failure when opening maps list file %s\n", map_list_file); exit(EXIT_FAILURE); } @@ -309,30 +310,33 @@ int main(int argc, char *argv[]) name[MAP_NAME_LENGTH_EXT-1] = '\0'; remove_extension(name); - printf("%s", name); if(find_map(name)) - printf(" already in cache!\n"); + ShowInfo("Map '"CL_WHITE"%s"CL_RESET"' already in cache.\n", name); else if(read_map(name, &map)) { cache_map(name, &map); - printf(" successfully cached\n"); + ShowInfo("Map '"CL_WHITE"%s"CL_RESET"' successfully cached.\n", name); } else - printf(" not found in GRF!\n"); + ShowError("Map '"CL_WHITE"%s"CL_RESET"' not found!\n", name); } - printf("Closing map list: %s\n", map_list_file); + ShowStatus("Closing map list: %s\n", map_list_file); fclose(list); // Write the main header and close the map cache - printf("Closing map cache: %s\n", map_cache_file); + ShowStatus("Closing map cache: %s\n", map_cache_file); fseek(map_cache_fp, 0, SEEK_SET); fwrite(&header, sizeof(struct main_header), 1, map_cache_fp); fclose(map_cache_fp); - printf("Finalizing grfio\n"); + ShowStatus("Finalizing grfio\n"); grfio_final(); - printf("%d maps now in cache\n", header.map_count); + ShowInfo("%d maps now in cache\n", header.map_count); return 0; } + +void do_final(void) +{ +} diff --git a/vcproj-10/mapcache.vcxproj b/vcproj-10/mapcache.vcxproj index 04c6edc67..47dc9a250 100644 --- a/vcproj-10/mapcache.vcxproj +++ b/vcproj-10/mapcache.vcxproj @@ -48,7 +48,7 @@ Disabled ..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MINICORE;%(PreprocessorDefinitions) false false true @@ -90,7 +90,7 @@ true true ..\3rdparty\zlib\include;..\3rdparty\msinttypes\include;%(AdditionalIncludeDirectories) - WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;%(PreprocessorDefinitions) + WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MINICORE;%(PreprocessorDefinitions) true MultiThreaded false @@ -120,11 +120,24 @@ - + + + + + + - + + + + + + + + + diff --git a/vcproj-7.1/mapcache.vcproj b/vcproj-7.1/mapcache.vcproj index fe57a98b6..af62d5194 100644 --- a/vcproj-7.1/mapcache.vcproj +++ b/vcproj-7.1/mapcache.vcproj @@ -20,7 +20,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\msinttypes\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;MINICORE" MinimalRebuild="TRUE" ExceptionHandling="FALSE" BasicRuntimeChecks="3" @@ -87,7 +87,7 @@ OptimizeForProcessor="2" OptimizeForWindowsApplication="TRUE" AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\msinttypes\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;MINICORE" StringPooling="TRUE" RuntimeLibrary="3" DefaultCharIsUnsigned="FALSE" @@ -138,14 +138,57 @@ + RelativePath="..\src\common\cbasetypes.h"> + + + + + + + + + + + + + + + RelativePath="..\src\common\showmsg.c"> + + + + + + + + + + + + + + diff --git a/vcproj-8/mapcache.vcproj b/vcproj-8/mapcache.vcproj index d09280d33..3c6585c13 100644 --- a/vcproj-8/mapcache.vcproj +++ b/vcproj-8/mapcache.vcproj @@ -41,7 +41,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\msinttypes\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MINICORE" GeneratePreprocessedFile="0" MinimalRebuild="true" ExceptionHandling="0" @@ -131,7 +131,7 @@ EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\msinttypes\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MINICORE" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="false" @@ -192,16 +192,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vcproj-9/mapcache.vcproj b/vcproj-9/mapcache.vcproj index 95bd96e55..f25c016f3 100644 --- a/vcproj-9/mapcache.vcproj +++ b/vcproj-9/mapcache.vcproj @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\msinttypes\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MINICORE" GeneratePreprocessedFile="0" MinimalRebuild="true" ExceptionHandling="0" @@ -134,7 +134,7 @@ EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\msinttypes\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;MINICORE" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="false" @@ -197,16 +197,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3-70-g09d2 From 6ab4ccb4d3d6cb959776d4800bcd5e92b3dd7ac2 Mon Sep 17 00:00:00 2001 From: eathenabot Date: Sun, 11 Dec 2011 20:43:49 +0000 Subject: * Merged changes up to eAthena 15014. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15063 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/CMakeLists.txt | 2 + src/common/Makefile.in | 4 +- src/common/des.c | 218 +++++++++++++++++++++++++++++++ src/common/des.h | 15 +++ src/common/grfio.c | 186 +++++++++----------------- src/map/Makefile.in | 4 +- src/tool/CMakeLists.txt | 2 + src/tool/Makefile.in | 4 +- vcproj-10/map-server_sql.vcxproj.filters | 3 + vcproj-10/map-server_txt.vcxproj.filters | 3 + vcproj-9/map-server_sql.vcproj | 8 ++ vcproj-9/map-server_txt.vcproj | 8 ++ vcproj-9/mapcache.vcproj | 8 ++ 13 files changed, 337 insertions(+), 128 deletions(-) create mode 100644 src/common/des.c create mode 100644 src/common/des.h (limited to 'src/tool/Makefile.in') diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index ea8ce6b71..3f04e5b04 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -60,6 +60,7 @@ set( COMMON_BASE_HEADERS ${COMMON_ALL_HEADERS} "${COMMON_SOURCE_DIR}/core.h" "${COMMON_SOURCE_DIR}/db.h" + "${COMMON_SOURCE_DIR}/des.h" "${COMMON_SOURCE_DIR}/ers.h" "${COMMON_SOURCE_DIR}/grfio.h" "${COMMON_SOURCE_DIR}/lock.h" @@ -78,6 +79,7 @@ set( COMMON_BASE_HEADERS set( COMMON_BASE_SOURCES "${COMMON_SOURCE_DIR}/core.c" "${COMMON_SOURCE_DIR}/db.c" + "${COMMON_SOURCE_DIR}/des.c" "${COMMON_SOURCE_DIR}/ers.c" "${COMMON_SOURCE_DIR}/grfio.c" "${COMMON_SOURCE_DIR}/lock.c" diff --git a/src/common/Makefile.in b/src/common/Makefile.in index 37606dde2..9e92a8886 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -2,11 +2,11 @@ COMMON_OBJ = obj_all/core.o obj_all/socket.o obj_all/timer.o obj_all/db.o obj_all/plugins.o obj_all/lock.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/minicore.o obj_all/minisocket.o obj_all/minimalloc.o obj_all/random.o obj_all/des.o COMMON_H = svnversion.h mmo.h plugin.h version.h \ core.h socket.h timer.h db.h plugins.h lock.h \ nullpo.h malloc.h showmsg.h strlib.h utils.h \ - grfio.h mapindex.h ers.h md5calc.h random.h + grfio.h mapindex.h ers.h md5calc.h random.h des.h COMMON_SQL_OBJ = obj_sql/sql.o COMMON_SQL_H = sql.h diff --git a/src/common/des.c b/src/common/des.c new file mode 100644 index 000000000..67a3a38d1 --- /dev/null +++ b/src/common/des.c @@ -0,0 +1,218 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder +#include "../common/cbasetypes.h" +#include "../common/des.h" + + +/// DES (Data Encryption Standard) algorithm, modified version. +/// @see http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=5099. +/// @see http://en.wikipedia.org/wiki/Data_Encryption_Standard +/// @see http://en.wikipedia.org/wiki/DES_supplementary_material + + +/// Bitmask for accessing individual bits of a byte. +static const uint8_t mask[8] = { + 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 +}; + + +/// Initial permutation (IP). +static void IP(BIT64* src) +{ + BIT64 tmp = {0}; + + static const uint8_t ip_table[64] = { + 58, 50, 42, 34, 26, 18, 10, 2, + 60, 52, 44, 36, 28, 20, 12, 4, + 62, 54, 46, 38, 30, 22, 14, 6, + 64, 56, 48, 40, 32, 24, 16, 8, + 57, 49, 41, 33, 25, 17, 9, 1, + 59, 51, 43, 35, 27, 19, 11, 3, + 61, 53, 45, 37, 29, 21, 13, 5, + 63, 55, 47, 39, 31, 23, 15, 7, + }; + + size_t i; + for( i = 0; i < ARRAYLENGTH(ip_table); ++i ) + { + uint8_t j = ip_table[i] - 1; + if( src->b[(j >> 3) & 7] & mask[j & 7] ) + tmp .b[(i >> 3) & 7] |= mask[i & 7]; + } + + *src = tmp; +} + + +/// Final permutation (IP^-1). +static void FP(BIT64* src) +{ + BIT64 tmp = {0}; + + static const uint8_t fp_table[64] = { + 40, 8, 48, 16, 56, 24, 64, 32, + 39, 7, 47, 15, 55, 23, 63, 31, + 38, 6, 46, 14, 54, 22, 62, 30, + 37, 5, 45, 13, 53, 21, 61, 29, + 36, 4, 44, 12, 52, 20, 60, 28, + 35, 3, 43, 11, 51, 19, 59, 27, + 34, 2, 42, 10, 50, 18, 58, 26, + 33, 1, 41, 9, 49, 17, 57, 25, + }; + + size_t i; + for( i = 0; i < ARRAYLENGTH(fp_table); ++i ) + { + uint8_t j = fp_table[i] - 1; + if( src->b[(j >> 3) & 7] & mask[j & 7] ) + tmp .b[(i >> 3) & 7] |= mask[i & 7]; + } + + *src = tmp; +} + + +/// Expansion (E). +/// Expands upper four 8-bits (32b) into eight 6-bits (48b). +static void E(BIT64* src) +{ + BIT64 tmp = {0}; + +if( false ) +{// original + static const uint8_t expand_table[48] = { + 32, 1, 2, 3, 4, 5, + 4, 5, 6, 7, 8, 9, + 8, 9, 10, 11, 12, 13, + 12, 13, 14, 15, 16, 17, + 16, 17, 18, 19, 20, 21, + 20, 21, 22, 23, 24, 25, + 24, 25, 26, 27, 28, 29, + 28, 29, 30, 31, 32, 1, + }; + + size_t i; + for( i = 0; i < ARRAYLENGTH(expand_table); ++i ) + { + uint8_t j = expand_table[i] - 1; + if( src->b[j / 8 + 4] & mask[j % 8] ) + tmp .b[i / 6 + 0] |= mask[i % 6]; + } +} +else +{// optimized + tmp.b[0] = ((src->b[7]<<5) | (src->b[4]>>3)) & 0x3f; // ..0 vutsr + tmp.b[1] = ((src->b[4]<<1) | (src->b[5]>>7)) & 0x3f; // ..srqpo n + tmp.b[2] = ((src->b[4]<<5) | (src->b[5]>>3)) & 0x3f; // ..o nmlkj + tmp.b[3] = ((src->b[5]<<1) | (src->b[6]>>7)) & 0x3f; // ..kjihg f + tmp.b[4] = ((src->b[5]<<5) | (src->b[6]>>3)) & 0x3f; // ..g fedcb + tmp.b[5] = ((src->b[6]<<1) | (src->b[7]>>7)) & 0x3f; // ..cba98 7 + tmp.b[6] = ((src->b[6]<<5) | (src->b[7]>>3)) & 0x3f; // ..8 76543 + tmp.b[7] = ((src->b[7]<<1) | (src->b[4]>>7)) & 0x3f; // ..43210 v +} + + *src = tmp; +} + + +/// Transposition (P-BOX). +static void TP(BIT64* src) +{ + BIT64 tmp = {0}; + + static const uint8_t tp_table[32] = { + 16, 7, 20, 21, + 29, 12, 28, 17, + 1, 15, 23, 26, + 5, 18, 31, 10, + 2, 8, 24, 14, + 32, 27, 3, 9, + 19, 13, 30, 6, + 22, 11, 4, 25, + }; + + size_t i; + for( i = 0; i < ARRAYLENGTH(tp_table); ++i ) + { + uint8_t j = tp_table[i] - 1; + if( src->b[(j >> 3) + 0] & mask[j & 7] ) + tmp .b[(i >> 3) + 4] |= mask[i & 7]; + } + + *src = tmp; +} + + +/// Substitution boxes (S-boxes). +/// NOTE: This implementation was optimized to process two nibbles in one step (twice as fast). +static void SBOX(BIT64* src) +{ + BIT64 tmp = {0}; + + static const uint8_t s_table[4][64] = { + { + 0xef, 0x03, 0x41, 0xfd, 0xd8, 0x74, 0x1e, 0x47, 0x26, 0xef, 0xfb, 0x22, 0xb3, 0xd8, 0x84, 0x1e, + 0x39, 0xac, 0xa7, 0x60, 0x62, 0xc1, 0xcd, 0xba, 0x5c, 0x96, 0x90, 0x59, 0x05, 0x3b, 0x7a, 0x85, + 0x40, 0xfd, 0x1e, 0xc8, 0xe7, 0x8a, 0x8b, 0x21, 0xda, 0x43, 0x64, 0x9f, 0x2d, 0x14, 0xb1, 0x72, + 0xf5, 0x5b, 0xc8, 0xb6, 0x9c, 0x37, 0x76, 0xec, 0x39, 0xa0, 0xa3, 0x05, 0x52, 0x6e, 0x0f, 0xd9, + },{ + 0xa7, 0xdd, 0x0d, 0x78, 0x9e, 0x0b, 0xe3, 0x95, 0x60, 0x36, 0x36, 0x4f, 0xf9, 0x60, 0x5a, 0xa3, + 0x11, 0x24, 0xd2, 0x87, 0xc8, 0x52, 0x75, 0xec, 0xbb, 0xc1, 0x4c, 0xba, 0x24, 0xfe, 0x8f, 0x19, + 0xda, 0x13, 0x66, 0xaf, 0x49, 0xd0, 0x90, 0x06, 0x8c, 0x6a, 0xfb, 0x91, 0x37, 0x8d, 0x0d, 0x78, + 0xbf, 0x49, 0x11, 0xf4, 0x23, 0xe5, 0xce, 0x3b, 0x55, 0xbc, 0xa2, 0x57, 0xe8, 0x22, 0x74, 0xce, + },{ + 0x2c, 0xea, 0xc1, 0xbf, 0x4a, 0x24, 0x1f, 0xc2, 0x79, 0x47, 0xa2, 0x7c, 0xb6, 0xd9, 0x68, 0x15, + 0x80, 0x56, 0x5d, 0x01, 0x33, 0xfd, 0xf4, 0xae, 0xde, 0x30, 0x07, 0x9b, 0xe5, 0x83, 0x9b, 0x68, + 0x49, 0xb4, 0x2e, 0x83, 0x1f, 0xc2, 0xb5, 0x7c, 0xa2, 0x19, 0xd8, 0xe5, 0x7c, 0x2f, 0x83, 0xda, + 0xf7, 0x6b, 0x90, 0xfe, 0xc4, 0x01, 0x5a, 0x97, 0x61, 0xa6, 0x3d, 0x40, 0x0b, 0x58, 0xe6, 0x3d, + },{ + 0x4d, 0xd1, 0xb2, 0x0f, 0x28, 0xbd, 0xe4, 0x78, 0xf6, 0x4a, 0x0f, 0x93, 0x8b, 0x17, 0xd1, 0xa4, + 0x3a, 0xec, 0xc9, 0x35, 0x93, 0x56, 0x7e, 0xcb, 0x55, 0x20, 0xa0, 0xfe, 0x6c, 0x89, 0x17, 0x62, + 0x17, 0x62, 0x4b, 0xb1, 0xb4, 0xde, 0xd1, 0x87, 0xc9, 0x14, 0x3c, 0x4a, 0x7e, 0xa8, 0xe2, 0x7d, + 0xa0, 0x9f, 0xf6, 0x5c, 0x6a, 0x09, 0x8d, 0xf0, 0x0f, 0xe3, 0x53, 0x25, 0x95, 0x36, 0x28, 0xcb, + } + }; + + size_t i; + for( i = 0; i < ARRAYLENGTH(s_table); ++i ) + { + tmp.b[i] = (s_table[i][src->b[i*2+0]] & 0xf0) + | (s_table[i][src->b[i*2+1]] & 0x0f); + } + + *src = tmp; +} + + +/// DES round function. +/// XORs src[0..3] with TP(SBOX(E(src[4..7]))). +static void RoundFunction(BIT64* src) +{ + BIT64 tmp = *src; + E(&tmp); + SBOX(&tmp); + TP(&tmp); + + src->b[0] ^= tmp.b[4]; + src->b[1] ^= tmp.b[5]; + src->b[2] ^= tmp.b[6]; + src->b[3] ^= tmp.b[7]; +} + + +void des_decrypt_block(BIT64* block) +{ + IP(block); + RoundFunction(block); + FP(block); +} + + +void des_decrypt(unsigned char* data, size_t size) +{ + BIT64* p = (BIT64*)data; + size_t i; + + for( i = 0; i*8 < size; i += 8 ) + des_decrypt_block(p); +} diff --git a/src/common/des.h b/src/common/des.h new file mode 100644 index 000000000..e42136436 --- /dev/null +++ b/src/common/des.h @@ -0,0 +1,15 @@ +// Copyright (c) Athena Dev Teams - Licensed under GNU GPL +// For more information, see LICENCE in the main folder +#ifndef _DES_H_ +#define _DES_H_ + + +/// One 64-bit block. +typedef struct BIT64 { uint8_t b[8]; } BIT64; + + +void des_decrypt_block(BIT64* block); +void des_decrypt(unsigned char* data, size_t size); + + +#endif // _DES_H_ diff --git a/src/common/grfio.c b/src/common/grfio.c index 1d1ce756f..eefeb8296 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -2,8 +2,9 @@ // For more information, see LICENCE in the main folder #include "../common/cbasetypes.h" -#include "../common/showmsg.h" +#include "../common/des.h" #include "../common/malloc.h" +#include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/utils.h" #include "grfio.h" @@ -57,63 +58,12 @@ char data_dir[1024] = ""; //---------------------------- int filelist_hash[256]; -//---------------------------- -// grf decode data table -//---------------------------- -static unsigned char BitMaskTable[8] = { - 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 -}; - -static char BitSwapTable1[64] = { - 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, - 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, - 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, - 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7 -}; -static char BitSwapTable2[64] = { - 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, - 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, - 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, - 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25 -}; -static char BitSwapTable3[32] = { - 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, - 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 -}; - -static unsigned char NibbleData[4][64]={ - { - 0xef, 0x03, 0x41, 0xfd, 0xd8, 0x74, 0x1e, 0x47, 0x26, 0xef, 0xfb, 0x22, 0xb3, 0xd8, 0x84, 0x1e, - 0x39, 0xac, 0xa7, 0x60, 0x62, 0xc1, 0xcd, 0xba, 0x5c, 0x96, 0x90, 0x59, 0x05, 0x3b, 0x7a, 0x85, - 0x40, 0xfd, 0x1e, 0xc8, 0xe7, 0x8a, 0x8b, 0x21, 0xda, 0x43, 0x64, 0x9f, 0x2d, 0x14, 0xb1, 0x72, - 0xf5, 0x5b, 0xc8, 0xb6, 0x9c, 0x37, 0x76, 0xec, 0x39, 0xa0, 0xa3, 0x05, 0x52, 0x6e, 0x0f, 0xd9, - }, { - 0xa7, 0xdd, 0x0d, 0x78, 0x9e, 0x0b, 0xe3, 0x95, 0x60, 0x36, 0x36, 0x4f, 0xf9, 0x60, 0x5a, 0xa3, - 0x11, 0x24, 0xd2, 0x87, 0xc8, 0x52, 0x75, 0xec, 0xbb, 0xc1, 0x4c, 0xba, 0x24, 0xfe, 0x8f, 0x19, - 0xda, 0x13, 0x66, 0xaf, 0x49, 0xd0, 0x90, 0x06, 0x8c, 0x6a, 0xfb, 0x91, 0x37, 0x8d, 0x0d, 0x78, - 0xbf, 0x49, 0x11, 0xf4, 0x23, 0xe5, 0xce, 0x3b, 0x55, 0xbc, 0xa2, 0x57, 0xe8, 0x22, 0x74, 0xce, - }, { - 0x2c, 0xea, 0xc1, 0xbf, 0x4a, 0x24, 0x1f, 0xc2, 0x79, 0x47, 0xa2, 0x7c, 0xb6, 0xd9, 0x68, 0x15, - 0x80, 0x56, 0x5d, 0x01, 0x33, 0xfd, 0xf4, 0xae, 0xde, 0x30, 0x07, 0x9b, 0xe5, 0x83, 0x9b, 0x68, - 0x49, 0xb4, 0x2e, 0x83, 0x1f, 0xc2, 0xb5, 0x7c, 0xa2, 0x19, 0xd8, 0xe5, 0x7c, 0x2f, 0x83, 0xda, - 0xf7, 0x6b, 0x90, 0xfe, 0xc4, 0x01, 0x5a, 0x97, 0x61, 0xa6, 0x3d, 0x40, 0x0b, 0x58, 0xe6, 0x3d, - }, { - 0x4d, 0xd1, 0xb2, 0x0f, 0x28, 0xbd, 0xe4, 0x78, 0xf6, 0x4a, 0x0f, 0x93, 0x8b, 0x17, 0xd1, 0xa4, - 0x3a, 0xec, 0xc9, 0x35, 0x93, 0x56, 0x7e, 0xcb, 0x55, 0x20, 0xa0, 0xfe, 0x6c, 0x89, 0x17, 0x62, - 0x17, 0x62, 0x4b, 0xb1, 0xb4, 0xde, 0xd1, 0x87, 0xc9, 0x14, 0x3c, 0x4a, 0x7e, 0xa8, 0xe2, 0x7d, - 0xa0, 0x9f, 0xf6, 0x5c, 0x6a, 0x09, 0x8d, 0xf0, 0x0f, 0xe3, 0x53, 0x25, 0x95, 0x36, 0x28, 0xcb, - } -}; - // little endian char array to uint conversion static unsigned int getlong(unsigned char* p) { return (p[0] | p[1] << 0x08 | p[2] << 0x10 | p[3] << 0x18); } -/*========================================== - * Grf data decode : Subs - *------------------------------------------*/ static void NibbleSwap(unsigned char* Src, int len) { for(;0> 3) & 7] & BitMaskTable[prm & 7]) { - tmp[(lop >> 3) & 7] |= BitMaskTable[lop & 7]; - } + uint8_t out; + + switch( in ) + { + case 0x00: out = 0x2B; break; + case 0x2B: out = 0x00; break; + case 0x6C: out = 0x80; break; + case 0x01: out = 0x68; break; + case 0x68: out = 0x01; break; + case 0x48: out = 0x77; break; + case 0x60: out = 0xFF; break; + case 0x77: out = 0x48; break; + case 0xB9: out = 0xC0; break; + case 0xC0: out = 0xB9; break; + case 0xFE: out = 0xEB; break; + case 0xEB: out = 0xFE; break; + case 0x80: out = 0x6C; break; + case 0xFF: out = 0x60; break; + default: out = in; break; } - memcpy(Src,tmp,8); + + return out; } -static void BitConvert4(unsigned char* Src) + +static void grf_shuffle_enc(BIT64* src) { - int lop,prm; - unsigned char tmp[8]; - tmp[0] = ((Src[7]<<5) | (Src[4]>>3)) & 0x3f; // ..0 vutsr - tmp[1] = ((Src[4]<<1) | (Src[5]>>7)) & 0x3f; // ..srqpo n - tmp[2] = ((Src[4]<<5) | (Src[5]>>3)) & 0x3f; // ..o nmlkj - tmp[3] = ((Src[5]<<1) | (Src[6]>>7)) & 0x3f; // ..kjihg f - tmp[4] = ((Src[5]<<5) | (Src[6]>>3)) & 0x3f; // ..g fedcb - tmp[5] = ((Src[6]<<1) | (Src[7]>>7)) & 0x3f; // ..cba98 7 - tmp[6] = ((Src[6]<<5) | (Src[7]>>3)) & 0x3f; // ..8 76543 - tmp[7] = ((Src[7]<<1) | (Src[4]>>7)) & 0x3f; // ..43210 v - - for(lop=0;lop!=4;lop++) { - tmp[lop] = (NibbleData[lop][tmp[lop*2]] & 0xf0) - | (NibbleData[lop][tmp[lop*2+1]] & 0x0f); - } + BIT64 out; + + out.b[0] = src->b[3]; + out.b[1] = src->b[4]; + out.b[2] = src->b[5]; + out.b[3] = src->b[0]; + out.b[4] = src->b[1]; + out.b[5] = src->b[6]; + out.b[6] = src->b[2]; + out.b[7] = grf_substitution(src->b[7]); + + *src = out; +} - memset(tmp+4,0,4); - for(lop=0;lop!=32;lop++) { - prm = BitSwapTable3[lop]-1; - if (tmp[prm >> 3] & BitMaskTable[prm & 7]) { - tmp[(lop >> 3) + 4] |= BitMaskTable[lop & 7]; - } - } - Src[0] ^= tmp[4]; - Src[1] ^= tmp[5]; - Src[2] ^= tmp[6]; - Src[3] ^= tmp[7]; + +static void grf_shuffle_dec(BIT64* src) +{ + BIT64 out; + + out.b[0] = src->b[3]; + out.b[1] = src->b[4]; + out.b[2] = src->b[6]; + out.b[3] = src->b[0]; + out.b[4] = src->b[1]; + out.b[5] = src->b[2]; + out.b[6] = src->b[5]; + out.b[7] = grf_substitution(src->b[7]); + + *src = out; } + static void decode_des_etc(unsigned char* buf, size_t len, int type, int cycle) { + BIT64* p = (BIT64*)buf; + size_t lop,cnt=0; if(cycle<3) cycle=3; else if(cycle<5) cycle++; else if(cycle<7) cycle+=9; else cycle+=15; - for(lop=0; lop*8 common + + common + common diff --git a/vcproj-10/map-server_txt.vcxproj.filters b/vcproj-10/map-server_txt.vcxproj.filters index bf2d728ae..a90302f0c 100644 --- a/vcproj-10/map-server_txt.vcxproj.filters +++ b/vcproj-10/map-server_txt.vcxproj.filters @@ -28,6 +28,9 @@ common + + common + common diff --git a/vcproj-9/map-server_sql.vcproj b/vcproj-9/map-server_sql.vcproj index d2c8192c2..d743bf0ed 100644 --- a/vcproj-9/map-server_sql.vcproj +++ b/vcproj-9/map-server_sql.vcproj @@ -235,6 +235,14 @@ RelativePath="..\src\common\db.h" > + + + + diff --git a/vcproj-9/map-server_txt.vcproj b/vcproj-9/map-server_txt.vcproj index 6291089a9..9e8abc1fd 100644 --- a/vcproj-9/map-server_txt.vcproj +++ b/vcproj-9/map-server_txt.vcproj @@ -530,6 +530,14 @@ RelativePath="..\src\common\db.h" > + + + + diff --git a/vcproj-9/mapcache.vcproj b/vcproj-9/mapcache.vcproj index 2fb78f198..94245c054 100644 --- a/vcproj-9/mapcache.vcproj +++ b/vcproj-9/mapcache.vcproj @@ -212,6 +212,14 @@ RelativePath="..\src\common\des.h" > + + + + -- cgit v1.2.3-70-g09d2 From 526217d77d50dc27b0815e3d5895df7bfa38ff76 Mon Sep 17 00:00:00 2001 From: gepard1984 Date: Mon, 13 Feb 2012 01:19:04 +0000 Subject: - Added `libconfig` (configuration file library: http://www.hyperrealm.com/libconfig/): - Updated VS9/10 project files. - Updated `configure` & `Makefile`s. - New GM, Commands & Permissions system: - '''This is a backwards compatibility breaking update''', please read tid:58877 - Replaced GM levels with Player Groups. - Commands permissions & other privileges now depend on group, not GM level. - `@help` command improvements: requires "commandname" param and shows more detailed info about commands. - Modified GM whisper system to deliver messages basing on permissions, not GM level. - Remote trade request is now possible only if player is allowed to use `@trade` command as well. - Added a proper permission to use `/changemaptype` command. - `clif_displaymessage` is now capable of displaying multiline messages. - All `ACMD_FUNC`s are static now, and the only way to invoke them is with `is_atcommand()`; all client commands (starting with `/`) are now translated into corresponding atcommands (with exception of `/kick` used on monster, as there is no atcommand to kill single monster). - Removed nonsense "bot check" triggering when player blocked (`/ex`) Server. - Merged `@monster`, `@monsterbig` and `@monstersmall`. - Improved flow of atcommand execution to avoid revealing info about online players or existing commands to non-privileged players. - Merged `atcommand` and `charcommand` script functions (`charcommand` is aliased to `atcommand`). - Fixed `atcommand` script function reading unknown memory area (possible access violation). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15572 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/libconfig/LICENSE | 674 ++++++++ 3rdparty/libconfig/Makefile.in | 24 + 3rdparty/libconfig/grammar.c | 2001 +++++++++++++++++++++++ 3rdparty/libconfig/grammar.h | 113 ++ 3rdparty/libconfig/libconfig-1.4.8 | 0 3rdparty/libconfig/libconfig.c | 1615 +++++++++++++++++++ 3rdparty/libconfig/libconfig.h | 320 ++++ 3rdparty/libconfig/parsectx.h | 47 + 3rdparty/libconfig/scanctx.c | 170 ++ 3rdparty/libconfig/scanctx.h | 61 + 3rdparty/libconfig/scanner.c | 2362 ++++++++++++++++++++++++++++ 3rdparty/libconfig/scanner.h | 326 ++++ 3rdparty/libconfig/strbuf.c | 57 + 3rdparty/libconfig/strbuf.h | 39 + 3rdparty/libconfig/wincompat.h | 89 ++ Makefile.in | 13 +- conf/atcommand_athena.conf | 813 +--------- conf/battle/gm.conf | 87 - conf/char_athena.conf | 6 +- conf/groups.conf | 274 ++++ conf/help.txt | 402 +++-- conf/help2.txt | 94 -- conf/import-tmpl/atcommand_conf.txt | 0 conf/log_athena.conf | 6 +- conf/login_athena.conf | 7 +- conf/msg_athena.conf | 12 +- configure | 288 +++- configure.in | 6 +- doc/atcommands.txt | 213 +++ doc/permissions.txt | 21 + sql-files/upgrade_svn15572.sql | 3 + src/char/Makefile.in | 20 +- src/char/char.c | 22 +- src/common/Makefile.in | 30 +- src/common/conf.c | 109 ++ src/common/conf.h | 13 + src/common/showmsg.c | 16 + src/common/showmsg.h | 3 + src/login/Makefile.in | 21 +- src/login/account.h | 2 +- src/login/account_sql.c | 12 +- src/login/login.c | 24 +- src/login/login.h | 4 +- src/map/Makefile.in | 24 +- src/map/atcommand.c | 1587 ++++++++----------- src/map/atcommand.h | 30 +- src/map/battle.c | 26 - src/map/battle.h | 27 - src/map/buyingstore.c | 10 +- src/map/chat.c | 4 +- src/map/chrif.c | 8 +- src/map/clif.c | 499 ++---- src/map/clif.h | 2 - src/map/intif.c | 34 +- src/map/intif.h | 2 +- src/map/log.c | 15 +- src/map/log.h | 4 +- src/map/mail.c | 8 +- src/map/party.c | 8 +- src/map/pc.c | 144 +- src/map/pc.h | 37 +- src/map/pc_groups.c | 459 ++++++ src/map/pc_groups.h | 20 + src/map/script.c | 59 +- src/map/skill.c | 13 +- src/map/storage.c | 8 +- src/map/trade.c | 30 +- src/map/vending.c | 4 +- src/tool/Makefile.in | 14 +- vcproj-10/char-server_sql.vcxproj | 20 +- vcproj-10/char-server_sql.vcxproj.filters | 54 +- vcproj-10/login-server_sql.vcxproj | 20 +- vcproj-10/login-server_sql.vcxproj.filters | 54 +- vcproj-10/map-server_sql.vcxproj | 24 +- vcproj-10/map-server_sql.vcxproj.filters | 85 +- vcproj-10/mapcache.vcxproj | 8 +- vcproj-9/char-server_sql.vcproj | 86 +- vcproj-9/login-server_sql.vcproj | 88 +- vcproj-9/map-server_sql.vcproj | 140 +- vcproj-9/mapcache.vcproj | 12 +- 80 files changed, 11240 insertions(+), 2846 deletions(-) create mode 100644 3rdparty/libconfig/LICENSE create mode 100644 3rdparty/libconfig/Makefile.in create mode 100644 3rdparty/libconfig/grammar.c create mode 100644 3rdparty/libconfig/grammar.h create mode 100644 3rdparty/libconfig/libconfig-1.4.8 create mode 100644 3rdparty/libconfig/libconfig.c create mode 100644 3rdparty/libconfig/libconfig.h create mode 100644 3rdparty/libconfig/parsectx.h create mode 100644 3rdparty/libconfig/scanctx.c create mode 100644 3rdparty/libconfig/scanctx.h create mode 100644 3rdparty/libconfig/scanner.c create mode 100644 3rdparty/libconfig/scanner.h create mode 100644 3rdparty/libconfig/strbuf.c create mode 100644 3rdparty/libconfig/strbuf.h create mode 100644 3rdparty/libconfig/wincompat.h create mode 100644 conf/groups.conf delete mode 100644 conf/help2.txt delete mode 100644 conf/import-tmpl/atcommand_conf.txt create mode 100644 doc/atcommands.txt create mode 100644 doc/permissions.txt create mode 100644 sql-files/upgrade_svn15572.sql create mode 100644 src/common/conf.c create mode 100644 src/common/conf.h create mode 100644 src/map/pc_groups.c create mode 100644 src/map/pc_groups.h (limited to 'src/tool/Makefile.in') diff --git a/3rdparty/libconfig/LICENSE b/3rdparty/libconfig/LICENSE new file mode 100644 index 000000000..94a9ed024 --- /dev/null +++ b/3rdparty/libconfig/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, 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 +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If 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 convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU 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 +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "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 PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM 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 PROGRAM (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 PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 3 of the License, 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/3rdparty/libconfig/Makefile.in b/3rdparty/libconfig/Makefile.in new file mode 100644 index 000000000..22642413d --- /dev/null +++ b/3rdparty/libconfig/Makefile.in @@ -0,0 +1,24 @@ + +LIBCONFIG_OBJ = libconfig.o grammar.o scanctx.o scanner.o strbuf.o +LIBCONFIG_H = libconfig.h grammar.h parsectx.h scanctx.h scanner.h strbuf.h wincompat.h + +@SET_MAKE@ + +##################################################################### +.PHONY : all clean help + +all: $(LIBCONFIG_OBJ) + +clean: + rm -rf *.o + +help: + @echo "possible targets are 'all' 'clean' 'help'" + @echo "'all' - builds $(LIBCONFIG_OBJ)" + @echo "'clean' - deletes $(LIBCONFIG_OBJ)" + @echo "'help' - outputs this message" + +##################################################################### + +%.o: %.c $(LIBCONFIG_H) + @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/3rdparty/libconfig/grammar.c b/3rdparty/libconfig/grammar.c new file mode 100644 index 000000000..e95a569f6 --- /dev/null +++ b/3rdparty/libconfig/grammar.c @@ -0,0 +1,2001 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* 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. + + 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 3 of the License, 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 . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ + +/* All symbols defined below should begin with yy or YY, to avoid + infringing on user name space. This should be done even for local + variables, as they might otherwise be expanded by user macros. + There are some unavoidable exceptions within include files to + define necessary library symbols; they are noted "INFRINGES ON + USER NAME SPACE" below. */ + +/* Identify Bison output. */ +#define YYBISON 1 + +/* Bison version. */ +#define YYBISON_VERSION "2.4.1" + +/* Skeleton name. */ +#define YYSKELETON_NAME "yacc.c" + +/* Pure parsers. */ +#define YYPURE 1 + +/* Push parsers. */ +#define YYPUSH 0 + +/* Pull parsers. */ +#define YYPULL 1 + +/* Using locations. */ +#define YYLSP_NEEDED 0 + +/* Substitute the variable and function names. */ +#define yyparse libconfig_yyparse +#define yylex libconfig_yylex +#define yyerror libconfig_yyerror +#define yylval libconfig_yylval +#define yychar libconfig_yychar +#define yydebug libconfig_yydebug +#define yynerrs libconfig_yynerrs + + +/* Copy the first part of user declarations. */ + +/* Line 189 of yacc.c */ +#line 32 "grammar.y" + +#include +#include +#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 +#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; +} + + + +/* Line 189 of yacc.c */ +#line 134 "grammar.c" + +/* Enabling traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif + +/* Enabling verbose error messages. */ +#ifdef YYERROR_VERBOSE +# undef YYERROR_VERBOSE +# define YYERROR_VERBOSE 1 +#else +# define YYERROR_VERBOSE 0 +#endif + +/* Enabling the token table. */ +#ifndef YYTOKEN_TABLE +# define YYTOKEN_TABLE 0 +#endif + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_BOOLEAN = 258, + TOK_INTEGER = 259, + TOK_HEX = 260, + TOK_INTEGER64 = 261, + TOK_HEX64 = 262, + TOK_FLOAT = 263, + TOK_STRING = 264, + TOK_NAME = 265, + TOK_EQUALS = 266, + TOK_NEWLINE = 267, + TOK_ARRAY_START = 268, + TOK_ARRAY_END = 269, + TOK_LIST_START = 270, + TOK_LIST_END = 271, + TOK_COMMA = 272, + TOK_GROUP_START = 273, + TOK_GROUP_END = 274, + TOK_SEMICOLON = 275, + TOK_GARBAGE = 276, + TOK_ERROR = 277 + }; +#endif +/* Tokens. */ +#define TOK_BOOLEAN 258 +#define TOK_INTEGER 259 +#define TOK_HEX 260 +#define TOK_INTEGER64 261 +#define TOK_HEX64 262 +#define TOK_FLOAT 263 +#define TOK_STRING 264 +#define TOK_NAME 265 +#define TOK_EQUALS 266 +#define TOK_NEWLINE 267 +#define TOK_ARRAY_START 268 +#define TOK_ARRAY_END 269 +#define TOK_LIST_START 270 +#define TOK_LIST_END 271 +#define TOK_COMMA 272 +#define TOK_GROUP_START 273 +#define TOK_GROUP_END 274 +#define TOK_SEMICOLON 275 +#define TOK_GARBAGE 276 +#define TOK_ERROR 277 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + +/* Line 214 of yacc.c */ +#line 85 "grammar.y" + + int ival; + long long llval; + double fval; + char *sval; + + + +/* Line 214 of yacc.c */ +#line 223 "grammar.c" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + +/* Copy the second part of user declarations. */ + + +/* Line 264 of yacc.c */ +#line 235 "grammar.c" + +#ifdef short +# undef short +#endif + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; +#endif + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; +#endif + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif +#endif + +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + +#ifndef YY_ +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YY_(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YY_ +# define YY_(msgid) msgid +# endif +#endif + +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int yyi) +#else +static int +YYID (yyi) + int yyi; +#endif +{ + return yyi; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE + +/* The parser invokes alloca or malloc; define the necessary symbols. */ + +# ifdef YYSTACK_USE_ALLOCA +# if YYSTACK_USE_ALLOCA +# ifdef __GNUC__ +# define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca +# else +# define YYSTACK_ALLOC alloca +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# endif +# endif +# endif + +# ifdef YYSTACK_ALLOC + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) +# ifndef YYSTACK_ALLOC_MAXIMUM + /* The OS might guarantee only one guard page at the bottom of the stack, + and a page size can be as small as 4096 bytes. So we cannot safely + invoke alloca (N) if N exceeds 4096. Use a slightly smaller number + to allow for a few compiler-allocated temporary stack slots. */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ +# endif +# else +# define YYSTACK_ALLOC YYMALLOC +# define YYSTACK_FREE YYFREE +# ifndef YYSTACK_ALLOC_MAXIMUM +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM +# endif +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif +# endif +# ifndef YYMALLOC +# define YYMALLOC malloc +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# ifndef YYFREE +# define YYFREE free +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +void free (void *); /* INFRINGES ON USER NAME SPACE */ +# endif +# endif +# endif +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ + + +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + +/* A type that is properly aligned for any stack member. */ +union yyalloc +{ + yytype_int16 yyss_alloc; + YYSTYPE yyvs_alloc; +}; + +/* The size of the maximum gap between one aligned stack and the next. */ +# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) + +/* The size of an array large to enough to hold all stacks, each with + N elements. */ +# define YYSTACK_BYTES(N) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + + YYSTACK_GAP_MAXIMUM) + +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif + +/* YYFINAL -- State number of the termination state. */ +#define YYFINAL 6 +/* YYLAST -- Last index in YYTABLE. */ +#define YYLAST 35 + +/* YYNTOKENS -- Number of terminals. */ +#define YYNTOKENS 23 +/* YYNNTS -- Number of nonterminals. */ +#define YYNNTS 20 +/* YYNRULES -- Number of rules. */ +#define YYNRULES 39 +/* YYNRULES -- Number of states. */ +#define YYNSTATES 47 + +/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +#define YYUNDEFTOK 2 +#define YYMAXUTOK 277 + +#define YYTRANSLATE(YYX) \ + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + +/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +static const yytype_uint8 yytranslate[] = +{ + 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22 +}; + +#if YYDEBUG +/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in + YYRHS. */ +static const yytype_uint8 yyprhs[] = +{ + 0, 0, 3, 4, 6, 8, 11, 12, 14, 15, + 17, 19, 20, 26, 27, 32, 33, 38, 40, 42, + 44, 46, 48, 51, 53, 55, 57, 59, 61, 63, + 65, 67, 71, 72, 74, 76, 80, 81, 83, 84 +}; + +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int8 yyrhs[] = +{ + 24, 0, -1, -1, 25, -1, 28, -1, 25, 28, + -1, -1, 25, -1, -1, 20, -1, 17, -1, -1, + 10, 29, 11, 34, 27, -1, -1, 13, 31, 40, + 14, -1, -1, 15, 33, 38, 16, -1, 36, -1, + 30, -1, 32, -1, 41, -1, 9, -1, 35, 9, + -1, 3, -1, 4, -1, 6, -1, 5, -1, 7, + -1, 8, -1, 35, -1, 34, -1, 37, 17, 34, + -1, -1, 37, -1, 36, -1, 39, 17, 36, -1, + -1, 39, -1, -1, 18, 42, 26, 19, -1 +}; + +/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ +static const yytype_uint16 yyrline[] = +{ + 0, 100, 100, 102, 106, 107, 110, 112, 115, 117, + 118, 123, 122, 142, 141, 165, 164, 187, 188, 189, + 190, 194, 195, 199, 219, 241, 263, 285, 307, 325, + 353, 354, 357, 359, 363, 364, 367, 369, 374, 373 +}; +#endif + +#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ +static const char *const yytname[] = +{ + "$end", "error", "$undefined", "TOK_BOOLEAN", "TOK_INTEGER", "TOK_HEX", + "TOK_INTEGER64", "TOK_HEX64", "TOK_FLOAT", "TOK_STRING", "TOK_NAME", + "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", "$accept", + "configuration", "setting_list", "setting_list_optional", + "setting_terminator", "setting", "$@1", "array", "$@2", "list", "$@3", + "value", "string", "simple_value", "value_list", "value_list_optional", + "simple_value_list", "simple_value_list_optional", "group", "$@4", 0 +}; +#endif + +# ifdef YYPRINT +/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to + token YYLEX-NUM. */ +static const yytype_uint16 yytoknum[] = +{ + 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, 276, 277 +}; +# endif + +/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +static const yytype_uint8 yyr1[] = +{ + 0, 23, 24, 24, 25, 25, 26, 26, 27, 27, + 27, 29, 28, 31, 30, 33, 32, 34, 34, 34, + 34, 35, 35, 36, 36, 36, 36, 36, 36, 36, + 37, 37, 38, 38, 39, 39, 40, 40, 42, 41 +}; + +/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ +static const yytype_uint8 yyr2[] = +{ + 0, 2, 0, 1, 1, 2, 0, 1, 0, 1, + 1, 0, 5, 0, 4, 0, 4, 1, 1, 1, + 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 0, 1, 1, 3, 0, 1, 0, 4 +}; + +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 2, 11, 0, 3, 4, 0, 1, 5, 0, 23, + 24, 26, 25, 27, 28, 21, 13, 15, 38, 18, + 19, 8, 29, 17, 20, 36, 32, 6, 10, 9, + 12, 22, 34, 37, 0, 30, 33, 0, 7, 0, + 0, 14, 0, 16, 39, 35, 31 +}; + +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int8 yydefgoto[] = +{ + -1, 2, 3, 39, 30, 4, 5, 19, 25, 20, + 26, 21, 22, 23, 36, 37, 33, 34, 24, 27 +}; + +/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +#define YYPACT_NINF -26 +static const yytype_int8 yypact[] = +{ + -8, -26, 12, -8, -26, 5, -26, -26, 0, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -6, 10, -26, -26, 23, 0, -8, -26, -26, + -26, -26, -26, 3, 7, -26, 6, 8, -8, 14, + 23, -26, 0, -26, -26, -26, -26 +}; + +/* YYPGOTO[NTERM-NUM]. */ +static const yytype_int8 yypgoto[] = +{ + -26, -26, -5, -26, -26, -3, -26, -26, -26, -26, + -26, -25, -26, -15, -26, -26, -26, -26, -26, -26 +}; + +/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule which + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ +#define YYTABLE_NINF -1 +static const yytype_uint8 yytable[] = +{ + 7, 35, 1, 9, 10, 11, 12, 13, 14, 15, + 32, 28, 6, 16, 29, 17, 8, 46, 18, 31, + 40, 41, 38, 42, 43, 45, 9, 10, 11, 12, + 13, 14, 15, 44, 0, 7 +}; + +static const yytype_int8 yycheck[] = +{ + 3, 26, 10, 3, 4, 5, 6, 7, 8, 9, + 25, 17, 0, 13, 20, 15, 11, 42, 18, 9, + 17, 14, 27, 17, 16, 40, 3, 4, 5, 6, + 7, 8, 9, 19, -1, 38 +}; + +/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 10, 24, 25, 28, 29, 0, 28, 11, 3, + 4, 5, 6, 7, 8, 9, 13, 15, 18, 30, + 32, 34, 35, 36, 41, 31, 33, 42, 17, 20, + 27, 9, 36, 39, 40, 34, 37, 38, 25, 26, + 17, 14, 17, 16, 19, 36, 34 +}; + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 + +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab + + +/* 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. */ + +#define YYFAIL goto yyerrlab + +#define YYRECOVERING() (!!yyerrstatus) + +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ + YYPOPSTACK (1); \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (scanner, ctx, scan_ctx, YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (YYID (0)) + + +#define YYTERROR 1 +#define YYERRCODE 256 + + +/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. + If N is 0, then set CURRENT to the empty location which ends + the previous symbol: RHS[0] (always defined). */ + +#define YYRHSLOC(Rhs, K) ((Rhs)[K]) +#ifndef YYLLOC_DEFAULT +# define YYLLOC_DEFAULT(Current, Rhs, N) \ + do \ + if (YYID (N)) \ + { \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ + } \ + else \ + { \ + (Current).first_line = (Current).last_line = \ + YYRHSLOC (Rhs, 0).last_line; \ + (Current).first_column = (Current).last_column = \ + YYRHSLOC (Rhs, 0).last_column; \ + } \ + while (YYID (0)) +#endif + + +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ + +#ifndef YY_LOCATION_PRINT +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif +#endif + + +/* YYLEX -- calling `yylex' with the right arguments. */ + +#ifdef YYLEX_PARAM +# define YYLEX yylex (&yylval, YYLEX_PARAM) +#else +# define YYLEX yylex (&yylval, scanner) +#endif + +/* Enable debugging if requested. */ +#if YYDEBUG + +# ifndef YYFPRINTF +# include /* INFRINGES ON USER NAME SPACE */ +# define YYFPRINTF fprintf +# endif + +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (YYID (0)) + +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value, scanner, ctx, scan_ctx); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + void *scanner; + struct parse_context *ctx; + struct scan_context *scan_ctx; +#endif +{ + if (!yyvaluep) + return; + YYUSE (scanner); + YYUSE (ctx); + YYUSE (scan_ctx); +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; + void *scanner; + struct parse_context *ctx; + struct scan_context *scan_ctx; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx); + YYFPRINTF (yyoutput, ")"); +} + +/*------------------------------------------------------------------. +| yy_stack_print -- Print the state stack from its BOTTOM up to its | +| TOP (included). | +`------------------------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +#else +static void +yy_stack_print (yybottom, yytop) + yytype_int16 *yybottom; + yytype_int16 *yytop; +#endif +{ + YYFPRINTF (stderr, "Stack now"); + for (; yybottom <= yytop; yybottom++) + { + int yybot = *yybottom; + YYFPRINTF (stderr, " %d", yybot); + } + YYFPRINTF (stderr, "\n"); +} + +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (YYID (0)) + + +/*------------------------------------------------. +| Report that the YYRULE is going to be reduced. | +`------------------------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_reduce_print (YYSTYPE *yyvsp, int yyrule, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) +#else +static void +yy_reduce_print (yyvsp, yyrule, scanner, ctx, scan_ctx) + YYSTYPE *yyvsp; + int yyrule; + void *scanner; + struct parse_context *ctx; + struct scan_context *scan_ctx; +#endif +{ + int yynrhs = yyr2[yyrule]; + int yyi; + unsigned long int yylno = yyrline[yyrule]; + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + YYFPRINTF (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + , scanner, ctx, scan_ctx); + YYFPRINTF (stderr, "\n"); + } +} + +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyvsp, Rule, scanner, ctx, scan_ctx); \ +} while (YYID (0)) + +/* Nonzero means print parse trace. It is left uninitialized so that + multiple parsers can coexist. */ +int yydebug; +#else /* !YYDEBUG */ +# define YYDPRINTF(Args) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) +# define YY_STACK_PRINT(Bottom, Top) +# define YY_REDUCE_PRINT(Rule) +#endif /* !YYDEBUG */ + + +/* YYINITDEPTH -- initial size of the parser's stacks. */ +#ifndef YYINITDEPTH +# define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only + if the built-in stack extension method is used). + + Do not make this value too large; the results are undefined if + YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) + evaluated with infinite-precision integer arithmetic. */ + +#ifndef YYMAXDEPTH +# define YYMAXDEPTH 10000 +#endif + + + +#if YYERROR_VERBOSE + +# ifndef yystrlen +# if defined __GLIBC__ && defined _STRING_H +# define yystrlen strlen +# else +/* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static YYSIZE_T +yystrlen (const char *yystr) +#else +static YYSIZE_T +yystrlen (yystr) + const char *yystr; +#endif +{ + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) + continue; + return yylen; +} +# endif +# endif + +# ifndef yystpcpy +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE +# define yystpcpy stpcpy +# else +/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in + YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static char * +yystpcpy (char *yydest, const char *yysrc) +#else +static char * +yystpcpy (yydest, yysrc) + char *yydest; + const char *yysrc; +#endif +{ + char *yyd = yydest; + const char *yys = yysrc; + + while ((*yyd++ = *yys++) != '\0') + continue; + + return yyd - 1; +} +# endif +# endif + +# ifndef yytnamerr +/* Copy to YYRES the contents of YYSTR after stripping away unnecessary + quotes and backslashes, so that it's suitable for yyerror. The + heuristic is that double-quoting is unnecessary unless the string + contains an apostrophe, a comma, or backslash (other than + backslash-backslash). YYSTR is taken from yytname. If YYRES is + null, do not copy; instead, return the length of what the result + would have been. */ +static YYSIZE_T +yytnamerr (char *yyres, const char *yystr) +{ + if (*yystr == '"') + { + YYSIZE_T yyn = 0; + char const *yyp = yystr; + + for (;;) + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; + + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; + + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } + do_not_strip_quotes: ; + } + + if (! yyres) + return yystrlen (yystr); + + return yystpcpy (yyres, yystr) - yyres; +} +# endif + +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) +{ + int yyn = yypact[yystate]; + + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } +} +#endif /* YYERROR_VERBOSE */ + + +/*-----------------------------------------------. +| Release the memory associated to this symbol. | +`-----------------------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) +#else +static void +yydestruct (yymsg, yytype, yyvaluep, scanner, ctx, scan_ctx) + const char *yymsg; + int yytype; + YYSTYPE *yyvaluep; + void *scanner; + struct parse_context *ctx; + struct scan_context *scan_ctx; +#endif +{ + YYUSE (yyvaluep); + YYUSE (scanner); + YYUSE (ctx); + YYUSE (scan_ctx); + + if (!yymsg) + yymsg = "Deleting"; + YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); + + switch (yytype) + { + + default: + break; + } +} + +/* Prevent warnings from -Wmissing-prototypes. */ +#ifdef YYPARSE_PARAM +#if defined __STDC__ || defined __cplusplus +int yyparse (void *YYPARSE_PARAM); +#else +int yyparse (); +#endif +#else /* ! YYPARSE_PARAM */ +#if defined __STDC__ || defined __cplusplus +int yyparse (void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx); +#else +int yyparse (); +#endif +#endif /* ! YYPARSE_PARAM */ + + + + + +/*-------------------------. +| yyparse or yypush_parse. | +`-------------------------*/ + +#ifdef YYPARSE_PARAM +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif +#else /* ! YYPARSE_PARAM */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx) +#else +int +yyparse (scanner, ctx, scan_ctx) + void *scanner; + struct parse_context *ctx; + struct scan_context *scan_ctx; +#endif +#endif +{ +/* The lookahead symbol. */ +int yychar; + +/* The semantic value of the lookahead symbol. */ +YYSTYPE yylval; + + /* Number of syntax errors so far. */ + int yynerrs; + + int yystate; + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + + /* The stacks and their tools: + `yyss': related to states. + `yyvs': related to semantic values. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs; + YYSTYPE *yyvsp; + + YYSIZE_T yystacksize; + + int yyn; + int yyresult; + /* Lookahead token as an internal (translated) token number. */ + int yytoken; + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif + +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; + + yytoken = 0; + yyss = yyssa; + yyvs = yyvsa; + yystacksize = YYINITDEPTH; + + YYDPRINTF ((stderr, "Starting parse\n")); + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + yyssp = yyss; + yyvsp = yyvs; + + goto yysetstate; + +/*------------------------------------------------------------. +| yynewstate -- Push a new state, which is found in yystate. | +`------------------------------------------------------------*/ + yynewstate: + /* In all cases, when you get here, the value and location stacks + have just been pushed. So pushing a state here evens the stacks. */ + yyssp++; + + yysetstate: + *yyssp = yystate; + + if (yyss + yystacksize - 1 <= yyssp) + { + /* Get the current used size of the three stacks, in elements. */ + YYSIZE_T yysize = yyssp - yyss + 1; + +#ifdef yyoverflow + { + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; + + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); + + yyss = yyss1; + yyvs = yyvs1; + } +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else + /* Extend the stack our own way. */ + if (YYMAXDEPTH <= yystacksize) + goto yyexhaustedlab; + yystacksize *= 2; + if (YYMAXDEPTH < yystacksize) + yystacksize = YYMAXDEPTH; + + { + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); +# undef YYSTACK_RELOCATE + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); + } +# endif +#endif /* no yyoverflow */ + + yyssp = yyss + yysize - 1; + yyvsp = yyvs + yysize - 1; + + YYDPRINTF ((stderr, "Stack size increased to %lu\n", + (unsigned long int) yystacksize)); + + if (yyss + yystacksize - 1 <= yyssp) + YYABORT; + } + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); + + if (yystate == YYFINAL) + YYACCEPT; + + goto yybackup; + +/*-----------. +| yybackup. | +`-----------*/ +yybackup: + + /* Do appropriate processing given the current state. Read a + lookahead token if we need one and don't already have one. */ + + /* First try to decide what to do without reference to lookahead token. */ + yyn = yypact[yystate]; + if (yyn == YYPACT_NINF) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + if (yychar == YYEMPTY) + { + YYDPRINTF ((stderr, "Reading a token: ")); + yychar = YYLEX; + } + + if (yychar <= YYEOF) + { + yychar = yytoken = YYEOF; + YYDPRINTF ((stderr, "Now at end of input.\n")); + } + else + { + yytoken = YYTRANSLATE (yychar); + YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); + } + + /* If the proper action on seeing token YYTOKEN is to reduce or to + detect an error, take that action. */ + yyn += yytoken; + if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) + goto yydefault; + yyn = yytable[yyn]; + if (yyn <= 0) + { + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + + /* Shift the lookahead token. */ + YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); + + /* Discard the shifted token. */ + yychar = YYEMPTY; + + yystate = yyn; + *++yyvsp = yylval; + + goto yynewstate; + + +/*-----------------------------------------------------------. +| yydefault -- do the default action for the current state. | +`-----------------------------------------------------------*/ +yydefault: + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + goto yyreduce; + + +/*-----------------------------. +| yyreduce -- Do a reduction. | +`-----------------------------*/ +yyreduce: + /* yyn is the number of a rule to reduce with. */ + yylen = yyr2[yyn]; + + /* If YYLEN is nonzero, implement the default value of the action: + `$$ = $1'. + + Otherwise, the following line sets YYVAL to garbage. + This behavior is undocumented and Bison + users should not rely upon it. Assigning to YYVAL + unconditionally makes the parser a bit smaller, and it avoids a + GCC warning that YYVAL may be used uninitialized. */ + yyval = yyvsp[1-yylen]; + + + YY_REDUCE_PRINT (yyn); + switch (yyn) + { + case 11: + +/* Line 1455 of yacc.c */ +#line 123 "grammar.y" + { + ctx->setting = config_setting_add(ctx->parent, (yyvsp[(1) - (1)].sval), CONFIG_TYPE_NONE); + + if(ctx->setting == NULL) + { + libconfig_yyerror(scanner, ctx, scan_ctx, err_duplicate_setting); + YYABORT; + } + else + { + CAPTURE_PARSE_POS(ctx->setting); + } + } + break; + + case 13: + +/* Line 1455 of yacc.c */ +#line 142 "grammar.y" + { + 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; + } + } + break; + + case 14: + +/* Line 1455 of yacc.c */ +#line 157 "grammar.y" + { + if(ctx->parent) + ctx->parent = ctx->parent->parent; + } + break; + + case 15: + +/* Line 1455 of yacc.c */ +#line 165 "grammar.y" + { + 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; + } + } + break; + + case 16: + +/* Line 1455 of yacc.c */ +#line 180 "grammar.y" + { + if(ctx->parent) + ctx->parent = ctx->parent->parent; + } + break; + + case 21: + +/* Line 1455 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 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 200 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + config_setting_t *e = config_setting_set_bool_elem(ctx->parent, -1, + (int)(yyvsp[(1) - (1)].ival)); + + 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)(yyvsp[(1) - (1)].ival)); + } + break; + + case 24: + +/* Line 1455 of yacc.c */ +#line 220 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, (yyvsp[(1) - (1)].ival)); + 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, (yyvsp[(1) - (1)].ival)); + config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT); + } + } + break; + + case 25: + +/* Line 1455 of yacc.c */ +#line 242 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, (yyvsp[(1) - (1)].llval)); + 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, (yyvsp[(1) - (1)].llval)); + config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT); + } + } + break; + + case 26: + +/* Line 1455 of yacc.c */ +#line 264 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, (yyvsp[(1) - (1)].ival)); + 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, (yyvsp[(1) - (1)].ival)); + config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX); + } + } + break; + + case 27: + +/* Line 1455 of yacc.c */ +#line 286 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, (yyvsp[(1) - (1)].llval)); + 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, (yyvsp[(1) - (1)].llval)); + config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX); + } + } + break; + + case 28: + +/* Line 1455 of yacc.c */ +#line 308 "grammar.y" + { + if(IN_ARRAY() || IN_LIST()) + { + config_setting_t *e = config_setting_set_float_elem(ctx->parent, -1, (yyvsp[(1) - (1)].fval)); + 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, (yyvsp[(1) - (1)].fval)); + } + break; + + case 29: + +/* Line 1455 of yacc.c */ +#line 326 "grammar.y" + { + 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); + } + } + break; + + case 38: + +/* Line 1455 of yacc.c */ +#line 374 "grammar.y" + { + 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; + } + } + break; + + case 39: + +/* Line 1455 of yacc.c */ +#line 389 "grammar.y" + { + if(ctx->parent) + ctx->parent = ctx->parent->parent; + } + break; + + + +/* Line 1455 of yacc.c */ +#line 1788 "grammar.c" + default: break; + } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); + + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + + *++yyvsp = yyval; + + /* Now `shift' the result of the reduction. Determine what state + that goes to, based on the state we popped back to and the rule + number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; + + goto yynewstate; + + +/*------------------------------------. +| yyerrlab -- here on detecting error | +`------------------------------------*/ +yyerrlab: + /* If not already recovering from an error, report this error. */ + if (!yyerrstatus) + { + ++yynerrs; +#if ! YYERROR_VERBOSE + yyerror (scanner, ctx, scan_ctx, YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (scanner, ctx, scan_ctx, yymsg); + } + else + { + yyerror (scanner, ctx, scan_ctx, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } + } +#endif + } + + + + if (yyerrstatus == 3) + { + /* If just tried and failed to reuse lookahead token after an + error, discard it. */ + + if (yychar <= YYEOF) + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } + else + { + yydestruct ("Error: discarding", + yytoken, &yylval, scanner, ctx, scan_ctx); + yychar = YYEMPTY; + } + } + + /* Else will try to reuse lookahead token after shifting the error + token. */ + goto yyerrlab1; + + +/*---------------------------------------------------. +| yyerrorlab -- error raised explicitly by YYERROR. | +`---------------------------------------------------*/ +yyerrorlab: + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; + + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); + yystate = *yyssp; + goto yyerrlab1; + + +/*-------------------------------------------------------------. +| yyerrlab1 -- common code for both syntax error and YYERROR. | +`-------------------------------------------------------------*/ +yyerrlab1: + yyerrstatus = 3; /* Each real token shifted decrements this. */ + + for (;;) + { + yyn = yypact[yystate]; + if (yyn != YYPACT_NINF) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } + + /* Pop the current state because it cannot handle the error token. */ + if (yyssp == yyss) + YYABORT; + + + yydestruct ("Error: popping", + yystos[yystate], yyvsp, scanner, ctx, scan_ctx); + YYPOPSTACK (1); + yystate = *yyssp; + YY_STACK_PRINT (yyss, yyssp); + } + + *++yyvsp = yylval; + + + /* Shift the error token. */ + YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); + + yystate = yyn; + goto yynewstate; + + +/*-------------------------------------. +| yyacceptlab -- YYACCEPT comes here. | +`-------------------------------------*/ +yyacceptlab: + yyresult = 0; + goto yyreturn; + +/*-----------------------------------. +| yyabortlab -- YYABORT comes here. | +`-----------------------------------*/ +yyabortlab: + yyresult = 1; + goto yyreturn; + +#if !defined(yyoverflow) || YYERROR_VERBOSE +/*-------------------------------------------------. +| yyexhaustedlab -- memory exhaustion comes here. | +`-------------------------------------------------*/ +yyexhaustedlab: + yyerror (scanner, ctx, scan_ctx, YY_("memory exhausted")); + yyresult = 2; + /* Fall through. */ +#endif + +yyreturn: + if (yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, scanner, ctx, scan_ctx); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); + while (yyssp != yyss) + { + yydestruct ("Cleanup: popping", + yystos[*yyssp], yyvsp, scanner, ctx, scan_ctx); + YYPOPSTACK (1); + } +#ifndef yyoverflow + if (yyss != yyssa) + YYSTACK_FREE (yyss); +#endif +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); +} + + + +/* Line 1675 of yacc.c */ +#line 395 "grammar.y" + + diff --git a/3rdparty/libconfig/grammar.h b/3rdparty/libconfig/grammar.h new file mode 100644 index 000000000..2ce199dde --- /dev/null +++ b/3rdparty/libconfig/grammar.h @@ -0,0 +1,113 @@ + +/* A Bison parser, made by GNU Bison 2.4.1. */ + +/* 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. + + 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 3 of the License, 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 . */ + +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ + + +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + TOK_BOOLEAN = 258, + TOK_INTEGER = 259, + TOK_HEX = 260, + TOK_INTEGER64 = 261, + TOK_HEX64 = 262, + TOK_FLOAT = 263, + TOK_STRING = 264, + TOK_NAME = 265, + TOK_EQUALS = 266, + TOK_NEWLINE = 267, + TOK_ARRAY_START = 268, + TOK_ARRAY_END = 269, + TOK_LIST_START = 270, + TOK_LIST_END = 271, + TOK_COMMA = 272, + TOK_GROUP_START = 273, + TOK_GROUP_END = 274, + TOK_SEMICOLON = 275, + TOK_GARBAGE = 276, + TOK_ERROR = 277 + }; +#endif +/* Tokens. */ +#define TOK_BOOLEAN 258 +#define TOK_INTEGER 259 +#define TOK_HEX 260 +#define TOK_INTEGER64 261 +#define TOK_HEX64 262 +#define TOK_FLOAT 263 +#define TOK_STRING 264 +#define TOK_NAME 265 +#define TOK_EQUALS 266 +#define TOK_NEWLINE 267 +#define TOK_ARRAY_START 268 +#define TOK_ARRAY_END 269 +#define TOK_LIST_START 270 +#define TOK_LIST_END 271 +#define TOK_COMMA 272 +#define TOK_GROUP_START 273 +#define TOK_GROUP_END 274 +#define TOK_SEMICOLON 275 +#define TOK_GARBAGE 276 +#define TOK_ERROR 277 + + + + +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +{ + +/* Line 1676 of yacc.c */ +#line 85 "grammar.y" + + int ival; + long long llval; + double fval; + char *sval; + + + +/* Line 1676 of yacc.c */ +#line 105 "grammar.h" +} YYSTYPE; +# define YYSTYPE_IS_TRIVIAL 1 +# define yystype YYSTYPE /* obsolescent; will be withdrawn */ +# define YYSTYPE_IS_DECLARED 1 +#endif + + + + diff --git a/3rdparty/libconfig/libconfig-1.4.8 b/3rdparty/libconfig/libconfig-1.4.8 new file mode 100644 index 000000000..e69de29bb diff --git a/3rdparty/libconfig/libconfig.c b/3rdparty/libconfig/libconfig.c new file mode 100644 index 000000000..e64213c16 --- /dev/null +++ b/3rdparty/libconfig/libconfig.c @@ -0,0 +1,1615 @@ +/* ---------------------------------------------------------------------------- + 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 General Public License as published by + the Free Software Foundation, either version 3 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#ifdef HAVE_CONFIG_H +#include "ac_config.h" +#endif + +#include "libconfig.h" +#include "grammar.h" +#include "scanner.h" +#include "scanctx.h" +#include "parsectx.h" +#include "wincompat.h" + +#include + +#ifdef HAVE_XLOCALE_H +#include +#endif + +#include +#include +#include + +#define PATH_TOKENS ":./" +#define CHUNK_SIZE 16 +#define FLOAT_PRECISION 10 + +#define _new(T) (T *)calloc(sizeof(T), 1) /* zeroed */ +#define _delete(P) free((void *)(P)) + +/* ------------------------------------------------------------------------- */ + +#ifndef LIBCONFIG_STATIC +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + return(TRUE); +} + +#endif /* WIN32 */ +#endif /* LIBCONFIG_STATIC */ + +/* ------------------------------------------------------------------------- */ + +static const char *__io_error = "file I/O error"; + +static void __config_list_destroy(config_list_t *list); +static void __config_write_setting(const config_setting_t *setting, + FILE *stream, int depth, + unsigned short tab_width); + +extern int libconfig_yyparse(void *scanner, struct parse_context *ctx, + struct scan_context *scan_ctx); +extern int libconfig_yylex_init_extra(struct scan_context *scan_ctx, + yyscan_t *scanner); + +/* ------------------------------------------------------------------------- */ + +static void __config_locale_override(void) +{ +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ + && ! defined(__MINGW32__) + + _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); + setlocale(LC_NUMERIC, "C"); + +#elif defined(__APPLE__) + + locale_t loc = newlocale(LC_NUMERIC_MASK, "C", NULL); + uselocale(loc); + +#elif ((defined HAVE_NEWLOCALE) && (defined HAVE_USELOCALE)) + + locale_t loc = newlocale(LC_NUMERIC, "C", NULL); + uselocale(loc); + +#else + +#warning "No way to modify calling thread's locale!" + +#endif +} + +/* ------------------------------------------------------------------------- */ + +static void __config_locale_restore(void) +{ +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ + && ! defined(__MINGW32__) + + _configthreadlocale(_DISABLE_PER_THREAD_LOCALE); + +#elif ((defined HAVE_USELOCALE) && (defined HAVE_FREELOCALE)) + + locale_t loc = uselocale(LC_GLOBAL_LOCALE); + freelocale(loc); + +#else + +#warning "No way to modify calling thread's locale!" + +#endif +} + +/* ------------------------------------------------------------------------- */ + +static int __config_name_compare(const char *a, const char *b) +{ + const char *p, *q; + + for(p = a, q = b; ; p++, q++) + { + int pd = ((! *p) || strchr(PATH_TOKENS, *p)); + int qd = ((! *q) || strchr(PATH_TOKENS, *q)); + + if(pd && qd) + break; + else if(pd) + return(-1); + else if(qd) + return(1); + else if(*p < *q) + return(-1); + else if(*p > *q) + return(1); + } + + return(0); +} + +/* ------------------------------------------------------------------------- */ + +static void __config_indent(FILE *stream, int depth, unsigned short w) +{ + if(w) + fprintf(stream, "%*s", (depth - 1) * w, " "); + else + { + int i; + for(i = 0; i < (depth - 1); ++i) + fputc('\t', stream); + } +} + +/* ------------------------------------------------------------------------- */ + +static void __config_write_value(const config_value_t *value, int type, + int format, int depth, + unsigned short tab_width, FILE *stream) +{ + char fbuf[64]; + + switch(type) + { + /* boolean */ + case CONFIG_TYPE_BOOL: + fputs(value->ival ? "true" : "false", stream); + break; + + /* int */ + case CONFIG_TYPE_INT: + switch(format) + { + case CONFIG_FORMAT_HEX: + fprintf(stream, "0x%X", value->ival); + break; + + case CONFIG_FORMAT_DEFAULT: + default: + fprintf(stream, "%d", value->ival); + break; + } + break; + + /* 64-bit int */ + case CONFIG_TYPE_INT64: + switch(format) + { + case CONFIG_FORMAT_HEX: + fprintf(stream, "0x" INT64_HEX_FMT "L", value->llval); + break; + + case CONFIG_FORMAT_DEFAULT: + default: + fprintf(stream, INT64_FMT "L", value->llval); + break; + } + break; + + /* float */ + case CONFIG_TYPE_FLOAT: + { + char *q; + + snprintf(fbuf, sizeof(fbuf) - 3, "%.*g", FLOAT_PRECISION, value->fval); + + /* check for exponent */ + q = strchr(fbuf, 'e'); + if(! q) + { + /* no exponent */ + if(! strchr(fbuf, '.')) /* no decimal point */ + strcat(fbuf, ".0"); + else + { + /* has decimal point */ + char *p; + + for(p = fbuf + strlen(fbuf) - 1; p > fbuf; --p) + { + if(*p != '0') + { + *(++p) = '\0'; + break; + } + } + } + } + + fputs(fbuf, stream); + break; + } + + /* string */ + case CONFIG_TYPE_STRING: + { + char *p; + + fputc('\"', stream); + + if(value->sval) + { + for(p = value->sval; *p; p++) + { + int c = (int)*p & 0xFF; + switch(c) + { + case '\"': + case '\\': + fputc('\\', stream); + fputc(c, stream); + break; + + case '\n': + fputs("\\n", stream); + break; + + case '\r': + fputs("\\r", stream); + break; + + case '\f': + fputs("\\f", stream); + break; + + case '\t': + fputs("\\t", stream); + break; + + default: + if(c >= ' ') + fputc(c, stream); + else + fprintf(stream, "\\x%02X", c); + } + } + } + fputc('\"', stream); + break; + } + + /* list */ + case CONFIG_TYPE_LIST: + { + config_list_t *list = value->list; + + fprintf(stream, "( "); + + if(list) + { + int len = list->length; + config_setting_t **s; + + for(s = list->elements; len--; s++) + { + __config_write_value(&((*s)->value), (*s)->type, + config_setting_get_format(*s), + depth + 1, tab_width, stream); + + if(len) + fputc(',', stream); + + fputc(' ', stream); + } + } + + fputc(')', stream); + break; + } + + /* array */ + case CONFIG_TYPE_ARRAY: + { + config_list_t *list = value->list; + + fprintf(stream, "[ "); + + if(list) + { + int len = list->length; + config_setting_t **s; + + for(s = list->elements; len--; s++) + { + __config_write_value(&((*s)->value), (*s)->type, + config_setting_get_format(*s), + depth + 1, tab_width, stream); + + if(len) + fputc(',', stream); + + fputc(' ', stream); + } + } + + fputc(']', stream); + break; + } + + /* group */ + case CONFIG_TYPE_GROUP: + { + config_list_t *list = value->list; + + if(depth > 0) + { +#ifdef K_AND_R_STYLE /* Horrendous, but many people like it. */ + fputc(' ', stream); +#else + fputc('\n', stream); + + if(depth > 1) + __config_indent(stream, depth, tab_width); +#endif + fprintf(stream, "{\n"); + } + + if(list) + { + int len = list->length; + config_setting_t **s; + + for(s = list->elements; len--; s++) + __config_write_setting(*s, stream, depth + 1, tab_width); + } + + if(depth > 1) + __config_indent(stream, depth, tab_width); + + if(depth > 0) + fputc('}', stream); + + break; + } + + default: + /* this shouldn't happen, but handle it gracefully... */ + fputs("???", stream); + break; + } +} + +/* ------------------------------------------------------------------------- */ + +static void __config_list_add(config_list_t *list, config_setting_t *setting) +{ + if((list->length % CHUNK_SIZE) == 0) + { + list->elements = (config_setting_t **)realloc( + list->elements, + (list->length + CHUNK_SIZE) * sizeof(config_setting_t *)); + } + + list->elements[list->length] = setting; + list->length++; +} + +/* ------------------------------------------------------------------------- */ + +static config_setting_t *__config_list_search(config_list_t *list, + const char *name, + unsigned int *idx) +{ + config_setting_t **found = NULL; + unsigned int i; + + if(! list) + return(NULL); + + for(i = 0, found = list->elements; i < list->length; i++, found++) + { + if(! (*found)->name) + continue; + + if(! __config_name_compare(name, (*found)->name)) + { + if(idx) + *idx = i; + + return(*found); + } + } + + return(NULL); +} + +/* ------------------------------------------------------------------------- */ + +static config_setting_t *__config_list_remove(config_list_t *list, int idx) +{ + config_setting_t *removed = *(list->elements + idx); + int offset = (idx * sizeof(config_setting_t *)); + int len = list->length - 1 - idx; + char *base = (char *)list->elements + offset; + + memmove(base, base + sizeof(config_setting_t *), + len * sizeof(config_setting_t *)); + + list->length--; + + /* possibly realloc smaller? */ + + return(removed); +} + +/* ------------------------------------------------------------------------- */ + +static void __config_setting_destroy(config_setting_t *setting) +{ + if(setting) + { + if(setting->name) + _delete(setting->name); + + if(setting->type == CONFIG_TYPE_STRING) + _delete(setting->value.sval); + + else if((setting->type == CONFIG_TYPE_GROUP) + || (setting->type == CONFIG_TYPE_ARRAY) + || (setting->type == CONFIG_TYPE_LIST)) + { + if(setting->value.list) + __config_list_destroy(setting->value.list); + } + + if(setting->hook && setting->config->destructor) + setting->config->destructor(setting->hook); + + _delete(setting); + } +} + +/* ------------------------------------------------------------------------- */ + +static void __config_list_destroy(config_list_t *list) +{ + config_setting_t **p; + unsigned int i; + + if(! list) + return; + + if(list->elements) + { + for(p = list->elements, i = 0; i < list->length; p++, i++) + __config_setting_destroy(*p); + + _delete(list->elements); + } + + _delete(list); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_vector_checktype(const config_setting_t *vector, int type) +{ + /* if the array is empty, then it has no type yet */ + + if(! vector->value.list) + return(CONFIG_TRUE); + + if(vector->value.list->length == 0) + return(CONFIG_TRUE); + + /* if it's a list, any type is allowed */ + + if(vector->type == CONFIG_TYPE_LIST) + return(CONFIG_TRUE); + + /* otherwise the first element added determines the type of the array */ + + return((vector->value.list->elements[0]->type == type) + ? CONFIG_TRUE : CONFIG_FALSE); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_validate_name(const char *name) +{ + const char *p = name; + + if(*p == '\0') + return(CONFIG_FALSE); + + if(! isalpha(*p) && (*p != '*')) + return(CONFIG_FALSE); + + for(++p; *p; ++p) + { + if(! (isalpha(*p) || isdigit(*p) || strchr("*_-", (int)*p))) + return(CONFIG_FALSE); + } + + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_read(config_t *config, FILE *stream, const char *filename, + const char *str) +{ + yyscan_t scanner; + struct scan_context scan_ctx; + struct parse_context parse_ctx; + YY_BUFFER_STATE buffer = NULL; + int r; + + /* Reinitialize the config */ + void (*destructor)(void *) = config->destructor; + const char *include_dir = config->include_dir; + unsigned short tab_width = config->tab_width; + unsigned short flags = config->flags; + + config->include_dir = NULL; + config_destroy(config); + config_init(config); + + config->destructor = destructor; + config->include_dir = include_dir; + config->tab_width = tab_width; + config->flags = flags; + + parsectx_init(&parse_ctx); + parse_ctx.config = config; + parse_ctx.parent = config->root; + parse_ctx.setting = config->root; + + __config_locale_override(); + + scanctx_init(&scan_ctx, filename); + scan_ctx.config = config; + libconfig_yylex_init_extra(&scan_ctx, &scanner); + + if(stream) + libconfig_yyrestart(stream, scanner); + else /* read from string */ + buffer = libconfig_yy_scan_string(str, scanner); + + libconfig_yyset_lineno(1, scanner); + r = libconfig_yyparse(scanner, &parse_ctx, &scan_ctx); + + if(r != 0) + { + YY_BUFFER_STATE buf; + + config->error_file = scanctx_current_filename(&scan_ctx); + config->error_type = CONFIG_ERR_PARSE; + + /* Unwind the include stack, freeing the buffers and closing the files. */ + while((buf = (YY_BUFFER_STATE)scanctx_pop_include(&scan_ctx)) != NULL) + libconfig_yy_delete_buffer(buf, scanner); + } + + libconfig_yylex_destroy(scanner); + config->filenames = scanctx_cleanup(&scan_ctx, &(config->num_filenames)); + parsectx_cleanup(&parse_ctx); + + __config_locale_restore(); + + return(r == 0 ? CONFIG_TRUE : CONFIG_FALSE); +} + +/* ------------------------------------------------------------------------- */ + +int config_read(config_t *config, FILE *stream) +{ + return(__config_read(config, stream, NULL, NULL)); +} + +/* ------------------------------------------------------------------------- */ + +int config_read_string(config_t *config, const char *str) +{ + return(__config_read(config, NULL, NULL, str)); +} + +/* ------------------------------------------------------------------------- */ + +static void __config_write_setting(const config_setting_t *setting, + FILE *stream, int depth, + unsigned short tab_width) +{ + if(depth > 1) + __config_indent(stream, depth, tab_width); + + if(setting->name) + { + fputs(setting->name, stream); + fprintf(stream, " %c ", (setting->type == CONFIG_TYPE_GROUP ? ':' : '=')); + } + + __config_write_value(&(setting->value), setting->type, + config_setting_get_format(setting), + depth, tab_width, stream); + + if(depth > 0) + { + fputc(';', stream); + fputc('\n', stream); + } +} + +/* ------------------------------------------------------------------------- */ + +void config_write(const config_t *config, FILE *stream) +{ + __config_locale_override(); + + __config_write_setting(config->root, stream, 0, config->tab_width); + + __config_locale_restore(); +} + +/* ------------------------------------------------------------------------- */ + +int config_read_file(config_t *config, const char *filename) +{ + int ret; + FILE *stream = fopen(filename, "rt"); + if(! stream) + { + config->error_text = __io_error; + config->error_type = CONFIG_ERR_FILE_IO; + return(CONFIG_FALSE); + } + + ret = __config_read(config, stream, filename, NULL); + fclose(stream); + + return(ret); +} + +/* ------------------------------------------------------------------------- */ + +int config_write_file(config_t *config, const char *filename) +{ + FILE *f = fopen(filename, "wt"); + if(! f) + { + config->error_text = __io_error; + config->error_type = CONFIG_ERR_FILE_IO; + return(CONFIG_FALSE); + } + + config_write(config, f); + fclose(f); + config->error_type = CONFIG_ERR_NONE; + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +void config_destroy(config_t *config) +{ + unsigned int count = config->num_filenames; + const char **f; + + __config_setting_destroy(config->root); + + for(f = config->filenames; count > 0; ++f, --count) + _delete(*f); + + _delete(config->filenames); + _delete(config->include_dir); + + memset((void *)config, 0, sizeof(config_t)); +} + +/* ------------------------------------------------------------------------- */ + +void config_init(config_t *config) +{ + memset((void *)config, 0, sizeof(config_t)); + + config->root = _new(config_setting_t); + config->root->type = CONFIG_TYPE_GROUP; + config->root->config = config; + config->tab_width = 2; +} + +/* ------------------------------------------------------------------------- */ + +void config_set_auto_convert(config_t *config, int flag) +{ + if(flag) + config->flags |= CONFIG_OPTION_AUTOCONVERT; + else + config->flags &= ~CONFIG_OPTION_AUTOCONVERT; +} + +/* ------------------------------------------------------------------------- */ + +int config_get_auto_convert(const config_t *config) +{ + return((config->flags & CONFIG_OPTION_AUTOCONVERT) != 0); +} + +/* ------------------------------------------------------------------------- */ + +static config_setting_t *config_setting_create(config_setting_t *parent, + const char *name, int type) +{ + config_setting_t *setting; + config_list_t *list; + + if((parent->type != CONFIG_TYPE_GROUP) + && (parent->type != CONFIG_TYPE_ARRAY) + && (parent->type != CONFIG_TYPE_LIST)) + return(NULL); + + setting = _new(config_setting_t); + setting->parent = parent; + setting->name = (name == NULL) ? NULL : strdup(name); + setting->type = type; + setting->config = parent->config; + setting->hook = NULL; + setting->line = 0; + + list = parent->value.list; + + if(! list) + list = parent->value.list = _new(config_list_t); + + __config_list_add(list, setting); + + return(setting); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_setting_get_int(const config_setting_t *setting, + int *value) +{ + switch(setting->type) + { + case CONFIG_TYPE_INT: + *value = setting->value.ival; + return(CONFIG_TRUE); + + case CONFIG_TYPE_INT64: + if((setting->value.llval > INT32_MAX) + || (setting->value.llval < INT32_MIN)) + *value = 0; + else + *value = (int)(setting->value.llval); + return(CONFIG_TRUE); + + case CONFIG_TYPE_FLOAT: + if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0) + { + *value = (int)(setting->value.fval); + return(CONFIG_TRUE); + } + else + { /* fall through */ } + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_get_int(const config_setting_t *setting) +{ + int value = 0; + __config_setting_get_int(setting, &value); + return(value); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_setting_get_int64(const config_setting_t *setting, + long long *value) +{ + switch(setting->type) + { + case CONFIG_TYPE_INT64: + *value = setting->value.llval; + return(CONFIG_TRUE); + + case CONFIG_TYPE_INT: + *value = (long long)(setting->value.ival); + return(CONFIG_TRUE); + + case CONFIG_TYPE_FLOAT: + if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0) + { + *value = (long long)(setting->value.fval); + return(CONFIG_TRUE); + } + else + { /* fall through */ } + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +long long config_setting_get_int64(const config_setting_t *setting) +{ + long long value = 0; + __config_setting_get_int64(setting, &value); + return(value); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_lookup_int(const config_setting_t *setting, + const char *name, int *value) +{ + config_setting_t *member = config_setting_get_member(setting, name); + if(! member) + return(CONFIG_FALSE); + + return(__config_setting_get_int(member, value)); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_lookup_int64(const config_setting_t *setting, + const char *name, long long *value) +{ + config_setting_t *member = config_setting_get_member(setting, name); + if(! member) + return(CONFIG_FALSE); + + return(__config_setting_get_int64(member, value)); +} + +/* ------------------------------------------------------------------------- */ + +static int __config_setting_get_float(const config_setting_t *setting, + double *value) +{ + switch(setting->type) + { + case CONFIG_TYPE_FLOAT: + *value = setting->value.fval; + return(CONFIG_TRUE); + + case CONFIG_TYPE_INT: + if(config_get_auto_convert(setting->config)) + { + *value = (double)(setting->value.ival); + return(CONFIG_TRUE); + } + else + return(CONFIG_FALSE); + + case CONFIG_TYPE_INT64: + if(config_get_auto_convert(setting->config)) + { + *value = (double)(setting->value.llval); + return(CONFIG_TRUE); + } + else + { /* fall through */ } + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +double config_setting_get_float(const config_setting_t *setting) +{ + double value = 0.0; + __config_setting_get_float(setting, &value); + return(value); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_lookup_float(const config_setting_t *setting, + const char *name, double *value) +{ + config_setting_t *member = config_setting_get_member(setting, name); + if(! member) + return(CONFIG_FALSE); + + return(__config_setting_get_float(member, value)); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_lookup_string(const config_setting_t *setting, + const char *name, const char **value) +{ + config_setting_t *member = config_setting_get_member(setting, name); + if(! member) + return(CONFIG_FALSE); + + if(config_setting_type(member) != CONFIG_TYPE_STRING) + return(CONFIG_FALSE); + + *value = config_setting_get_string(member); + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_lookup_bool(const config_setting_t *setting, + const char *name, int *value) +{ + config_setting_t *member = config_setting_get_member(setting, name); + if(! member) + return(CONFIG_FALSE); + + if(config_setting_type(member) != CONFIG_TYPE_BOOL) + return(CONFIG_FALSE); + + *value = config_setting_get_bool(member); + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_set_int(config_setting_t *setting, int value) +{ + switch(setting->type) + { + case CONFIG_TYPE_NONE: + setting->type = CONFIG_TYPE_INT; + /* fall through */ + + case CONFIG_TYPE_INT: + setting->value.ival = value; + return(CONFIG_TRUE); + + case CONFIG_TYPE_FLOAT: + if(config_get_auto_convert(setting->config)) + { + setting->value.fval = (float)value; + return(CONFIG_TRUE); + } + else + return(CONFIG_FALSE); + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_set_int64(config_setting_t *setting, long long value) +{ + switch(setting->type) + { + case CONFIG_TYPE_NONE: + setting->type = CONFIG_TYPE_INT64; + /* fall through */ + + case CONFIG_TYPE_INT64: + setting->value.llval = value; + return(CONFIG_TRUE); + + case CONFIG_TYPE_INT: + if((value > INT32_MAX) || (value < INT32_MIN)) + setting->value.ival = 0; + else + setting->value.ival = (int)value; + return(CONFIG_TRUE); + + case CONFIG_TYPE_FLOAT: + if(config_get_auto_convert(setting->config)) + { + setting->value.fval = (float)value; + return(CONFIG_TRUE); + } + else + return(CONFIG_FALSE); + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_set_float(config_setting_t *setting, double value) +{ + switch(setting->type) + { + case CONFIG_TYPE_NONE: + setting->type = CONFIG_TYPE_FLOAT; + /* fall through */ + + case CONFIG_TYPE_FLOAT: + setting->value.fval = value; + return(CONFIG_TRUE); + + case CONFIG_TYPE_INT: + if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0) + { + setting->value.ival = (int)value; + return(CONFIG_TRUE); + } + else + return(CONFIG_FALSE); + + case CONFIG_TYPE_INT64: + if((setting->config->flags & CONFIG_OPTION_AUTOCONVERT) != 0) + { + setting->value.llval = (long long)value; + return(CONFIG_TRUE); + } + else + return(CONFIG_FALSE); + + default: + return(CONFIG_FALSE); + } +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_get_bool(const config_setting_t *setting) +{ + return((setting->type == CONFIG_TYPE_BOOL) ? setting->value.ival : 0); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_set_bool(config_setting_t *setting, int value) +{ + if(setting->type == CONFIG_TYPE_NONE) + setting->type = CONFIG_TYPE_BOOL; + else if(setting->type != CONFIG_TYPE_BOOL) + return(CONFIG_FALSE); + + setting->value.ival = value; + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +const char *config_setting_get_string(const config_setting_t *setting) +{ + return((setting->type == CONFIG_TYPE_STRING) ? setting->value.sval : NULL); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_set_string(config_setting_t *setting, const char *value) +{ + if(setting->type == CONFIG_TYPE_NONE) + setting->type = CONFIG_TYPE_STRING; + else if(setting->type != CONFIG_TYPE_STRING) + return(CONFIG_FALSE); + + if(setting->value.sval) + _delete(setting->value.sval); + + setting->value.sval = (value == NULL) ? NULL : strdup(value); + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_set_format(config_setting_t *setting, short format) +{ + if(((setting->type != CONFIG_TYPE_INT) + && (setting->type != CONFIG_TYPE_INT64)) + || ((format != CONFIG_FORMAT_DEFAULT) && (format != CONFIG_FORMAT_HEX))) + return(CONFIG_FALSE); + + setting->format = format; + + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +short config_setting_get_format(const config_setting_t *setting) +{ + return(setting->format != 0 ? setting->format + : setting->config->default_format); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_lookup_from(config_setting_t *setting, + const char *path) +{ + const char *p = path; + config_setting_t *found; + + for(;;) + { + while(*p && strchr(PATH_TOKENS, *p)) + p++; + + if(! *p) + break; + + if(*p == '[') + found = config_setting_get_elem(setting, atoi(++p)); + else + found = config_setting_get_member(setting, p); + + if(! found) + break; + + setting = found; + + while(! strchr(PATH_TOKENS, *p)) + p++; + } + + return(*p ? NULL : setting); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_lookup(const config_t *config, const char *path) +{ + return(config_lookup_from(config->root, path)); +} + +/* ------------------------------------------------------------------------- */ + +int config_lookup_string(const config_t *config, const char *path, + const char **value) +{ + const config_setting_t *s = config_lookup(config, path); + if(! s) + return(CONFIG_FALSE); + + if(config_setting_type(s) != CONFIG_TYPE_STRING) + return(CONFIG_FALSE); + + *value = config_setting_get_string(s); + + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_lookup_int(const config_t *config, const char *path, + int *value) +{ + const config_setting_t *s = config_lookup(config, path); + if(! s) + return(CONFIG_FALSE); + + return(__config_setting_get_int(s, value)); +} + +/* ------------------------------------------------------------------------- */ + +int config_lookup_int64(const config_t *config, const char *path, + long long *value) +{ + const config_setting_t *s = config_lookup(config, path); + if(! s) + return(CONFIG_FALSE); + + return(__config_setting_get_int64(s, value)); +} + +/* ------------------------------------------------------------------------- */ + +int config_lookup_float(const config_t *config, const char *path, + double *value) +{ + const config_setting_t *s = config_lookup(config, path); + if(! s) + return(CONFIG_FALSE); + + return(__config_setting_get_float(s, value)); +} + +/* ------------------------------------------------------------------------- */ + +int config_lookup_bool(const config_t *config, const char *path, int *value) +{ + const config_setting_t *s = config_lookup(config, path); + if(! s) + return(CONFIG_FALSE); + + if(config_setting_type(s) != CONFIG_TYPE_BOOL) + return(CONFIG_FALSE); + + *value = config_setting_get_bool(s); + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_get_int_elem(const config_setting_t *vector, int idx) +{ + const config_setting_t *element = config_setting_get_elem(vector, idx); + + return(element ? config_setting_get_int(element) : 0); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_set_int_elem(config_setting_t *vector, + int idx, int value) +{ + config_setting_t *element = NULL; + + if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST)) + return(NULL); + + if(idx < 0) + { + if(! __config_vector_checktype(vector, CONFIG_TYPE_INT)) + return(NULL); + + element = config_setting_create(vector, NULL, CONFIG_TYPE_INT); + } + else + { + element = config_setting_get_elem(vector, idx); + + if(! element) + return(NULL); + } + + if(! config_setting_set_int(element, value)) + return(NULL); + + return(element); +} + +/* ------------------------------------------------------------------------- */ + +long long config_setting_get_int64_elem(const config_setting_t *vector, + int idx) +{ + const config_setting_t *element = config_setting_get_elem(vector, idx); + + return(element ? config_setting_get_int64(element) : 0); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_set_int64_elem(config_setting_t *vector, + int idx, long long value) +{ + config_setting_t *element = NULL; + + if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST)) + return(NULL); + + if(idx < 0) + { + if(! __config_vector_checktype(vector, CONFIG_TYPE_INT64)) + return(NULL); + + element = config_setting_create(vector, NULL, CONFIG_TYPE_INT64); + } + else + { + element = config_setting_get_elem(vector, idx); + + if(! element) + return(NULL); + } + + if(! config_setting_set_int64(element, value)) + return(NULL); + + return(element); +} + +/* ------------------------------------------------------------------------- */ + +double config_setting_get_float_elem(const config_setting_t *vector, int idx) +{ + config_setting_t *element = config_setting_get_elem(vector, idx); + + return(element ? config_setting_get_float(element) : 0.0); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_set_float_elem(config_setting_t *vector, + int idx, double value) +{ + config_setting_t *element = NULL; + + if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST)) + return(NULL); + + if(idx < 0) + { + if(! __config_vector_checktype(vector, CONFIG_TYPE_FLOAT)) + return(NULL); + + element = config_setting_create(vector, NULL, CONFIG_TYPE_FLOAT); + } + else + element = config_setting_get_elem(vector, idx); + + if(! element) + return(NULL); + + if(! config_setting_set_float(element, value)) + return(NULL); + + return(element); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_get_bool_elem(const config_setting_t *vector, int idx) +{ + config_setting_t *element = config_setting_get_elem(vector, idx); + + if(! element) + return(CONFIG_FALSE); + + if(element->type != CONFIG_TYPE_BOOL) + return(CONFIG_FALSE); + + return(element->value.ival); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_set_bool_elem(config_setting_t *vector, + int idx, int value) +{ + config_setting_t *element = NULL; + + if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST)) + return(NULL); + + if(idx < 0) + { + if(! __config_vector_checktype(vector, CONFIG_TYPE_BOOL)) + return(NULL); + + element = config_setting_create(vector, NULL, CONFIG_TYPE_BOOL); + } + else + element = config_setting_get_elem(vector, idx); + + if(! element) + return(NULL); + + if(! config_setting_set_bool(element, value)) + return(NULL); + + return(element); +} + +/* ------------------------------------------------------------------------- */ + +const char *config_setting_get_string_elem(const config_setting_t *vector, + int idx) +{ + config_setting_t *element = config_setting_get_elem(vector, idx); + + if(! element) + return(NULL); + + if(element->type != CONFIG_TYPE_STRING) + return(NULL); + + return(element->value.sval); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_set_string_elem(config_setting_t *vector, + int idx, const char *value) +{ + config_setting_t *element = NULL; + + if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST)) + return(NULL); + + if(idx < 0) + { + if(! __config_vector_checktype(vector, CONFIG_TYPE_STRING)) + return(NULL); + + element = config_setting_create(vector, NULL, CONFIG_TYPE_STRING); + } + else + element = config_setting_get_elem(vector, idx); + + if(! element) + return(NULL); + + if(! config_setting_set_string(element, value)) + return(NULL); + + return(element); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_get_elem(const config_setting_t *vector, + unsigned int idx) +{ + config_list_t *list = vector->value.list; + + if(((vector->type != CONFIG_TYPE_ARRAY) + && (vector->type != CONFIG_TYPE_LIST) + && (vector->type != CONFIG_TYPE_GROUP)) || ! list) + return(NULL); + + if(idx >= list->length) + return(NULL); + + return(list->elements[idx]); +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_get_member(const config_setting_t *setting, + const char *name) +{ + if(setting->type != CONFIG_TYPE_GROUP) + return(NULL); + + return(__config_list_search(setting->value.list, name, NULL)); +} + +/* ------------------------------------------------------------------------- */ + +void config_set_destructor(config_t *config, void (*destructor)(void *)) +{ + config->destructor = destructor; +} + +/* ------------------------------------------------------------------------- */ + +void config_set_include_dir(config_t *config, const char *include_dir) +{ + _delete(config->include_dir); + config->include_dir = strdup(include_dir); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_length(const config_setting_t *setting) +{ + if((setting->type != CONFIG_TYPE_GROUP) + && (setting->type != CONFIG_TYPE_ARRAY) + && (setting->type != CONFIG_TYPE_LIST)) + return(0); + + if(! setting->value.list) + return(0); + + return(setting->value.list->length); +} + +/* ------------------------------------------------------------------------- */ + +void config_setting_set_hook(config_setting_t *setting, void *hook) +{ + setting->hook = hook; +} + +/* ------------------------------------------------------------------------- */ + +config_setting_t *config_setting_add(config_setting_t *parent, + const char *name, int type) +{ + if((type < CONFIG_TYPE_NONE) || (type > CONFIG_TYPE_LIST)) + return(NULL); + + if(! parent) + return(NULL); + + if((parent->type == CONFIG_TYPE_ARRAY) || (parent->type == CONFIG_TYPE_LIST)) + name = NULL; + + if(name) + { + if(! __config_validate_name(name)) + return(NULL); + } + + if(config_setting_get_member(parent, name) != NULL) + return(NULL); /* already exists */ + + return(config_setting_create(parent, name, type)); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_remove(config_setting_t *parent, const char *name) +{ + unsigned int idx; + config_setting_t *setting; + + if(! parent) + return(CONFIG_FALSE); + + if(parent->type != CONFIG_TYPE_GROUP) + return(CONFIG_FALSE); + + if(! (setting = __config_list_search(parent->value.list, name, &idx))) + return(CONFIG_FALSE); + + __config_list_remove(parent->value.list, idx); + __config_setting_destroy(setting); + + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_remove_elem(config_setting_t *parent, unsigned int idx) +{ + config_list_t *list; + config_setting_t *removed = NULL; + + if(! parent) + return(CONFIG_FALSE); + + list = parent->value.list; + + if(((parent->type != CONFIG_TYPE_ARRAY) + && (parent->type != CONFIG_TYPE_LIST) + && (parent->type != CONFIG_TYPE_GROUP)) || ! list) + return(CONFIG_FALSE); + + if(idx >= list->length) + return(CONFIG_FALSE); + + removed = __config_list_remove(list, idx); + __config_setting_destroy(removed); + + return(CONFIG_TRUE); +} + +/* ------------------------------------------------------------------------- */ + +int config_setting_index(const config_setting_t *setting) +{ + config_setting_t **found = NULL; + config_list_t *list; + int i; + + if(! setting->parent) + return(-1); + + list = setting->parent->value.list; + + for(i = 0, found = list->elements; i < (int)list->length; ++i, ++found) + { + if(*found == setting) + return(i); + } + + return(-1); +} + +/* ------------------------------------------------------------------------- */ +/* eof */ diff --git a/3rdparty/libconfig/libconfig.h b/3rdparty/libconfig/libconfig.h new file mode 100644 index 000000000..683bda80b --- /dev/null +++ b/3rdparty/libconfig/libconfig.h @@ -0,0 +1,320 @@ +/* ---------------------------------------------------------------------------- + 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 General Public License as published by + the Free Software Foundation, either version 3 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#ifndef __libconfig_h +#define __libconfig_h + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +#if defined(LIBCONFIG_STATIC) +#define LIBCONFIG_API +#elif defined(LIBCONFIG_EXPORTS) +#define LIBCONFIG_API __declspec(dllexport) +#else /* ! LIBCONFIG_EXPORTS */ +#define LIBCONFIG_API __declspec(dllimport) +#endif /* LIBCONFIG_STATIC */ +#else /* ! WIN32 */ +#define LIBCONFIG_API +#endif /* WIN32 */ + +#define LIBCONFIG_VER_MAJOR 1 +#define LIBCONFIG_VER_MINOR 4 +#define LIBCONFIG_VER_REVISION 8 + +#include + +#define CONFIG_TYPE_NONE 0 +#define CONFIG_TYPE_GROUP 1 +#define CONFIG_TYPE_INT 2 +#define CONFIG_TYPE_INT64 3 +#define CONFIG_TYPE_FLOAT 4 +#define CONFIG_TYPE_STRING 5 +#define CONFIG_TYPE_BOOL 6 +#define CONFIG_TYPE_ARRAY 7 +#define CONFIG_TYPE_LIST 8 + +#define CONFIG_FORMAT_DEFAULT 0 +#define CONFIG_FORMAT_HEX 1 + +#define CONFIG_OPTION_AUTOCONVERT 0x01 + +#define CONFIG_TRUE (1) +#define CONFIG_FALSE (0) + +typedef union config_value_t +{ + int ival; + long long llval; + double fval; + char *sval; + struct config_list_t *list; +} config_value_t; + +typedef struct config_setting_t +{ + char *name; + short type; + short format; + config_value_t value; + struct config_setting_t *parent; + struct config_t *config; + void *hook; + unsigned int line; + const char *file; +} config_setting_t; + +typedef enum +{ + CONFIG_ERR_NONE = 0, + CONFIG_ERR_FILE_IO = 1, + CONFIG_ERR_PARSE = 2 +} config_error_t; + +typedef struct config_list_t +{ + unsigned int length; + config_setting_t **elements; +} config_list_t; + +typedef struct config_t +{ + config_setting_t *root; + void (*destructor)(void *); + unsigned short flags; + unsigned short tab_width; + short default_format; + const char *include_dir; + const char *error_text; + const char *error_file; + int error_line; + config_error_t error_type; + const char **filenames; + unsigned int num_filenames; +} config_t; + +extern LIBCONFIG_API int config_read(config_t *config, FILE *stream); +extern LIBCONFIG_API void config_write(const config_t *config, FILE *stream); + +extern LIBCONFIG_API void config_set_default_format(config_t *config, + short format); + +extern LIBCONFIG_API void config_set_auto_convert(config_t *config, int flag); +extern LIBCONFIG_API int config_get_auto_convert(const config_t *config); + +extern LIBCONFIG_API int config_read_string(config_t *config, const char *str); + +extern LIBCONFIG_API int config_read_file(config_t *config, + const char *filename); +extern LIBCONFIG_API int config_write_file(config_t *config, + const char *filename); + +extern LIBCONFIG_API void config_set_destructor(config_t *config, + void (*destructor)(void *)); +extern LIBCONFIG_API void config_set_include_dir(config_t *config, + const char *include_dir); + +extern LIBCONFIG_API void config_init(config_t *config); +extern LIBCONFIG_API void config_destroy(config_t *config); + +extern LIBCONFIG_API int config_setting_get_int( + const config_setting_t *setting); +extern LIBCONFIG_API long long config_setting_get_int64( + const config_setting_t *setting); +extern LIBCONFIG_API double config_setting_get_float( + const config_setting_t *setting); +extern LIBCONFIG_API int config_setting_get_bool( + const config_setting_t *setting); +extern LIBCONFIG_API const char *config_setting_get_string( + const config_setting_t *setting); + +extern LIBCONFIG_API int config_setting_lookup_int( + const config_setting_t *setting, const char *name, int *value); +extern LIBCONFIG_API int config_setting_lookup_int64( + const config_setting_t *setting, const char *name, long long *value); +extern LIBCONFIG_API int config_setting_lookup_float( + const config_setting_t *setting, const char *name, double *value); +extern LIBCONFIG_API int config_setting_lookup_bool( + const config_setting_t *setting, const char *name, int *value); +extern LIBCONFIG_API int config_setting_lookup_string( + const config_setting_t *setting, const char *name, const char **value); + +extern LIBCONFIG_API int config_setting_set_int(config_setting_t *setting, + int value); +extern LIBCONFIG_API int config_setting_set_int64(config_setting_t *setting, + long long value); +extern LIBCONFIG_API int config_setting_set_float(config_setting_t *setting, + double value); +extern LIBCONFIG_API int config_setting_set_bool(config_setting_t *setting, + int value); +extern LIBCONFIG_API int config_setting_set_string(config_setting_t *setting, + const char *value); + +extern LIBCONFIG_API int config_setting_set_format(config_setting_t *setting, + short format); +extern LIBCONFIG_API short config_setting_get_format( + const config_setting_t *setting); + +extern LIBCONFIG_API int config_setting_get_int_elem( + const config_setting_t *setting, int idx); +extern LIBCONFIG_API long long config_setting_get_int64_elem( + const config_setting_t *setting, int idx); +extern LIBCONFIG_API double config_setting_get_float_elem( + const config_setting_t *setting, int idx); +extern LIBCONFIG_API int config_setting_get_bool_elem( + const config_setting_t *setting, int idx); +extern LIBCONFIG_API const char *config_setting_get_string_elem( + const config_setting_t *setting, int idx); + +extern LIBCONFIG_API config_setting_t *config_setting_set_int_elem( + config_setting_t *setting, int idx, int value); +extern LIBCONFIG_API config_setting_t *config_setting_set_int64_elem( + config_setting_t *setting, int idx, long long value); +extern LIBCONFIG_API config_setting_t *config_setting_set_float_elem( + config_setting_t *setting, int idx, double value); +extern LIBCONFIG_API config_setting_t *config_setting_set_bool_elem( + config_setting_t *setting, int idx, int value); +extern LIBCONFIG_API config_setting_t *config_setting_set_string_elem( + config_setting_t *setting, int idx, const char *value); + +#define /* const char * */ config_get_include_dir(/* const config_t * */ C) \ + ((C)->include_dir) + +#define /* int */ config_setting_type(/* const config_setting_t * */ S) \ + ((S)->type) + +#define /* int */ config_setting_is_group(/* const config_setting_t * */ S) \ + ((S)->type == CONFIG_TYPE_GROUP) +#define /* int */ config_setting_is_array(/* const config_setting_t * */ S) \ + ((S)->type == CONFIG_TYPE_ARRAY) +#define /* int */ config_setting_is_list(/* const config_setting_t * */ S) \ + ((S)->type == CONFIG_TYPE_LIST) + +#define /* int */ config_setting_is_aggregate( \ + /* const config_setting_t * */ S) \ + (((S)->type == CONFIG_TYPE_GROUP) || ((S)->type == CONFIG_TYPE_LIST) \ + || ((S)->type == CONFIG_TYPE_ARRAY)) + +#define /* int */ config_setting_is_number(/* const config_setting_t * */ S) \ + (((S)->type == CONFIG_TYPE_INT) \ + || ((S)->type == CONFIG_TYPE_INT64) \ + || ((S)->type == CONFIG_TYPE_FLOAT)) + +#define /* int */ config_setting_is_scalar(/* const config_setting_t * */ S) \ + (((S)->type == CONFIG_TYPE_BOOL) || ((S)->type == CONFIG_TYPE_STRING) \ + || config_setting_is_number(S)) + +#define /* const char * */ config_setting_name( \ + /* const config_setting_t * */ S) \ + ((S)->name) + +#define /* config_setting_t * */ config_setting_parent( \ + /* const config_setting_t * */ S) \ + ((S)->parent) + +#define /* int */ config_setting_is_root( \ + /* const config_setting_t * */ S) \ + ((S)->parent ? CONFIG_FALSE : CONFIG_TRUE) + +extern LIBCONFIG_API int config_setting_index(const config_setting_t *setting); + +extern LIBCONFIG_API int config_setting_length( + const config_setting_t *setting); +extern LIBCONFIG_API config_setting_t *config_setting_get_elem( + const config_setting_t *setting, unsigned int idx); + +extern LIBCONFIG_API config_setting_t *config_setting_get_member( + const config_setting_t *setting, const char *name); + +extern LIBCONFIG_API config_setting_t *config_setting_add( + config_setting_t *parent, const char *name, int type); +extern LIBCONFIG_API int config_setting_remove(config_setting_t *parent, + const char *name); +extern LIBCONFIG_API int config_setting_remove_elem(config_setting_t *parent, + unsigned int idx); +extern LIBCONFIG_API void config_setting_set_hook(config_setting_t *setting, + void *hook); + +#define config_setting_get_hook(S) ((S)->hook) + +extern LIBCONFIG_API config_setting_t *config_lookup(const config_t *config, + const char *path); +extern LIBCONFIG_API config_setting_t *config_lookup_from( + config_setting_t *setting, const char *path); + +extern LIBCONFIG_API int config_lookup_int(const config_t *config, + const char *path, int *value); +extern LIBCONFIG_API int config_lookup_int64(const config_t *config, + const char *path, + long long *value); +extern LIBCONFIG_API int config_lookup_float(const config_t *config, + const char *path, double *value); +extern LIBCONFIG_API int config_lookup_bool(const config_t *config, + const char *path, int *value); +extern LIBCONFIG_API int config_lookup_string(const config_t *config, + const char *path, + const char **value); + +#define /* config_setting_t * */ config_root_setting( \ + /* const config_t * */ C) \ + ((C)->root) + +#define /* void */ config_set_default_format(/* config_t * */ C, \ + /* short */ F) \ + (C)->default_format = (F) + +#define /* short */ config_get_default_format(/* config_t * */ C) \ + ((C)->default_format) + +#define /* void */ config_set_tab_width(/* config_t * */ C, \ + /* unsigned short */ W) \ + (C)->tab_width = ((W) & 0x0F) + +#define /* unsigned char */ config_get_tab_width(/* const config_t * */ C) \ + ((C)->tab_width) + +#define /* unsigned short */ config_setting_source_line( \ + /* const config_setting_t * */ S) \ + ((S)->line) + +#define /* const char */ config_setting_source_file( \ + /* const config_setting_t * */ S) \ + ((S)->file) + +#define /* const char * */ config_error_text(/* const config_t * */ C) \ + ((C)->error_text) + +#define /* const char * */ config_error_file(/* const config_t * */ C) \ + ((C)->error_file) + +#define /* int */ config_error_line(/* const config_t * */ C) \ + ((C)->error_line) + +#define /* config_error_t */ config_error_type(/* const config_t * */ C) \ + ((C)->error_type) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __libconfig_h */ diff --git a/3rdparty/libconfig/parsectx.h b/3rdparty/libconfig/parsectx.h new file mode 100644 index 000000000..0beb1111c --- /dev/null +++ b/3rdparty/libconfig/parsectx.h @@ -0,0 +1,47 @@ +/* ---------------------------------------------------------------------------- + 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 General Public License as published by + the Free Software Foundation, either version 3 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#ifndef __libconfig_parsectx_h +#define __libconfig_parsectx_h + +#include "libconfig.h" +#include "strbuf.h" + +struct parse_context +{ + config_t *config; + config_setting_t *parent; + config_setting_t *setting; + char *name; + strbuf_t string; +}; + +#define parsectx_init(C) \ + memset((C), 0, sizeof(struct parse_context)) +#define parsectx_cleanup(C) \ + free((void *)(strbuf_release(&((C)->string)))) + +#define parsectx_append_string(C, S) \ + strbuf_append(&((C)->string), (S)) +#define parsectx_take_string(C) \ + strbuf_release(&((C)->string)) + +#endif /* __libconfig_parsectx_h */ diff --git a/3rdparty/libconfig/scanctx.c b/3rdparty/libconfig/scanctx.c new file mode 100644 index 000000000..7d7f4994c --- /dev/null +++ b/3rdparty/libconfig/scanctx.c @@ -0,0 +1,170 @@ +/* ---------------------------------------------------------------------------- + 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 General Public License as published by + the Free Software Foundation, either version 3 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#include "scanctx.h" +#include "wincompat.h" + +#include +#include +#include + +#define STRING_BLOCK_SIZE 64 +#define CHUNK_SIZE 32 + +/* ------------------------------------------------------------------------- */ + +static const char *err_bad_include = "cannot open include file"; +static const char *err_include_too_deep = "include file nesting too deep"; + +/* ------------------------------------------------------------------------- */ + +static const char *__scanctx_add_filename(struct scan_context *ctx, + const char *filename) +{ + unsigned int count = ctx->num_filenames; + const char **f; + + for(f = ctx->filenames; count > 0; ++f, --count) + { + if(!strcmp(*f, filename)) + { + free((void *)filename); + return(*f); /* already in list */ + } + } + + if((ctx->num_filenames % CHUNK_SIZE) == 0) + { + ctx->filenames = (const char **)realloc( + (void *)ctx->filenames, + (ctx->num_filenames + CHUNK_SIZE) * sizeof(const char *)); + } + + ctx->filenames[ctx->num_filenames] = filename; + ++ctx->num_filenames; + return(filename); +} + +/* ------------------------------------------------------------------------- */ + +void scanctx_init(struct scan_context *ctx, const char *top_filename) +{ + memset(ctx, 0, sizeof(struct scan_context)); + if(top_filename) + ctx->top_filename = __scanctx_add_filename(ctx, strdup(top_filename)); +} + +/* ------------------------------------------------------------------------- */ + +const char **scanctx_cleanup(struct scan_context *ctx, + unsigned int *num_filenames) +{ + int i; + + for(i = 0; i < ctx->depth; ++i) + fclose(ctx->streams[i]); + + free((void *)(strbuf_release(&(ctx->string)))); + + *num_filenames = ctx->num_filenames; + return(ctx->filenames); +} + +/* ------------------------------------------------------------------------- */ + +FILE *scanctx_push_include(struct scan_context *ctx, void *buffer, + const char **error) +{ + FILE *fp = NULL; + const char *file; + char *full_file = NULL; + + *error = NULL; + + if(ctx->depth == MAX_INCLUDE_DEPTH) + { + *error = err_include_too_deep; + return(NULL); + } + + file = scanctx_take_string(ctx); + if(ctx->config->include_dir) + { + full_file = (char *)malloc(strlen(ctx->config->include_dir) + strlen(file) + + 2); + strcpy(full_file, ctx->config->include_dir); + strcat(full_file, FILE_SEPARATOR); + strcat(full_file, file); + } + + fp = fopen(full_file ? full_file : file, "rt"); + free((void *)full_file); + + if(fp) + { + ctx->streams[ctx->depth] = fp; + ctx->files[ctx->depth] = __scanctx_add_filename(ctx, file); + ctx->buffers[ctx->depth] = buffer; + ++(ctx->depth); + } + else + { + free((void *)file); + *error = err_bad_include; + } + + return(fp); +} + +/* ------------------------------------------------------------------------- */ + +void *scanctx_pop_include(struct scan_context *ctx) +{ + void *buffer; + + if(ctx->depth == 0) + return(NULL); /* stack underflow */ + + --(ctx->depth); + buffer = ctx->buffers[ctx->depth]; + fclose(ctx->streams[ctx->depth]); + + return(buffer); +} + +/* ------------------------------------------------------------------------- */ + +char *scanctx_take_string(struct scan_context *ctx) +{ + char *r = strbuf_release(&(ctx->string)); + + return(r ? r : strdup("")); +} + +/* ------------------------------------------------------------------------- */ + +const char *scanctx_current_filename(struct scan_context *ctx) +{ + return((ctx->depth == 0) ? ctx->top_filename : ctx->files[ctx->depth - 1]); +} + +/* ------------------------------------------------------------------------- */ +/* eof */ diff --git a/3rdparty/libconfig/scanctx.h b/3rdparty/libconfig/scanctx.h new file mode 100644 index 000000000..b8cc11e3d --- /dev/null +++ b/3rdparty/libconfig/scanctx.h @@ -0,0 +1,61 @@ +/* ---------------------------------------------------------------------------- + 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 General Public License as published by + the Free Software Foundation, either version 3 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#ifndef __libconfig_scanctx_h +#define __libconfig_scanctx_h + +#include "libconfig.h" +#include "strbuf.h" + +#include +#include + +#define MAX_INCLUDE_DEPTH 10 + +struct scan_context +{ + config_t *config; + const char *top_filename; + const char *files[MAX_INCLUDE_DEPTH]; + void *buffers[MAX_INCLUDE_DEPTH]; + FILE *streams[MAX_INCLUDE_DEPTH]; + int depth; + strbuf_t string; + const char **filenames; + unsigned int num_filenames; +}; + +extern void scanctx_init(struct scan_context *ctx, const char *top_filename); +extern const char **scanctx_cleanup(struct scan_context *ctx, + unsigned int *num_filenames); + +extern FILE *scanctx_push_include(struct scan_context *ctx, void *prev_buffer, + const char **error); +extern void *scanctx_pop_include(struct scan_context *ctx); + +#define scanctx_append_string(C, S) \ + strbuf_append(&((C)->string), (S)) + +extern char *scanctx_take_string(struct scan_context *ctx); + +extern const char *scanctx_current_filename(struct scan_context *ctx); + +#endif /* __libconfig_scanctx_h */ diff --git a/3rdparty/libconfig/scanner.c b/3rdparty/libconfig/scanner.c new file mode 100644 index 000000000..c2eb7d188 --- /dev/null +++ b/3rdparty/libconfig/scanner.c @@ -0,0 +1,2362 @@ +#line 2 "scanner.c" + +#line 4 "scanner.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#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. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! C99 */ + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column) +#define yy_flex_debug yyg->yy_flex_debug_r + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yyg->yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yyg->yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE libconfig_yyrestart(yyin ,yyscanner ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* 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. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires + * access to the local variable yy_act. Since yyless() is a macro, it would break + * existing scanners that call yyless() from OUTSIDE libconfig_yylex. + * One obvious solution it to make yy_act a global. I tried that, and saw + * a 5% performance hit in a non-yylineno scanner, because yy_act is + * normally declared as a register variable-- so it is not worth it. + */ + #define YY_LESS_LINENO(n) \ + do { \ + int yyl;\ + for ( yyl = n; yyl < yyleng; ++yyl )\ + if ( yytext[yyl] == '\n' )\ + --yylineno;\ + }while(0) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = yyg->yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#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 + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int 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 + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via libconfig_yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \ + ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] + +void libconfig_yyrestart (FILE *input_file ,yyscan_t yyscanner ); +void libconfig_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE libconfig_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void libconfig_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void libconfig_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void libconfig_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +void libconfig_yypop_buffer_state (yyscan_t yyscanner ); + +static void libconfig_yyensure_buffer_stack (yyscan_t yyscanner ); +static void libconfig_yy_load_buffer_state (yyscan_t yyscanner ); +static void libconfig_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner ); + +#define YY_FLUSH_BUFFER libconfig_yy_flush_buffer(YY_CURRENT_BUFFER ,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 ); + +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 yy_new_buffer libconfig_yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + libconfig_yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + libconfig_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + libconfig_yyensure_buffer_stack (yyscanner); \ + YY_CURRENT_BUFFER_LVALUE = \ + libconfig_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +#define libconfig_yywrap(n) 1 +#define YY_SKIP_YYWRAP + +typedef unsigned char YY_CHAR; + +typedef int yy_state_type; + +#define yytext_ptr yytext_r + +static yy_state_type yy_get_previous_state (yyscan_t yyscanner ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner); +static int yy_get_next_buffer (yyscan_t yyscanner ); +static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yyg->yytext_ptr = yy_bp; \ + yyleng = (size_t) (yy_cp - yy_bp); \ + yyg->yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yyg->yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 41 +#define YY_END_OF_BUFFER 42 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +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, 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, + + 15, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 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, 1, 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, 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, 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, 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, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +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, + 3, 3, 3, 3, 3, 3, 1, 1 + } ; + +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 + } ; + +static yyconst flex_int16_t yy_def[113] = + { 0, + 102, 1, 103, 103, 104, 104, 105, 105, 102, 102, + 102, 102, 102, 102, 106, 102, 102, 107, 102, 102, + 102, 102, 102, 102, 102, 102, 107, 107, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 108, 102, 102, + 109, 102, 102, 102, 106, 102, 107, 102, 102, 102, + 102, 102, 106, 102, 102, 102, 110, 107, 107, 102, + 102, 102, 102, 108, 102, 111, 102, 102, 102, 102, + 102, 109, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 110, 107, 107, 102, 112, 102, 102, 102, 107, + 107, 102, 102, 102, 107, 102, 102, 102, 102, 102, + + 102, 0, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102 + } ; + +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, + 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, + + 46, 44, 102, 9, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102 + } ; + +static yyconst flex_int16_t yy_chk[253] = + { 0, + 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, 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, + + 15, 11, 9, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, + 102, 102 + } ; + +/* Table of booleans, true if rule could match eol. */ +static yyconst flex_int32_t yy_rule_can_match_eol[42] = + { 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, }; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +#line 1 "scanner.l" +/* -*- 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 + . + ---------------------------------------------------------------------------- +*/ +#define YY_NO_UNISTD_H 1 +#line 35 "scanner.l" + +#ifdef _MSC_VER +#pragma warning (disable: 4996) +#endif + +#include +#include +#include +#include "grammar.h" +#include "wincompat.h" +#include "parsectx.h" +#include "scanctx.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__ */ +} + + +#line 626 "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 +#endif + +#define YY_EXTRA_TYPE struct scan_context * + +/* Holds the entire state of the reentrant scanner. */ +struct yyguts_t + { + + /* User-defined. Not touched by flex. */ + YY_EXTRA_TYPE yyextra_r; + + /* The rest are the same as the globals declared in the non-reentrant scanner. */ + FILE *yyin_r, *yyout_r; + size_t yy_buffer_stack_top; /**< index of top of stack. */ + 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; + char *yy_c_buf_p; + int yy_init; + int yy_start; + int yy_did_buffer_switch_on_eof; + int yy_start_stack_ptr; + int yy_start_stack_depth; + int *yy_start_stack; + yy_state_type yy_last_accepting_state; + char* yy_last_accepting_cpos; + + int yylineno_r; + int yy_flex_debug_r; + + char *yytext_r; + int yy_more_flag; + int yy_more_len; + + YYSTYPE * yylval_r; + + }; /* end struct yyguts_t */ + +static int yy_init_globals (yyscan_t yyscanner ); + + /* This must go here because YYSTYPE and YYLTYPE are included + * from bison output in section 1.*/ + # define yylval yyg->yylval_r + +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. */ + +int libconfig_yylex_destroy (yyscan_t yyscanner ); + +int libconfig_yyget_debug (yyscan_t yyscanner ); + +void libconfig_yyset_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE libconfig_yyget_extra (yyscan_t yyscanner ); + +void libconfig_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *libconfig_yyget_in (yyscan_t yyscanner ); + +void libconfig_yyset_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *libconfig_yyget_out (yyscan_t yyscanner ); + +void libconfig_yyset_out (FILE * out_str ,yyscan_t yyscanner ); + +int libconfig_yyget_leng (yyscan_t yyscanner ); + +char *libconfig_yyget_text (yyscan_t yyscanner ); + +int libconfig_yyget_lineno (yyscan_t yyscanner ); + +void libconfig_yyset_lineno (int line_number ,yyscan_t yyscanner ); + +YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner ); + +void libconfig_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int libconfig_yywrap (yyscan_t yyscanner ); +#else +extern int libconfig_yywrap (yyscan_t yyscanner ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (yyscan_t yyscanner ); +#else +static int input (yyscan_t yyscanner ); +#endif + +#endif + +/* 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. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + size_t n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(yyin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int libconfig_yylex \ + (YYSTYPE * yylval_param ,yyscan_t yyscanner); + +#define YY_DECL int libconfig_yylex \ + (YYSTYPE * yylval_param , yyscan_t yyscanner) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + if ( yyleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (yytext[yyleng - 1] == '\n'); \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + +#line 100 "scanner.l" + + +#line 869 "scanner.c" + + yylval = yylval_param; + + if ( !yyg->yy_init ) + { + yyg->yy_init = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yyg->yy_start ) + yyg->yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + libconfig_yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + libconfig_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + libconfig_yy_load_buffer_state(yyscanner ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yyg->yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yyg->yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 103 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 204 ); + +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; + + if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) + { + int yyl; + for ( yyl = 0; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + + do{ yylineno++; + yycolumn=0; + }while(0) +; + } + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = yyg->yy_hold_char; + yy_cp = yyg->yy_last_accepting_cpos; + yy_current_state = yyg->yy_last_accepting_state; + goto yy_find_action; + +case 1: +YY_RULE_SETUP +#line 102 "scanner.l" +{ BEGIN COMMENT; } + YY_BREAK +case 2: +YY_RULE_SETUP +#line 103 "scanner.l" +{ BEGIN INITIAL; } + YY_BREAK +case 3: +YY_RULE_SETUP +#line 104 "scanner.l" +{ /* ignore */ } + YY_BREAK +case 4: +/* rule 4 can match eol */ +YY_RULE_SETUP +#line 105 "scanner.l" +{ /* ignore */ } + YY_BREAK +case 5: +YY_RULE_SETUP +#line 107 "scanner.l" +{ BEGIN STRING; } + YY_BREAK +case 6: +/* rule 6 can match eol */ +YY_RULE_SETUP +#line 108 "scanner.l" +{ scanctx_append_string(yyextra, yytext); } + YY_BREAK +case 7: +YY_RULE_SETUP +#line 109 "scanner.l" +{ scanctx_append_string(yyextra, "\n"); } + YY_BREAK +case 8: +YY_RULE_SETUP +#line 110 "scanner.l" +{ scanctx_append_string(yyextra, "\r"); } + YY_BREAK +case 9: +YY_RULE_SETUP +#line 111 "scanner.l" +{ scanctx_append_string(yyextra, "\t"); } + YY_BREAK +case 10: +YY_RULE_SETUP +#line 112 "scanner.l" +{ scanctx_append_string(yyextra, "\f"); } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 113 "scanner.l" +{ scanctx_append_string(yyextra, "\\"); } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 114 "scanner.l" +{ scanctx_append_string(yyextra, "\""); } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 115 "scanner.l" +{ + char c[2] = { (char)(strtol(yytext + 2, NULL, 16) & 0xFF), + 0 }; + scanctx_append_string(yyextra, c); + } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 120 "scanner.l" +{ + yylval->sval = scanctx_take_string(yyextra); + BEGIN INITIAL; + return(TOK_STRING); + } + YY_BREAK +case 15: +YY_RULE_SETUP +#line 126 "scanner.l" +{ BEGIN INCLUDE; } + YY_BREAK +case 16: +/* rule 16 can match eol */ +YY_RULE_SETUP +#line 127 "scanner.l" +{ scanctx_append_string(yyextra, yytext); } + YY_BREAK +case 17: +YY_RULE_SETUP +#line 128 "scanner.l" +{ scanctx_append_string(yyextra, "\\"); } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 129 "scanner.l" +{ scanctx_append_string(yyextra, "\""); } + YY_BREAK +case 19: +YY_RULE_SETUP +#line 130 "scanner.l" +{ + const char *error; + FILE *fp = scanctx_push_include(yyextra, + (void *)YY_CURRENT_BUFFER, + &error); + if(fp) + { + yyin = fp; + libconfig_yy_switch_to_buffer(libconfig_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; + } + YY_BREAK +case 20: +/* rule 20 can match eol */ +YY_RULE_SETUP +#line 154 "scanner.l" +{ /* ignore */ } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 155 "scanner.l" +{ /* ignore */ } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 157 "scanner.l" +{ return(TOK_EQUALS); } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 158 "scanner.l" +{ return(TOK_COMMA); } + YY_BREAK +case 24: +YY_RULE_SETUP +#line 159 "scanner.l" +{ return(TOK_GROUP_START); } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 160 "scanner.l" +{ return(TOK_GROUP_END); } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 161 "scanner.l" +{ yylval->ival = 1; return(TOK_BOOLEAN); } + YY_BREAK +case 27: +YY_RULE_SETUP +#line 162 "scanner.l" +{ yylval->ival = 0; return(TOK_BOOLEAN); } + YY_BREAK +case 28: +YY_RULE_SETUP +#line 163 "scanner.l" +{ yylval->sval = yytext; return(TOK_NAME); } + YY_BREAK +case 29: +YY_RULE_SETUP +#line 164 "scanner.l" +{ yylval->fval = atof(yytext); return(TOK_FLOAT); } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 165 "scanner.l" +{ yylval->ival = atoi(yytext); return(TOK_INTEGER); } + YY_BREAK +case 31: +YY_RULE_SETUP +#line 166 "scanner.l" +{ yylval->llval = atoll(yytext); return(TOK_INTEGER64); } + YY_BREAK +case 32: +YY_RULE_SETUP +#line 167 "scanner.l" +{ + yylval->ival = strtoul(yytext, NULL, 16); + return(TOK_HEX); + } + YY_BREAK +case 33: +YY_RULE_SETUP +#line 171 "scanner.l" +{ yylval->llval = fromhex(yytext); return(TOK_HEX64); } + YY_BREAK +case 34: +YY_RULE_SETUP +#line 172 "scanner.l" +{ return(TOK_ARRAY_START); } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 173 "scanner.l" +{ return(TOK_ARRAY_END); } + YY_BREAK +case 36: +YY_RULE_SETUP +#line 174 "scanner.l" +{ return(TOK_LIST_START); } + YY_BREAK +case 37: +YY_RULE_SETUP +#line 175 "scanner.l" +{ return(TOK_LIST_END); } + YY_BREAK +case 38: +YY_RULE_SETUP +#line 176 "scanner.l" +{ return(TOK_SEMICOLON); } + YY_BREAK +case 39: +*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" +{ /* ignore */ } + YY_BREAK +case 40: +YY_RULE_SETUP +#line 178 "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" +{ + YY_BUFFER_STATE buf = (YY_BUFFER_STATE)scanctx_pop_include( + yyextra); + if(buf) + { + libconfig_yy_delete_buffer(YY_CURRENT_BUFFER,yyscanner); + libconfig_yy_switch_to_buffer(buf,yyscanner); + } + else + yyterminate(); + } + YY_BREAK +case 41: +YY_RULE_SETUP +#line 191 "scanner.l" +ECHO; + YY_BREAK +#line 1227 "scanner.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yyg->yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * libconfig_yylex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner); + + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yyg->yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yyg->yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_END_OF_FILE: + { + yyg->yy_did_buffer_switch_on_eof = 0; + + if ( libconfig_yywrap(yyscanner ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = + yyg->yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yyg->yy_c_buf_p = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars]; + + yy_current_state = yy_get_previous_state( yyscanner ); + + yy_cp = yyg->yy_c_buf_p; + yy_bp = yyg->yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of libconfig_yylex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = yyg->yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0; + + else + { + int 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; + + 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; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + libconfig_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* 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 ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + if ( yyg->yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + libconfig_yyrestart(yyin ,yyscanner); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) libconfig_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + yyg->yy_n_chars += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (yyscan_t yyscanner) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + yy_current_state = yyg->yy_start; + yy_current_state += YY_AT_BOL(); + + for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 103 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) +{ + register int yy_is_jam; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ + register char *yy_cp = yyg->yy_c_buf_p; + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + yyg->yy_last_accepting_state = yy_current_state; + yyg->yy_last_accepting_cpos = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 103 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 102); + + return yy_is_jam ? 0 : yy_current_state; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (yyscan_t yyscanner) +#else + static int input (yyscan_t yyscanner) +#endif + +{ + int c; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + *yyg->yy_c_buf_p = yyg->yy_hold_char; + + if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] ) + /* This was really a NUL. */ + *yyg->yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yyg->yy_c_buf_p - yyg->yytext_ptr; + ++yyg->yy_c_buf_p; + + switch ( yy_get_next_buffer( yyscanner ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + libconfig_yyrestart(yyin ,yyscanner); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( libconfig_yywrap(yyscanner ) ) + return EOF; + + if ( ! yyg->yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(yyscanner); +#else + return input(yyscanner); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yyg->yy_c_buf_p = yyg->yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */ + *yyg->yy_c_buf_p = '\0'; /* preserve yytext */ + yyg->yy_hold_char = *++yyg->yy_c_buf_p; + + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + if ( YY_CURRENT_BUFFER_LVALUE->yy_at_bol ) + + do{ yylineno++; + yycolumn=0; + }while(0) +; + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * @param yyscanner The scanner object. + * @note This function does not reset the start condition to @c INITIAL . + */ + void libconfig_yyrestart (FILE * input_file , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! YY_CURRENT_BUFFER ){ + libconfig_yyensure_buffer_stack (yyscanner); + YY_CURRENT_BUFFER_LVALUE = + libconfig_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); + } + + libconfig_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner); + libconfig_yy_load_buffer_state(yyscanner ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * @param yyscanner The scanner object. + */ + void libconfig_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* TODO. We should be able to replace this entire function body + * with + * libconfig_yypop_buffer_state(); + * libconfig_yypush_buffer_state(new_buffer); + */ + libconfig_yyensure_buffer_stack (yyscanner); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + libconfig_yy_load_buffer_state(yyscanner ); + + /* We don't actually know whether we did this switch during + * EOF (libconfig_yywrap()) processing, but the only time this flag + * is looked at is after libconfig_yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yyg->yy_did_buffer_switch_on_eof = 1; +} + +static void libconfig_yy_load_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + yyg->yy_hold_char = *yyg->yy_c_buf_p; +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * @param yyscanner The scanner object. + * @return the allocated buffer state. + */ + YY_BUFFER_STATE libconfig_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) libconfig_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in libconfig_yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) libconfig_yyalloc(b->yy_buf_size + 2 ,yyscanner ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in libconfig_yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + libconfig_yy_init_buffer(b,file ,yyscanner); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with libconfig_yy_create_buffer() + * @param yyscanner The scanner object. + */ + void libconfig_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + libconfig_yyfree((void *) b->yy_ch_buf ,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. + */ + static void libconfig_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner) + +{ + int oerrno = errno; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + libconfig_yy_flush_buffer(b ,yyscanner); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then libconfig_yy_init_buffer was _probably_ + * called from libconfig_yyrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * @param yyscanner The scanner object. + */ + void libconfig_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + libconfig_yy_load_buffer_state(yyscanner ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * @param yyscanner The scanner object. + */ +void libconfig_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (new_buffer == NULL) + return; + + libconfig_yyensure_buffer_stack(yyscanner); + + /* This block is copied from libconfig_yy_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *yyg->yy_c_buf_p = yyg->yy_hold_char; + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p; + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars; + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + yyg->yy_buffer_stack_top++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from libconfig_yy_switch_to_buffer. */ + libconfig_yy_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * @param yyscanner The scanner object. + */ +void libconfig_yypop_buffer_state (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + if (!YY_CURRENT_BUFFER) + return; + + libconfig_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner); + YY_CURRENT_BUFFER_LVALUE = NULL; + if (yyg->yy_buffer_stack_top > 0) + --yyg->yy_buffer_stack_top; + + if (YY_CURRENT_BUFFER) { + libconfig_yy_load_buffer_state(yyscanner ); + yyg->yy_did_buffer_switch_on_eof = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void libconfig_yyensure_buffer_stack (yyscan_t yyscanner) +{ + int num_to_alloc; + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (!yyg->yy_buffer_stack) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + yyg->yy_buffer_stack = (struct yy_buffer_state**)libconfig_yyalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in libconfig_yyensure_buffer_stack()" ); + + memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + yyg->yy_buffer_stack_max = num_to_alloc; + yyg->yy_buffer_stack_top = 0; + return; + } + + if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = yyg->yy_buffer_stack_max + grow_size; + yyg->yy_buffer_stack = (struct yy_buffer_state**)libconfig_yyrealloc + (yyg->yy_buffer_stack, + num_to_alloc * sizeof(struct yy_buffer_state*) + , yyscanner); + if ( ! yyg->yy_buffer_stack ) + YY_FATAL_ERROR( "out of dynamic memory in libconfig_yyensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*)); + yyg->yy_buffer_stack_max = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE libconfig_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) libconfig_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in libconfig_yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + libconfig_yy_switch_to_buffer(b ,yyscanner ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to libconfig_yylex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * @param yyscanner The scanner object. + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * libconfig_yy_scan_bytes() instead. + */ +YY_BUFFER_STATE libconfig_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner) +{ + + return libconfig_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner); +} + +/** Setup the input buffer state to scan the given bytes. The next call to libconfig_yylex() will + * scan from a @e copy of @a bytes. + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * @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 b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) libconfig_yyalloc(n ,yyscanner ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in libconfig_yy_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = libconfig_yy_scan_buffer(buf,n ,yyscanner); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in libconfig_yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + yytext[yyleng] = yyg->yy_hold_char; \ + yyg->yy_c_buf_p = yytext + yyless_macro_arg; \ + yyg->yy_hold_char = *yyg->yy_c_buf_p; \ + *yyg->yy_c_buf_p = '\0'; \ + yyleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the user-defined data for this scanner. + * @param yyscanner The scanner object. + */ +YY_EXTRA_TYPE libconfig_yyget_extra (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyextra; +} + +/** Get the current line number. + * @param yyscanner The scanner object. + */ +int libconfig_yyget_lineno (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yylineno; +} + +/** Get the current column number. + * @param yyscanner The scanner object. + */ +int libconfig_yyget_column (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + if (! YY_CURRENT_BUFFER) + return 0; + + return yycolumn; +} + +/** Get the input stream. + * @param yyscanner The scanner object. + */ +FILE *libconfig_yyget_in (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyin; +} + +/** Get the output stream. + * @param yyscanner The scanner object. + */ +FILE *libconfig_yyget_out (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyout; +} + +/** Get the length of the current token. + * @param yyscanner The scanner object. + */ +int libconfig_yyget_leng (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yyleng; +} + +/** Get the current token. + * @param yyscanner The scanner object. + */ + +char *libconfig_yyget_text (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yytext; +} + +/** Set the user-defined data. This data is never touched by the scanner. + * @param user_defined The data to be associated with this scanner. + * @param yyscanner The scanner object. + */ +void libconfig_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyextra = user_defined ; +} + +/** Set the current line number. + * @param line_number + * @param yyscanner The scanner object. + */ +void libconfig_yyset_lineno (int line_number , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_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); + + yylineno = line_number; +} + +/** Set the current column. + * @param line_number + * @param yyscanner The scanner object. + */ +void libconfig_yyset_column (int column_no , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_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); + + yycolumn = column_no; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * @param yyscanner The scanner object. + * @see libconfig_yy_switch_to_buffer + */ +void libconfig_yyset_in (FILE * in_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyin = in_str ; +} + +void libconfig_yyset_out (FILE * out_str , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yyout = out_str ; +} + +int libconfig_yyget_debug (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yy_flex_debug; +} + +void libconfig_yyset_debug (int bdebug , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yy_flex_debug = bdebug ; +} + +/* Accessor methods for yylval and yylloc */ + +YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + return yylval; +} + +void libconfig_yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + yylval = yylval_param; +} + +/* User-visible API */ + +/* libconfig_yylex_init is special because it creates the scanner itself, so it is + * the ONLY reentrant function that doesn't take the scanner as the last argument. + * That's why we explicitly handle the declaration, instead of using our macros. + */ + +int libconfig_yylex_init(yyscan_t* ptr_yy_globals) + +{ + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) libconfig_yyalloc ( sizeof( struct yyguts_t ), NULL ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + return yy_init_globals ( *ptr_yy_globals ); +} + +/* libconfig_yylex_init_extra has the same functionality as libconfig_yylex_init, but follows the + * convention of taking the scanner as the last argument. Note however, that + * this is a *pointer* to a scanner, as it will be allocated by this call (and + * is the reason, too, why this function also must handle its own declaration). + * The user defined value in the first argument will be available to libconfig_yyalloc in + * the yyextra field. + */ + +int libconfig_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals ) + +{ + struct yyguts_t dummy_yyguts; + + libconfig_yyset_extra (yy_user_defined, &dummy_yyguts); + + if (ptr_yy_globals == NULL){ + errno = EINVAL; + return 1; + } + + *ptr_yy_globals = (yyscan_t) libconfig_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts ); + + if (*ptr_yy_globals == NULL){ + errno = ENOMEM; + return 1; + } + + /* By setting to 0xAA, we expose bugs in + yy_init_globals. Leave at 0x00 for releases. */ + memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t)); + + libconfig_yyset_extra (yy_user_defined, *ptr_yy_globals); + + return yy_init_globals ( *ptr_yy_globals ); +} + +static int yy_init_globals (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from libconfig_yylex_destroy(), so don't allocate here. + */ + + yyg->yy_buffer_stack = 0; + yyg->yy_buffer_stack_top = 0; + yyg->yy_buffer_stack_max = 0; + yyg->yy_c_buf_p = (char *) 0; + yyg->yy_init = 0; + yyg->yy_start = 0; + + yyg->yy_start_stack_ptr = 0; + yyg->yy_start_stack_depth = 0; + yyg->yy_start_stack = NULL; + +/* Defined in main.c */ +#ifdef YY_STDINIT + yyin = stdin; + yyout = stdout; +#else + yyin = (FILE *) 0; + yyout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * libconfig_yylex_init() + */ + return 0; +} + +/* libconfig_yylex_destroy is for both reentrant and non-reentrant scanners. */ +int libconfig_yylex_destroy (yyscan_t yyscanner) +{ + struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + libconfig_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner ); + YY_CURRENT_BUFFER_LVALUE = NULL; + libconfig_yypop_buffer_state(yyscanner); + } + + /* Destroy the stack itself. */ + libconfig_yyfree(yyg->yy_buffer_stack ,yyscanner); + yyg->yy_buffer_stack = NULL; + + /* Destroy the start condition stack. */ + libconfig_yyfree(yyg->yy_start_stack ,yyscanner ); + yyg->yy_start_stack = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * libconfig_yylex() is called, initialization will occur. */ + yy_init_globals( yyscanner); + + /* Destroy the main struct (reentrant only). */ + libconfig_yyfree ( yyscanner , yyscanner ); + yyscanner = NULL; + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *libconfig_yyalloc (yy_size_t size , yyscan_t yyscanner) +{ + return (void *) malloc( size ); +} + +void *libconfig_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void libconfig_yyfree (void * ptr , yyscan_t yyscanner) +{ + free( (char *) ptr ); /* see libconfig_yyrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + +#line 191 "scanner.l" diff --git a/3rdparty/libconfig/scanner.h b/3rdparty/libconfig/scanner.h new file mode 100644 index 000000000..baa6f771f --- /dev/null +++ b/3rdparty/libconfig/scanner.h @@ -0,0 +1,326 @@ +#ifndef libconfig_yyHEADER_H +#define libconfig_yyHEADER_H 1 +#define libconfig_yyIN_HEADER 1 + +#line 6 "scanner.h" + +#line 8 "scanner.h" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 33 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include +#include +#include +#include + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have . Non-C99 systems may or may not. */ + +#if __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. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +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 +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* An opaque pointer. */ +#ifndef YY_TYPEDEF_YY_SCANNER_T +#define YY_TYPEDEF_YY_SCANNER_T +typedef void* yyscan_t; +#endif + +/* For convenience, these vars (plus the bison vars far below) + are macros in the reentrant scanner. */ +#define yyin yyg->yyin_r +#define yyout yyg->yyout_r +#define yyextra yyg->yyextra_r +#define yyleng yyg->yyleng_r +#define yytext yyg->yytext_r +#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno) +#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); + +#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; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int 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 + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +void libconfig_yyrestart (FILE *input_file ,yyscan_t yyscanner ); +void libconfig_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +YY_BUFFER_STATE libconfig_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner ); +void libconfig_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void libconfig_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner ); +void libconfig_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner ); +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 ); + +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 YY_SKIP_YYWRAP + +#define yytext_ptr yytext_r + +#ifdef YY_HEADER_EXPORT_START_CONDITIONS +#define INITIAL 0 +#define COMMENT 1 + +#endif + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int libconfig_yylex_destroy (yyscan_t yyscanner ); + +int libconfig_yyget_debug (yyscan_t yyscanner ); + +void libconfig_yyset_debug (int debug_flag ,yyscan_t yyscanner ); + +YY_EXTRA_TYPE libconfig_yyget_extra (yyscan_t yyscanner ); + +void libconfig_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner ); + +FILE *libconfig_yyget_in (yyscan_t yyscanner ); + +void libconfig_yyset_in (FILE * in_str ,yyscan_t yyscanner ); + +FILE *libconfig_yyget_out (yyscan_t yyscanner ); + +void libconfig_yyset_out (FILE * out_str ,yyscan_t yyscanner ); + +int libconfig_yyget_leng (yyscan_t yyscanner ); + +char *libconfig_yyget_text (yyscan_t yyscanner ); + +int libconfig_yyget_lineno (yyscan_t yyscanner ); + +void libconfig_yyset_lineno (int line_number ,yyscan_t yyscanner ); + +YYSTYPE * libconfig_yyget_lval (yyscan_t yyscanner ); + +void libconfig_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int libconfig_yywrap (yyscan_t yyscanner ); +#else +extern int libconfig_yywrap (yyscan_t yyscanner ); +#endif +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner); +#endif + +#ifndef YY_NO_INPUT + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern 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 */ + +#undef YY_NEW_FILE +#undef YY_FLUSH_BUFFER +#undef yy_set_bol +#undef yy_new_buffer +#undef yy_set_interactive +#undef YY_DO_BEFORE_ACTION + +#ifdef YY_DECL_IS_OURS +#undef YY_DECL_IS_OURS +#undef YY_DECL +#endif + +#line 130 "scanner.l" + +#line 325 "scanner.h" +#undef libconfig_yyIN_HEADER +#endif /* libconfig_yyHEADER_H */ diff --git a/3rdparty/libconfig/strbuf.c b/3rdparty/libconfig/strbuf.c new file mode 100644 index 000000000..d2a667a7c --- /dev/null +++ b/3rdparty/libconfig/strbuf.c @@ -0,0 +1,57 @@ +/* ---------------------------------------------------------------------------- + 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 General Public License as published by + the Free Software Foundation, either version 3 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#include "strbuf.h" + +#include +#include + +#define STRING_BLOCK_SIZE 64 + +/* ------------------------------------------------------------------------- */ + +char *strbuf_release(strbuf_t *buf) +{ + char *r = buf->string; + memset(buf, 0, sizeof(strbuf_t)); + return(r); +} + +/* ------------------------------------------------------------------------- */ + +void strbuf_append(strbuf_t *buf, const char *text) +{ + static const size_t mask = ~(STRING_BLOCK_SIZE - 1); + size_t len = strlen(text); + size_t newlen = buf->length + len + 1; /* add 1 for NUL */ + + if(newlen > buf->capacity) + { + buf->capacity = (newlen + (STRING_BLOCK_SIZE - 1)) & mask; + buf->string = (char *)realloc(buf->string, buf->capacity); + } + + strcpy(buf->string + buf->length, text); + buf->length += len; +} + +/* ------------------------------------------------------------------------- */ +/* eof */ diff --git a/3rdparty/libconfig/strbuf.h b/3rdparty/libconfig/strbuf.h new file mode 100644 index 000000000..90afd44c8 --- /dev/null +++ b/3rdparty/libconfig/strbuf.h @@ -0,0 +1,39 @@ +/* ---------------------------------------------------------------------------- + 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 General Public License as published by + the Free Software Foundation, either version 3 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#ifndef __libconfig_strbuf_h +#define __libconfig_strbuf_h + +#include +#include + +typedef struct +{ + char *string; + size_t length; + size_t capacity; +} strbuf_t; + +char *strbuf_release(strbuf_t *buf); + +void strbuf_append(strbuf_t *buf, const char *text); + +#endif /* __libconfig_strbuf_h */ diff --git a/3rdparty/libconfig/wincompat.h b/3rdparty/libconfig/wincompat.h new file mode 100644 index 000000000..cfea2ec33 --- /dev/null +++ b/3rdparty/libconfig/wincompat.h @@ -0,0 +1,89 @@ +/* ---------------------------------------------------------------------------- + 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 General Public License as published by + the Free Software Foundation, either version 3 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this library. If not, see . + ---------------------------------------------------------------------------- +*/ + +#ifndef __wincompat_h +#define __wincompat_h + +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) + +#ifdef _MSC_VER +#pragma warning (disable: 4996) +#endif + +#define WIN32_LEAN_AND_MEAN +#include + +#define snprintf _snprintf + +#ifndef __MINGW32__ +#define atoll _atoi64 +#define strtoull _strtoui64 +#endif /* __MINGW32__ */ + +#endif + +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \ + || defined(__MINGW32__)) + +/* Why does gcc on MinGW use the Visual C++ style format directives + * for 64-bit integers? Inquiring minds want to know.... + */ + +#define INT64_FMT "%I64d" +#define UINT64_FMT "%I64u" + +#define INT64_HEX_FMT "%I64X" + +#define FILE_SEPARATOR "\\" + +#else /* defined(WIN32) || defined(__MINGW32__) */ + +#define INT64_FMT "%lld" +#define UINT64_FMT "%llu" + +#define INT64_HEX_FMT "%llX" + +#define FILE_SEPARATOR "/" + +#endif /* defined(WIN32) || defined(__MINGW32__) */ + +#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \ + && ! defined(__MINGW32__) + +#define INT64_CONST(I) (I ## i64) +#define UINT64_CONST(I) (I ## Ui64) + +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif + +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif + +#else /* defined(WIN32) && ! defined(__MINGW32__) */ + +#define INT64_CONST(I) (I ## LL) +#define UINT64_CONST(I) (I ## ULL) + +#endif /* defined(WIN32) && ! defined(__MINGW32__) */ + +#endif /* __wincompat_h */ diff --git a/Makefile.in b/Makefile.in index 02ca9b987..6fd5fff26 100644 --- a/Makefile.in +++ b/Makefile.in @@ -4,10 +4,10 @@ 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 - COMMON_SQL_DEPENDS=mt19937ar - LOGIN_SQL_DEPENDS=mt19937ar common_sql - CHAR_SQL_DEPENDS=mt19937ar common_sql - MAP_SQL_DEPENDS=mt19937ar common_sql + 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 CONVERTERS_DEPENDS=common_sql else ALL_DEPENDS=needs_mysql @@ -47,6 +47,9 @@ common_sql: $(COMMON_SQL_DEPENDS) mt19937ar: @$(MAKE) -C 3rdparty/mt19937ar +libconfig: + @$(MAKE) -C 3rdparty/libconfig + login_sql: $(LOGIN_SQL_DEPENDS) @$(MAKE) -C src/login sql @@ -74,6 +77,7 @@ import: clean: @$(MAKE) -C src/common $@ @$(MAKE) -C 3rdparty/mt19937ar $@ + @$(MAKE) -C 3rdparty/libconfig $@ @$(MAKE) -C src/login $@ @$(MAKE) -C src/char $@ @$(MAKE) -C src/map $@ @@ -85,6 +89,7 @@ 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)" diff --git a/conf/atcommand_athena.conf b/conf/atcommand_athena.conf index ce06e2b37..58813c1c7 100644 --- a/conf/atcommand_athena.conf +++ b/conf/atcommand_athena.conf @@ -1,753 +1,60 @@ -サソ//-------------------------------------------------------------- -// rAthena atcommand/charcommand Configuration File -//-------------------------------------------------------------- - -// The symbol that will be used to recognize commands. -// You can set any one character except control-characters (0x00-0x1f), -// '%', '$' (party/guild chat speaking) and '/' (standard client commands). -// command_symbol represents @commands used locally -// char_symbol represents #commands used on other players. -command_symbol:@ -char_symbol:# - -// The following settings in this file use the format ": level(@),level(#)". -// They define the minimum GM level required to execute the associated command. -// @ = atcommand. most work only on yourself. -// # = charcommand. remote usage only. GMs will be able to use these on other players. -// Adjust values as you like. Note that to activate commands for normal players, -// (GM level 0), you also need to change the 'atcommand_gm_only' option to 'no'. -// To completely disable a command, set its required GM level to 100. - -// Default levels were chosen so that they form the following hierarchy: -// 0: Normal player -// -> no commands accessible -// 1: Super player -// -> some minor advantage: storage, petrename, etc... -// 10: Super player+ -// -> more powerful commands, like mobsearch and changegm -// 20: Mediator -// -> GM commands for finding players and moving to them (also kicking them) -// 40: Sub-GM -// -> GM commands for basic tasks, no significant impact on other players -// 50: Sub-GM+ -// -> GM commands to spawn mobs and create guilds -// 60: GM -// -> almost all commands available (except administration and mass commands) -// 80: GM Chief -// -> can do anything, except administration commands -// 99: Administrator -// -> can do anything! -// 100: Disabled -// -> commands that will not be available to anyone - -// Syntax of file: -// command: @level,#level [] - -// Syntax Example: -// command: 40,40 [alias,alias2,alias3,alias4] -// If it has more than 4 aliases you can keep adding, just like in the example below: - -// Example: -// blvl: 60,60 [lvup,blevel,baselvl,baselvup,baselevel,baselvlup] - -//-------------------------- -// 0: normal player commands -// None for security purposes. - -//------------------------- -// 1: Super player commands - -// Displays a list of @ commands available to the player. -commands: 1,1 - -// Displays a list of # commands available to the player. -charcommands: 1,1 - -// Displays the server rates. -rates: 1,1 - -// Show server uptime since last map server restart -uptime: 1,1 - -// Shows/Hides the "there is a delay after a skill" message. -showdelay: 1,1 - -// Displays current levels and % progress. -exp: 1,40 - -// To change your (own) email -// note: this command doesn't check email itself, but check structure of the email (xxx@xxx) -// if you want be sure of each e-mail disable this option (value: 100) -email: 1,60 - -// Show Monster info (rates, stats, drops, MVP stuff) -monsterinfo: 1,1 [mobinfo, mi] - -// Show Item info (type, price, etc) -iteminfo: 1,1 [ii] - -// Show who drops an item (mobs with highest drop rate) -whodrops: 1,1 - -// Syncs the player's position on the client with the one stored on the server. -refresh: 1,40 - -// Give server time. (4 same commands) -time: 1,1 [date,serverdate,servertime] - -// Displays SVN version of the server. -version: 1,1 - -// Suicide your character. -die: 1,1 - -// Enables you to rename your pet. -petrename: 1,50 - -// Organize a new party, with you as the party leader -party: 1,1 - -// Opens your Kafra storage wherever you are -storage: 1,1 - -// Opens your mailbox -mail: 1,1 - -// Opens auctions window -auction: 1,1 - -// Locate someone on a map, returns your coordinates if the person isn't on. -where: 1,1 - -// Duel organizing commands -duel: 1,1 -invite: 1,1 -accept: 1,1 -reject: 1,1 -leave: 1,1 - -// Main chat -main: 1,1 - -// Autorejecting Deals/Invites -noask: 1,1 - -// Displays remaining jail time -jailtime: 1,40 - -// Homunculus commands for players -hominfo: 1,40 -homstats: 1,40 - -// Kill Steal Protection -noks: 1,1 - -// Set Font -font: 1,1 - -//--------------------------- -// 10: Super player+ commands - -// Displays/Hides Experience gained messages -showexp: 10,10 - -// Displays/Hides Zeny gained messages -showzeny: 10,10 - -// Warps you to predefined locations in major cities. -go: 10,10 - -// Enables/disables autolooting from killed mobs. -autoloot: 10,10 - -// Enables/disables autolooting an item. -alootid: 10,10 - -// Allows you continue vending offline. -autotrade: 10,10 [at] - -// Change Guild Master of your Guild -changegm: 10,10 - -// Change the leader of your party. -changeleader: 10,10 - -// Change the party exp- and item share rules. -partyoption: 10,10 - -// Command what the player's pet will say. -pettalk: 10,10 - -// Command what the player's homunculus will say. -homtalk: 10,10 - -// Locates and displays the position of a certain mob on the current map. -mobsearch: 10,10 -// Locates and displays the position of a certain mob on your mini-map -showmobs: 10,10 -// Prints out in which maps a monster normally spawns at (does not count script-invoked mobs) -whereis: 10,10 - -// Resets a Star Gladiator's marked maps -feelreset: 10,60 - -//---------------------- -// 20: Mediator commands - -// Displays helpfile in rAthena base directory (2 same commands). -help: 20,20 [h] -help2: 20,20 [h2] - -// Warp yourself to a person (3 same commands + /shift). -goto: 20,20 [jumpto,warpto] - -// Displays the motd file to all players -gmotd: 20,20 - -// Follow a player (including warping to them) -follow: 20,20 - -// Sends a request to all connected GMs (via the gm whisper system) -request: 20,100 - -// Disconnects a user from the server (1 command + right click menu for GM "(name) force to quit"). -kick: 20,20 - -// Changes your appearance. -model: 20,50 - -// To get a peco to (un)ride (2 same commands). -mount: 20,50 [mountpeco] - -// Returns list of logged in characters with their position (2 same commands). -who: 20,20 [whois] - -// Returns list of logged in characters with their job. -who2: 20,20 - -// Returns list of logged in characters with their party/guild. -who3: 20,20 - -// Returns list of logged in characters with their position in a specifical map. -whomap: 20,20 - -// Returns list of logged in characters with their job in a specifical map. -whomap2: 20,20 - -// Returns list of logged in characters with their party/guild in a specifical map. -whomap3: 20,20 - -// Displays GMs online. For those who are higher GM level than yourself, -// only the name is shown, for the rest, it displays the same info of -// @who+@who2+who3 -whogm: 20,20 - -// Change your appearence to other players to a mob. -disguise: 20,60 - -// Restore your normal appearance. -undisguise: 20,20 - -// Displays the text as a normal message with the format "*name message*" -// instead of "name : message" (Like the /me command in IRC) -me: 20,20 - -// Changes your name to your choice temporarily. -fakename: 20,50 - -// Changes your size. -size: 20,50 - -// Can command what other npcs (by name) can say. -npctalk: 20,100 [npctalkc] - -//-------------------- -// 40: Sub-GM commands - -// Broadcast to the whole server. Using (1 command + /nb, /b). -broadcast: 40,40 - -// Broadcast to the map you are on (1 command + /lb, /nlb). -localbroadcast: 40,40 - -// Broadcast (with or without name) -kami: 40,40 -// Same as kami but with blue color -kamib: 40,40 -// Same as kami but you can choose the color (uses different packet) -kamic: 40,40 - -// Enables GvG on a map (2 same commands). -gvgon: 40,100 [gpvpon] - -// Turns GvG (Guild vs. Guild) off on a map (2 same commands). -gvgoff: 40,100 [gpvpoff] - -// Activate/Deactivate kill steal protection on a map -allowks: 40,100 - -// Modifies your HP/SP. -heal: 40,60 - -// GM Hide (total invisibility to characters and monsters) (1 command + /hide). -hide: 40,60 - -// Changes your job to one you specify (2 same commands). -job: 40,60 [jobchange] - -// Enables you to to jump randomly on a map (that you are already on). -jump: 40,40 - -// Warps you to your last save point (2 same commands). -load: 40,60 [return] - -// Warps you to a specific npc -tonpc: 40,40 - -// Saves a warp point. -memo: 40,40 - -// Set your character display options. (Visual effects of your character) -option: 40,60 - -// Sets the level of intemecy of your pet. -petfriendly: 40,50 - -// Sets hunger level of your pet. -pethungry: 40,50 - -// Turns PvP (Person vs. Person) off on a map. -pvpoff: 40,100 - -// Enables PvP on a map. -pvpon: 40,100 - -// Permanently adds a quest skill -questskill: 40,60 - -// Permanently removes a quest skill -lostskill: 40,60 - -// Sets the speed you can walk/attack at. Default is 150. -speed: 40,60 - -// Summons spirit spheres around you. -spiritball: 40,60 - -// Warp yourself to a certain map, at (x,y) coordinates (2 same commands) + also /mm or /mapmove. -warp: 40,60 [rura,mapmove] - -// Changes GM clothes color (2 same commands) -dye: 40,50 [ccolor] - -// Changes GM hair style (2 same commands) -hairstyle: 40,40 [hstyle] - -// Changes GM hair color (2 same commands) -haircolor: 40,50 [hcolor] - -// Deletes all your items. -itemreset: 40,60 - -// Does a skill/stat reset. -reset: 40,60 - -// Displays distribution of players on the server per map (% on each map which has players) -users: 40,40 - -// Deletes floor items in your range of sight -cleanmap: 40,40 - -// Kill all monsters in map (without drops) -killmonster2: 40,40 - -// Sets your spawn point (aka save point). -save: 40,60 - -// Do some visual effect on your character -effect: 40,40 - -// Do some visual effect on your character (misceffect) -misceffect: 40,40 - -// GM's magnifier -identify: 40,40 - -// Drop all your items -dropall: 40,60 - -// Store all your items -storeall: 40,60 - -// Allow other players to hit you out of PvP -killable: 40,60 - -// Look up a skill by name -skillid: 40,40 - -// Use a skill by id -useskill: 40,40 - -// What skills are required to get this skill -skilltree: 40,40 - -// Marriage commands -marry: 40,40 -divorce: 40,40 - -// Adopt a novice into a family -adopt: 40,40 - -// Play a Sound! -sound: 40,40 - -// Displays a player's storage -storagelist: 40,40 - -// Displays a player's cart contents -cartlist: 40,40 - -// Displays a player's items -itemlist: 40,40 - -// Displays a player's stats -stats: 40,40 - -//--------------------- -// 50: Sub-GM+ commands - -// Creates a new guild, with you as the guildmaster. -guild: 50,50 - -// Brings up your guild storage wherever you are. -gstorage: 50,60 - -// Spawns a monster, and a certain amount (2 same commands + /monster). -monster: 50,50 [spawn] - -// Spawns a smaller sized version of a monster. -monstersmall: 50,50 - -// Spawns a larger sized version of a monster. -monsterbig: 50,50 - -// Spawns mobs that treat you as their master (they disappear after some time) -summon: 50,50 - -// It will spawn a supportive clone of the given player. -clone: 50,50 - -// It will spawn a supportive clone of the given player that follows the creator around. -slaveclone: 50,50 - -// It will spawn an aggresive clone of the given player. -evilclone: 50,50 - -//---------------- -// 60: GM commands - -// Add or Remove Cash Points to/from yourself -cash: 60,60 - -// Add or Remove Kafra Points to/from yourself -points: 60,60 - -// Starts Guild Wars -agitstart: 60,100 - -// Ends Guild Wars -agitend: 60,100 - -// Resurects yourself. -alive: 60,60 - -// Raises your base level by specified amount (7 same commands). -blvl: 60,60 [lvup,blevel,baselvl,baselvup,baselevel,baselvlup] - -// Raises your job level by specified amount (6 same commands). -jlvl: 60,60 [jlevel,joblvl,joblvup,joblevel,joblvlup] - -// Changes the sex of yourself -changesex: 60,60 - -// Raises your guild level by specified amount (6 same commands). -glvl: 60,60 [glevel,guildlvl,guildlvup,guildlevel,guildlvlup] - -// Find an itemID based on item name -idsearch: 60,60 - -// Creates an item of your choosing, either Item ID or Name (1 command + /item). -item: 60,60 - -// Creates a complet item (card, etc...) of your choosing, either Item ID or Name. -item2: 60,60 - -// Deletes an item of your choosing, either Item ID or Name. -delitem: 60,60 - -// Kill another character without hitting them. -kill: 60,60 - -// Kill all monsters in map (with drops) -killmonster: 60,60 - -// Creates yourself a pet egg. -makeegg: 60,60 - -// Hatches an egg -hatch: 60,60 - -// Instantly kills player whose name is entered and deals insane damage to everything around -nuke: 60,60 - -// Enable hitting a player even when not in PvP -killer: 60,60 - -// Creates weapon of desired element. -produce: 60,60 - -// Warps a character to you (1 command + /recall). -recall: 60,60 - -// Refines all weapons in your items list. -refine: 60,80 - -// Will repair all broken items in inventory. -repairall: 60,60 - -// Change Status of your character -str: 60,60 -agi: 60,60 -vit: 60,60 -int: 60,60 -dex: 60,60 -luk: 60,60 - -// Gives all skills -allskill: 60,60 [allskills,skillall,skillsall] - -// Sets GM stats to maximum -allstats: 60,60 [allstat,statall,statsall] - -// Gives you stat points. -stpoint: 60,60 - -// Gives you skill points of desired amount. -skpoint: 60,60 - -// Warps all online character of a guild to you. (at least one member of that guild must be on.) -guildrecall: 60,60 - -// Warps all online character of a party to you. -// (at least one party member must be online.) -partyrecall: 60,60 - -// Allows you to spy on any Guilds Guild chat. -// (at least one member of that guild must be on.) -// NOTE: map server needs to be configured to enable spying to use this command (enable_spy: yes) -guildspy: 60,60 - -// Allows you to spy on any party's party chat. -// (at least one party member must be online.) -// NOTE: map server needs to be configured to enable spying to use this command (enable_spy: yes) -partyspy: 60,60 - -// Gives you zeny (or subtracts, if amount is negative) -zeny: 60,80 - -// Block a player indefinitely -block: 60,100 [charblock] - -// Unblock a player -unblock: 60,100 [charunblock] - -// Ban a player for a limited time -ban: 60,100 [banish,charban,charbanish] - -// Unban a player -unban: 60,100 [unbanish,charunban,charunbanish] - -// To send specified character in jails -jail: 60,100 - -// To discharge a jailed character (2 same commands) -unjail: 60,100 [discharge] - -// Timed jailing -jailfor: 60,60 - -// Create a static warp portal that lasts until the next reboot -addwarp: 60,60 - -// Open a trade window with any player -trade: 60,60 - -// Changes the player's appearance (headgear) -changelook: 60,60 - -// Homunculus commands for GMs -hlvl: 60,60 [homlevel,hlevel,homlvl,homlvup] -homevolve: 60,60 [homevolution] -makehomun: 60,60 -homfriendly: 60,60 -homhungry: 60,60 -// Re-calculates stats, as if the homun was sent back to level 1 and re-leveled -homshuffle: 60,60 - -// WoE 2 start/stop commands -agitstart2: 60,100 -agitend2: 60,100 - -// Resets player stats -streset: 60,60 - -// Resets player skills -skreset: 60,60 - -//---------------------- -// 80: GM Chief commands - -// Set the server to day. -day: 80,100 - -// Set the server to night. -night: 80,100 - -// Kills everyone on the server. -doom: 80,100 - -// Kills everyone on the map you are on. -doommap: 80,80 - -// Recalls Everyone To Your Coordinates -recallall: 80,80 - -// Revives all players on the map. -raisemap: 80,80 - -// Revives all players on the server. -raise: 80,100 - -// Hides a NPC. -hidenpc: 80,100 - -// Unhides a NPC. -shownpc: 80,100 - -// Loads an NPC script by path -loadnpc: 80,100 - -// Unloads a NPC -unloadnpc: 80,100 - -// Move a NPC -npcmove: 80,100 - -// turn skills on for a map -skillon: 80,100 - -// turn skills off for a map -skilloff: 80,100 - -// Mute a player (prevents talking, usage of skills and commands) -mute: 80,100 - -// Unmute a player -unmute: 80,100 - -//--------------------------- -// 99: Administrator commands - -// Disconnect all users from the server -kickall: 99,100 - -// Closes Map-Server -mapexit: 99,100 - -// Used for testing packet sends from the client (debug function) -send: 99,100 - -// Give information about terrain/area (debug function) -gat: 99,100 - -// Displays a status change without really applying it (debug function) -displaystatus: 99,100 - -// Displays the animation of a skill without really using it (debug function) -displayskill: 99,100 - -// Shows information about the map -mapinfo: 99,100 - -// Set Map Flags -mapflag: 99,100 - -// Re-load item database (admin command) -reloaditemdb: 99,100 - -// Re-load monsters database (admin command) -reloadmobdb: 99,100 - -// Re-load skills database (admin command) -reloadskilldb: 99,100 - -// Re-load scripts (admin command) -reloadscript: 99,100 - -// Change a battle_config flag without rebooting server -setbattleflag: 99,100 - -// Re-load gm command config (admin command) -reloadatcommand: 99,100 - -// Re-load battle config (admin command) -// Note that some player config settings won't take effect until relog -// (display exp, display zeny, display skill delay fail, ...) -reloadbattleconf: 99,100 - -// Re-load status database (admin command) -reloadstatusdb: 99,100 - -// Re-load player info database (admin command) -reloadpcdb: 99,100 - -// Re-load the Message of the Day (admin command) -reloadmotd: 99,100 - -// Changes the GM level of another character -// (lasts until reboot, or gm list reload) -adjgmlvl: 99,100 - -// Changes the required GM level of an @ command -// (effect lasts until restart or command reload) -adjcmdlvl: 99,100 - -// [Un]Disguise All Players (admin command) -disguiseall: 99,100 -undisguiseall: 99,100 - -// Mutes every player on screen (admin command) -mutearea: 99,100 [stfu] - -// Makes you immune to attacks (monsters/players/skills cannot target/hit you, admin command) -battleignore: 99,100 [monsterignore] - -//--------------------------------------------------------------- -// 99: Weather effects -snow: 99,100 -clouds: 99,100 -clouds2: 99,100 -fog: 99,100 -fireworks: 99,100 -sakura: 99,100 -leaves: 99,100 - -// Stop all weather effects -clearweather: 99,100 - -//--------------------------------------------------------------- -// 100: Disabled commands - -//--------------------- -// OTHER: not a command -import:conf/import/atcommand_conf.txt \ No newline at end of file +/* Atcommands and charcommands configuration file */ + +/* The symbol that will be used to recognize commands. +You can set any one character except: + - control-characters (0x00-0x1f), + - '%' (party chat symbol) + - '$' (guild chat symbol) + - '/' (client commands symbol) +atcommand_symbol represents @commands used locally. +charcommand_symbol represents #commands used on other players. +*/ + +atcommand_symbol : "@" +charcommand_symbol: "#" + +/* Command aliases +You can define aliases for any command. Aliases work just like original +command. +Format is + : ["", ...] +*/ + +aliases: { + mobinfo: ["monsterinfo", "mi"] + iteminfo: ["ii"] + time: ["date", "serverdate", "servertime"] + autotrade: ["at"] + help: ["h"] + jumpto: ["goto", "warpto"] + mount: ["mountpeco"] + who: ["whois"] + npctalk: ["npctalkc"] + gvgon: ["gpvpon"] + gvgoff: ["gpvpoff"] + jobchange: ["job"] + load: ["return"] + warp: ["rura", "mapmove"] + dye: ["ccolor"] + hairstyle: ["hstyle"] + haircolor: ["hcolor"] + monster: ["spawn"] + blvl: ["lvup", "blevel", "baselvl", "baselvup", "baselevel", "baselvlup"] + jlvl: ["jlevel", "joblvl", "joblvup", "joblevel", "joblvlup"] + glvl: ["glevel", "guildlvl", "guildlvup", "guildlevel", "guildlvlup"] + allskill: ["allskills", "skillall", "skillsall"] + allstats: ["allstat", "statall", "statsall"] + ban: ["banish"] + unban: ["unbanish"] + unjail: ["discharge"] + homlevel: ["hlvl", "hlevel", "homlvl", "homlvup"] + homevolution: ["homevolve"] + mutearea: ["stfu"] + monsterignore: ["battleignore"] + raise: ["revive"] +} + +/* Commands help file */ +help: { + @include "conf/help.txt" +} \ No newline at end of file diff --git a/conf/battle/gm.conf b/conf/battle/gm.conf index b7dc81909..fe07a6fc4 100644 --- a/conf/battle/gm.conf +++ b/conf/battle/gm.conf @@ -18,97 +18,10 @@ atcommand_slave_clone_limit: 25 // current map server. partial_name_scan: yes -// The level at which a player with access is considered a GM. -// An account with an access level lower than this is not effected -// by gm_can_drop_lv (battle_athena.conf). -lowest_gm_level: 1 - -// [GM] Can use all skills? (No or mimimum GM level) -gm_all_skill: no - -// [GM] Can equip anything? (No or minimum GM level, can cause client errors.) -gm_all_equipment: no - -// [GM] Can use skills without meeting the required conditions (items, etc...)? -// 'no' or minimum GM level to bypass requirements. -gm_skill_unconditional: no - -// [GM] Can join a password protected chat? (No or mimimum GM level) -gm_join_chat: no - -// [GM] Can't be kicked from a chat? (No or mimimum GM level) -gm_kick_chat: no - -// (@) GM Commands available only to GM's? (Note 1) -// set to 'No', Normal players (gm level 0) can use GM commands _IF_ you set the command level to 0. -// set to 'Yes', Normal players (gm level 0) can never use a GM command even if you set the command level to 0. -atcommand_gm_only: no - // (@) @allstats/@str/@agi/@vit/@int/@dex/@luk // allow gms to bypass the maximum stat parameter? ( if yes gm stats can go up to 32k ) default: no atcommand_max_stat_bypass: no -// Is the character of a GM account set as the object of a display by @ command etc. or not? -hide_GM_session: no - -// At what GM level can you see GMs and Account/Char IDs in the @who command? -who_display_aid: 40 - // Ban people that try trade dupe. // Duration of the ban, in minutes (default: 5). To disable the ban, set 0. ban_hack_trade: 5 - -// Set here minimum level of a (online) GM that can receive all informations about any player that try to hack, spoof a name, etc. -// Values are from 0 to 100. -// 100: disable information -// 0: send to any people, including normal players -// default: 60, according to GM definition in atcommand_athena.conf -hack_info_GM_level: 60 - -// The minimum GM level to bypass nowarp and nowarpto mapflags. -// This option is mainly used in commands which modify a character's -// map/coordinates (like @memo, @warp, @charwarp, @go, @jump, etc...). -// default: 20 (first level after normal player or super'normal' player) -any_warp_GM_min_level: 20 - -// The minimum level for a GM to be unable to distribute items. -// You should set this to the same level @item is set to in the atcommand.conf -// NEVER SET THIS VALUE TO 0, or you will block drop/trade for normal players -gm_cant_drop_min_lv: 1 - -//The trust level for your GMs. Any GMs ABOVE this level will be able to distribute items -//ie: Use Storage/Guild Storage, Drop Items, Use Vend, Trade items. -gm_cant_drop_max_lv: 0 - -// Minimum GM level to see the hp of every player? (Default: 60) -// no/0 can be used to disable it. -disp_hpmeter: 0 - -// Minimum GM level to view players equip regardless of their setting. -// (Default: 0 = Disabled). -gm_viewequip_min_lv: 0 - -// Can GMs invite non GMs to a party? (Note 1) -// set to 'No', GMs under the party invite trust level may not invite non GMs to a party. -// set to 'Yes', All GMs can invite any player to a party. -// Also, as long as this is off, players cannot invite GMs to a party as well. -gm_can_party: no - -//The trust level for GMs to invite to a party. Any GMs ABOVE OR EQUAL TO this level will be able to invite normal -//players into their party in addittion to other GMs. (regardless of gm_can_party) -gm_cant_party_min_lv: 20 - -// Players Titles (check msg_athena.conf for title strings) -// You may assign different titles for your Players and GMs -title_lvl1: 1 -title_lvl2: 10 -title_lvl3: 20 -title_lvl4: 40 -title_lvl5: 50 -title_lvl6: 60 -title_lvl7: 80 -title_lvl8: 99 - -// Minimum GM level required for client command /check (display character status) to work. -// Default: 60 -gm_check_minlevel: 60 diff --git a/conf/char_athena.conf b/conf/char_athena.conf index bc9e1ab1c..1b5e96a16 100644 --- a/conf/char_athena.conf +++ b/conf/char_athena.conf @@ -93,8 +93,10 @@ char_new_display: 0 // Maximum users able to connect to the server. Set to 0 for unlimited. max_connect_user: 0 -// Minimum GM level that is allowed to bypass the server limit of users. -gm_allow_level: 99 +// Group ID that is allowed to bypass the server limit of users. +// Default: -1 = nobody (there are no groups with ID < 0) +// See: conf/groups.conf +gm_allow_group: -1 // How often should the server save all files? (In seconds) // Note: Applies to all data files on TXT servers. diff --git a/conf/groups.conf b/conf/groups.conf new file mode 100644 index 000000000..d93d2aa09 --- /dev/null +++ b/conf/groups.conf @@ -0,0 +1,274 @@ +/* + +Player groups configuration file +--------------------------------- + +This file defines "player groups" and their privileges. + +Each group has its id and name, lists of available commands and other +permissions, and a list of other groups it inherits from. + + +Group settings +-------------- + +Unique group number. The only required field. + + +Any string. If empty, defaults to "Group ". It is used in several @who +commands. + + +Equivalent of GM level, which was used in revisions before r xxxxx. You can +set it to any number, but usually it's between 0 (default) and 99. Members of +groups with lower level can not perform some actions/commands (like @kick) on +members of groups with higher level. It is what script command getgmlevel() +returns. Group level can also be used to override trade restrictions +(db/item_trade.txt). + + +A group of settings + : +or + : [ , ] +First boolean value is for atcommand, second one for charcommand. If set to +true, group can use command. If only atcommand value is provided, false is +assumed for charcommand. If a command name is not included, false is assumed for +both atcommand and charcommand. +For a full list of available commands, see: doc/atcommands.txt. +Command names must not be aliases. + + +Boolean value. If true then all commands used by the group will be logged to +atcommandlog. If setting is omitted in a group definition, false is assumed. +Requires 'log_commands' to be enabled in 'conf/log_athena.conf'. + + +A group of settings + : +If a permission is not included, false is assumed. +For a full list of available permissions, see: doc/permissions.txt + + +A list of group names that given group will inherit commands and permissions +from. Group names are case-sensitive. + +Inheritance results +------------------- +Both multiple inheritance (Group 2 -> Group 1 and Group 3 -> Group 1) and +recursive inheritance (Group 3 -> Group 2 -> Group 1) are allowed. + +Inheritance rules should not create cycles (eg Group 1 inherits from Group 2, +and Group inherits from Group 1 at the same time). Configuration with cycles is +considered faulty and can't be processed fully by server. + +Command or permission is inherited ONLY if it's not already defined for the +group. +If group inherits from multiple groups, and the same command or permission is +defined for more than one of these groups, it's undefined which one will be +inherited. + +Syntax +------ +This config file uses libconfig syntax: +http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-Files + + +Upgrading from revisions before XXXXX +------------------------------------- + +*/ + +groups: ( +{ + id: 0 /* group 0 is the default group for every new account */ + name: "Player" + level: 0 + inherit: ( /*empty list*/ ) + commands: { + /* no commands by default */ + } + permissions: { + /* without this basic permissions regular players could not + trade or party */ + can_trade: true + can_party: true + } +}, +{ + id: 1 + name: "Super Player" + inherit: ( "Player" ) /* can do everything Players can and more */ + level: 0 + commands: { + /* informational commands */ + commands: true + charcommands: true + help: true + rates: true + uptime: true + showdelay: true + exp: true + mobinfo: true + iteminfo: true + whodrops: true + time: true + jailtime: true + hominfo: true + homstats: true + showexp: true + showzeny: true + whereis: true + /* feature commands */ + refresh: true + noask: true + noks: true + main: true + autoloot: true + alootid: true + autotrade: true + request: true + go: true + } + permissions: { + } +}, +{ + id: 2 + name: "Support" + inherit: ( "Super Player" ) + level: 1 + commands: { + version: true + where: true + jumpto: true + who: true + who2: true + who3: true + whomap: true + whomap2: true + whomap3: true + users: true + broadcast: true + localbroadcast: true + } + log_commands: true + permissions: { + receive_requests: true + view_equipment: true + } +}, +{ + id: 3 + name: "Script Manager" + inherit: ( "Support" ) + level: 1 + commands: { + tonpc: true + hidenpc: true + shownpc: true + loadnpc: true + unloadnpc: true + npcmove: true + addwarp: true + } + log_commands: true + permissions: { + any_warp: true + } +}, +{ + id: 4 + name: "Event Manager" + inherit: ( "Support" ) + level: 1 + commands: { + monster: true + monstersmall: true + monsterbig: true + killmonster2: true + cleanmap: true + item: [true, true] + zeny: [true, true] + disguise: [true, true] + undisguise: [true, true] + size: [true, true] + raise: true + raisemap: true + day: true + night: true + skillon: true + skilloff: true + pvpon: true + pvpoff: true + gvgon: true + gvgoff: true + allowks: true + me: true + marry: true + divorce: true + } + log_commands: true + permissions: { + can_trade: false + any_warp: true + } +}, +{ + id: 10 + name: "Law Enforcement" + inherit: ( "Support" ) + level: 2 + commands: { + hide: true + follow: true + kick: true + disguise: true + fakename: true + option: true + speed: true + warp: true + kill: true + recall: true + ban: true + block: true + jail: true + jailfor: true + mute: true + storagelist: true + cartlist: true + itemlist: true + stats: true + } + log_commands: true + permissions: { + join_chat: true + kick_chat: true + hide_session: true + who_display_aid: true + hack_info: true + any_warp: true + view_hpmeter: true + } +}, +{ + id: 99 + name: "Admin" + level: 99 + inherit: ( "Support", "Law Enforcement" ) + commands: { + } + log_commands: true + permissions: { + can_trade: true + can_party: true + all_skill: true + all_equipment: true + skill_unconditional: true + use_check: true + use_changemaptype: true + all_commands: true + } +} +) + diff --git a/conf/help.txt b/conf/help.txt index 13a958798..5a8f5871f 100644 --- a/conf/help.txt +++ b/conf/help.txt @@ -1,172 +1,230 @@ -// put at first, the minimum level to display the line - 1:To use one command, type it inside the message window where you usually type to chat. - 20:@h/@help - display this help guide. - 20:@h2/@help2 - displays the second help guide. - 1: - 1:--- MESSAGE CMD --- - 1:@main [on|off|message] - Turns on or off global chat (@main must be on to see global chat messages) - 1:@noask - Auto rejects Deals/Invites - 20:@gmotd - Broadcasts the Message of The Day file to all players. - 20:@me - Displays normal text as a message in this format: *name message* (like /me in mIRC) - 20:@fakename [Name] - Changes your name to your choice temporarly. - 20:@npctalk [NPC Name],[Message] - Forces a NPC to display a message in normal chat. - 40:/b/@broadcast - Broadcasts a GM message with name of the GM (in yellow) - 40:/nb /@kami - Broadcasts a GM message without name of the GM (in yellow) - 40:@kamib - Broadcasts a GM message without name of the GM (in blue) - 40:/lb/@localbroadcast - Broadcasts a GM message with name of the GM (in yellow) ONLY on your map - 40:/nlb - Broadcasts a GM message without name of the GM (in yellow) ONLY on your map - 1: - 1:--- INFORMATION CMD --- - 1:@commands - Displays a list of commands that you can use. - 1:@rates - Displays the server's current rates. - 1:@uptime - Displays how long the server has been online. - 1:@showdelay - Shows/Hides the "there is a delay after this skill" message. - 1:@exp - Displays current levels and % progress - 1:@mobinfo/@monsterinfo/@mi [Mob ID|Part of monster name] - Shows Monster Info (rates, stats, drops, MVP stuff) - 1:@iteminfo/@ii [Item ID|Part of item name] - Shows Item info (type, price, etc) - 1:@whodrops [Item ID|Part of item name] - Shows who drops an item (mobs with highest drop rates) - 1:@version - Displays SVN version of the server - 1:@email - to change your e-mail (characters protection) - 1:@where [char name] - Tells you the location of a character - 1:@time/@date/@server_date/@serverdate/@server_time/@servertime - Display the date/time of the server - 10:@showexp - Displays/Hides Experience gained. - 10:@showzeny - Displays/Hides Zeny gained. - 10:@mobsearch [Mob ID|Monster Name] - Shows the location of a certain mob on the current map. - 20:@who/@whois/@w [match_text] - Display a listing of who is online and their party/guild. - 20:@who2 [match_text] - Display a listing of who is online and their job. - 20:@who3 [match_text] - Display a listing of who is online and where. - 20:@whomap/@whomap2/@whomap3 [map] - like @who/@who2/@who3 but only for specifical map. - 20:@whogm [match_text] - Like @who+@who2+who3, but only for GM. - 40:@charcartlist - Displays all items of a player's cart. - 60: - 60:@guildspy - You will receive all messages of the guild channel (Chat logging must be enabled) - 60:@partyspy - You will receive all messages of the party channel (Chat logging must be enabled) - 99:@mapinfo [<0-3> [map]] - Give information about a map (general info +: 0: no more, 1: players, 2: NPC, 3: shops/chat). - 1: - 1:--- CHANGE GM STATE CMD --- - 1:@die - Kills yourself - 10:@go - Warps you to a city. - 10: -3: (Memo point 2) 1: morocc 5: izlude 9: yuno 13: niflheim - 10: -2: (Memo point 1) 2: geffen 6: aldebaran 10: amatsu 14: louyang - 10: -1: (Memo point 0) 3: payon 7: xmas (lutie) 11: gonryun 15: start point - 10: 0: prontera 4: alberta 8: comodo 12: umbala 16: prison/jail - 10: - 20:/shift/@jumpto/@warpto/@goto - Warps you to selected character - 20:@follow - follow a player - 20:@mountpeco - Give/remove you a peco (Class is required, but not skill) - 20:@disguise - Change your appearence to other players to a mob. - 20:@undisguise - Restore your normal appearance. - 20:@model - Changes your characters appearence. - 20:@size <1-3> Changes your size (1-Smallest 2-Biggest 3-Normal) - 40:/hide/@hide - Makes you character invisible (GM invisibility). Type /hide or@hide again become visible. - 40:@save - Sets respawn point to current spot - 40:@load/@return - Warps you to your save point - 40:/mm//mapmove/@warp/@rura/@mapmove - Warps you to the selected position - 40:@jump [x [y]]- Randomly warps you like a flywing. - 40:@job/@jobchange - Changes your job - 40: 0: Novice 18: Alchemist 4015: Paladin - 40: 1: Swordman 19: Bard 4016: Champion - 40: 2: Mage 20: Dancer 4017: Professor - 40: 3: Archer 23: Super Novice 4018: Stalker - 40: 4: Acolyte 4001: High Novice 4019: Creator - 40: 5: Merchant 4002: High Swordman 4020: Clown - 40: 6: Thief 4003: High Mage 4021: Gypsy - 40: 7: Knight 4004: High Archer 4046: Taekwon - 40: 8: Priest 4005: High Acolyte 4047: Star Gladiator - 40: 9: Wizard 4006: High Merchant 4049: Soul Linker - 40: 10: Blacksmith 4007: High Thief 24: Gunslinger - 40: 11: Hunter 4008: Lord Knight 25: Ninja - 40: 12: Assassin 4009: High Priest - 40: 14: Crusader 4010: High Wizard - 40: 15: Monk 4011: Whitesmith - 40: 16: Sage 4012: Sniper - 40: 17: Rogue 4013: Assassin Cross - 40: ---- Baby Classes ---- - 40: 4023: Baby 4024: Baby Swordman 4025: Baby Mage - 40: 4026: Baby Archer 4027: Baby Acolyte 4028: Baby Merchant - 40: 4029: Baby Thief 4030: Baby Knight 4031: Baby Priest - 40: 4032: Baby Wizard 4033: Baby Blacksmith 4034: Baby Hunter - 40: 4035: Baby Assassin 4037: Baby Crusader 4038: Baby Monk - 40: 4039: Baby Sage 4040: Baby Rogue 4041: Baby Alchemist - 40: 4042: Baby Bard 4043: Baby Dancer 4045: Super Baby - 40: - 40: (stackable) - 40: 1 Petrified (stackable) 01 Sight 32 Peco Peco riding 2048 Orc Head - 40: 2 Frozen 01 Poison 02 Hide 64 GM Perfect Hide 4096 Wedding Sprites - 40: 3 Stunned 02 Cursed 04 Cloak 128 Level 2 Cart 8192 Ruwach - 40: 4 Sleeping 04 Silenced 08 Level 1 Cart 256 Level 3 Cart - 40: 6 darkness 08 ??? 16 Falcon 512 Level 4 Cart - 40: 16 darkness 1024 Level 5 Cart - 40: - 40:@heal [ ] - Heals the desired amount of HP and SP. No value specified will do a full heal. - 40:@option - Adds different visual effects on or around your character - 40:@dye/@ccolor - Changes your characters appearence (only clothes color). - 40:@hairstyle/@hstyle - Changes your characters appearence (only hair style). - 40:@haircolor/@hcolor - Changes your characters appearence (only hair color). - 40:@speed <1-1000> - Changes you walking speed. 1 being the fastest and 1000 the slowest. Default 150. - 40:@effect [flag] - Give an efect to your character. - 40:@dropall - throws all your possession on the ground - 40:@storeall - puts all your possessions in storage - 40:@killable - make your character killable - 40:@memo [memo_position] - set/change a memo location (no position: display memo points). - 40:@spiritball - Gives you "spirit spheres" like from the skill "Call Spirits" - 40: (If the number you use is > 1000, your server may become instable or crash) - 40:@questskill <#> - Gives you the specified quest skill - 40:@lostskill <#> - Takes away the specified quest skill from you - 40:@skillid - look up a skill by name - 40:@useskill - use a skill on target - 40: Novice Swordsman Thief Merchant - 40: 142 = Emergency Care 144 = Moving HP Recovery 149 = Throw Sand 153 = Cart Revolution - 40: 143 = Act dead 145 = Attack Weak Point 150 = Back Sliding 154 = Change Cart - 40: Archer 146 = Auto Berserk 151 = Take Stone 155 = Crazy Uproar/Loud Voice - 40: 147 = Arrow Creation Acolyte 152 = Stone Throw Magician - 40: 148 = Charge Arrows 156 = Holy Light 157 = Energy Coat - 40: @skilltree < - 40: @marry , - marry two players - 40: @divorce - divorces the two players (you need just one name of them) - 60:@alive - Revives yourself from death - 60:@lvup/@blevel/@baselvlup - Raises your base level the desired number of levels. The max is 255 (User Defined). - 60:@joblvup/@jlevel/@joblvlup -Raises your job level the desired number of levels. The max is 50 For Basic Classes. For Super Novice and Advanced Classes it is 70. - 60:@allskill/@allskills/@skillall/@skillsall - Give you all skills. - 60:@stpoint - Gives you the desired number of stat points. - 60:@skpoint - Gives you the desired number of skill points. - 60:@zeny - Gives you desired amount of Zeny. - 60:@cash - Gives you the specified amount of cash points. - 60:@points - Gives you the specified amount of Kafra Points. - 60:@str,@agi,@vit,@int,@dex,@luk - Adds desired amount to any stat. For example "@str 10" raises your str by 10 - 60:@statall/@statsall/@allstats/@allstat [value] - Adds value in all stats (maximum if no value). - 60: @addwarp - 40: - 40:--- MONSTERS CMD --- - 40:@killmonster2 - kill all monsters of your map (without drops) - 50:/monster - Spawns 1 of the desired monster. - 50:@spawn/@monster/@summon [ [ [ []]]] - 50:@monster2 [ [ []]] - 50:@spawn/@monster/@summon/@monster2 "desired monster name" [ [ []]] - 50:@spawn/@monster/@summon/@monster2 "desired monster name" [ [ []]] - 50: Spawns the desired monster with any desired name. - 50:@monstersmall [Mob ID|Mob Name] - Spawns a smaller version of a monster. - 50:@monsterbig [Mob ID|Mob Name] - Spawns a larger version of a monster. - 60:@killmonster [map] - kill all monsters of the map (they drop) - 40: - 10:--- MISC CMD --- - 10:@autoloot [on|off|#] - Makes items go straight into your inventory. - 10:@autotrade/@at - Allows you to vend while you are offline. - 10:@changegm [Player Name] - Changes the leader of your guild (You must be guild leader) - 10:@changeleader [Player Name] - Changes the leader of your party (You must be party leader) - 20:@request [Message] - Sends a message to all connected GMs (via the gm whisper system) - 40:@sound [Path way to file in Data or GRF file] - Plays a sound from the data or grf file located on the client. - 50:@clone [Player Name] - Spawns a supportive clone of the given player. - 50:@slaveclone [Player Name] - Spawns a supportive clone of the given player that follows the creator around. - 50:@evilclone [Player Name] - Spawns an agressive clone of the given player. - 60:@changesex - Changes your gender. - 10: - 1:--- DUEL CMD --- - 1:@duel - Starts a duel. - 1:@invite - Invites a player to a duel. - 1:@accept - Accepts an invitation to a duel. - 1:@reject - Rejects an invitation to a duel. - 1:@leave - Leaves a duel. - 1: - 1:--- MAIL SYSTEM --- (SQL Only) - 1:@mail - Open mail box. +// This is help file that contains help messages for atcommands/charcommands. + +// Format: +// : "" + +// This file uses libconfig syntax. + +help: "Params: \n" "Shows help for specified command." +main: "Params: [on|off|]\n" "Turns on or off main (server-wide) chat. Sends message to main chat." +noask: "Auto rejects deals/invites." +gmotd: "Broadcasts the Message of The Day to all players." +me: "Params: \n" "Displays normal text as a message in this format: *name message* (like /me in mIRC)." +fakename: "Params: \n" "Changes your name to your choice temporarily." +npctalk: "Params: \n" "Forces a NPC to display a message in normal chat." +broadcast: "Params: \n" "Broadcasts a message with your name (in yellow)." +kami: "Params: \n" "Broadcasts a message without your name (in yellow)." +kamib: "Params: \n" "Broadcasts a message without your name (in blue)." +localbroadcast: "Params: \n" "Broadcasts a message with your name (in yellow) only on your map." +commands: "Displays a list of commands that you can use." +rates: "Displays the server's current rates." +uptime: "Displays how long the server has been online." +showdelay: "Shows/hides the \"There is a delay after this skill\" message." +exp: "Displays current levels and % progress." +mobinfo: "Params: |\n" "Shows monster info (stats, exp, drops etc)." +iteminfo: "Params: |\n" "Shows item info (type, price etc)." +whodrops: "Params: |\n" "Shows who drops an item (monster with highest drop rates)." +version: "Displays SVN version of the server." +email: "Params: \n" "Changes your account e-mail address." +where: "Params: \n" "Tells you the location of a character." +time: "Shows the date and time of the server." +showexp: "Displays/hides experience gained." +showzeny: "Displays/hides Zeny gained." +mobsearch: "Params: |\n" "Shows the location of a certain mob on the current map." +who: "Params: []\n" "Shows a list of online players and their party and guild." +who2: "Params: []\n" "Shows a list of online players and their job." +who3: "Params: []\n" "Shows a list of online players and their location." +whomap: "@whomap/@whomap2/@whomap3 [map] - like @who/@who2/@who3 but only for specifical map." +whogm: "Params: [match_text] - Like @who+@who2+who3, but only for GM." +guildspy: "Params: - You will receive all messages of the guild channel (Chat logging must be enabled)" +partyspy: "@partyspy - You will receive all messages of the party channel (Chat logging must be enabled)" +mapinfo: "Params: [<0-3> [map]] - Give information about a map (general info +: 0: no more, 1: players, 2: NPC, 3: shops/chat)." +die: "Kills yourself." +go: "Params: \n" "Warps you to a city.\n" + " -3: (Memo point 2) 1: morocc 5: izlude 9: yuno 13: niflheim \n" + " -2: (Memo point 1) 2: geffen 6: aldebaran 10: amatsu 14: louyang\n" + " -1: (Memo point 0) 3: payon 7: xmas (lutie) 11: gonryun 15: start point\n" + " 0: prontera 4: alberta 8: comodo 12: umbala 16: prison/jail\n" +jumpto: "Params: \n" "Warps you to selected character." +follow: "Params: \n" "Follow a player." +mount: "Give/remove you a peco (Class is required, but not skill)" +disguise: "Params: \n" "Change your appearence to other players to a mob." +undisguise: "Restore your normal appearance." +model: "Params: - Changes your characters appearence." +size: "Params: <1-3> Changes your size (1-Smallest 2-Biggest 3-Normal)" +hide: "Makes you character invisible (GM invisibility). Type again to become visible." +save: "Sets respawn point to current spot." +load: "Warps you to your save point." +warp: "Params: [ ]\n" "Warps you to the selected map and position." +jump: "Params: [ []]\n" "Randomly warps you like a flywing." +jobchange: "Params: \n" "Changes your job.\n" +" 0: Novice 18: Alchemist 4015: Paladin\n" +" 1: Swordman 19: Bard 4016: Champion\n" +" 2: Mage 20: Dancer 4017: Professor\n" +" 3: Archer 23: Super Novice 4018: Stalker\n" +" 4: Acolyte 4001: High Novice 4019: Creator\n" +" 5: Merchant 4002: High Swordman 4020: Clown\n" +" 6: Thief 4003: High Mage 4021: Gypsy\n" +" 7: Knight 4004: High Archer 4046: Taekwon\n" +" 8: Priest 4005: High Acolyte 4047: Star Gladiator\n" +" 9: Wizard 4006: High Merchant 4049: Soul Linker\n" +" 10: Blacksmith 4007: High Thief 24: Gunslinger\n" +" 11: Hunter 4008: Lord Knight 25: Ninja\n" +" 12: Assassin 4009: High Priest\n" +" 14: Crusader 4010: High Wizard\n" +" 15: Monk 4011: Whitesmith\n" +" 16: Sage 4012: Sniper\n" +" 17: Rogue 4013: Assassin Cross\n" +" ---- Baby Classes ----\n" +" 4023: Baby 4024: Baby Swordman 4025: Baby Mage\n" +" 4026: Baby Archer 4027: Baby Acolyte 4028: Baby Merchant\n" +" 4029: Baby Thief 4030: Baby Knight 4031: Baby Priest\n" +" 4032: Baby Wizard 4033: Baby Blacksmith 4034: Baby Hunter\n" +" 4035: Baby Assassin 4037: Baby Crusader 4038: Baby Monk\n" +" 4039: Baby Sage 4040: Baby Rogue 4041: Baby Alchemist\n" +" 4042: Baby Bard 4043: Baby Dancer 4045: Super Baby\n" +option: "Params: \n" "Adds different visual effects on or around your character.\n" +" (stackable) \n" +"1 Petrified (stackable) 01 Sight 32 Peco Peco riding 2048 Orc Head\n" +"2 Frozen 01 Poison 02 Hide 64 GM Perfect Hide 4096 Wedding Sprites\n" +"3 Stunned 02 Cursed 04 Cloak 128 Level 2 Cart 8192 Ruwach\n" +"4 Sleeping 04 Silenced 08 Level 1 Cart 256 Level 3 Cart\n" +"6 darkness 08 ??? 16 Falcon 512 Level 4 Cart\n" +" 16 darkness 1024 Level 5 Cart\n" +heal: "Params: [ ]\n" "Heals the desired amount of HP and SP. No value specified will do a full heal." +dye: "Params: \n" "Changes your characters clothes color." +hairstyle: "Params: \n" "Changes your hair style." +haircolor: "Params \n" "Changes your hair color." +speed: "Params: <1-1000>\n" "Changes you walking speed. 1 being the fastest and 1000 the slowest. Default is 150." +effect: "Params: []\n" "Give an effect to your character." +dropall: "Throws all your possession on the ground." +storeall: "Puts all your possessions in storage." +killable: "Make your character killable." +memo: "Params: [memo position]\n" "Set/change a memo location (no position: display memo points)." +spiritball: "Params: <1-100>\n" "Gives you \"spirit spheres\" like from the skill \"Call Spirits\".\n" +questskill: "Params: <#>\n" "Gives you the specified quest skill" +lostskill: "Params: <#>\n" "Takes away the specified quest skill from you\n" +" Novice Swordsman Thief Merchant\n" +" 142 = Emergency Care 144 = Moving HP Recovery 149 = Throw Sand 153 = Cart Revolution\n" +" 143 = Act dead 145 = Attack Weak Point 150 = Back Sliding 154 = Change Cart\n" +" Archer 146 = Auto Berserk 151 = Take Stone 155 = Crazy Uproar/Loud Voice\n" +" 147 = Arrow Creation Acolyte 152 = Stone Throw Magician\n" +" 148 = Charge Arrows 156 = Holy Light 157 = Energy Coat\n" +skillid: "Params: \n" "Look up a skill by name" +useskill: "Params: \n" "Use a skill on target" +skilltree: "Params: <" +marry: "Params: ,\n" "Marry two players." +divorce: "Params: \n" "Divorces the two players (you need just one name of them)" +alive: "Revives yourself from death." +blvl: "Params: \n" "Raises your base level the desired number of levels." +jlvl: "Params: \n" "Raises your job level the desired number of levels." +allskill: "Give you all skills." +stpoint: "Params: - Gives you the desired number of stat points." +skpoint: "Params: - Gives you the desired number of skill points." +zeny: "Params: - Gives you desired amount of Zeny." +cash: "Params: - Gives you the specified amount of cash points." +points: "Params: - Gives you the specified amount of Kafra Points." +str: "Params: \n" "Raises STR by given amount." +agi: "Params: \n" "Raises AGI by given amount." +dex: "Params: \n" "Raises DEX by given amount." +vit: "Params: \n" "Raises VIT by given amount." +int: "Params: \n" "Raises INT by given amount." +luk: "Params: \n" "Raises LUK by given amount." +allstats: "Params: \n" "Adds value in all stats (maximum if no value)." +addwarp: "Params: \n" +killmonster2: "Kills all monsters of your map (without drops)." +monster: "Params: [ [ [ []]]]\n" + "@monster2 [ [ []]]\n" +"@spawn/@monster/@summon/@monster2 \"desired monster name\" [ [ []]]\n" +"@spawn/@monster/@summon/@monster2 \"desired monster name\" [ [ []]]\n" +" Spawns the desired monster with any desired name." +monstersmall: "Params: [Mob ID|Mob Name]\n" "Spawns a smaller version of a monster." +monsterbig: "Params: [Mob ID|Mob Name]\n" "Spawns a larger version of a monster." +killmonster: "Params: [map]\n" "Kill all monsters of the map (they drop)" +autoloot: "Params: [on|off|#]\n" "Makes items go straight into your inventory." +autotrade: "Allows you to vend while you are offline." +changegm: "Params: [Player Name]\n" "Changes the leader of your guild (You must be guild leader)" +changeleader: "Params: [Player Name]\n" "Changes the leader of your party (You must be party leader)" +request: "Params: [Message]\n" "Sends a message to all connected GMs (via the gm whisper system)" +sound: "Params: [Path way to file in Data or GRF file]\n" "Plays a sound from the data or grf file located on the client." +clone: "Params: [Player Name]\n" "Spawns a supportive clone of the given player." +slaveclone: "Params: [Player Name]\n" "Spawns a supportive clone of the given player that follows the creator around." +evilclone: "Params: [Player Name]\n" "Spawns an agressive clone of the given player." +changesex: "Changes your gender." +duel: "Starts a duel." +invite: "Invites a player to a duel." +accept: "Accepts an invitation to a duel." +reject: "Rejects an invitation to a duel." +leave: "Leaves a duel." +mail: "Open mail box." +storage: "Opens storage." +itemreset: "Remove all your items." +guildstorage: "Opens guild storage." +idsearch: "Params: \n" "Search all items that name have part_of_item_name" +refine: "Params: <+/- amount>" +produce: "Params: <# of very's>\n" +" Element: 0=None 1=Ice 2=Earth 3=Fire 4=Wind\n" +" You can add up to 3 Star Crumbs and 1 element\n" +repairall: "Repair all items of your inventory" +item: "Params: \n" "Gives you the desired item." +item2: "Params: \n" "Gives you the desired item." +pvpon: "Turns pvp on on the current map" +pvpoff: "Turns pvp off on the current map" +gvgon: "Turns gvg on on the current map" +gvgoff: "Turns gvg off on the current map" +agitstart: "Starts War of Emperium" +agitend: "End War of Emperium" +party: "Params: \n" "Create a party." +guild: "Params: \n" "Create a guild." +glvl: "Params: <# of levels>\n" "Raise Guild by desired number of levels" +guildrecall: "Params: \n" "Warps all online characters of a guild to you." +partyrecall: "Params: \n" "Warps all online characters of a party to you." +petrename: "Re-enable pet rename" +pettalk: "Params: [Message]\n" "Makes your pet say a message." +petfriendly: "Params: <#>\n" "Set pet friendly amount (0-1000) 1000 = Max" +pethungry: "Params: <#>\n" "Set pet hungry amount (0-100) 100 = Max" +hatch: "Create a pet from your inventory eggs list." +makeegg: "Params: \n" "Gives pet egg for monster number in pet DB" +kick: "Params: \n" "Kicks specified character off the server" +unjail: "Params: \n" "Discharges specified character/prisoner" +kill: "Params: \n" "Kills specified character." +recall: "Params: \n" "Warps target character to you." +raise: "Params: \n" "Revives target character." +block: "Params: \n" "Blocks definitively a account" +unblock: "Params: \n" "Unblocks a account" +ban: "Params: diff --git a/vcproj-9/map-server_sql.vcproj b/vcproj-9/map-server_sql.vcproj index 14c807bcb..39a58e47d 100644 --- a/vcproj-9/map-server_sql.vcproj +++ b/vcproj-9/map-server_sql.vcproj @@ -42,8 +42,8 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP" Optimization="0" - AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;FD_SETSIZE=4096" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;PCRE_SUPPORT;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST" GeneratePreprocessedFile="0" ExceptionHandling="0" BasicRuntimeChecks="3" @@ -136,8 +136,8 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" - AdditionalIncludeDirectories="..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;FD_SETSIZE=4096" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\mysql\include;..\3rdparty\zlib\include;..\3rdparty\pcre\include;..\3rdparty\msinttypes\include;..\3rdparty\mt19937ar" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;PCRE_SUPPORT;FD_SETSIZE=4096;LIBCONFIG_STATIC;YY_USE_CONST" StringPooling="true" RuntimeLibrary="0" DefaultCharIsUnsigned="false" @@ -203,20 +203,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + @@ -451,6 +523,10 @@ RelativePath="..\src\map\duel.h" > + + @@ -499,6 +575,10 @@ RelativePath="..\src\map\log.h" > + + @@ -576,47 +656,31 @@ > - - - - - - - - + + @@ -659,6 +727,10 @@ RelativePath="..\src\map\storage.h" > + + diff --git a/vcproj-9/mapcache.vcproj b/vcproj-9/mapcache.vcproj index 645ae0b5e..e13f7ab27 100644 --- a/vcproj-9/mapcache.vcproj +++ b/vcproj-9/mapcache.vcproj @@ -42,8 +42,8 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP" Optimization="0" - AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\msinttypes\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;MINICORE" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;_DEBUG;MINICORE;LIBCONFIG_STATIC;YY_USE_CONST" GeneratePreprocessedFile="0" ExceptionHandling="0" BasicRuntimeChecks="3" @@ -135,8 +135,8 @@ OmitFramePointers="true" EnableFiberSafeOptimizations="true" WholeProgramOptimization="true" - AdditionalIncludeDirectories="..\3rdparty\zlib\include;..\3rdparty\msinttypes\include" - PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;MINICORE" + AdditionalIncludeDirectories="..\3rdparty\libconfig;..\3rdparty\zlib\include;..\3rdparty\msinttypes\include" + PreprocessorDefinitions="WIN32;_WIN32;__WIN32;NDEBUG;MINICORE;LIBCONFIG_STATIC;YY_USE_CONST" StringPooling="true" RuntimeLibrary="0" EnableFunctionLevelLinking="false" @@ -211,11 +211,11 @@ > Date: Thu, 16 Feb 2012 17:09:43 +0000 Subject: - Removed outdated version number handling (follow-up to r11503). - Fixed mapcache compilation issues in Linux. - Added some missing `svn:ignore` properties. - Moved `BLOCK_SIZE` definition from header to source file. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15586 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/char/Makefile.in | 2 +- src/char/char.c | 1 - src/common/Makefile.in | 2 +- src/common/core.c | 1 - src/common/core.h | 6 ++++++ src/common/plugins.c | 1 - src/common/showmsg.c | 1 - src/common/version.h | 30 ------------------------------ src/login/Makefile.in | 2 +- src/login/login.c | 1 - src/map/clif.c | 3 +-- src/map/instance.c | 1 - src/map/map.c | 8 +++----- src/map/map.h | 1 - src/map/quest.c | 1 - src/plugins/sig.c | 3 --- src/tool/Makefile.in | 8 ++++---- vcproj-10/char-server_sql.vcxproj | 1 - vcproj-10/char-server_sql.vcxproj.filters | 3 --- vcproj-10/login-server_sql.vcxproj | 1 - vcproj-10/login-server_sql.vcxproj.filters | 3 --- vcproj-10/map-server_sql.vcxproj | 1 - vcproj-10/map-server_sql.vcxproj.filters | 3 --- vcproj-10/mapcache.vcxproj | 1 - vcproj-10/mapcache.vcxproj.filters | 3 --- vcproj-9/char-server_sql.vcproj | 4 ---- vcproj-9/login-server_sql.vcproj | 4 ---- vcproj-9/map-server_sql.vcproj | 4 ---- vcproj-9/mapcache.vcproj | 4 ---- 29 files changed, 17 insertions(+), 87 deletions(-) delete mode 100644 src/common/version.h (limited to 'src/tool/Makefile.in') diff --git a/src/char/Makefile.in b/src/char/Makefile.in index f48f116b8..4ef8ae7ea 100644 --- a/src/char/Makefile.in +++ b/src/char/Makefile.in @@ -5,7 +5,7 @@ COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_a ../common/obj_all/strlib.o \ ../common/obj_all/mapindex.o ../common/obj_all/ers.o ../common/obj_all/random.o ../common/obj_all/conf.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ + ../common/db.h ../common/plugins.h ../common/lock.h \ ../common/malloc.h ../common/showmsg.h ../common/utils.h \ ../common/strlib.h \ ../common/mapindex.h ../common/ers.h ../common/random.h ../common/obj_all/conf.h diff --git a/src/char/char.c b/src/char/char.c index a569f5ca1..b1f0ee224 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -12,7 +12,6 @@ #include "../common/strlib.h" #include "../common/timer.h" #include "../common/utils.h" -#include "../common/version.h" #include "inter.h" #include "int_guild.h" #include "int_homun.h" diff --git a/src/common/Makefile.in b/src/common/Makefile.in index 7897b6cfb..de591a59f 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -4,7 +4,7 @@ COMMON_OBJ = obj_all/core.o obj_all/socket.o obj_all/timer.o obj_all/db.o obj_al 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 -COMMON_H = mmo.h plugin.h version.h \ +COMMON_H = mmo.h plugin.h \ core.h socket.h timer.h db.h plugins.h lock.h \ nullpo.h malloc.h showmsg.h strlib.h utils.h \ grfio.h mapindex.h ers.h md5calc.h random.h des.h \ diff --git a/src/common/core.c b/src/common/core.c index 60ba5d6cd..89a002ebe 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -2,7 +2,6 @@ // For more information, see LICENCE in the main folder #include "../common/mmo.h" -#include "../common/version.h" #include "../common/showmsg.h" #include "../common/malloc.h" #include "core.h" diff --git a/src/common/core.h b/src/common/core.h index ecaa2a9d0..11b4f7c47 100644 --- a/src/common/core.h +++ b/src/common/core.h @@ -14,6 +14,12 @@ extern char **arg_v; /// @see E_CORE_ST extern int runflag; extern char *SERVER_NAME; + +#define ATHENA_SERVER_NONE 0 // not defined +#define ATHENA_SERVER_LOGIN 1 // login server +#define ATHENA_SERVER_CHAR 2 // char server +#define ATHENA_SERVER_INTER 4 // inter server +#define ATHENA_SERVER_MAP 8 // map server extern char SERVER_TYPE; extern int parse_console(const char* buf); diff --git a/src/common/plugins.c b/src/common/plugins.c index 2d50fc9e8..937ec0aaa 100644 --- a/src/common/plugins.c +++ b/src/common/plugins.c @@ -7,7 +7,6 @@ #include "../common/utils.h" // findfile() #include "../common/socket.h" #include "../common/malloc.h" -#include "../common/version.h" #include "../common/showmsg.h" #include "plugins.h" diff --git a/src/common/showmsg.c b/src/common/showmsg.c index b77bf3949..4d09e2c53 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -5,7 +5,6 @@ #include "../common/strlib.h" // StringBuf #include "showmsg.h" #include "core.h" //[Ind] - For SERVER_TYPE -#include "version.h" //[Ind] - For SERVER_TYPE values #include #include diff --git a/src/common/version.h b/src/common/version.h deleted file mode 100644 index 71a93dcd9..000000000 --- a/src/common/version.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Athena Dev Teams - Licensed under GNU GPL -// For more information, see LICENCE in the main folder - -#ifndef _VERSION_H_ -#define _VERSION_H_ - -#define ATHENA_MAJOR_VERSION 1 // Major Version -#define ATHENA_MINOR_VERSION 0 // Minor Version -#define ATHENA_REVISION 0 // Revision - -#define ATHENA_RELEASE_FLAG 1 // 1=Develop,0=Stable -#define ATHENA_OFFICIAL_FLAG 1 // 1=Mod,0=Official - -#define ATHENA_SERVER_NONE 0 // not defined -#define ATHENA_SERVER_LOGIN 1 // login server -#define ATHENA_SERVER_CHAR 2 // char server -#define ATHENA_SERVER_INTER 4 // inter server -#define ATHENA_SERVER_MAP 8 // map server - -// ATHENA_MOD_VERSIONはパッチ番号です。 -// これは無理に変えなくても気が向いたら変える程度の扱いで。 -// (毎回アップロードの度に変更するのも面倒と思われるし、そもそも -//  この項目を参照する人がいるかどうかで疑問だから。) -// その程度の扱いなので、サーバーに問い合わせる側も、あくまで目安程度の扱いで -// あんまり信用しないこと。 -// 鯖snapshotの時や、大きな変更があった場合は設定してほしいです。 -// C言語の仕様上、最初に0を付けると8進数になるので間違えないで下さい。 -#define ATHENA_MOD_VERSION 1249 // mod version (patch No.) - -#endif /* _VERSION_H_ */ diff --git a/src/login/Makefile.in b/src/login/Makefile.in index 7938640aa..348943403 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -6,7 +6,7 @@ COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_a ../common/obj_all/ers.o ../common/obj_all/md5calc.o ../common/obj_all/random.o \ ../common/obj_all/conf.o COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/version.h ../common/db.h ../common/plugins.h ../common/lock.h \ + ../common/db.h ../common/plugins.h ../common/lock.h \ ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ ../common/mapindex.h \ ../common/ers.h ../common/md5calc.h ../common/random.h ../common/conf.h diff --git a/src/login/login.c b/src/login/login.c index 5a504ce2f..78211dc64 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -10,7 +10,6 @@ #include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "../common/version.h" #include "account.h" #include "ipban.h" #include "login.h" diff --git a/src/map/clif.c b/src/map/clif.c index 2770b61cc..8203ab7f5 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -6,7 +6,6 @@ #include "../common/timer.h" #include "../common/grfio.h" #include "../common/malloc.h" -#include "../common/version.h" #include "../common/nullpo.h" #include "../common/random.h" #include "../common/showmsg.h" @@ -270,7 +269,7 @@ static inline unsigned char clif_bl_type(struct block_list *bl) { case BL_SKILL: return 0x3; //SKILL_TYPE case BL_CHAT: return 0x4; //UNKNOWN_TYPE case BL_MOB: return pcdb_checkid(status_get_viewdata(bl)->class_)?0x0:0x5; //NPC_MOB_TYPE - case BL_NPC: return 0x6; //NPC_EVT_TYPE + case BL_NPC: return pcdb_checkid(status_get_viewdata(bl)->class_)?0x0:0x6; //NPC_EVT_TYPE case BL_PET: return pcdb_checkid(status_get_viewdata(bl)->class_)?0x0:0x7; //NPC_PET_TYPE case BL_HOM: return 0x8; //NPC_HOM_TYPE case BL_MER: return 0x9; //NPC_MERSOL_TYPE diff --git a/src/map/instance.c b/src/map/instance.c index 52d0dfeef..c4e151d79 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -5,7 +5,6 @@ #include "../common/socket.h" #include "../common/timer.h" #include "../common/malloc.h" -#include "../common/version.h" #include "../common/nullpo.h" #include "../common/showmsg.h" #include "../common/strlib.h" diff --git a/src/map/map.c b/src/map/map.c index fd6f41202..4677e8753 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -8,7 +8,6 @@ #include "../common/malloc.h" #include "../common/socket.h" // WFIFO*() #include "../common/showmsg.h" -#include "../common/version.h" #include "../common/nullpo.h" #include "../common/random.h" #include "../common/strlib.h" @@ -105,6 +104,7 @@ static DBMap* regen_db=NULL; // int id -> struct block_list* (status_natural_hea static int map_users=0; +#define BLOCK_SIZE 8 #define block_free_max 1048576 struct block_list *block_free[block_free_max]; static int block_free_count = 0, block_free_lock = 0; @@ -3553,12 +3553,10 @@ static void map_helpscreen(bool do_exit) *------------------------------------------------------*/ static void map_versionscreen(bool do_exit) { - ShowInfo(CL_WHITE"RAthena version %d.%02d.%02d, Athena Mod version %d" CL_RESET"\n", ATHENA_MAJOR_VERSION, ATHENA_MINOR_VERSION, ATHENA_REVISION, ATHENA_MOD_VERSION); + ShowInfo(CL_WHITE"rAthena SVN version: %s" CL_RESET"\n", get_svn_revision()); ShowInfo(CL_GREEN"Website/Forum:"CL_RESET"\thttp://rathena.org/\n"); - ShowInfo(CL_GREEN"IRC Channel:"CL_RESET"\tirc://irc.rizon.net/#rthena\n"); + ShowInfo(CL_GREEN"IRC Channel:"CL_RESET"\tirc://irc.rathena.net/#rathena\n"); ShowInfo("Open "CL_WHITE"readme.html"CL_RESET" for more information.\n"); - if(ATHENA_RELEASE_FLAG) - ShowNotice("This version is not for release.\n"); if( do_exit ) exit(EXIT_SUCCESS); } diff --git a/src/map/map.h b/src/map/map.h index 06e955b6e..97063bfbb 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -29,7 +29,6 @@ enum E_MAPSERVER_ST #define MAX_NPC_PER_MAP 512 -#define BLOCK_SIZE 8 #define AREA_SIZE battle_config.area_size #define DAMAGELOG_SIZE 30 #define LOOTITEM_SIZE 10 diff --git a/src/map/quest.c b/src/map/quest.c index c01557974..ebb5b15c1 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -5,7 +5,6 @@ #include "../common/socket.h" #include "../common/timer.h" #include "../common/malloc.h" -#include "../common/version.h" #include "../common/nullpo.h" #include "../common/showmsg.h" #include "../common/strlib.h" diff --git a/src/plugins/sig.c b/src/plugins/sig.c index 15fd71846..8f7dead4b 100644 --- a/src/plugins/sig.c +++ b/src/plugins/sig.c @@ -7,7 +7,6 @@ #include #include #include "../common/plugin.h" -#include "../common/version.h" #include "../common/showmsg.h" PLUGIN_INFO = { @@ -121,8 +120,6 @@ void sig_dump(int sn) ShowNotice ("Dumping stack to '"CL_WHITE"%s"CL_RESET"'...\n", file); if ((revision = getrevision()) != NULL) fprintf(fp, "Version: svn%s \n", revision); - else - fprintf(fp, "Version: %2d.%02d.%02d mod%02d \n", ATHENA_MAJOR_VERSION, ATHENA_MINOR_VERSION, ATHENA_REVISION, ATHENA_MOD_VERSION); fprintf(fp, "Exception: %s \n", strsignal(sn)); fflush (fp); diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 8d14d9ed2..2ad022936 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -2,7 +2,7 @@ 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_H = ../common/core.h ../common/mmo.h ../common/version.h \ +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 @@ -40,8 +40,8 @@ help: obj_all: -mkdir obj_all -obj_all/%.o: %.c $(COMMON_H) - @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_all/%.o: %.c $(COMMON_H) $(LIBCONFIG_H) + @CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files ../common/obj_all/%.o: @@ -51,4 +51,4 @@ obj_all/%.o: %.c $(COMMON_H) @$(MAKE) -C ../common txt LIBCONFIG_OBJ: - @$(MAKE) -C ../../3rdparty/libconfig \ No newline at end of file + @$(MAKE) -C ../../3rdparty/libconfig diff --git a/vcproj-10/char-server_sql.vcxproj b/vcproj-10/char-server_sql.vcxproj index afa7f85d3..e070d3e34 100644 --- a/vcproj-10/char-server_sql.vcxproj +++ b/vcproj-10/char-server_sql.vcxproj @@ -152,7 +152,6 @@ - diff --git a/vcproj-10/char-server_sql.vcxproj.filters b/vcproj-10/char-server_sql.vcxproj.filters index 3b11113ee..f47beddec 100644 --- a/vcproj-10/char-server_sql.vcxproj.filters +++ b/vcproj-10/char-server_sql.vcxproj.filters @@ -147,9 +147,6 @@ common - - common - char_sql diff --git a/vcproj-10/login-server_sql.vcxproj b/vcproj-10/login-server_sql.vcxproj index 6cd25c88c..d747c3e1e 100644 --- a/vcproj-10/login-server_sql.vcxproj +++ b/vcproj-10/login-server_sql.vcxproj @@ -159,7 +159,6 @@ - diff --git a/vcproj-10/login-server_sql.vcxproj.filters b/vcproj-10/login-server_sql.vcxproj.filters index 4af055584..0d75bb624 100644 --- a/vcproj-10/login-server_sql.vcxproj.filters +++ b/vcproj-10/login-server_sql.vcxproj.filters @@ -90,9 +90,6 @@ common - - common - common diff --git a/vcproj-10/map-server_sql.vcxproj b/vcproj-10/map-server_sql.vcxproj index 55ad74671..e90c3c4de 100644 --- a/vcproj-10/map-server_sql.vcxproj +++ b/vcproj-10/map-server_sql.vcxproj @@ -155,7 +155,6 @@ - diff --git a/vcproj-10/map-server_sql.vcxproj.filters b/vcproj-10/map-server_sql.vcxproj.filters index a1b51acce..f5862c135 100644 --- a/vcproj-10/map-server_sql.vcxproj.filters +++ b/vcproj-10/map-server_sql.vcxproj.filters @@ -285,9 +285,6 @@ map_sql - - common - common diff --git a/vcproj-10/mapcache.vcxproj b/vcproj-10/mapcache.vcxproj index b0f58b70b..5ff4a99b4 100644 --- a/vcproj-10/mapcache.vcxproj +++ b/vcproj-10/mapcache.vcxproj @@ -142,7 +142,6 @@ - diff --git a/vcproj-10/mapcache.vcxproj.filters b/vcproj-10/mapcache.vcxproj.filters index 713cdb64b..41955216f 100644 --- a/vcproj-10/mapcache.vcxproj.filters +++ b/vcproj-10/mapcache.vcxproj.filters @@ -54,9 +54,6 @@ common - - common - diff --git a/vcproj-9/char-server_sql.vcproj b/vcproj-9/char-server_sql.vcproj index 43b959827..2ef9ec81b 100644 --- a/vcproj-9/char-server_sql.vcproj +++ b/vcproj-9/char-server_sql.vcproj @@ -412,10 +412,6 @@ RelativePath="..\src\common\utils.h" > - - - - - - - - Date: Fri, 1 Jun 2012 10:46:02 +0000 Subject: feature merge bs-coreoptimize->trunk: Build Output Cleanup, Makefile Common Dependency Handling - "Optimized" the build Output using Makefiles - to Kernel style build output. - Changed dependency handling to common (core), by generating one lib file (ar) and link against that instead of assigning all deps individually in every subproject - Changed header dependency handling in Subproject makefiles - requiring all common/ headers. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16198 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/libconfig/Makefile.in | 6 ++++-- 3rdparty/mt19937ar/Makefile.in | 8 +++++--- configure | 43 +++++++++++++++++++++++++++++++++++++++++- configure.in | 1 + src/char/Makefile.in | 29 ++++++++++++---------------- src/common/Makefile.in | 37 +++++++++++++++++++++++------------- src/login/Makefile.in | 34 +++++++++++++-------------------- src/map/Makefile.in | 43 +++++++++++++++++------------------------- src/plugins/Makefile.in | 9 ++++++--- src/tool/Makefile.in | 9 ++++++--- 10 files changed, 130 insertions(+), 89 deletions(-) (limited to 'src/tool/Makefile.in') diff --git a/3rdparty/libconfig/Makefile.in b/3rdparty/libconfig/Makefile.in index 12ff7572b..ab03d4154 100644 --- a/3rdparty/libconfig/Makefile.in +++ b/3rdparty/libconfig/Makefile.in @@ -10,7 +10,8 @@ LIBCONFIG_H = libconfig.h grammar.h parsectx.h scanctx.h scanner.h strbuf.h winc all: $(LIBCONFIG_OBJ) clean: - rm -rf *.o + @echo " CLEAN libconfig" + @rm -rf *.o help: @echo "possible targets are 'all' 'clean' 'help'" @@ -21,4 +22,5 @@ help: ##################################################################### %.o: %.c $(LIBCONFIG_H) - @CC@ @CFLAGS@ @DEFS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ @DEFS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/3rdparty/mt19937ar/Makefile.in b/3rdparty/mt19937ar/Makefile.in index 7cae3140b..63f75fdad 100644 --- a/3rdparty/mt19937ar/Makefile.in +++ b/3rdparty/mt19937ar/Makefile.in @@ -9,8 +9,9 @@ MT19937AR_H = mt19937ar.h all: $(MT19937AR_OBJ) -clean: - rm -rf *.o +clean: + @echo " CLEAN mt19937ar" + @rm -rf *.o help: @echo "possible targets are 'all' 'clean' 'help'" @@ -21,4 +22,5 @@ help: ##################################################################### %.o: %.c $(MT19937AR_H) - @CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/configure b/configure index d8fb1068e..23c222c68 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 16196 . +# From configure.in Revision: 16197 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.67. # @@ -605,6 +605,7 @@ MYSQL_VERSION HAVE_MYSQL MYSQL_CONFIG_HOME WITH_PLUGINS +AR SET_MAKE EGREP GREP @@ -4342,6 +4343,46 @@ 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 +# Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_path_AR+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + case $AR in + [\\/]* | ?:[\\/]*) + ac_cv_path_AR="$AR" # Let the user override the test with a path. + ;; + *) + 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_AR="$as_dir/$ac_word$ac_exec_ext" + $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 + + ;; +esac +fi +AR=$ac_cv_path_AR +if test -n "$AR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 +$as_echo "$AR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' diff --git a/configure.in b/configure.in index e5dae76b6..75c20dd48 100644 --- a/configure.in +++ b/configure.in @@ -298,6 +298,7 @@ AC_ARG_WITH( AC_PROG_MAKE_SET AC_PROG_CC AC_PROG_CPP +AC_PATH_PROG(AR, ar) AC_LANG([C]) diff --git a/src/char/Makefile.in b/src/char/Makefile.in index 1c93cfa6d..bfe9d1585 100644 --- a/src/char/Makefile.in +++ b/src/char/Makefile.in @@ -1,14 +1,5 @@ -COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_all/timer.o \ - ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ - ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/utils.o \ - ../common/obj_all/strlib.o \ - ../common/obj_all/mapindex.o ../common/obj_all/ers.o ../common/obj_all/random.o ../common/obj_all/conf.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/malloc.h ../common/showmsg.h ../common/utils.h \ - ../common/strlib.h \ - ../common/mapindex.h ../common/ers.h ../common/random.h ../common/obj_all/conf.h +COMMON_H = $(shell ls ../common/*.h) MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h @@ -30,7 +21,7 @@ CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homu HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) + CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) else CHAR_SERVER_SQL_DEPENDS=needs_mysql endif @@ -43,10 +34,12 @@ endif all: char-server_sql char-server_sql: $(CHAR_SERVER_SQL_DEPENDS) - @CC@ @LDFLAGS@ -o ../../char-server_sql@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ + @echo " LD $@" + @@CC@ @LDFLAGS@ -o ../../char-server_sql@EXEEXT@ $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ clean: - rm -rf *.o obj_sql ../../char-server_sql@EXEEXT@ + @echo " CLEAN char" + @rm -rf *.o obj_sql ../../char-server_sql@EXEEXT@ help: @echo "possible targets are 'char-server_sql' 'all' 'clean' 'help'" @@ -62,16 +55,18 @@ needs_mysql: @exit 1 obj_sql: - -mkdir obj_sql + @echo " MKDIR obj_sql" + @-mkdir obj_sql obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files -../common/obj_all/%.o: +../common/obj_all/common.a: @$(MAKE) -C ../common sql -../common/obj_sql/%.o: +../common/obj_sql/common_sql.a: @$(MAKE) -C ../common sql MT19937AR_OBJ: diff --git a/src/common/Makefile.in b/src/common/Makefile.in index de591a59f..5e3b00a88 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -4,11 +4,8 @@ COMMON_OBJ = obj_all/core.o obj_all/socket.o obj_all/timer.o obj_all/db.o obj_al 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 -COMMON_H = mmo.h plugin.h \ - core.h socket.h timer.h db.h plugins.h lock.h \ - nullpo.h malloc.h showmsg.h strlib.h utils.h \ - grfio.h mapindex.h ers.h md5calc.h random.h des.h \ - conf.h + +COMMON_H = $(shell ls ../common/*.h) COMMON_SQL_OBJ = obj_sql/sql.o COMMON_SQL_H = sql.h @@ -46,7 +43,8 @@ txt: $(TXT_DEPENDS) sql: $(SQL_DEPENDS) clean: - rm -rf *.o obj_all obj_sql + @echo " CLEAN common" + @rm -rf *.o obj_all obj_sql help: @echo "possible targets are 'txt' 'sql' 'all' 'clean' 'help'" @@ -63,24 +61,37 @@ needs_mysql: @exit 1 obj_all: - -mkdir obj_all + @echo " MKDIR obj_all" + @-mkdir obj_all obj_sql: - -mkdir obj_sql + @echo " MKDIR obj_sql" + @-mkdir obj_sql + +obj_all/common.a: $(COMMON_OBJ) + @echo " AR $@" + @@AR@ rcs obj_all/common.a $(COMMON_OBJ) -common: obj_all $(COMMON_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) +obj_sql/common_sql.a: $(COMMON_SQL_OBJ) + @echo " AR $@" + @@AR@ rcs obj_sql/common_sql.a $(COMMON_SQL_OBJ) + -common_sql: obj_sql $(COMMON_SQL_OBJ) +common: obj_all $(COMMON_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common.a +common_sql: obj_sql $(COMMON_SQL_OBJ) obj_sql/common_sql.a obj_all/%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< obj_all/mini%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DMINICORE @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DMINICORE @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files diff --git a/src/login/Makefile.in b/src/login/Makefile.in index 348943403..d0fc34756 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -1,18 +1,5 @@ -COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_all/timer.o \ - ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ - ../common/obj_all/malloc.o ../common/obj_all/showmsg.o ../common/obj_all/utils.o \ - ../common/obj_all/strlib.o ../common/obj_all/mapindex.o \ - ../common/obj_all/ers.o ../common/obj_all/md5calc.o ../common/obj_all/random.o \ - ../common/obj_all/conf.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h \ - ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/malloc.h ../common/showmsg.h ../common/utils.h ../common/strlib.h \ - ../common/mapindex.h \ - ../common/ers.h ../common/md5calc.h ../common/random.h ../common/conf.h - -COMMON_SQL_OBJ = ../common/obj_sql/sql.o -COMMON_SQL_H = ../common/sql.h +COMMON_H = $(shell ls ../common/*.h) MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h @@ -32,7 +19,7 @@ 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) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) + LOGIN_SERVER_SQL_DEPENDS=obj_sql $(LOGIN_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) else LOGIN_SERVER_SQL_DEPENDS=needs_mysql endif @@ -47,7 +34,8 @@ all: sql sql: obj_sql login-server_sql clean: - rm -rf *.o obj_sql ../../login-server@EXEEXT@ ../../login-server_sql@EXEEXT@ + @echo " CLEAN login" + @rm -rf *.o obj_sql ../../login-server@EXEEXT@ ../../login-server_sql@EXEEXT@ help: @echo "possible targets are 'sql' 'all' 'clean' 'help'" @@ -65,23 +53,27 @@ needs_mysql: # object directories obj_sql: - test -d obj_sql || mkdir obj_sql + @echo " MKDIR obj_sql" + @-mkdir obj_sql #executables login-server_sql: $(LOGIN_SERVER_SQL_DEPENDS) - @CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ + @echo " LD $@" + @@CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_SQL_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) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files -../common/obj_all/%.o: +../common/obj_all/common.a: @$(MAKE) -C ../common sql -../common/obj_sql/%.o: +../common/obj_sql/common_sql.a: @$(MAKE) -C ../common sql MT19937AR_OBJ: diff --git a/src/map/Makefile.in b/src/map/Makefile.in index beeab32dd..06925bcec 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -1,19 +1,5 @@ -COMMON_OBJ = ../common/obj_all/core.o ../common/obj_all/socket.o ../common/obj_all/timer.o \ - ../common/obj_all/db.o ../common/obj_all/plugins.o ../common/obj_all/lock.o \ - ../common/obj_all/nullpo.o ../common/obj_all/malloc.o ../common/obj_all/showmsg.o \ - ../common/obj_all/utils.o ../common/obj_all/strlib.o ../common/obj_all/grfio.o \ - ../common/obj_all/mapindex.o ../common/obj_all/ers.o ../common/obj_all/md5calc.o \ - ../common/obj_all/random.o ../common/obj_all/des.o ../common/obj_all/conf.o -COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h \ - ../common/db.h ../common/plugins.h ../common/lock.h \ - ../common/nullpo.h ../common/malloc.h ../common/showmsg.h \ - ../common/utils.h ../common/strlib.h ../common/grfio.h \ - ../common/mapindex.h ../common/ers.h ../common/md5calc.h \ - ../common/random.h ../common/des.h ../common/conf.h - -COMMON_SQL_OBJ = ../common/obj_sql/sql.o -COMMON_SQL_H = ../common/sql.h +COMMON_H = $(shell ls ../common/*.h) MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h @@ -72,7 +58,8 @@ txt: $(TXT_DEPENDS) sql: $(SQL_DEPENDS) clean: - rm -rf *.o obj_txt obj_sql ../../map-server@EXEEXT@ ../../map-server_sql@EXEEXT@ + @echo " CLEAN map" + @rm -rf *.o obj_txt obj_sql ../../map-server@EXEEXT@ ../../map-server_sql@EXEEXT@ help: ifeq ($(HAVE_MYSQL),yes) @@ -94,28 +81,32 @@ needs_mysql: # object directories obj_txt: - -mkdir obj_txt + @echo " MKDIR obj_txt" + @-mkdir obj_txt obj_sql: - -mkdir obj_sql + @echo " MKDIR obj_sql" + @-mkdir obj_sql # executables -map-server_sql: obj_sql $(MAP_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) - @CC@ @LDFLAGS@ -o ../../map-server_sql@EXEEXT@ $(MAP_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ +map-server_sql: obj_sql $(MAP_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a + @echo " LD $@" + @@CC@ @LDFLAGS@ -o ../../map-server_sql@EXEEXT@ $(MAP_SQL_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) $(COMMON_SQL_H) $(MT19937AR_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< +obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) + @echo " CC $<" + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files -../common/obj_all/%.o: +../common/obj_all/common.a: @$(MAKE) -C ../common sql - -../common/obj_sql/%.o: + +../common/obj_sql/common_sql.a: @$(MAKE) -C ../common sql - + MT19937AR_OBJ: @$(MAKE) -C ../../3rdparty/mt19937ar diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in index fa74ff90d..1b92ea3fa 100644 --- a/src/plugins/Makefile.in +++ b/src/plugins/Makefile.in @@ -23,7 +23,8 @@ pid: pid@DLLEXT@ console: console@DLLEXT@ clean: - rm -rf *.o + @echo " CLEAN plugins" + @rm -rf *.o help: @echo "possible targets are $(PLUGINS:%='%') 'all' 'clean' 'help'" @@ -38,10 +39,12 @@ help: ##################################################################### %@DLLEXT@: %.c - @CC@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ -shared -o ../../plugins/$@ $< + @echo " CC $<" + @@CC@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ -shared -o ../../plugins/$@ $< sig@DLLEXT@: sig.c $(COMMON_OBJ) - @CC@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ -shared -o ../../plugins/$@ $< $(COMMON_OBJ) + @echo " CC $<" + @@CC@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ -shared -o ../../plugins/$@ $< $(COMMON_OBJ) # missing common object files ../common/obj_all/%.o: ../common/%.c $(COMMON_H) diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 2ad022936..59ef89958 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -23,10 +23,12 @@ MAPCACHE_OBJ = obj_all/mapcache.o all: mapcache mapcache: obj_all $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) - @CC@ @LDFLAGS@ $(LIBCONFIG_INCLUDE) -o ../../mapcache@EXEEXT@ $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) @LIBS@ + @echo " LD $@" + @@CC@ @LDFLAGS@ $(LIBCONFIG_INCLUDE) -o ../../mapcache@EXEEXT@ $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) @LIBS@ clean: - rm -rf obj_all/*.o ../../mapcache@EXEEXT@ + @echo " CLEAN tool" + @rm -rf obj_all/*.o ../../mapcache@EXEEXT@ help: @echo "possible targets are 'mapcache' 'all' 'clean' 'help'" @@ -41,7 +43,8 @@ obj_all: -mkdir obj_all obj_all/%.o: %.c $(COMMON_H) $(LIBCONFIG_H) - @CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @echo " CC $<" + @@CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files ../common/obj_all/%.o: -- cgit v1.2.3-70-g09d2 From 0598cc569db02ee93d7fc0470defecb64e995f5c Mon Sep 17 00:00:00 2001 From: blacksirius Date: Mon, 11 Jun 2012 23:31:19 +0000 Subject: Fixed bugreport:5990 OSX compiling error / warnings Bug in Detail: - Misplaced LDFLAGS uage in some Makefile templates (by passing them to the compiler not to the linker.) - Wrong usage of volatile (a functions return value couldnt be declared to return volatile :D ) - Unsupported Inline ASM using lock xchg operation on llvm-gcc .. (apple loves this ..) Fixed by: - Removed unnecessary LDFLAGS - Removed unnecessary volatile declarator - Replaced InterlockedExchange and InterlockedExchange64 with gcc intrinsics. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16270 54d463be-8e91-2dee-dedb-b68131a5f0ec --- 3rdparty/libconfig/Makefile.in | 2 +- 3rdparty/mt19937ar/Makefile.in | 2 +- src/common/Makefile.in | 4 ++-- src/common/atomic.h | 44 +++++++++++++----------------------------- src/tool/Makefile.in | 2 +- 5 files changed, 18 insertions(+), 36 deletions(-) (limited to 'src/tool/Makefile.in') diff --git a/3rdparty/libconfig/Makefile.in b/3rdparty/libconfig/Makefile.in index ab03d4154..b0fa9a314 100644 --- a/3rdparty/libconfig/Makefile.in +++ b/3rdparty/libconfig/Makefile.in @@ -23,4 +23,4 @@ help: %.o: %.c $(LIBCONFIG_H) @echo " CC $<" - @@CC@ @CFLAGS@ @DEFS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CC@ @CFLAGS@ @DEFS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/3rdparty/mt19937ar/Makefile.in b/3rdparty/mt19937ar/Makefile.in index 63f75fdad..8a7b64669 100644 --- a/3rdparty/mt19937ar/Makefile.in +++ b/3rdparty/mt19937ar/Makefile.in @@ -23,4 +23,4 @@ help: %.o: %.c $(MT19937AR_H) @echo " CC $<" - @@CC@ @CFLAGS@ @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CC@ @CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/src/common/Makefile.in b/src/common/Makefile.in index b6713b6a1..379f80231 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -83,11 +83,11 @@ common_sql: obj_sql $(COMMON_SQL_OBJ) obj_sql/common_sql.a obj_all/%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) @echo " CC $<" - @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $< obj_all/mini%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) @echo " CC $<" - @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DMINICORE @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DMINICORE @CPPFLAGS@ -c $(OUTPUT_OPTION) $< obj_sql/%.o: %.c $(COMMON_H) $(COMMON_SQL_H) $(LIBCONFIG_H) @echo " CC $<" diff --git a/src/common/atomic.h b/src/common/atomic.h index c09d8d386..b1a4bda92 100644 --- a/src/common/atomic.h +++ b/src/common/atomic.h @@ -86,71 +86,53 @@ forceinline volatile int64 InterlockedExchange64(volatile int64 *target, int64 v #error Your Target Platfrom is not supported #endif -static forceinline volatile int64 InterlockedExchangeAdd64(volatile int64 *addend, int64 increment){ +static forceinline int64 InterlockedExchangeAdd64(volatile int64 *addend, int64 increment){ return __sync_fetch_and_add(addend, increment); }//end: InterlockedExchangeAdd64() -static forceinline volatile int32 InterlockedExchangeAdd(volatile int32 *addend, int32 increment){ +static forceinline int32 InterlockedExchangeAdd(volatile int32 *addend, int32 increment){ return __sync_fetch_and_add(addend, increment); }//end: InterlockedExchangeAdd() -static forceinline volatile int64 InterlockedIncrement64(volatile int64 *addend){ +static forceinline int64 InterlockedIncrement64(volatile int64 *addend){ return __sync_add_and_fetch(addend, 1); }//end: InterlockedIncrement64() -static forceinline volatile int32 InterlockedIncrement(volatile int32 *addend){ +static forceinline int32 InterlockedIncrement(volatile int32 *addend){ return __sync_add_and_fetch(addend, 1); }//end: InterlockedIncrement() -static forceinline volatile int64 InterlockedDecrement64(volatile int64 *addend){ +static forceinline int64 InterlockedDecrement64(volatile int64 *addend){ return __sync_sub_and_fetch(addend, 1); }//end: InterlockedDecrement64() -static forceinline volatile int32 InterlockedDecrement(volatile int32 *addend){ +static forceinline int32 InterlockedDecrement(volatile int32 *addend){ return __sync_sub_and_fetch(addend, 1); }//end: InterlockedDecrement() -static forceinline volatile int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch, int64 cmp){ +static forceinline int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch, int64 cmp){ return __sync_val_compare_and_swap(dest, cmp, exch); }//end: InterlockedCompareExchange64() -static forceinline volatile int32 InterlockedCompareExchange(volatile int32 *dest, int32 exch, int32 cmp){ - return __sync_val_compare_and_swap(dest, cmp, exch); +static forceinline int32 InterlockedCompareExchange(volatile int32 *dest, int32 exch, int32 cmp){ + return __sync_val_compare_and_swap(dest, cmp, exch); }//end: InterlockedCompareExchnage() -static forceinline volatile int64 InterlockedExchange64(volatile int64 *target, int64 val){ - int ret; - - __asm__ __volatile__( - "lock xchg %2, (%1)" - :"=r" (ret) - :"r" (target), "0" (val) - :"memory" - ); - - return ret; +static forceinline int64 InterlockedExchange64(volatile int64 *target, int64 val){ + return __sync_lock_test_and_set(target, val); }//end: InterlockedExchange64() -static forceinline volatile int32 InterlockedExchange(volatile int32 *target, int32 val){ - int ret; - - __asm__ __volatile__( - "lock xchgl %2, (%1)" - :"=r" (ret) - :"r" (target), "0" (val) - :"memory" - ); - - return ret; +static forceinline int32 InterlockedExchange(volatile int32 *target, int32 val){ + return __sync_lock_test_and_set(target, val); }//end: InterlockedExchange() diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 59ef89958..9d9a8668f 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -44,7 +44,7 @@ obj_all: obj_all/%.o: %.c $(COMMON_H) $(LIBCONFIG_H) @echo " CC $<" - @@CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @LDFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< + @@CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing common object files ../common/obj_all/%.o: -- cgit v1.2.3-70-g09d2 From 9cb21bac409ae46c0f4aa12732579f4f24141278 Mon Sep 17 00:00:00 2001 From: shennetsind Date: Fri, 9 Nov 2012 02:27:33 +0000 Subject: Fixed bugreport:6209 / Follow up r16867 : updated mapcache to write onto its proper map_cache.dat depending on the instance's #RENEWAL git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16884 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/tool/Makefile.in | 6 ++++-- src/tool/mapcache.c | 13 ++++++++++++- vcproj-10/mapcache.vcxproj | 1 + vcproj-9/mapcache.vcproj | 4 ++++ 4 files changed, 21 insertions(+), 3 deletions(-) (limited to 'src/tool/Makefile.in') diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 9d9a8668f..d72ef5405 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -4,7 +4,7 @@ COMMON_OBJ = ../common/obj_all/minicore.o ../common/obj_all/malloc.o \ ../common/obj_all/utils.o ../common/obj_all/des.o ../common/obj_all/grfio.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/utils.h ../common/cbasetypes.h ../common/des.h ../common/grfio.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 @@ -13,6 +13,8 @@ LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/gram ../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig +OTHER_H = ../config/renewal.h + MAPCACHE_OBJ = obj_all/mapcache.o @SET_MAKE@ @@ -42,7 +44,7 @@ help: obj_all: -mkdir obj_all -obj_all/%.o: %.c $(COMMON_H) $(LIBCONFIG_H) +obj_all/%.o: %.c $(COMMON_H) $(OTHER_H) $(LIBCONFIG_H) @echo " CC $<" @@CC@ @CFLAGS@ $(LIBCONFIG_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/src/tool/mapcache.c b/src/tool/mapcache.c index 9c4fd2cbf..9cb1d792c 100644 --- a/src/tool/mapcache.c +++ b/src/tool/mapcache.c @@ -7,6 +7,8 @@ #include "../common/mmo.h" #include "../common/showmsg.h" +#include "../config/renewal.h" + #include #include #include @@ -19,7 +21,7 @@ char grf_list_file[256] = "conf/grf-files.txt"; char map_list_file[256] = "db/map_index.txt"; -char map_cache_file[256] = "db/map_cache.dat"; +char map_cache_file[256]; int rebuild = 0; FILE *map_cache_fp; @@ -254,6 +256,15 @@ int do_init(int argc, char** argv) struct map_data map; char name[MAP_NAME_LENGTH_EXT]; + /* setup pre-defined, #define-dependant */ + sprintf(map_cache_file,"db/%s/map_cache.dat", +#ifndef RENEWAL + "re" +#else + "pre-re" +#endif + ); + // Process the command-line arguments process_args(argc, argv); diff --git a/vcproj-10/mapcache.vcxproj b/vcproj-10/mapcache.vcxproj index 3f277143f..f2f5fec95 100644 --- a/vcproj-10/mapcache.vcxproj +++ b/vcproj-10/mapcache.vcxproj @@ -143,6 +143,7 @@ + diff --git a/vcproj-9/mapcache.vcproj b/vcproj-9/mapcache.vcproj index 5fdac3d5b..45d40a004 100644 --- a/vcproj-9/mapcache.vcproj +++ b/vcproj-9/mapcache.vcproj @@ -278,6 +278,10 @@ RelativePath="..\src\tool\mapcache.c" > + + -- cgit v1.2.3-70-g09d2