From babdf60b0339ac4249072a4ba13d27052e0b2fc5 Mon Sep 17 00:00:00 2001 From: Haru Date: Wed, 18 Sep 2013 05:11:10 +0200 Subject: Makefiles improvements and cleanup This should resolve #138 (please reopen or comment on it if it's not the case). Special thanks to Takkun for helping to reproduce the issue. Signed-off-by: Haru --- src/login/Makefile.in | 62 +++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 29 deletions(-) (limited to 'src/login') diff --git a/src/login/Makefile.in b/src/login/Makefile.in index 5014d667a..125f4fb7a 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -1,25 +1,26 @@ COMMON_H = $(shell ls ../common/*.h) - -MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o -MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h -MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar - -LIBCONFIG_OBJ = ../../3rdparty/libconfig/libconfig.o ../../3rdparty/libconfig/grammar.o \ - ../../3rdparty/libconfig/scanctx.o ../../3rdparty/libconfig/scanner.o ../../3rdparty/libconfig/strbuf.o -LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/grammar.h \ - ../../3rdparty/libconfig/parsectx.h ../../3rdparty/libconfig/scanctx.h ../../3rdparty/libconfig/scanner.h \ - ../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h -LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig - -LOGIN_OBJ = login.o -LOGIN_SQL_OBJ = $(LOGIN_OBJ:%=obj_sql/%) \ - obj_sql/account_sql.o obj_sql/ipban_sql.o obj_sql/loginlog_sql.o +CONFIG_H = $(shell ls ../config/*.h ../config/*/*.h) + +MT19937AR_D = ../../3rdparty/mt19937ar +MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o +MT19937AR_H = $(MT19937AR_D)/mt19937ar.h +MT19937AR_INCLUDE = -I$(MT19937AR_D) + +LIBCONFIG_D = ../../3rdparty/libconfig +LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \ + scanner.o strbuf.o) +LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \ + scanctx.h scanner.h strbuf.h wincompat.h) +LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D) + +LOGIN_OBJ = $(addprefix obj_sql/, account_sql.o ipban_sql.o login.o \ + loginlog_sql.o) LOGIN_H = login.h account.h ipban.h loginlog.h HAVE_MYSQL=@HAVE_MYSQL@ ifeq ($(HAVE_MYSQL),yes) - LOGIN_SERVER_SQL_DEPENDS=obj_sql $(LOGIN_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) + LOGIN_SERVER_SQL_DEPENDS=$(LOGIN_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) else LOGIN_SERVER_SQL_DEPENDS=needs_mysql endif @@ -30,22 +31,22 @@ CC = @CC@ export CC ##################################################################### -.PHONY :all sql clean help +.PHONY: all sql login-server clean help all: sql -sql: obj_sql login-server +sql: login-server clean: @echo " CLEAN login" @rm -rf *.o obj_sql ../../login-server@EXEEXT@ help: - @echo "possible targets are 'sql' 'all' 'clean' 'help'" - @echo "'sql' - login server (SQL version)" - @echo "'all' - builds all above targets" - @echo "'clean' - cleans builds and objects" - @echo "'help' - outputs this message" + @echo "possible targets are 'login-server' 'all' 'clean' 'help'" + @echo "'login-server' - login server" + @echo "'all' - builds all above targets" + @echo "'clean' - cleans builds and objects" + @echo "'help' - outputs this message" ##################################################################### @@ -59,28 +60,31 @@ obj_sql: @echo " MKDIR obj_sql" @-mkdir obj_sql -#executables +# executables login-server: $(LOGIN_SERVER_SQL_DEPENDS) @echo " LD $@" - @$(CC) @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_SQL_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ - + @$(CC) @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ # login object files -obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) +obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql @echo " CC $<" @$(CC) @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< # missing object files ../common/obj_all/common.a: + @echo " MAKE $@" @$(MAKE) -C ../common sql ../common/obj_sql/common_sql.a: + @echo " MAKE $@" @$(MAKE) -C ../common sql $(MT19937AR_OBJ): - @$(MAKE) -C ../../3rdparty/mt19937ar + @echo " MAKE $@" + @$(MAKE) -C $(MT19937AR_D) $(LIBCONFIG_OBJ): - @$(MAKE) -C ../../3rdparty/libconfig + @echo " MAKE $@" + @$(MAKE) -C $(LIBCONFIG_D) -- cgit v1.2.3-70-g09d2 From beaf3a26a60d5b0429a577b7d58232957d4483e7 Mon Sep 17 00:00:00 2001 From: Haru Date: Sat, 21 Sep 2013 20:03:52 +0200 Subject: Added Makefile.in change detection (and auto-rebuild) capabilities - If a Makefile.in is changed, ./config.status (or ./configure in case it's not available) will be automatically run to update the Makefiles. - Special thanks to Yommy for the idea. Signed-off-by: Haru --- 3rdparty/libconfig/Makefile.in | 5 +++- 3rdparty/mt19937ar/Makefile.in | 4 ++++ Makefile.in | 52 ++++++++++++++++++++++++++++-------------- src/char/Makefile.in | 5 +++- src/common/Makefile.in | 15 +++++++----- src/login/Makefile.in | 5 +++- src/map/Makefile.in | 5 +++- src/plugins/Makefile.in | 5 +++- src/test/Makefile.in | 7 ++++-- src/tool/Makefile.in | 7 ++++-- 10 files changed, 78 insertions(+), 32 deletions(-) (limited to 'src/login') diff --git a/3rdparty/libconfig/Makefile.in b/3rdparty/libconfig/Makefile.in index d6714e50e..048a1b3b7 100644 --- a/3rdparty/libconfig/Makefile.in +++ b/3rdparty/libconfig/Makefile.in @@ -24,6 +24,9 @@ help: ##################################################################### -%.o: %.c $(LIBCONFIG_H) +Makefile: Makefile.in + @$(MAKE) -C ../.. 3rdparty/libconfig/Makefile + +%.o: %.c $(LIBCONFIG_H) Makefile @echo " CC $<" @$(CC) @CFLAGS@ @DEFS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/3rdparty/mt19937ar/Makefile.in b/3rdparty/mt19937ar/Makefile.in index 7891bbd2d..c48848c8d 100644 --- a/3rdparty/mt19937ar/Makefile.in +++ b/3rdparty/mt19937ar/Makefile.in @@ -24,6 +24,10 @@ help: ##################################################################### +Makefile: Makefile.in + @$(MAKE) -C ../.. 3rdparty/mt19937ar/Makefile + +%.o: %.c $(LIBCONFIG_H) Makefile %.o: %.c $(MT19937AR_H) @echo " CC $<" @$(CC) @CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< diff --git a/Makefile.in b/Makefile.in index d78aa631d..7dfb138f9 100644 --- a/Makefile.in +++ b/Makefile.in @@ -27,6 +27,10 @@ else PLUGIN_DEPENDS=no_plugins endif +MF_TARGETS = Makefile $(addsuffix /Makefile, src/common 3rdparty/mt19937ar \ + 3rdparty/libconfig src/char src/login src/map src/plugins \ + src/tool src/test) + CC = @CC@ export CC @@ -41,56 +45,73 @@ export CC plugins \ import \ test \ - clean help + clean \ + help all: $(ALL_DEPENDS) sql: $(SQL_DEPENDS) -common_sql: $(COMMON_SQL_DEPENDS) +$(MF_TARGETS): %: %.in + @echo " CONFIGURE" + @if [ -x config.status ]; then \ + echo "Reconfiguring with options: $$(./config.status --config)"; \ + ./config.status; \ + else \ + echo "Unable to find a previous config.status. ./configure will be re-run with the default options."; \ + echo "If you want to use custom options, please press CTRL-C and run ./configure yourself"; \ + for i in 1 2 3 4 5 6 7 8 9 10; do \ + printf "\a. "; \ + sleep 1; \ + done; \ + echo ""; \ + ./configure; \ + fi; + +common_sql: $(COMMON_SQL_DEPENDS) src/common/Makefile @echo " MAKE $@" @$(MAKE) -C src/common sql -mt19937ar: +mt19937ar: 3rdparty/mt19937ar/Makefile @echo " MAKE $@" @$(MAKE) -C 3rdparty/mt19937ar -libconfig: +libconfig: 3rdparty/libconfig/Makefile @echo " MAKE $@" @$(MAKE) -C 3rdparty/libconfig -login_sql: $(LOGIN_SQL_DEPENDS) +login_sql: $(LOGIN_SQL_DEPENDS) src/login/Makefile @echo " MAKE $@" @$(MAKE) -C src/login sql -char_sql: $(CHAR_SQL_DEPENDS) +char_sql: $(CHAR_SQL_DEPENDS) src/char/Makefile @echo " MAKE $@" @$(MAKE) -C src/char -map_sql: $(MAP_SQL_DEPENDS) +map_sql: $(MAP_SQL_DEPENDS) src/map/Makefile @echo " MAKE $@" @$(MAKE) -C src/map sql -tools: $(TOOLS_DEPENDS) +tools: $(TOOLS_DEPENDS) src/tool/Makefile @echo " MAKE $@" @$(MAKE) -C src/tool -test: +test: src/test/Makefile @echo " MAKE $@" @$(MAKE) -C src/test -plugins: $(PLUGIN_DEPENDS) +plugins: $(PLUGIN_DEPENDS) src/plugins/Makefile @echo " MAKE $@" @$(MAKE) -C src/plugins -import: +import: Makefile @# 1) create conf/import folder @# 2) add missing files @echo "building conf/import folder..." @if test ! -d conf/import ; then mkdir conf/import ; fi @for f in $$(ls conf/import-tmpl) ; do if test ! -e conf/import/$$f ; then cp conf/import-tmpl/$$f conf/import ; fi ; done -clean: +clean: $(MF_TARGETS) @$(MAKE) -C src/common $@ @$(MAKE) -C 3rdparty/mt19937ar $@ @$(MAKE) -C 3rdparty/libconfig $@ @@ -102,12 +123,9 @@ clean: @$(MAKE) -C src/test $@ distclean: clean - @-rm -f Makefile src/common/Makefile 3rdparty/mt19937ar/Makefile \ - 3rdparty/libconfig/Makefile src/char/Makefile src/login/Makefile \ - src/map/Makefile src/plugins/Makefile src/tool/Makefile \ - src/test/Makefile + @-rm -f $(MF_TARGETS) config.status config.log -help: +help: Makefile @echo "most common targets are 'all' 'sql' 'clean' 'plugins' 'help'" @echo "possible targets are:" @echo "'common_sql' - builds object files used in SQL servers" diff --git a/src/char/Makefile.in b/src/char/Makefile.in index b2cee3f88..e22d3f5a5 100644 --- a/src/char/Makefile.in +++ b/src/char/Makefile.in @@ -57,6 +57,9 @@ needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 +Makefile: Makefile.in + @$(MAKE) -C ../.. src/char/Makefile + # object directories obj_sql: @@ -65,7 +68,7 @@ obj_sql: # executables -char-server: $(CHAR_SERVER_SQL_DEPENDS) +char-server: $(CHAR_SERVER_SQL_DEPENDS) Makefile @echo " LD $@" @$(CC) @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ diff --git a/src/common/Makefile.in b/src/common/Makefile.in index 00d63dd5e..78f9cd0d1 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -59,6 +59,9 @@ help: ##################################################################### +Makefile: Makefile.in + @$(MAKE) -C ../.. src/common/Makefile + needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 @@ -73,23 +76,23 @@ obj_sql: @echo " MKDIR obj_sql" @-mkdir obj_sql -obj_all/common.a: $(COMMON_OBJ) +obj_all/common.a: $(COMMON_OBJ) Makefile @echo " AR $@" @@AR@ rcs obj_all/common.a $(COMMON_OBJ) -obj_all/common_mini.a: $(COMMON_MINI_OBJ) +obj_all/common_mini.a: $(COMMON_MINI_OBJ) Makefile @echo " AR $@" @@AR@ rcs obj_all/common_mini.a $(COMMON_MINI_OBJ) -obj_sql/common_sql.a: $(COMMON_SQL_OBJ) +obj_sql/common_sql.a: $(COMMON_SQL_OBJ) Makefile @echo " AR $@" @@AR@ rcs obj_sql/common_sql.a $(COMMON_SQL_OBJ) -common: $(COMMON_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common.a +common: $(COMMON_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common.a Makefile -common_mini: $(COMMON_MINI_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common_mini.a +common_mini: $(COMMON_MINI_OBJ) $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) obj_all/common_mini.a Makefile -common_sql: $(COMMON_SQL_OBJ) obj_sql/common_sql.a +common_sql: $(COMMON_SQL_OBJ) obj_sql/common_sql.a Makefile obj_all/%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_all @echo " CC $<" diff --git a/src/login/Makefile.in b/src/login/Makefile.in index 125f4fb7a..681eb5e6f 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -50,6 +50,9 @@ help: ##################################################################### +Makefile: Makefile.in + @$(MAKE) -C ../.. src/login/Makefile + needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 @@ -62,7 +65,7 @@ obj_sql: # executables -login-server: $(LOGIN_SERVER_SQL_DEPENDS) +login-server: $(LOGIN_SERVER_SQL_DEPENDS) Makefile @echo " LD $@" @$(CC) @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ diff --git a/src/map/Makefile.in b/src/map/Makefile.in index ed1b9a79d..f7e178667 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -66,6 +66,9 @@ help: ##################################################################### +Makefile: Makefile.in + @$(MAKE) -C ../.. src/map/Makefile + needs_mysql: @echo "MySQL not found or disabled by the configure script" @exit 1 @@ -78,7 +81,7 @@ obj_sql: # executables -map-server: $(MAP_SERVER_SQL_DEPENDS) +map-server: $(MAP_SERVER_SQL_DEPENDS) Makefile @echo " LD $@" @$(CC) @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ diff --git a/src/plugins/Makefile.in b/src/plugins/Makefile.in index 5ed421abf..ff7d5b2e2 100644 --- a/src/plugins/Makefile.in +++ b/src/plugins/Makefile.in @@ -11,7 +11,7 @@ export CC ##################################################################### .PHONY: all $(PLUGINS) sample db2sql clean help -all: $(PLUGINS) +all: $(PLUGINS) Makefile sample: sample@DLLEXT@ @@ -28,6 +28,9 @@ help: ##################################################################### +Makefile: Makefile.in + @$(MAKE) -C ../.. src/plugins/Makefile + %@DLLEXT@: %.c $(COMMON_H) @echo " CC $<" @$(CC) @DEFS@ @CFLAGS@ @CPPFLAGS@ @LDFLAGS@ @SOFLAGS@ -o ../../plugins/$@ $< diff --git a/src/test/Makefile.in b/src/test/Makefile.in index f17c43202..cb99e7004 100644 --- a/src/test/Makefile.in +++ b/src/test/Makefile.in @@ -26,7 +26,7 @@ export CC ##################################################################### .PHONY: all test_spinlock -all: test_spinlock +all: test_spinlock Makefile clean: @echo " CLEAN test" @@ -34,6 +34,9 @@ clean: ##################################################################### +Makefile: Makefile.in + @$(MAKE) -C ../.. src/test/Makefile + # object directories obj: @@ -42,7 +45,7 @@ obj: #executables -test_spinlock: $(TEST_SPINLOCK_DEPENDS) +test_spinlock: $(TEST_SPINLOCK_DEPENDS) Makefile @echo " LD $@" @$(CC) @LDFLAGS@ -o ../../test_spinlock@EXEEXT@ $(TEST_SPINLOCK_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 4fa527ffc..4f9dc7590 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -24,9 +24,9 @@ export CC ##################################################################### .PHONY: all mapcache clean help -all: mapcache +all: mapcache Makefile -mapcache: $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) +mapcache: $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) Makefile @echo " LD $@" @$(CC) @LDFLAGS@ $(LIBCONFIG_INCLUDE) -o ../../mapcache@EXEEXT@ $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @@ -43,6 +43,9 @@ help: ##################################################################### +Makefile: Makefile.in + @$(MAKE) -C ../.. src/tool/Makefile + obj_all: @echo " MKDIR obj_all" @-mkdir obj_all -- cgit v1.2.3-70-g09d2 From 469102135fd5429a4225afe378bed3e82dc81d31 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 22 Sep 2013 09:56:48 +0200 Subject: Corrected various hardcoded database table names - Added an elemental_db setting to inter-server.conf (elemental table) - Switched an instance of hardcoded `ipbanlist` to use the ipban_table setting; thanks to Takkun, related to issue #135 - Switched two instances of hardcoded `char` to use the char_db setting - Added a TODO notice about the usage of the login table (on a side note, hardcoded) from the login server (related to issue #142) Signed-off-by: Haru --- conf/inter-server.conf | 1 + src/char/char.c | 6 +++++- src/char/char.h | 1 + src/char/int_elemental.c | 26 ++++++++++++++------------ src/char/inter.c | 5 +++-- src/login/ipban_sql.c | 2 +- 6 files changed, 25 insertions(+), 16 deletions(-) (limited to 'src/login') diff --git a/conf/inter-server.conf b/conf/inter-server.conf index 468cf5a26..09ac15f82 100644 --- a/conf/inter-server.conf +++ b/conf/inter-server.conf @@ -108,6 +108,7 @@ skill_homunculus_db: skill_homunculus mercenary_db: mercenary mercenary_owner_db: mercenary_owner ragsrvinfo_db: ragsrvinfo +elemental_db: elemental // Map Database Tables item_db_db: item_db diff --git a/src/char/char.c b/src/char/char.c index dc7966e8d..cbc987f0d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -68,6 +68,7 @@ char skill_homunculus_db[256] = "skill_homunculus"; char mercenary_db[256] = "mercenary"; char mercenary_owner_db[256] = "mercenary_owner"; char ragsrvinfo_db[256] = "ragsrvinfo"; +char elemental_db[256] = "elemental"; char interreg_db[32] = "interreg"; // show loading/saving messages @@ -2819,7 +2820,8 @@ int parse_frommap(int fd) int aid, cid; aid = RFIFOL(fd,2); cid = RFIFOL(fd,6); - if( SQL_ERROR == SQL->Query(sql_handle, "SELECT type, tick, val1, val2, val3, val4 from `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", + if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` " + "FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'", scdata_db, aid, cid) ) { Sql_ShowDebug(sql_handle); @@ -4715,6 +4717,8 @@ void sql_config_read(const char* cfgName) safestrncpy(mercenary_owner_db,w2,sizeof(mercenary_owner_db)); else if(!strcmpi(w1,"ragsrvinfo_db")) safestrncpy(ragsrvinfo_db,w2,sizeof(ragsrvinfo_db)); + else if(!strcmpi(w1,"elemental_db")) + safestrncpy(elemental_db,w2,sizeof(elemental_db)); else if(!strcmpi(w1,"interreg_db")) safestrncpy(interreg_db,w2,sizeof(interreg_db)); //support the import command, just like any other config diff --git a/src/char/char.h b/src/char/char.h index d98ce9004..a3bbdd904 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -103,6 +103,7 @@ extern char skill_homunculus_db[256]; extern char mercenary_db[256]; extern char mercenary_owner_db[256]; extern char ragsrvinfo_db[256]; +extern char elemental_db[256]; extern char interreg_db[32]; extern int db_use_sql_item_db; diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index 53a63a212..ed0c2a9ed 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -21,9 +21,9 @@ bool mapif_elemental_save(struct s_elemental* ele) { if( ele->elemental_id == 0 ) { // Create new DB entry if( SQL_ERROR == SQL->Query(sql_handle, - "INSERT INTO `elemental` (`char_id`,`class`,`mode`,`hp`,`sp`,`max_hp`,`max_sp`,`atk1`,`atk2`,`matk`,`aspd`,`def`,`mdef`,`flee`,`hit`,`life_time`)" - "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%u')", - ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2, ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time) ) + "INSERT INTO `%s` (`char_id`,`class`,`mode`,`hp`,`sp`,`max_hp`,`max_sp`,`atk1`,`atk2`,`matk`,`aspd`,`def`,`mdef`,`flee`,`hit`,`life_time`)" + "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%u')", + elemental_db, ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2, ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time) ) { Sql_ShowDebug(sql_handle); flag = false; @@ -31,11 +31,11 @@ bool mapif_elemental_save(struct s_elemental* ele) { else ele->elemental_id = (int)SQL->LastInsertId(sql_handle); } else if( SQL_ERROR == SQL->Query(sql_handle, - "UPDATE `elemental` SET `char_id` = '%d', `class` = '%d', `mode` = '%d', `hp` = '%d', `sp` = '%d'," - "`max_hp` = '%d', `max_sp` = '%d', `atk1` = '%d', `atk2` = '%d', `matk` = '%d', `aspd` = '%d', `def` = '%d'," - "`mdef` = '%d', `flee` = '%d', `hit` = '%d', `life_time` = '%u' WHERE `ele_id` = '%d'", - ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2, - ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time, ele->elemental_id) ) + "UPDATE `%s` SET `char_id` = '%d', `class` = '%d', `mode` = '%d', `hp` = '%d', `sp` = '%d'," + "`max_hp` = '%d', `max_sp` = '%d', `atk1` = '%d', `atk2` = '%d', `matk` = '%d', `aspd` = '%d', `def` = '%d'," + "`mdef` = '%d', `flee` = '%d', `hit` = '%d', `life_time` = '%u' WHERE `ele_id` = '%d'", + elemental_db, ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2, + ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time, ele->elemental_id) ) { // Update DB entry Sql_ShowDebug(sql_handle); flag = false; @@ -50,9 +50,11 @@ bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) { ele->elemental_id = ele_id; ele->char_id = char_id; - if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `atk1`, `atk2`, `matk`, `aspd`," - "`def`, `mdef`, `flee`, `hit`, `life_time` FROM `elemental` WHERE `ele_id` = '%d' AND `char_id` = '%d'", - ele_id, char_id) ) { + if( SQL_ERROR == SQL->Query(sql_handle, + "SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `atk1`, `atk2`, `matk`, `aspd`," + "`def`, `mdef`, `flee`, `hit`, `life_time` FROM `%s` WHERE `ele_id` = '%d' AND `char_id` = '%d'", + elemental_db, ele_id, char_id) ) + { Sql_ShowDebug(sql_handle); return false; } @@ -85,7 +87,7 @@ bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) { } bool mapif_elemental_delete(int ele_id) { - if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `elemental` WHERE `ele_id` = '%d'", ele_id) ) { + if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `ele_id` = '%d'", elemental_db, ele_id) ) { Sql_ShowDebug(sql_handle); return false; } diff --git a/src/char/inter.c b/src/char/inter.c index 1ff2bca61..4eb4f0c0a 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -451,7 +451,7 @@ void mapif_parse_accinfo(int fd) { account_id = atoi(query); if (account_id < START_ACCOUNT_NUM) { // is string - if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `char` WHERE `name` LIKE '%s' LIMIT 10", query_esq) + if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq) || SQL->NumRows(sql_handle) == 0 ) { if( SQL->NumRows(sql_handle) == 0 ) { inter_to_fd(fd, u_fd, aid, "No matches were found for your criteria, '%s'",query); @@ -493,6 +493,7 @@ void mapif_parse_accinfo(int fd) { char userid[NAME_LENGTH], user_pass[NAME_LENGTH], email[40], last_ip[20], lastlogin[30], pincode[5], birthdate[11]; short level = -1; int logincount = 0,state = 0; + // FIXME: No, this doesn't really look right. We can't, and shouldn't, access the login table from the char server. if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `userid`, `user_pass`, `email`, `last_ip`, `group_id`, `lastlogin`, `logincount`, `state`,`pincode`,`birthdate` FROM `login` WHERE `account_id` = '%d' LIMIT 1", account_id) || SQL->NumRows(sql_handle) == 0 ) { if( SQL->NumRows(sql_handle) == 0 ) { @@ -536,7 +537,7 @@ void mapif_parse_accinfo(int fd) { inter_to_fd(fd, u_fd, aid, "-- Character Details --" ); - if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` FROM `char` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", account_id, MAX_CHARS) + if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` FROM `%s` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", char_db, account_id, MAX_CHARS) || SQL->NumRows(sql_handle) == 0 ) { if( SQL->NumRows(sql_handle) == 0 ) diff --git a/src/login/ipban_sql.c b/src/login/ipban_sql.c index fd9f1a4a1..d037a5ddc 100644 --- a/src/login/ipban_sql.c +++ b/src/login/ipban_sql.c @@ -252,7 +252,7 @@ int ipban_cleanup(int tid, unsigned int tick, int id, intptr_t data) if( !login_config.ipban ) return 0;// ipban disabled - if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `ipbanlist` WHERE `rtime` <= NOW()") ) + if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `rtime` <= NOW()", ipban_table) ) Sql_ShowDebug(sql_handle); return 0; -- cgit v1.2.3-70-g09d2 From 233453c7d2e256aece37ece349fe4890cdeb4586 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 22 Sep 2013 10:20:44 +0200 Subject: Changed Makefiles to avoid rebuilding targets if nothing was modified To force a rebuild, it's still possible to use the -B flag of make, or just run make clean beforehand. Signed-off-by: Haru --- src/char/Makefile.in | 6 ++++-- src/login/Makefile.in | 6 ++++-- src/map/Makefile.in | 6 ++++-- src/tool/Makefile.in | 6 ++++-- 4 files changed, 16 insertions(+), 8 deletions(-) (limited to 'src/login') diff --git a/src/char/Makefile.in b/src/char/Makefile.in index e22d3f5a5..02759b32e 100644 --- a/src/char/Makefile.in +++ b/src/char/Makefile.in @@ -68,8 +68,10 @@ obj_sql: # executables -char-server: $(CHAR_SERVER_SQL_DEPENDS) Makefile - @echo " LD $@" +char-server: ../../char-server@EXEEXT@ + +../../char-server@EXEEXT@: $(CHAR_SERVER_SQL_DEPENDS) Makefile + @echo " LD $(notdir $@)" @$(CC) @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ # char object files diff --git a/src/login/Makefile.in b/src/login/Makefile.in index 681eb5e6f..b6b70a495 100644 --- a/src/login/Makefile.in +++ b/src/login/Makefile.in @@ -65,8 +65,10 @@ obj_sql: # executables -login-server: $(LOGIN_SERVER_SQL_DEPENDS) Makefile - @echo " LD $@" +login-server: ../../login-server@EXEEXT@ + +../../login-server@EXEEXT@: $(LOGIN_SERVER_SQL_DEPENDS) Makefile + @echo " LD $(notdir $@)" @$(CC) @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@ # login object files diff --git a/src/map/Makefile.in b/src/map/Makefile.in index f7e178667..fb78d51a1 100644 --- a/src/map/Makefile.in +++ b/src/map/Makefile.in @@ -81,8 +81,10 @@ obj_sql: # executables -map-server: $(MAP_SERVER_SQL_DEPENDS) Makefile - @echo " LD $@" +map-server: ../../map-server@EXEEXT@ + +../../map-server@EXEEXT@: $(MAP_SERVER_SQL_DEPENDS) Makefile + @echo " LD $(notdir $@)" @$(CC) @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@ # map object files diff --git a/src/tool/Makefile.in b/src/tool/Makefile.in index 4f9dc7590..baf4a0327 100644 --- a/src/tool/Makefile.in +++ b/src/tool/Makefile.in @@ -26,8 +26,10 @@ export CC all: mapcache Makefile -mapcache: $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) Makefile - @echo " LD $@" +mapcache: ../../mapcache@EXEEXT@ + +../../mapcache@EXEEXT@: $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) Makefile + @echo " LD $(notdir $@)" @$(CC) @LDFLAGS@ $(LIBCONFIG_INCLUDE) -o ../../mapcache@EXEEXT@ $(MAPCACHE_OBJ) $(COMMON_OBJ) $(LIBCONFIG_OBJ) @LIBS@ clean: -- cgit v1.2.3-70-g09d2