summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-09-25 09:07:33 -0300
committershennetsind <ind@henn.et>2013-09-25 09:07:33 -0300
commit13afb7e0bf35bacc9c90c7dffe34120ddd2fd099 (patch)
tree180c739ac69aceab8ce4cc6151030539a32ac8c3 /src/char
parent1114eb3da58b078258a824424fef687a1ccee90c (diff)
parent66979ef89363c03e3cc02d63feb5248836daff4e (diff)
downloadhercules-13afb7e0bf35bacc9c90c7dffe34120ddd2fd099.tar.gz
hercules-13afb7e0bf35bacc9c90c7dffe34120ddd2fd099.tar.bz2
hercules-13afb7e0bf35bacc9c90c7dffe34120ddd2fd099.tar.xz
hercules-13afb7e0bf35bacc9c90c7dffe34120ddd2fd099.zip
Merge branch 'master' of https://github.com/HerculesWS/Hercules
Conflicts: src/map/chrif.c src/map/clif.c src/map/homunculus.c src/map/pet.c src/map/script.c src/map/skill.c src/map/status.c All clear.
Diffstat (limited to 'src/char')
-rw-r--r--src/char/Makefile.in81
-rw-r--r--src/char/char.c46
-rw-r--r--src/char/char.h1
-rw-r--r--src/char/int_elemental.c26
-rw-r--r--src/char/inter.c13
5 files changed, 94 insertions, 73 deletions
diff --git a/src/char/Makefile.in b/src/char/Makefile.in
index 0c4034a53..02759b32e 100644
--- a/src/char/Makefile.in
+++ b/src/char/Makefile.in
@@ -1,27 +1,29 @@
COMMON_H = $(shell ls ../common/*.h)
-
-MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o
-MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h
-MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar
-
-LIBCONFIG_OBJ = ../../3rdparty/libconfig/libconfig.o ../../3rdparty/libconfig/grammar.o \
- ../../3rdparty/libconfig/scanctx.o ../../3rdparty/libconfig/scanner.o ../../3rdparty/libconfig/strbuf.o
-LIBCONFIG_H = ../../3rdparty/libconfig/libconfig.h ../../3rdparty/libconfig/grammar.h \
- ../../3rdparty/libconfig/parsectx.h ../../3rdparty/libconfig/scanctx.h ../../3rdparty/libconfig/scanner.h \
- ../../3rdparty/libconfig/strbuf.h ../../3rdparty/libconfig/wincompat.h
-LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig
-
-COMMON_SQL_OBJ = ../common/obj_sql/sql.o
-COMMON_H = ../common/sql.h
-
-CHAR_OBJ = obj_sql/char.o obj_sql/inter.o obj_sql/int_party.o obj_sql/int_guild.o \
- obj_sql/int_storage.o obj_sql/int_pet.o obj_sql/int_homun.o obj_sql/int_mail.o obj_sql/int_auction.o obj_sql/int_quest.o obj_sql/int_mercenary.o obj_sql/int_elemental.o obj_sql/pincode.o
-CHAR_H = char.h inter.h int_party.h int_guild.h int_storage.h int_pet.h int_homun.h int_mail.h int_auction.h int_quest.h int_mercenary.h int_elemental.h pincode.h
+CONFIG_H = $(shell ls ../config/*.h ../config/*/*.h)
+
+MT19937AR_D = ../../3rdparty/mt19937ar
+MT19937AR_OBJ = $(MT19937AR_D)/mt19937ar.o
+MT19937AR_H = $(MT19937AR_D)/mt19937ar.h
+MT19937AR_INCLUDE = -I$(MT19937AR_D)
+
+LIBCONFIG_D = ../../3rdparty/libconfig
+LIBCONFIG_OBJ = $(addprefix $(LIBCONFIG_D)/, libconfig.o grammar.o scanctx.o \
+ scanner.o strbuf.o)
+LIBCONFIG_H = $(addprefix $(LIBCONFIG_D)/, libconfig.h grammar.h parsectx.h \
+ scanctx.h scanner.h strbuf.h wincompat.h)
+LIBCONFIG_INCLUDE = -I$(LIBCONFIG_D)
+
+CHAR_OBJ = $(addprefix obj_sql/, char.o inter.o int_auction.o int_elemental.o \
+ int_guild.o int_homun.o int_mail.o int_mercenary.o int_party.o \
+ int_pet.o int_quest.o int_storage.o pincode.o)
+CHAR_H = char.h inter.h int_auction.h int_elemental.h int_guild.h int_homun.h \
+ int_mail.h int_mercenary.h int_party.h int_pet.h int_quest.h \
+ int_storage.h pincode.h
HAVE_MYSQL=@HAVE_MYSQL@
ifeq ($(HAVE_MYSQL),yes)
- CHAR_SERVER_SQL_DEPENDS=obj_sql $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ)
+ CHAR_SERVER_SQL_DEPENDS=$(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ)
else
CHAR_SERVER_SQL_DEPENDS=needs_mysql
endif
@@ -32,13 +34,11 @@ CC = @CC@
export CC
#####################################################################
-.PHONY : all char-server clean help
+.PHONY: all sql char-server clean help
-all: char-server
+all: sql
-char-server: $(CHAR_SERVER_SQL_DEPENDS)
- @echo " LD $@"
- @$(CC) @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
+sql: char-server
clean:
@echo " CLEAN char"
@@ -46,10 +46,10 @@ clean:
help:
@echo "possible targets are 'char-server' 'all' 'clean' 'help'"
- @echo "'char-server' - char server (SQL version)"
- @echo "'all' - builds all above targets"
- @echo "'clean' - cleans builds and objects"
- @echo "'help' - outputs this message"
+ @echo "'char-server' - char server"
+ @echo "'all' - builds all above targets"
+ @echo "'clean' - cleans builds and objects"
+ @echo "'help' - outputs this message"
#####################################################################
@@ -57,23 +57,42 @@ needs_mysql:
@echo "MySQL not found or disabled by the configure script"
@exit 1
+Makefile: Makefile.in
+ @$(MAKE) -C ../.. src/char/Makefile
+
+# object directories
+
obj_sql:
@echo " MKDIR obj_sql"
@-mkdir obj_sql
-obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(COMMON_SQL_H) $(MT19937AR_H) $(LIBCONFIG_H)
+# executables
+
+char-server: ../../char-server@EXEEXT@
+
+../../char-server@EXEEXT@: $(CHAR_SERVER_SQL_DEPENDS) Makefile
+ @echo " LD $(notdir $@)"
+ @$(CC) @LDFLAGS@ -o ../../char-server@EXEEXT@ $(CHAR_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_OBJ) @LIBS@ @MYSQL_LIBS@
+
+# char object files
+
+obj_sql/%.o: %.c $(CHAR_H) $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | obj_sql
@echo " CC $<"
@$(CC) @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
# missing object files
../common/obj_all/common.a:
+ @echo " MAKE $@"
@$(MAKE) -C ../common sql
../common/obj_sql/common_sql.a:
+ @echo " MAKE $@"
@$(MAKE) -C ../common sql
$(MT19937AR_OBJ):
- @$(MAKE) -C ../../3rdparty/mt19937ar
+ @echo " MAKE $@"
+ @$(MAKE) -C $(MT19937AR_D)
$(LIBCONFIG_OBJ):
- @$(MAKE) -C ../../3rdparty/libconfig
+ @echo " MAKE $@"
+ @$(MAKE) -C $(LIBCONFIG_D)
diff --git a/src/char/char.c b/src/char/char.c
index f618320e1..7a948398c 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -68,6 +68,7 @@ char skill_homunculus_db[256] = "skill_homunculus";
char mercenary_db[256] = "mercenary";
char mercenary_owner_db[256] = "mercenary_owner";
char ragsrvinfo_db[256] = "ragsrvinfo";
+char elemental_db[256] = "elemental";
char interreg_db[32] = "interreg";
// show loading/saving messages
@@ -136,7 +137,7 @@ int guild_exp_rate = 100;
//Custom limits for the fame lists. [Skotlex]
int fame_list_size_chemist = MAX_FAME_LIST;
-int fame_list_size_smith = MAX_FAME_LIST;
+int fame_list_size_smith = MAX_FAME_LIST;
int fame_list_size_taekwon = MAX_FAME_LIST;
// Char-server-side stored fame lists [DracoRPG]
@@ -2517,8 +2518,7 @@ int save_accreg2(unsigned char* buf, int len)
return 0;
}
-void char_read_fame_list(void)
-{
+void char_read_fame_list(void) {
int i;
char* data;
size_t len;
@@ -2576,8 +2576,7 @@ void char_read_fame_list(void)
}
// Send map-servers the fame ranking lists
-int char_send_fame_list(int fd)
-{
+int char_send_fame_list(int fd) {
int i, len = 8;
unsigned char buf[32000];
@@ -2612,8 +2611,7 @@ int char_send_fame_list(int fd)
return 0;
}
-void char_update_fame_list(int type, int index, int fame)
-{
+void char_update_fame_list(int type, int index, int fame) {
unsigned char buf[8];
WBUFW(buf,0) = 0x2b22;
WBUFB(buf,2) = type;
@@ -2822,7 +2820,8 @@ int parse_frommap(int fd)
int aid, cid;
aid = RFIFOL(fd,2);
cid = RFIFOL(fd,6);
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT type, tick, val1, val2, val3, val4 from `%s` WHERE `account_id` = '%d' AND `char_id`='%d'",
+ if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` "
+ "FROM `%s` WHERE `account_id` = '%d' AND `char_id`='%d'",
scdata_db, aid, cid) )
{
Sql_ShowDebug(sql_handle);
@@ -3210,12 +3209,11 @@ int parse_frommap(int fd)
int player_pos;
int fame_pos;
- switch(type)
- {
- case 1: size = fame_list_size_smith; list = smith_fame_list; break;
- case 2: size = fame_list_size_chemist; list = chemist_fame_list; break;
- case 3: size = fame_list_size_taekwon; list = taekwon_fame_list; break;
- default: size = 0; list = NULL; break;
+ switch(type) {
+ case RANKTYPE_BLACKSMITH: size = fame_list_size_smith; list = smith_fame_list; break;
+ case RANKTYPE_ALCHEMIST: size = fame_list_size_chemist; list = chemist_fame_list; break;
+ case RANKTYPE_TAEKWON: size = fame_list_size_taekwon; list = taekwon_fame_list; break;
+ default: size = 0; list = NULL; break;
}
ARR_FIND(0, size, player_pos, list[player_pos].id == cid);// position of the player
@@ -3223,22 +3221,20 @@ int parse_frommap(int fd)
if( player_pos == size && fame_pos == size )
;// not on list and not enough fame to get on it
- else if( fame_pos == player_pos )
- {// same position
+ else if( fame_pos == player_pos ) {
+ // same position
list[player_pos].fame = fame;
char_update_fame_list(type, player_pos, fame);
- }
- else
- {// move in the list
- if( player_pos == size )
- {// new ranker - not in the list
+ } else {
+ // move in the list
+ if( player_pos == size ) {
+ // new ranker - not in the list
ARR_MOVE(size - 1, fame_pos, list, struct fame_list);
list[fame_pos].id = cid;
list[fame_pos].fame = fame;
char_loadName(cid, list[fame_pos].name);
- }
- else
- {// already in the list
+ } else {
+ // already in the list
if( fame_pos == size )
--fame_pos;// move to the end of the list
ARR_MOVE(player_pos, fame_pos, list, struct fame_list);
@@ -4721,6 +4717,8 @@ void sql_config_read(const char* cfgName)
safestrncpy(mercenary_owner_db,w2,sizeof(mercenary_owner_db));
else if(!strcmpi(w1,"ragsrvinfo_db"))
safestrncpy(ragsrvinfo_db,w2,sizeof(ragsrvinfo_db));
+ else if(!strcmpi(w1,"elemental_db"))
+ safestrncpy(elemental_db,w2,sizeof(elemental_db));
else if(!strcmpi(w1,"interreg_db"))
safestrncpy(interreg_db,w2,sizeof(interreg_db));
//support the import command, just like any other config
diff --git a/src/char/char.h b/src/char/char.h
index d98ce9004..a3bbdd904 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -103,6 +103,7 @@ extern char skill_homunculus_db[256];
extern char mercenary_db[256];
extern char mercenary_owner_db[256];
extern char ragsrvinfo_db[256];
+extern char elemental_db[256];
extern char interreg_db[32];
extern int db_use_sql_item_db;
diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c
index 53a63a212..ed0c2a9ed 100644
--- a/src/char/int_elemental.c
+++ b/src/char/int_elemental.c
@@ -21,9 +21,9 @@ bool mapif_elemental_save(struct s_elemental* ele) {
if( ele->elemental_id == 0 ) { // Create new DB entry
if( SQL_ERROR == SQL->Query(sql_handle,
- "INSERT INTO `elemental` (`char_id`,`class`,`mode`,`hp`,`sp`,`max_hp`,`max_sp`,`atk1`,`atk2`,`matk`,`aspd`,`def`,`mdef`,`flee`,`hit`,`life_time`)"
- "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%u')",
- ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2, ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time) )
+ "INSERT INTO `%s` (`char_id`,`class`,`mode`,`hp`,`sp`,`max_hp`,`max_sp`,`atk1`,`atk2`,`matk`,`aspd`,`def`,`mdef`,`flee`,`hit`,`life_time`)"
+ "VALUES ('%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%d','%u')",
+ elemental_db, ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2, ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time) )
{
Sql_ShowDebug(sql_handle);
flag = false;
@@ -31,11 +31,11 @@ bool mapif_elemental_save(struct s_elemental* ele) {
else
ele->elemental_id = (int)SQL->LastInsertId(sql_handle);
} else if( SQL_ERROR == SQL->Query(sql_handle,
- "UPDATE `elemental` SET `char_id` = '%d', `class` = '%d', `mode` = '%d', `hp` = '%d', `sp` = '%d',"
- "`max_hp` = '%d', `max_sp` = '%d', `atk1` = '%d', `atk2` = '%d', `matk` = '%d', `aspd` = '%d', `def` = '%d',"
- "`mdef` = '%d', `flee` = '%d', `hit` = '%d', `life_time` = '%u' WHERE `ele_id` = '%d'",
- ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2,
- ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time, ele->elemental_id) )
+ "UPDATE `%s` SET `char_id` = '%d', `class` = '%d', `mode` = '%d', `hp` = '%d', `sp` = '%d',"
+ "`max_hp` = '%d', `max_sp` = '%d', `atk1` = '%d', `atk2` = '%d', `matk` = '%d', `aspd` = '%d', `def` = '%d',"
+ "`mdef` = '%d', `flee` = '%d', `hit` = '%d', `life_time` = '%u' WHERE `ele_id` = '%d'",
+ elemental_db, ele->char_id, ele->class_, ele->mode, ele->hp, ele->sp, ele->max_hp, ele->max_sp, ele->atk, ele->atk2,
+ ele->matk, ele->amotion, ele->def, ele->mdef, ele->flee, ele->hit, ele->life_time, ele->elemental_id) )
{ // Update DB entry
Sql_ShowDebug(sql_handle);
flag = false;
@@ -50,9 +50,11 @@ bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) {
ele->elemental_id = ele_id;
ele->char_id = char_id;
- if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `atk1`, `atk2`, `matk`, `aspd`,"
- "`def`, `mdef`, `flee`, `hit`, `life_time` FROM `elemental` WHERE `ele_id` = '%d' AND `char_id` = '%d'",
- ele_id, char_id) ) {
+ if( SQL_ERROR == SQL->Query(sql_handle,
+ "SELECT `class`, `mode`, `hp`, `sp`, `max_hp`, `max_sp`, `atk1`, `atk2`, `matk`, `aspd`,"
+ "`def`, `mdef`, `flee`, `hit`, `life_time` FROM `%s` WHERE `ele_id` = '%d' AND `char_id` = '%d'",
+ elemental_db, ele_id, char_id) )
+ {
Sql_ShowDebug(sql_handle);
return false;
}
@@ -85,7 +87,7 @@ bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) {
}
bool mapif_elemental_delete(int ele_id) {
- if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `elemental` WHERE `ele_id` = '%d'", ele_id) ) {
+ if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `ele_id` = '%d'", elemental_db, ele_id) ) {
Sql_ShowDebug(sql_handle);
return false;
}
diff --git a/src/char/inter.c b/src/char/inter.c
index 23f400ee9..353d3e009 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -451,7 +451,7 @@ void mapif_parse_accinfo(int fd) {
account_id = atoi(query);
if (account_id < START_ACCOUNT_NUM) { // is string
- if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `char` WHERE `name` LIKE '%s' LIMIT 10", query_esq)
+ if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `account_id`,`name`,`class`,`base_level`,`job_level`,`online` FROM `%s` WHERE `name` LIKE '%s' LIMIT 10", char_db, query_esq)
|| SQL->NumRows(sql_handle) == 0 ) {
if( SQL->NumRows(sql_handle) == 0 ) {
inter_to_fd(fd, u_fd, aid, "No matches were found for your criteria, '%s'",query);
@@ -490,9 +490,10 @@ void mapif_parse_accinfo(int fd) {
/* it will only get here if we have a single match */
if( account_id ) {
- char userid[NAME_LENGTH], user_pass[NAME_LENGTH], email[40], last_ip[20], lastlogin[30], pincode[5], birthdate[11];
+ char userid[NAME_LENGTH], user_pass[NAME_LENGTH], email[40], last_ip[20], lastlogin[30], pin_code[5], birthdate[11];
short level = -1;
int logincount = 0,state = 0;
+ // FIXME: No, this doesn't really look right. We can't, and shouldn't, access the login table from the char server.
if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `userid`, `user_pass`, `email`, `last_ip`, `group_id`, `lastlogin`, `logincount`, `state`,`pincode`,`birthdate` FROM `login` WHERE `account_id` = '%d' LIMIT 1", account_id)
|| SQL->NumRows(sql_handle) == 0 ) {
if( SQL->NumRows(sql_handle) == 0 ) {
@@ -511,7 +512,7 @@ void mapif_parse_accinfo(int fd) {
SQL->GetData(sql_handle, 5, &data, NULL); safestrncpy(lastlogin, data, sizeof(lastlogin));
SQL->GetData(sql_handle, 6, &data, NULL); logincount = atoi(data);
SQL->GetData(sql_handle, 7, &data, NULL); state = atoi(data);
- SQL->GetData(sql_handle, 8, &data, NULL); safestrncpy(pincode, data, sizeof(pincode));
+ SQL->GetData(sql_handle, 8, &data, NULL); safestrncpy(pin_code, data, sizeof(pin_code));
SQL->GetData(sql_handle, 9, &data, NULL); safestrncpy(birthdate, data, sizeof(birthdate));
}
@@ -524,8 +525,8 @@ void mapif_parse_accinfo(int fd) {
inter_to_fd(fd, u_fd, aid, "User: %s | GM Group: %d | State: %d", userid, level, state );
if (level < castergroup) { /* only show pass if your gm level is greater than the one you're searching for */
- if( strlen(pincode) )
- inter_to_fd(fd, u_fd, aid, "Password: %s (PIN:%s)", user_pass, pincode );
+ if( strlen(pin_code) )
+ inter_to_fd(fd, u_fd, aid, "Password: %s (PIN:%s)", user_pass, pin_code );
else
inter_to_fd(fd, u_fd, aid, "Password: %s", user_pass );
}
@@ -536,7 +537,7 @@ void mapif_parse_accinfo(int fd) {
inter_to_fd(fd, u_fd, aid, "-- Character Details --" );
- if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` FROM `char` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", account_id, MAX_CHARS)
+ if ( SQL_ERROR == SQL->Query(sql_handle, "SELECT `char_id`, `name`, `char_num`, `class`, `base_level`, `job_level`, `online` FROM `%s` WHERE `account_id` = '%d' ORDER BY `char_num` LIMIT %d", char_db, account_id, MAX_CHARS)
|| SQL->NumRows(sql_handle) == 0 ) {
if( SQL->NumRows(sql_handle) == 0 )