Merged TXT removal branch back to trunk.
* TXT save engine is removed and no longer supported. * See also tid:53926, tid:57717. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15503 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
7a30325ab1
commit
bf1c81839f
@ -443,7 +443,6 @@ set( DEVELOPMENT_FILES
|
||||
set( DEVELOPMENT_DIRECTORIES
|
||||
"3rdparty"
|
||||
"conf/import-tmpl"
|
||||
"save-tmpl"
|
||||
"src"
|
||||
"vcproj-9"
|
||||
"vcproj-10"
|
||||
@ -452,21 +451,17 @@ set( RUNTIME_FILES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/athena-start"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char-server.sh"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/charserv-sql.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/charserv.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/dbghelp.dll"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/libmysql.dll"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/login-server.sh"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/logserv-sql.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/logserv.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/map-server.sh"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mapserv-sql.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/mapserv.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/notice.txt"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/pcre3.dll"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/readme.html"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/runserver-sql.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/runserver.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/serv.bat"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/start"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/zlib1.dll"
|
||||
@ -511,7 +506,6 @@ endif()
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
# templates
|
||||
set( _TEMPLATES
|
||||
"save-tmpl" "save"
|
||||
"conf/import-tmpl" "conf/import"
|
||||
)
|
||||
set( INSTALL_TEMPLATES_FILE "${CMAKE_CURRENT_BINARY_DIR}/InstallTemplates.cmake" )
|
||||
|
73
Makefile.in
73
Makefile.in
@ -2,76 +2,56 @@
|
||||
|
||||
HAVE_MYSQL=@HAVE_MYSQL@
|
||||
ifeq ($(HAVE_MYSQL),yes)
|
||||
ALL_DEPENDS=mt19937ar common common_sql login login_sql char char_sql map map_sql tools converters import save
|
||||
SQL_DEPENDS=mt19937ar common_sql login_sql char_sql map_sql import save
|
||||
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
|
||||
CONVERTERS_DEPENDS=common_sql
|
||||
else
|
||||
ALL_DEPENDS=mt19937ar common login char map tools import save
|
||||
ALL_DEPENDS=needs_mysql
|
||||
SQL_DEPENDS=needs_mysql
|
||||
COMMON_SQL_DEPENDS=needs_mysql
|
||||
LOGIN_SQL_DEPENDS=needs_mysql
|
||||
CHAR_SQL_DEPENDS=needs_mysql
|
||||
MAP_SQL_DEPENDS=needs_mysql
|
||||
CONVERTERS_DEPENDS=needs_mysql
|
||||
endif
|
||||
COMMON_TXT_DEPENDS=mt19937ar
|
||||
LOGIN_TXT_DEPENDS=mt19937ar common
|
||||
CHAR_TXT_DEPENDS=mt19937ar common
|
||||
MAP_TXT_DEPENDS=mt19937ar common
|
||||
|
||||
WITH_PLUGINS=@WITH_PLUGINS@
|
||||
ifeq ($(WITH_PLUGINS),yes)
|
||||
ALL_DEPENDS+=plugins
|
||||
PLUGIN_DEPENDS=common
|
||||
PLUGIN_DEPENDS=common_sql
|
||||
else
|
||||
PLUGIN_DEPENDS=no_plugins
|
||||
endif
|
||||
|
||||
#####################################################################
|
||||
.PHONY: txt sql conf \
|
||||
common common_sql \
|
||||
.PHONY: sql \
|
||||
common_sql \
|
||||
mt19937ar \
|
||||
login login_sql \
|
||||
char char_sql \
|
||||
map map_sql \
|
||||
tools converters plugins addons import save \
|
||||
login_sql \
|
||||
char_sql \
|
||||
map_sql \
|
||||
tools plugins addons \
|
||||
import \
|
||||
clean help
|
||||
|
||||
all: $(ALL_DEPENDS)
|
||||
|
||||
txt: common login char map import save
|
||||
|
||||
sql: $(SQL_DEPENDS)
|
||||
|
||||
conf: import save
|
||||
|
||||
common: $(COMMON_TXT_DEPENDS)
|
||||
@$(MAKE) -C src/common txt
|
||||
|
||||
common_sql: $(COMMON_SQL_DEPENDS)
|
||||
@$(MAKE) -C src/common sql
|
||||
|
||||
mt19937ar:
|
||||
@$(MAKE) -C 3rdparty/mt19937ar
|
||||
|
||||
login: $(LOGIN_TXT_DEPENDS)
|
||||
@$(MAKE) -C src/login txt
|
||||
|
||||
login_sql: $(LOGIN_SQL_DEPENDS)
|
||||
@$(MAKE) -C src/login sql
|
||||
|
||||
char: $(CHAR_TXT_DEPENDS)
|
||||
@$(MAKE) -C src/char
|
||||
|
||||
char_sql: $(CHAR_SQL_DEPENDS)
|
||||
@$(MAKE) -C src/char_sql
|
||||
|
||||
map: $(MAP_TXT_DEPENDS)
|
||||
@$(MAKE) -C src/map txt
|
||||
@$(MAKE) -C src/char
|
||||
|
||||
map_sql: $(MAP_SQL_DEPENDS)
|
||||
@$(MAKE) -C src/map sql
|
||||
@ -79,12 +59,9 @@ map_sql: $(MAP_SQL_DEPENDS)
|
||||
tools:
|
||||
@$(MAKE) -C src/tool
|
||||
|
||||
converters: $(CONVERTERS_DEPENDS)
|
||||
@$(MAKE) -C src/txt-converter
|
||||
|
||||
plugins addons: $(PLUGIN_DEPENDS)
|
||||
@$(MAKE) -C src/plugins
|
||||
|
||||
|
||||
import:
|
||||
# 1) create conf/import folder
|
||||
# 2) add missing files
|
||||
@ -94,50 +71,30 @@ import:
|
||||
@for f in $$(ls conf/import-tmpl) ; do if test ! -e conf/import/$$f ; then cp conf/import-tmpl/$$f conf/import ; fi ; done
|
||||
@rm -rf conf/import/.svn
|
||||
|
||||
save:
|
||||
# 1) create save folder
|
||||
# 2) add missing files
|
||||
# 3) remove remaining .svn folder
|
||||
@echo "building save folder..."
|
||||
@if test ! -d save ; then mkdir save ; fi
|
||||
@for f in $$(ls save-tmpl) ; do if test ! -e save/$$f ; then cp save-tmpl/$$f save ; fi ; done
|
||||
@rm -rf save/.svn
|
||||
|
||||
clean:
|
||||
@$(MAKE) -C src/common $@
|
||||
@$(MAKE) -C 3rdparty/mt19937ar $@
|
||||
@$(MAKE) -C src/login $@
|
||||
@$(MAKE) -C src/char $@
|
||||
@$(MAKE) -C src/char_sql $@
|
||||
@$(MAKE) -C src/map $@
|
||||
@$(MAKE) -C src/plugins $@
|
||||
@$(MAKE) -C src/tool $@
|
||||
@$(MAKE) -C src/txt-converter $@
|
||||
|
||||
help:
|
||||
@echo "most common targets are 'all' 'txt' 'sql' 'conf' 'clean' 'help'"
|
||||
@echo "most common targets are 'all' 'sql' 'conf' 'clean' 'help'"
|
||||
@echo "possible targets are:"
|
||||
@echo "'common' - builds object files used in TXT servers"
|
||||
@echo "'common_sql' - builds object files used in SQL servers"
|
||||
@echo "'mt19937ar' - builds object file of Mersenne Twister MT19937"
|
||||
@echo "'login' - builds login server (TXT version)"
|
||||
@echo "'login_sql' - builds login server (SQL version)"
|
||||
@echo "'char' - builds char server (TXT version)"
|
||||
@echo "'char_sql' - builds char server (SQL version)"
|
||||
@echo "'map' - builds map server (TXT version)"
|
||||
@echo "'map_sql' - builds map server (SQL version)"
|
||||
@echo "'tools' - builds all the tools in src/tools"
|
||||
@echo "'converters' - builds the login/char converters"
|
||||
@echo "'plugins' - builds all the plugins in src/plugins"
|
||||
@echo "'addons'"
|
||||
@echo "'import' - builds conf/import folder from the template conf/import-tmpl"
|
||||
@echo "'save' - builds save folder from the template save-tmpl"
|
||||
@echo "'all' - builds all the above targets"
|
||||
@echo "'txt' - builds txt servers (targets 'common' 'login' 'char' 'map'"
|
||||
@echo " 'import' and 'save')"
|
||||
@echo "'sql' - builds sql servers (targets 'common_sql' 'login_sql' 'char_sql'"
|
||||
@echo " 'map_sql' 'import' and 'save')"
|
||||
@echo "'conf' - builds templated folders/files (targets 'import' and 'save')"
|
||||
@echo " 'map_sql' and 'import')"
|
||||
@echo "'clean' - cleans builds and objects"
|
||||
@echo "'help' - outputs this message"
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
@ECHO OFF
|
||||
CALL serv.bat char-server.exe Char-Server
|
@ -104,12 +104,6 @@ autosave_time: 60
|
||||
// Display information on the console whenever characters/guilds/parties/pets are loaded/saved?
|
||||
save_log: yes
|
||||
|
||||
// Character server flatfile database
|
||||
char_txt: save/athena.txt
|
||||
|
||||
// Friends list flatfile database
|
||||
friends_txt: save/friends.txt
|
||||
|
||||
// Start point, Map name followed by coordinates (x,y)
|
||||
start_point: new_1-1,53,111
|
||||
|
||||
|
@ -11,37 +11,6 @@ inter_log_filename: log/inter.log
|
||||
// Level range for sharing within a party
|
||||
party_share_level: 15
|
||||
|
||||
|
||||
// TXT version options only
|
||||
|
||||
// Storage flatfile database, used for Karfa storage.
|
||||
storage_txt: save/storage.txt
|
||||
|
||||
// Party flatfile database, for party names, members and other party info.
|
||||
party_txt: save/party.txt
|
||||
|
||||
// Hotkeys flatfile database, where character skill shortcuts are stored.
|
||||
hotkeys_txt: save/hotkeys.txt
|
||||
|
||||
// Guild flatfile database, for guild names, members, and other guild info.
|
||||
guild_txt: save/guild.txt
|
||||
|
||||
// Pet flatfile database, for pet names, and other pet info.
|
||||
pet_txt: save/pet.txt
|
||||
|
||||
// Homunculus flatfile database, for homunculus information.
|
||||
homun_txt: save/homun.txt
|
||||
|
||||
// Castle flatfile database, for emperium war castles, etc.
|
||||
castle_txt: save/castle.txt
|
||||
|
||||
// Status change flatfile database, for status changes that are saved between sessions.
|
||||
scdata_txt: save/scdata.txt
|
||||
|
||||
// Mapserver permanent script variables ($-type)
|
||||
mapreg_txt: save/mapreg.txt
|
||||
|
||||
|
||||
// SQL version options only
|
||||
|
||||
// You can specify the codepage to use in your mySQL tables here.
|
||||
|
@ -117,9 +117,6 @@ dnsbl_servers: dnsbl.deltaanime.net
|
||||
account.engine: auto
|
||||
|
||||
// Account data storage configuration
|
||||
// TXT
|
||||
account.txt.account_db: save/account.txt
|
||||
account.txt.case_sensitive: no
|
||||
// SQL
|
||||
//account.sql.db_hostname: 127.0.0.1
|
||||
//account.sql.db_port: 3306
|
||||
|
99
configure
vendored
99
configure
vendored
@ -868,9 +868,8 @@ Optional Packages:
|
||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
|
||||
--with-mysql[=ARG]
|
||||
use MySQL client library, optionally specify the
|
||||
path to the mysql_config executable (by default
|
||||
mysql is used if found)
|
||||
optionally specify the path to the mysql_config
|
||||
executable
|
||||
--with-MYSQL_CFLAGS=ARG specify MYSQL_CFLAGS manually (instead of using
|
||||
"mysql_config --include")
|
||||
--with-MYSQL_LIBS=ARG specify MYSQL_LIBS manually (instead of using
|
||||
@ -1339,8 +1338,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||
|
||||
ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile"
|
||||
|
||||
ac_config_files="$ac_config_files src/char_sql/Makefile src/txt-converter/Makefile"
|
||||
|
||||
ac_config_files="$ac_config_files src/map/Makefile src/plugins/Makefile src/tool/Makefile"
|
||||
|
||||
|
||||
@ -1486,30 +1483,22 @@ fi;
|
||||
|
||||
|
||||
#
|
||||
# Enable/disable MySql and optionally specify the path to mysql_config (optional library)
|
||||
# Optionally specify the path to mysql_config
|
||||
#
|
||||
|
||||
# Check whether --with-mysql or --without-mysql was given.
|
||||
if test "${with_mysql+set}" = set; then
|
||||
withval="$with_mysql"
|
||||
|
||||
if test "$withval" = "no" ; then
|
||||
want_mysql="no"
|
||||
else
|
||||
want_mysql="yes"
|
||||
require_mysql="yes"
|
||||
if test "$withval" != "yes" ; then
|
||||
if test ! -x "$withval" ; then
|
||||
{ { echo "$as_me:$LINENO: error: $withval is not an executable file" >&5
|
||||
if test "$withval" != "no" ; then
|
||||
if test ! -x "$withval" ; then
|
||||
{ { echo "$as_me:$LINENO: error: $withval is not an executable file" >&5
|
||||
echo "$as_me: error: $withval is not an executable file" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi
|
||||
MYSQL_CONFIG_HOME="$withval"
|
||||
fi
|
||||
MYSQL_CONFIG_HOME="$withval"
|
||||
fi
|
||||
|
||||
else
|
||||
want_mysql="yes" require_mysql="no"
|
||||
|
||||
fi;
|
||||
|
||||
@ -5096,18 +5085,11 @@ fi
|
||||
|
||||
|
||||
#
|
||||
# MySQL library (optional)
|
||||
# MySQL library
|
||||
#
|
||||
|
||||
if test "$want_mysql" = "no" ; then
|
||||
MYSQL_VERSION=""
|
||||
MYSQL_CFLAGS=""
|
||||
MYSQL_LIBS=""
|
||||
{ echo "$as_me:$LINENO: ignoring MySQL (optional)" >&5
|
||||
echo "$as_me: ignoring MySQL (optional)" >&6;}
|
||||
else
|
||||
if test -z "$MYSQL_CONFIG_HOME"; then
|
||||
# Extract the first word of "mysql_config", so it can be a program name with args.
|
||||
if test -z "$MYSQL_CONFIG_HOME"; then
|
||||
# Extract the first word of "mysql_config", so it can be a program name with args.
|
||||
set dummy mysql_config; ac_word=$2
|
||||
echo "$as_me:$LINENO: checking for $ac_word" >&5
|
||||
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
|
||||
@ -5147,23 +5129,23 @@ else
|
||||
echo "${ECHO_T}no" >&6
|
||||
fi
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
if test "$MYSQL_CONFIG_HOME" != "no" ; then
|
||||
MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
|
||||
if test "$manual_MYSQL_CFLAGS" = "no" ; then
|
||||
MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
|
||||
fi
|
||||
if test "$manual_MYSQL_LIBS" = "no" ; then
|
||||
MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
|
||||
fi
|
||||
else
|
||||
MYSQL_VERSION="unknown"
|
||||
if test "$MYSQL_CONFIG_HOME" != "no" ; then
|
||||
MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
|
||||
if test "$manual_MYSQL_CFLAGS" = "no" ; then
|
||||
MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
|
||||
fi
|
||||
if test "$manual_MYSQL_LIBS" = "no" ; then
|
||||
MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
|
||||
fi
|
||||
else
|
||||
MYSQL_VERSION="unknown"
|
||||
fi
|
||||
|
||||
MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
|
||||
MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
|
||||
echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5
|
||||
MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
|
||||
MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
|
||||
echo "$as_me:$LINENO: checking for mysql_init in -lmysqlclient" >&5
|
||||
echo $ECHO_N "checking for mysql_init in -lmysqlclient... $ECHO_C" >&6
|
||||
if test "${ac_cv_lib_mysqlclient_mysql_init+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
@ -5231,7 +5213,7 @@ if test $ac_cv_lib_mysqlclient_mysql_init = yes; then
|
||||
HAVE_MYSQL="yes"
|
||||
fi
|
||||
|
||||
if test "${ac_cv_header_mysql_h+set}" = set; then
|
||||
if test "${ac_cv_header_mysql_h+set}" = set; then
|
||||
echo "$as_me:$LINENO: checking for mysql.h" >&5
|
||||
echo $ECHO_N "checking for mysql.h... $ECHO_C" >&6
|
||||
if test "${ac_cv_header_mysql_h+set}" = set; then
|
||||
@ -5375,29 +5357,20 @@ else
|
||||
fi
|
||||
|
||||
|
||||
CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
|
||||
LDFLAGS="$MYSQL_OLD_LDFLAGS"
|
||||
CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
|
||||
LDFLAGS="$MYSQL_OLD_LDFLAGS"
|
||||
|
||||
echo "$as_me:$LINENO: checking MySQL library (optional)" >&5
|
||||
echo $ECHO_N "checking MySQL library (optional)... $ECHO_C" >&6
|
||||
if test "$HAVE_MYSQL" = "yes" ; then
|
||||
echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5
|
||||
echo "$as_me:$LINENO: checking MySQL library (required)" >&5
|
||||
echo $ECHO_N "checking MySQL library (required)... $ECHO_C" >&6
|
||||
if test "$HAVE_MYSQL" = "yes" ; then
|
||||
echo "$as_me:$LINENO: result: yes ($MYSQL_VERSION)" >&5
|
||||
echo "${ECHO_T}yes ($MYSQL_VERSION)" >&6
|
||||
else
|
||||
echo "$as_me:$LINENO: result: no" >&5
|
||||
else
|
||||
echo "$as_me:$LINENO: result: no" >&5
|
||||
echo "${ECHO_T}no" >&6
|
||||
if test "$require_mysql" = "yes" ; then
|
||||
{ { echo "$as_me:$LINENO: error: MySQL not found or incompatible (requested)" >&5
|
||||
echo "$as_me: error: MySQL not found or incompatible (requested)" >&2;}
|
||||
{ { echo "$as_me:$LINENO: error: MySQL not found or incompatible" >&5
|
||||
echo "$as_me: error: MySQL not found or incompatible" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
else
|
||||
{ echo "$as_me:$LINENO: disabling MySQL (optional)" >&5
|
||||
echo "$as_me: disabling MySQL (optional)" >&6;}
|
||||
MYSQL_VERSION=""
|
||||
MYSQL_CFLAGS=""
|
||||
MYSQL_LIBS=""
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@ -6195,8 +6168,6 @@ do
|
||||
"3rdparty/mt19937ar/Makefile" ) CONFIG_FILES="$CONFIG_FILES 3rdparty/mt19937ar/Makefile" ;;
|
||||
"src/char/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char/Makefile" ;;
|
||||
"src/login/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;;
|
||||
"src/char_sql/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/char_sql/Makefile" ;;
|
||||
"src/txt-converter/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/txt-converter/Makefile" ;;
|
||||
"src/map/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;;
|
||||
"src/plugins/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/plugins/Makefile" ;;
|
||||
"src/tool/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/tool/Makefile" ;;
|
||||
|
90
configure.in
90
configure.in
@ -8,7 +8,6 @@ AC_CONFIG_SRCDIR([src/common/cbasetypes.h])
|
||||
AC_CONFIG_FILES([Makefile src/common/Makefile])
|
||||
AC_CONFIG_FILES([3rdparty/mt19937ar/Makefile])
|
||||
AC_CONFIG_FILES([src/char/Makefile src/login/Makefile])
|
||||
AC_CONFIG_FILES([src/char_sql/Makefile src/txt-converter/Makefile])
|
||||
AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile src/tool/Makefile])
|
||||
|
||||
|
||||
@ -166,29 +165,22 @@ AC_ARG_ENABLE(
|
||||
|
||||
|
||||
#
|
||||
# Enable/disable MySql and optionally specify the path to mysql_config (optional library)
|
||||
# Optionally specify the path to mysql_config
|
||||
#
|
||||
AC_ARG_WITH(
|
||||
[mysql],
|
||||
AC_HELP_STRING(
|
||||
[--with-mysql@<:@=ARG@:>@],
|
||||
[use MySQL client library, optionally specify the path to the mysql_config executable (by default mysql is used if found)]
|
||||
[optionally specify the path to the mysql_config executable]
|
||||
),
|
||||
[
|
||||
if test "$withval" = "no" ; then
|
||||
want_mysql="no"
|
||||
else
|
||||
want_mysql="yes"
|
||||
require_mysql="yes"
|
||||
if test "$withval" != "yes" ; then
|
||||
if test ! -x "$withval" ; then
|
||||
AC_MSG_ERROR([$withval is not an executable file])
|
||||
fi
|
||||
MYSQL_CONFIG_HOME="$withval"
|
||||
if test "$withval" != "no" ; then
|
||||
if test ! -x "$withval" ; then
|
||||
AC_MSG_ERROR([$withval is not an executable file])
|
||||
fi
|
||||
MYSQL_CONFIG_HOME="$withval"
|
||||
fi
|
||||
],
|
||||
[want_mysql="yes" require_mysql="no"]
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@ -632,52 +624,38 @@ fi
|
||||
|
||||
|
||||
#
|
||||
# MySQL library (optional)
|
||||
# MySQL library
|
||||
#
|
||||
|
||||
if test "$want_mysql" = "no" ; then
|
||||
MYSQL_VERSION=""
|
||||
MYSQL_CFLAGS=""
|
||||
MYSQL_LIBS=""
|
||||
AC_MSG_NOTICE([ignoring MySQL (optional)])
|
||||
if test -z "$MYSQL_CONFIG_HOME"; then
|
||||
AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
|
||||
fi
|
||||
|
||||
if test "$MYSQL_CONFIG_HOME" != "no" ; then
|
||||
MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
|
||||
if test "$manual_MYSQL_CFLAGS" = "no" ; then
|
||||
MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
|
||||
fi
|
||||
if test "$manual_MYSQL_LIBS" = "no" ; then
|
||||
MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
|
||||
fi
|
||||
else
|
||||
if test -z "$MYSQL_CONFIG_HOME"; then
|
||||
AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
|
||||
fi
|
||||
MYSQL_VERSION="unknown"
|
||||
fi
|
||||
|
||||
if test "$MYSQL_CONFIG_HOME" != "no" ; then
|
||||
MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
|
||||
if test "$manual_MYSQL_CFLAGS" = "no" ; then
|
||||
MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
|
||||
fi
|
||||
if test "$manual_MYSQL_LIBS" = "no" ; then
|
||||
MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
|
||||
fi
|
||||
else
|
||||
MYSQL_VERSION="unknown"
|
||||
fi
|
||||
MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
|
||||
MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
|
||||
AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
|
||||
AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
|
||||
CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
|
||||
LDFLAGS="$MYSQL_OLD_LDFLAGS"
|
||||
|
||||
MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
|
||||
MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
|
||||
AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
|
||||
AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
|
||||
CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
|
||||
LDFLAGS="$MYSQL_OLD_LDFLAGS"
|
||||
|
||||
AC_MSG_CHECKING([MySQL library (optional)])
|
||||
if test "$HAVE_MYSQL" = "yes" ; then
|
||||
AC_MSG_RESULT([yes ($MYSQL_VERSION)])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
if test "$require_mysql" = "yes" ; then
|
||||
AC_MSG_ERROR([MySQL not found or incompatible (requested)])
|
||||
else
|
||||
AC_MSG_NOTICE([disabling MySQL (optional)])
|
||||
MYSQL_VERSION=""
|
||||
MYSQL_CFLAGS=""
|
||||
MYSQL_LIBS=""
|
||||
fi
|
||||
fi
|
||||
AC_MSG_CHECKING([MySQL library (required)])
|
||||
if test "$HAVE_MYSQL" = "yes" ; then
|
||||
AC_MSG_RESULT([yes ($MYSQL_VERSION)])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([MySQL not found or incompatible])
|
||||
fi
|
||||
|
||||
AC_SUBST([HAVE_MYSQL])
|
||||
|
@ -1,2 +0,0 @@
|
||||
@ECHO OFF
|
||||
CALL serv.bat login-server.exe Login-Server
|
@ -1,2 +0,0 @@
|
||||
@ECHO OFF
|
||||
CALL serv.bat map-server.exe Map-Server
|
@ -1,11 +1,5 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_txt", "vcproj-10\map-server_txt.vcxproj", "{D356871D-58E1-450B-967A-E1E9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_txt", "vcproj-10\login-server_txt.vcxproj", "{D356871D-58E1-450B-967A-E2E9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_txt", "vcproj-10\char-server_txt.vcxproj", "{D356871D-58E1-450B-967A-E3E9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_sql", "vcproj-10\char-server_sql.vcxproj", "{D356871D-58E1-450B-967A-E4E9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_sql", "vcproj-10\login-server_sql.vcxproj", "{D356871D-58E1-450B-967A-E5E9646175AF}"
|
||||
@ -14,112 +8,28 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_sql", "vcproj-10
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mapcache", "vcproj-10\mapcache.vcxproj", "{D356871D-58E1-450B-967A-E7E9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-login", "vcproj-10\txt-converter-login.vcxproj", "{D356871D-58E1-450B-967A-E9E9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-char", "vcproj-10\txt-converter-char.vcxproj", "{D356871D-58E1-450B-967A-EAE9646175AF}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug-sql|Win32 = Debug-sql|Win32
|
||||
Debug-txt|Win32 = Debug-txt|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
Release-sql|Win32 = Release-sql|Win32
|
||||
Release-txt|Win32 = Release-txt|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Release-txt|Win32.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,11 +1,5 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_txt", "vcproj-9\map-server_txt.vcproj", "{D356871D-58E1-450B-967A-E1E9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_txt", "vcproj-9\login-server_txt.vcproj", "{D356871D-58E1-450B-967A-E2E9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_txt", "vcproj-9\char-server_txt.vcproj", "{D356871D-58E1-450B-967A-E3E9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "char-server_sql", "vcproj-9\char-server_sql.vcproj", "{D356871D-58E1-450B-967A-E4E9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "login-server_sql", "vcproj-9\login-server_sql.vcproj", "{D356871D-58E1-450B-967A-E5E9646175AF}"
|
||||
@ -14,10 +8,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "map-server_sql", "vcproj-9\
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mapcache", "vcproj-9\mapcache.vcproj", "{D356871D-58E1-450B-967A-E7E9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-login", "vcproj-9\txt-converter-login.vcproj", "{D356871D-58E1-450B-967A-E9E9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "txt-converter-char", "vcproj-9\txt-converter-char.vcproj", "{D356871D-58E1-450B-967A-EAE9646175AF}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "plugin-console", "vcproj-9\plugin-console.vcproj", "{73E1101A-310C-4453-8F45-FD2795ABEF15}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "plugin-pid", "vcproj-9\plugin-pid.vcproj", "{9509E1B9-DA2B-4153-9EE0-CBCA6597F198}"
|
||||
@ -25,105 +15,25 @@ EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug-sql|Win32 = Debug-sql|Win32
|
||||
Debug-txt|Win32 = Debug-txt|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
Release-sql|Win32 = Release-sql|Win32
|
||||
Release-txt|Win32 = Release-txt|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E1E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E2E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E3E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E4E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E5E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E6E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Debug-sql|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Release-sql|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E7E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-E9E9646175AF}.Release-txt|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Debug-sql|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Debug-txt|Win32.ActiveCfg = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Debug-txt|Win32.Build.0 = Debug|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Release|Win32.Build.0 = Release|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Release-sql|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Release-txt|Win32.ActiveCfg = Release|Win32
|
||||
{D356871D-58E1-450B-967A-EAE9646175AF}.Release-txt|Win32.Build.0 = Release|Win32
|
||||
{73E1101A-310C-4453-8F45-FD2795ABEF15}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{73E1101A-310C-4453-8F45-FD2795ABEF15}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{73E1101A-310C-4453-8F45-FD2795ABEF15}.Release|Win32.ActiveCfg = Release|Win32
|
||||
|
@ -1,75 +0,0 @@
|
||||
@echo off
|
||||
|
||||
rem ----- Configuration -----
|
||||
rem Defines the server type (txt or sql).
|
||||
set SERVER_TYPE=txt
|
||||
rem Defines how long to wait before restarting (in seconds).
|
||||
set SLEEP_TIME=15
|
||||
rem Defines whether to run all servers in one window (yes or no).
|
||||
set SINGLE_WINDOW=no
|
||||
rem ----- ------------- -----
|
||||
|
||||
:L_Init
|
||||
set this=%0
|
||||
if %SERVER_TYPE% == txt set suffix=
|
||||
if %SERVER_TYPE% == sql set suffix=_sql
|
||||
if %SINGLE_WINDOW% == yes set wndswitch=/B
|
||||
|
||||
:L_Main
|
||||
set command=%1
|
||||
if "%command%" == "" goto L_DefaultAction
|
||||
|
||||
if %command% == exec goto L_ExecServerExe
|
||||
if %command% == start goto L_StartServerExe
|
||||
if %command% == stop goto L_StopServerExe
|
||||
if %command% == restart echo "TODO"
|
||||
goto L_EOF
|
||||
|
||||
:L_DefaultAction
|
||||
:L_StartServer
|
||||
call %this% start login-server%suffix%.exe
|
||||
call %this% start char-server%suffix%.exe
|
||||
call %this% start map-server%suffix%.exe
|
||||
goto L_EOF
|
||||
|
||||
:L_StopServer
|
||||
call %this% stop login-server%suffix%.exe
|
||||
call %this% stop char-server%suffix%.exe
|
||||
call %this% stop map-server%suffix%.exe
|
||||
goto L_EOF
|
||||
|
||||
:L_StartServerExe
|
||||
set filename=%2
|
||||
if "%filename%" == "" goto L_StartServer
|
||||
if exist %filename% goto L_HaveExe
|
||||
echo Cannot start '%filename%' because the file is missing!
|
||||
goto L_EOF
|
||||
|
||||
:L_HaveExe
|
||||
echo Starting %filename%...
|
||||
start "%filename%" %wndswitch% %this% exec %filename%
|
||||
goto L_EOF
|
||||
|
||||
:L_StopServerExe
|
||||
set filename=%2
|
||||
if "%filename%" == "" goto L_StopServer
|
||||
if exist %windir%\system32\taskkill.exe goto L_HaveTaskKill
|
||||
echo The 'stop' command is not available on your system.
|
||||
exit
|
||||
|
||||
:L_HaveTaskKill
|
||||
rem CAUTION! This will kill all processes called %filename%.
|
||||
echo Stopping '%filename%'...
|
||||
taskkill /F /FI "WINDOWTITLE eq %filename% - %this% exec %filename%"
|
||||
taskkill /F /IM "%filename%"
|
||||
goto L_EOF
|
||||
|
||||
:L_ExecServerExe
|
||||
%filename%
|
||||
echo .
|
||||
echo .
|
||||
echo Server exited, restarting in %SLEEP_TIME% seconds! Press CTRL+C to abort!
|
||||
ping.exe -n %SLEEP_TIME% 127.0.0.1 > nul
|
||||
goto L_ExecServerExe
|
||||
|
||||
:L_EOF
|
@ -1,16 +0,0 @@
|
||||
20110114
|
||||
// Accounts file: here are saved all information about the accounts.
|
||||
// Structure: account ID, username, password, sex, email, level, state, unban time, expiration time, # of logins, last login time, last (accepted) login ip, birth date, repeated(register key, register value)
|
||||
// where:
|
||||
// sex : M or F for normal accounts, S for server accounts
|
||||
// level : this account's gm level
|
||||
// state : 0: account is ok, 1 to 256: error code of packet 0x006a + 1
|
||||
// unban time : 0: no ban, <other value>: banned until the date (unix timestamp)
|
||||
// expiration time : 0: unlimited account, <other value>: account expires on the date (unix timestamp)
|
||||
1 s1 p1 S a@a.com 0 0 0 0 0 0000-00-00 00:00:00 - 0000-00-00
|
||||
2 s2 p2 S a@a.com 0 0 0 0 0 0000-00-00 00:00:00 - 0000-00-00
|
||||
3 s3 p3 S a@a.com 0 0 0 0 0 0000-00-00 00:00:00 - 0000-00-00
|
||||
4 s4 p4 S a@a.com 0 0 0 0 0 0000-00-00 00:00:00 - 0000-00-00
|
||||
5 s5 p5 S a@a.com 0 0 0 0 0 0000-00-00 00:00:00 - 0000-00-00
|
||||
2000001 Test Test M a@a.com 0 0 0 0 0 0000-00-00 00:00:00 - 0000-00-00
|
||||
2000002 %newid%
|
@ -1,34 +0,0 @@
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
21,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
23,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
24,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
26,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
27,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
29,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
@ -3,11 +3,6 @@
|
||||
# setup and static libraries
|
||||
#
|
||||
add_subdirectory( common )
|
||||
if( HAVE_common_base )
|
||||
option( BUILD_TXT_SERVERS "build txt server executables" ON )
|
||||
else()
|
||||
message( STATUS "Disabled txt server targets (requires common_base)" )
|
||||
endif()
|
||||
if( HAVE_common_sql )
|
||||
option( BUILD_SQL_SERVERS "build sql server executables" ON )
|
||||
else()
|
||||
@ -20,8 +15,6 @@ endif()
|
||||
#
|
||||
add_subdirectory( login )
|
||||
add_subdirectory( char )
|
||||
add_subdirectory( char_sql )
|
||||
add_subdirectory( map )
|
||||
add_subdirectory( tool )
|
||||
add_subdirectory( txt-converter )
|
||||
add_subdirectory( plugins )
|
||||
|
@ -2,52 +2,57 @@
|
||||
#
|
||||
# setup
|
||||
#
|
||||
set( TXT_CHAR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
set( SQL_CHAR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
|
||||
|
||||
#
|
||||
# char txt
|
||||
# char sql
|
||||
#
|
||||
if( BUILD_TXT_SERVERS )
|
||||
message( STATUS "Creating target char-server" )
|
||||
set( TXT_CHAR_HEADERS
|
||||
"${TXT_CHAR_SOURCE_DIR}/char.h"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_guild.h"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_homun.h"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_party.h"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_pet.h"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_status.h"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_storage.h"
|
||||
"${TXT_CHAR_SOURCE_DIR}/inter.h"
|
||||
if( BUILD_SQL_SERVERS )
|
||||
message( STATUS "Creating target char-server_sql" )
|
||||
set( SQL_CHAR_HEADERS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_auction.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_guild.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_homun.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_mail.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_mercenary.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_party.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_pet.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_quest.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_storage.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/inter.h"
|
||||
)
|
||||
set( TXT_CHAR_SOURCES
|
||||
"${TXT_CHAR_SOURCE_DIR}/char.c"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_guild.c"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_homun.c"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_party.c"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_pet.c"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_status.c"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_storage.c"
|
||||
"${TXT_CHAR_SOURCE_DIR}/inter.c"
|
||||
set( SQL_CHAR_SOURCES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_auction.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_guild.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_homun.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_mail.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_mercenary.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_party.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_pet.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_quest.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_storage.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/inter.c"
|
||||
)
|
||||
set( DEPENDENCIES common_base )
|
||||
set( DEPENDENCIES common_sql )
|
||||
set( LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${GLOBAL_DEFINITIONS} -DTXT_ONLY" )
|
||||
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${TXT_CHAR_HEADERS} ${TXT_CHAR_SOURCES} )
|
||||
source_group( common FILES ${COMMON_BASE_HEADERS} )
|
||||
source_group( char FILES ${TXT_CHAR_HEADERS} ${TXT_CHAR_SOURCES} )
|
||||
set( DEFINITIONS "${GLOBAL_DEFINITIONS}" )
|
||||
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ${SQL_CHAR_HEADERS} ${SQL_CHAR_SOURCES} )
|
||||
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} )
|
||||
source_group( char FILES ${SQL_CHAR_HEADERS} ${SQL_CHAR_SOURCES} )
|
||||
include_directories( ${INCLUDE_DIRS} )
|
||||
add_executable( char-server ${SOURCE_FILES} )
|
||||
add_dependencies( char-server ${DEPENDENCIES} )
|
||||
target_link_libraries( char-server ${LIBRARIES} ${DEPENDENCIES} )
|
||||
set_target_properties( char-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
|
||||
add_executable( char-server_sql ${SOURCE_FILES} )
|
||||
add_dependencies( char-server_sql ${DEPENDENCIES} )
|
||||
target_link_libraries( char-server_sql ${LIBRARIES} ${DEPENDENCIES} )
|
||||
set_target_properties( char-server_sql PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
cpack_add_component( Runtime_charserver_txt DESCRIPTION "char-server (txt version)" DISPLAY_NAME "char-server" GROUP Runtime )
|
||||
install( TARGETS char-server
|
||||
cpack_add_component( Runtime_charserver_sql DESCRIPTION "char-server (sql version)" DISPLAY_NAME "char-server_sql" GROUP Runtime )
|
||||
install( TARGETS char-server_sql
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_charserver_txt )
|
||||
COMPONENT Runtime_charserver_sql )
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
set( TARGET_LIST ${TARGET_LIST} char-server CACHE INTERNAL "" )
|
||||
message( STATUS "Creating target char-server - done" )
|
||||
endif( BUILD_TXT_SERVERS )
|
||||
message( STATUS "Creating target char-server_sql - done" )
|
||||
endif( BUILD_SQL_SERVERS )
|
||||
|
@ -14,41 +14,58 @@ MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o
|
||||
MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h
|
||||
MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar
|
||||
|
||||
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
|
||||
COMMON_SQL_OBJ = ../common/obj_sql/sql.o
|
||||
COMMON_H = ../common/sql.h
|
||||
|
||||
CHAR_OBJ = obj_sql/char.o obj_sql/inter.o obj_sql/int_party.o obj_sql/int_guild.o \
|
||||
obj_sql/int_storage.o obj_sql/int_pet.o obj_sql/int_homun.o obj_sql/int_mail.o obj_sql/int_auction.o obj_sql/int_quest.o obj_sql/int_mercenary.o
|
||||
CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h int_mail.h int_auction.h int_quest.h int_mercenary.h
|
||||
|
||||
HAVE_MYSQL=@HAVE_MYSQL@
|
||||
ifeq ($(HAVE_MYSQL),yes)
|
||||
CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ)
|
||||
else
|
||||
CHAR_SERVER_SQL_DEPENDS=needs_mysql
|
||||
endif
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
#####################################################################
|
||||
.PHONY : all char-server clean help
|
||||
.PHONY : all char-server_sql clean help
|
||||
|
||||
all: char-server
|
||||
all: char-server_sql
|
||||
|
||||
char-server: obj_txt $(CHAR_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ)
|
||||
@CC@ @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @LIBS@
|
||||
char-server_sql: $(CHAR_SERVER_SQL_DEPENDS)
|
||||
@CC@ @LDFLAGS@ -o ../../char-server_sql@EXEEXT@ $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) @LIBS@ @MYSQL_LIBS@
|
||||
|
||||
clean:
|
||||
rm -rf *.o obj_txt ../../char-server@EXEEXT@
|
||||
rm -rf *.o obj_sql ../../char-server_sql@EXEEXT@
|
||||
|
||||
help:
|
||||
@echo "possible targets are 'char-server' 'all' 'clean' 'help'"
|
||||
@echo "'char-server' - char server (TXT version)"
|
||||
@echo "'all' - builds all above targets"
|
||||
@echo "'clean' - cleans builds and objects"
|
||||
@echo "'help' - outputs this message"
|
||||
@echo "possible targets are 'char-server_sql' 'all' 'clean' 'help'"
|
||||
@echo "'char-server_sql' - char server (SQL version)"
|
||||
@echo "'all' - builds all above targets"
|
||||
@echo "'clean' - cleans builds and objects"
|
||||
@echo "'help' - outputs this message"
|
||||
|
||||
#####################################################################
|
||||
|
||||
obj_txt:
|
||||
-mkdir obj_txt
|
||||
needs_mysql:
|
||||
@echo "MySQL not found or disabled by the configure script"
|
||||
@exit 1
|
||||
|
||||
obj_txt/%.o: %.c $(CHAR_H) $(COMMON_H) $(MT19937AR_H)
|
||||
@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
|
||||
obj_sql:
|
||||
-mkdir obj_sql
|
||||
|
||||
obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H)
|
||||
@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
|
||||
|
||||
# missing object files
|
||||
../common/obj_all/%.o:
|
||||
@$(MAKE) -C ../common txt
|
||||
@$(MAKE) -C ../common sql
|
||||
|
||||
../common/obj_sql/%.o:
|
||||
@$(MAKE) -C ../common sql
|
||||
|
||||
MT19937AR_OBJ:
|
||||
@$(MAKE) -C ../../3rdparty/mt19937ar
|
||||
|
3551
src/char/char.c
3551
src/char/char.c
File diff suppressed because it is too large
Load Diff
@ -1,62 +1,81 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _CHAR_H_
|
||||
#define _CHAR_H_
|
||||
#ifndef _CHAR_SQL_H_
|
||||
#define _CHAR_SQL_H_
|
||||
|
||||
#include "../common/core.h" // CORE_ST_LAST
|
||||
#include "../common/mmo.h"
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
enum E_CHARSERVER_ST
|
||||
{
|
||||
CHARSERVER_ST_RUNNING = CORE_ST_LAST,
|
||||
CHARSERVER_ST_SHUTDOWN,
|
||||
CHARSERVER_ST_LAST
|
||||
};
|
||||
#endif
|
||||
|
||||
struct mmo_charstatus;
|
||||
|
||||
#define MAX_MAP_SERVERS 30
|
||||
|
||||
#define DEFAULT_AUTOSAVE_INTERVAL 300*1000
|
||||
|
||||
struct character_data {
|
||||
struct mmo_charstatus status;
|
||||
int global_num;
|
||||
struct global_reg global[GLOBAL_REG_NUM];
|
||||
enum {
|
||||
TABLE_INVENTORY,
|
||||
TABLE_CART,
|
||||
TABLE_STORAGE,
|
||||
TABLE_GUILD_STORAGE,
|
||||
};
|
||||
|
||||
struct mmo_charstatus* search_character(int aid, int cid);
|
||||
struct mmo_charstatus* search_character_byname(char* character_name);
|
||||
int search_character_index(char* character_name);
|
||||
char* search_character_name(int index);
|
||||
int search_character_online(int aid, int cid);
|
||||
int memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch);
|
||||
|
||||
int mapif_sendall(unsigned char *buf, unsigned int len);
|
||||
int mapif_sendallwos(int fd,unsigned char *buf, unsigned int len);
|
||||
int mapif_send(int fd,unsigned char *buf, unsigned int len);
|
||||
int mapif_sendall(unsigned char *buf,unsigned int len);
|
||||
int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len);
|
||||
int mapif_send(int fd,unsigned char *buf,unsigned int len);
|
||||
|
||||
int char_married(int pl1,int pl2);
|
||||
int char_child(int parent_id, int child_id);
|
||||
int char_family(int cid1, int cid2, int cid3);
|
||||
|
||||
int char_log(char *fmt, ...);
|
||||
int char_family(int pl1,int pl2,int pl3);
|
||||
|
||||
int request_accreg2(int account_id, int char_id);
|
||||
int char_parse_Registry(int account_id, int char_id, unsigned char *buf, int len);
|
||||
int save_accreg2(unsigned char *buf, int len);
|
||||
int char_account_reg_reply(int fd,int account_id,int char_id);
|
||||
int save_accreg2(unsigned char* buf, int len);
|
||||
|
||||
extern int char_name_option;
|
||||
extern char char_name_letters[];
|
||||
extern bool char_gm_read;
|
||||
extern int autosave_interval;
|
||||
extern int save_log;
|
||||
extern char db_path[];
|
||||
extern char char_db[256];
|
||||
extern char scdata_db[256];
|
||||
extern char cart_db[256];
|
||||
extern char inventory_db[256];
|
||||
extern char charlog_db[256];
|
||||
extern char storage_db[256];
|
||||
extern char interlog_db[256];
|
||||
extern char reg_db[256];
|
||||
extern char skill_db[256];
|
||||
extern char memo_db[256];
|
||||
extern char guild_db[256];
|
||||
extern char guild_alliance_db[256];
|
||||
extern char guild_castle_db[256];
|
||||
extern char guild_expulsion_db[256];
|
||||
extern char guild_member_db[256];
|
||||
extern char guild_position_db[256];
|
||||
extern char guild_skill_db[256];
|
||||
extern char guild_storage_db[256];
|
||||
extern char party_db[256];
|
||||
extern char pet_db[256];
|
||||
extern char mail_db[256];
|
||||
extern char auction_db[256];
|
||||
extern char quest_db[256];
|
||||
|
||||
extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris]
|
||||
|
||||
extern int guild_exp_rate;
|
||||
extern int log_inter;
|
||||
//Exported for use in the TXT-SQL converter.
|
||||
extern char char_txt[];
|
||||
int char_config_read(const char *cfgName);
|
||||
int mmo_char_fromstr(char *str, struct mmo_charstatus *p, struct global_reg *reg, int *reg_num);
|
||||
int parse_friend_txt(struct mmo_charstatus *p);
|
||||
|
||||
#endif /* _CHAR_H_ */
|
||||
//Exported for use in the TXT-SQL converter.
|
||||
int mmo_char_tosql(int char_id, struct mmo_charstatus *p);
|
||||
void sql_config_read(const char *cfgName);
|
||||
|
||||
#endif /* _CHAR_SQL_H_ */
|
||||
|
2443
src/char/int_guild.c
2443
src/char/int_guild.c
File diff suppressed because it is too large
Load Diff
@ -1,26 +1,40 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INT_GUILD_H_
|
||||
#define _INT_GUILD_H_
|
||||
#ifndef _INT_GUILD_SQL_H_
|
||||
#define _INT_GUILD_SQL_H_
|
||||
|
||||
#define GS_BASIC 0x0001
|
||||
#define GS_MEMBER 0x0002
|
||||
#define GS_POSITION 0x0004
|
||||
#define GS_ALLIANCE 0x0008
|
||||
#define GS_EXPULSION 0x0010
|
||||
#define GS_SKILL 0x0020
|
||||
#define GS_EMBLEM 0x0040
|
||||
#define GS_CONNECT 0x0080
|
||||
#define GS_LEVEL 0x0100
|
||||
#define GS_MES 0x0200
|
||||
#define GS_MASK 0x03FF
|
||||
#define GS_BASIC_MASK (GS_BASIC | GS_EMBLEM | GS_CONNECT | GS_LEVEL | GS_MES)
|
||||
#define GS_REMOVE 0x8000
|
||||
|
||||
struct guild;
|
||||
struct guild_castle;
|
||||
|
||||
int inter_guild_init(void);
|
||||
void inter_guild_final(void);
|
||||
int inter_guild_save(void);
|
||||
int inter_guild_parse_frommap(int fd);
|
||||
struct guild *inter_guild_search(int guild_id);
|
||||
int inter_guild_sql_init(void);
|
||||
void inter_guild_sql_final(void);
|
||||
int inter_guild_mapif_init(int fd);
|
||||
int inter_guild_leave(int guild_id,int account_id,int char_id);
|
||||
int mapif_parse_BreakGuild(int fd,int guild_id);
|
||||
int inter_guild_broken(int guild_id);
|
||||
int inter_guild_sex_changed(int guild_id,int account_id,int char_id, short gender);
|
||||
int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char *name);
|
||||
int inter_guild_CharOnline(int char_id, int guild_id);
|
||||
int inter_guild_CharOffline(int char_id, int guild_id);
|
||||
|
||||
extern char guild_txt[1024];
|
||||
extern char castle_txt[1024];
|
||||
//For the TXT->SQL converter.
|
||||
int inter_guild_tosql(struct guild *g,int flag);
|
||||
int inter_guildcastle_tosql(struct guild_castle *gc);
|
||||
|
||||
//For the TXT->SQL converter
|
||||
int inter_guild_fromstr(char *str, struct guild *g);
|
||||
int inter_guildcastle_fromstr(char *str, struct guild_castle *gc);
|
||||
|
||||
#endif /* _INT_GUILD_H_ */
|
||||
#endif /* _INT_GUILD_SQL_H_ */
|
||||
|
@ -3,363 +3,311 @@
|
||||
|
||||
#include "../common/mmo.h"
|
||||
#include "../common/malloc.h"
|
||||
#include "../common/socket.h"
|
||||
#include "../common/db.h"
|
||||
#include "../common/lock.h"
|
||||
#include "../common/strlib.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/socket.h"
|
||||
#include "../common/utils.h"
|
||||
#include "../common/sql.h"
|
||||
#include "char.h"
|
||||
#include "inter.h"
|
||||
#include "int_homun.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char homun_txt[1024]="save/homun.txt";
|
||||
|
||||
static DBMap* homun_db; // int hom_id -> struct s_homunculus*
|
||||
static int homun_newid = 100;
|
||||
|
||||
int inter_homun_tostr(char *str,struct s_homunculus *p)
|
||||
int inter_homunculus_sql_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
str+=sprintf(str,"%d,%d\t%s\t%d,%d,%d,%d,%d,"
|
||||
"%u,%d,%d,%d,"
|
||||
"%u,%d,%d,"
|
||||
"%d,%d,%d,%d,%d,%d\t",
|
||||
p->hom_id, p->class_, p->name,
|
||||
p->char_id, p->hp, p->max_hp, p->sp, p->max_sp,
|
||||
p->intimacy, p->hunger, p->skillpts, p->level,
|
||||
p->exp, p->rename_flag, p->vaporize,
|
||||
p->str, p->agi, p->vit, p->int_, p->dex, p->luk);
|
||||
|
||||
for (i = 0; i < MAX_HOMUNSKILL; i++)
|
||||
{
|
||||
if (p->hskill[i].id && p->hskill[i].flag == SKILL_FLAG_PERMANENT)
|
||||
str+=sprintf(str,"%d,%d,", p->hskill[i].id, p->hskill[i].lv);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int inter_homun_fromstr(char *str,struct s_homunculus *p)
|
||||
void inter_homunculus_sql_final(void)
|
||||
{
|
||||
int i, next, len;
|
||||
int tmp_int[25];
|
||||
unsigned int tmp_uint[5];
|
||||
char tmp_str[256];
|
||||
|
||||
memset(p,0,sizeof(struct s_homunculus));
|
||||
|
||||
i=sscanf(str,"%d,%d\t%127[^\t]\t%d,%d,%d,%d,%d,"
|
||||
"%u,%d,%d,%d,"
|
||||
"%u,%d,%d,"
|
||||
"%d,%d,%d,%d,%d,%d\t%n",
|
||||
&tmp_int[0],&tmp_int[1],tmp_str,
|
||||
&tmp_int[2],&tmp_int[3],&tmp_int[4],&tmp_int[5],&tmp_int[6],
|
||||
&tmp_uint[0],&tmp_int[7],&tmp_int[8],&tmp_int[9],
|
||||
&tmp_uint[1],&tmp_int[10],&tmp_int[11],
|
||||
&tmp_int[12],&tmp_int[13],&tmp_int[14],&tmp_int[15],&tmp_int[16],&tmp_int[17],
|
||||
&next);
|
||||
|
||||
if(i!=21)
|
||||
return 1;
|
||||
|
||||
p->hom_id = tmp_int[0];
|
||||
p->class_ = tmp_int[1];
|
||||
memcpy(p->name, tmp_str, NAME_LENGTH);
|
||||
|
||||
p->char_id = tmp_int[2];
|
||||
p->hp = tmp_int[3];
|
||||
p->max_hp = tmp_int[4];
|
||||
p->sp = tmp_int[5];
|
||||
p->max_sp = tmp_int[6];
|
||||
|
||||
p->intimacy = tmp_uint[0];
|
||||
p->hunger = tmp_int[7];
|
||||
p->skillpts = tmp_int[8];
|
||||
p->level = tmp_int[9];
|
||||
|
||||
p->exp = tmp_uint[1];
|
||||
p->rename_flag = tmp_int[10];
|
||||
p->vaporize = tmp_int[11];
|
||||
|
||||
p->str = tmp_int[12];
|
||||
p->agi = tmp_int[13];
|
||||
p->vit = tmp_int[14];
|
||||
p->int_= tmp_int[15];
|
||||
p->dex = tmp_int[16];
|
||||
p->luk = tmp_int[17];
|
||||
|
||||
//Read skills.
|
||||
while(str[next] && str[next] != '\n' && str[next] != '\r') {
|
||||
if (sscanf(str+next, "%d,%d,%n", &tmp_int[0], &tmp_int[1], &len) != 2)
|
||||
return 2;
|
||||
|
||||
if (tmp_int[0] >= HM_SKILLBASE && tmp_int[0] < HM_SKILLBASE+MAX_HOMUNSKILL)
|
||||
{
|
||||
i = tmp_int[0] - HM_SKILLBASE;
|
||||
p->hskill[i].id = tmp_int[0];
|
||||
p->hskill[i].lv = tmp_int[1];
|
||||
} else
|
||||
ShowError("Read Homun: Unsupported Skill ID %d for homunculus (Homun ID=%d)\n", tmp_int[0], p->hom_id);
|
||||
next += len;
|
||||
if (str[next] == ' ')
|
||||
next++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int inter_homun_init()
|
||||
{
|
||||
char line[8192];
|
||||
struct s_homunculus *p;
|
||||
FILE *fp;
|
||||
int c=0;
|
||||
|
||||
homun_db= idb_alloc(DB_OPT_RELEASE_DATA);
|
||||
|
||||
if( (fp=fopen(homun_txt,"r"))==NULL )
|
||||
return 1;
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
p = (struct s_homunculus*)aCalloc(sizeof(struct s_homunculus), 1);
|
||||
if(p==NULL){
|
||||
ShowFatalError("int_homun: out of memory!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if(inter_homun_fromstr(line,p)==0 && p->hom_id>0){
|
||||
if( p->hom_id >= homun_newid)
|
||||
homun_newid=p->hom_id+1;
|
||||
idb_put(homun_db,p->hom_id,p);
|
||||
}else{
|
||||
ShowError("int_homun: broken data [%s] line %d\n",homun_txt,c);
|
||||
aFree(p);
|
||||
}
|
||||
c++;
|
||||
}
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void inter_homun_final()
|
||||
{
|
||||
homun_db->destroy(homun_db, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
int inter_homun_save_sub(DBKey key,void *data,va_list ap)
|
||||
{
|
||||
char line[8192];
|
||||
FILE *fp;
|
||||
inter_homun_tostr(line,(struct s_homunculus *)data);
|
||||
fp=va_arg(ap,FILE *);
|
||||
fprintf(fp,"%s\n",line);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int inter_homun_save()
|
||||
{
|
||||
FILE *fp;
|
||||
int lock;
|
||||
if( (fp=lock_fopen(homun_txt,&lock))==NULL ){
|
||||
ShowError("int_homun: can't write [%s] !!! data is lost !!!\n",homun_txt);
|
||||
return 1;
|
||||
}
|
||||
homun_db->foreach(homun_db,inter_homun_save_sub,fp);
|
||||
lock_fclose(fp,homun_txt,&lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int inter_homun_delete(int hom_id)
|
||||
{
|
||||
struct s_homunculus *p;
|
||||
p = (struct s_homunculus*)idb_get(homun_db,hom_id);
|
||||
if( p == NULL)
|
||||
return 0;
|
||||
idb_remove(homun_db,hom_id);
|
||||
ShowInfo("Deleted homun (hom_id: %d)\n",hom_id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int mapif_homun_created(int fd,int account_id, struct s_homunculus *p)
|
||||
static void mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag)
|
||||
{
|
||||
WFIFOHEAD(fd, sizeof(struct s_homunculus)+9);
|
||||
WFIFOW(fd, 0) =0x3890;
|
||||
WFIFOW(fd,0) = 0x3890;
|
||||
WFIFOW(fd,2) = sizeof(struct s_homunculus)+9;
|
||||
WFIFOL(fd,4) = account_id;
|
||||
WFIFOB(fd,8)= p->hom_id?1:0;
|
||||
memcpy(WFIFOP(fd,9), p, sizeof(struct s_homunculus));
|
||||
WFIFOB(fd,8)= flag;
|
||||
memcpy(WFIFOP(fd,9),sh,sizeof(struct s_homunculus));
|
||||
WFIFOSET(fd, WFIFOW(fd,2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_homun_info(int fd,int account_id,struct s_homunculus *p)
|
||||
static void mapif_homunculus_deleted(int fd, int flag)
|
||||
{
|
||||
WFIFOHEAD(fd, 3);
|
||||
WFIFOW(fd, 0) = 0x3893;
|
||||
WFIFOB(fd,2) = flag; //Flag 1 = success
|
||||
WFIFOSET(fd, 3);
|
||||
}
|
||||
|
||||
static void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd)
|
||||
{
|
||||
WFIFOHEAD(fd, sizeof(struct s_homunculus)+9);
|
||||
WFIFOW(fd,0) = 0x3891;
|
||||
WFIFOW(fd,2) = sizeof(struct s_homunculus)+9;
|
||||
WFIFOL(fd,4) = account_id;
|
||||
WFIFOB(fd,8) = 1; // account loaded with success
|
||||
|
||||
memcpy(WFIFOP(fd,9), p, sizeof(struct s_homunculus));
|
||||
WFIFOSET(fd,WFIFOW(fd,2));
|
||||
return 0;
|
||||
if( hd != NULL )
|
||||
{
|
||||
WFIFOB(fd,8) = 1; // success
|
||||
memcpy(WFIFOP(fd,9), hd, sizeof(struct s_homunculus));
|
||||
}
|
||||
else
|
||||
{
|
||||
WFIFOB(fd,8) = 0; // not found.
|
||||
memset(WFIFOP(fd,9), 0, sizeof(struct s_homunculus));
|
||||
}
|
||||
WFIFOSET(fd, sizeof(struct s_homunculus)+9);
|
||||
}
|
||||
|
||||
int mapif_homun_noinfo(int fd,int account_id)
|
||||
{
|
||||
WFIFOHEAD(fd,sizeof(struct s_homunculus) + 9);
|
||||
WFIFOW(fd,0)=0x3891;
|
||||
WFIFOW(fd,2)=sizeof(struct s_homunculus) + 9;
|
||||
WFIFOL(fd,4)=account_id;
|
||||
WFIFOB(fd,8)=0;
|
||||
memset(WFIFOP(fd,9),0,sizeof(struct s_homunculus));
|
||||
WFIFOSET(fd,WFIFOW(fd,2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_save_homun_ack(int fd,int account_id,int flag)
|
||||
static void mapif_homunculus_saved(int fd, int account_id, bool flag)
|
||||
{
|
||||
WFIFOHEAD(fd, 7);
|
||||
WFIFOW(fd,0)=0x3892;
|
||||
WFIFOL(fd,2)=account_id;
|
||||
WFIFOB(fd,6)=flag;
|
||||
WFIFOSET(fd,7);
|
||||
return 0;
|
||||
WFIFOW(fd,0) = 0x3892;
|
||||
WFIFOL(fd,2) = account_id;
|
||||
WFIFOB(fd,6) = flag; // 1:success, 0:failure
|
||||
WFIFOSET(fd, 7);
|
||||
}
|
||||
|
||||
int mapif_delete_homun_ack(int fd,int flag)
|
||||
static void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, char* name)
|
||||
{
|
||||
WFIFOHEAD(fd, 3);
|
||||
WFIFOW(fd,0)=0x3893;
|
||||
WFIFOB(fd,2)=flag;
|
||||
WFIFOSET(fd,3);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_rename_homun_ack(int fd, int account_id, int char_id, int flag, char *name){
|
||||
WFIFOHEAD(fd, NAME_LENGTH+12);
|
||||
WFIFOW(fd, 0) =0x3894;
|
||||
WFIFOL(fd, 2) =account_id;
|
||||
WFIFOL(fd, 6) =char_id;
|
||||
WFIFOB(fd, 10) =flag;
|
||||
memcpy(WFIFOP(fd, 11), name, NAME_LENGTH);
|
||||
WFIFOW(fd, 0) = 0x3894;
|
||||
WFIFOL(fd, 2) = account_id;
|
||||
WFIFOL(fd, 6) = char_id;
|
||||
WFIFOB(fd,10) = flag;
|
||||
safestrncpy((char*)WFIFOP(fd,11), name, NAME_LENGTH);
|
||||
WFIFOSET(fd, NAME_LENGTH+12);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_create_homun(int fd)
|
||||
bool mapif_homunculus_save(struct s_homunculus* hd)
|
||||
{
|
||||
struct s_homunculus *p;
|
||||
p= (struct s_homunculus *) aCalloc(sizeof(struct s_homunculus), 1);
|
||||
if(p==NULL){
|
||||
ShowFatalError("int_homun: out of memory !\n");
|
||||
//Sending the received data will pass hom_id == 0 <- fail.
|
||||
mapif_homun_created(fd,RFIFOL(fd,4),(struct s_homunculus*)RFIFOP(fd,8));
|
||||
return 0;
|
||||
bool flag = true;
|
||||
char esc_name[NAME_LENGTH*2+1];
|
||||
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, hd->name, strnlen(hd->name, NAME_LENGTH));
|
||||
|
||||
if( hd->hom_id == 0 )
|
||||
{// new homunculus
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `homunculus` "
|
||||
"(`char_id`, `class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`, `rename_flag`, `vaporize`) "
|
||||
"VALUES ('%d', '%d', '%s', '%d', '%u', '%u', '%d', '%d', %d, '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
|
||||
hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
|
||||
hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
hd->hom_id = (int)Sql_LastInsertId(sql_handle);
|
||||
}
|
||||
}
|
||||
memcpy(p, RFIFOP(fd,8), sizeof(struct s_homunculus));
|
||||
p->hom_id = homun_newid++; //New ID
|
||||
idb_put(homun_db,p->hom_id,p);
|
||||
mapif_homun_created(fd,RFIFOL(fd,4),p);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `homunculus` SET `char_id`='%d', `class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'",
|
||||
hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
|
||||
hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize, hd->hom_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
SqlStmt* stmt;
|
||||
int i;
|
||||
|
||||
int mapif_load_homun(int fd)
|
||||
{
|
||||
struct s_homunculus *p;
|
||||
int account_id;
|
||||
account_id = RFIFOL(fd,2);
|
||||
|
||||
p = (struct s_homunculus*)idb_get(homun_db,RFIFOL(fd,6));
|
||||
if(p==NULL) {
|
||||
mapif_homun_noinfo(fd,account_id);
|
||||
return 0;
|
||||
stmt = SqlStmt_Malloc(sql_handle);
|
||||
if( SQL_ERROR == SqlStmt_Prepare(stmt, "REPLACE INTO `skill_homunculus` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", hd->hom_id) )
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
for( i = 0; i < MAX_HOMUNSKILL; ++i )
|
||||
{
|
||||
if( hd->hskill[i].id > 0 && hd->hskill[i].lv != 0 )
|
||||
{
|
||||
SqlStmt_BindParam(stmt, 0, SQLDT_USHORT, &hd->hskill[i].id, 0);
|
||||
SqlStmt_BindParam(stmt, 1, SQLDT_USHORT, &hd->hskill[i].lv, 0);
|
||||
if( SQL_ERROR == SqlStmt_Execute(stmt) )
|
||||
{
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
SqlStmt_Free(stmt);
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SqlStmt_Free(stmt);
|
||||
}
|
||||
}
|
||||
mapif_homun_info(fd,account_id,p);
|
||||
return 0;
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
static void* create_homun(DBKey key, va_list args) {
|
||||
struct s_homunculus *p;
|
||||
p=(struct s_homunculus *)aCalloc(sizeof(struct s_homunculus),1);
|
||||
p->hom_id = key.i;
|
||||
return p;
|
||||
}
|
||||
int mapif_save_homun(int fd,int account_id,struct s_homunculus *data)
|
||||
|
||||
|
||||
// Load an homunculus
|
||||
bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
|
||||
{
|
||||
struct s_homunculus *p;
|
||||
int hom_id;
|
||||
|
||||
if (data->hom_id == 0)
|
||||
data->hom_id = homun_newid++;
|
||||
hom_id = data->hom_id;
|
||||
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;
|
||||
int i;
|
||||
char* data;
|
||||
size_t len;
|
||||
|
||||
memset(hd, 0, sizeof(*hd));
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `homun_id`,`char_id`,`class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `homunculus` WHERE `homun_id`='%u'", homun_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !Sql_NumRows(sql_handle) )
|
||||
{ //No homunculus found.
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
hd->hom_id = homun_id;
|
||||
Sql_GetData(sql_handle, 1, &data, NULL); hd->char_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, NULL); hd->class_ = atoi(data);
|
||||
Sql_GetData(sql_handle, 3, &data, &len); safestrncpy(hd->name, data, sizeof(hd->name));
|
||||
Sql_GetData(sql_handle, 4, &data, NULL); hd->level = atoi(data);
|
||||
Sql_GetData(sql_handle, 5, &data, NULL); hd->exp = atoi(data);
|
||||
Sql_GetData(sql_handle, 6, &data, NULL); hd->intimacy = (unsigned int)strtoul(data, NULL, 10);
|
||||
Sql_GetData(sql_handle, 7, &data, NULL); hd->hunger = atoi(data);
|
||||
Sql_GetData(sql_handle, 8, &data, NULL); hd->str = atoi(data);
|
||||
Sql_GetData(sql_handle, 9, &data, NULL); hd->agi = atoi(data);
|
||||
Sql_GetData(sql_handle, 10, &data, NULL); hd->vit = atoi(data);
|
||||
Sql_GetData(sql_handle, 11, &data, NULL); hd->int_ = atoi(data);
|
||||
Sql_GetData(sql_handle, 12, &data, NULL); hd->dex = atoi(data);
|
||||
Sql_GetData(sql_handle, 13, &data, NULL); hd->luk = atoi(data);
|
||||
Sql_GetData(sql_handle, 14, &data, NULL); hd->hp = atoi(data);
|
||||
Sql_GetData(sql_handle, 15, &data, NULL); hd->max_hp = atoi(data);
|
||||
Sql_GetData(sql_handle, 16, &data, NULL); hd->sp = atoi(data);
|
||||
Sql_GetData(sql_handle, 17, &data, NULL); hd->max_sp = atoi(data);
|
||||
Sql_GetData(sql_handle, 18, &data, NULL); hd->skillpts = atoi(data);
|
||||
Sql_GetData(sql_handle, 19, &data, NULL); hd->rename_flag = atoi(data);
|
||||
Sql_GetData(sql_handle, 20, &data, NULL); hd->vaporize = atoi(data);
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
hd->intimacy = cap_value(hd->intimacy, 0, 100000);
|
||||
hd->hunger = cap_value(hd->hunger, 0, 100);
|
||||
|
||||
// Load Homunculus Skill
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `skill_homunculus` WHERE `homun_id`=%d", homun_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
while( SQL_SUCCESS == Sql_NextRow(sql_handle) )
|
||||
{
|
||||
// id
|
||||
Sql_GetData(sql_handle, 0, &data, NULL);
|
||||
i = atoi(data);
|
||||
if( i < HM_SKILLBASE || i >= HM_SKILLBASE + MAX_HOMUNSKILL )
|
||||
continue;// invalid skill id
|
||||
i = i - HM_SKILLBASE;
|
||||
hd->hskill[i].id = (unsigned short)atoi(data);
|
||||
|
||||
// lv
|
||||
Sql_GetData(sql_handle, 1, &data, NULL);
|
||||
hd->hskill[i].lv = (unsigned char)atoi(data);
|
||||
}
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
if( save_log )
|
||||
ShowInfo("Homunculus loaded (%d - %s).\n", hd->hom_id, hd->name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int mapif_delete_homun(int fd,int hom_id)
|
||||
bool mapif_homunculus_delete(int homun_id)
|
||||
{
|
||||
mapif_delete_homun_ack(fd,inter_homun_delete(hom_id));
|
||||
return 0;
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `homunculus` WHERE `homun_id` = '%u'", homun_id)
|
||||
|| SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `skill_homunculus` WHERE `homun_id` = '%u'", homun_id)
|
||||
) {
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int mapif_rename_homun(int fd, int account_id, int char_id, char *name){
|
||||
bool mapif_homunculus_rename(char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
// Check Authorised letters/symbols in the name of the homun
|
||||
if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
|
||||
for (i = 0; i < NAME_LENGTH && name[i]; i++)
|
||||
if (strchr(char_name_letters, name[i]) == NULL) {
|
||||
mapif_rename_homun_ack(fd, account_id, char_id, 0, name);
|
||||
return 0;
|
||||
}
|
||||
} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
|
||||
for (i = 0; i < NAME_LENGTH && name[i]; i++)
|
||||
if (strchr(char_name_letters, name[i]) != NULL) {
|
||||
mapif_rename_homun_ack(fd, account_id, char_id, 0, name);
|
||||
return 0;
|
||||
}
|
||||
if( char_name_option == 1 )
|
||||
{// only letters/symbols in char_name_letters are authorised
|
||||
for( i = 0; i < NAME_LENGTH && name[i]; i++ )
|
||||
if( strchr(char_name_letters, name[i]) == NULL )
|
||||
return false;
|
||||
} else
|
||||
if( char_name_option == 2 )
|
||||
{// letters/symbols in char_name_letters are forbidden
|
||||
for( i = 0; i < NAME_LENGTH && name[i]; i++ )
|
||||
if( strchr(char_name_letters, name[i]) != NULL )
|
||||
return false;
|
||||
}
|
||||
|
||||
mapif_rename_homun_ack(fd, account_id, char_id, 1, name);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
int mapif_parse_SaveHomun(int fd)
|
||||
|
||||
static void mapif_parse_homunculus_create(int fd, int len, int account_id, struct s_homunculus* phd)
|
||||
{
|
||||
mapif_save_homun(fd,RFIFOL(fd,4),(struct s_homunculus *)RFIFOP(fd,8));
|
||||
return 0;
|
||||
bool result = mapif_homunculus_save(phd);
|
||||
mapif_homunculus_created(fd, account_id, phd, result);
|
||||
}
|
||||
|
||||
int mapif_parse_DeleteHomun(int fd)
|
||||
static void mapif_parse_homunculus_delete(int fd, int homun_id)
|
||||
{
|
||||
mapif_delete_homun(fd,RFIFOL(fd,2));
|
||||
return 0;
|
||||
bool result = mapif_homunculus_delete(homun_id);
|
||||
mapif_homunculus_deleted(fd, result);
|
||||
}
|
||||
|
||||
int mapif_parse_RenameHomun(int fd)
|
||||
static void mapif_parse_homunculus_load(int fd, int account_id, int homun_id)
|
||||
{
|
||||
mapif_rename_homun(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), (char*)RFIFOP(fd, 10));
|
||||
return 0;
|
||||
struct s_homunculus hd;
|
||||
bool result = mapif_homunculus_load(homun_id, &hd);
|
||||
mapif_homunculus_loaded(fd, account_id, ( result ? &hd : NULL ));
|
||||
}
|
||||
|
||||
int inter_homun_parse_frommap(int fd)
|
||||
static void mapif_parse_homunculus_save(int fd, int len, int account_id, struct s_homunculus* phd)
|
||||
{
|
||||
switch(RFIFOW(fd,0)){
|
||||
case 0x3090: mapif_create_homun(fd); break;
|
||||
case 0x3091: mapif_load_homun(fd); break;
|
||||
case 0x3092: mapif_parse_SaveHomun(fd); break;
|
||||
case 0x3093: mapif_parse_DeleteHomun(fd); break;
|
||||
case 0x3094: mapif_parse_RenameHomun(fd); break;
|
||||
default:
|
||||
return 0;
|
||||
bool result = mapif_homunculus_save(phd);
|
||||
mapif_homunculus_saved(fd, account_id, result);
|
||||
}
|
||||
|
||||
static void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, char* name)
|
||||
{
|
||||
bool result = mapif_homunculus_rename(name);
|
||||
mapif_homunculus_renamed(fd, account_id, char_id, result, name);
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* Inter Packets
|
||||
*------------------------------------------*/
|
||||
int inter_homunculus_parse_frommap(int fd)
|
||||
{
|
||||
unsigned short cmd = RFIFOW(fd,0);
|
||||
|
||||
switch( cmd )
|
||||
{
|
||||
case 0x3090: mapif_parse_homunculus_create(fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break;
|
||||
case 0x3091: mapif_parse_homunculus_load (fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
|
||||
case 0x3092: mapif_parse_homunculus_save (fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break;
|
||||
case 0x3093: mapif_parse_homunculus_delete(fd, (int)RFIFOL(fd,2)); break;
|
||||
case 0x3094: mapif_parse_homunculus_rename(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,15 +1,18 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INT_HOMUN_H_
|
||||
#define _INT_HOMUN_H_
|
||||
#ifndef _INT_HOMUN_SQL_H_
|
||||
#define _INT_HOMUN_SQL_H_
|
||||
|
||||
int inter_homun_init(void);
|
||||
void inter_homun_final(void);
|
||||
int inter_homun_save(void);
|
||||
int inter_homun_delete(int homun_id);
|
||||
int inter_homun_parse_frommap(int fd);
|
||||
struct s_homunculus;
|
||||
|
||||
extern char homun_txt[1024];
|
||||
int inter_homunculus_sql_init(void);
|
||||
void inter_homunculus_sql_final(void);
|
||||
int inter_homunculus_parse_frommap(int fd);
|
||||
|
||||
#endif /* _INT_HOMUN_H_ */
|
||||
bool mapif_homunculus_save(struct s_homunculus* hd);
|
||||
bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd);
|
||||
bool mapif_homunculus_delete(int homun_id);
|
||||
bool mapif_homunculus_rename(char *name);
|
||||
|
||||
#endif /* _INT_HOMUN_SQL_H_ */
|
||||
|
@ -136,8 +136,6 @@ bool mapif_mercenary_delete(int merc_id)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
|
||||
static void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag)
|
||||
{
|
||||
int size = sizeof(struct s_mercenary) + 5;
|
||||
@ -218,4 +216,3 @@ int inter_mercenary_parse_frommap(int fd)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
File diff suppressed because it is too large
Load Diff
@ -1,20 +1,32 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INT_PARTY_H_
|
||||
#define _INT_PARTY_H_
|
||||
#ifndef _INT_PARTY_SQL_H_
|
||||
#define _INT_PARTY_SQL_H_
|
||||
|
||||
//Party Flags on what to save/delete.
|
||||
//Create a new party entry (index holds leader's info)
|
||||
#define PS_CREATE 0x01
|
||||
//Update basic party info.
|
||||
#define PS_BASIC 0x02
|
||||
//Update party's leader
|
||||
#define PS_LEADER 0x04
|
||||
//Specify new party member (index specifies which party member)
|
||||
#define PS_ADDMEMBER 0x08
|
||||
//Specify member that left (index specifies which party member)
|
||||
#define PS_DELMEMBER 0x10
|
||||
//Specify that this party must be deleted.
|
||||
#define PS_BREAK 0x20
|
||||
|
||||
struct party;
|
||||
|
||||
int inter_party_init(void);
|
||||
void inter_party_final(void);
|
||||
int inter_party_save(void);
|
||||
int inter_party_parse_frommap(int fd);
|
||||
int inter_party_sql_init(void);
|
||||
void inter_party_sql_final(void);
|
||||
int inter_party_leave(int party_id,int account_id, int char_id);
|
||||
int inter_party_CharOnline(int char_id, int party_id);
|
||||
int inter_party_CharOffline(int char_id, int party_id);
|
||||
//Required for the TXT->SQL converter
|
||||
int inter_party_tosql(struct party *p, int flag, int index);
|
||||
|
||||
extern char party_txt[1024];
|
||||
|
||||
//For the TXT->SQL converter
|
||||
int inter_party_fromstr(char *str, struct party *p);
|
||||
|
||||
#endif /* _INT_PARTY_H_ */
|
||||
#endif /* _INT_PARTY_SQL_H_ */
|
||||
|
@ -4,307 +4,251 @@
|
||||
#include "../common/mmo.h"
|
||||
#include "../common/malloc.h"
|
||||
#include "../common/socket.h"
|
||||
#include "../common/db.h"
|
||||
#include "../common/lock.h"
|
||||
#include "../common/strlib.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/utils.h"
|
||||
#include "../common/sql.h"
|
||||
#include "char.h"
|
||||
#include "inter.h"
|
||||
#include "int_pet.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char pet_txt[1024]="save/pet.txt";
|
||||
struct s_pet *pet_pt;
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
static DBMap* pet_db; // int pet_id -> struct s_pet*
|
||||
static int pet_newid = 100;
|
||||
|
||||
int inter_pet_tostr(char *str,struct s_pet *p)
|
||||
//---------------------------------------------------------
|
||||
int inter_pet_tosql(int pet_id, struct s_pet* p)
|
||||
{
|
||||
int len;
|
||||
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`)
|
||||
char esc_name[NAME_LENGTH*2+1];// escaped pet name
|
||||
|
||||
if(p->hungry < 0)
|
||||
p->hungry = 0;
|
||||
else if(p->hungry > 100)
|
||||
p->hungry = 100;
|
||||
if(p->intimate < 0)
|
||||
p->intimate = 0;
|
||||
else if(p->intimate > 1000)
|
||||
p->intimate = 1000;
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
|
||||
p->hungry = cap_value(p->hungry, 0, 100);
|
||||
p->intimate = cap_value(p->intimate, 0, 1000);
|
||||
|
||||
len=sprintf(str,"%d,%d,%s\t%d,%d,%d,%d,%d,%d,%d,%d,%d",
|
||||
p->pet_id,p->class_,p->name,p->account_id,p->char_id,p->level,p->egg_id,
|
||||
p->equip,p->intimate,p->hungry,p->rename_flag,p->incuvate);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
||||
int inter_pet_fromstr(char *str,struct s_pet *p)
|
||||
{
|
||||
int s;
|
||||
int tmp_int[16];
|
||||
char tmp_str[256];
|
||||
|
||||
memset(p,0,sizeof(struct s_pet));
|
||||
|
||||
s=sscanf(str,"%d,%d,%[^\t]\t%d,%d,%d,%d,%d,%d,%d,%d,%d",&tmp_int[0],&tmp_int[1],tmp_str,&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]);
|
||||
|
||||
if(s!=12)
|
||||
return 1;
|
||||
|
||||
p->pet_id = tmp_int[0];
|
||||
p->class_ = tmp_int[1];
|
||||
memcpy(p->name,tmp_str,NAME_LENGTH);
|
||||
p->account_id = tmp_int[2];
|
||||
p->char_id = tmp_int[3];
|
||||
p->level = tmp_int[4];
|
||||
p->egg_id = tmp_int[5];
|
||||
p->equip = tmp_int[6];
|
||||
p->intimate = tmp_int[7];
|
||||
p->hungry = tmp_int[8];
|
||||
p->rename_flag = tmp_int[9];
|
||||
p->incuvate = tmp_int[10];
|
||||
|
||||
if(p->hungry < 0)
|
||||
p->hungry = 0;
|
||||
else if(p->hungry > 100)
|
||||
p->hungry = 100;
|
||||
if(p->intimate < 0)
|
||||
p->intimate = 0;
|
||||
else if(p->intimate > 1000)
|
||||
p->intimate = 1000;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
int inter_pet_init()
|
||||
{
|
||||
char line[8192];
|
||||
struct s_pet *p;
|
||||
FILE *fp;
|
||||
int c=0;
|
||||
|
||||
pet_db= idb_alloc(DB_OPT_RELEASE_DATA);
|
||||
|
||||
if( (fp=fopen(pet_txt,"r"))==NULL )
|
||||
return 1;
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
p = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1);
|
||||
if(p==NULL){
|
||||
ShowFatalError("int_pet: out of memory!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
if( pet_id == -1 )
|
||||
{// New pet.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` "
|
||||
"(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) "
|
||||
"VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
|
||||
pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
|
||||
p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
memset(p,0,sizeof(struct s_pet));
|
||||
if(inter_pet_fromstr(line,p)==0 && p->pet_id>0){
|
||||
if( p->pet_id >= pet_newid)
|
||||
pet_newid=p->pet_id+1;
|
||||
idb_put(pet_db,p->pet_id,p);
|
||||
}else{
|
||||
ShowError("int_pet: broken data [%s] line %d\n",pet_txt,c);
|
||||
aFree(p);
|
||||
}
|
||||
c++;
|
||||
}
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void inter_pet_final()
|
||||
{
|
||||
pet_db->destroy(pet_db, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
int inter_pet_save_sub(DBKey key,void *data,va_list ap)
|
||||
{
|
||||
char line[8192];
|
||||
FILE *fp;
|
||||
inter_pet_tostr(line,(struct s_pet *)data);
|
||||
fp=va_arg(ap,FILE *);
|
||||
fprintf(fp,"%s\n",line);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int inter_pet_save()
|
||||
{
|
||||
FILE *fp;
|
||||
int lock;
|
||||
if( (fp=lock_fopen(pet_txt,&lock))==NULL ){
|
||||
ShowError("int_pet: can't write [%s] !!! data is lost !!!\n",pet_txt);
|
||||
return 1;
|
||||
}
|
||||
pet_db->foreach(pet_db,inter_pet_save_sub,fp);
|
||||
lock_fclose(fp,pet_txt,&lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int inter_pet_delete(int pet_id)
|
||||
{
|
||||
struct s_pet *p;
|
||||
p = (struct s_pet*)idb_get(pet_db,pet_id);
|
||||
if( p == NULL)
|
||||
return 1;
|
||||
else {
|
||||
idb_remove(pet_db,pet_id);
|
||||
ShowInfo("Deleted pet (pet_id: %d)\n",pet_id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_pet_created(int fd,int account_id,struct s_pet *p)
|
||||
{
|
||||
WFIFOHEAD(fd, 11);
|
||||
WFIFOW(fd,0)=0x3880;
|
||||
WFIFOL(fd,2)=account_id;
|
||||
if(p!=NULL){
|
||||
WFIFOB(fd,6)=0;
|
||||
WFIFOL(fd,7)=p->pet_id;
|
||||
ShowInfo("Created pet (%d - %s)\n",p->pet_id,p->name);
|
||||
}else{
|
||||
WFIFOB(fd,6)=1;
|
||||
WFIFOL(fd,7)=0;
|
||||
}
|
||||
WFIFOSET(fd,11);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_pet_info(int fd,int account_id,struct s_pet *p)
|
||||
{
|
||||
WFIFOHEAD(fd, sizeof(struct s_pet) + 9);
|
||||
WFIFOW(fd,0)=0x3881;
|
||||
WFIFOW(fd,2)=sizeof(struct s_pet) + 9;
|
||||
WFIFOL(fd,4)=account_id;
|
||||
WFIFOB(fd,8)=0;
|
||||
memcpy(WFIFOP(fd,9),p,sizeof(struct s_pet));
|
||||
WFIFOSET(fd,WFIFOW(fd,2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_pet_noinfo(int fd,int account_id)
|
||||
{
|
||||
WFIFOHEAD(fd, sizeof(struct s_pet) + 9);
|
||||
WFIFOW(fd,0)=0x3881;
|
||||
WFIFOW(fd,2)=sizeof(struct s_pet) + 9;
|
||||
WFIFOL(fd,4)=account_id;
|
||||
WFIFOB(fd,8)=1;
|
||||
memset(WFIFOP(fd,9),0,sizeof(struct s_pet));
|
||||
WFIFOSET(fd,WFIFOW(fd,2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_save_pet_ack(int fd,int account_id,int flag)
|
||||
{
|
||||
WFIFOHEAD(fd, 7);
|
||||
WFIFOW(fd,0)=0x3882;
|
||||
WFIFOL(fd,2)=account_id;
|
||||
WFIFOB(fd,6)=flag;
|
||||
WFIFOSET(fd,7);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_delete_pet_ack(int fd,int flag)
|
||||
{
|
||||
WFIFOHEAD(fd, 3);
|
||||
WFIFOW(fd,0)=0x3883;
|
||||
WFIFOB(fd,2)=flag;
|
||||
WFIFOSET(fd,3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet_lv,short pet_egg_id,
|
||||
short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name)
|
||||
{
|
||||
struct s_pet *p;
|
||||
p= (struct s_pet *) aCalloc(sizeof(struct s_pet), 1);
|
||||
if(p==NULL){
|
||||
ShowFatalError("int_pet: out of memory !\n");
|
||||
mapif_pet_created(fd,account_id,NULL);
|
||||
return 0;
|
||||
}
|
||||
// memset(p,0,sizeof(struct s_pet)); unnecessary after aCalloc [Skotlex]
|
||||
p->pet_id = pet_newid++;
|
||||
memcpy(p->name,pet_name,NAME_LENGTH);
|
||||
if(incuvate == 1)
|
||||
p->account_id = p->char_id = 0;
|
||||
else {
|
||||
p->account_id = account_id;
|
||||
p->char_id = char_id;
|
||||
}
|
||||
p->class_ = pet_class;
|
||||
p->level = pet_lv;
|
||||
p->egg_id = pet_egg_id;
|
||||
p->equip = pet_equip;
|
||||
p->intimate = intimate;
|
||||
p->hungry = hungry;
|
||||
p->rename_flag = rename_flag;
|
||||
p->incuvate = incuvate;
|
||||
|
||||
if(p->hungry < 0)
|
||||
p->hungry = 0;
|
||||
else if(p->hungry > 100)
|
||||
p->hungry = 100;
|
||||
if(p->intimate < 0)
|
||||
p->intimate = 0;
|
||||
else if(p->intimate > 1000)
|
||||
p->intimate = 1000;
|
||||
|
||||
idb_put(pet_db,p->pet_id,p);
|
||||
|
||||
mapif_pet_created(fd,account_id,p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_load_pet(int fd,int account_id,int char_id,int pet_id)
|
||||
{
|
||||
struct s_pet *p;
|
||||
p = (struct s_pet*)idb_get(pet_db,pet_id);
|
||||
if(p!=NULL) {
|
||||
if(p->incuvate == 1) {
|
||||
p->account_id = p->char_id = 0;
|
||||
mapif_pet_info(fd,account_id,p);
|
||||
}
|
||||
else if(account_id == p->account_id && char_id == p->char_id)
|
||||
mapif_pet_info(fd,account_id,p);
|
||||
else
|
||||
mapif_pet_noinfo(fd,account_id);
|
||||
p->pet_id = (int)Sql_LastInsertId(sql_handle);
|
||||
}
|
||||
else
|
||||
mapif_pet_noinfo(fd,account_id);
|
||||
{// Update pet.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incuvate`='%d' WHERE `pet_id`='%d'",
|
||||
pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
|
||||
p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate, p->pet_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (save_log)
|
||||
ShowInfo("Pet saved %d - %s.\n", pet_id, p->name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int inter_pet_fromsql(int pet_id, struct s_pet* p)
|
||||
{
|
||||
char* data;
|
||||
size_t len;
|
||||
|
||||
#ifdef NOISY
|
||||
ShowInfo("Loading pet (%d)...\n",pet_id);
|
||||
#endif
|
||||
memset(p, 0, sizeof(struct s_pet));
|
||||
|
||||
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`)
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
|
||||
{
|
||||
p->pet_id = pet_id;
|
||||
Sql_GetData(sql_handle, 1, &data, NULL); p->class_ = atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH));
|
||||
Sql_GetData(sql_handle, 3, &data, NULL); p->account_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 4, &data, NULL); p->char_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 5, &data, NULL); p->level = atoi(data);
|
||||
Sql_GetData(sql_handle, 6, &data, NULL); p->egg_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 7, &data, NULL); p->equip = atoi(data);
|
||||
Sql_GetData(sql_handle, 8, &data, NULL); p->intimate = atoi(data);
|
||||
Sql_GetData(sql_handle, 9, &data, NULL); p->hungry = atoi(data);
|
||||
Sql_GetData(sql_handle, 10, &data, NULL); p->rename_flag = atoi(data);
|
||||
Sql_GetData(sql_handle, 11, &data, NULL); p->incuvate = atoi(data);
|
||||
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
p->hungry = cap_value(p->hungry, 0, 100);
|
||||
p->intimate = cap_value(p->intimate, 0, 1000);
|
||||
|
||||
if( save_log )
|
||||
ShowInfo("Pet loaded (%d - %s).\n", pet_id, p->name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//----------------------------------------------
|
||||
|
||||
int inter_pet_sql_init(void){
|
||||
//memory alloc
|
||||
pet_pt = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1);
|
||||
return 0;
|
||||
}
|
||||
void inter_pet_sql_final(void){
|
||||
if (pet_pt) aFree(pet_pt);
|
||||
return;
|
||||
}
|
||||
//----------------------------------
|
||||
int inter_pet_delete(int pet_id){
|
||||
ShowInfo("delete pet request: %d...\n",pet_id);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
//------------------------------------------------------
|
||||
int mapif_pet_created(int fd, int account_id, struct s_pet *p)
|
||||
{
|
||||
WFIFOHEAD(fd, 11);
|
||||
WFIFOW(fd, 0) =0x3880;
|
||||
WFIFOL(fd, 2) =account_id;
|
||||
if(p!=NULL){
|
||||
WFIFOB(fd, 6)=0;
|
||||
WFIFOL(fd, 7) =p->pet_id;
|
||||
ShowInfo("int_pet: created pet %d - %s\n", p->pet_id, p->name);
|
||||
}else{
|
||||
WFIFOB(fd, 6)=1;
|
||||
WFIFOL(fd, 7)=0;
|
||||
}
|
||||
WFIFOSET(fd, 11);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void* create_pet(DBKey key, va_list args) {
|
||||
struct s_pet *p;
|
||||
p=(struct s_pet *)aCalloc(sizeof(struct s_pet),1);
|
||||
p->pet_id = key.i;
|
||||
return p;
|
||||
int mapif_pet_info(int fd, int account_id, struct s_pet *p){
|
||||
WFIFOHEAD(fd, sizeof(struct s_pet) + 9);
|
||||
WFIFOW(fd, 0) =0x3881;
|
||||
WFIFOW(fd, 2) =sizeof(struct s_pet) + 9;
|
||||
WFIFOL(fd, 4) =account_id;
|
||||
WFIFOB(fd, 8)=0;
|
||||
memcpy(WFIFOP(fd, 9), p, sizeof(struct s_pet));
|
||||
WFIFOSET(fd, WFIFOW(fd, 2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
int mapif_save_pet(int fd,int account_id,struct s_pet *data)
|
||||
|
||||
int mapif_pet_noinfo(int fd, int account_id){
|
||||
WFIFOHEAD(fd, sizeof(struct s_pet) + 9);
|
||||
WFIFOW(fd, 0) =0x3881;
|
||||
WFIFOW(fd, 2) =sizeof(struct s_pet) + 9;
|
||||
WFIFOL(fd, 4) =account_id;
|
||||
WFIFOB(fd, 8)=1;
|
||||
memset(WFIFOP(fd, 9), 0, sizeof(struct s_pet));
|
||||
WFIFOSET(fd, WFIFOW(fd, 2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_save_pet_ack(int fd, int account_id, int flag){
|
||||
WFIFOHEAD(fd, 7);
|
||||
WFIFOW(fd, 0) =0x3882;
|
||||
WFIFOL(fd, 2) =account_id;
|
||||
WFIFOB(fd, 6) =flag;
|
||||
WFIFOSET(fd, 7);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_delete_pet_ack(int fd, int flag){
|
||||
WFIFOHEAD(fd, 3);
|
||||
WFIFOW(fd, 0) =0x3883;
|
||||
WFIFOB(fd, 2) =flag;
|
||||
WFIFOSET(fd, 3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id,
|
||||
short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name)
|
||||
{
|
||||
struct s_pet *p;
|
||||
int pet_id, len;
|
||||
RFIFOHEAD(fd);
|
||||
len=RFIFOW(fd,2);
|
||||
|
||||
if(sizeof(struct s_pet)!=len-8) {
|
||||
ShowError("inter pet: data size error %d %d\n",sizeof(struct s_pet),len-8);
|
||||
memset(pet_pt, 0, sizeof(struct s_pet));
|
||||
strncpy(pet_pt->name, pet_name, NAME_LENGTH);
|
||||
if(incuvate == 1)
|
||||
pet_pt->account_id = pet_pt->char_id = 0;
|
||||
else {
|
||||
pet_pt->account_id = account_id;
|
||||
pet_pt->char_id = char_id;
|
||||
}
|
||||
pet_pt->class_ = pet_class;
|
||||
pet_pt->level = pet_lv;
|
||||
pet_pt->egg_id = pet_egg_id;
|
||||
pet_pt->equip = pet_equip;
|
||||
pet_pt->intimate = intimate;
|
||||
pet_pt->hungry = hungry;
|
||||
pet_pt->rename_flag = rename_flag;
|
||||
pet_pt->incuvate = incuvate;
|
||||
|
||||
if(pet_pt->hungry < 0)
|
||||
pet_pt->hungry = 0;
|
||||
else if(pet_pt->hungry > 100)
|
||||
pet_pt->hungry = 100;
|
||||
if(pet_pt->intimate < 0)
|
||||
pet_pt->intimate = 0;
|
||||
else if(pet_pt->intimate > 1000)
|
||||
pet_pt->intimate = 1000;
|
||||
|
||||
pet_pt->pet_id = -1; //Signal NEW pet.
|
||||
if (inter_pet_tosql(pet_pt->pet_id,pet_pt))
|
||||
mapif_pet_created(fd, account_id, pet_pt);
|
||||
else //Failed...
|
||||
mapif_pet_created(fd, account_id, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_load_pet(int fd, int account_id, int char_id, int pet_id){
|
||||
memset(pet_pt, 0, sizeof(struct s_pet));
|
||||
|
||||
inter_pet_fromsql(pet_id, pet_pt);
|
||||
|
||||
if(pet_pt!=NULL) {
|
||||
if(pet_pt->incuvate == 1) {
|
||||
pet_pt->account_id = pet_pt->char_id = 0;
|
||||
mapif_pet_info(fd, account_id, pet_pt);
|
||||
}
|
||||
else if(account_id == pet_pt->account_id && char_id == pet_pt->char_id)
|
||||
mapif_pet_info(fd, account_id, pet_pt);
|
||||
else
|
||||
mapif_pet_noinfo(fd, account_id);
|
||||
}
|
||||
else
|
||||
mapif_pet_noinfo(fd, account_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_save_pet(int fd, int account_id, struct s_pet *data) {
|
||||
//here process pet save request.
|
||||
int len;
|
||||
RFIFOHEAD(fd);
|
||||
len=RFIFOW(fd, 2);
|
||||
if(sizeof(struct s_pet)!=len-8) {
|
||||
ShowError("inter pet: data size error %d %d\n", sizeof(struct s_pet), len-8);
|
||||
}
|
||||
|
||||
else{
|
||||
pet_id = data->pet_id;
|
||||
if (pet_id == 0)
|
||||
pet_id = data->pet_id = pet_newid++;
|
||||
p = (struct s_pet*)idb_ensure(pet_db,pet_id,create_pet);
|
||||
if(data->hungry < 0)
|
||||
data->hungry = 0;
|
||||
else if(data->hungry > 100)
|
||||
@ -313,61 +257,47 @@ int mapif_save_pet(int fd,int account_id,struct s_pet *data)
|
||||
data->intimate = 0;
|
||||
else if(data->intimate > 1000)
|
||||
data->intimate = 1000;
|
||||
memcpy(p,data,sizeof(struct s_pet));
|
||||
if(p->incuvate == 1)
|
||||
p->account_id = p->char_id = 0;
|
||||
|
||||
mapif_save_pet_ack(fd,account_id,0);
|
||||
inter_pet_tosql(data->pet_id,data);
|
||||
mapif_save_pet_ack(fd, account_id, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_delete_pet(int fd,int pet_id)
|
||||
{
|
||||
mapif_delete_pet_ack(fd,inter_pet_delete(pet_id));
|
||||
int mapif_delete_pet(int fd, int pet_id){
|
||||
mapif_delete_pet_ack(fd, inter_pet_delete(pet_id));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_parse_CreatePet(int fd)
|
||||
{
|
||||
int mapif_parse_CreatePet(int fd){
|
||||
RFIFOHEAD(fd);
|
||||
mapif_create_pet(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOW(fd,14),RFIFOW(fd,16),RFIFOW(fd,18),
|
||||
RFIFOW(fd,20),RFIFOB(fd,22),RFIFOB(fd,23),(char*)RFIFOP(fd,24));
|
||||
mapif_create_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOW(fd, 10), RFIFOW(fd, 12), RFIFOW(fd, 14), RFIFOW(fd, 16), RFIFOW(fd, 18),
|
||||
RFIFOW(fd, 20), RFIFOB(fd, 22), RFIFOB(fd, 23), (char*)RFIFOP(fd, 24));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_parse_LoadPet(int fd)
|
||||
{
|
||||
int mapif_parse_LoadPet(int fd){
|
||||
RFIFOHEAD(fd);
|
||||
mapif_load_pet(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOL(fd,10));
|
||||
mapif_load_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOL(fd, 10));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_parse_SavePet(int fd)
|
||||
{
|
||||
int mapif_parse_SavePet(int fd){
|
||||
RFIFOHEAD(fd);
|
||||
mapif_save_pet(fd,RFIFOL(fd,4),(struct s_pet *)RFIFOP(fd,8));
|
||||
mapif_save_pet(fd, RFIFOL(fd, 4), (struct s_pet *) RFIFOP(fd, 8));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_parse_DeletePet(int fd)
|
||||
{
|
||||
int mapif_parse_DeletePet(int fd){
|
||||
RFIFOHEAD(fd);
|
||||
mapif_delete_pet(fd,RFIFOL(fd,2));
|
||||
mapif_delete_pet(fd, RFIFOL(fd, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
// map server からの通信
|
||||
// ・1パケットのみ解析すること
|
||||
// ・パケット長データはinter.cにセットしておくこと
|
||||
// ・パケット長チェックや、RFIFOSKIPは呼び出し元で行われるので行ってはならない
|
||||
// ・エラーなら0(false)、そうでないなら1(true)をかえさなければならない
|
||||
int inter_pet_parse_frommap(int fd)
|
||||
{
|
||||
int inter_pet_parse_frommap(int fd){
|
||||
RFIFOHEAD(fd);
|
||||
switch(RFIFOW(fd,0)){
|
||||
switch(RFIFOW(fd, 0)){
|
||||
case 0x3080: mapif_parse_CreatePet(fd); break;
|
||||
case 0x3081: mapif_parse_LoadPet(fd); break;
|
||||
case 0x3082: mapif_parse_SavePet(fd); break;
|
||||
@ -377,4 +307,3 @@ int inter_pet_parse_frommap(int fd)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
||||
|
@ -1,21 +1,21 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INT_PET_H_
|
||||
#define _INT_PET_H_
|
||||
#ifndef _INT_PET_SQL_H_
|
||||
#define _INT_PET_SQL_H_
|
||||
|
||||
struct s_pet;
|
||||
|
||||
int inter_pet_init(void);
|
||||
void inter_pet_final(void);
|
||||
void inter_pet_sql_final(void);
|
||||
int inter_pet_save(void);
|
||||
int inter_pet_delete(int pet_id);
|
||||
|
||||
int inter_pet_parse_frommap(int fd);
|
||||
|
||||
extern char pet_txt[1024];
|
||||
int inter_pet_sql_init(void);
|
||||
//extern char pet_txt[256];
|
||||
|
||||
//Exported for use in the TXT-SQL converter.
|
||||
int inter_pet_fromstr(char *str,struct s_pet *p);
|
||||
int inter_pet_tosql(int pet_id, struct s_pet *p);
|
||||
|
||||
#endif /* _INT_PET_H_ */
|
||||
#endif /* _INT_PET_SQL_H_ */
|
||||
|
@ -1,183 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/mmo.h"
|
||||
#include "../common/db.h"
|
||||
#include "../common/lock.h"
|
||||
#include "../common/malloc.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "int_status.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
// Contains all the status change data in-memory. [Skotlex]
|
||||
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)
|
||||
{
|
||||
struct scdata *data;
|
||||
data = (struct scdata*)aCalloc(1, sizeof(struct scdata));
|
||||
data->account_id = va_arg(args, int);
|
||||
data->char_id = key.i;
|
||||
return data;
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* Loads status change data of the player given. [Skotlex]
|
||||
*------------------------------------------*/
|
||||
struct scdata* status_search_scdata(int aid, int cid)
|
||||
{
|
||||
return (struct scdata*)scdata_db->ensure(scdata_db, db_i2key(cid), create_scdata, aid);
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* Deletes status change data of the player given. [Skotlex]
|
||||
* Should be invoked after the data of said player was successfully loaded.
|
||||
*------------------------------------------*/
|
||||
void status_delete_scdata(int aid, int cid)
|
||||
{
|
||||
struct scdata* scdata = (struct scdata*)idb_remove(scdata_db, cid);
|
||||
if (scdata)
|
||||
{
|
||||
if (scdata->data)
|
||||
aFree(scdata->data);
|
||||
aFree(scdata);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void inter_status_tostr(char* line, struct scdata *sc_data)
|
||||
{
|
||||
int i, len;
|
||||
|
||||
len = sprintf(line, "%d,%d,%d\t", sc_data->account_id, sc_data->char_id, sc_data->count);
|
||||
for(i = 0; i < sc_data->count; i++) {
|
||||
len += sprintf(line + len, "%d,%ld,%ld,%ld,%ld,%ld\t", sc_data->data[i].type, sc_data->data[i].tick,
|
||||
sc_data->data[i].val1, sc_data->data[i].val2, sc_data->data[i].val3, sc_data->data[i].val4);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static int inter_scdata_fromstr(char *line, struct scdata *sc_data)
|
||||
{
|
||||
int i, len, next;
|
||||
|
||||
if (sscanf(line,"%d,%d,%d\t%n",&sc_data->account_id, &sc_data->char_id, &sc_data->count, &next) < 3)
|
||||
return 0;
|
||||
|
||||
if (sc_data->count < 1)
|
||||
return 0;
|
||||
|
||||
sc_data->data = (struct status_change_data*)aCalloc(sc_data->count, sizeof (struct status_change_data));
|
||||
|
||||
for (i = 0; i < sc_data->count; i++)
|
||||
{
|
||||
if (sscanf(line + next, "%hu,%ld,%ld,%ld,%ld,%ld\t%n", &sc_data->data[i].type, &sc_data->data[i].tick,
|
||||
&sc_data->data[i].val1, &sc_data->data[i].val2, &sc_data->data[i].val3, &sc_data->data[i].val4, &len) < 6)
|
||||
{
|
||||
aFree(sc_data->data);
|
||||
return 0;
|
||||
}
|
||||
next+=len;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*==========================================
|
||||
* Loads all scdata from the given filename.
|
||||
*------------------------------------------*/
|
||||
void status_load_scdata(const char* filename)
|
||||
{
|
||||
FILE *fp;
|
||||
int sd_count=0, sc_count=0;
|
||||
char line[8192];
|
||||
struct scdata *sc;
|
||||
|
||||
if ((fp = fopen(filename, "r")) == NULL) {
|
||||
ShowError("status_load_scdata: Cannot open file %s!\n", filename);
|
||||
return;
|
||||
}
|
||||
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
sc = (struct scdata*)aCalloc(1, sizeof(struct scdata));
|
||||
if (inter_scdata_fromstr(line, sc)) {
|
||||
sd_count++;
|
||||
sc_count+= sc->count;
|
||||
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);
|
||||
aFree(sc);
|
||||
}
|
||||
} else {
|
||||
ShowError("status_load_scdata: Broken line data: %s\n", line);
|
||||
aFree(sc);
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
ShowStatus("Loaded %d saved status changes for %d characters.\n", sc_count, sd_count);
|
||||
}
|
||||
|
||||
static int inter_status_save_sub(DBKey key, void *data, va_list ap) {
|
||||
char line[8192];
|
||||
struct scdata * sc_data;
|
||||
FILE *fp;
|
||||
|
||||
sc_data = (struct scdata *)data;
|
||||
if (sc_data->count < 1)
|
||||
return 0;
|
||||
|
||||
fp = va_arg(ap, FILE *);
|
||||
inter_status_tostr(line, sc_data);
|
||||
fprintf(fp, "%s\n", line);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* Saves all scdata to the given filename.
|
||||
*------------------------------------------*/
|
||||
void inter_status_save()
|
||||
{
|
||||
FILE *fp;
|
||||
int lock;
|
||||
|
||||
if ((fp = lock_fopen(scdata_txt, &lock)) == NULL) {
|
||||
ShowError("int_status: can't write [%s] !!! data is lost !!!\n", scdata_txt);
|
||||
return;
|
||||
}
|
||||
scdata_db->foreach(scdata_db, inter_status_save_sub, fp);
|
||||
lock_fclose(fp,scdata_txt, &lock);
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* Initializes db.
|
||||
*------------------------------------------*/
|
||||
void status_init()
|
||||
{
|
||||
scdata_db = idb_alloc(DB_OPT_BASE);
|
||||
status_load_scdata(scdata_txt);
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* Frees up memory.
|
||||
*------------------------------------------*/
|
||||
static int scdata_db_final(DBKey k,void *d,va_list ap)
|
||||
{
|
||||
struct scdata *data = (struct scdata*)d;
|
||||
if (data->data)
|
||||
aFree(data->data);
|
||||
aFree(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* Final cleanup.
|
||||
*------------------------------------------*/
|
||||
void status_final(void)
|
||||
{
|
||||
scdata_db->destroy(scdata_db, scdata_db_final);
|
||||
}
|
||||
|
||||
#endif //ENABLE_SC_SAVING
|
@ -1,23 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INT_STATUS_H_
|
||||
#define _INT_STATUS_H_
|
||||
|
||||
struct status_change_data;
|
||||
|
||||
struct scdata {
|
||||
int account_id, char_id;
|
||||
int count;
|
||||
struct status_change_data* data;
|
||||
};
|
||||
|
||||
extern char scdata_txt[1024];
|
||||
|
||||
struct scdata* status_search_scdata(int aid, int cid);
|
||||
void status_delete_scdata(int aid, int cid);
|
||||
void inter_status_save(void);
|
||||
void status_init(void);
|
||||
void status_final(void);
|
||||
|
||||
#endif /* _INT_STATUS_H_ */
|
@ -3,414 +3,184 @@
|
||||
|
||||
#include "../common/mmo.h"
|
||||
#include "../common/malloc.h"
|
||||
#include "../common/socket.h"
|
||||
#include "../common/db.h"
|
||||
#include "../common/lock.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/utils.h"
|
||||
#include "../common/socket.h"
|
||||
#include "../common/strlib.h" // StringBuf
|
||||
#include "../common/sql.h"
|
||||
#include "char.h"
|
||||
#include "inter.h"
|
||||
#include "int_storage.h"
|
||||
#include "int_pet.h"
|
||||
#include "int_guild.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
// ファイル名のデフォルト
|
||||
// inter_config_read()で再設定される
|
||||
char storage_txt[1024]="save/storage.txt";
|
||||
char guild_storage_txt[1024]="save/g_storage.txt";
|
||||
|
||||
static DBMap* storage_db = NULL; // int account_id -> struct storage_data*
|
||||
static DBMap* guild_storage_db = NULL; // int guild_id -> struct guild_storage*
|
||||
#define STORAGE_MEMINC 16
|
||||
|
||||
// 倉庫データを文字列に変換
|
||||
bool storage_tostr(char* str, int account_id, struct storage_data* p)
|
||||
/// Save storage data to sql
|
||||
int storage_tosql(int account_id, struct storage_data* p)
|
||||
{
|
||||
int i,j;
|
||||
char *str_p = str;
|
||||
str_p += sprintf(str_p, "%d,%d\t", account_id, p->storage_amount);
|
||||
|
||||
for( i = 0; i < MAX_STORAGE; i++ )
|
||||
if( p->items[i].nameid > 0 && p->items[i].amount > 0 )
|
||||
{
|
||||
str_p += sprintf(str_p, "%d,%d,%d,%d,%d,%d,%d",
|
||||
p->items[i].id,p->items[i].nameid,p->items[i].amount,p->items[i].equip,
|
||||
p->items[i].identify,p->items[i].refine,p->items[i].attribute);
|
||||
for(j=0; j<MAX_SLOTS; j++)
|
||||
str_p += sprintf(str_p,",%d",p->items[i].card[j]);
|
||||
str_p += sprintf(str_p," ");
|
||||
}
|
||||
|
||||
*(str_p++)='\t';
|
||||
|
||||
*str_p='\0';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 文字列を倉庫データに変換
|
||||
bool storage_fromstr(char* str, int* account_id, struct storage_data* p)
|
||||
{
|
||||
int tmp_int[256];
|
||||
char tmp_str[256];
|
||||
int next,len,i,j;
|
||||
|
||||
if( sscanf(str, "%d,%d%n", &tmp_int[0], &tmp_int[1], &next) != 2 )
|
||||
return false;
|
||||
|
||||
*account_id = tmp_int[0];
|
||||
p->storage_amount = tmp_int[1]; //FIXME: limit to MAX_STORAGE?
|
||||
|
||||
next++;
|
||||
for( i = 0; str[next] && str[next]!='\t' && i < MAX_STORAGE; i++ )
|
||||
{
|
||||
if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d%[0-9,-]%n",
|
||||
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
|
||||
&tmp_int[4], &tmp_int[5], &tmp_int[6], tmp_str, &len) != 8)
|
||||
return false;
|
||||
|
||||
p->items[i].id = tmp_int[0];
|
||||
p->items[i].nameid = tmp_int[1];
|
||||
p->items[i].amount = tmp_int[2];
|
||||
p->items[i].equip = tmp_int[3];
|
||||
p->items[i].identify = tmp_int[4];
|
||||
p->items[i].refine = tmp_int[5];
|
||||
p->items[i].attribute = tmp_int[6];
|
||||
|
||||
for(j = 0; j < MAX_SLOTS && tmp_str[0] && sscanf(tmp_str, ",%d%[0-9,-]",&tmp_int[0], tmp_str) > 0; j++)
|
||||
p->items[i].card[j] = tmp_int[0];
|
||||
|
||||
next += len;
|
||||
if (str[next] == ' ')
|
||||
next++;
|
||||
}
|
||||
|
||||
if( i >= MAX_STORAGE && str[next] && str[next] != '\t' )
|
||||
ShowWarning("storage_fromstr: Found a storage line with more items than MAX_STORAGE (%d), remaining items have been discarded!\n", MAX_STORAGE);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int guild_storage_tostr(char *str,struct guild_storage *p)
|
||||
{
|
||||
int i,j,f=0;
|
||||
char *str_p = str;
|
||||
str_p+=sprintf(str,"%d,%d\t",p->guild_id,p->storage_amount);
|
||||
|
||||
for(i=0;i<MAX_GUILD_STORAGE;i++)
|
||||
if( (p->items[i].nameid) && (p->items[i].amount) ){
|
||||
str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d",
|
||||
p->items[i].id,p->items[i].nameid,p->items[i].amount,p->items[i].equip,
|
||||
p->items[i].identify,p->items[i].refine,p->items[i].attribute);
|
||||
for(j=0; j<MAX_SLOTS; j++)
|
||||
str_p += sprintf(str_p,",%d",p->items[i].card[j]);
|
||||
str_p += sprintf(str_p," ");
|
||||
f++;
|
||||
}
|
||||
|
||||
*(str_p++)='\t';
|
||||
|
||||
*str_p='\0';
|
||||
if(!f)
|
||||
str[0]=0;
|
||||
memitemdata_to_sql(p->items, MAX_STORAGE, account_id, TABLE_STORAGE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int guild_storage_fromstr(char *str,struct guild_storage *p)
|
||||
/// Load storage data to mem
|
||||
int storage_fromsql(int account_id, struct storage_data* p)
|
||||
{
|
||||
int tmp_int[256];
|
||||
char tmp_str[256];
|
||||
int set,next,len,i,j;
|
||||
StringBuf buf;
|
||||
struct item* item;
|
||||
char* data;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
set=sscanf(str,"%d,%d%n",&tmp_int[0],&tmp_int[1],&next);
|
||||
p->storage_amount=tmp_int[1];
|
||||
memset(p, 0, sizeof(struct storage_data)); //clean up memory
|
||||
p->storage_amount = 0;
|
||||
|
||||
if(set!=2)
|
||||
return 1;
|
||||
if(str[next]=='\n' || str[next]=='\r')
|
||||
return 0;
|
||||
next++;
|
||||
for(i=0;str[next] && str[next]!='\t' && i < MAX_GUILD_STORAGE;i++){
|
||||
if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d%[0-9,-]%n",
|
||||
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
|
||||
&tmp_int[4], &tmp_int[5], &tmp_int[6], tmp_str, &len) == 8)
|
||||
// storage {`account_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`}
|
||||
StringBuf_Init(&buf);
|
||||
StringBuf_AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`expire_time`");
|
||||
for( j = 0; j < MAX_SLOTS; ++j )
|
||||
StringBuf_Printf(&buf, ",`card%d`", j);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `account_id`='%d' ORDER BY `nameid`", storage_db, account_id);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
StringBuf_Destroy(&buf);
|
||||
|
||||
for( i = 0; i < MAX_STORAGE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
|
||||
{
|
||||
item = &p->items[i];
|
||||
Sql_GetData(sql_handle, 0, &data, NULL); item->id = atoi(data);
|
||||
Sql_GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data);
|
||||
Sql_GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data);
|
||||
Sql_GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data);
|
||||
Sql_GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data);
|
||||
Sql_GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data);
|
||||
Sql_GetData(sql_handle, 7, &data, NULL); item->expire_time = (unsigned int)atoi(data);
|
||||
for( j = 0; j < MAX_SLOTS; ++j )
|
||||
{
|
||||
p->items[i].id = tmp_int[0];
|
||||
p->items[i].nameid = tmp_int[1];
|
||||
p->items[i].amount = tmp_int[2];
|
||||
p->items[i].equip = tmp_int[3];
|
||||
p->items[i].identify = tmp_int[4];
|
||||
p->items[i].refine = tmp_int[5];
|
||||
p->items[i].attribute = tmp_int[6];
|
||||
for(j = 0; j < MAX_SLOTS && tmp_str[0] && sscanf(tmp_str, ",%d%[0-9,-]",&tmp_int[0], tmp_str) > 0; j++)
|
||||
p->items[i].card[j] = tmp_int[0];
|
||||
next += len;
|
||||
if (str[next] == ' ')
|
||||
next++;
|
||||
Sql_GetData(sql_handle, 8+j, &data, NULL); item->card[j] = atoi(data);
|
||||
}
|
||||
else return 1;
|
||||
}
|
||||
if (i >= MAX_GUILD_STORAGE && str[next] && str[next]!='\t')
|
||||
ShowWarning("guild_storage_fromstr: Found a storage line with more items than MAX_GUILD_STORAGE (%d), remaining items have been discarded!\n", MAX_GUILD_STORAGE);
|
||||
p->storage_amount = i;
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
ShowInfo("storage load complete from DB - id: %d (total: %d)\n", account_id, p->storage_amount);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// Save guild_storage data to sql
|
||||
int guild_storage_tosql(int guild_id, struct guild_storage* p)
|
||||
{
|
||||
memitemdata_to_sql(p->items, MAX_GUILD_STORAGE, guild_id, TABLE_GUILD_STORAGE);
|
||||
ShowInfo ("guild storage save to DB - guild: %d\n", guild_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
|
||||
static void* create_storage(DBKey key, va_list args)
|
||||
/// Load guild_storage data to mem
|
||||
int guild_storage_fromsql(int guild_id, struct guild_storage* p)
|
||||
{
|
||||
return (struct storage_data *) aCalloc(sizeof(struct storage_data), 1);
|
||||
}
|
||||
StringBuf buf;
|
||||
struct item* item;
|
||||
char* data;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
static void* create_guildstorage(DBKey key, va_list args)
|
||||
{
|
||||
struct guild_storage* gs = NULL;
|
||||
gs = (struct guild_storage *) aCalloc(sizeof(struct guild_storage), 1);
|
||||
gs->guild_id=key.i;
|
||||
return gs;
|
||||
}
|
||||
memset(p, 0, sizeof(struct guild_storage)); //clean up memory
|
||||
p->storage_amount = 0;
|
||||
p->guild_id = guild_id;
|
||||
|
||||
/// Loads storage data into the provided data structure.
|
||||
/// If data doesn't exist, the destination is zeroed and false is returned.
|
||||
bool storage_load(int account_id, struct storage_data* storage)
|
||||
{
|
||||
struct storage_data* s = (struct storage_data*)idb_get(storage_db, account_id);
|
||||
// storage {`guild_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`}
|
||||
StringBuf_Init(&buf);
|
||||
StringBuf_AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`");
|
||||
for( j = 0; j < MAX_SLOTS; ++j )
|
||||
StringBuf_Printf(&buf, ",`card%d`", j);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `guild_id`='%d' ORDER BY `nameid`", guild_storage_db, guild_id);
|
||||
|
||||
if( s != NULL )
|
||||
memcpy(storage, s, sizeof(*storage));
|
||||
else
|
||||
memset(storage, 0x00, sizeof(*storage));
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
return( s != NULL );
|
||||
}
|
||||
StringBuf_Destroy(&buf);
|
||||
|
||||
/// Writes provided data into storage cache.
|
||||
/// If data contains 0 items, any existing entry in cache is destroyed.
|
||||
/// If data contains 1+ items and no cache entry exists, a new one is created.
|
||||
bool storage_save(int account_id, struct storage_data* storage)
|
||||
{
|
||||
if( storage->storage_amount > 0 )
|
||||
for( i = 0; i < MAX_GUILD_STORAGE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
|
||||
{
|
||||
struct storage_data* s = (struct storage_data*)idb_ensure(storage_db, account_id, create_storage);
|
||||
memcpy(s, storage, sizeof(*storage));
|
||||
}
|
||||
else
|
||||
{
|
||||
idb_remove(storage_db, account_id);
|
||||
item = &p->items[i];
|
||||
Sql_GetData(sql_handle, 0, &data, NULL); item->id = atoi(data);
|
||||
Sql_GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data);
|
||||
Sql_GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data);
|
||||
Sql_GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data);
|
||||
Sql_GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data);
|
||||
Sql_GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data);
|
||||
item->expire_time = 0;
|
||||
for( j = 0; j < MAX_SLOTS; ++j )
|
||||
{
|
||||
Sql_GetData(sql_handle, 7+j, &data, NULL); item->card[j] = atoi(data);
|
||||
}
|
||||
}
|
||||
p->storage_amount = i;
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
return true;
|
||||
ShowInfo("guild storage load complete from DB - id: %d (total: %d)\n", guild_id, p->storage_amount);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// 倉庫データを読み込む
|
||||
int inter_storage_init()
|
||||
// storage data initialize
|
||||
int inter_storage_sql_init(void)
|
||||
{
|
||||
char line[65536];
|
||||
int c = 0;
|
||||
FILE *fp;
|
||||
|
||||
storage_db = idb_alloc(DB_OPT_RELEASE_DATA);
|
||||
|
||||
fp=fopen(storage_txt,"r");
|
||||
if(fp==NULL){
|
||||
ShowError("can't read : %s\n",storage_txt);
|
||||
return 1;
|
||||
}
|
||||
while( fgets(line, sizeof(line), fp) )
|
||||
{
|
||||
int account_id;
|
||||
struct storage_data *s;
|
||||
|
||||
s = (struct storage_data*)aCalloc(sizeof(struct storage_data), 1);
|
||||
if( s == NULL )
|
||||
{
|
||||
ShowFatalError("int_storage: out of memory!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if( storage_fromstr(line,&account_id,s) )
|
||||
{
|
||||
idb_put(storage_db,account_id,s);
|
||||
}
|
||||
else{
|
||||
ShowError("int_storage: broken data in [%s] line %d\n",storage_txt,c);
|
||||
aFree(s);
|
||||
}
|
||||
c++;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
c = 0;
|
||||
guild_storage_db = idb_alloc(DB_OPT_RELEASE_DATA);
|
||||
|
||||
fp=fopen(guild_storage_txt,"r");
|
||||
if(fp==NULL){
|
||||
ShowError("can't read : %s\n",guild_storage_txt);
|
||||
return 1;
|
||||
}
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
int tmp_int;
|
||||
struct guild_storage *gs;
|
||||
|
||||
sscanf(line,"%d",&tmp_int);
|
||||
gs = (struct guild_storage*)aCalloc(sizeof(struct guild_storage), 1);
|
||||
if(gs==NULL){
|
||||
ShowFatalError("int_storage: out of memory!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// memset(gs,0,sizeof(struct guild_storage)); aCalloc...
|
||||
gs->guild_id=tmp_int;
|
||||
if(gs->guild_id > 0 && guild_storage_fromstr(line,gs) == 0) {
|
||||
idb_put(guild_storage_db,gs->guild_id,gs);
|
||||
}
|
||||
else{
|
||||
ShowError("int_storage: broken data [%s] line %d\n",guild_storage_txt,c);
|
||||
aFree(gs);
|
||||
}
|
||||
c++;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void inter_storage_final() {
|
||||
if(storage_db)
|
||||
{
|
||||
storage_db->destroy(storage_db, NULL);
|
||||
}
|
||||
if(guild_storage_db)
|
||||
{
|
||||
guild_storage_db->destroy(guild_storage_db, NULL);
|
||||
}
|
||||
// storage data finalize
|
||||
void inter_storage_sql_final(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// 倉庫データを書き込む
|
||||
int inter_storage_save()
|
||||
{
|
||||
struct DBIterator* iter;
|
||||
DBKey key;
|
||||
struct storage_data* data;
|
||||
FILE *fp;
|
||||
int lock;
|
||||
if( (fp=lock_fopen(storage_txt,&lock))==NULL ){
|
||||
ShowError("int_storage: can't write [%s] !!! data is lost !!!\n",storage_txt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
iter = storage_db->iterator(storage_db);
|
||||
for( data = (struct storage_data*)iter->first(iter,&key); iter->exists(iter); data = (struct storage_data*)iter->next(iter,&key) )
|
||||
{
|
||||
int account_id = key.i;
|
||||
char line[65536];
|
||||
storage_tostr(line,account_id,data);
|
||||
fprintf(fp,"%s\n",line);
|
||||
}
|
||||
iter->destroy(iter);
|
||||
|
||||
lock_fclose(fp,storage_txt,&lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// 倉庫データを書き込む
|
||||
int inter_guild_storage_save()
|
||||
{
|
||||
struct DBIterator* iter;
|
||||
struct guild_storage* data;
|
||||
FILE *fp;
|
||||
int lock;
|
||||
if( (fp=lock_fopen(guild_storage_txt,&lock))==NULL ){
|
||||
ShowError("int_storage: can't write [%s] !!! data is lost !!!\n",guild_storage_txt);
|
||||
return 1;
|
||||
}
|
||||
|
||||
iter = guild_storage_db->iterator(guild_storage_db);
|
||||
for( data = (struct guild_storage*)iter->first(iter,NULL); iter->exists(iter); data = (struct guild_storage*)iter->next(iter,NULL) )
|
||||
{
|
||||
char line[65536];
|
||||
if(inter_guild_search(data->guild_id) != NULL)
|
||||
{
|
||||
guild_storage_tostr(line,data);
|
||||
if(*line)
|
||||
fprintf(fp,"%s\n",line);
|
||||
}
|
||||
}
|
||||
iter->destroy(iter);
|
||||
|
||||
lock_fclose(fp,guild_storage_txt,&lock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 倉庫データ削除
|
||||
// q?f[^?
|
||||
int inter_storage_delete(int account_id)
|
||||
{
|
||||
struct storage_data *s = (struct storage_data*)idb_get(storage_db,account_id);
|
||||
if(s) {
|
||||
int i;
|
||||
for(i=0;i<s->storage_amount;i++){
|
||||
if(s->items[i].card[0] == (short)0xff00)
|
||||
inter_pet_delete( MakeDWord(s->items[i].card[1],s->items[i].card[2]) );
|
||||
}
|
||||
idb_remove(storage_db,account_id);
|
||||
}
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ギルド倉庫データ削除
|
||||
int inter_guild_storage_delete(int guild_id)
|
||||
{
|
||||
struct guild_storage *gs = (struct guild_storage*)idb_get(guild_storage_db,guild_id);
|
||||
if(gs) {
|
||||
int i;
|
||||
for(i=0;i<gs->storage_amount;i++){
|
||||
if(gs->items[i].card[0] == (short)0xff00)
|
||||
inter_pet_delete( MakeDWord(gs->items[i].card[1],gs->items[i].card[2]) );
|
||||
}
|
||||
idb_remove(guild_storage_db,guild_id);
|
||||
}
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_storage_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct guild_storage *guild2storage(int guild_id)
|
||||
{
|
||||
struct guild_storage* gs = NULL;
|
||||
if(inter_guild_search(guild_id) != NULL)
|
||||
gs = (struct guild_storage*)idb_ensure(guild_storage_db, guild_id, create_guildstorage);
|
||||
return gs;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// map serverへの通信
|
||||
// packet from map server
|
||||
|
||||
int mapif_load_guild_storage(int fd,int account_id,int guild_id)
|
||||
{
|
||||
struct guild_storage *gs=guild2storage(guild_id);
|
||||
WFIFOHEAD(fd, sizeof(struct guild_storage)+12);
|
||||
WFIFOW(fd,0)=0x3818;
|
||||
if(gs) {
|
||||
WFIFOW(fd,2)=sizeof(struct guild_storage)+12;
|
||||
WFIFOL(fd,4)=account_id;
|
||||
WFIFOL(fd,8)=guild_id;
|
||||
memcpy(WFIFOP(fd,12),gs,sizeof(struct guild_storage));
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else if( Sql_NumRows(sql_handle) > 0 )
|
||||
{// guild exists
|
||||
WFIFOHEAD(fd, sizeof(struct guild_storage)+12);
|
||||
WFIFOW(fd,0) = 0x3818;
|
||||
WFIFOW(fd,2) = sizeof(struct guild_storage)+12;
|
||||
WFIFOL(fd,4) = account_id;
|
||||
WFIFOL(fd,8) = guild_id;
|
||||
guild_storage_fromsql(guild_id, (struct guild_storage*)WFIFOP(fd,12));
|
||||
WFIFOSET(fd, WFIFOW(fd,2));
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
WFIFOW(fd,2)=12;
|
||||
WFIFOL(fd,4)=account_id;
|
||||
WFIFOL(fd,8)=0;
|
||||
}
|
||||
WFIFOSET(fd,WFIFOW(fd,2));
|
||||
|
||||
// guild does not exist
|
||||
Sql_FreeResult(sql_handle);
|
||||
WFIFOHEAD(fd, 12);
|
||||
WFIFOW(fd,0) = 0x3818;
|
||||
WFIFOW(fd,2) = 12;
|
||||
WFIFOL(fd,4) = account_id;
|
||||
WFIFOL(fd,8) = 0;
|
||||
WFIFOSET(fd, 12);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail)
|
||||
{
|
||||
WFIFOHEAD(fd,11);
|
||||
@ -423,7 +193,7 @@ int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail)
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// map serverからの通信
|
||||
// packet from map server
|
||||
|
||||
int mapif_parse_LoadGuildStorage(int fd)
|
||||
{
|
||||
@ -434,31 +204,35 @@ int mapif_parse_LoadGuildStorage(int fd)
|
||||
|
||||
int mapif_parse_SaveGuildStorage(int fd)
|
||||
{
|
||||
struct guild_storage *gs;
|
||||
int guild_id, len;
|
||||
int guild_id;
|
||||
int len;
|
||||
|
||||
RFIFOHEAD(fd);
|
||||
guild_id=RFIFOL(fd,8);
|
||||
len=RFIFOW(fd,2);
|
||||
if(sizeof(struct guild_storage)!=len-12){
|
||||
ShowError("inter storage: data size error %d %d\n",sizeof(struct guild_storage),len-12);
|
||||
guild_id = RFIFOL(fd,8);
|
||||
len = RFIFOW(fd,2);
|
||||
|
||||
if( sizeof(struct guild_storage) != len - 12 )
|
||||
{
|
||||
ShowError("inter storage: data size error %d != %d\n", sizeof(struct guild_storage), len - 12);
|
||||
}
|
||||
else {
|
||||
gs=guild2storage(guild_id);
|
||||
if(gs) {
|
||||
memcpy(gs,RFIFOP(fd,12),sizeof(struct guild_storage));
|
||||
mapif_save_guild_storage_ack(fd,RFIFOL(fd,4),guild_id,0);
|
||||
else
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else if( Sql_NumRows(sql_handle) > 0 )
|
||||
{// guild exists
|
||||
Sql_FreeResult(sql_handle);
|
||||
guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12));
|
||||
mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
mapif_save_guild_storage_ack(fd,RFIFOL(fd,4),guild_id,1);
|
||||
Sql_FreeResult(sql_handle);
|
||||
}
|
||||
mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// map server からの通信
|
||||
// ・1パケットのみ解析すること
|
||||
// ・パケット長データはinter.cにセットしておくこと
|
||||
// ・パケット長チェックや、RFIFOSKIPは呼び出し元で行われるので行ってはならない
|
||||
// ・エラーなら0(false)、そうでないなら1(true)をかえさなければならない
|
||||
|
||||
int inter_storage_parse_frommap(int fd)
|
||||
{
|
||||
RFIFOHEAD(fd);
|
||||
@ -470,4 +244,3 @@ int inter_storage_parse_frommap(int fd)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
||||
|
@ -1,28 +1,22 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INT_STORAGE_H_
|
||||
#define _INT_STORAGE_H_
|
||||
#ifndef _INT_STORAGE_SQL_H_
|
||||
#define _INT_STORAGE_SQL_H_
|
||||
|
||||
struct storage_data;
|
||||
struct guild_storage;
|
||||
|
||||
int inter_storage_init(void);
|
||||
void inter_storage_final(void);
|
||||
int inter_storage_save(void);
|
||||
int inter_guild_storage_save(void);
|
||||
int inter_storage_sql_init(void);
|
||||
void inter_storage_sql_final(void);
|
||||
int inter_storage_delete(int account_id);
|
||||
int inter_guild_storage_delete(int guild_id);
|
||||
|
||||
int inter_storage_parse_frommap(int fd);
|
||||
|
||||
extern char storage_txt[1024];
|
||||
extern char guild_storage_txt[1024];
|
||||
|
||||
//Exported for use in the TXT-SQL converter.
|
||||
bool storage_fromstr(char* str, int* account_id, struct storage_data* p);
|
||||
int guild_storage_fromstr(char *str,struct guild_storage *p);
|
||||
int storage_fromsql(int account_id, struct storage_data* p);
|
||||
int storage_tosql(int account_id,struct storage_data *p);
|
||||
int guild_storage_tosql(int guild_id, struct guild_storage *p);
|
||||
|
||||
bool storage_load(int account_id, struct storage_data* storage);
|
||||
bool storage_save(int account_id, struct storage_data* storage);
|
||||
|
||||
#endif /* _INT_STORAGE_H_ */
|
||||
#endif /* _INT_STORAGE_SQL_H_ */
|
||||
|
780
src/char/inter.c
780
src/char/inter.c
File diff suppressed because it is too large
Load Diff
@ -1,16 +1,17 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INTER_H_
|
||||
#define _INTER_H_
|
||||
#ifndef _INTER_SQL_H_
|
||||
#define _INTER_SQL_H_
|
||||
|
||||
struct accreg;
|
||||
#include "../common/sql.h"
|
||||
|
||||
int inter_init_txt(const char *file);
|
||||
int inter_init_sql(const char *file);
|
||||
void inter_final(void);
|
||||
int inter_save(void);
|
||||
int inter_parse_frommap(int fd);
|
||||
int inter_mapif_init(int fd);
|
||||
int mapif_send_gmaccounts(void);
|
||||
int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason);
|
||||
|
||||
int inter_log(char *fmt,...);
|
||||
@ -18,10 +19,12 @@ int inter_log(char *fmt,...);
|
||||
#define inter_cfgName "conf/inter_athena.conf"
|
||||
|
||||
extern unsigned int party_share_level;
|
||||
|
||||
extern Sql* sql_handle;
|
||||
extern Sql* lsql_handle;
|
||||
|
||||
extern char main_chat_nick[16];
|
||||
|
||||
//For TXT->SQL conversion
|
||||
extern char accreg_txt[];
|
||||
int inter_accreg_fromstr(const char *str, struct accreg *reg);
|
||||
int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type);
|
||||
|
||||
#endif /* _INTER_H_ */
|
||||
#endif /* _INTER_SQL_H_ */
|
||||
|
@ -1,58 +0,0 @@
|
||||
|
||||
#
|
||||
# setup
|
||||
#
|
||||
set( SQL_CHAR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
|
||||
|
||||
#
|
||||
# char sql
|
||||
#
|
||||
if( BUILD_SQL_SERVERS )
|
||||
message( STATUS "Creating target char-server_sql" )
|
||||
set( SQL_CHAR_HEADERS
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_auction.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_guild.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_homun.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_mail.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_mercenary.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_party.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_pet.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_quest.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_storage.h"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/inter.h"
|
||||
)
|
||||
set( SQL_CHAR_SOURCES
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/char.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_auction.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_guild.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_homun.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_mail.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_mercenary.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_party.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_pet.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_quest.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/int_storage.c"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/inter.c"
|
||||
)
|
||||
set( DEPENDENCIES common_sql )
|
||||
set( LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${GLOBAL_DEFINITIONS}" )
|
||||
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} ${SQL_CHAR_HEADERS} ${SQL_CHAR_SOURCES} )
|
||||
source_group( common FILES ${COMMON_BASE_HEADERS} ${COMMON_SQL_HEADERS} )
|
||||
source_group( char FILES ${SQL_CHAR_HEADERS} ${SQL_CHAR_SOURCES} )
|
||||
include_directories( ${INCLUDE_DIRS} )
|
||||
add_executable( char-server_sql ${SOURCE_FILES} )
|
||||
add_dependencies( char-server_sql ${DEPENDENCIES} )
|
||||
target_link_libraries( char-server_sql ${LIBRARIES} ${DEPENDENCIES} )
|
||||
set_target_properties( char-server_sql PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
cpack_add_component( Runtime_charserver_sql DESCRIPTION "char-server (sql version)" DISPLAY_NAME "char-server_sql" GROUP Runtime )
|
||||
install( TARGETS char-server_sql
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_charserver_sql )
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
message( STATUS "Creating target char-server_sql - done" )
|
||||
endif( BUILD_SQL_SERVERS )
|
@ -1,71 +0,0 @@
|
||||
|
||||
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_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/mapindex.h ../common/ers.h ../common/random.h
|
||||
|
||||
MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o
|
||||
MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h
|
||||
MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar
|
||||
|
||||
COMMON_SQL_OBJ = ../common/obj_sql/sql.o
|
||||
COMMON_H = ../common/sql.h
|
||||
|
||||
CHAR_OBJ = obj_sql/char.o obj_sql/inter.o obj_sql/int_party.o obj_sql/int_guild.o \
|
||||
obj_sql/int_storage.o obj_sql/int_pet.o obj_sql/int_homun.o obj_sql/int_mail.o obj_sql/int_auction.o obj_sql/int_quest.o obj_sql/int_mercenary.o
|
||||
CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h int_mail.h int_auction.h int_quest.h int_mercenary.h
|
||||
|
||||
HAVE_MYSQL=@HAVE_MYSQL@
|
||||
ifeq ($(HAVE_MYSQL),yes)
|
||||
CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_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) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) @LIBS@ @MYSQL_LIBS@
|
||||
|
||||
clean:
|
||||
rm -rf *.o obj_sql ../../char-server_sql@EXEEXT@
|
||||
|
||||
help:
|
||||
@echo "possible targets are 'char-server_sql' 'all' 'clean' 'help'"
|
||||
@echo "'char-server_sql' - char server (SQL version)"
|
||||
@echo "'all' - builds all above targets"
|
||||
@echo "'clean' - cleans builds and objects"
|
||||
@echo "'help' - outputs this message"
|
||||
|
||||
#####################################################################
|
||||
|
||||
needs_mysql:
|
||||
@echo "MySQL not found or disabled by the configure script"
|
||||
@exit 1
|
||||
|
||||
obj_sql:
|
||||
-mkdir obj_sql
|
||||
|
||||
obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H)
|
||||
@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
|
||||
|
||||
# missing object files
|
||||
../common/obj_all/%.o:
|
||||
@$(MAKE) -C ../common sql
|
||||
|
||||
../common/obj_sql/%.o:
|
||||
@$(MAKE) -C ../common sql
|
||||
|
||||
MT19937AR_OBJ:
|
||||
@$(MAKE) -C ../../3rdparty/mt19937ar
|
4636
src/char_sql/char.c
4636
src/char_sql/char.c
File diff suppressed because it is too large
Load Diff
@ -1,83 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _CHAR_SQL_H_
|
||||
#define _CHAR_SQL_H_
|
||||
|
||||
#include "../common/core.h" // CORE_ST_LAST
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
enum E_CHARSERVER_ST
|
||||
{
|
||||
CHARSERVER_ST_RUNNING = CORE_ST_LAST,
|
||||
CHARSERVER_ST_SHUTDOWN,
|
||||
CHARSERVER_ST_LAST
|
||||
};
|
||||
#endif
|
||||
|
||||
struct mmo_charstatus;
|
||||
|
||||
#define MAX_MAP_SERVERS 30
|
||||
|
||||
#define DEFAULT_AUTOSAVE_INTERVAL 300*1000
|
||||
|
||||
enum {
|
||||
TABLE_INVENTORY,
|
||||
TABLE_CART,
|
||||
TABLE_STORAGE,
|
||||
TABLE_GUILD_STORAGE,
|
||||
};
|
||||
|
||||
int memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch);
|
||||
|
||||
int mapif_sendall(unsigned char *buf,unsigned int len);
|
||||
int mapif_sendallwos(int fd,unsigned char *buf,unsigned int len);
|
||||
int mapif_send(int fd,unsigned char *buf,unsigned int len);
|
||||
|
||||
int char_married(int pl1,int pl2);
|
||||
int char_child(int parent_id, int child_id);
|
||||
int char_family(int pl1,int pl2,int pl3);
|
||||
|
||||
int request_accreg2(int account_id, int char_id);
|
||||
int save_accreg2(unsigned char* buf, int len);
|
||||
|
||||
extern int char_name_option;
|
||||
extern char char_name_letters[];
|
||||
extern bool char_gm_read;
|
||||
extern int autosave_interval;
|
||||
extern int save_log;
|
||||
extern char db_path[];
|
||||
extern char char_db[256];
|
||||
extern char scdata_db[256];
|
||||
extern char cart_db[256];
|
||||
extern char inventory_db[256];
|
||||
extern char charlog_db[256];
|
||||
extern char storage_db[256];
|
||||
extern char interlog_db[256];
|
||||
extern char reg_db[256];
|
||||
extern char skill_db[256];
|
||||
extern char memo_db[256];
|
||||
extern char guild_db[256];
|
||||
extern char guild_alliance_db[256];
|
||||
extern char guild_castle_db[256];
|
||||
extern char guild_expulsion_db[256];
|
||||
extern char guild_member_db[256];
|
||||
extern char guild_position_db[256];
|
||||
extern char guild_skill_db[256];
|
||||
extern char guild_storage_db[256];
|
||||
extern char party_db[256];
|
||||
extern char pet_db[256];
|
||||
extern char mail_db[256];
|
||||
extern char auction_db[256];
|
||||
extern char quest_db[256];
|
||||
|
||||
extern int db_use_sqldbs; // added for sql item_db read for char server [Valaris]
|
||||
|
||||
extern int guild_exp_rate;
|
||||
extern int log_inter;
|
||||
|
||||
//Exported for use in the TXT-SQL converter.
|
||||
int mmo_char_tosql(int char_id, struct mmo_charstatus *p);
|
||||
void sql_config_read(const char *cfgName);
|
||||
|
||||
#endif /* _CHAR_SQL_H_ */
|
File diff suppressed because it is too large
Load Diff
@ -1,40 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INT_GUILD_SQL_H_
|
||||
#define _INT_GUILD_SQL_H_
|
||||
|
||||
#define GS_BASIC 0x0001
|
||||
#define GS_MEMBER 0x0002
|
||||
#define GS_POSITION 0x0004
|
||||
#define GS_ALLIANCE 0x0008
|
||||
#define GS_EXPULSION 0x0010
|
||||
#define GS_SKILL 0x0020
|
||||
#define GS_EMBLEM 0x0040
|
||||
#define GS_CONNECT 0x0080
|
||||
#define GS_LEVEL 0x0100
|
||||
#define GS_MES 0x0200
|
||||
#define GS_MASK 0x03FF
|
||||
#define GS_BASIC_MASK (GS_BASIC | GS_EMBLEM | GS_CONNECT | GS_LEVEL | GS_MES)
|
||||
#define GS_REMOVE 0x8000
|
||||
|
||||
struct guild;
|
||||
struct guild_castle;
|
||||
|
||||
int inter_guild_parse_frommap(int fd);
|
||||
int inter_guild_sql_init(void);
|
||||
void inter_guild_sql_final(void);
|
||||
int inter_guild_mapif_init(int fd);
|
||||
int inter_guild_leave(int guild_id,int account_id,int char_id);
|
||||
int mapif_parse_BreakGuild(int fd,int guild_id);
|
||||
int inter_guild_broken(int guild_id);
|
||||
int inter_guild_sex_changed(int guild_id,int account_id,int char_id, short gender);
|
||||
int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char *name);
|
||||
int inter_guild_CharOnline(int char_id, int guild_id);
|
||||
int inter_guild_CharOffline(int char_id, int guild_id);
|
||||
|
||||
//For the TXT->SQL converter.
|
||||
int inter_guild_tosql(struct guild *g,int flag);
|
||||
int inter_guildcastle_tosql(struct guild_castle *gc);
|
||||
|
||||
#endif /* _INT_GUILD_SQL_H_ */
|
@ -1,313 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/mmo.h"
|
||||
#include "../common/malloc.h"
|
||||
#include "../common/strlib.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/socket.h"
|
||||
#include "../common/utils.h"
|
||||
#include "../common/sql.h"
|
||||
#include "char.h"
|
||||
#include "inter.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int inter_homunculus_sql_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
void inter_homunculus_sql_final(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag)
|
||||
{
|
||||
WFIFOHEAD(fd, sizeof(struct s_homunculus)+9);
|
||||
WFIFOW(fd,0) = 0x3890;
|
||||
WFIFOW(fd,2) = sizeof(struct s_homunculus)+9;
|
||||
WFIFOL(fd,4) = account_id;
|
||||
WFIFOB(fd,8)= flag;
|
||||
memcpy(WFIFOP(fd,9),sh,sizeof(struct s_homunculus));
|
||||
WFIFOSET(fd, WFIFOW(fd,2));
|
||||
}
|
||||
|
||||
static void mapif_homunculus_deleted(int fd, int flag)
|
||||
{
|
||||
WFIFOHEAD(fd, 3);
|
||||
WFIFOW(fd, 0) = 0x3893;
|
||||
WFIFOB(fd,2) = flag; //Flag 1 = success
|
||||
WFIFOSET(fd, 3);
|
||||
}
|
||||
|
||||
static void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd)
|
||||
{
|
||||
WFIFOHEAD(fd, sizeof(struct s_homunculus)+9);
|
||||
WFIFOW(fd,0) = 0x3891;
|
||||
WFIFOW(fd,2) = sizeof(struct s_homunculus)+9;
|
||||
WFIFOL(fd,4) = account_id;
|
||||
if( hd != NULL )
|
||||
{
|
||||
WFIFOB(fd,8) = 1; // success
|
||||
memcpy(WFIFOP(fd,9), hd, sizeof(struct s_homunculus));
|
||||
}
|
||||
else
|
||||
{
|
||||
WFIFOB(fd,8) = 0; // not found.
|
||||
memset(WFIFOP(fd,9), 0, sizeof(struct s_homunculus));
|
||||
}
|
||||
WFIFOSET(fd, sizeof(struct s_homunculus)+9);
|
||||
}
|
||||
|
||||
static void mapif_homunculus_saved(int fd, int account_id, bool flag)
|
||||
{
|
||||
WFIFOHEAD(fd, 7);
|
||||
WFIFOW(fd,0) = 0x3892;
|
||||
WFIFOL(fd,2) = account_id;
|
||||
WFIFOB(fd,6) = flag; // 1:success, 0:failure
|
||||
WFIFOSET(fd, 7);
|
||||
}
|
||||
|
||||
static void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, char* name)
|
||||
{
|
||||
WFIFOHEAD(fd, NAME_LENGTH+12);
|
||||
WFIFOW(fd, 0) = 0x3894;
|
||||
WFIFOL(fd, 2) = account_id;
|
||||
WFIFOL(fd, 6) = char_id;
|
||||
WFIFOB(fd,10) = flag;
|
||||
safestrncpy((char*)WFIFOP(fd,11), name, NAME_LENGTH);
|
||||
WFIFOSET(fd, NAME_LENGTH+12);
|
||||
}
|
||||
|
||||
bool mapif_homunculus_save(struct s_homunculus* hd)
|
||||
{
|
||||
bool flag = true;
|
||||
char esc_name[NAME_LENGTH*2+1];
|
||||
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, hd->name, strnlen(hd->name, NAME_LENGTH));
|
||||
|
||||
if( hd->hom_id == 0 )
|
||||
{// new homunculus
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `homunculus` "
|
||||
"(`char_id`, `class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`, `rename_flag`, `vaporize`) "
|
||||
"VALUES ('%d', '%d', '%s', '%d', '%u', '%u', '%d', '%d', %d, '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
|
||||
hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
|
||||
hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
hd->hom_id = (int)Sql_LastInsertId(sql_handle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `homunculus` SET `char_id`='%d', `class`='%d',`name`='%s',`level`='%d',`exp`='%u',`intimacy`='%u',`hunger`='%d', `str`='%d', `agi`='%d', `vit`='%d', `int`='%d', `dex`='%d', `luk`='%d', `hp`='%d',`max_hp`='%d',`sp`='%d',`max_sp`='%d',`skill_point`='%d', `rename_flag`='%d', `vaporize`='%d' WHERE `homun_id`='%d'",
|
||||
hd->char_id, hd->class_, esc_name, hd->level, hd->exp, hd->intimacy, hd->hunger, hd->str, hd->agi, hd->vit, hd->int_, hd->dex, hd->luk,
|
||||
hd->hp, hd->max_hp, hd->sp, hd->max_sp, hd->skillpts, hd->rename_flag, hd->vaporize, hd->hom_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
SqlStmt* stmt;
|
||||
int i;
|
||||
|
||||
stmt = SqlStmt_Malloc(sql_handle);
|
||||
if( SQL_ERROR == SqlStmt_Prepare(stmt, "REPLACE INTO `skill_homunculus` (`homun_id`, `id`, `lv`) VALUES (%d, ?, ?)", hd->hom_id) )
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
for( i = 0; i < MAX_HOMUNSKILL; ++i )
|
||||
{
|
||||
if( hd->hskill[i].id > 0 && hd->hskill[i].lv != 0 )
|
||||
{
|
||||
SqlStmt_BindParam(stmt, 0, SQLDT_USHORT, &hd->hskill[i].id, 0);
|
||||
SqlStmt_BindParam(stmt, 1, SQLDT_USHORT, &hd->hskill[i].lv, 0);
|
||||
if( SQL_ERROR == SqlStmt_Execute(stmt) )
|
||||
{
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
SqlStmt_Free(stmt);
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SqlStmt_Free(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Load an homunculus
|
||||
bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
|
||||
{
|
||||
int i;
|
||||
char* data;
|
||||
size_t len;
|
||||
|
||||
memset(hd, 0, sizeof(*hd));
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `homun_id`,`char_id`,`class`,`name`,`level`,`exp`,`intimacy`,`hunger`, `str`, `agi`, `vit`, `int`, `dex`, `luk`, `hp`,`max_hp`,`sp`,`max_sp`,`skill_point`,`rename_flag`, `vaporize` FROM `homunculus` WHERE `homun_id`='%u'", homun_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !Sql_NumRows(sql_handle) )
|
||||
{ //No homunculus found.
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
Sql_FreeResult(sql_handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
hd->hom_id = homun_id;
|
||||
Sql_GetData(sql_handle, 1, &data, NULL); hd->char_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, NULL); hd->class_ = atoi(data);
|
||||
Sql_GetData(sql_handle, 3, &data, &len); safestrncpy(hd->name, data, sizeof(hd->name));
|
||||
Sql_GetData(sql_handle, 4, &data, NULL); hd->level = atoi(data);
|
||||
Sql_GetData(sql_handle, 5, &data, NULL); hd->exp = atoi(data);
|
||||
Sql_GetData(sql_handle, 6, &data, NULL); hd->intimacy = (unsigned int)strtoul(data, NULL, 10);
|
||||
Sql_GetData(sql_handle, 7, &data, NULL); hd->hunger = atoi(data);
|
||||
Sql_GetData(sql_handle, 8, &data, NULL); hd->str = atoi(data);
|
||||
Sql_GetData(sql_handle, 9, &data, NULL); hd->agi = atoi(data);
|
||||
Sql_GetData(sql_handle, 10, &data, NULL); hd->vit = atoi(data);
|
||||
Sql_GetData(sql_handle, 11, &data, NULL); hd->int_ = atoi(data);
|
||||
Sql_GetData(sql_handle, 12, &data, NULL); hd->dex = atoi(data);
|
||||
Sql_GetData(sql_handle, 13, &data, NULL); hd->luk = atoi(data);
|
||||
Sql_GetData(sql_handle, 14, &data, NULL); hd->hp = atoi(data);
|
||||
Sql_GetData(sql_handle, 15, &data, NULL); hd->max_hp = atoi(data);
|
||||
Sql_GetData(sql_handle, 16, &data, NULL); hd->sp = atoi(data);
|
||||
Sql_GetData(sql_handle, 17, &data, NULL); hd->max_sp = atoi(data);
|
||||
Sql_GetData(sql_handle, 18, &data, NULL); hd->skillpts = atoi(data);
|
||||
Sql_GetData(sql_handle, 19, &data, NULL); hd->rename_flag = atoi(data);
|
||||
Sql_GetData(sql_handle, 20, &data, NULL); hd->vaporize = atoi(data);
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
hd->intimacy = cap_value(hd->intimacy, 0, 100000);
|
||||
hd->hunger = cap_value(hd->hunger, 0, 100);
|
||||
|
||||
// Load Homunculus Skill
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `id`,`lv` FROM `skill_homunculus` WHERE `homun_id`=%d", homun_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
while( SQL_SUCCESS == Sql_NextRow(sql_handle) )
|
||||
{
|
||||
// id
|
||||
Sql_GetData(sql_handle, 0, &data, NULL);
|
||||
i = atoi(data);
|
||||
if( i < HM_SKILLBASE || i >= HM_SKILLBASE + MAX_HOMUNSKILL )
|
||||
continue;// invalid skill id
|
||||
i = i - HM_SKILLBASE;
|
||||
hd->hskill[i].id = (unsigned short)atoi(data);
|
||||
|
||||
// lv
|
||||
Sql_GetData(sql_handle, 1, &data, NULL);
|
||||
hd->hskill[i].lv = (unsigned char)atoi(data);
|
||||
}
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
if( save_log )
|
||||
ShowInfo("Homunculus loaded (%d - %s).\n", hd->hom_id, hd->name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mapif_homunculus_delete(int homun_id)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `homunculus` WHERE `homun_id` = '%u'", homun_id)
|
||||
|| SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `skill_homunculus` WHERE `homun_id` = '%u'", homun_id)
|
||||
) {
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool mapif_homunculus_rename(char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
// Check Authorised letters/symbols in the name of the homun
|
||||
if( char_name_option == 1 )
|
||||
{// only letters/symbols in char_name_letters are authorised
|
||||
for( i = 0; i < NAME_LENGTH && name[i]; i++ )
|
||||
if( strchr(char_name_letters, name[i]) == NULL )
|
||||
return false;
|
||||
} else
|
||||
if( char_name_option == 2 )
|
||||
{// letters/symbols in char_name_letters are forbidden
|
||||
for( i = 0; i < NAME_LENGTH && name[i]; i++ )
|
||||
if( strchr(char_name_letters, name[i]) != NULL )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void mapif_parse_homunculus_create(int fd, int len, int account_id, struct s_homunculus* phd)
|
||||
{
|
||||
bool result = mapif_homunculus_save(phd);
|
||||
mapif_homunculus_created(fd, account_id, phd, result);
|
||||
}
|
||||
|
||||
static void mapif_parse_homunculus_delete(int fd, int homun_id)
|
||||
{
|
||||
bool result = mapif_homunculus_delete(homun_id);
|
||||
mapif_homunculus_deleted(fd, result);
|
||||
}
|
||||
|
||||
static void mapif_parse_homunculus_load(int fd, int account_id, int homun_id)
|
||||
{
|
||||
struct s_homunculus hd;
|
||||
bool result = mapif_homunculus_load(homun_id, &hd);
|
||||
mapif_homunculus_loaded(fd, account_id, ( result ? &hd : NULL ));
|
||||
}
|
||||
|
||||
static void mapif_parse_homunculus_save(int fd, int len, int account_id, struct s_homunculus* phd)
|
||||
{
|
||||
bool result = mapif_homunculus_save(phd);
|
||||
mapif_homunculus_saved(fd, account_id, result);
|
||||
}
|
||||
|
||||
static void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, char* name)
|
||||
{
|
||||
bool result = mapif_homunculus_rename(name);
|
||||
mapif_homunculus_renamed(fd, account_id, char_id, result, name);
|
||||
}
|
||||
|
||||
/*==========================================
|
||||
* Inter Packets
|
||||
*------------------------------------------*/
|
||||
int inter_homunculus_parse_frommap(int fd)
|
||||
{
|
||||
unsigned short cmd = RFIFOW(fd,0);
|
||||
|
||||
switch( cmd )
|
||||
{
|
||||
case 0x3090: mapif_parse_homunculus_create(fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break;
|
||||
case 0x3091: mapif_parse_homunculus_load (fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
|
||||
case 0x3092: mapif_parse_homunculus_save (fd, (int)RFIFOW(fd,2), (int)RFIFOL(fd,4), (struct s_homunculus*)RFIFOP(fd,8)); break;
|
||||
case 0x3093: mapif_parse_homunculus_delete(fd, (int)RFIFOL(fd,2)); break;
|
||||
case 0x3094: mapif_parse_homunculus_rename(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INT_HOMUN_SQL_H_
|
||||
#define _INT_HOMUN_SQL_H_
|
||||
|
||||
struct s_homunculus;
|
||||
|
||||
int inter_homunculus_sql_init(void);
|
||||
void inter_homunculus_sql_final(void);
|
||||
int inter_homunculus_parse_frommap(int fd);
|
||||
|
||||
bool mapif_homunculus_save(struct s_homunculus* hd);
|
||||
bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd);
|
||||
bool mapif_homunculus_delete(int homun_id);
|
||||
bool mapif_homunculus_rename(char *name);
|
||||
|
||||
#endif /* _INT_HOMUN_SQL_H_ */
|
@ -1,870 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/cbasetypes.h"
|
||||
#include "../common/mmo.h"
|
||||
#include "../common/db.h"
|
||||
#include "../common/malloc.h"
|
||||
#include "../common/strlib.h"
|
||||
#include "../common/socket.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/mapindex.h"
|
||||
#include "../common/sql.h"
|
||||
#include "char.h"
|
||||
#include "inter.h"
|
||||
#include "int_party.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
struct party_data {
|
||||
struct party party;
|
||||
unsigned int min_lv, max_lv;
|
||||
int family; //Is this party a family? if so, this holds the child id.
|
||||
unsigned char size; //Total size of party.
|
||||
};
|
||||
|
||||
static struct party_data *party_pt;
|
||||
static DBMap* party_db_; // int party_id -> struct party_data*
|
||||
|
||||
int mapif_party_broken(int party_id,int flag);
|
||||
int party_check_empty(struct party_data *p);
|
||||
int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id);
|
||||
int party_check_exp_share(struct party_data *p);
|
||||
int mapif_party_optionchanged(int fd,struct party *p, int account_id, int flag);
|
||||
|
||||
//Updates party's level range and unsets even share if broken.
|
||||
static int int_party_check_lv(struct party_data *p) {
|
||||
int i;
|
||||
unsigned int lv;
|
||||
p->min_lv = UINT_MAX;
|
||||
p->max_lv = 0;
|
||||
for(i=0;i<MAX_PARTY;i++){
|
||||
/**
|
||||
* - If not online OR if it's a family party and this is the child (doesn't affect exp range)
|
||||
**/
|
||||
if(!p->party.member[i].online || p->party.member[i].char_id == p->family )
|
||||
continue;
|
||||
|
||||
lv=p->party.member[i].lv;
|
||||
if (lv < p->min_lv) p->min_lv = lv;
|
||||
if (lv > p->max_lv) p->max_lv = lv;
|
||||
}
|
||||
|
||||
if (p->party.exp && !party_check_exp_share(p)) {
|
||||
p->party.exp = 0;
|
||||
mapif_party_optionchanged(0, &p->party, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
//Calculates the state of a party.
|
||||
static void int_party_calc_state(struct party_data *p)
|
||||
{
|
||||
int i;
|
||||
unsigned int lv;
|
||||
p->min_lv = UINT_MAX;
|
||||
p->max_lv = 0;
|
||||
p->party.count =
|
||||
p->size =
|
||||
p->family = 0;
|
||||
|
||||
//Check party size
|
||||
for(i=0;i<MAX_PARTY;i++){
|
||||
if (!p->party.member[i].lv) continue;
|
||||
p->size++;
|
||||
if(p->party.member[i].online)
|
||||
p->party.count++;
|
||||
}
|
||||
if( p->size == 2 && ( char_child(p->party.member[0].char_id,p->party.member[1].char_id) || char_child(p->party.member[1].char_id,p->party.member[0].char_id) ) ) {
|
||||
//Child should be able to share with either of their parents [RoM]
|
||||
if(p->party.member[0].class_&0x2000) //first slot is the child?
|
||||
p->family = p->party.member[0].char_id;
|
||||
else
|
||||
p->family = p->party.member[1].char_id;
|
||||
} else if( p->size == 3 ) {
|
||||
//Check Family State.
|
||||
p->family = char_family(
|
||||
p->party.member[0].char_id,
|
||||
p->party.member[1].char_id,
|
||||
p->party.member[2].char_id
|
||||
);
|
||||
}
|
||||
//max/min levels.
|
||||
for(i=0;i<MAX_PARTY;i++){
|
||||
lv=p->party.member[i].lv;
|
||||
if (!lv) continue;
|
||||
if(p->party.member[i].online &&
|
||||
//On families, the kid is not counted towards exp share rules.
|
||||
p->party.member[i].char_id != p->family)
|
||||
{
|
||||
if( lv < p->min_lv ) p->min_lv=lv;
|
||||
if( p->max_lv < lv ) p->max_lv=lv;
|
||||
}
|
||||
}
|
||||
|
||||
if (p->party.exp && !party_check_exp_share(p)) {
|
||||
p->party.exp = 0; //Set off even share.
|
||||
mapif_party_optionchanged(0, &p->party, 0, 0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
||||
// Save party to mysql
|
||||
int inter_party_tosql(struct party *p, int flag, int index)
|
||||
{
|
||||
// 'party' ('party_id','name','exp','item','leader_id','leader_char')
|
||||
char esc_name[NAME_LENGTH*2+1];// escaped party name
|
||||
int party_id;
|
||||
|
||||
if( p == NULL || p->party_id == 0 )
|
||||
return 0;
|
||||
party_id = p->party_id;
|
||||
|
||||
#ifdef NOISY
|
||||
ShowInfo("Save party request ("CL_BOLD"%d"CL_RESET" - %s).\n", party_id, p->name);
|
||||
#endif
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
if( flag & PS_BREAK )
|
||||
{// Break the party
|
||||
// we'll skip name-checking and just reset everyone with the same party id [celest]
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
//Remove from memory
|
||||
idb_remove(party_db_, party_id);
|
||||
return 1;
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
||||
if( flag & PS_CREATE )
|
||||
{// Create party
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` "
|
||||
"(`name`, `exp`, `item`, `leader_id`, `leader_char`) "
|
||||
"VALUES ('%s', '%d', '%d', '%d', '%d')",
|
||||
party_db, esc_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
party_id = p->party_id = (int)Sql_LastInsertId(sql_handle);
|
||||
#else
|
||||
//During conversion, you want to specify the id, and allow overwriting
|
||||
//(in case someone is re-running the process.
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` "
|
||||
"(`party_id`, `name`, `exp`, `item`, `leader_id`, `leader_char`) "
|
||||
"VALUES ('%d', '%s', '%d', '%d', '%d', '%d')",
|
||||
party_db, p->party_id, esc_name, p->exp, p->item, p->member[index].account_id, p->member[index].char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
if( flag & PS_BASIC )
|
||||
{// Update party info.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `name`='%s', `exp`='%d', `item`='%d' WHERE `party_id`='%d'",
|
||||
party_db, esc_name, p->exp, p->item, party_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
|
||||
if( flag & PS_LEADER )
|
||||
{// Update leader
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `leader_id`='%d', `leader_char`='%d' WHERE `party_id`='%d'",
|
||||
party_db, p->member[index].account_id, p->member[index].char_id, party_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
|
||||
if( flag & PS_ADDMEMBER )
|
||||
{// Add one party member.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='%d' WHERE `account_id`='%d' AND `char_id`='%d'",
|
||||
char_db, party_id, p->member[index].account_id, p->member[index].char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
|
||||
if( flag & PS_DELMEMBER )
|
||||
{// Remove one party member.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d' AND `account_id`='%d' AND `char_id`='%d'",
|
||||
char_db, party_id, p->member[index].account_id, p->member[index].char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
||||
if( save_log )
|
||||
ShowInfo("Party Saved (%d - %s)\n", party_id, p->name);
|
||||
return 1;
|
||||
}
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
// Read party from mysql
|
||||
struct party_data *inter_party_fromsql(int party_id)
|
||||
{
|
||||
int leader_id = 0;
|
||||
int leader_char = 0;
|
||||
struct party_data* p;
|
||||
struct party_member* m;
|
||||
char* data;
|
||||
size_t len;
|
||||
int i;
|
||||
|
||||
#ifdef NOISY
|
||||
ShowInfo("Load party request ("CL_BOLD"%d"CL_RESET")\n", party_id);
|
||||
#endif
|
||||
if( party_id <= 0 )
|
||||
return NULL;
|
||||
|
||||
//Load from memory
|
||||
p = (struct party_data*)idb_get(party_db_, party_id);
|
||||
if( p != NULL )
|
||||
return p;
|
||||
|
||||
p = party_pt;
|
||||
memset(p, 0, sizeof(struct party_data));
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", party_db, party_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
return NULL;
|
||||
|
||||
p->party.party_id = party_id;
|
||||
Sql_GetData(sql_handle, 1, &data, &len); memcpy(p->party.name, data, min(len, NAME_LENGTH));
|
||||
Sql_GetData(sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0);
|
||||
Sql_GetData(sql_handle, 3, &data, NULL); p->party.item = atoi(data);
|
||||
Sql_GetData(sql_handle, 4, &data, NULL); leader_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 5, &data, NULL); leader_char = atoi(data);
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
// Load members
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", char_db, party_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return NULL;
|
||||
}
|
||||
for( i = 0; i < MAX_PARTY && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
|
||||
{
|
||||
m = &p->party.member[i];
|
||||
Sql_GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, &len); memcpy(m->name, data, min(len, NAME_LENGTH));
|
||||
Sql_GetData(sql_handle, 3, &data, NULL); m->lv = atoi(data);
|
||||
Sql_GetData(sql_handle, 4, &data, NULL); m->map = mapindex_name2id(data);
|
||||
Sql_GetData(sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0);
|
||||
Sql_GetData(sql_handle, 6, &data, NULL); m->class_ = atoi(data);
|
||||
m->leader = (m->account_id == leader_id && m->char_id == leader_char ? 1 : 0);
|
||||
}
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
if( save_log )
|
||||
ShowInfo("Party loaded (%d - %s).\n", party_id, p->party.name);
|
||||
//Add party to memory.
|
||||
CREATE(p, struct party_data, 1);
|
||||
memcpy(p, party_pt, sizeof(struct party_data));
|
||||
//init state
|
||||
int_party_calc_state(p);
|
||||
idb_put(party_db_, party_id, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
int inter_party_sql_init(void)
|
||||
{
|
||||
//memory alloc
|
||||
party_db_ = idb_alloc(DB_OPT_RELEASE_DATA);
|
||||
party_pt = (struct party_data*)aCalloc(sizeof(struct party_data), 1);
|
||||
if (!party_pt) {
|
||||
ShowFatalError("inter_party_sql_init: Out of Memory!\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Uncomment the following if you want to do a party_db cleanup (remove parties with no members) on startup.[Skotlex]
|
||||
ShowStatus("cleaning party table...\n");
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` USING `%s` LEFT JOIN `%s` ON `%s`.leader_id =`%s`.account_id AND `%s`.leader_char = `%s`.char_id WHERE `%s`.account_id IS NULL",
|
||||
party_db, party_db, char_db, party_db, char_db, party_db, char_db, char_db) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
void inter_party_sql_final(void)
|
||||
{
|
||||
party_db_->destroy(party_db_, NULL);
|
||||
aFree(party_pt);
|
||||
return;
|
||||
}
|
||||
|
||||
// Search for the party according to its name
|
||||
struct party_data* search_partyname(char* str)
|
||||
{
|
||||
char esc_name[NAME_LENGTH*2+1];
|
||||
char* data;
|
||||
struct party_data* p = NULL;
|
||||
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, str, safestrnlen(str, NAME_LENGTH));
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id` FROM `%s` WHERE `name`='%s'", party_db, esc_name) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
|
||||
{
|
||||
Sql_GetData(sql_handle, 0, &data, NULL);
|
||||
p = inter_party_fromsql(atoi(data));
|
||||
}
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
// Returns whether this party can keep having exp share or not.
|
||||
int party_check_exp_share(struct party_data *p)
|
||||
{
|
||||
return (p->party.count < 2 || p->max_lv - p->min_lv <= party_share_level);
|
||||
}
|
||||
|
||||
// Is there any member in the party?
|
||||
int party_check_empty(struct party_data *p)
|
||||
{
|
||||
int i;
|
||||
if (p==NULL||p->party.party_id==0) return 1;
|
||||
for(i=0;i<MAX_PARTY && !p->party.member[i].account_id;i++);
|
||||
if (i < MAX_PARTY) return 0;
|
||||
// If there is no member, then break the party
|
||||
mapif_party_broken(p->party.party_id,0);
|
||||
inter_party_tosql(&p->party, PS_BREAK, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// map serverへの通信
|
||||
|
||||
// パーティ作成可否
|
||||
int mapif_party_created(int fd,int account_id,int char_id,struct party *p)
|
||||
{
|
||||
WFIFOHEAD(fd, 39);
|
||||
WFIFOW(fd,0)=0x3820;
|
||||
WFIFOL(fd,2)=account_id;
|
||||
WFIFOL(fd,6)=char_id;
|
||||
if(p!=NULL){
|
||||
WFIFOB(fd,10)=0;
|
||||
WFIFOL(fd,11)=p->party_id;
|
||||
memcpy(WFIFOP(fd,15),p->name,NAME_LENGTH);
|
||||
ShowInfo("int_party: Party created (%d - %s)\n",p->party_id,p->name);
|
||||
}else{
|
||||
WFIFOB(fd,10)=1;
|
||||
WFIFOL(fd,11)=0;
|
||||
memset(WFIFOP(fd,15),0,NAME_LENGTH);
|
||||
}
|
||||
WFIFOSET(fd,39);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// パーティ情報見つからず
|
||||
static void mapif_party_noinfo(int fd, int party_id, int char_id)
|
||||
{
|
||||
WFIFOHEAD(fd, 12);
|
||||
WFIFOW(fd,0) = 0x3821;
|
||||
WFIFOW(fd,2) = 12;
|
||||
WFIFOL(fd,4) = char_id;
|
||||
WFIFOL(fd,8) = party_id;
|
||||
WFIFOSET(fd,12);
|
||||
ShowWarning("int_party: info not found (party_id=%d char_id=%d)\n", party_id, char_id);
|
||||
}
|
||||
// パーティ情報まとめ送り
|
||||
static void mapif_party_info(int fd, struct party* p, int char_id)
|
||||
{
|
||||
unsigned char buf[8 + sizeof(struct party)];
|
||||
WBUFW(buf,0) = 0x3821;
|
||||
WBUFW(buf,2) = 8 + sizeof(struct party);
|
||||
WBUFL(buf,4) = char_id;
|
||||
memcpy(WBUFP(buf,8), p, sizeof(struct party));
|
||||
|
||||
if(fd<0)
|
||||
mapif_sendall(buf,WBUFW(buf,2));
|
||||
else
|
||||
mapif_send(fd,buf,WBUFW(buf,2));
|
||||
}
|
||||
// パーティメンバ追加可否
|
||||
int mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, int flag) {
|
||||
WFIFOHEAD(fd, 15);
|
||||
WFIFOW(fd,0) = 0x3822;
|
||||
WFIFOL(fd,2) = party_id;
|
||||
WFIFOL(fd,6) = account_id;
|
||||
WFIFOL(fd,10) = char_id;
|
||||
WFIFOB(fd,14) = flag;
|
||||
WFIFOSET(fd,15);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// パーティ設定変更通知
|
||||
int mapif_party_optionchanged(int fd,struct party *p,int account_id,int flag)
|
||||
{
|
||||
unsigned char buf[16];
|
||||
WBUFW(buf,0)=0x3823;
|
||||
WBUFL(buf,2)=p->party_id;
|
||||
WBUFL(buf,6)=account_id;
|
||||
WBUFW(buf,10)=p->exp;
|
||||
WBUFW(buf,12)=p->item;
|
||||
WBUFB(buf,14)=flag;
|
||||
if(flag==0)
|
||||
mapif_sendall(buf,15);
|
||||
else
|
||||
mapif_send(fd,buf,15);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// パーティ脱退通知
|
||||
int mapif_party_withdraw(int party_id,int account_id, int char_id) {
|
||||
unsigned char buf[16];
|
||||
|
||||
WBUFW(buf,0) = 0x3824;
|
||||
WBUFL(buf,2) = party_id;
|
||||
WBUFL(buf,6) = account_id;
|
||||
WBUFL(buf,10) = char_id;
|
||||
mapif_sendall(buf, 14);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// パーティマップ更新通知
|
||||
int mapif_party_membermoved(struct party *p,int idx)
|
||||
{
|
||||
unsigned char buf[20];
|
||||
|
||||
WBUFW(buf,0) = 0x3825;
|
||||
WBUFL(buf,2) = p->party_id;
|
||||
WBUFL(buf,6) = p->member[idx].account_id;
|
||||
WBUFL(buf,10) = p->member[idx].char_id;
|
||||
WBUFW(buf,14) = p->member[idx].map;
|
||||
WBUFB(buf,16) = p->member[idx].online;
|
||||
WBUFW(buf,17) = p->member[idx].lv;
|
||||
mapif_sendall(buf, 19);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// パーティ解散通知
|
||||
int mapif_party_broken(int party_id,int flag)
|
||||
{
|
||||
unsigned char buf[16];
|
||||
WBUFW(buf,0)=0x3826;
|
||||
WBUFL(buf,2)=party_id;
|
||||
WBUFB(buf,6)=flag;
|
||||
mapif_sendall(buf,7);
|
||||
//printf("int_party: broken %d\n",party_id);
|
||||
return 0;
|
||||
}
|
||||
// パーティ内発言
|
||||
int mapif_party_message(int party_id,int account_id,char *mes,int len, int sfd)
|
||||
{
|
||||
unsigned char buf[512];
|
||||
WBUFW(buf,0)=0x3827;
|
||||
WBUFW(buf,2)=len+12;
|
||||
WBUFL(buf,4)=party_id;
|
||||
WBUFL(buf,8)=account_id;
|
||||
memcpy(WBUFP(buf,12),mes,len);
|
||||
mapif_sendallwos(sfd, buf,len+12);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// map serverからの通信
|
||||
|
||||
|
||||
// Create Party
|
||||
int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct party_member *leader)
|
||||
{
|
||||
struct party_data *p;
|
||||
int i;
|
||||
if( (p=search_partyname(name))!=NULL){
|
||||
mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
|
||||
return 0;
|
||||
}
|
||||
// Check Authorised letters/symbols in the name of the character
|
||||
if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
|
||||
for (i = 0; i < NAME_LENGTH && name[i]; i++)
|
||||
if (strchr(char_name_letters, name[i]) == NULL) {
|
||||
mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
|
||||
return 0;
|
||||
}
|
||||
} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
|
||||
for (i = 0; i < NAME_LENGTH && name[i]; i++)
|
||||
if (strchr(char_name_letters, name[i]) != NULL) {
|
||||
mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
p = (struct party_data*)aCalloc(1, sizeof(struct party_data));
|
||||
|
||||
memcpy(p->party.name,name,NAME_LENGTH);
|
||||
p->party.exp=0;
|
||||
p->party.item=(item?1:0)|(item2?2:0);
|
||||
|
||||
memcpy(&p->party.member[0], leader, sizeof(struct party_member));
|
||||
p->party.member[0].leader=1;
|
||||
p->party.member[0].online=1;
|
||||
|
||||
p->party.party_id=-1;//New party.
|
||||
if (inter_party_tosql(&p->party,PS_CREATE|PS_ADDMEMBER,0)) {
|
||||
//Add party to db
|
||||
int_party_calc_state(p);
|
||||
idb_put(party_db_, p->party.party_id, p);
|
||||
mapif_party_info(fd, &p->party, 0);
|
||||
mapif_party_created(fd,leader->account_id,leader->char_id,&p->party);
|
||||
} else { //Failed to create party.
|
||||
aFree(p);
|
||||
mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
// パーティ情報要求
|
||||
static void mapif_parse_PartyInfo(int fd, int party_id, int char_id)
|
||||
{
|
||||
struct party_data *p;
|
||||
p = inter_party_fromsql(party_id);
|
||||
|
||||
if (p)
|
||||
mapif_party_info(fd, &p->party, char_id);
|
||||
else
|
||||
mapif_party_noinfo(fd, party_id, char_id);
|
||||
}
|
||||
// パーティ追加要求
|
||||
int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member)
|
||||
{
|
||||
struct party_data *p;
|
||||
int i;
|
||||
|
||||
p = inter_party_fromsql(party_id);
|
||||
if( p == NULL || p->size == MAX_PARTY ) {
|
||||
mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == 0 );
|
||||
if( i == MAX_PARTY )
|
||||
{// Party full
|
||||
mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(&p->party.member[i], member, sizeof(struct party_member));
|
||||
p->party.member[i].leader = 0;
|
||||
if (p->party.member[i].online) p->party.count++;
|
||||
p->size++;
|
||||
if (p->size == 2 || p->size == 3) // Check family state. And also accept either of their Parents. [RoM]
|
||||
int_party_calc_state(p);
|
||||
else //Check even share range.
|
||||
if (member->lv < p->min_lv || member->lv > p->max_lv || p->family) {
|
||||
if (p->family) p->family = 0; //Family state broken.
|
||||
int_party_check_lv(p);
|
||||
}
|
||||
|
||||
mapif_party_info(-1, &p->party, 0);
|
||||
mapif_party_memberadded(fd, party_id, member->account_id, member->char_id, 0);
|
||||
inter_party_tosql(&p->party, PS_ADDMEMBER, i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// パーティー設定変更要求
|
||||
int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int item)
|
||||
{
|
||||
struct party_data *p;
|
||||
int flag = 0;
|
||||
p = inter_party_fromsql(party_id);
|
||||
|
||||
if(!p)
|
||||
return 0;
|
||||
|
||||
p->party.exp=exp;
|
||||
if( exp && !party_check_exp_share(p) ){
|
||||
flag|=0x01;
|
||||
p->party.exp=0;
|
||||
}
|
||||
p->party.item = item&0x3; //Filter out invalid values.
|
||||
mapif_party_optionchanged(fd,&p->party,account_id,flag);
|
||||
inter_party_tosql(&p->party, PS_BASIC, 0);
|
||||
return 0;
|
||||
}
|
||||
// パーティ脱退要求
|
||||
int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id)
|
||||
{
|
||||
struct party_data *p;
|
||||
int i,j=-1;
|
||||
|
||||
p = inter_party_fromsql(party_id);
|
||||
if( p == NULL )
|
||||
{// Party does not exists?
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `party_id`='0' WHERE `party_id`='%d'", char_db, party_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < MAX_PARTY; i++) {
|
||||
if(p->party.member[i].account_id == account_id &&
|
||||
p->party.member[i].char_id == char_id) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i >= MAX_PARTY)
|
||||
return 0; //Member not found?
|
||||
|
||||
mapif_party_withdraw(party_id, account_id, char_id);
|
||||
|
||||
if (p->party.member[i].leader){
|
||||
p->party.member[i].account_id = 0;
|
||||
for (j = 0; j < MAX_PARTY; j++) {
|
||||
if (!p->party.member[j].account_id)
|
||||
continue;
|
||||
mapif_party_withdraw(party_id, p->party.member[j].account_id, p->party.member[j].char_id);
|
||||
p->party.member[j].account_id = 0;
|
||||
}
|
||||
//Party gets deleted on the check_empty call below.
|
||||
} else {
|
||||
inter_party_tosql(&p->party,PS_DELMEMBER,i);
|
||||
j = p->party.member[i].lv;
|
||||
if(p->party.member[i].online) p->party.count--;
|
||||
memset(&p->party.member[i], 0, sizeof(struct party_member));
|
||||
p->size--;
|
||||
if (j == p->min_lv || j == p->max_lv || p->family)
|
||||
{
|
||||
if(p->family) p->family = 0; //Family state broken.
|
||||
int_party_check_lv(p);
|
||||
}
|
||||
}
|
||||
|
||||
if (party_check_empty(p) == 0)
|
||||
mapif_party_info(-1, &p->party, 0);
|
||||
return 0;
|
||||
}
|
||||
// When member goes to other map or levels up.
|
||||
int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv)
|
||||
{
|
||||
struct party_data *p;
|
||||
int i;
|
||||
|
||||
p = inter_party_fromsql(party_id);
|
||||
if (p == NULL)
|
||||
return 0;
|
||||
|
||||
for(i = 0; i < MAX_PARTY &&
|
||||
(p->party.member[i].account_id != account_id ||
|
||||
p->party.member[i].char_id != char_id); i++);
|
||||
|
||||
if (i == MAX_PARTY) return 0;
|
||||
|
||||
if (p->party.member[i].online != online)
|
||||
{
|
||||
p->party.member[i].online = online;
|
||||
if (online)
|
||||
p->party.count++;
|
||||
else
|
||||
p->party.count--;
|
||||
// Even share check situations: Family state (always breaks)
|
||||
// character logging on/off is max/min level (update level range)
|
||||
// or character logging on/off has a different level (update level range using new level)
|
||||
if (p->family ||
|
||||
(p->party.member[i].lv <= p->min_lv || p->party.member[i].lv >= p->max_lv) ||
|
||||
(p->party.member[i].lv != lv && (lv <= p->min_lv || lv >= p->max_lv))
|
||||
)
|
||||
{
|
||||
p->party.member[i].lv = lv;
|
||||
int_party_check_lv(p);
|
||||
}
|
||||
//Send online/offline update.
|
||||
mapif_party_membermoved(&p->party, i);
|
||||
}
|
||||
|
||||
if (p->party.member[i].lv != lv) {
|
||||
if(p->party.member[i].lv == p->min_lv ||
|
||||
p->party.member[i].lv == p->max_lv)
|
||||
{
|
||||
p->party.member[i].lv = lv;
|
||||
int_party_check_lv(p);
|
||||
} else
|
||||
p->party.member[i].lv = lv;
|
||||
//There is no need to send level update to map servers
|
||||
//since they do nothing with it.
|
||||
}
|
||||
|
||||
if (p->party.member[i].map != map) {
|
||||
p->party.member[i].map = map;
|
||||
mapif_party_membermoved(&p->party, i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// パーティ解散要求
|
||||
int mapif_parse_BreakParty(int fd,int party_id)
|
||||
{
|
||||
struct party_data *p;
|
||||
|
||||
p = inter_party_fromsql(party_id);
|
||||
|
||||
if(!p)
|
||||
return 0;
|
||||
inter_party_tosql(&p->party,PS_BREAK,0);
|
||||
mapif_party_broken(fd,party_id);
|
||||
return 0;
|
||||
}
|
||||
// パーティメッセージ送信
|
||||
int mapif_parse_PartyMessage(int fd,int party_id,int account_id,char *mes,int len)
|
||||
{
|
||||
return mapif_party_message(party_id,account_id,mes,len, fd);
|
||||
}
|
||||
|
||||
int mapif_parse_PartyLeaderChange(int fd,int party_id,int account_id,int char_id)
|
||||
{
|
||||
struct party_data *p;
|
||||
int i;
|
||||
|
||||
p = inter_party_fromsql(party_id);
|
||||
|
||||
if(!p)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < MAX_PARTY; i++)
|
||||
{
|
||||
if(p->party.member[i].leader)
|
||||
p->party.member[i].leader = 0;
|
||||
if(p->party.member[i].account_id == account_id &&
|
||||
p->party.member[i].char_id == char_id)
|
||||
{
|
||||
p->party.member[i].leader = 1;
|
||||
inter_party_tosql(&p->party,PS_LEADER, i);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// map server からの通信
|
||||
// ・1パケットのみ解析すること
|
||||
// ・パケット長データはinter.cにセットしておくこと
|
||||
// ・パケット長チェックや、RFIFOSKIPは呼び出し元で行われるので行ってはならない
|
||||
// ・エラーなら0(false)、そうでないなら1(true)をかえさなければならない
|
||||
int inter_party_parse_frommap(int fd)
|
||||
{
|
||||
RFIFOHEAD(fd);
|
||||
switch(RFIFOW(fd,0)) {
|
||||
case 0x3020: mapif_parse_CreateParty(fd, (char*)RFIFOP(fd,4), RFIFOB(fd,28), RFIFOB(fd,29), (struct party_member*)RFIFOP(fd,30)); break;
|
||||
case 0x3021: mapif_parse_PartyInfo(fd, RFIFOL(fd,2), RFIFOL(fd,6)); break;
|
||||
case 0x3022: mapif_parse_PartyAddMember(fd, RFIFOL(fd,4), (struct party_member*)RFIFOP(fd,8)); break;
|
||||
case 0x3023: mapif_parse_PartyChangeOption(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOW(fd,10), RFIFOW(fd,12)); break;
|
||||
case 0x3024: mapif_parse_PartyLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break;
|
||||
case 0x3025: mapif_parse_PartyChangeMap(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOW(fd,14), RFIFOB(fd,16), RFIFOW(fd,17)); break;
|
||||
case 0x3026: mapif_parse_BreakParty(fd, RFIFOL(fd,2)); break;
|
||||
case 0x3027: mapif_parse_PartyMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), (char*)RFIFOP(fd,12), RFIFOW(fd,2)-12); break;
|
||||
case 0x3029: mapif_parse_PartyLeaderChange(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// サーバーから脱退要求(キャラ削除用)
|
||||
int inter_party_leave(int party_id,int account_id, int char_id)
|
||||
{
|
||||
return mapif_parse_PartyLeave(-1,party_id,account_id, char_id);
|
||||
}
|
||||
|
||||
int inter_party_CharOnline(int char_id, int party_id)
|
||||
{
|
||||
struct party_data* p;
|
||||
int i;
|
||||
|
||||
if( party_id == -1 )
|
||||
{// Get party_id from the database
|
||||
char* data;
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
return 0; //Eh? No party?
|
||||
|
||||
Sql_GetData(sql_handle, 0, &data, NULL);
|
||||
party_id = atoi(data);
|
||||
Sql_FreeResult(sql_handle);
|
||||
}
|
||||
if (party_id == 0)
|
||||
return 0; //No party...
|
||||
|
||||
p = inter_party_fromsql(party_id);
|
||||
if(!p) {
|
||||
ShowError("Character %d's party %d not found!\n", char_id, party_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Set member online
|
||||
for(i=0; i<MAX_PARTY; i++) {
|
||||
if (p->party.member[i].char_id == char_id) {
|
||||
if (!p->party.member[i].online) {
|
||||
p->party.member[i].online = 1;
|
||||
p->party.count++;
|
||||
if (p->party.member[i].lv < p->min_lv ||
|
||||
p->party.member[i].lv > p->max_lv)
|
||||
int_party_check_lv(p);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int inter_party_CharOffline(int char_id, int party_id) {
|
||||
struct party_data *p=NULL;
|
||||
int i;
|
||||
|
||||
if( party_id == -1 )
|
||||
{// Get guild_id from the database
|
||||
char* data;
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT party_id FROM `%s` WHERE char_id='%d'", char_db, char_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
return 0; //Eh? No party?
|
||||
|
||||
Sql_GetData(sql_handle, 0, &data, NULL);
|
||||
party_id = atoi(data);
|
||||
Sql_FreeResult(sql_handle);
|
||||
}
|
||||
if (party_id == 0)
|
||||
return 0; //No party...
|
||||
|
||||
//Character has a party, set character offline and check if they were the only member online
|
||||
if ((p = inter_party_fromsql(party_id)) == NULL)
|
||||
return 0;
|
||||
|
||||
//Set member offline
|
||||
for(i=0; i< MAX_PARTY; i++) {
|
||||
if(p->party.member[i].char_id == char_id)
|
||||
{
|
||||
p->party.member[i].online = 0;
|
||||
p->party.count--;
|
||||
if(p->party.member[i].lv == p->min_lv ||
|
||||
p->party.member[i].lv == p->max_lv)
|
||||
int_party_check_lv(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!p->party.count)
|
||||
//Parties don't have any data that needs be saved at this point... so just remove it from memory.
|
||||
idb_remove(party_db_, party_id);
|
||||
return 1;
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
@ -1,32 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INT_PARTY_SQL_H_
|
||||
#define _INT_PARTY_SQL_H_
|
||||
|
||||
//Party Flags on what to save/delete.
|
||||
//Create a new party entry (index holds leader's info)
|
||||
#define PS_CREATE 0x01
|
||||
//Update basic party info.
|
||||
#define PS_BASIC 0x02
|
||||
//Update party's leader
|
||||
#define PS_LEADER 0x04
|
||||
//Specify new party member (index specifies which party member)
|
||||
#define PS_ADDMEMBER 0x08
|
||||
//Specify member that left (index specifies which party member)
|
||||
#define PS_DELMEMBER 0x10
|
||||
//Specify that this party must be deleted.
|
||||
#define PS_BREAK 0x20
|
||||
|
||||
struct party;
|
||||
|
||||
int inter_party_parse_frommap(int fd);
|
||||
int inter_party_sql_init(void);
|
||||
void inter_party_sql_final(void);
|
||||
int inter_party_leave(int party_id,int account_id, int char_id);
|
||||
int inter_party_CharOnline(int char_id, int party_id);
|
||||
int inter_party_CharOffline(int char_id, int party_id);
|
||||
//Required for the TXT->SQL converter
|
||||
int inter_party_tosql(struct party *p, int flag, int index);
|
||||
|
||||
#endif /* _INT_PARTY_SQL_H_ */
|
@ -1,310 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/mmo.h"
|
||||
#include "../common/malloc.h"
|
||||
#include "../common/socket.h"
|
||||
#include "../common/strlib.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/utils.h"
|
||||
#include "../common/sql.h"
|
||||
#include "char.h"
|
||||
#include "inter.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
struct s_pet *pet_pt;
|
||||
|
||||
//---------------------------------------------------------
|
||||
int inter_pet_tosql(int pet_id, struct s_pet* p)
|
||||
{
|
||||
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`)
|
||||
char esc_name[NAME_LENGTH*2+1];// escaped pet name
|
||||
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, p->name, strnlen(p->name, NAME_LENGTH));
|
||||
p->hungry = cap_value(p->hungry, 0, 100);
|
||||
p->intimate = cap_value(p->intimate, 0, 1000);
|
||||
|
||||
if( pet_id == -1 )
|
||||
{// New pet.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` "
|
||||
"(`class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`) "
|
||||
"VALUES ('%d', '%s', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
|
||||
pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
|
||||
p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
p->pet_id = (int)Sql_LastInsertId(sql_handle);
|
||||
}
|
||||
else
|
||||
{// Update pet.
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `class`='%d',`name`='%s',`account_id`='%d',`char_id`='%d',`level`='%d',`egg_id`='%d',`equip`='%d',`intimate`='%d',`hungry`='%d',`rename_flag`='%d',`incuvate`='%d' WHERE `pet_id`='%d'",
|
||||
pet_db, p->class_, esc_name, p->account_id, p->char_id, p->level, p->egg_id,
|
||||
p->equip, p->intimate, p->hungry, p->rename_flag, p->incuvate, p->pet_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (save_log)
|
||||
ShowInfo("Pet saved %d - %s.\n", pet_id, p->name);
|
||||
return 1;
|
||||
}
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
int inter_pet_fromsql(int pet_id, struct s_pet* p)
|
||||
{
|
||||
char* data;
|
||||
size_t len;
|
||||
|
||||
#ifdef NOISY
|
||||
ShowInfo("Loading pet (%d)...\n",pet_id);
|
||||
#endif
|
||||
memset(p, 0, sizeof(struct s_pet));
|
||||
|
||||
//`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate`)
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incuvate` FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
|
||||
{
|
||||
p->pet_id = pet_id;
|
||||
Sql_GetData(sql_handle, 1, &data, NULL); p->class_ = atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, &len); memcpy(p->name, data, min(len, NAME_LENGTH));
|
||||
Sql_GetData(sql_handle, 3, &data, NULL); p->account_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 4, &data, NULL); p->char_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 5, &data, NULL); p->level = atoi(data);
|
||||
Sql_GetData(sql_handle, 6, &data, NULL); p->egg_id = atoi(data);
|
||||
Sql_GetData(sql_handle, 7, &data, NULL); p->equip = atoi(data);
|
||||
Sql_GetData(sql_handle, 8, &data, NULL); p->intimate = atoi(data);
|
||||
Sql_GetData(sql_handle, 9, &data, NULL); p->hungry = atoi(data);
|
||||
Sql_GetData(sql_handle, 10, &data, NULL); p->rename_flag = atoi(data);
|
||||
Sql_GetData(sql_handle, 11, &data, NULL); p->incuvate = atoi(data);
|
||||
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
p->hungry = cap_value(p->hungry, 0, 100);
|
||||
p->intimate = cap_value(p->intimate, 0, 1000);
|
||||
|
||||
if( save_log )
|
||||
ShowInfo("Pet loaded (%d - %s).\n", pet_id, p->name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//----------------------------------------------
|
||||
|
||||
int inter_pet_sql_init(void){
|
||||
//memory alloc
|
||||
pet_pt = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1);
|
||||
return 0;
|
||||
}
|
||||
void inter_pet_sql_final(void){
|
||||
if (pet_pt) aFree(pet_pt);
|
||||
return;
|
||||
}
|
||||
//----------------------------------
|
||||
int inter_pet_delete(int pet_id){
|
||||
ShowInfo("delete pet request: %d...\n",pet_id);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
//------------------------------------------------------
|
||||
int mapif_pet_created(int fd, int account_id, struct s_pet *p)
|
||||
{
|
||||
WFIFOHEAD(fd, 11);
|
||||
WFIFOW(fd, 0) =0x3880;
|
||||
WFIFOL(fd, 2) =account_id;
|
||||
if(p!=NULL){
|
||||
WFIFOB(fd, 6)=0;
|
||||
WFIFOL(fd, 7) =p->pet_id;
|
||||
ShowInfo("int_pet: created pet %d - %s\n", p->pet_id, p->name);
|
||||
}else{
|
||||
WFIFOB(fd, 6)=1;
|
||||
WFIFOL(fd, 7)=0;
|
||||
}
|
||||
WFIFOSET(fd, 11);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_pet_info(int fd, int account_id, struct s_pet *p){
|
||||
WFIFOHEAD(fd, sizeof(struct s_pet) + 9);
|
||||
WFIFOW(fd, 0) =0x3881;
|
||||
WFIFOW(fd, 2) =sizeof(struct s_pet) + 9;
|
||||
WFIFOL(fd, 4) =account_id;
|
||||
WFIFOB(fd, 8)=0;
|
||||
memcpy(WFIFOP(fd, 9), p, sizeof(struct s_pet));
|
||||
WFIFOSET(fd, WFIFOW(fd, 2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_pet_noinfo(int fd, int account_id){
|
||||
WFIFOHEAD(fd, sizeof(struct s_pet) + 9);
|
||||
WFIFOW(fd, 0) =0x3881;
|
||||
WFIFOW(fd, 2) =sizeof(struct s_pet) + 9;
|
||||
WFIFOL(fd, 4) =account_id;
|
||||
WFIFOB(fd, 8)=1;
|
||||
memset(WFIFOP(fd, 9), 0, sizeof(struct s_pet));
|
||||
WFIFOSET(fd, WFIFOW(fd, 2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_save_pet_ack(int fd, int account_id, int flag){
|
||||
WFIFOHEAD(fd, 7);
|
||||
WFIFOW(fd, 0) =0x3882;
|
||||
WFIFOL(fd, 2) =account_id;
|
||||
WFIFOB(fd, 6) =flag;
|
||||
WFIFOSET(fd, 7);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_delete_pet_ack(int fd, int flag){
|
||||
WFIFOHEAD(fd, 3);
|
||||
WFIFOW(fd, 0) =0x3883;
|
||||
WFIFOB(fd, 2) =flag;
|
||||
WFIFOSET(fd, 3);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id,
|
||||
short pet_equip, short intimate, short hungry, char rename_flag, char incuvate, char *pet_name)
|
||||
{
|
||||
memset(pet_pt, 0, sizeof(struct s_pet));
|
||||
strncpy(pet_pt->name, pet_name, NAME_LENGTH);
|
||||
if(incuvate == 1)
|
||||
pet_pt->account_id = pet_pt->char_id = 0;
|
||||
else {
|
||||
pet_pt->account_id = account_id;
|
||||
pet_pt->char_id = char_id;
|
||||
}
|
||||
pet_pt->class_ = pet_class;
|
||||
pet_pt->level = pet_lv;
|
||||
pet_pt->egg_id = pet_egg_id;
|
||||
pet_pt->equip = pet_equip;
|
||||
pet_pt->intimate = intimate;
|
||||
pet_pt->hungry = hungry;
|
||||
pet_pt->rename_flag = rename_flag;
|
||||
pet_pt->incuvate = incuvate;
|
||||
|
||||
if(pet_pt->hungry < 0)
|
||||
pet_pt->hungry = 0;
|
||||
else if(pet_pt->hungry > 100)
|
||||
pet_pt->hungry = 100;
|
||||
if(pet_pt->intimate < 0)
|
||||
pet_pt->intimate = 0;
|
||||
else if(pet_pt->intimate > 1000)
|
||||
pet_pt->intimate = 1000;
|
||||
|
||||
pet_pt->pet_id = -1; //Signal NEW pet.
|
||||
if (inter_pet_tosql(pet_pt->pet_id,pet_pt))
|
||||
mapif_pet_created(fd, account_id, pet_pt);
|
||||
else //Failed...
|
||||
mapif_pet_created(fd, account_id, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_load_pet(int fd, int account_id, int char_id, int pet_id){
|
||||
memset(pet_pt, 0, sizeof(struct s_pet));
|
||||
|
||||
inter_pet_fromsql(pet_id, pet_pt);
|
||||
|
||||
if(pet_pt!=NULL) {
|
||||
if(pet_pt->incuvate == 1) {
|
||||
pet_pt->account_id = pet_pt->char_id = 0;
|
||||
mapif_pet_info(fd, account_id, pet_pt);
|
||||
}
|
||||
else if(account_id == pet_pt->account_id && char_id == pet_pt->char_id)
|
||||
mapif_pet_info(fd, account_id, pet_pt);
|
||||
else
|
||||
mapif_pet_noinfo(fd, account_id);
|
||||
}
|
||||
else
|
||||
mapif_pet_noinfo(fd, account_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_save_pet(int fd, int account_id, struct s_pet *data) {
|
||||
//here process pet save request.
|
||||
int len;
|
||||
RFIFOHEAD(fd);
|
||||
len=RFIFOW(fd, 2);
|
||||
if(sizeof(struct s_pet)!=len-8) {
|
||||
ShowError("inter pet: data size error %d %d\n", sizeof(struct s_pet), len-8);
|
||||
}
|
||||
|
||||
else{
|
||||
if(data->hungry < 0)
|
||||
data->hungry = 0;
|
||||
else if(data->hungry > 100)
|
||||
data->hungry = 100;
|
||||
if(data->intimate < 0)
|
||||
data->intimate = 0;
|
||||
else if(data->intimate > 1000)
|
||||
data->intimate = 1000;
|
||||
inter_pet_tosql(data->pet_id,data);
|
||||
mapif_save_pet_ack(fd, account_id, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_delete_pet(int fd, int pet_id){
|
||||
mapif_delete_pet_ack(fd, inter_pet_delete(pet_id));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_parse_CreatePet(int fd){
|
||||
RFIFOHEAD(fd);
|
||||
mapif_create_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOW(fd, 10), RFIFOW(fd, 12), RFIFOW(fd, 14), RFIFOW(fd, 16), RFIFOW(fd, 18),
|
||||
RFIFOW(fd, 20), RFIFOB(fd, 22), RFIFOB(fd, 23), (char*)RFIFOP(fd, 24));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_parse_LoadPet(int fd){
|
||||
RFIFOHEAD(fd);
|
||||
mapif_load_pet(fd, RFIFOL(fd, 2), RFIFOL(fd, 6), RFIFOL(fd, 10));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_parse_SavePet(int fd){
|
||||
RFIFOHEAD(fd);
|
||||
mapif_save_pet(fd, RFIFOL(fd, 4), (struct s_pet *) RFIFOP(fd, 8));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_parse_DeletePet(int fd){
|
||||
RFIFOHEAD(fd);
|
||||
mapif_delete_pet(fd, RFIFOL(fd, 2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int inter_pet_parse_frommap(int fd){
|
||||
RFIFOHEAD(fd);
|
||||
switch(RFIFOW(fd, 0)){
|
||||
case 0x3080: mapif_parse_CreatePet(fd); break;
|
||||
case 0x3081: mapif_parse_LoadPet(fd); break;
|
||||
case 0x3082: mapif_parse_SavePet(fd); break;
|
||||
case 0x3083: mapif_parse_DeletePet(fd); break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
@ -1,21 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INT_PET_SQL_H_
|
||||
#define _INT_PET_SQL_H_
|
||||
|
||||
struct s_pet;
|
||||
|
||||
int inter_pet_init(void);
|
||||
void inter_pet_sql_final(void);
|
||||
int inter_pet_save(void);
|
||||
int inter_pet_delete(int pet_id);
|
||||
|
||||
int inter_pet_parse_frommap(int fd);
|
||||
int inter_pet_sql_init(void);
|
||||
//extern char pet_txt[256];
|
||||
|
||||
//Exported for use in the TXT-SQL converter.
|
||||
int inter_pet_tosql(int pet_id, struct s_pet *p);
|
||||
|
||||
#endif /* _INT_PET_SQL_H_ */
|
@ -1,250 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/mmo.h"
|
||||
#include "../common/malloc.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/socket.h"
|
||||
#include "../common/strlib.h" // StringBuf
|
||||
#include "../common/sql.h"
|
||||
#include "char.h"
|
||||
#include "inter.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#define STORAGE_MEMINC 16
|
||||
|
||||
/// Save storage data to sql
|
||||
int storage_tosql(int account_id, struct storage_data* p)
|
||||
{
|
||||
memitemdata_to_sql(p->items, MAX_STORAGE, account_id, TABLE_STORAGE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
/// Load storage data to mem
|
||||
int storage_fromsql(int account_id, struct storage_data* p)
|
||||
{
|
||||
StringBuf buf;
|
||||
struct item* item;
|
||||
char* data;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
memset(p, 0, sizeof(struct storage_data)); //clean up memory
|
||||
p->storage_amount = 0;
|
||||
|
||||
// storage {`account_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`}
|
||||
StringBuf_Init(&buf);
|
||||
StringBuf_AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`,`expire_time`");
|
||||
for( j = 0; j < MAX_SLOTS; ++j )
|
||||
StringBuf_Printf(&buf, ",`card%d`", j);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `account_id`='%d' ORDER BY `nameid`", storage_db, account_id);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
StringBuf_Destroy(&buf);
|
||||
|
||||
for( i = 0; i < MAX_STORAGE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
|
||||
{
|
||||
item = &p->items[i];
|
||||
Sql_GetData(sql_handle, 0, &data, NULL); item->id = atoi(data);
|
||||
Sql_GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data);
|
||||
Sql_GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data);
|
||||
Sql_GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data);
|
||||
Sql_GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data);
|
||||
Sql_GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data);
|
||||
Sql_GetData(sql_handle, 7, &data, NULL); item->expire_time = (unsigned int)atoi(data);
|
||||
for( j = 0; j < MAX_SLOTS; ++j )
|
||||
{
|
||||
Sql_GetData(sql_handle, 8+j, &data, NULL); item->card[j] = atoi(data);
|
||||
}
|
||||
}
|
||||
p->storage_amount = i;
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
ShowInfo("storage load complete from DB - id: %d (total: %d)\n", account_id, p->storage_amount);
|
||||
return 1;
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
||||
|
||||
/// Save guild_storage data to sql
|
||||
int guild_storage_tosql(int guild_id, struct guild_storage* p)
|
||||
{
|
||||
memitemdata_to_sql(p->items, MAX_GUILD_STORAGE, guild_id, TABLE_GUILD_STORAGE);
|
||||
ShowInfo ("guild storage save to DB - guild: %d\n", guild_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
/// Load guild_storage data to mem
|
||||
int guild_storage_fromsql(int guild_id, struct guild_storage* p)
|
||||
{
|
||||
StringBuf buf;
|
||||
struct item* item;
|
||||
char* data;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
memset(p, 0, sizeof(struct guild_storage)); //clean up memory
|
||||
p->storage_amount = 0;
|
||||
p->guild_id = guild_id;
|
||||
|
||||
// storage {`guild_id`/`id`/`nameid`/`amount`/`equip`/`identify`/`refine`/`attribute`/`card0`/`card1`/`card2`/`card3`}
|
||||
StringBuf_Init(&buf);
|
||||
StringBuf_AppendStr(&buf, "SELECT `id`,`nameid`,`amount`,`equip`,`identify`,`refine`,`attribute`");
|
||||
for( j = 0; j < MAX_SLOTS; ++j )
|
||||
StringBuf_Printf(&buf, ",`card%d`", j);
|
||||
StringBuf_Printf(&buf, " FROM `%s` WHERE `guild_id`='%d' ORDER BY `nameid`", guild_storage_db, guild_id);
|
||||
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf)) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
StringBuf_Destroy(&buf);
|
||||
|
||||
for( i = 0; i < MAX_GUILD_STORAGE && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
|
||||
{
|
||||
item = &p->items[i];
|
||||
Sql_GetData(sql_handle, 0, &data, NULL); item->id = atoi(data);
|
||||
Sql_GetData(sql_handle, 1, &data, NULL); item->nameid = atoi(data);
|
||||
Sql_GetData(sql_handle, 2, &data, NULL); item->amount = atoi(data);
|
||||
Sql_GetData(sql_handle, 3, &data, NULL); item->equip = atoi(data);
|
||||
Sql_GetData(sql_handle, 4, &data, NULL); item->identify = atoi(data);
|
||||
Sql_GetData(sql_handle, 5, &data, NULL); item->refine = atoi(data);
|
||||
Sql_GetData(sql_handle, 6, &data, NULL); item->attribute = atoi(data);
|
||||
item->expire_time = 0;
|
||||
for( j = 0; j < MAX_SLOTS; ++j )
|
||||
{
|
||||
Sql_GetData(sql_handle, 7+j, &data, NULL); item->card[j] = atoi(data);
|
||||
}
|
||||
}
|
||||
p->storage_amount = i;
|
||||
Sql_FreeResult(sql_handle);
|
||||
|
||||
ShowInfo("guild storage load complete from DB - id: %d (total: %d)\n", guild_id, p->storage_amount);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// storage data initialize
|
||||
int inter_storage_sql_init(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
// storage data finalize
|
||||
void inter_storage_sql_final(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// q?f[^?
|
||||
int inter_storage_delete(int account_id)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
int inter_guild_storage_delete(int guild_id)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_storage_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// packet from map server
|
||||
|
||||
int mapif_load_guild_storage(int fd,int account_id,int guild_id)
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else if( Sql_NumRows(sql_handle) > 0 )
|
||||
{// guild exists
|
||||
WFIFOHEAD(fd, sizeof(struct guild_storage)+12);
|
||||
WFIFOW(fd,0) = 0x3818;
|
||||
WFIFOW(fd,2) = sizeof(struct guild_storage)+12;
|
||||
WFIFOL(fd,4) = account_id;
|
||||
WFIFOL(fd,8) = guild_id;
|
||||
guild_storage_fromsql(guild_id, (struct guild_storage*)WFIFOP(fd,12));
|
||||
WFIFOSET(fd, WFIFOW(fd,2));
|
||||
return 0;
|
||||
}
|
||||
// guild does not exist
|
||||
Sql_FreeResult(sql_handle);
|
||||
WFIFOHEAD(fd, 12);
|
||||
WFIFOW(fd,0) = 0x3818;
|
||||
WFIFOW(fd,2) = 12;
|
||||
WFIFOL(fd,4) = account_id;
|
||||
WFIFOL(fd,8) = 0;
|
||||
WFIFOSET(fd, 12);
|
||||
return 0;
|
||||
}
|
||||
int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail)
|
||||
{
|
||||
WFIFOHEAD(fd,11);
|
||||
WFIFOW(fd,0)=0x3819;
|
||||
WFIFOL(fd,2)=account_id;
|
||||
WFIFOL(fd,6)=guild_id;
|
||||
WFIFOB(fd,10)=fail;
|
||||
WFIFOSET(fd,11);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// packet from map server
|
||||
|
||||
int mapif_parse_LoadGuildStorage(int fd)
|
||||
{
|
||||
RFIFOHEAD(fd);
|
||||
mapif_load_guild_storage(fd,RFIFOL(fd,2),RFIFOL(fd,6));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mapif_parse_SaveGuildStorage(int fd)
|
||||
{
|
||||
int guild_id;
|
||||
int len;
|
||||
|
||||
RFIFOHEAD(fd);
|
||||
guild_id = RFIFOL(fd,8);
|
||||
len = RFIFOW(fd,2);
|
||||
|
||||
if( sizeof(struct guild_storage) != len - 12 )
|
||||
{
|
||||
ShowError("inter storage: data size error %d != %d\n", sizeof(struct guild_storage), len - 12);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
else if( Sql_NumRows(sql_handle) > 0 )
|
||||
{// guild exists
|
||||
Sql_FreeResult(sql_handle);
|
||||
guild_storage_tosql(guild_id, (struct guild_storage*)RFIFOP(fd,12));
|
||||
mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 0);
|
||||
return 0;
|
||||
}
|
||||
Sql_FreeResult(sql_handle);
|
||||
}
|
||||
mapif_save_guild_storage_ack(fd, RFIFOL(fd,4), guild_id, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int inter_storage_parse_frommap(int fd)
|
||||
{
|
||||
RFIFOHEAD(fd);
|
||||
switch(RFIFOW(fd,0)){
|
||||
case 0x3018: mapif_parse_LoadGuildStorage(fd); break;
|
||||
case 0x3019: mapif_parse_SaveGuildStorage(fd); break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
@ -1,22 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INT_STORAGE_SQL_H_
|
||||
#define _INT_STORAGE_SQL_H_
|
||||
|
||||
struct storage_data;
|
||||
struct guild_storage;
|
||||
|
||||
int inter_storage_sql_init(void);
|
||||
void inter_storage_sql_final(void);
|
||||
int inter_storage_delete(int account_id);
|
||||
int inter_guild_storage_delete(int guild_id);
|
||||
|
||||
int inter_storage_parse_frommap(int fd);
|
||||
|
||||
//Exported for use in the TXT-SQL converter.
|
||||
int storage_fromsql(int account_id, struct storage_data* p);
|
||||
int storage_tosql(int account_id,struct storage_data *p);
|
||||
int guild_storage_tosql(int guild_id, struct guild_storage *p);
|
||||
|
||||
#endif /* _INT_STORAGE_SQL_H_ */
|
@ -1,744 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/mmo.h"
|
||||
#include "../common/db.h"
|
||||
#include "../common/malloc.h"
|
||||
#include "../common/strlib.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/socket.h"
|
||||
#include "../common/timer.h"
|
||||
#include "char.h"
|
||||
#include "inter.h"
|
||||
#include "int_party.h"
|
||||
#include "int_guild.h"
|
||||
#include "int_storage.h"
|
||||
#include "int_pet.h"
|
||||
#include "int_homun.h"
|
||||
#include "int_mercenary.h"
|
||||
#include "int_mail.h"
|
||||
#include "int_auction.h"
|
||||
#include "int_quest.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define WISDATA_TTL (60*1000) // Wisデータの生存時間(60秒)
|
||||
#define WISDELLIST_MAX 256 // Wisデータ削除リストの要素数
|
||||
|
||||
|
||||
Sql* sql_handle = NULL;
|
||||
|
||||
int char_server_port = 3306;
|
||||
char char_server_ip[32] = "127.0.0.1";
|
||||
char char_server_id[32] = "ragnarok";
|
||||
char char_server_pw[32] = "ragnarok";
|
||||
char char_server_db[32] = "ragnarok";
|
||||
char default_codepage[32] = ""; //Feature by irmin.
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
|
||||
static struct accreg *accreg_pt;
|
||||
unsigned int party_share_level = 10;
|
||||
char main_chat_nick[16] = "Main";
|
||||
|
||||
// recv. packet list
|
||||
int inter_recv_packet_length[] = {
|
||||
-1,-1, 7,-1, -1,13,36, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3000-
|
||||
6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, // 3010-
|
||||
-1,10,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, // 3020- Party
|
||||
-1, 6,-1,-1, 55,19, 6,-1, 14,-1,-1,-1, 18,19,186,-1, // 3030-
|
||||
5, 9, 0, 0, 0, 0, 0, 0, 7, 6,10,10, 10,-1, 0, 0, // 3040-
|
||||
-1,-1,10,10, 0,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3050- Auction System [Zephyrus]
|
||||
6,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3060- Quest system [Kevin] [Inkfish]
|
||||
-1,10, 6,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3070- Mercenary packets [Zephyrus]
|
||||
48,14,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3080-
|
||||
-1,10,-1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 3090- Homunculus packets [albator]
|
||||
};
|
||||
|
||||
struct WisData {
|
||||
int id, fd, count, len;
|
||||
unsigned long tick;
|
||||
unsigned char src[24], dst[24], msg[512];
|
||||
};
|
||||
static DBMap* wis_db = NULL; // int wis_id -> struct WisData*
|
||||
static int wis_dellist[WISDELLIST_MAX], wis_delnum;
|
||||
|
||||
#endif //TXT_SQL_CONVERT
|
||||
//--------------------------------------------------------
|
||||
// Save registry to sql
|
||||
int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type)
|
||||
{
|
||||
struct global_reg* r;
|
||||
SqlStmt* stmt;
|
||||
int i;
|
||||
|
||||
if( account_id <= 0 )
|
||||
return 0;
|
||||
reg->account_id = account_id;
|
||||
reg->char_id = char_id;
|
||||
|
||||
//`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`)
|
||||
switch( type )
|
||||
{
|
||||
case 3: //Char Reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
account_id = 0;
|
||||
break;
|
||||
case 2: //Account Reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `type`=2 AND `account_id`='%d'", reg_db, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
char_id = 0;
|
||||
break;
|
||||
case 1: //Account2 Reg
|
||||
ShowError("inter_accreg_tosql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
|
||||
return 0;
|
||||
default:
|
||||
ShowError("inter_accreg_tosql: Invalid type %d\n", type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( reg->reg_num <= 0 )
|
||||
return 0;
|
||||
|
||||
stmt = SqlStmt_Malloc(sql_handle);
|
||||
if( SQL_ERROR == SqlStmt_Prepare(stmt, "INSERT INTO `%s` (`type`, `account_id`, `char_id`, `str`, `value`) VALUES ('%d','%d','%d',?,?)", reg_db, type, account_id, char_id) )
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
for( i = 0; i < reg->reg_num; ++i )
|
||||
{
|
||||
r = ®->reg[i];
|
||||
if( r->str[0] != '\0' && r->value != '\0' )
|
||||
{
|
||||
// str
|
||||
SqlStmt_BindParam(stmt, 0, SQLDT_STRING, r->str, strnlen(r->str, sizeof(r->str)));
|
||||
// value
|
||||
SqlStmt_BindParam(stmt, 1, SQLDT_STRING, r->value, strnlen(r->value, sizeof(r->value)));
|
||||
|
||||
if( SQL_ERROR == SqlStmt_Execute(stmt) )
|
||||
SqlStmt_ShowDebug(stmt);
|
||||
}
|
||||
}
|
||||
SqlStmt_Free(stmt);
|
||||
return 1;
|
||||
}
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
|
||||
// Load account_reg from sql (type=2)
|
||||
int inter_accreg_fromsql(int account_id,int char_id, struct accreg *reg, int type)
|
||||
{
|
||||
struct global_reg* r;
|
||||
char* data;
|
||||
size_t len;
|
||||
int i;
|
||||
|
||||
if( reg == NULL)
|
||||
return 0;
|
||||
|
||||
memset(reg, 0, sizeof(struct accreg));
|
||||
reg->account_id = account_id;
|
||||
reg->char_id = char_id;
|
||||
|
||||
//`global_reg_value` (`type`, `account_id`, `char_id`, `str`, `value`)
|
||||
switch( type )
|
||||
{
|
||||
case 3: //char reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=3 AND `char_id`='%d'", reg_db, char_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 2: //account reg
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `str`, `value` FROM `%s` WHERE `type`=2 AND `account_id`='%d'", reg_db, account_id) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
break;
|
||||
case 1: //account2 reg
|
||||
ShowError("inter_accreg_fromsql: Char server shouldn't handle type 1 registry values (##). That is the login server's work!\n");
|
||||
return 0;
|
||||
default:
|
||||
ShowError("inter_accreg_fromsql: Invalid type %d\n", type);
|
||||
return 0;
|
||||
}
|
||||
for( i = 0; i < MAX_REG_NUM && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
|
||||
{
|
||||
r = ®->reg[i];
|
||||
// str
|
||||
Sql_GetData(sql_handle, 0, &data, &len);
|
||||
memcpy(r->str, data, min(len, sizeof(r->str)));
|
||||
// value
|
||||
Sql_GetData(sql_handle, 1, &data, &len);
|
||||
memcpy(r->value, data, min(len, sizeof(r->value)));
|
||||
}
|
||||
reg->reg_num = i;
|
||||
Sql_FreeResult(sql_handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Initialize
|
||||
int inter_accreg_sql_init(void)
|
||||
{
|
||||
CREATE(accreg_pt, struct accreg, 1);
|
||||
return 0;
|
||||
|
||||
}
|
||||
#endif //TXT_SQL_CONVERT
|
||||
|
||||
/*==========================================
|
||||
* read config file
|
||||
*------------------------------------------*/
|
||||
static int inter_config_read(const char* cfgName)
|
||||
{
|
||||
int i;
|
||||
char line[1024], w1[1024], w2[1024];
|
||||
FILE* fp;
|
||||
|
||||
fp = fopen(cfgName, "r");
|
||||
if(fp == NULL) {
|
||||
ShowError("file not found: %s\n", cfgName);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ShowInfo("reading file %s...\n", cfgName);
|
||||
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
i = sscanf(line, "%[^:]: %[^\r\n]", w1, w2);
|
||||
if(i != 2)
|
||||
continue;
|
||||
|
||||
if(!strcmpi(w1,"char_server_ip")) {
|
||||
strcpy(char_server_ip,w2);
|
||||
ShowStatus ("set char_server_ip : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"char_server_port")) {
|
||||
char_server_port = atoi(w2);
|
||||
ShowStatus ("set char_server_port : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"char_server_id")) {
|
||||
strcpy(char_server_id,w2);
|
||||
ShowStatus ("set char_server_id : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"char_server_pw")) {
|
||||
strcpy(char_server_pw,w2);
|
||||
ShowStatus ("set char_server_pw : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"char_server_db")) {
|
||||
strcpy(char_server_db,w2);
|
||||
ShowStatus ("set char_server_db : %s\n", w2);
|
||||
} else
|
||||
if(!strcmpi(w1,"default_codepage")) {
|
||||
strcpy(default_codepage,w2);
|
||||
ShowStatus ("set default_codepage : %s\n", w2);
|
||||
}
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
else if(!strcmpi(w1,"party_share_level"))
|
||||
party_share_level = atoi(w2);
|
||||
else if(!strcmpi(w1,"log_inter"))
|
||||
log_inter = atoi(w2);
|
||||
else if(!strcmpi(w1,"main_chat_nick"))
|
||||
safestrncpy(main_chat_nick, w2, sizeof(main_chat_nick));
|
||||
#endif //TXT_SQL_CONVERT
|
||||
else if(!strcmpi(w1,"import"))
|
||||
inter_config_read(w2);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
ShowInfo ("done reading %s.\n", cfgName);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
|
||||
// Save interlog into sql
|
||||
int inter_log(char* fmt, ...)
|
||||
{
|
||||
char str[255];
|
||||
char esc_str[sizeof(str)*2+1];// escaped str
|
||||
va_list ap;
|
||||
|
||||
va_start(ap,fmt);
|
||||
vsnprintf(str, sizeof(str), fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
Sql_EscapeStringLen(sql_handle, esc_str, str, strnlen(str, sizeof(str)));
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s` (`time`, `log`) VALUES (NOW(), '%s')", interlog_db, esc_str) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif //TXT_SQL_CONVERT
|
||||
|
||||
// initialize
|
||||
int inter_init_sql(const char *file)
|
||||
{
|
||||
//int i;
|
||||
|
||||
ShowInfo ("interserver initialize...\n");
|
||||
inter_config_read(file);
|
||||
|
||||
//DB connection initialized
|
||||
sql_handle = Sql_Malloc();
|
||||
ShowInfo("Connect Character DB server.... (Character Server)\n");
|
||||
if( SQL_ERROR == Sql_Connect(sql_handle, char_server_id, char_server_pw, char_server_ip, (uint16)char_server_port, char_server_db) )
|
||||
{
|
||||
Sql_ShowDebug(sql_handle);
|
||||
Sql_Free(sql_handle);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if( *default_codepage ) {
|
||||
if( SQL_ERROR == Sql_SetEncoding(sql_handle, default_codepage) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
}
|
||||
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
wis_db = idb_alloc(DB_OPT_RELEASE_DATA);
|
||||
inter_guild_sql_init();
|
||||
inter_storage_sql_init();
|
||||
inter_party_sql_init();
|
||||
inter_pet_sql_init();
|
||||
inter_homunculus_sql_init();
|
||||
inter_mercenary_sql_init();
|
||||
inter_accreg_sql_init();
|
||||
inter_mail_sql_init();
|
||||
inter_auction_sql_init();
|
||||
|
||||
#endif //TXT_SQL_CONVERT
|
||||
return 0;
|
||||
}
|
||||
#ifndef TXT_SQL_CONVERT
|
||||
|
||||
// finalize
|
||||
void inter_final(void)
|
||||
{
|
||||
wis_db->destroy(wis_db, NULL);
|
||||
|
||||
inter_guild_sql_final();
|
||||
inter_storage_sql_final();
|
||||
inter_party_sql_final();
|
||||
inter_pet_sql_final();
|
||||
inter_homunculus_sql_final();
|
||||
inter_mercenary_sql_final();
|
||||
inter_mail_sql_final();
|
||||
inter_auction_sql_final();
|
||||
|
||||
if (accreg_pt) aFree(accreg_pt);
|
||||
return;
|
||||
}
|
||||
|
||||
int inter_mapif_init(int fd)
|
||||
{
|
||||
inter_guild_mapif_init(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
||||
// broadcast sending
|
||||
int mapif_broadcast(unsigned char *mes, int len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd)
|
||||
{
|
||||
unsigned char *buf = (unsigned char*)aMallocA((len)*sizeof(unsigned char));
|
||||
|
||||
WBUFW(buf,0) = 0x3800;
|
||||
WBUFW(buf,2) = len;
|
||||
WBUFL(buf,4) = fontColor;
|
||||
WBUFW(buf,8) = fontType;
|
||||
WBUFW(buf,10) = fontSize;
|
||||
WBUFW(buf,12) = fontAlign;
|
||||
WBUFW(buf,14) = fontY;
|
||||
memcpy(WBUFP(buf,16), mes, len - 16);
|
||||
mapif_sendallwos(sfd, buf, len);
|
||||
|
||||
if (buf)
|
||||
aFree(buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Wis sending
|
||||
int mapif_wis_message(struct WisData *wd)
|
||||
{
|
||||
unsigned char buf[2048];
|
||||
if (wd->len > 2047-56) wd->len = 2047-56; //Force it to fit to avoid crashes. [Skotlex]
|
||||
|
||||
WBUFW(buf, 0) = 0x3801;
|
||||
WBUFW(buf, 2) = 56 +wd->len;
|
||||
WBUFL(buf, 4) = wd->id;
|
||||
memcpy(WBUFP(buf, 8), wd->src, NAME_LENGTH);
|
||||
memcpy(WBUFP(buf,32), wd->dst, NAME_LENGTH);
|
||||
memcpy(WBUFP(buf,56), wd->msg, wd->len);
|
||||
wd->count = mapif_sendall(buf,WBUFW(buf,2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Wis sending result
|
||||
int mapif_wis_end(struct WisData *wd, int flag)
|
||||
{
|
||||
unsigned char buf[27];
|
||||
|
||||
WBUFW(buf, 0)=0x3802;
|
||||
memcpy(WBUFP(buf, 2),wd->src,24);
|
||||
WBUFB(buf,26)=flag;
|
||||
mapif_send(wd->fd,buf,27);
|
||||
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));
|
||||
}
|
||||
|
||||
// Send the requested account_reg
|
||||
int mapif_account_reg_reply(int fd,int account_id,int char_id, int type)
|
||||
{
|
||||
struct accreg *reg=accreg_pt;
|
||||
WFIFOHEAD(fd, 13 + 5000);
|
||||
inter_accreg_fromsql(account_id,char_id,reg,type);
|
||||
|
||||
WFIFOW(fd,0)=0x3804;
|
||||
WFIFOL(fd,4)=account_id;
|
||||
WFIFOL(fd,8)=char_id;
|
||||
WFIFOB(fd,12)=type;
|
||||
if(reg->reg_num==0){
|
||||
WFIFOW(fd,2)=13;
|
||||
}else{
|
||||
int i,p;
|
||||
for (p=13,i = 0; i < reg->reg_num && p < 5000; i++) {
|
||||
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)
|
||||
ShowWarning("Too many acc regs for %d:%d, not all values were loaded.\n", account_id, char_id);
|
||||
}
|
||||
WFIFOSET(fd,WFIFOW(fd,2));
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Request to kick char from a certain map server. [Skotlex]
|
||||
int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason)
|
||||
{
|
||||
if (fd >= 0)
|
||||
{
|
||||
WFIFOHEAD(fd,7);
|
||||
WFIFOW(fd,0) = 0x2b1f;
|
||||
WFIFOL(fd,2) = account_id;
|
||||
WFIFOB(fd,6) = reason;
|
||||
WFIFOSET(fd,7);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
||||
// Existence check of WISP data
|
||||
int check_ttl_wisdata_sub(DBKey key, void *data, va_list ap)
|
||||
{
|
||||
unsigned long tick;
|
||||
struct WisData *wd = (struct WisData *)data;
|
||||
tick = va_arg(ap, unsigned long);
|
||||
|
||||
if (DIFF_TICK(tick, wd->tick) > WISDATA_TTL && wis_delnum < WISDELLIST_MAX)
|
||||
wis_dellist[wis_delnum++] = wd->id;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int check_ttl_wisdata(void)
|
||||
{
|
||||
unsigned long tick = gettick();
|
||||
int i;
|
||||
|
||||
do {
|
||||
wis_delnum = 0;
|
||||
wis_db->foreach(wis_db, check_ttl_wisdata_sub, tick);
|
||||
for(i = 0; i < wis_delnum; 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
|
||||
idb_remove(wis_db, wd->id);
|
||||
}
|
||||
} while(wis_delnum >= WISDELLIST_MAX);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
||||
// broadcast sending
|
||||
int mapif_parse_broadcast(int fd)
|
||||
{
|
||||
mapif_broadcast(RFIFOP(fd,16), RFIFOW(fd,2), RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Wisp/page request to send
|
||||
int mapif_parse_WisRequest(int fd)
|
||||
{
|
||||
struct WisData* wd;
|
||||
static int wisid = 0;
|
||||
char name[NAME_LENGTH];
|
||||
char esc_name[NAME_LENGTH*2+1];// escaped name
|
||||
char* data;
|
||||
size_t len;
|
||||
|
||||
|
||||
if ( fd <= 0 ) {return 0;} // check if we have a valid fd
|
||||
|
||||
if (RFIFOW(fd,2)-52 >= sizeof(wd->msg)) {
|
||||
ShowWarning("inter: Wis message size too long.\n");
|
||||
return 0;
|
||||
} else if (RFIFOW(fd,2)-52 <= 0) { // normaly, impossible, but who knows...
|
||||
ShowError("inter: Wis message doesn't exist.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
safestrncpy(name, (char*)RFIFOP(fd,28), NAME_LENGTH); //Received name may be too large and not contain \0! [Skotlex]
|
||||
|
||||
Sql_EscapeStringLen(sql_handle, esc_name, name, strnlen(name, NAME_LENGTH));
|
||||
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `name` FROM `%s` WHERE `name`='%s'", char_db, esc_name) )
|
||||
Sql_ShowDebug(sql_handle);
|
||||
|
||||
// search if character exists before to ask all map-servers
|
||||
if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
|
||||
{
|
||||
unsigned char buf[27];
|
||||
WBUFW(buf, 0) = 0x3802;
|
||||
memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH);
|
||||
WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
|
||||
mapif_send(fd, buf, 27);
|
||||
}
|
||||
else
|
||||
{// Character exists. So, ask all map-servers
|
||||
// to be sure of the correct name, rewrite it
|
||||
Sql_GetData(sql_handle, 0, &data, &len);
|
||||
memset(name, 0, NAME_LENGTH);
|
||||
memcpy(name, data, min(len, NAME_LENGTH));
|
||||
// if source is destination, don't ask other servers.
|
||||
if( strncmp((const char*)RFIFOP(fd,4), name, NAME_LENGTH) == 0 )
|
||||
{
|
||||
uint8 buf[27];
|
||||
WBUFW(buf, 0) = 0x3802;
|
||||
memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), NAME_LENGTH);
|
||||
WBUFB(buf,26) = 1; // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
|
||||
mapif_send(fd, buf, 27);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
CREATE(wd, struct WisData, 1);
|
||||
|
||||
// Whether the failure of previous wisp/page transmission (timeout)
|
||||
check_ttl_wisdata();
|
||||
|
||||
wd->id = ++wisid;
|
||||
wd->fd = fd;
|
||||
wd->len= RFIFOW(fd,2)-52;
|
||||
memcpy(wd->src, RFIFOP(fd, 4), NAME_LENGTH);
|
||||
memcpy(wd->dst, RFIFOP(fd,28), NAME_LENGTH);
|
||||
memcpy(wd->msg, RFIFOP(fd,52), wd->len);
|
||||
wd->tick = gettick();
|
||||
idb_put(wis_db, wd->id, wd);
|
||||
mapif_wis_message(wd);
|
||||
}
|
||||
}
|
||||
|
||||
Sql_FreeResult(sql_handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Wisp/page transmission result
|
||||
int mapif_parse_WisReply(int fd)
|
||||
{
|
||||
int id, flag;
|
||||
struct WisData *wd;
|
||||
|
||||
id = RFIFOL(fd,2);
|
||||
flag = RFIFOB(fd,6);
|
||||
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
|
||||
|
||||
if ((--wd->count) <= 0 || flag != 1) {
|
||||
mapif_wis_end(wd, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
|
||||
idb_remove(wis_db, id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Received wisp message from map-server for ALL gm (just copy the message and resends it to ALL map-servers)
|
||||
int mapif_parse_WisToGM(int fd)
|
||||
{
|
||||
unsigned char buf[2048]; // 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B
|
||||
|
||||
memcpy(WBUFP(buf,0), RFIFOP(fd,0), RFIFOW(fd,2));
|
||||
WBUFW(buf, 0) = 0x3803;
|
||||
mapif_sendall(buf, RFIFOW(fd,2));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Save account_reg into sql (type=2)
|
||||
int mapif_parse_Registry(int fd)
|
||||
{
|
||||
int j,p,len, max;
|
||||
struct accreg *reg=accreg_pt;
|
||||
|
||||
memset(accreg_pt,0,sizeof(struct accreg));
|
||||
switch (RFIFOB(fd, 12)) {
|
||||
case 3: //Character registry
|
||||
max = GLOBAL_REG_NUM;
|
||||
break;
|
||||
case 2: //Account Registry
|
||||
max = ACCOUNT_REG_NUM;
|
||||
break;
|
||||
case 1: //Account2 registry, must be sent over to login server.
|
||||
return save_accreg2(RFIFOP(fd,4), RFIFOW(fd,2)-4);
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
for(j=0,p=13;j<max && p<RFIFOW(fd,2);j++){
|
||||
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((char*)RFIFOP(fd,p), "%255c%n",reg->reg[j].value,&len);
|
||||
reg->reg[j].value[len]='\0';
|
||||
p +=len+1;
|
||||
}
|
||||
reg->reg_num=j;
|
||||
|
||||
inter_accreg_tosql(RFIFOL(fd,4),RFIFOL(fd,8),reg, RFIFOB(fd,12));
|
||||
mapif_account_reg(fd,RFIFOP(fd,0)); // Send updated accounts to other map servers.
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Request the value of all registries.
|
||||
int mapif_parse_RegistryRequest(int fd)
|
||||
{
|
||||
//Load Char Registry
|
||||
if (RFIFOB(fd,12)) mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),3);
|
||||
//Load Account Registry
|
||||
if (RFIFOB(fd,11)) mapif_account_reg_reply(fd,RFIFOL(fd,2),RFIFOL(fd,6),2);
|
||||
//Ask Login Server for Account2 values.
|
||||
if (RFIFOB(fd,10)) request_accreg2(RFIFOL(fd,2),RFIFOL(fd,6));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, char *name)
|
||||
{
|
||||
WFIFOHEAD(fd, NAME_LENGTH+13);
|
||||
WFIFOW(fd, 0) = 0x3806;
|
||||
WFIFOL(fd, 2) = account_id;
|
||||
WFIFOL(fd, 6) = char_id;
|
||||
WFIFOB(fd,10) = type;
|
||||
WFIFOB(fd,11) = flag;
|
||||
memcpy(WFIFOP(fd, 12), name, NAME_LENGTH);
|
||||
WFIFOSET(fd, NAME_LENGTH+13);
|
||||
}
|
||||
|
||||
int mapif_parse_NameChangeRequest(int fd)
|
||||
{
|
||||
int account_id, char_id, type;
|
||||
char* name;
|
||||
int i;
|
||||
|
||||
account_id = RFIFOL(fd,2);
|
||||
char_id = RFIFOL(fd,6);
|
||||
type = RFIFOB(fd,10);
|
||||
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
|
||||
for (i = 0; i < NAME_LENGTH && name[i]; i++)
|
||||
if (strchr(char_name_letters, name[i]) == NULL) {
|
||||
mapif_namechange_ack(fd, account_id, char_id, type, 0, name);
|
||||
return 0;
|
||||
}
|
||||
} else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
|
||||
for (i = 0; i < NAME_LENGTH && name[i]; i++)
|
||||
if (strchr(char_name_letters, name[i]) != NULL) {
|
||||
mapif_namechange_ack(fd, account_id, char_id, type, 0, name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
//TODO: type holds the type of object to rename.
|
||||
//If it were a player, it needs to have the guild information and db information
|
||||
//updated here, because changing it on the map won't make it be saved [Skotlex]
|
||||
|
||||
//name allowed.
|
||||
mapif_namechange_ack(fd, account_id, char_id, type, 1, name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
||||
/// Returns the length of the next complete packet to process,
|
||||
/// or 0 if no complete packet exists in the queue.
|
||||
///
|
||||
/// @param length The minimum allowed length, or -1 for dynamic lookup
|
||||
int inter_check_length(int fd, int length)
|
||||
{
|
||||
if( length == -1 )
|
||||
{// variable-length packet
|
||||
if( RFIFOREST(fd) < 4 )
|
||||
return 0;
|
||||
length = RFIFOW(fd,2);
|
||||
}
|
||||
|
||||
if( (int)RFIFOREST(fd) < length )
|
||||
return 0;
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
int inter_parse_frommap(int fd)
|
||||
{
|
||||
int cmd;
|
||||
int len = 0;
|
||||
cmd = RFIFOW(fd,0);
|
||||
// inter鯖管轄かを調べる
|
||||
if(cmd < 0x3000 || cmd >= 0x3000 + ARRAYLENGTH(inter_recv_packet_length) || inter_recv_packet_length[cmd - 0x3000] == 0)
|
||||
return 0;
|
||||
|
||||
// パケット長を調べる
|
||||
if((len = inter_check_length(fd, inter_recv_packet_length[cmd - 0x3000])) == 0)
|
||||
return 2;
|
||||
|
||||
switch(cmd) {
|
||||
case 0x3000: mapif_parse_broadcast(fd); break;
|
||||
case 0x3001: mapif_parse_WisRequest(fd); break;
|
||||
case 0x3002: mapif_parse_WisReply(fd); break;
|
||||
case 0x3003: mapif_parse_WisToGM(fd); break;
|
||||
case 0x3004: mapif_parse_Registry(fd); break;
|
||||
case 0x3005: mapif_parse_RegistryRequest(fd); break;
|
||||
case 0x3006: mapif_parse_NameChangeRequest(fd); break;
|
||||
default:
|
||||
if( inter_party_parse_frommap(fd)
|
||||
|| inter_guild_parse_frommap(fd)
|
||||
|| inter_storage_parse_frommap(fd)
|
||||
|| inter_pet_parse_frommap(fd)
|
||||
|| inter_homunculus_parse_frommap(fd)
|
||||
|| inter_mercenary_parse_frommap(fd)
|
||||
|| inter_mail_parse_frommap(fd)
|
||||
|| inter_auction_parse_frommap(fd)
|
||||
|| inter_quest_parse_frommap(fd)
|
||||
)
|
||||
break;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
RFIFOSKIP(fd, len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif //TXT_SQL_CONVERT
|
@ -1,30 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef _INTER_SQL_H_
|
||||
#define _INTER_SQL_H_
|
||||
|
||||
struct accreg;
|
||||
#include "../common/sql.h"
|
||||
|
||||
int inter_init_sql(const char *file);
|
||||
void inter_final(void);
|
||||
int inter_parse_frommap(int fd);
|
||||
int inter_mapif_init(int fd);
|
||||
int mapif_send_gmaccounts(void);
|
||||
int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason);
|
||||
|
||||
int inter_log(char *fmt,...);
|
||||
|
||||
#define inter_cfgName "conf/inter_athena.conf"
|
||||
|
||||
extern unsigned int party_share_level;
|
||||
|
||||
extern Sql* sql_handle;
|
||||
extern Sql* lsql_handle;
|
||||
|
||||
extern char main_chat_nick[16];
|
||||
|
||||
int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type);
|
||||
|
||||
#endif /* _INTER_SQL_H_ */
|
@ -3,12 +3,10 @@
|
||||
# setup
|
||||
#
|
||||
set( LOGIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
set( TXT_LOGIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
set( SQL_LOGIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
|
||||
|
||||
#
|
||||
# targets
|
||||
#
|
||||
add_subdirectory( txt )
|
||||
add_subdirectory( sql )
|
||||
|
@ -18,8 +18,6 @@ MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h
|
||||
MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar
|
||||
|
||||
LOGIN_OBJ = login.o
|
||||
LOGIN_TXT_OBJ = $(LOGIN_OBJ:%=obj_txt/%) \
|
||||
obj_txt/account_txt.o obj_txt/ipban_txt.o obj_txt/loginlog_txt.o
|
||||
LOGIN_SQL_OBJ = $(LOGIN_OBJ:%=obj_sql/%) \
|
||||
obj_sql/account_sql.o obj_sql/ipban_sql.o obj_sql/loginlog_sql.o
|
||||
LOGIN_H = login.h account.h ipban.h loginlog.h
|
||||
@ -30,26 +28,22 @@ ifeq ($(HAVE_MYSQL),yes)
|
||||
else
|
||||
LOGIN_SERVER_SQL_DEPENDS=needs_mysql
|
||||
endif
|
||||
LOGIN_SERVER_TXT_DEPENDS=obj_txt $(LOGIN_TXT_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ)
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
#####################################################################
|
||||
.PHONY :all txt sql clean help
|
||||
.PHONY :all sql clean help
|
||||
|
||||
all: txt sql
|
||||
|
||||
txt: obj_txt login-server
|
||||
all: sql
|
||||
|
||||
sql: obj_sql login-server_sql
|
||||
|
||||
clean:
|
||||
rm -rf *.o obj_txt obj_sql ../../login-server@EXEEXT@ ../../login-server_sql@EXEEXT@
|
||||
rm -rf *.o obj_sql ../../login-server@EXEEXT@ ../../login-server_sql@EXEEXT@
|
||||
|
||||
help:
|
||||
@echo "possible targets are 'sql' 'txt' 'all' 'clean' 'help'"
|
||||
@echo "possible targets are 'sql' 'all' 'clean' 'help'"
|
||||
@echo "'sql' - login server (SQL version)"
|
||||
@echo "'txt' - login server (TXT version)"
|
||||
@echo "'all' - builds all above targets"
|
||||
@echo "'clean' - cleans builds and objects"
|
||||
@echo "'help' - outputs this message"
|
||||
@ -61,29 +55,23 @@ needs_mysql:
|
||||
@exit 1
|
||||
|
||||
# object directories
|
||||
obj_txt:
|
||||
test -d obj_txt || mkdir obj_txt
|
||||
|
||||
obj_sql:
|
||||
test -d obj_sql || mkdir obj_sql
|
||||
|
||||
#executables
|
||||
login-server: $(LOGIN_SERVER_TXT_DEPENDS)
|
||||
@CC@ @LDFLAGS@ -o ../../login-server@EXEEXT@ $(LOGIN_TXT_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @LIBS@
|
||||
|
||||
login-server_sql: $(LOGIN_SERVER_SQL_DEPENDS)
|
||||
@CC@ @LDFLAGS@ -o ../../login-server_sql@EXEEXT@ $(LOGIN_SQL_OBJ) $(COMMON_OBJ) $(COMMON_SQL_OBJ) $(MT19937AR_OBJ) @LIBS@ @MYSQL_LIBS@
|
||||
|
||||
# login object files
|
||||
obj_txt/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H)
|
||||
@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) -DWITH_TXT @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
|
||||
|
||||
obj_sql/%.o: %.c $(LOGIN_H) $(COMMON_H) $(MT19937AR_H)
|
||||
@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
|
||||
|
||||
# missing object files
|
||||
../common/obj_all/%.o:
|
||||
@$(MAKE) -C ../common txt
|
||||
@$(MAKE) -C ../common sql
|
||||
|
||||
../common/obj_sql/%.o:
|
||||
@$(MAKE) -C ../common sql
|
||||
|
@ -12,12 +12,8 @@ typedef struct AccountDBIterator AccountDBIterator;
|
||||
|
||||
|
||||
// standard engines
|
||||
#ifdef WITH_TXT
|
||||
AccountDB* account_db_txt(void);
|
||||
#endif
|
||||
#ifdef WITH_SQL
|
||||
AccountDB* account_db_sql(void);
|
||||
#endif
|
||||
|
||||
// extra engines (will probably use the other txt functions)
|
||||
#define ACCOUNTDB_CONSTRUCTOR_(engine) account_db_##engine
|
||||
#define ACCOUNTDB_CONSTRUCTOR(engine) ACCOUNTDB_CONSTRUCTOR_(engine)
|
||||
|
@ -1,645 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/db.h"
|
||||
#include "../common/lock.h"
|
||||
#include "../common/malloc.h"
|
||||
#include "../common/mmo.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/strlib.h"
|
||||
#include "../common/timer.h"
|
||||
#include "account.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/// global defines
|
||||
#define ACCOUNT_TXT_DB_VERSION 20110114
|
||||
#define AUTHS_BEFORE_SAVE 10 // flush every 10 saves
|
||||
#define AUTH_SAVING_INTERVAL 60000 // flush every 10 minutes
|
||||
|
||||
/// internal structure
|
||||
typedef struct AccountDB_TXT
|
||||
{
|
||||
AccountDB vtable; // public interface
|
||||
|
||||
DBMap* accounts; // in-memory accounts storage
|
||||
int next_account_id; // auto_increment
|
||||
int auths_before_save; // prevents writing to disk too often
|
||||
int save_timer; // save timer id
|
||||
|
||||
char account_db[1024]; // account data storage file
|
||||
bool case_sensitive; // how to look up usernames
|
||||
|
||||
} AccountDB_TXT;
|
||||
|
||||
/// internal structure
|
||||
typedef struct AccountDBIterator_TXT
|
||||
{
|
||||
AccountDBIterator vtable; // public interface
|
||||
|
||||
DBIterator* iter;
|
||||
} AccountDBIterator_TXT;
|
||||
|
||||
/// internal functions
|
||||
static bool account_db_txt_init(AccountDB* self);
|
||||
static void account_db_txt_destroy(AccountDB* self);
|
||||
static bool account_db_txt_get_property(AccountDB* self, const char* key, char* buf, size_t buflen);
|
||||
static bool account_db_txt_set_property(AccountDB* self, const char* option, const char* value);
|
||||
static bool account_db_txt_create(AccountDB* self, struct mmo_account* acc);
|
||||
static bool account_db_txt_remove(AccountDB* self, const int account_id);
|
||||
static bool account_db_txt_save(AccountDB* self, const struct mmo_account* acc);
|
||||
static bool account_db_txt_load_num(AccountDB* self, struct mmo_account* acc, const int account_id);
|
||||
static bool account_db_txt_load_str(AccountDB* self, struct mmo_account* acc, const char* userid);
|
||||
static AccountDBIterator* account_db_txt_iterator(AccountDB* self);
|
||||
static void account_db_txt_iter_destroy(AccountDBIterator* self);
|
||||
static bool account_db_txt_iter_next(AccountDBIterator* self, struct mmo_account* acc);
|
||||
|
||||
static bool mmo_auth_fromstr(struct mmo_account* acc, char* str, unsigned int version);
|
||||
static bool mmo_auth_tostr(const struct mmo_account* acc, char* str);
|
||||
static void mmo_auth_sync(AccountDB_TXT* self);
|
||||
static int mmo_auth_sync_timer(int tid, unsigned int tick, int id, intptr_t data);
|
||||
|
||||
/// public constructor
|
||||
AccountDB* account_db_txt(void)
|
||||
{
|
||||
AccountDB_TXT* db = (AccountDB_TXT*)aCalloc(1, sizeof(AccountDB_TXT));
|
||||
|
||||
// set up the vtable
|
||||
db->vtable.init = &account_db_txt_init;
|
||||
db->vtable.destroy = &account_db_txt_destroy;
|
||||
db->vtable.get_property = &account_db_txt_get_property;
|
||||
db->vtable.set_property = &account_db_txt_set_property;
|
||||
db->vtable.save = &account_db_txt_save;
|
||||
db->vtable.create = &account_db_txt_create;
|
||||
db->vtable.remove = &account_db_txt_remove;
|
||||
db->vtable.load_num = &account_db_txt_load_num;
|
||||
db->vtable.load_str = &account_db_txt_load_str;
|
||||
db->vtable.iterator = &account_db_txt_iterator;
|
||||
|
||||
// initialize to default values
|
||||
db->accounts = NULL;
|
||||
db->next_account_id = START_ACCOUNT_NUM;
|
||||
db->auths_before_save = AUTHS_BEFORE_SAVE;
|
||||
db->save_timer = INVALID_TIMER;
|
||||
safestrncpy(db->account_db, "save/account.txt", sizeof(db->account_db));
|
||||
db->case_sensitive = false;
|
||||
|
||||
return &db->vtable;
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/// opens accounts file, loads it, and starts a periodic saving timer
|
||||
static bool account_db_txt_init(AccountDB* self)
|
||||
{
|
||||
AccountDB_TXT* db = (AccountDB_TXT*)self;
|
||||
DBMap* accounts;
|
||||
FILE* fp;
|
||||
char line[2048];
|
||||
unsigned int version = 0;
|
||||
|
||||
// create accounts database
|
||||
db->accounts = idb_alloc(DB_OPT_RELEASE_DATA);
|
||||
accounts = db->accounts;
|
||||
|
||||
// open data file
|
||||
fp = fopen(db->account_db, "r");
|
||||
if( fp == NULL )
|
||||
{
|
||||
// no account file -> no account -> no login, including char-server (ERROR)
|
||||
ShowError(CL_RED"account_db_txt_init: Accounts file [%s] not found."CL_RESET"\n", db->account_db);
|
||||
return false;
|
||||
}
|
||||
|
||||
// load data file
|
||||
while( fgets(line, sizeof(line), fp) != NULL )
|
||||
{
|
||||
int account_id, n;
|
||||
unsigned int v;
|
||||
struct mmo_account acc;
|
||||
struct mmo_account* tmp;
|
||||
struct DBIterator* iter;
|
||||
int (*compare)(const char* str1, const char* str2) = ( db->case_sensitive ) ? strcmp : stricmp;
|
||||
|
||||
if( line[0] == '/' && line[1] == '/' )
|
||||
continue;
|
||||
|
||||
n = 0;
|
||||
if( sscanf(line, "%d%n", &v, &n) == 1 && (line[n] == '\n' || line[n] == '\r') )
|
||||
{// format version definition
|
||||
version = v;
|
||||
continue;
|
||||
}
|
||||
|
||||
n = 0;
|
||||
if( sscanf(line, "%d\t%%newid%%%n", &account_id, &n) == 1 && (line[n] == '\n' || line[n] == '\r') )
|
||||
{// auto-increment
|
||||
if( account_id > db->next_account_id )
|
||||
db->next_account_id = account_id;
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !mmo_auth_fromstr(&acc, line, version) )
|
||||
{
|
||||
ShowError("account_db_txt_init: skipping invalid data: %s", line);
|
||||
continue;
|
||||
}
|
||||
|
||||
// apply constraints & checks here
|
||||
if( acc.sex != 'S' && (acc.account_id < START_ACCOUNT_NUM || acc.account_id > END_ACCOUNT_NUM) )
|
||||
ShowWarning("account_db_txt_init: account %d:'%s' has ID outside of the defined range for accounts (min:%d max:%d)!\n", acc.account_id, acc.userid, START_ACCOUNT_NUM, END_ACCOUNT_NUM);
|
||||
|
||||
iter = accounts->iterator(accounts);
|
||||
for( tmp = (struct mmo_account*)iter->first(iter,NULL); iter->exists(iter); tmp = (struct mmo_account*)iter->next(iter,NULL) )
|
||||
if( compare(acc.userid, tmp->userid) == 0 )
|
||||
break;
|
||||
iter->destroy(iter);
|
||||
|
||||
if( tmp != NULL )
|
||||
{// entry with identical username
|
||||
ShowWarning("account_db_txt_init: account %d:'%s' has same username as account %d. The account will be inaccessible!\n", acc.account_id, acc.userid, tmp->account_id);
|
||||
}
|
||||
|
||||
if( idb_get(accounts, acc.account_id) != NULL )
|
||||
{// account id already occupied
|
||||
ShowError("account_db_txt_init: ID collision for account id %d! Discarding data for account '%s'...\n", acc.account_id, acc.userid);
|
||||
continue;
|
||||
}
|
||||
|
||||
// record entry in db
|
||||
tmp = (struct mmo_account*)aMalloc(sizeof(struct mmo_account));
|
||||
memcpy(tmp, &acc, sizeof(struct mmo_account));
|
||||
idb_put(accounts, acc.account_id, tmp);
|
||||
|
||||
if( acc.account_id >= db->next_account_id )
|
||||
db->next_account_id = acc.account_id + 1;
|
||||
}
|
||||
|
||||
// close data file
|
||||
fclose(fp);
|
||||
|
||||
// initialize data saving timer
|
||||
add_timer_func_list(mmo_auth_sync_timer, "mmo_auth_sync_timer");
|
||||
db->save_timer = add_timer_interval(gettick() + AUTH_SAVING_INTERVAL, mmo_auth_sync_timer, 0, (intptr_t)db, AUTH_SAVING_INTERVAL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// flush accounts db, close savefile and deallocate structures
|
||||
static void account_db_txt_destroy(AccountDB* self)
|
||||
{
|
||||
AccountDB_TXT* db = (AccountDB_TXT*)self;
|
||||
DBMap* accounts = db->accounts;
|
||||
|
||||
// stop saving timer
|
||||
delete_timer(db->save_timer, mmo_auth_sync_timer);
|
||||
|
||||
// write data
|
||||
mmo_auth_sync(db);
|
||||
|
||||
// delete accounts database
|
||||
accounts->destroy(accounts, NULL);
|
||||
db->accounts = NULL;
|
||||
|
||||
// delete entire structure
|
||||
aFree(db);
|
||||
}
|
||||
|
||||
/// Gets a property from this database.
|
||||
static bool account_db_txt_get_property(AccountDB* self, const char* key, char* buf, size_t buflen)
|
||||
{
|
||||
AccountDB_TXT* db = (AccountDB_TXT*)self;
|
||||
const char* signature = "account.txt.";
|
||||
|
||||
if( strcmp(key, "engine.name") == 0 )
|
||||
{
|
||||
safesnprintf(buf, buflen, "txt");
|
||||
return true;
|
||||
}
|
||||
if( strcmp(key, "engine.version") == 0 )
|
||||
{
|
||||
safesnprintf(buf, buflen, "%d", ACCOUNT_TXT_DB_VERSION);
|
||||
return true;
|
||||
}
|
||||
if( strcmp(key, "engine.comment") == 0 )
|
||||
{
|
||||
safesnprintf(buf, buflen, "TXT Account Database %d", ACCOUNT_TXT_DB_VERSION);
|
||||
return true;
|
||||
}
|
||||
|
||||
if( strncmp(key, signature, strlen(signature)) != 0 )
|
||||
return false;
|
||||
|
||||
key += strlen(signature);
|
||||
|
||||
if( strcmpi(key, "account_db") == 0 )
|
||||
safesnprintf(buf, buflen, "%s", db->account_db);
|
||||
else if( strcmpi(key, "case_sensitive") == 0 )
|
||||
safesnprintf(buf, buflen, "%d", (db->case_sensitive ? 1 : 0));
|
||||
else
|
||||
return false;// not found
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Sets a property in this database.
|
||||
static bool account_db_txt_set_property(AccountDB* self, const char* key, const char* value)
|
||||
{
|
||||
AccountDB_TXT* db = (AccountDB_TXT*)self;
|
||||
const char* signature = "account.txt.";
|
||||
|
||||
if( strncmp(key, signature, strlen(signature)) != 0 )
|
||||
return false;
|
||||
|
||||
key += strlen(signature);
|
||||
|
||||
if( strcmpi(key, "account_db") == 0 )
|
||||
safestrncpy(db->account_db, value, sizeof(db->account_db));
|
||||
else if( strcmpi(key, "case_sensitive") == 0 )
|
||||
db->case_sensitive = config_switch(value);
|
||||
else // no match
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Add a new entry for this account to the account db and save it.
|
||||
/// If acc->account_id is -1, the account id will be auto-generated,
|
||||
/// and its value will be written to acc->account_id if everything succeeds.
|
||||
static bool account_db_txt_create(AccountDB* self, struct mmo_account* acc)
|
||||
{
|
||||
AccountDB_TXT* db = (AccountDB_TXT*)self;
|
||||
DBMap* accounts = db->accounts;
|
||||
struct mmo_account* tmp;
|
||||
|
||||
// decide on the account id to assign
|
||||
int account_id = ( acc->account_id != -1 ) ? acc->account_id : db->next_account_id;
|
||||
|
||||
// absolute maximum
|
||||
if( account_id > END_ACCOUNT_NUM )
|
||||
return false;
|
||||
|
||||
// check if the account_id is free
|
||||
tmp = (struct mmo_account*)idb_get(accounts, account_id);
|
||||
if( tmp != NULL )
|
||||
{// error condition - entry already present
|
||||
ShowError("account_db_txt_create: cannot create account %d:'%s', this id is already occupied by %d:'%s'!\n", account_id, acc->userid, account_id, tmp->userid);
|
||||
return false;
|
||||
}
|
||||
|
||||
// copy the data and store it in the db
|
||||
CREATE(tmp, struct mmo_account, 1);
|
||||
memcpy(tmp, acc, sizeof(struct mmo_account));
|
||||
tmp->account_id = account_id;
|
||||
idb_put(accounts, account_id, tmp);
|
||||
|
||||
// increment the auto_increment value
|
||||
if( account_id >= db->next_account_id )
|
||||
db->next_account_id = account_id + 1;
|
||||
|
||||
// flush data
|
||||
mmo_auth_sync(db);
|
||||
|
||||
// write output
|
||||
acc->account_id = account_id;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// find an existing entry for this account id and delete it
|
||||
static bool account_db_txt_remove(AccountDB* self, const int account_id)
|
||||
{
|
||||
AccountDB_TXT* db = (AccountDB_TXT*)self;
|
||||
DBMap* accounts = db->accounts;
|
||||
|
||||
//TODO: find out if this really works
|
||||
struct mmo_account* tmp = (struct mmo_account*)idb_remove(accounts, account_id);
|
||||
if( tmp == NULL )
|
||||
{// error condition - entry not present
|
||||
ShowError("account_db_txt_remove: no such account with id %d\n", account_id);
|
||||
return false;
|
||||
}
|
||||
|
||||
// flush data
|
||||
mmo_auth_sync(db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// rewrite the data stored in the account_db with the one provided
|
||||
static bool account_db_txt_save(AccountDB* self, const struct mmo_account* acc)
|
||||
{
|
||||
AccountDB_TXT* db = (AccountDB_TXT*)self;
|
||||
DBMap* accounts = db->accounts;
|
||||
int account_id = acc->account_id;
|
||||
|
||||
// retrieve previous data
|
||||
struct mmo_account* tmp = (struct mmo_account*)idb_get(accounts, account_id);
|
||||
if( tmp == NULL )
|
||||
{// error condition - entry not found
|
||||
return false;
|
||||
}
|
||||
|
||||
// overwrite with new data
|
||||
memcpy(tmp, acc, sizeof(struct mmo_account));
|
||||
|
||||
// modify save counter and save if needed
|
||||
if( --db->auths_before_save == 0 )
|
||||
mmo_auth_sync(db);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// retrieve data from db and store it in the provided data structure
|
||||
static bool account_db_txt_load_num(AccountDB* self, struct mmo_account* acc, const int account_id)
|
||||
{
|
||||
AccountDB_TXT* db = (AccountDB_TXT*)self;
|
||||
DBMap* accounts = db->accounts;
|
||||
|
||||
// retrieve data
|
||||
struct mmo_account* tmp = (struct mmo_account*)idb_get(accounts, account_id);
|
||||
if( tmp == NULL )
|
||||
{// entry not found
|
||||
return false;
|
||||
}
|
||||
|
||||
// store it
|
||||
memcpy(acc, tmp, sizeof(struct mmo_account));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// retrieve data from db and store it in the provided data structure
|
||||
static bool account_db_txt_load_str(AccountDB* self, struct mmo_account* acc, const char* userid)
|
||||
{
|
||||
AccountDB_TXT* db = (AccountDB_TXT*)self;
|
||||
DBMap* accounts = db->accounts;
|
||||
|
||||
// retrieve data
|
||||
struct DBIterator* iter = accounts->iterator(accounts);
|
||||
struct mmo_account* tmp;
|
||||
int (*compare)(const char* str1, const char* str2) = ( db->case_sensitive ) ? strcmp : stricmp;
|
||||
|
||||
for( tmp = (struct mmo_account*)iter->first(iter,NULL); iter->exists(iter); tmp = (struct mmo_account*)iter->next(iter,NULL) )
|
||||
if( compare(userid, tmp->userid) == 0 )
|
||||
break;
|
||||
iter->destroy(iter);
|
||||
|
||||
if( tmp == NULL )
|
||||
{// entry not found
|
||||
return false;
|
||||
}
|
||||
|
||||
// store it
|
||||
memcpy(acc, tmp, sizeof(struct mmo_account));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// Returns a new forward iterator.
|
||||
static AccountDBIterator* account_db_txt_iterator(AccountDB* self)
|
||||
{
|
||||
AccountDB_TXT* db = (AccountDB_TXT*)self;
|
||||
DBMap* accounts = db->accounts;
|
||||
AccountDBIterator_TXT* iter = (AccountDBIterator_TXT*)aCalloc(1, sizeof(AccountDBIterator_TXT));
|
||||
|
||||
// set up the vtable
|
||||
iter->vtable.destroy = &account_db_txt_iter_destroy;
|
||||
iter->vtable.next = &account_db_txt_iter_next;
|
||||
|
||||
// fill data
|
||||
iter->iter = db_iterator(accounts);
|
||||
|
||||
return &iter->vtable;
|
||||
}
|
||||
|
||||
|
||||
/// Destroys this iterator, releasing all allocated memory (including itself).
|
||||
static void account_db_txt_iter_destroy(AccountDBIterator* self)
|
||||
{
|
||||
AccountDBIterator_TXT* iter = (AccountDBIterator_TXT*)self;
|
||||
dbi_destroy(iter->iter);
|
||||
aFree(iter);
|
||||
}
|
||||
|
||||
|
||||
/// Fetches the next account in the database.
|
||||
static bool account_db_txt_iter_next(AccountDBIterator* self, struct mmo_account* acc)
|
||||
{
|
||||
AccountDBIterator_TXT* iter = (AccountDBIterator_TXT*)self;
|
||||
struct mmo_account* tmp = (struct mmo_account*)dbi_next(iter->iter);
|
||||
if( dbi_exists(iter->iter) )
|
||||
{
|
||||
memcpy(acc, tmp, sizeof(struct mmo_account));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// parse input string into the provided account data structure
|
||||
static bool mmo_auth_fromstr(struct mmo_account* a, char* str, unsigned int version)
|
||||
{
|
||||
char* fields[32];
|
||||
int count;
|
||||
char* regs;
|
||||
int i, n;
|
||||
|
||||
// zero out the destination first
|
||||
memset(a, 0x00, sizeof(struct mmo_account));
|
||||
|
||||
// defaults for older format versions
|
||||
safestrncpy(a->birthdate, "0000-00-00", sizeof(a->birthdate));
|
||||
|
||||
// extract tab-separated columns from line
|
||||
count = sv_split(str, strlen(str), 0, '\t', fields, ARRAYLENGTH(fields), (e_svopt)(SV_TERMINATE_LF|SV_TERMINATE_CRLF));
|
||||
|
||||
if( version == ACCOUNT_TXT_DB_VERSION && count == 14 )
|
||||
{
|
||||
a->account_id = strtol(fields[1], NULL, 10);
|
||||
safestrncpy(a->userid, fields[2], sizeof(a->userid));
|
||||
safestrncpy(a->pass, fields[3], sizeof(a->pass));
|
||||
a->sex = fields[4][0];
|
||||
safestrncpy(a->email, fields[5], sizeof(a->email));
|
||||
a->level = strtoul(fields[6], NULL, 10);
|
||||
a->state = strtoul(fields[7], NULL, 10);
|
||||
a->unban_time = strtol(fields[8], NULL, 10);
|
||||
a->expiration_time = strtol(fields[9], NULL, 10);
|
||||
a->logincount = strtoul(fields[10], NULL, 10);
|
||||
safestrncpy(a->lastlogin, fields[11], sizeof(a->lastlogin));
|
||||
safestrncpy(a->last_ip, fields[12], sizeof(a->last_ip));
|
||||
safestrncpy(a->birthdate, fields[13], sizeof(a->birthdate));
|
||||
regs = fields[14];
|
||||
}
|
||||
else
|
||||
if( version == 20080409 && count == 13 )
|
||||
{
|
||||
a->account_id = strtol(fields[1], NULL, 10);
|
||||
safestrncpy(a->userid, fields[2], sizeof(a->userid));
|
||||
safestrncpy(a->pass, fields[3], sizeof(a->pass));
|
||||
a->sex = fields[4][0];
|
||||
safestrncpy(a->email, fields[5], sizeof(a->email));
|
||||
a->level = strtoul(fields[6], NULL, 10);
|
||||
a->state = strtoul(fields[7], NULL, 10);
|
||||
a->unban_time = strtol(fields[8], NULL, 10);
|
||||
a->expiration_time = strtol(fields[9], NULL, 10);
|
||||
a->logincount = strtoul(fields[10], NULL, 10);
|
||||
safestrncpy(a->lastlogin, fields[11], sizeof(a->lastlogin));
|
||||
safestrncpy(a->last_ip, fields[12], sizeof(a->last_ip));
|
||||
regs = fields[13];
|
||||
}
|
||||
else
|
||||
if( version == 0 && count == 14 )
|
||||
{
|
||||
a->account_id = strtol(fields[1], NULL, 10);
|
||||
safestrncpy(a->userid, fields[2], sizeof(a->userid));
|
||||
safestrncpy(a->pass, fields[3], sizeof(a->pass));
|
||||
safestrncpy(a->lastlogin, fields[4], sizeof(a->lastlogin));
|
||||
a->sex = fields[5][0];
|
||||
a->logincount = strtoul(fields[6], NULL, 10);
|
||||
a->state = strtoul(fields[7], NULL, 10);
|
||||
safestrncpy(a->email, fields[8], sizeof(a->email));
|
||||
//safestrncpy(a->error_message, fields[9], sizeof(a->error_message));
|
||||
a->expiration_time = strtol(fields[10], NULL, 10);
|
||||
safestrncpy(a->last_ip, fields[11], sizeof(a->last_ip));
|
||||
//safestrncpy(a->memo, fields[12], sizeof(a->memo));
|
||||
a->unban_time = strtol(fields[13], NULL, 10);
|
||||
regs = fields[14];
|
||||
}
|
||||
else
|
||||
if( version == 0 && count == 13 )
|
||||
{
|
||||
a->account_id = strtol(fields[1], NULL, 10);
|
||||
safestrncpy(a->userid, fields[2], sizeof(a->userid));
|
||||
safestrncpy(a->pass, fields[3], sizeof(a->pass));
|
||||
safestrncpy(a->lastlogin, fields[4], sizeof(a->lastlogin));
|
||||
a->sex = fields[5][0];
|
||||
a->logincount = strtoul(fields[6], NULL, 10);
|
||||
a->state = strtoul(fields[7], NULL, 10);
|
||||
safestrncpy(a->email, fields[8], sizeof(a->email));
|
||||
//safestrncpy(a->error_message, fields[9], sizeof(a->error_message));
|
||||
a->expiration_time = strtol(fields[10], NULL, 10);
|
||||
safestrncpy(a->last_ip, fields[11], sizeof(a->last_ip));
|
||||
//safestrncpy(a->memo, fields[12], sizeof(a->memo));
|
||||
regs = fields[13];
|
||||
}
|
||||
else
|
||||
if( version == 0 && count == 8 )
|
||||
{
|
||||
a->account_id = strtol(fields[1], NULL, 10);
|
||||
safestrncpy(a->userid, fields[2], sizeof(a->userid));
|
||||
safestrncpy(a->pass, fields[3], sizeof(a->pass));
|
||||
safestrncpy(a->lastlogin, fields[4], sizeof(a->lastlogin));
|
||||
a->sex = fields[5][0];
|
||||
a->logincount = strtoul(fields[6], NULL, 10);
|
||||
a->state = strtoul(fields[7], NULL, 10);
|
||||
regs = fields[8];
|
||||
}
|
||||
else
|
||||
{// unmatched row
|
||||
return false;
|
||||
}
|
||||
|
||||
// extract account regs
|
||||
// {reg name<COMMA>reg value<SPACE>}*
|
||||
n = 0;
|
||||
for( i = 0; i < ACCOUNT_REG2_NUM; ++i )
|
||||
{
|
||||
char key[32];
|
||||
char value[256];
|
||||
|
||||
regs += n;
|
||||
|
||||
if (sscanf(regs, "%31[^\t,],%255[^\t ] %n", key, value, &n) != 2)
|
||||
{
|
||||
// We must check if a str is void. If it's, we can continue to read other REG2.
|
||||
// Account line will have something like: str2,9 ,9 str3,1 (here, ,9 is not good)
|
||||
if (regs[0] == ',' && sscanf(regs, ",%[^\t ] %n", value, &n) == 1) {
|
||||
i--;
|
||||
continue;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
safestrncpy(a->account_reg2[i].str, key, 32);
|
||||
safestrncpy(a->account_reg2[i].value, value, 256);
|
||||
}
|
||||
a->account_reg2_num = i;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// dump the contents of the account data structure into the provided string buffer
|
||||
static bool mmo_auth_tostr(const struct mmo_account* a, char* str)
|
||||
{
|
||||
int i;
|
||||
char* str_p = str;
|
||||
|
||||
str_p += sprintf(str_p, "%d\t%s\t%s\t%c\t%s\t%u\t%u\t%ld\t%ld\t%u\t%s\t%s\t%s\t",
|
||||
a->account_id, a->userid, a->pass, a->sex, a->email, a->level,
|
||||
a->state, (long)a->unban_time, (long)a->expiration_time,
|
||||
a->logincount, a->lastlogin, a->last_ip, a->birthdate);
|
||||
|
||||
for( i = 0; i < a->account_reg2_num; ++i )
|
||||
if( a->account_reg2[i].str[0] )
|
||||
str_p += sprintf(str_p, "%s,%s ", a->account_reg2[i].str, a->account_reg2[i].value);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// dump the entire account db to disk
|
||||
static void mmo_auth_sync(AccountDB_TXT* db)
|
||||
{
|
||||
int lock;
|
||||
FILE *fp;
|
||||
struct DBIterator* iter;
|
||||
struct mmo_account* acc;
|
||||
|
||||
fp = lock_fopen(db->account_db, &lock);
|
||||
if( fp == NULL )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(fp, "%d\n", ACCOUNT_TXT_DB_VERSION); // savefile version
|
||||
|
||||
fprintf(fp, "// Accounts file: here are saved all information about the accounts.\n");
|
||||
fprintf(fp, "// Structure: account ID, username, password, sex, email, level, state, unban time, expiration time, # of logins, last login time, last (accepted) login ip, birth date, repeated(register key, register value)\n");
|
||||
fprintf(fp, "// where:\n");
|
||||
fprintf(fp, "// sex : M or F for normal accounts, S for server accounts\n");
|
||||
fprintf(fp, "// level : this account's gm level\n");
|
||||
fprintf(fp, "// state : 0: account is ok, 1 to 256: error code of packet 0x006a + 1\n");
|
||||
fprintf(fp, "// unban time : 0: no ban, <other value>: banned until the date (unix timestamp)\n");
|
||||
fprintf(fp, "// expiration time : 0: unlimited account, <other value>: account expires on the date (unix timestamp)\n");
|
||||
|
||||
//TODO: sort?
|
||||
|
||||
iter = db->accounts->iterator(db->accounts);
|
||||
for( acc = (struct mmo_account*)iter->first(iter,NULL); iter->exists(iter); acc = (struct mmo_account*)iter->next(iter,NULL) )
|
||||
{
|
||||
char buf[2048]; // ought to be big enough ^^
|
||||
mmo_auth_tostr(acc, buf);
|
||||
fprintf(fp, "%s\n", buf);
|
||||
}
|
||||
fprintf(fp, "%d\t%%newid%%\n", db->next_account_id);
|
||||
iter->destroy(iter);
|
||||
|
||||
lock_fclose(fp, db->account_db, &lock);
|
||||
|
||||
// reset save counter
|
||||
db->auths_before_save = AUTHS_BEFORE_SAVE;
|
||||
}
|
||||
|
||||
static int mmo_auth_sync_timer(int tid, unsigned int tick, int id, intptr_t data)
|
||||
{
|
||||
AccountDB_TXT* db = (AccountDB_TXT*)data;
|
||||
|
||||
if( db->auths_before_save < AUTHS_BEFORE_SAVE )
|
||||
mmo_auth_sync(db); // db was modified, flush it
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/cbasetypes.h"
|
||||
#include "../common/strlib.h"
|
||||
#include "login.h"
|
||||
#include "ipban.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void ipban_init(void)
|
||||
{
|
||||
}
|
||||
|
||||
void ipban_final(void)
|
||||
{
|
||||
}
|
||||
|
||||
bool ipban_check(uint32 ip)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void ipban_log(uint32 ip)
|
||||
{
|
||||
}
|
||||
|
||||
bool ipban_config_read(const char* key, const char* value)
|
||||
{
|
||||
// login server settings
|
||||
if( strcmpi(key, "ipban.enable") == 0 )
|
||||
login_config.ipban = (bool)config_switch(value);
|
||||
else
|
||||
if( strcmpi(key, "ipban.dynamic_pass_failure_ban") == 0 )
|
||||
login_config.dynamic_pass_failure_ban = (bool)config_switch(value);
|
||||
else
|
||||
if( strcmpi(key, "ipban.dynamic_pass_failure_ban_interval") == 0 )
|
||||
login_config.dynamic_pass_failure_ban_interval = atoi(value);
|
||||
else
|
||||
if( strcmpi(key, "ipban.dynamic_pass_failure_ban_limit") == 0 )
|
||||
login_config.dynamic_pass_failure_ban_limit = atoi(value);
|
||||
else
|
||||
if( strcmpi(key, "ipban.dynamic_pass_failure_ban_duration") == 0 )
|
||||
login_config.dynamic_pass_failure_ban_duration = atoi(value);
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -30,12 +30,7 @@ static struct{
|
||||
AccountDB* (*constructor)(void);
|
||||
AccountDB* db;
|
||||
} account_engines[] = {
|
||||
#ifdef WITH_TXT
|
||||
{account_db_txt, NULL},
|
||||
#endif
|
||||
#ifdef WITH_SQL
|
||||
{account_db_sql, NULL},
|
||||
#endif
|
||||
#ifdef ACCOUNTDB_ENGINE_0
|
||||
{ACCOUNTDB_CONSTRUCTOR(ACCOUNTDB_ENGINE_0), NULL},
|
||||
#endif
|
||||
|
@ -1,81 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/cbasetypes.h"
|
||||
#include "../common/mmo.h"
|
||||
#include "../common/core.h"
|
||||
#include "../common/malloc.h"
|
||||
#include "../common/socket.h"
|
||||
#include "../common/strlib.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "account.h"
|
||||
#include "login.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char login_log_filename[1024] = "log/login.log";
|
||||
|
||||
|
||||
// Returns the number of failed login attemps by the ip in the last minutes.
|
||||
unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes)
|
||||
{
|
||||
// XXX not implemented
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*=============================================
|
||||
* Records an event in the login log
|
||||
*---------------------------------------------*/
|
||||
void login_log(uint32 ip, const char* username, int rcode, const char* message)
|
||||
{
|
||||
FILE* log_fp;
|
||||
|
||||
if( !login_config.log_login )
|
||||
return;
|
||||
|
||||
log_fp = fopen(login_log_filename, "a");
|
||||
if( log_fp != NULL )
|
||||
{
|
||||
char esc_username[NAME_LENGTH*4+1];
|
||||
char esc_message[255*4+1];
|
||||
time_t raw_time;
|
||||
char str_time[24];
|
||||
|
||||
sv_escape_c(esc_username, username, safestrnlen(username,NAME_LENGTH), NULL);
|
||||
sv_escape_c(esc_message, message, safestrnlen(message,255), NULL);
|
||||
|
||||
time(&raw_time);
|
||||
strftime(str_time, 24, login_config.date_format, localtime(&raw_time));
|
||||
str_time[23] = '\0';
|
||||
|
||||
fprintf(log_fp, "%s\t%s\t%s\t%d\t%s\n", str_time, ip2str(ip,NULL), esc_username, rcode, esc_message);
|
||||
|
||||
fclose(log_fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool loginlog_config_read(const char* w1, const char* w2)
|
||||
{
|
||||
if(!strcmpi(w1, "login_log_filename"))
|
||||
safestrncpy(login_log_filename, w2, sizeof(login_log_filename));
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool loginlog_init(void)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool loginlog_final(void)
|
||||
{
|
||||
return true;
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
|
||||
#
|
||||
# login txt
|
||||
#
|
||||
if( BUILD_TXT_SERVERS )
|
||||
message( STATUS "Creating target login-server" )
|
||||
set( TXT_LOGIN_HEADERS
|
||||
"${TXT_LOGIN_SOURCE_DIR}/account.h"
|
||||
"${TXT_LOGIN_SOURCE_DIR}/ipban.h"
|
||||
"${TXT_LOGIN_SOURCE_DIR}/login.h"
|
||||
"${TXT_LOGIN_SOURCE_DIR}/loginlog.h"
|
||||
)
|
||||
set( TXT_LOGIN_SOURCES
|
||||
"${TXT_LOGIN_SOURCE_DIR}/account_txt.c"
|
||||
"${TXT_LOGIN_SOURCE_DIR}/ipban_txt.c"
|
||||
"${TXT_LOGIN_SOURCE_DIR}/login.c"
|
||||
"${TXT_LOGIN_SOURCE_DIR}/loginlog_txt.c"
|
||||
)
|
||||
set( DEPENDENCIES common_base )
|
||||
set( LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${GLOBAL_DEFINITIONS} -DWITH_TXT" )
|
||||
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${TXT_LOGIN_HEADERS} ${TXT_LOGIN_SOURCES} )
|
||||
source_group( common FILES ${COMMON_BASE_HEADERS} )
|
||||
source_group( login FILES ${TXT_LOGIN_HEADERS} ${TXT_LOGIN_SOURCES} )
|
||||
include_directories( ${INCLUDE_DIRS} )
|
||||
add_executable( login-server ${SOURCE_FILES} )
|
||||
add_dependencies( login-server ${DEPENDENCIES} )
|
||||
target_link_libraries( login-server ${LIBRARIES} ${DEPENDENCIES} )
|
||||
set_target_properties( login-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
cpack_add_component( Runtime_loginserver_txt DESCRIPTION "login-server (txt version)" DISPLAY_NAME "login-server" GROUP Runtime )
|
||||
install( TARGETS login-server
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_loginserver_txt )
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
set( TARGET_LIST ${TARGET_LIST} login-server CACHE INTERNAL "" )
|
||||
message( STATUS "Creating target login-server - done" )
|
||||
endif( BUILD_TXT_SERVERS )
|
@ -3,12 +3,10 @@
|
||||
# setup
|
||||
#
|
||||
set( MAP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
set( TXT_MAP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
set( SQL_MAP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
|
||||
|
||||
#
|
||||
# targets
|
||||
#
|
||||
add_subdirectory( txt )
|
||||
add_subdirectory( sql )
|
||||
|
@ -25,8 +25,6 @@ MAP_OBJ = map.o chrif.o clif.o pc.o status.o npc.o \
|
||||
intif.o trade.o party.o vending.o guild.o pet.o \
|
||||
log.o mail.o date.o unit.o homunculus.o mercenary.o quest.o instance.o \
|
||||
buyingstore.o searchstore.o duel.o
|
||||
MAP_TXT_OBJ = $(MAP_OBJ:%=obj_txt/%) \
|
||||
obj_txt/mapreg_txt.o
|
||||
MAP_SQL_OBJ = $(MAP_OBJ:%=obj_sql/%) \
|
||||
obj_sql/mapreg_sql.o
|
||||
MAP_H = map.h chrif.h clif.h pc.h status.h npc.h \
|
||||
@ -95,22 +93,18 @@ obj_sql:
|
||||
-mkdir obj_sql
|
||||
|
||||
# executables
|
||||
map-server: obj_txt $(MAP_TXT_OBJ) $(COMMON_OBJ)
|
||||
@CC@ @LDFLAGS@ -o ../../map-server@EXEEXT@ $(MAP_TXT_OBJ) $(COMMON_OBJ) $(MT19937AR_OBJ) @LIBS@ @PCRE_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) $(MT19937AR_OBJ) @LIBS@ @PCRE_LIBS@ @MYSQL_LIBS@
|
||||
|
||||
# map object files
|
||||
obj_txt/%.o: %.c $(MAP_H) $(COMMON_H) $(MT19937AR_H)
|
||||
@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(PCRE_CFLAGS) -DTXT_ONLY @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
|
||||
|
||||
obj_sql/%.o: %.c $(MAP_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H)
|
||||
@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(PCRE_CFLAGS) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
|
||||
|
||||
# missing object files
|
||||
../common/obj_all/%.o:
|
||||
@$(MAKE) -C ../common txt
|
||||
@$(MAKE) -C ../common sql
|
||||
|
||||
../common/obj_sql/%.o:
|
||||
@$(MAKE) -C ../common sql
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "npc.h"
|
||||
#include "pet.h"
|
||||
#include "homunculus.h"
|
||||
#include "mail.h"
|
||||
#include "mercenary.h"
|
||||
#include "party.h"
|
||||
#include "guild.h"
|
||||
@ -38,9 +39,6 @@
|
||||
#include "trade.h"
|
||||
#include "unit.h"
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
#include "mail.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -4333,9 +4331,7 @@ ACMD_FUNC(reloadbattleconf)
|
||||
)
|
||||
{ // Exp or Drop rates changed.
|
||||
mob_reload(); //Needed as well so rate changes take effect.
|
||||
#ifndef TXT_ONLY
|
||||
chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
|
||||
#endif
|
||||
}
|
||||
clif_displaymessage(fd, msg_txt(255));
|
||||
return 0;
|
||||
@ -7112,9 +7108,7 @@ ACMD_FUNC(misceffect)
|
||||
ACMD_FUNC(mail)
|
||||
{
|
||||
nullpo_ret(sd);
|
||||
#ifndef TXT_ONLY
|
||||
mail_openmail(sd);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -8434,9 +8428,7 @@ ACMD_FUNC(auction)
|
||||
{
|
||||
nullpo_ret(sd);
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
clif_Auction_openwindow(sd);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -225,11 +225,7 @@ void chrif_checkdefaultlogin(void)
|
||||
{
|
||||
if (strcmp(userid, "s1")==0 && strcmp(passwd, "p1")==0) {
|
||||
ShowError("Using the default user/password s1/p1 is NOT RECOMMENDED.\n");
|
||||
#ifdef TXT_ONLY
|
||||
ShowNotice("Please edit your save/account.txt file to create a proper inter-server user/password (gender 'S')\n");
|
||||
#else
|
||||
ShowNotice("Please edit your 'login' table to create a proper inter-server user/password (gender 'S')\n");
|
||||
#endif
|
||||
ShowNotice("and then edit your user/password in conf/map_athena.conf (or conf/import/map_conf.txt)\n");
|
||||
}
|
||||
}
|
||||
@ -312,10 +308,8 @@ int chrif_save(struct map_session_data *sd, int flag)
|
||||
merc_save(sd->hd);
|
||||
if( sd->md && mercenary_get_lifetime(sd->md) > 0 )
|
||||
mercenary_save(sd->md);
|
||||
#ifndef TXT_ONLY
|
||||
if( sd->save_quest )
|
||||
intif_quest_save(sd);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1536,16 +1530,12 @@ static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_
|
||||
|
||||
chrif_connect(char_fd);
|
||||
chrif_connected = (chrif_state == 2);
|
||||
#ifndef TXT_ONLY
|
||||
srvinfo = 0;
|
||||
#endif /* not TXT_ONLY */
|
||||
} else {
|
||||
#ifndef TXT_ONLY
|
||||
if (srvinfo == 0) {
|
||||
chrif_ragsrvinfo(battle_config.base_exp_rate, battle_config.job_exp_rate, battle_config.item_rate_common);
|
||||
srvinfo = 1;
|
||||
}
|
||||
#endif /* not TXT_ONLY */
|
||||
}
|
||||
if (chrif_isconnected()) displayed = 0;
|
||||
return 0;
|
||||
@ -1555,7 +1545,7 @@ static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_
|
||||
* Asks char server to remove friend_id from the friend list of char_id
|
||||
*------------------------------------------*/
|
||||
int chrif_removefriend(int char_id, int friend_id) {
|
||||
#ifndef TXT_ONLY
|
||||
|
||||
chrif_check(-1);
|
||||
|
||||
WFIFOHEAD(char_fd,10);
|
||||
@ -1563,7 +1553,7 @@ int chrif_removefriend(int char_id, int friend_id) {
|
||||
WFIFOL(char_fd,2) = char_id;
|
||||
WFIFOL(char_fd,6) = friend_id;
|
||||
WFIFOSET(char_fd,10);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -8137,9 +8137,7 @@ void clif_refresh(struct map_session_data *sd)
|
||||
// unlike vending, resuming buyingstore crashes the client.
|
||||
buyingstore_close(sd);
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
mail_clear(sd);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -9205,9 +9203,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd)
|
||||
sd->state.changemap = false;
|
||||
}
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
mail_clear(sd);
|
||||
#endif
|
||||
|
||||
if(map[sd->bl.m].flag.loadevent) // Lance
|
||||
npc_script_event(sd, NPCE_LOADMAP);
|
||||
@ -13425,7 +13421,6 @@ void clif_parse_Check(int fd, struct map_session_data *sd)
|
||||
}
|
||||
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
|
||||
/// MAIL SYSTEM
|
||||
/// By Zephyrus
|
||||
@ -14205,8 +14200,6 @@ void clif_parse_Auction_buysell(int fd, struct map_session_data* sd)
|
||||
intif_Auction_requestlist(sd->status.char_id, type, 0, "", 1);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/// CASH/POINT SHOP
|
||||
///
|
||||
@ -16515,7 +16508,6 @@ static int packetdb_readdb(void)
|
||||
{clif_parse_Check,"check"},
|
||||
{clif_parse_Adopt_request,"adoptrequest"},
|
||||
{clif_parse_Adopt_reply,"adoptreply"},
|
||||
#ifndef TXT_ONLY
|
||||
// MAIL SYSTEM
|
||||
{clif_parse_Mail_refreshinbox,"mailrefresh"},
|
||||
{clif_parse_Mail_read,"mailread"},
|
||||
@ -16536,7 +16528,6 @@ static int packetdb_readdb(void)
|
||||
{clif_parse_Auction_bid,"auctionbid"},
|
||||
// Quest Log System
|
||||
{clif_parse_questStateAck,"queststate"},
|
||||
#endif
|
||||
{clif_parse_cashshop_buy,"cashshopbuy"},
|
||||
{clif_parse_ViewPlayerEquip,"viewplayerequip"},
|
||||
{clif_parse_EquipTick,"equiptickbox"},
|
||||
|
@ -641,7 +641,6 @@ void clif_displayexp(struct map_session_data *sd, unsigned int exp, char type, b
|
||||
int clif_send(const uint8* buf, int len, struct block_list* bl, enum send_target type);
|
||||
int do_init_clif(void);
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
// MAIL SYSTEM
|
||||
void clif_Mail_window(int fd, int flag);
|
||||
void clif_Mail_read(struct map_session_data *sd, int mail_id);
|
||||
@ -657,7 +656,6 @@ void clif_Auction_results(struct map_session_data *sd, short count, short pages,
|
||||
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);
|
||||
#endif
|
||||
|
||||
void clif_bossmapinfo(int fd, struct mob_data *md, short flag);
|
||||
void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd);
|
||||
|
@ -1412,8 +1412,6 @@ int intif_quest_save(TBL_PC *sd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
|
||||
/*==========================================
|
||||
* MAIL SYSTEM
|
||||
* By Zephyrus
|
||||
@ -1888,8 +1886,6 @@ static void intif_parse_Auction_message(int fd)
|
||||
clif_Auction_message(sd->fd, result);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*==========================================
|
||||
* Mercenary's System
|
||||
*------------------------------------------*/
|
||||
@ -2049,7 +2045,6 @@ int intif_parse(int fd)
|
||||
case 0x3860: intif_parse_questlog(fd); break;
|
||||
case 0x3861: intif_parse_questsave(fd); break;
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
// Mail System
|
||||
case 0x3848: intif_parse_Mail_inboxreceived(fd); break;
|
||||
case 0x3849: intif_parse_Mail_new(fd); break;
|
||||
@ -2064,7 +2059,7 @@ int intif_parse(int fd)
|
||||
case 0x3853: intif_parse_Auction_close(fd); break;
|
||||
case 0x3854: intif_parse_Auction_message(fd); break;
|
||||
case 0x3855: intif_parse_Auction_bid(fd); break;
|
||||
#endif
|
||||
|
||||
// Mercenary System
|
||||
case 0x3870: intif_parse_mercenary_received(fd); break;
|
||||
case 0x3871: intif_parse_mercenary_deleted(fd); break;
|
||||
|
@ -83,7 +83,6 @@ int intif_mercenary_request(int merc_id, int char_id);
|
||||
int intif_mercenary_delete(int merc_id);
|
||||
int intif_mercenary_save(struct s_mercenary *merc);
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
// MAIL SYSTEM
|
||||
int intif_Mail_requestinbox(int char_id, unsigned char flag);
|
||||
int intif_Mail_read(int mail_id);
|
||||
@ -97,7 +96,6 @@ int intif_Auction_register(struct auction_data *auction);
|
||||
int intif_Auction_cancel(int char_id, unsigned int auction_id);
|
||||
int intif_Auction_close(int char_id, unsigned int auction_id);
|
||||
int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, int bid);
|
||||
#endif
|
||||
|
||||
int CheckForCharServer(void);
|
||||
|
||||
|
@ -984,7 +984,6 @@ static int itemdb_readdb(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
/*======================================
|
||||
* item_db table reading
|
||||
*======================================*/
|
||||
@ -1034,18 +1033,15 @@ static int itemdb_read_sqldb(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* not TXT_ONLY */
|
||||
|
||||
/*====================================
|
||||
* read all item-related databases
|
||||
*------------------------------------*/
|
||||
static void itemdb_read(void)
|
||||
{
|
||||
#ifndef TXT_ONLY
|
||||
if (db_use_sqldbs)
|
||||
itemdb_read_sqldb();
|
||||
else
|
||||
#endif
|
||||
itemdb_readdb();
|
||||
|
||||
itemdb_read_itemgroup();
|
||||
|
@ -136,7 +136,6 @@ void log_branch(struct map_session_data* sd)
|
||||
if( !log_config.branch )
|
||||
return;
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
if( log_config.sql_logs )
|
||||
{
|
||||
SqlStmt* stmt;
|
||||
@ -152,7 +151,6 @@ void log_branch(struct map_session_data* sd)
|
||||
SqlStmt_Free(stmt);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
char timestring[255];
|
||||
time_t curtime;
|
||||
@ -179,7 +177,6 @@ void log_pick(int id, int m, e_log_pick_type type, int amount, struct item* itm)
|
||||
if( !should_log_item(itm->nameid, amount, itm->refine) )
|
||||
return; //we skip logging this item set - it doesn't meet our logging conditions [Lupus]
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
if( log_config.sql_logs )
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `type`, `nameid`, `amount`, `refine`, `card0`, `card1`, `card2`, `card3`, `map`) VALUES (NOW(), '%d', '%c', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%s')",
|
||||
@ -190,7 +187,6 @@ void log_pick(int id, int m, e_log_pick_type type, int amount, struct item* itm)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
char timestring[255];
|
||||
time_t curtime;
|
||||
@ -228,7 +224,6 @@ void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_sess
|
||||
if( !log_config.zeny || ( log_config.zeny != 1 && abs(amount) < log_config.zeny ) )
|
||||
return;
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
if( log_config.sql_logs )
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`time`, `char_id`, `src_id`, `type`, `amount`, `map`) VALUES (NOW(), '%d', '%d', '%c', '%d', '%s')",
|
||||
@ -239,7 +234,6 @@ void log_zeny(struct map_session_data* sd, e_log_pick_type type, struct map_sess
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
char timestring[255];
|
||||
time_t curtime;
|
||||
@ -263,7 +257,6 @@ void log_mvpdrop(struct map_session_data* sd, int monster_id, int* log_mvp)
|
||||
if( !log_config.mvpdrop )
|
||||
return;
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
if( log_config.sql_logs )
|
||||
{
|
||||
if( SQL_ERROR == Sql_Query(logmysql_handle, LOG_QUERY " INTO `%s` (`mvp_date`, `kill_char_id`, `monster_id`, `prize`, `mvpexp`, `map`) VALUES (NOW(), '%d', '%d', '%d', '%d', '%s') ",
|
||||
@ -274,7 +267,6 @@ void log_mvpdrop(struct map_session_data* sd, int monster_id, int* log_mvp)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
char timestring[255];
|
||||
time_t curtime;
|
||||
@ -298,7 +290,6 @@ void log_atcommand(struct map_session_data* sd, int cmdlvl, const char* message)
|
||||
if( cmdlvl < log_config.gm )
|
||||
return;
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
if( log_config.sql_logs )
|
||||
{
|
||||
SqlStmt* stmt;
|
||||
@ -316,7 +307,6 @@ void log_atcommand(struct map_session_data* sd, int cmdlvl, const char* message)
|
||||
SqlStmt_Free(stmt);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
char timestring[255];
|
||||
time_t curtime;
|
||||
@ -340,7 +330,6 @@ void log_npc(struct map_session_data* sd, const char* message)
|
||||
if( !log_config.npc )
|
||||
return;
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
if( log_config.sql_logs )
|
||||
{
|
||||
SqlStmt* stmt;
|
||||
@ -357,7 +346,6 @@ void log_npc(struct map_session_data* sd, const char* message)
|
||||
SqlStmt_Free(stmt);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
char timestring[255];
|
||||
time_t curtime;
|
||||
@ -386,7 +374,6 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid,
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
if( log_config.sql_logs )
|
||||
{
|
||||
SqlStmt* stmt;
|
||||
@ -404,7 +391,6 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid,
|
||||
SqlStmt_Free(stmt);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
char timestring[255];
|
||||
time_t curtime;
|
||||
@ -457,16 +443,7 @@ int log_config_read(const char* cfgName)
|
||||
if( strcmpi(w1, "enable_logs") == 0 )
|
||||
log_config.enable_logs = (e_log_pick_type)config_switch(w2);
|
||||
else if( strcmpi(w1, "sql_logs") == 0 )
|
||||
{
|
||||
log_config.sql_logs = (bool)config_switch(w2);
|
||||
#ifdef TXT_ONLY
|
||||
if( log_config.sql_logs )
|
||||
{
|
||||
ShowWarning("log_config_read: SQL logging is not supported on this server.\n");
|
||||
log_config.sql_logs = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
//start of common filter settings
|
||||
else if( strcmpi(w1, "rare_items_log") == 0 )
|
||||
log_config.rare_items_log = atoi(w2);
|
||||
|
@ -1,8 +1,6 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
|
||||
#include "../common/nullpo.h"
|
||||
#include "../common/showmsg.h"
|
||||
|
||||
@ -194,5 +192,3 @@ bool mail_invalid_operation(struct map_session_data *sd)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -44,9 +44,7 @@
|
||||
#include "mercenary.h"
|
||||
#include "atcommand.h"
|
||||
#include "log.h"
|
||||
#ifndef TXT_ONLY
|
||||
#include "mail.h"
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -56,7 +54,6 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
char default_codepage[32] = "";
|
||||
|
||||
int map_server_port = 3306;
|
||||
@ -83,8 +80,6 @@ char log_db_pw[32] = "ragnarok";
|
||||
char log_db_db[32] = "log";
|
||||
Sql* logmysql_handle;
|
||||
|
||||
#endif /* not TXT_ONLY */
|
||||
|
||||
// This param using for sending mainchat
|
||||
// messages like whispers to this nick. [LuzZza]
|
||||
char main_chat_nick[16] = "Main";
|
||||
@ -3240,8 +3235,6 @@ int inter_config_read(char *cfgName)
|
||||
|
||||
if(strcmpi(w1, "main_chat_nick")==0)
|
||||
safestrncpy(main_chat_nick, w2, sizeof(main_chat_nick));
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
else
|
||||
if(strcmpi(w1,"item_db_db")==0)
|
||||
strcpy(item_db_db,w2);
|
||||
@ -3295,7 +3288,6 @@ int inter_config_read(char *cfgName)
|
||||
else
|
||||
if(strcmpi(w1,"log_db_db")==0)
|
||||
strcpy(log_db_db, w2);
|
||||
#endif
|
||||
else
|
||||
if( mapreg_config_read(w1,w2) )
|
||||
continue;
|
||||
@ -3309,7 +3301,6 @@ int inter_config_read(char *cfgName)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
/*=======================================
|
||||
* MySQL Init
|
||||
*---------------------------------------*/
|
||||
@ -3363,8 +3354,6 @@ int log_sql_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* not TXT_ONLY */
|
||||
|
||||
int map_db_final(DBKey k,void *d,va_list ap)
|
||||
{
|
||||
struct map_data_other_server *mdos = (struct map_data_other_server*)d;
|
||||
@ -3498,9 +3487,8 @@ void do_final(void)
|
||||
iwall_db->destroy(iwall_db, NULL);
|
||||
regen_db->destroy(regen_db, NULL);
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
map_sql_close();
|
||||
#endif /* not TXT_ONLY */
|
||||
|
||||
ShowStatus("Finished.\n");
|
||||
}
|
||||
|
||||
@ -3762,11 +3750,9 @@ int do_init(int argc, char *argv[])
|
||||
|
||||
iwall_db = strdb_alloc(DB_OPT_RELEASE_DATA,2*NAME_LENGTH+2+1); // [Zephyrus] Invisible Walls
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
map_sql_init();
|
||||
if (log_config.sql_logs)
|
||||
log_sql_init();
|
||||
#endif /* not TXT_ONLY */
|
||||
|
||||
mapindex_init();
|
||||
if(enable_grf)
|
||||
|
@ -709,8 +709,6 @@ typedef struct mercenary_data TBL_MER;
|
||||
|
||||
extern char main_chat_nick[16];
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
|
||||
#include "../common/sql.h"
|
||||
|
||||
extern int db_use_sqldbs;
|
||||
@ -726,8 +724,6 @@ extern char mob_db2_db[32];
|
||||
extern char mob_skill_db_db[32];
|
||||
extern char mob_skill_db2_db[32];
|
||||
|
||||
#endif /* not TXT_ONLY */
|
||||
|
||||
void do_shutdown(void);
|
||||
|
||||
#endif /* _MAP_H_ */
|
||||
|
@ -1,202 +0,0 @@
|
||||
// Copyright (c) Athena Dev Teams - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/cbasetypes.h"
|
||||
#include "../common/db.h"
|
||||
#include "../common/lock.h"
|
||||
#include "../common/malloc.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/strlib.h"
|
||||
#include "../common/timer.h"
|
||||
#include "script.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static DBMap* mapreg_db = NULL; // int var_id -> int value
|
||||
static DBMap* mapregstr_db = NULL; // int var_id -> char* value
|
||||
|
||||
static char mapreg_txt[256] = "save/mapreg.txt";
|
||||
static bool mapreg_dirty = false;
|
||||
#define MAPREG_AUTOSAVE_INTERVAL (300*1000)
|
||||
|
||||
|
||||
/// Looks up the value of an integer variable using its uid.
|
||||
int mapreg_readreg(int uid)
|
||||
{
|
||||
return (int)idb_get(mapreg_db, uid);
|
||||
}
|
||||
|
||||
/// Looks up the value of a string variable using its uid.
|
||||
char* mapreg_readregstr(int uid)
|
||||
{
|
||||
return (char*)idb_get(mapregstr_db, uid);
|
||||
}
|
||||
|
||||
/// Modifies the value of an integer variable.
|
||||
bool mapreg_setreg(int uid, int val)
|
||||
{
|
||||
if( val != 0 )
|
||||
idb_put(mapreg_db,uid,(void*)val);
|
||||
else
|
||||
idb_remove(mapreg_db,uid);
|
||||
|
||||
mapreg_dirty = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Modifies the value of a string variable.
|
||||
bool mapreg_setregstr(int uid, const char* str)
|
||||
{
|
||||
if( str == NULL || *str == 0 )
|
||||
idb_remove(mapregstr_db,uid);
|
||||
else
|
||||
idb_put(mapregstr_db,uid,aStrdup(str));
|
||||
|
||||
mapreg_dirty = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Loads permanent variables from savefile
|
||||
static void script_load_mapreg(void)
|
||||
{
|
||||
FILE* fp;
|
||||
char line[1024];
|
||||
|
||||
fp = fopen(mapreg_txt,"rt");
|
||||
if( fp == NULL )
|
||||
return;
|
||||
|
||||
while( fgets(line,sizeof(line),fp) )
|
||||
{
|
||||
char varname[32+1];
|
||||
char value[255+1];
|
||||
int n,s,i;
|
||||
|
||||
// read name and index
|
||||
if( sscanf(line, "%32[^,],%d\t%n", varname,&i,&n) != 2 &&
|
||||
(i = 0, sscanf(line,"%[^\t]\t%n", varname,&n) != 1) )
|
||||
continue;
|
||||
|
||||
// read value
|
||||
if( sscanf(line + n, "%[^\n\r]", value) != 1 )
|
||||
{
|
||||
ShowError("%s: %s broken data !\n", mapreg_txt, varname);
|
||||
continue;
|
||||
}
|
||||
|
||||
s = add_str(varname);
|
||||
if( varname[strlen(varname)-1] == '$' )
|
||||
idb_put(mapregstr_db, (i<<24)|s, aStrdup(value));
|
||||
else
|
||||
idb_put(mapreg_db, (i<<24)|s, (void*)atoi(value));
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
mapreg_dirty = false;
|
||||
}
|
||||
|
||||
/// Saves permanent variables to savefile
|
||||
static void script_save_mapreg(void)
|
||||
{
|
||||
FILE *fp;
|
||||
int lock;
|
||||
DBIterator* iter;
|
||||
void* data;
|
||||
DBKey key;
|
||||
|
||||
fp = lock_fopen(mapreg_txt,&lock);
|
||||
if( fp == NULL )
|
||||
{
|
||||
ShowError("script_save_mapreg: Unable to lock-open file [%s]!\n", mapreg_txt);
|
||||
return;
|
||||
}
|
||||
|
||||
iter = mapreg_db->iterator(mapreg_db);
|
||||
for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) )
|
||||
{
|
||||
int num = (key.i & 0x00ffffff);
|
||||
int i = (key.i & 0xff000000) >> 24;
|
||||
const char* name = get_str(num);
|
||||
|
||||
if( name[1] == '@' )
|
||||
continue;
|
||||
|
||||
if( i == 0 )
|
||||
fprintf(fp, "%s\t%d\n", name, (int)data);
|
||||
else
|
||||
fprintf(fp, "%s,%d\t%d\n", name, i, (int)data);
|
||||
}
|
||||
iter->destroy(iter);
|
||||
|
||||
iter = mapregstr_db->iterator(mapregstr_db);
|
||||
for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) )
|
||||
{
|
||||
int num = (key.i & 0x00ffffff);
|
||||
int i = (key.i & 0xff000000) >> 24;
|
||||
const char* name = get_str(num);
|
||||
|
||||
if( name[1] == '@' )
|
||||
continue;
|
||||
|
||||
if( i == 0 )
|
||||
fprintf(fp, "%s\t%s\n", name, (char *)data);
|
||||
else
|
||||
fprintf(fp, "%s,%d\t%s\n", name, i, (char *)data);
|
||||
}
|
||||
iter->destroy(iter);
|
||||
|
||||
lock_fclose(fp,mapreg_txt,&lock);
|
||||
|
||||
mapreg_dirty = false;
|
||||
}
|
||||
|
||||
static int script_autosave_mapreg(int tid, unsigned int tick, int id, intptr_t data)
|
||||
{
|
||||
if( mapreg_dirty )
|
||||
script_save_mapreg();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void mapreg_reload(void)
|
||||
{
|
||||
if( mapreg_dirty )
|
||||
script_save_mapreg();
|
||||
|
||||
mapreg_db->clear(mapreg_db, NULL);
|
||||
mapregstr_db->clear(mapregstr_db, NULL);
|
||||
|
||||
script_load_mapreg();
|
||||
}
|
||||
|
||||
void mapreg_final(void)
|
||||
{
|
||||
if( mapreg_dirty )
|
||||
script_save_mapreg();
|
||||
|
||||
mapreg_db->destroy(mapreg_db,NULL);
|
||||
mapregstr_db->destroy(mapregstr_db,NULL);
|
||||
}
|
||||
|
||||
void mapreg_init(void)
|
||||
{
|
||||
mapreg_db = idb_alloc(DB_OPT_BASE);
|
||||
mapregstr_db = idb_alloc(DB_OPT_RELEASE_DATA);
|
||||
|
||||
script_load_mapreg();
|
||||
|
||||
add_timer_func_list(script_autosave_mapreg, "script_autosave_mapreg");
|
||||
add_timer_interval(gettick() + MAPREG_AUTOSAVE_INTERVAL, script_autosave_mapreg, 0, 0, MAPREG_AUTOSAVE_INTERVAL);
|
||||
}
|
||||
|
||||
bool mapreg_config_read(const char* w1, const char* w2)
|
||||
{
|
||||
if(!strcmpi(w1, "mapreg_txt"))
|
||||
safestrncpy(mapreg_txt, w2, sizeof(mapreg_txt));
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
@ -3719,7 +3719,6 @@ static void mob_readdb(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
/*==========================================
|
||||
* mob_db table reading
|
||||
*------------------------------------------*/
|
||||
@ -3774,7 +3773,6 @@ static int mob_read_sqldb(void)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* not TXT_ONLY */
|
||||
|
||||
/*==========================================
|
||||
* MOB display graphic change data reading
|
||||
@ -4301,7 +4299,6 @@ static void mob_readskilldb(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
/**
|
||||
* mob_skill_db table reading [CalciumKid]
|
||||
* not overly sure if this is all correct
|
||||
@ -4358,7 +4355,6 @@ static int mob_read_sqlskilldb(void)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* not TXT_ONLY */
|
||||
|
||||
/*==========================================
|
||||
* mob_race2_db.txt reading
|
||||
@ -4393,14 +4389,12 @@ static bool mob_readdb_race2(char* fields[], int columns, int current)
|
||||
*/
|
||||
static void mob_load(void)
|
||||
{
|
||||
#ifndef TXT_ONLY
|
||||
if (db_use_sqldbs)
|
||||
{
|
||||
mob_read_sqldb();
|
||||
mob_read_sqlskilldb();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
mob_readdb();
|
||||
mob_readskilldb();
|
||||
|
10
src/map/pc.c
10
src/map/pc.c
@ -1188,10 +1188,8 @@ int pc_reg_received(struct map_session_data *sd)
|
||||
status_calc_pc(sd,1);
|
||||
chrif_scdata_request(sd->status.account_id, sd->status.char_id);
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
intif_Mail_requestinbox(sd->status.char_id, 0); // MAIL SYSTEM - Request Mail Inbox
|
||||
intif_request_questlog(sd);
|
||||
#endif
|
||||
|
||||
if (sd->state.connect_new == 0 && sd->fd)
|
||||
{ //Character already loaded map! Gotta trigger LoadEndAck manually.
|
||||
@ -1199,9 +1197,8 @@ int pc_reg_received(struct map_session_data *sd)
|
||||
clif_parse_LoadEndAck(sd->fd, sd);
|
||||
}
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
pc_inventory_rentals(sd);
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -7962,15 +7959,10 @@ int pc_divorce(struct map_session_data *sd)
|
||||
|
||||
if( (p_sd = map_charid2sd(sd->status.partner_id)) == NULL )
|
||||
{ // Lets char server do the divorce
|
||||
#ifndef TXT_ONLY
|
||||
if( chrif_divorce(sd->status.char_id, sd->status.partner_id) )
|
||||
return -1; // No char server connected
|
||||
|
||||
return 0;
|
||||
#else
|
||||
ShowError("pc_divorce: p_sd nullpo\n");
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Both players online, lets do the divorce manually
|
||||
|
@ -13543,7 +13543,6 @@ BUILDIN_FUNC(setd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
int buildin_query_sql_sub(struct script_state* st, Sql* handle)
|
||||
{
|
||||
int i, j;
|
||||
@ -13643,22 +13642,14 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle)
|
||||
script_pushint(st, i);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
BUILDIN_FUNC(query_sql)
|
||||
{
|
||||
#ifndef TXT_ONLY
|
||||
return buildin_query_sql_sub(st, mmysql_handle);
|
||||
#else
|
||||
//for TXT version, we always return -1
|
||||
script_pushint(st,-1);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
BUILDIN_FUNC(query_logsql)
|
||||
{
|
||||
#ifndef TXT_ONLY
|
||||
if( !log_config.sql_logs )
|
||||
{// logmysql_handle == NULL
|
||||
ShowWarning("buildin_query_logsql: SQL logs are disabled, query '%s' will not be executed.\n", script_getstr(st,2));
|
||||
@ -13667,11 +13658,6 @@ BUILDIN_FUNC(query_logsql)
|
||||
}
|
||||
|
||||
return buildin_query_sql_sub(st, logmysql_handle);
|
||||
#else
|
||||
//for TXT version, we always return -1
|
||||
script_pushint(st,-1);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
//Allows escaping of a given string.
|
||||
@ -13684,11 +13670,7 @@ BUILDIN_FUNC(escape_sql)
|
||||
str = script_getstr(st,2);
|
||||
len = strlen(str);
|
||||
esc_str = (char*)aMallocA(len*2+1);
|
||||
#if defined(TXT_ONLY)
|
||||
jstrescapecpy(esc_str, str);
|
||||
#else
|
||||
Sql_EscapeStringLen(mmysql_handle, esc_str, str, len);
|
||||
#endif
|
||||
script_pushstr(st, esc_str);
|
||||
return 0;
|
||||
}
|
||||
@ -14709,9 +14691,8 @@ BUILDIN_FUNC(openmail)
|
||||
if( sd == NULL )
|
||||
return 0;
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
mail_openmail(sd);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -14723,9 +14704,8 @@ BUILDIN_FUNC(openauction)
|
||||
if( sd == NULL )
|
||||
return 0;
|
||||
|
||||
#ifndef TXT_ONLY
|
||||
clif_Auction_openwindow(sd);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -14778,7 +14758,6 @@ BUILDIN_FUNC(setcell)
|
||||
*------------------------------------------*/
|
||||
BUILDIN_FUNC(mercenary_create)
|
||||
{
|
||||
#ifndef TXT_ONLY
|
||||
struct map_session_data *sd;
|
||||
int class_, contract_time;
|
||||
|
||||
@ -14792,7 +14771,6 @@ BUILDIN_FUNC(mercenary_create)
|
||||
|
||||
contract_time = script_getnum(st,3);
|
||||
merc_create(sd, class_, contract_time);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,108 +0,0 @@
|
||||
|
||||
#
|
||||
# map txt
|
||||
#
|
||||
if( BUILD_TXT_SERVERS )
|
||||
message( STATUS "Creating target map-server" )
|
||||
set( TXT_MAP_HEADERS
|
||||
"${TXT_MAP_SOURCE_DIR}/atcommand.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/battle.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/battleground.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/buyingstore.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/chat.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/chrif.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/clif.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/date.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/duel.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/guild.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/homunculus.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/instance.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/intif.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/itemdb.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/log.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/mail.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/map.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/mapreg.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/mercenary.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/mob.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/npc.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/party.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/path.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/pc.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/pet.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/quest.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/script.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/searchstore.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/skill.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/status.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/storage.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/trade.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/unit.h"
|
||||
"${TXT_MAP_SOURCE_DIR}/vending.h"
|
||||
)
|
||||
set( TXT_MAP_SOURCES
|
||||
"${TXT_MAP_SOURCE_DIR}/atcommand.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/battle.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/battleground.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/buyingstore.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/chat.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/chrif.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/clif.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/date.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/duel.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/guild.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/homunculus.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/instance.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/intif.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/itemdb.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/log.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/mail.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/map.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/mapreg_txt.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/mercenary.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/mob.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/npc.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/npc_chat.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/party.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/path.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/pc.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/pet.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/quest.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/script.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/searchstore.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/skill.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/status.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/storage.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/trade.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/unit.c"
|
||||
"${TXT_MAP_SOURCE_DIR}/vending.c"
|
||||
)
|
||||
set( DEPENDENCIES common_base )
|
||||
set( LIBRARIES ${GLOBAL_LIBRARIES} )
|
||||
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${GLOBAL_DEFINITIONS} -DTXT_ONLY" )
|
||||
if( WITH_PCRE )
|
||||
message( STATUS "Enabled PCRE code" )
|
||||
set( LIBRARIES ${LIBRARIES} ${PCRE_LIBRARIES} )
|
||||
set( INCLUDE_DIRS ${INCLUDE_DIRS} ${PCRE_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${DEFINITIONS} -DPCRE_SUPPORT" )
|
||||
else()
|
||||
message( STATUS "Disabled PCRE code" )
|
||||
endif()
|
||||
set( SOURCE_FILES ${COMMON_BASE_HEADERS} ${TXT_MAP_HEADERS} ${TXT_MAP_SOURCES} )
|
||||
source_group( common FILES ${COMMON_BASE_HEADERS} )
|
||||
source_group( map FILES ${TXT_MAP_HEADERS} ${TXT_MAP_SOURCES} )
|
||||
include_directories( ${INCLUDE_DIRS} )
|
||||
add_executable( map-server ${SOURCE_FILES} )
|
||||
add_dependencies( map-server ${DEPENDENCIES} )
|
||||
target_link_libraries( map-server ${LIBRARIES} ${DEPENDENCIES} )
|
||||
set_target_properties( map-server PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
cpack_add_component( Runtime_mapserver_txt DESCRIPTION "map-server (txt version)" DISPLAY_NAME "map-server" GROUP Runtime )
|
||||
install( TARGETS map-server
|
||||
DESTINATION "."
|
||||
COMPONENT Runtime_mapserver_txt )
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
set( TARGET_LIST ${TARGET_LIST} map-server CACHE INTERNAL "" )
|
||||
message( STATUS "Creating target map-server - done" )
|
||||
endif( BUILD_TXT_SERVERS )
|
@ -1,17 +0,0 @@
|
||||
|
||||
#
|
||||
# setup
|
||||
#
|
||||
set( CONVERTER_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "" )
|
||||
if( WITH_MYSQL )
|
||||
option( BUILD_CONVERTERS "build converter executables" OFF )
|
||||
else()
|
||||
message( STATUS "Disabled converter targets (requires MYSQL)" )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
# targets
|
||||
#
|
||||
add_subdirectory( login )
|
||||
add_subdirectory( char )
|
@ -1,150 +0,0 @@
|
||||
LOGIN_CONVERTER_OBJ = \
|
||||
obj_login/login-converter.o \
|
||||
../login/obj_txt/account_txt.o \
|
||||
../login/obj_sql/account_sql.o \
|
||||
../common/obj_all/minicore.o \
|
||||
../common/obj_all/db.o \
|
||||
../common/obj_all/ers.o \
|
||||
../common/obj_all/lock.o \
|
||||
../common/obj_all/malloc.o \
|
||||
../common/obj_all/showmsg.o \
|
||||
../common/obj_all/strlib.o \
|
||||
../common/obj_all/timer.o \
|
||||
../common/obj_all/utils.o \
|
||||
../common/obj_sql/sql.o
|
||||
LOGIN_CONVERTER_H = \
|
||||
../login/account.h \
|
||||
../common/cbasetypes.h \
|
||||
../common/mmo.h \
|
||||
../common/core.h \
|
||||
../common/db.h \
|
||||
../common/ers.h \
|
||||
../common/lock.h \
|
||||
../common/malloc.h \
|
||||
../common/showmsg.h \
|
||||
../common/strlib.h \
|
||||
../common/timer.h \
|
||||
../common/utils.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 \
|
||||
obj_char/sql-int_mercenary.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/timer.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 \
|
||||
../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 \
|
||||
../char_sql/int_mercenary.h \
|
||||
../common/cbasetypes.h \
|
||||
../common/mmo.h \
|
||||
../common/core.h \
|
||||
../common/malloc.h \
|
||||
../common/strlib.h \
|
||||
../common/showmsg.h \
|
||||
../common/timer.h \
|
||||
../common/utils.h \
|
||||
../common/ers.h \
|
||||
../common/mapindex.h \
|
||||
../common/sql.h
|
||||
|
||||
HAVE_MYSQL=@HAVE_MYSQL@
|
||||
ifeq ($(HAVE_MYSQL),yes)
|
||||
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
|
||||
|
||||
all: login-converter char-converter
|
||||
|
||||
login-converter: $(LOGIN_CONVERTER_DEPENDS)
|
||||
@CC@ @LDFLAGS@ -o ../../tools/login-converter@EXEEXT@ $(LOGIN_CONVERTER_OBJ) @LIBS@ @MYSQL_LIBS@
|
||||
|
||||
char-converter: $(CHAR_CONVERTER_DEPENDS)
|
||||
@CC@ @LDFLAGS@ -o ../../tools/char-converter@EXEEXT@ $(CHAR_CONVERTER_OBJ) @LIBS@ @MYSQL_LIBS@
|
||||
|
||||
clean:
|
||||
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'"
|
||||
@echo "'login-converter' - login server converter"
|
||||
@echo "'char-converter' - char server converter"
|
||||
@echo "'all' - builds all above targets"
|
||||
@echo "'clean' - cleans builds and objects"
|
||||
@echo "'help' - outputs this message"
|
||||
|
||||
#####################################################################
|
||||
|
||||
needs_mysql:
|
||||
@echo "MySQL not found or disabled by the configure script"
|
||||
@exit 1
|
||||
|
||||
obj_login:
|
||||
-mkdir obj_login
|
||||
|
||||
obj_char:
|
||||
-mkdir obj_char
|
||||
|
||||
obj_login/%.o: %.c $(LOGIN_CONVERTER_H)
|
||||
@CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DWITH_TXT -DWITH_SQL -c $(OUTPUT_OPTION) $<
|
||||
|
||||
obj_char/%.o: %.c $(CHAR_CONVERTER_H)
|
||||
@CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $<
|
||||
|
||||
obj_char/txt-%.o: ../char/%.c $(CHAR_CONVERTER_H)
|
||||
@CC@ @CFLAGS@ @MYSQL_CFLAGS@ @CPPFLAGS@ -DTXT_SQL_CONVERT -c $(OUTPUT_OPTION) $<
|
||||
|
||||
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_all/%.o:
|
||||
@$(MAKE) -C ../common sql
|
||||
|
||||
../common/obj_sql/%.o:
|
||||
@$(MAKE) -C ../common sql
|
||||
|
||||
# missing login server files
|
||||
../login/obj_txt/%.o:
|
||||
@$(MAKE) -C ../login txt
|
||||
|
||||
../login/obj_sql/%.o:
|
||||
@$(MAKE) -C ../login sql
|
@ -1,303 +0,0 @@
|
||||
// (c) eAthena Dev Team - Licensed under GNU GPL
|
||||
// For more information, see LICENCE in the main folder
|
||||
|
||||
#include "../common/cbasetypes.h"
|
||||
#include "../common/mmo.h"
|
||||
#include "../common/core.h"
|
||||
#include "../common/strlib.h"
|
||||
#include "../common/showmsg.h"
|
||||
#include "../common/mapindex.h"
|
||||
#include "../common/utils.h"
|
||||
|
||||
#include "../char/char.h"
|
||||
#include "../char/int_storage.h"
|
||||
#include "../char/int_pet.h"
|
||||
#include "../char/int_party.h"
|
||||
#include "../char/int_guild.h"
|
||||
#include "../char/inter.h"
|
||||
|
||||
#include "../char_sql/char.h"
|
||||
#include "../char_sql/int_storage.h"
|
||||
#include "../char_sql/int_pet.h"
|
||||
#include "../char_sql/int_party.h"
|
||||
#include "../char_sql/int_guild.h"
|
||||
#include "../char_sql/inter.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define CHAR_CONF_NAME "conf/char_athena.conf"
|
||||
#define SQL_CONF_NAME "conf/inter_athena.conf"
|
||||
#define INTER_CONF_NAME "conf/inter_athena.conf"
|
||||
//--------------------------------------------------------
|
||||
|
||||
int convert_init(void)
|
||||
{
|
||||
char line[65536];
|
||||
int ret;
|
||||
int tmp_int[2], lineno, count;
|
||||
char input;
|
||||
FILE *fp;
|
||||
|
||||
ShowWarning("Make sure you backup your databases before continuing!\n");
|
||||
ShowMessage("\n");
|
||||
|
||||
ShowNotice("Do you wish to convert your Character Database to SQL? (y/n) : ");
|
||||
input = getchar();
|
||||
if(input == 'y' || input == 'Y')
|
||||
{
|
||||
struct character_data char_dat;
|
||||
struct accreg reg;
|
||||
|
||||
ShowStatus("Converting Character Database...\n");
|
||||
if( (fp = fopen(char_txt, "r")) == NULL )
|
||||
{
|
||||
ShowError("Unable to open file [%s]!\n", char_txt);
|
||||
return 0;
|
||||
}
|
||||
lineno = count = 0;
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
lineno++;
|
||||
memset(&char_dat, 0, sizeof(struct character_data));
|
||||
ret=mmo_char_fromstr(line, &char_dat.status, char_dat.global, &char_dat.global_num);
|
||||
if(ret > 0) {
|
||||
count++;
|
||||
parse_friend_txt(&char_dat.status); //Retrieve friends.
|
||||
mmo_char_tosql(char_dat.status.char_id , &char_dat.status);
|
||||
|
||||
memset(®, 0, sizeof(reg));
|
||||
reg.account_id = char_dat.status.account_id;
|
||||
reg.char_id = char_dat.status.char_id;
|
||||
reg.reg_num = char_dat.global_num;
|
||||
memcpy(®.reg, &char_dat.global, reg.reg_num*sizeof(struct global_reg));
|
||||
inter_accreg_tosql(reg.account_id, reg.char_id, ®, 3); //Type 3: Character regs
|
||||
} else {
|
||||
ShowError("Error %d converting character line [%s] (at %s:%d).\n", ret, line, char_txt, lineno);
|
||||
}
|
||||
}
|
||||
ShowStatus("Converted %d characters.\n", count);
|
||||
fclose(fp);
|
||||
ShowStatus("Converting Account variables Database...\n");
|
||||
if( (fp = fopen(accreg_txt, "r")) == NULL )
|
||||
{
|
||||
ShowError("Unable to open file %s!", accreg_txt);
|
||||
return 1;
|
||||
}
|
||||
lineno = count = 0;
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
lineno++;
|
||||
memset (®, 0, sizeof(struct accreg));
|
||||
if(inter_accreg_fromstr(line, ®) == 0 && reg.account_id > 0) {
|
||||
count++;
|
||||
inter_accreg_tosql(reg.account_id, 0, ®, 2); //Type 2: Account regs
|
||||
} else {
|
||||
ShowError("accreg reading: broken data [%s] at %s:%d\n", line, accreg_txt, lineno);
|
||||
}
|
||||
}
|
||||
ShowStatus("Converted %d account registries.\n", count);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
while(getchar() != '\n');
|
||||
ShowMessage("\n");
|
||||
ShowNotice("Do you wish to convert your Storage Database to SQL? (y/n) : ");
|
||||
input = getchar();
|
||||
if(input == 'y' || input == 'Y')
|
||||
{
|
||||
struct storage_data storage;
|
||||
ShowMessage("\n");
|
||||
ShowStatus("Converting Storage Database...\n");
|
||||
if( (fp = fopen(storage_txt,"r")) == NULL )
|
||||
{
|
||||
ShowError("can't read : %s\n", storage_txt);
|
||||
return 0;
|
||||
}
|
||||
lineno = count = 0;
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
int account_id;
|
||||
|
||||
lineno++;
|
||||
if( sscanf(line,"%d,%d",&tmp_int[0],&tmp_int[1]) != 2 )
|
||||
continue;
|
||||
|
||||
memset(&storage, 0, sizeof(struct storage_data));
|
||||
if( storage_fromstr(line,&account_id,&storage) )
|
||||
{
|
||||
count++;
|
||||
storage_tosql(account_id,&storage); //to sql. (dump)
|
||||
} else
|
||||
ShowError("Error parsing storage line [%s] (at %s:%d)\n", line, storage_txt, lineno);
|
||||
}
|
||||
ShowStatus("Converted %d storages.\n", count);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
//FIXME: CONVERT STATUS DATA HERE!!!
|
||||
|
||||
while(getchar() != '\n');
|
||||
ShowMessage("\n");
|
||||
ShowNotice("Do you wish to convert your Pet Database to SQL? (y/n) : ");
|
||||
input=getchar();
|
||||
if(input == 'y' || input == 'Y')
|
||||
{
|
||||
struct s_pet p;
|
||||
ShowMessage("\n");
|
||||
ShowStatus("Converting Pet Database...\n");
|
||||
if( (fp = fopen(pet_txt, "r")) == NULL )
|
||||
{
|
||||
ShowError("Unable to open file %s!", pet_txt);
|
||||
return 1;
|
||||
}
|
||||
lineno = count = 0;
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
lineno++;
|
||||
memset (&p, 0, sizeof(struct s_pet));
|
||||
if(inter_pet_fromstr(line, &p)==0 && p.pet_id>0) {
|
||||
count++;
|
||||
inter_pet_tosql(p.pet_id,&p);
|
||||
} else {
|
||||
ShowError("pet reading: broken data [%s] at %s:%d\n", line, pet_txt, lineno);
|
||||
}
|
||||
}
|
||||
ShowStatus("Converted %d pets.\n", count);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
//FIXME: CONVERT HOMUNCULUS DATA AND SKILLS HERE!!!
|
||||
|
||||
while(getchar() != '\n');
|
||||
ShowMessage("\n");
|
||||
ShowNotice("Do you wish to convert your Party Database to SQL? (y/n) : ");
|
||||
input=getchar();
|
||||
if(input == 'y' || input == 'Y')
|
||||
{
|
||||
struct party p;
|
||||
ShowMessage("\n");
|
||||
ShowStatus("Converting Party Database...\n");
|
||||
if( (fp = fopen(party_txt, "r")) == NULL )
|
||||
{
|
||||
ShowError("Unable to open file %s!", party_txt);
|
||||
return 1;
|
||||
}
|
||||
lineno = count = 0;
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
lineno++;
|
||||
memset (&p, 0, sizeof(struct party));
|
||||
if(inter_party_fromstr(line, &p) == 0 &&
|
||||
p.party_id > 0 &&
|
||||
inter_party_tosql(&p, PS_CREATE, 0))
|
||||
count++;
|
||||
else{
|
||||
ShowError("party reading: broken data [%s] at %s:%d\n", line, pet_txt, lineno);
|
||||
}
|
||||
}
|
||||
ShowStatus("Converted %d parties.\n", count);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
while(getchar() != '\n');
|
||||
ShowMessage("\n");
|
||||
ShowNotice("Do you wish to convert your Guilds and Castles Database to SQL? (y/n) : ");
|
||||
input=getchar();
|
||||
if(input == 'y' || input == 'Y')
|
||||
{
|
||||
struct guild g;
|
||||
struct guild_castle gc;
|
||||
ShowMessage("\n");
|
||||
ShowStatus("Converting Guild Database...\n");
|
||||
if( (fp = fopen(guild_txt, "r")) == NULL )
|
||||
{
|
||||
ShowError("Unable to open file %s!", guild_txt);
|
||||
return 1;
|
||||
}
|
||||
lineno = count = 0;
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
lineno++;
|
||||
memset (&g, 0, sizeof(struct guild));
|
||||
if (inter_guild_fromstr(line, &g) == 0 &&
|
||||
g.guild_id > 0 &&
|
||||
inter_guild_tosql(&g,GS_MASK))
|
||||
count++;
|
||||
else
|
||||
ShowError("guild reading: broken data [%s] at %s:%d\n", line, guild_txt, lineno);
|
||||
}
|
||||
ShowStatus("Converted %d guilds.\n", count);
|
||||
fclose(fp);
|
||||
ShowStatus("Converting Guild Castles Database...\n");
|
||||
if( (fp = fopen(castle_txt, "r")) == NULL )
|
||||
{
|
||||
ShowError("Unable to open file %s!", castle_txt);
|
||||
return 1;
|
||||
}
|
||||
lineno = count = 0;
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
lineno++;
|
||||
memset(&gc, 0, sizeof(struct guild_castle));
|
||||
if (inter_guildcastle_fromstr(line, &gc) == 0) {
|
||||
inter_guildcastle_tosql(&gc);
|
||||
count++;
|
||||
}
|
||||
else
|
||||
ShowError("guild castle reading: broken data [%s] at %s:%d\n", line, castle_txt, lineno);
|
||||
}
|
||||
ShowStatus("Converted %d guild castles.\n", count);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
while(getchar() != '\n');
|
||||
ShowMessage("\n");
|
||||
ShowNotice("Do you wish to convert your Guild Storage Database to SQL? (y/n) : ");
|
||||
input=getchar();
|
||||
if(input == 'y' || input == 'Y')
|
||||
{
|
||||
struct guild_storage storage_;
|
||||
ShowMessage("\n");
|
||||
ShowStatus("Converting Guild Storage Database...\n");
|
||||
if( (fp = fopen(guild_storage_txt, "r")) == NULL )
|
||||
{
|
||||
ShowError("can't read : %s\n", guild_storage_txt);
|
||||
return 0;
|
||||
}
|
||||
lineno = count = 0;
|
||||
while(fgets(line, sizeof(line), fp))
|
||||
{
|
||||
lineno++;
|
||||
memset(&storage_, 0, sizeof(struct guild_storage));
|
||||
if (sscanf(line,"%d",&storage_.guild_id) == 1 &&
|
||||
storage_.guild_id > 0 &&
|
||||
guild_storage_fromstr(line,&storage_) == 0
|
||||
) {
|
||||
count++;
|
||||
guild_storage_tosql(storage_.guild_id, &storage_);
|
||||
} else
|
||||
ShowError("Error parsing guild storage line [%s] (at %s:%d)\n", line, guild_storage_txt, lineno);
|
||||
}
|
||||
ShowStatus("Converted %d guild storages.\n", count);
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int do_init(int argc, char** argv)
|
||||
{
|
||||
char_config_read( (argc > 1) ? argv[1] : CHAR_CONF_NAME);
|
||||
mapindex_init();
|
||||
sql_config_read( (argc > 2) ? argv[2] : SQL_CONF_NAME);
|
||||
inter_init_txt( (argc > 3) ? argv[3] : INTER_CONF_NAME);
|
||||
inter_init_sql( (argc > 3) ? argv[3] : INTER_CONF_NAME);
|
||||
convert_init();
|
||||
ShowStatus("Everything's been converted!\n");
|
||||
mapindex_final();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void do_final(void) {}
|
@ -1,76 +0,0 @@
|
||||
|
||||
#
|
||||
# char-converter
|
||||
#
|
||||
if( BUILD_CONVERTERS )
|
||||
message( STATUS "Creating target char-converter" )
|
||||
set( COMMON_HEADERS
|
||||
${COMMON_MINI_HEADERS}
|
||||
"${COMMON_SOURCE_DIR}/mapindex.h"
|
||||
"${COMMON_SOURCE_DIR}/sql.h"
|
||||
"${COMMON_SOURCE_DIR}/timer.h"
|
||||
)
|
||||
set( COMMON_SOURCES
|
||||
${COMMON_MINI_SOURCES}
|
||||
"${COMMON_SOURCE_DIR}/mapindex.c"
|
||||
"${COMMON_SOURCE_DIR}/sql.c"
|
||||
"${COMMON_SOURCE_DIR}/timer.c"
|
||||
)
|
||||
set( TXT_HEADERS
|
||||
"${TXT_CHAR_SOURCE_DIR}/char.h"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_pet.h"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_storage.h"
|
||||
"${TXT_CHAR_SOURCE_DIR}/inter.h"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_party.h"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_guild.h"
|
||||
)
|
||||
set( TXT_SOURCES
|
||||
"${TXT_CHAR_SOURCE_DIR}/char.c"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_pet.c"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_storage.c"
|
||||
"${TXT_CHAR_SOURCE_DIR}/inter.c"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_party.c"
|
||||
"${TXT_CHAR_SOURCE_DIR}/int_guild.c"
|
||||
)
|
||||
set( SQL_HEADERS
|
||||
"${SQL_CHAR_SOURCE_DIR}/char.h"
|
||||
"${SQL_CHAR_SOURCE_DIR}/int_pet.h"
|
||||
"${SQL_CHAR_SOURCE_DIR}/int_storage.h"
|
||||
"${SQL_CHAR_SOURCE_DIR}/inter.h"
|
||||
"${SQL_CHAR_SOURCE_DIR}/int_party.h"
|
||||
"${SQL_CHAR_SOURCE_DIR}/int_guild.h"
|
||||
"${SQL_CHAR_SOURCE_DIR}/int_mercenary.h"
|
||||
)
|
||||
set( SQL_SOURCES
|
||||
"${SQL_CHAR_SOURCE_DIR}/char.c"
|
||||
"${SQL_CHAR_SOURCE_DIR}/int_pet.c"
|
||||
"${SQL_CHAR_SOURCE_DIR}/int_storage.c"
|
||||
"${SQL_CHAR_SOURCE_DIR}/inter.c"
|
||||
"${SQL_CHAR_SOURCE_DIR}/int_party.c"
|
||||
"${SQL_CHAR_SOURCE_DIR}/int_guild.c"
|
||||
"${SQL_CHAR_SOURCE_DIR}/int_mercenary.c"
|
||||
)
|
||||
set( CONVERTER_SOURCES
|
||||
"${CONVERTER_SOURCE_DIR}/char-converter.c"
|
||||
)
|
||||
set( LIBRARIES ${GLOBAL_LIBRARIES} ${MYSQL_LIBRARIES} )
|
||||
set( INCLUDE_DIRS ${GLOBAL_INCLUDE_DIRS} ${MYSQL_INCLUDE_DIRS} )
|
||||
set( DEFINITIONS "${GLOBAL_DEFINITIONS} ${COMMON_MINI_DEFINITIONS} -DTXT_SQL_CONVERT" )
|
||||
set( SOURCE_FILES ${COMMON_HEADERS} ${COMMON_SOURCES} ${TXT_HEADERS} ${TXT_SOURCES} ${SQL_HEADERS} ${SQL_SOURCES} ${CONVERTER_SOURCES} )
|
||||
source_group( common FILES ${COMMON_HEADERS} ${COMMON_SOURCES} )
|
||||
source_group( txt FILES ${TXT_HEADERS} ${TXT_SOURCES} )
|
||||
source_group( sql FILES ${SQL_HEADERS} ${SQL_SOURCES} )
|
||||
source_group( converter FILES ${CONVERTER_SOURCES} )
|
||||
include_directories( ${INCLUDE_DIRS} )
|
||||
add_executable( char-converter ${SOURCE_FILES} )
|
||||
target_link_libraries( char-converter ${LIBRARIES} )
|
||||
set_target_properties( char-converter PROPERTIES COMPILE_FLAGS "${DEFINITIONS}" )
|
||||
if( INSTALL_COMPONENT_RUNTIME )
|
||||
cpack_add_component( Runtime_charconverter DESCRIPTION "char-converter" DISPLAY_NAME "char-converter" GROUP Runtime )
|
||||
install( TARGETS char-converter
|
||||
DESTINATION "tools"
|
||||
COMPONENT Runtime_charconverter )
|
||||
endif( INSTALL_COMPONENT_RUNTIME )
|
||||
set( TARGET_LIST ${TARGET_LIST} char-converter CACHE INTERNAL "" )
|
||||
message( STATUS "Creating target char-converter - done" )
|
||||
endif( BUILD_CONVERTERS )
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user