From 8066bdef468938dd467a231d5be1d3d8f930ba5f Mon Sep 17 00:00:00 2001 From: lighta Date: Fri, 19 Dec 2014 21:31:04 -0500 Subject: [PATCH] Data alignement Align account_id and char_id to uint32 as this is the value they can be in DB. Remove src/test folder, unused Remove useless #include to speedup compilation. --- Makefile.in | 6 -- configure | 3 - configure.in | 1 - src/char/char.c | 36 ++++++------ src/char/char.h | 39 ++++++------- src/char/char_clif.c | 24 ++++---- src/char/char_clif.h | 6 +- src/char/char_cnslif.c | 1 - src/char/char_logif.c | 14 ++--- src/char/char_logif.h | 6 +- src/char/char_mapif.c | 20 +++---- src/char/int_elemental.c | 8 +-- src/char/int_guild.c | 65 +++++++++------------- src/char/int_guild.h | 10 ++-- src/char/int_homun.c | 19 +++---- src/char/int_mail.c | 16 ++---- src/char/int_mercenary.c | 14 ++--- src/char/int_mercenary.h | 6 +- src/char/int_party.c | 39 ++++++------- src/char/int_party.h | 6 +- src/char/int_pet.c | 16 +++--- src/char/int_quest.c | 17 ++---- src/char/int_storage.c | 13 ++--- src/char/int_storage.h | 6 +- src/char/inter.c | 18 +++--- src/char/inter.h | 4 +- src/common/conf.c | 2 - src/common/core.c | 14 +---- src/common/db.c | 1 - src/common/grfio.c | 3 - src/common/malloc.c | 1 - src/common/mapindex.c | 4 -- src/common/md5calc.c | 1 - src/common/mempool.c | 2 - src/common/mmo.h | 30 +++++----- src/common/mutex.c | 3 +- src/common/netbuffer.c | 15 ----- src/common/network.c | 30 ++-------- src/common/random.c | 2 +- src/common/showmsg.c | 5 -- src/common/socket.c | 11 +--- src/common/sql.c | 12 +++- src/common/strlib.c | 2 - src/common/timer.c | 4 -- src/common/utils.c | 4 -- src/login/account.c | 25 ++++----- src/login/account.h | 6 +- src/login/ipban.c | 9 +-- src/login/login.c | 7 +-- src/login/login.h | 14 ++--- src/login/loginchrif.c | 27 ++++----- src/login/loginclif.c | 2 - src/login/logincnslif.c | 2 - src/login/loginlog.c | 4 +- src/map/atcommand.c | 26 ++------- src/map/battle.c | 37 +++++-------- src/map/battleground.c | 5 -- src/map/buyingstore.c | 11 ++-- src/map/buyingstore.h | 4 +- src/map/cashshop.c | 4 -- src/map/channel.c | 5 +- src/map/chat.c | 4 -- src/map/chrif.c | 37 +++++-------- src/map/chrif.h | 20 +++---- src/map/clif.c | 32 +++++------ src/map/clif.h | 12 ++-- src/map/duel.c | 2 - src/map/elemental.c | 22 +------- src/map/guild.c | 40 ++++++------- src/map/guild.h | 30 +++++----- src/map/homunculus.c | 21 +------ src/map/homunculus.h | 2 +- src/map/instance.c | 6 -- src/map/intif.c | 86 +++++++++++++--------------- src/map/intif.h | 62 ++++++++++----------- src/map/itemdb.c | 9 +-- src/map/log.c | 3 +- src/map/mail.c | 4 -- src/map/map.c | 41 ++++++-------- src/map/map.h | 16 +++++- src/map/mapreg.c | 3 +- src/map/mercenary.c | 15 ----- src/map/mob.c | 17 +----- src/map/npc.c | 15 +---- src/map/npc_chat.c | 7 --- src/map/party.c | 84 +++++++++------------------- src/map/party.h | 22 ++++---- src/map/path.h | 2 - src/map/pc.c | 46 +++++---------- src/map/pc.h | 8 +-- src/map/pc_groups.c | 9 +-- src/map/pet.c | 24 ++------ src/map/pet.h | 4 +- src/map/quest.c | 26 ++------- src/map/script.c | 38 ++++++------- src/map/searchstore.c | 6 +- src/map/searchstore.h | 8 +-- src/map/skill.c | 10 ++-- src/map/status.c | 17 ------ src/map/storage.c | 15 ++--- src/map/storage.h | 2 +- src/map/trade.c | 7 +-- src/map/unit.c | 14 +---- src/map/vending.c | 16 ++---- src/test/Makefile.in | 65 ---------------------- src/test/test_spinlock.c | 117 --------------------------------------- 106 files changed, 586 insertions(+), 1207 deletions(-) delete mode 100644 src/test/Makefile.in delete mode 100644 src/test/test_spinlock.c diff --git a/Makefile.in b/Makefile.in index 37841edfdd..8d750af172 100644 --- a/Makefile.in +++ b/Makefile.in @@ -28,7 +28,6 @@ endif map \ tools \ import \ - test \ clean help \ install uninstall bin-clean \ @@ -60,9 +59,6 @@ libconfig: tools: @$(MAKE) -C src/tool -test: - @$(MAKE) -C src/test - import: # 1) create conf/import folder # 2) add missing files @@ -86,7 +82,6 @@ clean: @$(MAKE) -C src/char $@ @$(MAKE) -C src/map $@ @$(MAKE) -C src/tool $@ - @$(MAKE) -C src/test $@ help: @echo "most common targets are 'all' 'server' 'conf' 'clean' 'help'" @@ -101,7 +96,6 @@ help: @echo "'import' - builds conf/import, conf/msg_conf/import and db/import folders from their template folders (x-tmpl)" @echo "'all' - builds all the above targets" @echo "'server' - builds servers (targets 'common' 'login' 'char' 'map' and 'import')" - @echo "'test' - builds tests" @echo "'clean' - cleans builds and objects" @echo "'install' - run installer wich setup rathena in /opt/" @echo "'bin-clean' - delete binary installed" diff --git a/configure b/configure index 124848c73b..ac712aadba 100755 --- a/configure +++ b/configure @@ -2177,8 +2177,6 @@ ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile" ac_config_files="$ac_config_files src/map/Makefile src/tool/Makefile" -ac_config_files="$ac_config_files src/test/Makefile" - ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -8115,7 +8113,6 @@ do "src/login/Makefile") CONFIG_FILES="$CONFIG_FILES src/login/Makefile" ;; "src/map/Makefile") CONFIG_FILES="$CONFIG_FILES src/map/Makefile" ;; "src/tool/Makefile") CONFIG_FILES="$CONFIG_FILES src/tool/Makefile" ;; - "src/test/Makefile") CONFIG_FILES="$CONFIG_FILES src/test/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac diff --git a/configure.in b/configure.in index 5bb500c609..3d55d504f0 100644 --- a/configure.in +++ b/configure.in @@ -9,7 +9,6 @@ AC_CONFIG_FILES([Makefile src/common/Makefile]) AC_CONFIG_FILES([3rdparty/mt19937ar/Makefile 3rdparty/libconfig/Makefile]) AC_CONFIG_FILES([src/char/Makefile src/login/Makefile]) AC_CONFIG_FILES([src/map/Makefile src/tool/Makefile]) -AC_CONFIG_FILES([src/test/Makefile]) AC_GNU_SOURCE diff --git a/src/char/char.c b/src/char/char.c index db91d5cd02..f29edbc0c9 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2,11 +2,9 @@ // For more information, see LICENCE in the main folder #include -#include #include #include #include -#include #include #include "../common/cbasetypes.h" @@ -19,10 +17,7 @@ #include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" -#include "../common/utils.h" #include "../common/cli.h" -#include "../common/random.h" -#include "../common/ers.h" #include "int_guild.h" #include "int_homun.h" #include "int_mercenary.h" @@ -34,7 +29,6 @@ #include "char_mapif.h" #include "char_cnslif.h" #include "char_clif.h" -#include "char.h" //definition of exported var declared in .h int login_fd=-1; //login file descriptor @@ -76,9 +70,9 @@ int subnet_count = 0; int char_chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data); -DBMap* auth_db; // int account_id -> struct auth_node* -DBMap* online_char_db; // int account_id -> struct online_char_data* -DBMap* char_db_; // int char_id -> struct mmo_charstatus* +DBMap* auth_db; // uint32 account_id -> struct auth_node* +DBMap* online_char_db; // uint32 account_id -> struct online_char_data* +DBMap* char_db_; // uint32 char_id -> struct mmo_charstatus* DBMap* char_get_authdb() { return auth_db; } DBMap* char_get_onlinedb() { return online_char_db; } DBMap* char_get_chardb() { return char_db_; } @@ -97,7 +91,7 @@ DBData char_create_online_data(DBKey key, va_list args){ return db_ptr2data(character); } -void char_set_charselect(int account_id) { +void char_set_charselect(uint32 account_id) { struct online_char_data* character; character = (struct online_char_data*)idb_ensure(online_char_db, account_id, char_create_online_data); @@ -118,7 +112,7 @@ void char_set_charselect(int account_id) { } -void char_set_char_online(int map_id, int char_id, int account_id) { +void char_set_char_online(int map_id, uint32 char_id, uint32 account_id) { struct online_char_data* character; struct mmo_charstatus *cp; @@ -156,7 +150,7 @@ void char_set_char_online(int map_id, int char_id, int account_id) { chlogif_send_setacconline(account_id); } -void char_set_char_offline(int char_id, int account_id){ +void char_set_char_offline(uint32 char_id, uint32 account_id){ struct online_char_data* character; if ( char_id == -1 ) @@ -277,7 +271,7 @@ static DBData char_create_charstatus(DBKey key, va_list args) { int char_inventory_to_sql(const struct item items[], int max, int id); -int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p){ +int char_mmo_char_tosql(uint32 char_id, struct mmo_charstatus* p){ int i = 0; int count = 0; int diff = 0; @@ -948,7 +942,7 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) { } //===================================================================================================== -int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything) { +int char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_everything) { int i,j; char t_msg[128] = ""; struct mmo_charstatus* cp; @@ -1255,7 +1249,7 @@ int char_mmo_sql_init(void) { //----------------------------------- // Function to change chararcter's names //----------------------------------- -int char_rename_char_sql(struct char_session_data *sd, int char_id) +int char_rename_char_sql(struct char_session_data *sd, uint32 char_id) { struct mmo_charstatus char_dat; char esc_name[NAME_LENGTH*2+1]; @@ -1365,7 +1359,8 @@ int char_make_new_char_sql(struct char_session_data* sd, char* name_, int str, i #endif char name[NAME_LENGTH]; char esc_name[NAME_LENGTH*2+1]; - int char_id, flag, k; + uint32 char_id; + int flag, k; safestrncpy(name, name_, NAME_LENGTH); normalize_name(name,TRIM_CHARS); @@ -1465,10 +1460,11 @@ int char_divorce_char_sql(int partner_id1, int partner_id2){ /* Returns 0 if successful * Returns < 0 for error */ -int char_delete_char_sql(int char_id){ +int char_delete_char_sql(uint32 char_id){ char name[NAME_LENGTH]; char esc_name[NAME_LENGTH*2+1]; //Name needs be escaped. - int account_id, party_id, guild_id, hom_id, base_level, partner_id, father_id, mother_id, elemental_id; + uint32 account_id; + int party_id, guild_id, hom_id, base_level, partner_id, father_id, mother_id, elemental_id; char *data; size_t len; @@ -1802,7 +1798,7 @@ int char_family(int cid1, int cid2, int cid3) //---------------------------------------------------------------------- // Force disconnection of an online player (with account value) by [Yor] //---------------------------------------------------------------------- -void char_disconnect_player(int account_id) +void char_disconnect_player(uint32 account_id) { int i; struct char_session_data* sd; @@ -1907,7 +1903,7 @@ void char_read_fame_list(void) //Loads a character's name and stores it in the buffer given (must be NAME_LENGTH in size) //Returns 1 on found, 0 on not found (buffer is filled with Unknown char name) -int char_loadName(int char_id, char* name){ +int char_loadName(uint32 char_id, char* name){ char* data; size_t len; diff --git a/src/char/char.h b/src/char/char.h index d748e72869..2a325f1d1e 100644 --- a/src/char/char.h +++ b/src/char/char.h @@ -150,8 +150,8 @@ extern struct mmo_map_server map_server[MAX_MAP_SERVERS]; #define AUTH_TIMEOUT 30000 struct auth_node { - int account_id; - int char_id; + uint32 account_id; + uint32 char_id; uint32 login_id1; uint32 login_id2; uint32 ip; @@ -161,21 +161,22 @@ struct auth_node { unsigned changing_mapservers : 1; uint8 version; }; -DBMap* char_get_authdb(); // int account_id -> struct auth_node* +DBMap* char_get_authdb(); // uint32 account_id -> struct auth_node* struct online_char_data { - int account_id; - int char_id; + uint32 account_id; + uint32 char_id; int fd; int waiting_disconnect; short server; // -2: unknown server, -1: not connected, 0+: id of server bool pincode_success; }; -DBMap* char_get_onlinedb(); // int account_id -> struct online_char_data* +DBMap* char_get_onlinedb(); // uint32 account_id -> struct online_char_data* struct char_session_data { bool auth; // whether the session is authed or not - int account_id, login_id1, login_id2, sex; + uint32 account_id, login_id1, login_id2; + int sex; int found_char[MAX_CHARS]; // ids of chars on this account char email[40]; // e-mail (default: a@a.com) by [Yor] time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) @@ -202,7 +203,7 @@ struct char_session_data { struct mmo_charstatus; -DBMap* char_get_chardb(); // int char_id -> struct mmo_charstatus* +DBMap* char_get_chardb(); // uint32 char_id -> struct mmo_charstatus* //Custom limits for the fame lists. [Skotlex] extern int fame_list_size_chemist; @@ -222,38 +223,38 @@ int char_lan_subnetcheck(uint32 ip); int char_count_users(void); DBData char_create_online_data(DBKey key, va_list args); int char_db_setoffline(DBKey key, DBData *data, va_list ap); -void char_set_char_online(int map_id, int char_id, int account_id); -void char_set_char_offline(int char_id, int account_id); +void char_set_char_online(int map_id, uint32 char_id, uint32 account_id); +void char_set_char_offline(uint32 char_id, uint32 account_id); void char_set_all_offline(int id); -void char_disconnect_player(int account_id); +void char_disconnect_player(uint32 account_id); int char_chardb_waiting_disconnect(int tid, unsigned int tick, int id, intptr_t data); int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p); -int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p); -int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything); +int char_mmo_char_tosql(uint32 char_id, struct mmo_charstatus* p); +int char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_everything); int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf); -int char_delete_char_sql(int char_id); -int char_rename_char_sql(struct char_session_data *sd, int char_id); +int char_delete_char_sql(uint32 char_id); +int char_rename_char_sql(struct char_session_data *sd, uint32 char_id); int char_divorce_char_sql(int partner_id1, int partner_id2); int char_memitemdata_to_sql(const struct item items[], int max, int id, int tableswitch); -void disconnect_player(int account_id); +void disconnect_player(uint32 account_id); 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 char_request_accreg2(int account_id, int char_id); +int char_request_accreg2(uint32 account_id, uint32 char_id); int char_save_accreg2(unsigned char* buf, int len); //extern bool char_gm_read; -int char_loadName(int char_id, char* name); +int char_loadName(uint32 char_id, char* name); int char_check_char_name(char * name, char * esc_name); void char_pincode_decrypt( uint32 userSeed, char* pin ); int char_pincode_compare( int fd, struct char_session_data* sd, char* pin ); void char_auth_ok(int fd, struct char_session_data *sd); -void char_set_charselect(int account_id); +void char_set_charselect(uint32 account_id); void char_read_fame_list(void); #if PACKETVER >= 20120307 diff --git a/src/char/char_clif.c b/src/char/char_clif.c index e1a1c89e1d..46e6e14676 100644 --- a/src/char/char_clif.c +++ b/src/char/char_clif.c @@ -17,9 +17,7 @@ #include "char_mapif.h" #include "char_clif.h" -#include #include -#include //------------------------------------------------ @@ -319,7 +317,7 @@ void chclif_send_auth_result(int fd,char result){ /// 5 (0x71b): To delete a character you must withdraw from the party. /// Any (0x718): An unknown error has occurred. /// HC: <0828>.W .L .L .L -void chclif_char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_date) { +void chclif_char_delete2_ack(int fd, uint32 char_id, uint32 result, time_t delete_date) { WFIFOHEAD(fd,14); WFIFOW(fd,0) = 0x828; WFIFOL(fd,2) = char_id; @@ -337,7 +335,7 @@ void chclif_char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_d /// 5 (0x71e): Date of birth do not match. /// Any (0x718): An unknown error has occurred. /// HC: <082a>.W .L .L -void chclif_char_delete2_accept_ack(int fd, int char_id, uint32 result) { +void chclif_char_delete2_accept_ack(int fd, uint32 char_id, uint32 result) { if(result == 1 ){ struct char_session_data* sd; sd = (struct char_session_data*)session[fd]->session_data; @@ -359,7 +357,7 @@ void chclif_char_delete2_accept_ack(int fd, int char_id, uint32 result) { /// 2 (0x719): A database error occurred. /// Any (0x718): An unknown error has occurred. /// HC: <082c>.W .L .L -void chclif_char_delete2_cancel_ack(int fd, int char_id, uint32 result) { +void chclif_char_delete2_cancel_ack(int fd, uint32 char_id, uint32 result) { WFIFOHEAD(fd,10); WFIFOW(fd,0) = 0x82c; WFIFOL(fd,2) = char_id; @@ -369,9 +367,9 @@ void chclif_char_delete2_cancel_ack(int fd, int char_id, uint32 result) { // CH: <0827>.W .L int chclif_parse_char_delete2_req(int fd, struct char_session_data* sd) { - FIFOSD_CHECK(6) - { - int char_id, i; + FIFOSD_CHECK(6) + { + uint32 char_id, i; char* data; time_t delete_date; @@ -435,7 +433,8 @@ int chclif_parse_char_delete2_accept(int fd, struct char_session_data* sd) { FIFOSD_CHECK(12) { char birthdate[8+1]; - int char_id, i, k; + uint32 char_id; + int i, k; unsigned int base_level; char* data; time_t delete_date; @@ -510,7 +509,8 @@ int chclif_parse_char_delete2_accept(int fd, struct char_session_data* sd) { // CH: <082b>.W .L int chclif_parse_char_delete2_cancel(int fd, struct char_session_data* sd) { - int char_id, i; + uint32 char_id; + int i; FIFOSD_CHECK(6) @@ -590,7 +590,7 @@ int chclif_parse_reqtoconnect(int fd, struct char_session_data* sd,uint32 ipl){ struct auth_node* node; DBMap *auth_db = char_get_authdb(); - int account_id = RFIFOL(fd,2); + uint32 account_id = RFIFOL(fd,2); uint32 login_id1 = RFIFOL(fd,6); uint32 login_id2 = RFIFOL(fd,10); int sex = RFIFOB(fd,16); @@ -678,7 +678,7 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){ struct mmo_charstatus char_dat; struct mmo_charstatus *cd; char* data; - int char_id; + uint32 char_id; uint32 subnet_map_ip; struct auth_node* node; int i, map_fd; diff --git a/src/char/char_clif.h b/src/char/char_clif.h index 9d97d888b9..014d4e94aa 100644 --- a/src/char/char_clif.h +++ b/src/char/char_clif.h @@ -29,9 +29,9 @@ void chclif_mmo_send082d(int fd, struct char_session_data* sd); void chclif_mmo_send099d(int fd, struct char_session_data *sd); void chclif_mmo_char_send(int fd, struct char_session_data* sd); void chclif_send_auth_result(int fd,char result); -void chclif_char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_date); -void chclif_char_delete2_accept_ack(int fd, int char_id, uint32 result); -void chclif_char_delete2_cancel_ack(int fd, int char_id, uint32 result); +void chclif_char_delete2_ack(int fd, uint32 char_id, uint32 result, time_t delete_date); +void chclif_char_delete2_accept_ack(int fd, uint32 char_id, uint32 result); +void chclif_char_delete2_cancel_ack(int fd, uint32 char_id, uint32 result); int chclif_parse_char_delete2_req(int fd, struct char_session_data* sd); int chclif_parse_char_delete2_accept(int fd, struct char_session_data* sd); diff --git a/src/char/char_cnslif.c b/src/char/char_cnslif.c index 2b2c58cd50..c90e7c9acd 100644 --- a/src/char/char_cnslif.c +++ b/src/char/char_cnslif.c @@ -9,7 +9,6 @@ #include "char.h" #include "char_cnslif.h" -#include #include #include diff --git a/src/char/char_logif.c b/src/char/char_logif.c index 754145c8cb..1ffad3e3c9 100644 --- a/src/char/char_logif.c +++ b/src/char/char_logif.c @@ -14,15 +14,13 @@ #include "char_mapif.h" #include "char_logif.h" -#include #include -#include //early declaration void chlogif_on_ready(void); void chlogif_on_disconnect(void); -int chlogif_pincode_notifyLoginPinError( int account_id ){ +int chlogif_pincode_notifyLoginPinError( uint32 account_id ){ if (login_fd > 0 && session[login_fd] && !session[login_fd]->flag.eof){ WFIFOHEAD(login_fd,6); WFIFOW(login_fd,0) = 0x2739; @@ -33,7 +31,7 @@ int chlogif_pincode_notifyLoginPinError( int account_id ){ return 0; } -int chlogif_pincode_notifyLoginPinUpdate( int account_id, char* pin ){ +int chlogif_pincode_notifyLoginPinUpdate( uint32 account_id, char* pin ){ if (login_fd > 0 && session[login_fd] && !session[login_fd]->flag.eof){ int size = 8 + PINCODE_LENGTH+1; WFIFOHEAD(login_fd,size); @@ -49,7 +47,7 @@ int chlogif_pincode_notifyLoginPinUpdate( int account_id, char* pin ){ void chlogif_pincode_start(int fd, struct char_session_data* sd){ if( charserv_config.pincode_config.pincode_enabled ){ - ShowInfo("Asking to start pincode to AID: %d\n", sd->account_id); + //ShowInfo("Asking to start pincode to AID: %d\n", sd->account_id); // PIN code system enabled if( sd->pincode[0] == '\0' ){ // No PIN code has been set yet @@ -179,7 +177,7 @@ int chlogif_save_accreg2(unsigned char* buf, int len){ return 0; } -int chlogif_request_accreg2(int account_id, int char_id){ +int chlogif_request_accreg2(uint32 account_id, uint32 char_id){ if (login_fd > 0) { WFIFOHEAD(login_fd,10); WFIFOW(login_fd,0) = 0x272e; @@ -257,7 +255,7 @@ int chlogif_parse_ackaccreq(int fd, struct char_session_data* sd){ if (RFIFOREST(fd) < 25) return 0; { - int account_id = RFIFOL(fd,2); + uint32 account_id = RFIFOL(fd,2); uint32 login_id1 = RFIFOL(fd,6); uint32 login_id2 = RFIFOL(fd,10); uint8 sex = RFIFOB(fd,14); @@ -361,7 +359,7 @@ int chlogif_parse_ackchangesex(int fd, struct char_session_data* sd){ if( acc > 0 ) {// TODO: Is this even possible? - int char_id[MAX_CHARS]; + uint32 char_id[MAX_CHARS]; int class_[MAX_CHARS]; int guild_id[MAX_CHARS]; unsigned char num, i; diff --git a/src/char/char_logif.h b/src/char/char_logif.h index 16a3e2e114..214ec7f461 100644 --- a/src/char/char_logif.h +++ b/src/char/char_logif.h @@ -14,14 +14,14 @@ extern "C" { #endif -int chlogif_pincode_notifyLoginPinError( int account_id ); -int chlogif_pincode_notifyLoginPinUpdate( int account_id, char* pin ); +int chlogif_pincode_notifyLoginPinError( uint32 account_id ); +int chlogif_pincode_notifyLoginPinUpdate( uint32 account_id, char* pin ); void chlogif_pincode_start(int fd, struct char_session_data* sd); int chlogif_send_acc_tologin(int tid, unsigned int tick, int id, intptr_t data); int chlogif_broadcast_user_count(int tid, unsigned int tick, int id, intptr_t data); int chlogif_send_usercount(int users); int chlogif_save_accreg2(unsigned char* buf, int len); -int chlogif_request_accreg2(int account_id, int char_id); +int chlogif_request_accreg2(uint32 account_id, uint32 char_id); int chlogif_send_reqaccdata(int fd, struct char_session_data *sd); int chlogif_send_setacconline(int aid); void chlogif_send_setallaccoffline(int fd); diff --git a/src/char/char_mapif.c b/src/char/char_mapif.c index 1e9f246382..5eba5d896a 100644 --- a/src/char/char_mapif.c +++ b/src/char/char_mapif.c @@ -17,9 +17,7 @@ #include "char_logif.h" #include "char_mapif.h" -#include #include -#include /** * Packet send to all map-servers, attach to ourself @@ -396,7 +394,7 @@ int chmapif_parse_authok(int fd){ if( RFIFOREST(fd) < 19 ) return 0; else{ - int account_id = RFIFOL(fd,2); + uint32 account_id = RFIFOL(fd,2); uint32 login_id1 = RFIFOL(fd,6); uint32 login_id2 = RFIFOL(fd,10); uint32 ip = RFIFOL(fd,14); @@ -613,7 +611,7 @@ int chmapif_parse_askrmfriend(int fd){ if (RFIFOREST(fd) < 10) return 0; { - int char_id, friend_id; + uint32 char_id, friend_id; char_id = RFIFOL(fd,2); friend_id = RFIFOL(fd,6); if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id`='%d' AND `friend_id`='%d' LIMIT 1", @@ -945,10 +943,10 @@ int chmapif_parse_reqauth(int fd, int id){ return 0; { - int account_id; - int char_id; - int login_id1; - char sex; + uint32 account_id; + uint32 char_id; + uint32 login_id1; + unsigned char sex; uint32 ip; struct auth_node* node; struct mmo_charstatus* cd; @@ -969,12 +967,12 @@ int chmapif_parse_reqauth(int fd, int id){ node = (struct auth_node*)idb_get(auth_db, account_id); cd = (struct mmo_charstatus*)uidb_get(char_db_,char_id); if( cd == NULL ) - { //Really shouldn't happen. + { //Really shouldn't happen. (or autotrade) char_mmo_char_fromsql(char_id, &char_dat, true); cd = (struct mmo_charstatus*)uidb_get(char_db_,char_id); } if( runflag == CHARSERVER_ST_RUNNING && autotrade && cd ){ - uint32 mmo_charstatus_len = sizeof(struct mmo_charstatus) + 25; + uint16 mmo_charstatus_len = sizeof(struct mmo_charstatus) + 25; cd->sex = sex; WFIFOHEAD(fd,mmo_charstatus_len); @@ -999,7 +997,7 @@ int chmapif_parse_reqauth(int fd, int id){ node->sex == sex /*&& node->ip == ip*/ ) {// auth ok - uint32 mmo_charstatus_len = sizeof(struct mmo_charstatus) + 25; + uint16 mmo_charstatus_len = sizeof(struct mmo_charstatus) + 25; cd->sex = sex; WFIFOHEAD(fd,mmo_charstatus_len); diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index 502c46f4d8..1a331fc0a0 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -2,18 +2,14 @@ // 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 #include -#include bool mapif_elemental_save(struct s_elemental* ele) { bool flag = true; @@ -42,7 +38,7 @@ bool mapif_elemental_save(struct s_elemental* ele) { return flag; } -bool mapif_elemental_load(int ele_id, int char_id, struct s_elemental *ele) { +bool mapif_elemental_load(int ele_id, uint32 char_id, struct s_elemental *ele) { char* data; memset(ele, 0, sizeof(struct s_elemental)); @@ -108,7 +104,7 @@ static void mapif_parse_elemental_create(int fd, struct s_elemental* ele) { mapif_elemental_send(fd, ele, result); } -static void mapif_parse_elemental_load(int fd, int ele_id, int char_id) { +static void mapif_parse_elemental_load(int fd, int ele_id, uint32 char_id) { struct s_elemental ele; bool result = mapif_elemental_load(ele_id, char_id, &ele); mapif_elemental_send(fd, &ele, result); diff --git a/src/char/int_guild.c b/src/char/int_guild.c index 0b3d1967b0..8046412742 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -5,7 +5,6 @@ #include "../common/mmo.h" #include "../common/malloc.h" #include "../common/socket.h" -#include "../common/db.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/timer.h" @@ -14,8 +13,6 @@ #include "inter.h" #include "int_guild.h" -#include -#include #include #define GS_MEMBER_UNMODIFIED 0x00 @@ -37,7 +34,7 @@ static DBMap *castle_db; static unsigned int guild_exp[100]; -int mapif_parse_GuildLeave(int fd,int guild_id,int account_id,int char_id,int flag,const char *mes); +int mapif_parse_GuildLeave(int fd,int guild_id,uint32 account_id,uint32 char_id,int flag,const char *mes); int mapif_guild_broken(int guild_id,int flag); static bool guild_check_empty(struct guild *g); int guild_calcinfo(struct guild *g); @@ -89,7 +86,7 @@ static int guild_save_timer(int tid, unsigned int tick, int id, intptr_t data) return 0; } -int inter_guild_removemember_tosql(int account_id, int char_id) +int inter_guild_removemember_tosql(uint32 account_id, uint32 char_id) { if( SQL_ERROR == Sql_Query(sql_handle, "DELETE from `%s` where `account_id` = '%d' and `char_id` = '%d'", schema_config.guild_member_db, account_id, char_id) ) Sql_ShowDebug(sql_handle); @@ -611,7 +608,7 @@ static bool exp_guild_parse_row(char* split[], int column, int current) } -int inter_guild_CharOnline(int char_id, int guild_id) +int inter_guild_CharOnline(uint32 char_id, int guild_id) { struct guild *g; int i; @@ -661,7 +658,7 @@ int inter_guild_CharOnline(int char_id, int guild_id) return 1; } -int inter_guild_CharOffline(int char_id, int guild_id) +int inter_guild_CharOffline(uint32 char_id, int guild_id) { struct guild *g=NULL; int online_count, i; @@ -789,32 +786,22 @@ static bool guild_check_empty(struct guild *g) { int i; ARR_FIND( 0, g->max_member, i, g->member[i].account_id > 0 ); - if( i < g->max_member) - return false; // not empty - //Let the calling function handle the guild removal in case they need //to do something else with it before freeing the data. [Skotlex] - return true; + return i < g->max_member ? false : true; // not empty } unsigned int guild_nextexp(int level) { if (level == 0) return 1; - if (level < 100 && level > 0) // Change by hack - return guild_exp[level-1]; - - return 0; + return level < 100 && level > 0 ? guild_exp[level-1] : 0; } int guild_checkskill(struct guild *g,int id) { int idx = id - GD_SKILLBASE; - - if(idx < 0 || idx >= MAX_GUILDSKILL) - return 0; - - return g->skill[idx].lv; + return idx < 0 || idx >= MAX_GUILDSKILL ? 0 : g->skill[idx].lv; } int guild_calcinfo(struct guild *g) @@ -884,7 +871,7 @@ int guild_calcinfo(struct guild *g) //------------------------------------------------------------------- // Packet sent to map server -int mapif_guild_created(int fd,int account_id,struct guild *g) +int mapif_guild_created(int fd,uint32 account_id,struct guild *g) { WFIFOHEAD(fd, 10); WFIFOW(fd,0)=0x3830; @@ -930,7 +917,7 @@ int mapif_guild_info(int fd,struct guild *g) } // ACK member add -int mapif_guild_memberadded(int fd,int guild_id,int account_id,int char_id,int flag) +int mapif_guild_memberadded(int fd,int guild_id,uint32 account_id,uint32 char_id,int flag) { WFIFOHEAD(fd, 15); WFIFOW(fd,0)=0x3832; @@ -943,7 +930,7 @@ int mapif_guild_memberadded(int fd,int guild_id,int account_id,int char_id,int f } // ACK member leave -int mapif_guild_withdraw(int guild_id,int account_id,int char_id,int flag, const char *name, const char *mes) +int mapif_guild_withdraw(int guild_id,uint32 account_id,uint32 char_id,int flag, const char *name, const char *mes) { unsigned char buf[55+NAME_LENGTH]; WBUFW(buf, 0)=0x3834; @@ -986,7 +973,7 @@ int mapif_guild_broken(int guild_id,int flag) } // Send guild message -int mapif_guild_message(int guild_id,int account_id,char *mes,int len, int sfd) +int mapif_guild_message(int guild_id,uint32 account_id,char *mes,int len, int sfd) { unsigned char buf[512]; if (len > 500) @@ -1016,7 +1003,7 @@ int mapif_guild_basicinfochanged(int guild_id,int type,const void *data,int len) } // Send member info -int mapif_guild_memberinfochanged(int guild_id,int account_id,int char_id, int type,const void *data,int len) +int mapif_guild_memberinfochanged(int guild_id,uint32 account_id,uint32 char_id, int type,const void *data,int len) { unsigned char buf[2048]; if (len > 2030) @@ -1033,7 +1020,7 @@ int mapif_guild_memberinfochanged(int guild_id,int account_id,int char_id, int t } // ACK guild skill up -int mapif_guild_skillupack(int guild_id,uint16 skill_id,int account_id) +int mapif_guild_skillupack(int guild_id,uint16 skill_id,uint32 account_id) { unsigned char buf[14]; WBUFW(buf, 0)=0x383c; @@ -1045,7 +1032,7 @@ int mapif_guild_skillupack(int guild_id,uint16 skill_id,int account_id) } // ACK guild alliance -int mapif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag,const char *name1,const char *name2) +int mapif_guild_alliance(int guild_id1,int guild_id2,uint32 account_id1,uint32 account_id2,int flag,const char *name1,const char *name2) { unsigned char buf[19+2*NAME_LENGTH]; WBUFW(buf, 0)=0x383d; @@ -1132,7 +1119,7 @@ int mapif_guild_castle_dataload(int fd, int sz, int *castle_ids) // Guild creation request -int mapif_parse_CreateGuild(int fd,int account_id,char *name,struct guild_member *master) +int mapif_parse_CreateGuild(int fd,uint32 account_id,char *name,struct guild_member *master) { struct guild *g; int i=0; @@ -1261,7 +1248,7 @@ int mapif_parse_GuildAddMember(int fd,int guild_id,struct guild_member *m) } // Delete member from guild -int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, int flag, const char *mes) +int mapif_parse_GuildLeave(int fd, int guild_id, uint32 account_id, uint32 char_id, int flag, const char *mes) { int i; @@ -1279,7 +1266,7 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in ARR_FIND( 0, g->max_member, i, g->member[i].account_id == account_id && g->member[i].char_id == char_id ); if( i == g->max_member ) { - //TODO + //TODO member not found return 0; } @@ -1319,7 +1306,7 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in } // Change member info -int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id,int account_id,int char_id,int online,int lv,int class_) +int mapif_parse_GuildChangeMemberInfoShort(int fd,int guild_id,uint32 account_id,uint32 char_id,int online,int lv,int class_) { // Could speed up by manipulating only guild_member struct guild * g; @@ -1421,7 +1408,7 @@ int mapif_parse_BreakGuild(int fd,int guild_id) } // Forward Guild message to others map servers -int mapif_parse_GuildMessage(int fd,int guild_id,int account_id,char *mes,int len) +int mapif_parse_GuildMessage(int fd,int guild_id,uint32 account_id,char *mes,int len) { return mapif_guild_message(guild_id,account_id,mes,len, fd); } @@ -1467,7 +1454,7 @@ int mapif_parse_GuildBasicInfoChange(int fd,int guild_id,int type,const char *da * @param len : Size of value * @return */ -int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int char_id,int type,const char *data,int len) +int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,uint32 account_id,uint32 char_id,int type,const char *data,int len) { // Could make some improvement in speed, because only change guild_member int i; @@ -1574,12 +1561,12 @@ int mapif_parse_GuildMemberInfoChange(int fd,int guild_id,int account_id,int cha return 0; } -int inter_guild_sex_changed(int guild_id,int account_id,int char_id, short gender) +int inter_guild_sex_changed(int guild_id,uint32 account_id,uint32 char_id, short gender) { return mapif_parse_GuildMemberInfoChange(0, guild_id, account_id, char_id, GMI_GENDER, (const char*)&gender, sizeof(gender)); } -int inter_guild_charname_changed(int guild_id,int account_id, int char_id, char *name) +int inter_guild_charname_changed(int guild_id,uint32 account_id, uint32 char_id, char *name) { struct guild *g; int i, flag = 0; @@ -1633,7 +1620,7 @@ int mapif_parse_GuildPosition(int fd,int guild_id,int idx,struct guild_position } // Guild Skill UP -int mapif_parse_GuildSkillUp(int fd,int guild_id,uint16 skill_id,int account_id,int max) +int mapif_parse_GuildSkillUp(int fd,int guild_id,uint16 skill_id,uint32 account_id,int max) { struct guild * g; int idx = skill_id - GD_SKILLBASE; @@ -1655,7 +1642,7 @@ int mapif_parse_GuildSkillUp(int fd,int guild_id,uint16 skill_id,int account_id, } //Manual deletion of an alliance when partnering guild does not exists. [Skotlex] -static int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int account_id1, int account_id2, int flag) +static int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, uint32 account_id1, uint32 account_id2, int flag) { int i; char name[NAME_LENGTH]; @@ -1682,7 +1669,7 @@ static int mapif_parse_GuildDeleteAlliance(struct guild *g, int guild_id, int ac * @param flag * @return */ -int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,int account_id1,int account_id2,int flag) +int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,uint32 account_id1,uint32 account_id2,int flag) { // Could speed up struct guild *g[2]; @@ -1884,7 +1871,7 @@ int inter_guild_parse_frommap(int fd) } //Leave request from the server (for deleting character from guild) -int inter_guild_leave(int guild_id, int account_id, int char_id) +int inter_guild_leave(int guild_id, uint32 account_id, uint32 char_id) { return mapif_parse_GuildLeave(-1, guild_id, account_id, char_id, 0, "** Character Deleted **"); } diff --git a/src/char/int_guild.h b/src/char/int_guild.h index 47c42dcc55..addad602d7 100644 --- a/src/char/int_guild.h +++ b/src/char/int_guild.h @@ -26,12 +26,12 @@ 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_leave(int guild_id,int account_id,int char_id); +int inter_guild_leave(int guild_id,uint32 account_id,uint32 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); +int inter_guild_sex_changed(int guild_id,uint32 account_id,uint32 char_id, short gender); +int inter_guild_charname_changed(int guild_id,uint32 account_id, uint32 char_id, char *name); +int inter_guild_CharOnline(uint32 char_id, int guild_id); +int inter_guild_CharOffline(uint32 char_id, int guild_id); #endif /* _INT_GUILD_SQL_H_ */ diff --git a/src/char/int_homun.c b/src/char/int_homun.c index ab0f84f751..c134f0101c 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -2,7 +2,6 @@ // 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" @@ -11,9 +10,7 @@ #include "char.h" #include "inter.h" -#include #include -#include int inter_homunculus_sql_init(void) @@ -25,7 +22,7 @@ void inter_homunculus_sql_final(void) return; } -static void mapif_homunculus_created(int fd, int account_id, struct s_homunculus *sh, unsigned char flag) +static void mapif_homunculus_created(int fd, uint32 account_id, struct s_homunculus *sh, unsigned char flag) { WFIFOHEAD(fd, sizeof(struct s_homunculus)+9); WFIFOW(fd,0) = 0x3890; @@ -44,7 +41,7 @@ static void mapif_homunculus_deleted(int fd, int flag) WFIFOSET(fd, 3); } -static void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd) +static void mapif_homunculus_loaded(int fd, uint32 account_id, struct s_homunculus *hd) { WFIFOHEAD(fd, sizeof(struct s_homunculus)+9); WFIFOW(fd,0) = 0x3891; @@ -63,7 +60,7 @@ static void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus WFIFOSET(fd, sizeof(struct s_homunculus)+9); } -static void mapif_homunculus_saved(int fd, int account_id, bool flag) +static void mapif_homunculus_saved(int fd, uint32 account_id, bool flag) { WFIFOHEAD(fd, 7); WFIFOW(fd,0) = 0x3892; @@ -72,7 +69,7 @@ static void mapif_homunculus_saved(int fd, int account_id, bool flag) WFIFOSET(fd, 7); } -static void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, char* name) +static void mapif_homunculus_renamed(int fd, uint32 account_id, uint32 char_id, unsigned char flag, char* name) { WFIFOHEAD(fd, NAME_LENGTH+12); WFIFOW(fd, 0) = 0x3894; @@ -263,7 +260,7 @@ bool mapif_homunculus_rename(char *name) } -static void mapif_parse_homunculus_create(int fd, int len, int account_id, struct s_homunculus* phd) +static void mapif_parse_homunculus_create(int fd, int len, uint32 account_id, struct s_homunculus* phd) { bool result = mapif_homunculus_save(phd); mapif_homunculus_created(fd, account_id, phd, result); @@ -275,20 +272,20 @@ static void mapif_parse_homunculus_delete(int fd, int homun_id) mapif_homunculus_deleted(fd, result); } -static void mapif_parse_homunculus_load(int fd, int account_id, int homun_id) +static void mapif_parse_homunculus_load(int fd, uint32 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) +static void mapif_parse_homunculus_save(int fd, int len, uint32 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) +static void mapif_parse_homunculus_rename(int fd, uint32 account_id, uint32 char_id, char* name) { bool result = mapif_homunculus_rename(name); mapif_homunculus_renamed(fd, account_id, char_id, result, name); diff --git a/src/char/int_mail.c b/src/char/int_mail.c index 4375cdda58..55f6c8f4b7 100644 --- a/src/char/int_mail.c +++ b/src/char/int_mail.c @@ -2,21 +2,17 @@ // 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" #include "../common/sql.h" -#include "../common/timer.h" #include "char.h" #include "char_mapif.h" #include "inter.h" -#include -#include #include -static int mail_fromsql(int char_id, struct mail_data* md) +static int mail_fromsql(uint32 char_id, struct mail_data* md) { int i, j; struct mail_message *msg; @@ -200,7 +196,7 @@ static bool mail_loadmessage(int mail_id, struct mail_message* msg) /*========================================== * Client Inbox Request *------------------------------------------*/ -static void mapif_Mail_sendinbox(int fd, int char_id, unsigned char flag) +static void mapif_Mail_sendinbox(int fd, uint32 char_id, unsigned char flag) { struct mail_data md; mail_fromsql(char_id, &md); @@ -256,7 +252,7 @@ static bool mail_DeleteAttach(int mail_id) return true; } -static void mapif_Mail_getattach(int fd, int char_id, int mail_id) +static void mapif_Mail_getattach(int fd, uint32 char_id, int mail_id) { struct mail_message msg; @@ -292,7 +288,7 @@ static void mapif_parse_Mail_getattach(int fd) /*========================================== * Delete Mail *------------------------------------------*/ -static void mapif_Mail_delete(int fd, int char_id, int mail_id) +static void mapif_Mail_delete(int fd, uint32 char_id, int mail_id) { bool failed = false; if ( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", schema_config.mail_db, mail_id) ) @@ -335,7 +331,7 @@ void mapif_Mail_new(struct mail_message *msg) /*========================================== * Return Mail *------------------------------------------*/ -static void mapif_Mail_return(int fd, int char_id, int mail_id) +static void mapif_Mail_return(int fd, uint32 char_id, int mail_id) { struct mail_message msg; int new_mail = 0; @@ -399,7 +395,7 @@ static void mapif_parse_Mail_send(int fd) { struct mail_message msg; char esc_name[NAME_LENGTH*2+1]; - int account_id = 0; + uint32 account_id = 0; if(RFIFOW(fd,2) != 8 + sizeof(struct mail_message)) return; diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c index 9ed35db7f2..0b912cb540 100644 --- a/src/char/int_mercenary.c +++ b/src/char/int_mercenary.c @@ -2,20 +2,16 @@ // 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 #include -#include -bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) +bool mercenary_owner_fromsql(uint32 char_id, struct mmo_charstatus *status) { char* data; @@ -43,7 +39,7 @@ bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) return true; } -bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status) +bool mercenary_owner_tosql(uint32 char_id, struct mmo_charstatus *status) { if( SQL_ERROR == Sql_Query(sql_handle, "REPLACE INTO `%s` (`char_id`, `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", schema_config.mercenary_owner_db, char_id, status->mer_id, status->arch_calls, status->arch_faith, status->spear_calls, status->spear_faith, status->sword_calls, status->sword_faith) ) @@ -55,7 +51,7 @@ bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status) return true; } -bool mercenary_owner_delete(int char_id) +bool mercenary_owner_delete(uint32 char_id) { if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", schema_config.mercenary_owner_db, char_id) ) Sql_ShowDebug(sql_handle); @@ -93,7 +89,7 @@ bool mapif_mercenary_save(struct s_mercenary* merc) return flag; } -bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc) +bool mapif_mercenary_load(int merc_id, uint32 char_id, struct s_mercenary *merc) { char* data; @@ -154,7 +150,7 @@ static void mapif_parse_mercenary_create(int fd, struct s_mercenary* merc) mapif_mercenary_send(fd, merc, result); } -static void mapif_parse_mercenary_load(int fd, int merc_id, int char_id) +static void mapif_parse_mercenary_load(int fd, int merc_id, uint32 char_id) { struct s_mercenary merc; bool result = mapif_mercenary_load(merc_id, char_id, &merc); diff --git a/src/char/int_mercenary.h b/src/char/int_mercenary.h index 01e4a841f7..460c2856f7 100644 --- a/src/char/int_mercenary.h +++ b/src/char/int_mercenary.h @@ -11,9 +11,9 @@ void inter_mercenary_sql_final(void); int inter_mercenary_parse_frommap(int fd); // Mercenary Owner Database -bool mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status); -bool mercenary_owner_tosql(int char_id, struct mmo_charstatus *status); -bool mercenary_owner_delete(int char_id); +bool mercenary_owner_fromsql(uint32 char_id, struct mmo_charstatus *status); +bool mercenary_owner_tosql(uint32 char_id, struct mmo_charstatus *status); +bool mercenary_owner_delete(uint32 char_id); bool mapif_mercenary_delete(int merc_id); diff --git a/src/char/int_party.c b/src/char/int_party.c index 157f00fd71..38a3d3f659 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -3,7 +3,6 @@ #include "../common/cbasetypes.h" #include "../common/mmo.h" -#include "../common/db.h" #include "../common/malloc.h" #include "../common/strlib.h" #include "../common/socket.h" @@ -15,9 +14,7 @@ #include "inter.h" #include "int_party.h" -#include #include -#include struct party_data { struct party party; @@ -31,9 +28,9 @@ 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 mapif_parse_PartyLeave(int fd, int party_id, uint32 account_id, uint32 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); +int mapif_party_optionchanged(int fd,struct party *p, uint32 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) { @@ -328,7 +325,7 @@ int party_check_empty(struct party_data *p) // Create a party whether or not -int mapif_party_created(int fd,int account_id,int char_id,struct party *p) +int mapif_party_created(int fd,uint32 account_id,uint32 char_id,struct party *p) { WFIFOHEAD(fd, 39); WFIFOW(fd,0)=0x3820; @@ -350,7 +347,7 @@ int mapif_party_created(int fd,int account_id,int char_id,struct party *p) } //Party information not found -static void mapif_party_noinfo(int fd, int party_id, int char_id) +static void mapif_party_noinfo(int fd, int party_id, uint32 char_id) { WFIFOHEAD(fd, 12); WFIFOW(fd,0) = 0x3821; @@ -362,7 +359,7 @@ static void mapif_party_noinfo(int fd, int party_id, int char_id) } //Digest party information -static void mapif_party_info(int fd, struct party* p, int char_id) +static void mapif_party_info(int fd, struct party* p, uint32 char_id) { unsigned char buf[8 + sizeof(struct party)]; WBUFW(buf,0) = 0x3821; @@ -377,7 +374,7 @@ static void mapif_party_info(int fd, struct party* p, int char_id) } //Whether or not additional party members -int mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, int flag) { +int mapif_party_memberadded(int fd, int party_id, uint32 account_id, uint32 char_id, int flag) { WFIFOHEAD(fd, 15); WFIFOW(fd,0) = 0x3822; WFIFOL(fd,2) = party_id; @@ -390,7 +387,7 @@ int mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, i } // Party setting change notification -int mapif_party_optionchanged(int fd,struct party *p,int account_id,int flag) +int mapif_party_optionchanged(int fd,struct party *p,uint32 account_id,int flag) { unsigned char buf[16]; WBUFW(buf,0)=0x3823; @@ -407,7 +404,7 @@ int mapif_party_optionchanged(int fd,struct party *p,int account_id,int flag) } //Withdrawal notification party -int mapif_party_withdraw(int party_id,int account_id, int char_id) { +int mapif_party_withdraw(int party_id,uint32 account_id, uint32 char_id) { unsigned char buf[16]; WBUFW(buf,0) = 0x3824; @@ -447,7 +444,7 @@ int mapif_party_broken(int party_id,int flag) } //Remarks in the party -int mapif_party_message(int party_id,int account_id,char *mes,int len, int sfd) +int mapif_party_message(int party_id,uint32 account_id,char *mes,int len, int sfd) { unsigned char buf[512]; WBUFW(buf,0)=0x3827; @@ -518,7 +515,7 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part } // Party information request -static void mapif_parse_PartyInfo(int fd, int party_id, int char_id) +static void mapif_parse_PartyInfo(int fd, int party_id, uint32 char_id) { struct party_data *p; p = inter_party_fromsql(party_id); @@ -568,7 +565,7 @@ int mapif_parse_PartyAddMember(int fd, int party_id, struct party_member *member } //Party setting change request -int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int item) +int mapif_parse_PartyChangeOption(int fd,int party_id,uint32 account_id,int exp,int item) { struct party_data *p; int flag = 0; @@ -589,7 +586,7 @@ int mapif_parse_PartyChangeOption(int fd,int party_id,int account_id,int exp,int } //Request leave party -int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id) +int mapif_parse_PartyLeave(int fd, int party_id, uint32 account_id, uint32 char_id) { struct party_data *p; int i,j=-1; @@ -640,7 +637,7 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id) 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) +int mapif_parse_PartyChangeMap(int fd, int party_id, uint32 account_id, uint32 char_id, unsigned short map, int online, unsigned int lv) { struct party_data *p; int i; @@ -711,12 +708,12 @@ int mapif_parse_BreakParty(int fd,int party_id) } //Party sending the message -int mapif_parse_PartyMessage(int fd,int party_id,int account_id,char *mes,int len) +int mapif_parse_PartyMessage(int fd,int party_id,uint32 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) +int mapif_parse_PartyLeaderChange(int fd,int party_id,uint32 account_id,uint32 char_id) { struct party_data *p; int i; @@ -791,12 +788,12 @@ int inter_party_parse_frommap(int fd) } //Leave request from the server (for delete character) -int inter_party_leave(int party_id,int account_id, int char_id) +int inter_party_leave(int party_id,uint32 account_id, uint32 char_id) { return mapif_parse_PartyLeave(-1,party_id,account_id, char_id); } -int inter_party_CharOnline(int char_id, int party_id) +int inter_party_CharOnline(uint32 char_id, int party_id) { struct party_data* p; int i; @@ -843,7 +840,7 @@ int inter_party_CharOnline(int char_id, int party_id) return 1; } -int inter_party_CharOffline(int char_id, int party_id) { +int inter_party_CharOffline(uint32 char_id, int party_id) { struct party_data *p=NULL; int i; diff --git a/src/char/int_party.h b/src/char/int_party.h index d8cdcdc6af..1a30ef0aed 100644 --- a/src/char/int_party.h +++ b/src/char/int_party.h @@ -19,8 +19,8 @@ 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); +int inter_party_leave(int party_id,uint32 account_id, uint32 char_id); +int inter_party_CharOnline(uint32 char_id, int party_id); +int inter_party_CharOffline(uint32 char_id, int party_id); #endif /* _INT_PARTY_SQL_H_ */ diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 8803b8ef20..023af8249c 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -11,9 +11,7 @@ #include "char.h" #include "inter.h" -#include #include -#include struct s_pet *pet_pt; @@ -119,7 +117,7 @@ int inter_pet_delete(int pet_id){ return 0; } //------------------------------------------------------ -int mapif_pet_created(int fd, int account_id, struct s_pet *p) +int mapif_pet_created(int fd, uint32 account_id, struct s_pet *p) { WFIFOHEAD(fd, 12); WFIFOW(fd, 0) = 0x3880; @@ -137,7 +135,7 @@ int mapif_pet_created(int fd, int account_id, struct s_pet *p) return 0; } -int mapif_pet_info(int fd, int account_id, struct s_pet *p){ +int mapif_pet_info(int fd, uint32 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; @@ -149,7 +147,7 @@ int mapif_pet_info(int fd, int account_id, struct s_pet *p){ return 0; } -int mapif_pet_noinfo(int fd, int account_id){ +int mapif_pet_noinfo(int fd, uint32 account_id){ WFIFOHEAD(fd, sizeof(struct s_pet) + 9); WFIFOW(fd, 0) =0x3881; WFIFOW(fd, 2) =sizeof(struct s_pet) + 9; @@ -161,7 +159,7 @@ int mapif_pet_noinfo(int fd, int account_id){ return 0; } -int mapif_save_pet_ack(int fd, int account_id, int flag){ +int mapif_save_pet_ack(int fd, uint32 account_id, int flag){ WFIFOHEAD(fd, 7); WFIFOW(fd, 0) =0x3882; WFIFOL(fd, 2) =account_id; @@ -180,7 +178,7 @@ int mapif_delete_pet_ack(int fd, int flag){ return 0; } -int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id, +int mapif_create_pet(int fd, uint32 account_id, uint32 char_id, short pet_class, short pet_lv, short pet_egg_id, short pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name) { memset(pet_pt, 0, sizeof(struct s_pet)); @@ -218,7 +216,7 @@ int mapif_create_pet(int fd, int account_id, int char_id, short pet_class, short return 0; } -int mapif_load_pet(int fd, int account_id, int char_id, int pet_id){ +int mapif_load_pet(int fd, uint32 account_id, uint32 char_id, int pet_id){ memset(pet_pt, 0, sizeof(struct s_pet)); inter_pet_fromsql(pet_id, pet_pt); @@ -239,7 +237,7 @@ int mapif_load_pet(int fd, int account_id, int char_id, int pet_id){ return 0; } -int mapif_save_pet(int fd, int account_id, struct s_pet *data) { +int mapif_save_pet(int fd, uint32 account_id, struct s_pet *data) { //here process pet save request. int len; RFIFOHEAD(fd); diff --git a/src/char/int_quest.c b/src/char/int_quest.c index 0def3d7587..8a98c9d7d9 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -2,20 +2,15 @@ // For more information, see LICENCE in the main folder #include "../common/mmo.h" -#include "../common/db.h" #include "../common/malloc.h" -#include "../common/showmsg.h" #include "../common/socket.h" #include "../common/strlib.h" #include "../common/sql.h" -#include "../common/timer.h" #include "char.h" #include "inter.h" #include "int_quest.h" -#include -#include #include /** @@ -26,7 +21,7 @@ * @return Array of found entries. It has *count entries, and it is care of the * caller to aFree() it afterwards. */ -struct quest *mapif_quests_fromsql(int char_id, int *count) { +struct quest *mapif_quests_fromsql(uint32 char_id, int *count) { struct quest *questlog = NULL; struct quest tmp_quest; SqlStmt *stmt; @@ -87,7 +82,7 @@ struct quest *mapif_quests_fromsql(int char_id, int *count) { * @param quest_id Quest ID * @return false in case of errors, true otherwise */ -bool mapif_quest_delete(int char_id, int quest_id) { +bool mapif_quest_delete(uint32 char_id, int quest_id) { if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `quest_id` = '%d' AND `char_id` = '%d'", schema_config.quest_db, quest_id, char_id) ) { Sql_ShowDebug(sql_handle); @@ -104,7 +99,7 @@ bool mapif_quest_delete(int char_id, int quest_id) { * @param qd Quest data * @return false in case of errors, true otherwise */ -bool mapif_quest_add(int char_id, struct quest qd) { +bool mapif_quest_add(uint32 char_id, struct quest qd) { if( SQL_ERROR == Sql_Query(sql_handle, "INSERT INTO `%s`(`quest_id`, `char_id`, `state`, `time`, `count1`, `count2`, `count3`) VALUES ('%d', '%d', '%d','%d', '%d', '%d', '%d')", schema_config.quest_db, qd.quest_id, char_id, qd.state, qd.time, qd.count[0], qd.count[1], qd.count[2]) ) { Sql_ShowDebug(sql_handle); @@ -121,7 +116,7 @@ bool mapif_quest_add(int char_id, struct quest qd) { * @param qd Quest data * @return false in case of errors, true otherwise */ -bool mapif_quest_update(int char_id, struct quest qd) { +bool mapif_quest_update(uint32 char_id, struct quest qd) { if( SQL_ERROR == Sql_Query(sql_handle, "UPDATE `%s` SET `state`='%d', `count1`='%d', `count2`='%d', `count3`='%d' WHERE `quest_id` = '%d' AND `char_id` = '%d'", schema_config.quest_db, qd.state, qd.count[0], qd.count[1], qd.count[2], qd.quest_id, char_id) ) { Sql_ShowDebug(sql_handle); @@ -140,7 +135,7 @@ bool mapif_quest_update(int char_id, struct quest qd) { */ int mapif_parse_quest_save(int fd) { int i, j, k, old_n, new_n = (RFIFOW(fd,2) - 8) / sizeof(struct quest); - int char_id = RFIFOL(fd,4); + uint32 char_id = RFIFOL(fd,4); struct quest *old_qd = NULL, *new_qd = NULL; bool success = true; @@ -191,7 +186,7 @@ int mapif_parse_quest_save(int fd) { * @see inter_parse_frommap */ int mapif_parse_quest_load(int fd) { - int char_id = RFIFOL(fd,2); + uint32 char_id = RFIFOL(fd,2); struct quest *tmp_questlog = NULL; int num_quests; diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 99f868ae85..58096a4710 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -2,7 +2,6 @@ // 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 @@ -10,8 +9,6 @@ #include "char.h" #include "inter.h" -#include -#include #include @@ -25,7 +22,7 @@ int storage_tosql(int account_id, struct storage_data* p) } /// Load storage data to mem -int storage_fromsql(int account_id, struct storage_data* p) +int storage_fromsql(uint32 account_id, struct storage_data* p) { StringBuf buf; int i, j; @@ -140,7 +137,7 @@ void inter_storage_sql_final(void) } // Delete char storage -int inter_storage_delete(int account_id) +int inter_storage_delete(uint32 account_id) { if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", schema_config.storage_db, account_id) ) Sql_ShowDebug(sql_handle); @@ -156,7 +153,7 @@ int inter_guild_storage_delete(int guild_id) //--------------------------------------------------------- // packet from map server -int mapif_load_guild_storage(int fd,int account_id,int guild_id, char flag) +int mapif_load_guild_storage(int fd,uint32 account_id,int guild_id, char flag) { if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", schema_config.guild_db, guild_id) ) Sql_ShowDebug(sql_handle); @@ -182,7 +179,7 @@ int mapif_load_guild_storage(int fd,int account_id,int guild_id, char flag) WFIFOSET(fd, 12); return 0; } -int mapif_save_guild_storage_ack(int fd,int account_id,int guild_id,int fail) +int mapif_save_guild_storage_ack(int fd,uint32 account_id,int guild_id,int fail) { WFIFOHEAD(fd,11); WFIFOW(fd,0)=0x3819; @@ -255,7 +252,7 @@ int mapif_parse_itembound_retrieve(int fd) bool found = false; struct item items[MAX_INVENTORY]; unsigned int bound_item[MAX_INVENTORY] = { 0 }; - int char_id = RFIFOL(fd,2); + uint32 char_id = RFIFOL(fd,2); int aid = RFIFOL(fd,6); int guild_id = RFIFOW(fd,10); diff --git a/src/char/int_storage.h b/src/char/int_storage.h index adc4bc2e20..a68c04d960 100644 --- a/src/char/int_storage.h +++ b/src/char/int_storage.h @@ -9,13 +9,13 @@ struct guild_storage; int inter_storage_sql_init(void); void inter_storage_sql_final(void); -int inter_storage_delete(int account_id); +int inter_storage_delete(uint32 account_id); int inter_guild_storage_delete(int guild_id); int inter_storage_parse_frommap(int fd); -int storage_fromsql(int account_id, struct storage_data* p); -int storage_tosql(int account_id,struct storage_data *p); +int storage_fromsql(uint32 account_id, struct storage_data* p); +int storage_tosql(uint32 account_id,struct storage_data *p); int guild_storage_tosql(int guild_id, struct guild_storage *p); #endif /* _INT_STORAGE_SQL_H_ */ diff --git a/src/char/inter.c b/src/char/inter.c index 1781b6fd99..f6585b0569 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -2,7 +2,6 @@ // 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" @@ -23,8 +22,6 @@ #include "int_quest.h" #include "int_elemental.h" -#include -#include #include #include // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool] @@ -517,7 +514,7 @@ void mapif_accinfo_ack(bool success, int map_fd, int u_fd, int u_aid, int accoun //-------------------------------------------------------- // Save registry to sql -int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type) +int inter_accreg_tosql(uint32 account_id, uint32 char_id, struct accreg* reg, int type) { StringBuf buf; int i; @@ -579,7 +576,7 @@ int inter_accreg_tosql(int account_id, int char_id, struct accreg* reg, int type } // Load account_reg from sql (type=2) -int inter_accreg_fromsql(int account_id,int char_id, struct accreg *reg, int type) +int inter_accreg_fromsql(uint32 account_id,uint32 char_id, struct accreg *reg, int type) { char* data; size_t len; @@ -710,6 +707,8 @@ int inter_init_sql(const char *file) 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) ) { + ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n", + char_server_id, char_server_pw, char_server_ip, char_server_port, char_server_db); Sql_ShowDebug(sql_handle); Sql_Free(sql_handle); exit(EXIT_FAILURE); @@ -821,7 +820,7 @@ static void mapif_account_reg(int fd, unsigned char *src) } // Send the requested account_reg -int mapif_account_reg_reply(int fd,int account_id,int char_id, int type) +int mapif_account_reg_reply(int fd,uint32 account_id,uint32 char_id, int type) { struct accreg *reg=accreg_pt; WFIFOHEAD(fd, 13 + 5000); @@ -848,7 +847,7 @@ int mapif_account_reg_reply(int fd,int account_id,int char_id, int type) } //Request to kick char from a certain map server. [Skotlex] -int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason) +int mapif_disconnectplayer(int fd, uint32 account_id, uint32 char_id, int reason) { if (fd >= 0) { @@ -1064,7 +1063,7 @@ int mapif_parse_RegistryRequest(int fd) return 1; } -static void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, char *name) +static void mapif_namechange_ack(int fd, uint32 account_id, uint32 char_id, int type, int flag, char *name) { WFIFOHEAD(fd, NAME_LENGTH+13); WFIFOW(fd, 0) = 0x3806; @@ -1078,7 +1077,8 @@ static void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int mapif_parse_NameChangeRequest(int fd) { - int account_id, char_id, type; + uint32 account_id, char_id; + int type; char* name; int i; diff --git a/src/char/inter.h b/src/char/inter.h index 04cacd056c..03f60ee925 100644 --- a/src/char/inter.h +++ b/src/char/inter.h @@ -12,7 +12,7 @@ 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 mapif_disconnectplayer(int fd, uint32 account_id, uint32 char_id, int reason); void mapif_accinfo_ack(bool success, int map_fd, int u_fd, int u_aid, int account_id, int8 type, int group_id, int logincount, int state, const char *email, const char *last_ip, const char *lastlogin, const char *birthdate, const char *user_pass, const char *pincode, const char *userid); @@ -26,6 +26,6 @@ extern unsigned int party_share_level; extern Sql* sql_handle; extern Sql* lsql_handle; -int inter_accreg_tosql(int account_id, int char_id, struct accreg *reg, int type); +int inter_accreg_tosql(uint32 account_id, uint32 char_id, struct accreg *reg, int type); #endif /* _INTER_SQL_H_ */ diff --git a/src/common/conf.c b/src/common/conf.c index 3057bd4dc2..7650a13fdd 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -2,8 +2,6 @@ // For more information, see LICENCE in the main folder #include "conf.h" -#include "libconfig.h" - #include "../common/showmsg.h" // ShowError int conf_read_file(config_t *config, const char *config_filename) diff --git a/src/common/core.c b/src/common/core.c index 92a6a475c2..8180059382 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -7,20 +7,14 @@ #include "core.h" #include "strlib.h" #ifndef MINICORE -#include "db.h" #include "socket.h" #include "timer.h" #include "thread.h" #include "mempool.h" #include "sql.h" -#include "cbasetypes.h" -#include "msg_conf.h" #endif - -#include #include #include -#include #ifndef _WIN32 #include #else @@ -37,8 +31,6 @@ void (*shutdown_callback)(void) = NULL; #endif int runflag = CORE_ST_RUN; -int arg_c = 0; -char **arg_v = NULL; char db_path[12] = "db"; /// relative path for db from server char *SERVER_NAME = NULL; @@ -326,7 +318,7 @@ void usercheck(void) int main (int argc, char **argv) { {// initialize program arguments - char *p1 = SERVER_NAME = argv[0]; + char *p1; if((p1 = strrchr(argv[0], '/')) != NULL || (p1 = strrchr(argv[0], '\\')) != NULL ){ char *pwd = NULL; //path working directory int n=0; @@ -337,10 +329,6 @@ int main (int argc, char **argv) ShowError("Couldn't change working directory to %s for %s, runtime will probably fail",pwd,SERVER_NAME); free(pwd); } - - arg_c = argc; - arg_v = argv; - } malloc_init();// needed for Show* in display_title() [FlavioJS] diff --git a/src/common/db.c b/src/common/db.c index 572b4f99a7..04aff81245 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -69,7 +69,6 @@ #include #include "db.h" -#include "../common/mmo.h" #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/ers.h" diff --git a/src/common/grfio.c b/src/common/grfio.c index 38ccf0967c..3c5bb72b61 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -9,10 +9,7 @@ #include "../common/utils.h" #include "grfio.h" -#include #include -#include -#include #include //---------------------------- diff --git a/src/common/malloc.c b/src/common/malloc.c index 23580e9316..44f2eff5cd 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -5,7 +5,6 @@ #include "../common/core.h" #include "../common/showmsg.h" -#include #include #include #include diff --git a/src/common/mapindex.c b/src/common/mapindex.c index 195f101d39..685a56f347 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -3,13 +3,9 @@ #include "../common/mmo.h" #include "../common/showmsg.h" -#include "../common/malloc.h" #include "../common/strlib.h" -#include "../common/db.h" #include "mapindex.h" -#include -#include #include DBMap *mapindex_db; diff --git a/src/common/md5calc.c b/src/common/md5calc.c index 05fde42cc9..50a1f711b5 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -10,7 +10,6 @@ #include "md5calc.h" #include #include -#include #ifndef UINT_MAX #define UINT_MAX 4294967295U diff --git a/src/common/mempool.c b/src/common/mempool.c index 5eccbf1780..12d35bd2e3 100644 --- a/src/common/mempool.c +++ b/src/common/mempool.c @@ -13,7 +13,6 @@ #include #include #include -#include #ifdef WIN32 #include "../common/winapi.h" @@ -26,7 +25,6 @@ #include "../common/mempool.h" #include "../common/atomic.h" #include "../common/spinlock.h" -#include "../common/thread.h" #include "../common/malloc.h" #include "../common/mutex.h" diff --git a/src/common/mmo.h b/src/common/mmo.h index e21b569a04..badfe34ff2 100644 --- a/src/common/mmo.h +++ b/src/common/mmo.h @@ -248,7 +248,7 @@ struct global_reg { //Holds array of global registries, used by the char server and converter. struct accreg { - int account_id, char_id; + uint32 account_id, char_id; int reg_num; struct global_reg reg[MAX_REG_NUM]; }; @@ -287,8 +287,8 @@ struct guild_storage { }; struct s_pet { - int account_id; - int char_id; + uint32 account_id; + uint32 char_id; int pet_id; short class_; short level; @@ -304,7 +304,7 @@ struct s_pet { struct s_homunculus { //[orn] char name[NAME_LENGTH]; int hom_id; - int char_id; + uint32 char_id; short class_; short prev_class; int hp,max_hp,sp,max_sp; @@ -328,7 +328,7 @@ struct s_homunculus { //[orn] struct s_mercenary { int mercenary_id; - int char_id; + uint32 char_id; short class_; int hp, sp; unsigned int kill_count; @@ -337,7 +337,7 @@ struct s_mercenary { struct s_elemental { int elemental_id; - int char_id; + uint32 char_id; short class_; int mode; int hp, sp, max_hp, max_sp, matk, atk, atk2; @@ -346,8 +346,8 @@ struct s_elemental { }; struct s_friend { - int account_id; - int char_id; + uint32 account_id; + uint32 char_id; char name[NAME_LENGTH]; }; @@ -360,9 +360,9 @@ struct hotkey { #endif struct mmo_charstatus { - int char_id; - int account_id; - int partner_id; + uint32 char_id; + uint32 account_id; + uint32 partner_id; int father; int mother; int child; @@ -481,8 +481,8 @@ struct registry { }; struct party_member { - int account_id; - int char_id; + uint32 account_id; + uint32 char_id; char name[NAME_LENGTH]; unsigned short class_; unsigned short map; @@ -502,7 +502,7 @@ struct party { struct map_session_data; struct guild_member { - int account_id, char_id; + uint32 account_id, char_id; short hair,hair_color,gender,class_,lv; uint64 exp; int exp_payper; @@ -528,7 +528,7 @@ struct guild_alliance { struct guild_expulsion { char name[NAME_LENGTH]; char mes[40]; - int account_id; + uint32 account_id; }; struct guild_skill { diff --git a/src/common/mutex.c b/src/common/mutex.c index 6b4f551197..e11438e904 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -5,8 +5,7 @@ #include "../common/winapi.h" #else #include -#include -#include + #endif #include "../common/cbasetypes.h" diff --git a/src/common/netbuffer.c b/src/common/netbuffer.c index 57742d6124..37bac53e2e 100644 --- a/src/common/netbuffer.c +++ b/src/common/netbuffer.c @@ -10,21 +10,6 @@ // // -#include -#include -#include - -#include "../common/cbasetypes.h" -#include "../common/atomic.h" -#include "../common/mempool.h" -#include "../common/showmsg.h" -#include "../common/raconf.h" -#include "../common/thread.h" -#include "../common/malloc.h" -#include "../common/core.h" - -#include "../common/netbuffer.h" - // // Buffers are available in the following sizes: diff --git a/src/common/network.c b/src/common/network.c index 68394dcc1a..e958bff33c 100644 --- a/src/common/network.c +++ b/src/common/network.c @@ -11,26 +11,6 @@ #define _GNU_SOURCE //#endif -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - - -#include "../common/cbasetypes.h" -#include "../common/showmsg.h" -#include "../common/timer.h" -#include "../common/evdp.h" -#include "../common/netbuffer.h" - -#include "../common/network.h" #define ENABLE_IPV6 #define HAVE_ACCEPT4 @@ -362,7 +342,7 @@ int32 network_addlistener(bool v6, const char *addr, uint16 port){ s->addr.v6.sin6_family = AF_INET6; s->addr.v6.sin6_port = htons(port); if(inet_pton(AF_INET6, addr, &s->addr.v6.sin6_addr) != 1){ - ShowError("network_addlistener(%c, '%s', %u): failed to parse the given IPV6 address.\n", (v6==true?'t':'f'), addr, port); + ShowError("network_addlistener(t, '%s', %u): failed to parse the given IPV6 address.\n", addr, port); close(fd); return -1; } @@ -387,14 +367,14 @@ int32 network_addlistener(bool v6, const char *addr, uint16 port){ #ifdef ENABLE_IPV6 if(v6 == true){ if( bind(fd, (struct sockaddr*)&s->addr.v6, sizeof(s->addr.v6)) == -1) { - ShowError("network_addlistener(%c, '%s', %u): bind failed (errno: %u / %s)\n", (v6==true?'t':'f'), addr, port, errno, strerror(errno)); + ShowError("network_addlistener(t, '%s', %u): bind failed (errno: %u / %s)\n", addr, port, errno, strerror(errno)); close(fd); return -1; } }else{ #endif if( bind(fd, (struct sockaddr*)&s->addr.v4, sizeof(s->addr.v4)) == -1) { - ShowError("network_addlistener(%c, '%s', %u): bind failed (errno: %u / %s)\n", (v6==true?'t':'f'), addr, port, errno, strerror(errno)); + ShowError("network_addlistener(f, '%s', %u): bind failed (errno: %u / %s)\n", addr, port, errno, strerror(errno)); close(fd); return -1; } @@ -548,7 +528,7 @@ int32 network_connect(bool v6, ip6.sin6_port = htons(from_port); if(inet_pton(AF_INET6, from_addr, &ip6.sin6_addr) != 1){ - ShowError("network_connect(%c, '%s', %u...): cannot parse originating (from) IPV6 address (errno: %u / %s)\n", (v6==true?'t':'f'), addr, port, errno, strerror(errno)); + ShowError("network_connect(t, '%s', %u...): cannot parse originating (from) IPV6 address (errno: %u / %s)\n", addr, port, errno, strerror(errno)); close(fd); return -1; } @@ -584,7 +564,7 @@ int32 network_connect(bool v6, ip6.sin6_port = htons(port); if(inet_pton(AF_INET6, addr, &ip6.sin6_addr) != 1){ - ShowError("network_connect(%c, '%s', %u...): cannot parse destination IPV6 address (errno: %u / %s)\n", (v6==true?'t':'f'), addr, port, errno, strerror(errno)); + ShowError("network_connect(t, '%s', %u...): cannot parse destination IPV6 address (errno: %u / %s)\n", addr, port, errno, strerror(errno)); close(fd); return -1; } diff --git a/src/common/random.c b/src/common/random.c index 5c048c7ebc..ae668f1be0 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -10,7 +10,7 @@ #include #include #endif -#include // time + #include // init_genrand, genrand_int32, genrand_res53 diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 2969b35922..8a374d9042 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -6,14 +6,9 @@ #include "showmsg.h" #include "core.h" //[Ind] - For SERVER_TYPE -#include -#include -#include #include #include // atexit -#include "libconfig.h" - #ifdef WIN32 #include "../common/winapi.h" diff --git a/src/common/socket.c b/src/common/socket.c index be3a8d68e4..dee6c618cb 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -7,25 +7,18 @@ #include "../common/malloc.h" #include "../common/showmsg.h" #include "../common/strlib.h" -#include "../config/core.h" #include "socket.h" -#include #include -#include -#include #ifdef WIN32 #include "../common/winapi.h" #else #include - #include - #include - #include +#include #include #include - #include - #include +#include #include #include diff --git a/src/common/sql.c b/src/common/sql.c index c20e34020a..de86feb597 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -12,7 +12,6 @@ #include "../common/winapi.h" #endif #include -#include // strlen/strnlen/memcpy/memset #include // strtoul #define SQL_CONF_NAME "conf/inter_athena.conf" @@ -87,7 +86,16 @@ Sql* Sql_Malloc(void) static int Sql_P_Keepalive(Sql* self); -/// Establishes a connection. +/** + * Establishes a connection to schema + * @param self : sql handle + * @param user : username to access + * @param passwd : password + * @param host : hostname + * @param port : port + * @param db : schema name + * @return + */ int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* host, uint16 port, const char* db) { if( self == NULL ) diff --git a/src/common/strlib.c b/src/common/strlib.c index 01a74527f1..0554de412c 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -6,9 +6,7 @@ #include "../common/showmsg.h" #include "strlib.h" -#include #include -#include #define J_MAX_MALLOC_SIZE 65535 diff --git a/src/common/timer.c b/src/common/timer.c index f55c4bddf5..80e609629c 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -9,16 +9,12 @@ #include "../common/nullpo.h" #include "timer.h" -#include #include #include -#include #ifdef WIN32 #include "../common/winapi.h" // GetTickCount() #else -#include -#include // struct timeval, gettimeofday() #endif // If the server can't handle processing thousands of monsters diff --git a/src/common/utils.c b/src/common/utils.c index f5f866e779..df64cd8984 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -2,14 +2,10 @@ // For more information, see LICENCE in the main folder #include "../common/cbasetypes.h" -#include "../common/mmo.h" -#include "../common/malloc.h" #include "../common/showmsg.h" #include "socket.h" #include "utils.h" -#include -#include #include #include #include // floor() diff --git a/src/login/account.c b/src/login/account.c index 24204cc297..b337a42109 100644 --- a/src/login/account.c +++ b/src/login/account.c @@ -12,11 +12,8 @@ #include "../common/showmsg.h" #include "../common/sql.h" #include "../common/strlib.h" -#include "../common/timer.h" -#include "../config/core.h" #include "account.h" #include -#include /// global defines #define ACCOUNT_SQL_DB_VERSION 20140928 @@ -52,15 +49,15 @@ static void account_db_sql_destroy(AccountDB* self); static bool account_db_sql_get_property(AccountDB* self, const char* key, char* buf, size_t buflen); static bool account_db_sql_set_property(AccountDB* self, const char* option, const char* value); static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc); -static bool account_db_sql_remove(AccountDB* self, const int account_id); +static bool account_db_sql_remove(AccountDB* self, const uint32 account_id); static bool account_db_sql_save(AccountDB* self, const struct mmo_account* acc); -static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, const int account_id); +static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, const uint32 account_id); static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, const char* userid); static AccountDBIterator* account_db_sql_iterator(AccountDB* self); static void account_db_sql_iter_destroy(AccountDBIterator* self); static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account* acc); -static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int account_id); +static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, uint32 account_id); static bool mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new); /// public constructor @@ -129,6 +126,8 @@ static bool account_db_sql_init(AccountDB* self) { if( SQL_ERROR == Sql_Connect(sql_handle, username, password, hostname, port, database) ) { + ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n", + username, password, hostname, port, database); Sql_ShowDebug(sql_handle); Sql_Free(db->accounts); db->accounts = NULL; @@ -258,7 +257,7 @@ static bool account_db_sql_set_property(AccountDB* self, const char* key, const safestrncpy(db->codepage, value, sizeof(db->codepage)); else if( strcmpi(key, "case_sensitive") == 0 ) - db->case_sensitive = config_switch(value); + db->case_sensitive = (config_switch(value)==1); else return false;// not found return true; @@ -280,7 +279,7 @@ static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc) { Sql* sql_handle = db->accounts; // decide on the account id to assign - int account_id; + uint32 account_id; if( acc->account_id != -1 ) {// caller specifies it manually account_id = acc->account_id; @@ -330,7 +329,7 @@ static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc) { * @param account_id: id of user account * @return true if successful, false if something has failed */ -static bool account_db_sql_remove(AccountDB* self, const int account_id) { +static bool account_db_sql_remove(AccountDB* self, const uint32 account_id) { AccountDB_SQL* db = (AccountDB_SQL*)self; Sql* sql_handle = db->accounts; bool result = false; @@ -366,7 +365,7 @@ static bool account_db_sql_save(AccountDB* self, const struct mmo_account* acc) * @param account_id: id of user account * @return true if successful, false if something has failed */ -static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, const int account_id) { +static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, const uint32 account_id) { AccountDB_SQL* db = (AccountDB_SQL*)self; return mmo_auth_fromsql(db, acc, account_id); } @@ -384,7 +383,7 @@ static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, co AccountDB_SQL* db = (AccountDB_SQL*)self; Sql* sql_handle = db->accounts; char esc_userid[2*NAME_LENGTH+1]; - int account_id; + uint32 account_id; char* data; Sql_EscapeString(sql_handle, esc_userid, userid); @@ -469,7 +468,7 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account SQL_SUCCESS == Sql_GetData(sql_handle, 0, &data, NULL) && data != NULL ) {// get account data - int account_id; + uint32 account_id; account_id = atoi(data); if( mmo_auth_fromsql(db, acc, account_id) ) { @@ -489,7 +488,7 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account * @param account_id: id of user account to take data from * @return true if successful, false if something has failed */ -static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int account_id) { +static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, uint32 account_id) { Sql* sql_handle = db->accounts; char* data; int i = 0; diff --git a/src/login/account.h b/src/login/account.h index c456900209..55a1994d5e 100644 --- a/src/login/account.h +++ b/src/login/account.h @@ -22,7 +22,7 @@ typedef struct AccountDBIterator AccountDBIterator; AccountDB* account_db_sql(void); struct mmo_account { - int account_id; + uint32 account_id; char userid[NAME_LENGTH]; char pass[32+1]; // 23+1 for plaintext, 32+1 for md5-ed passwords char sex; // gender (M/F/S) @@ -108,7 +108,7 @@ struct AccountDB { /// @param self Database /// @param account_id Account id /// @return true if successful - bool (*remove)(AccountDB* self, const int account_id); + bool (*remove)(AccountDB* self, const uint32 account_id); /// Modifies the data of an existing account. /// Uses acc->account_id to identify the account. @@ -124,7 +124,7 @@ struct AccountDB { /// @param acc Pointer that receives the account data /// @param account_id Target account id /// @return true if successful - bool (*load_num)(AccountDB* self, struct mmo_account* acc, const int account_id); + bool (*load_num)(AccountDB* self, struct mmo_account* acc, const uint32 account_id); /// Finds an account with userid and copies it to acc. /// diff --git a/src/login/ipban.c b/src/login/ipban.c index 0a652bc038..8aa628a2cf 100644 --- a/src/login/ipban.c +++ b/src/login/ipban.c @@ -9,17 +9,14 @@ */ #include "../common/cbasetypes.h" -#include "../common/db.h" -#include "../common/malloc.h" +#include "../common/showmsg.h" #include "../common/sql.h" -#include "../common/socket.h" #include "../common/strlib.h" #include "../common/timer.h" #include "login.h" #include "ipban.h" #include "loginlog.h" #include -#include // login sql settings static char ipban_db_hostname[32] = "127.0.0.1"; @@ -213,10 +210,14 @@ void ipban_init(void) { sql_handle = Sql_Malloc(); if( SQL_ERROR == Sql_Connect(sql_handle, username, password, hostname, port, database) ) { + ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n", + username, password, hostname, port, database); Sql_ShowDebug(sql_handle); Sql_Free(sql_handle); exit(EXIT_FAILURE); } + ShowInfo("Ipban conection made\n"); + if( codepage[0] != '\0' && SQL_ERROR == Sql_SetEncoding(sql_handle, codepage) ) Sql_ShowDebug(sql_handle); diff --git a/src/login/login.c b/src/login/login.c index fa968e1419..3c43d06892 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -19,7 +19,6 @@ #include "../common/timer.h" #include "../common/msg_conf.h" #include "../common/cli.h" -#include "../common/ers.h" #include "../common/utils.h" #include "../common/mmo.h" #include "../config/core.h" @@ -31,9 +30,7 @@ #include "loginchrif.h" #include "logincnslif.h" -#include #include -#include #define LOGIN_MAX_MSG 30 /// Max number predefined in msg_conf static char* msg_table[LOGIN_MAX_MSG]; /// Login Server messages_conf @@ -93,7 +90,7 @@ DBData login_create_online_user(DBKey key, va_list args) { * @param account_id : aid connected * @return the new online_login_data for that user */ -struct online_login_data* login_add_online_user(int char_server, int account_id){ +struct online_login_data* login_add_online_user(int char_server, uint32 account_id){ struct online_login_data* p; p = idb_ensure(online_db, account_id, login_create_online_user); p->char_server = char_server; @@ -110,7 +107,7 @@ struct online_login_data* login_add_online_user(int char_server, int account_id) * Checking if user was already scheduled for deletion, and remove that timer if found. * @param account_id : aid to remove from db */ -void login_remove_online_user(int account_id) { +void login_remove_online_user(uint32 account_id) { struct online_login_data* p; p = (struct online_login_data*)idb_get(online_db, account_id); if( p == NULL ) diff --git a/src/login/login.h b/src/login/login.h index a56c686574..bab48a7121 100644 --- a/src/login/login.h +++ b/src/login/login.h @@ -28,7 +28,7 @@ enum E_LOGINSERVER_ST { ///Struct of 1 client connected to login-serv struct login_session_data { - int account_id; ///also GID + uint32 account_id; ///also GID long login_id1; long login_id2; char sex; /// 'F','M','S' @@ -125,16 +125,16 @@ bool login_config_read(const char* cfgName, bool normal); /// Online User Database [Wizputer] struct online_login_data { - int account_id; + uint32 account_id; int waiting_disconnect; int char_server; }; -extern DBMap* online_db; // int account_id -> struct online_login_data* +extern DBMap* online_db; // uint32 account_id -> struct online_login_data* /// Auth database #define AUTH_TIMEOUT 30000 struct auth_node { - int account_id; + uint32 account_id; uint32 login_id1; uint32 login_id2; uint32 ip; @@ -142,7 +142,7 @@ struct auth_node { uint32 version; uint8 clienttype; }; -extern DBMap* auth_db; // int account_id -> struct auth_node* +extern DBMap* auth_db; // uint32 account_id -> struct auth_node* ///Accessors AccountDB* login_get_accounts_db(void); @@ -164,14 +164,14 @@ DBData login_create_online_user(DBKey key, va_list args); * @param account_id: the account identifier * @return the new|registered online data */ -struct online_login_data* login_add_online_user(int char_server, int account_id); +struct online_login_data* login_add_online_user(int char_server, uint32 account_id); /** * Function to remove a user from online_db. * Checking if user was already scheduled for deletion, and remove that timer if found. * @param account_id: the account identifier */ -void login_remove_online_user(int account_id); +void login_remove_online_user(uint32 account_id); /** * Timered function to disconnect a user from login. diff --git a/src/login/loginchrif.c b/src/login/loginchrif.c index 8e9d646163..2ac6f46967 100644 --- a/src/login/loginchrif.c +++ b/src/login/loginchrif.c @@ -11,17 +11,12 @@ #include "../common/strlib.h" //safeprint #include "../common/showmsg.h" //show notice #include "../common/socket.h" //wfifo session -#include "../common/malloc.h" #include "account.h" -#include "ipban.h" //ipban_check #include "login.h" #include "loginlog.h" -#include "loginclif.h" #include "loginchrif.h" -#include #include -#include //early declaration void logchrif_on_disconnect(int id); @@ -82,7 +77,7 @@ int logchrif_parse_reqauth(int fd, int id,char* ip){ return 0; else{ struct auth_node* node; - int account_id = RFIFOL(fd,2); + uint32 account_id = RFIFOL(fd,2); uint32 login_id1 = RFIFOL(fd,6); uint32 login_id2 = RFIFOL(fd,10); uint8 sex = RFIFOB(fd,14); @@ -169,7 +164,7 @@ int logchrif_parse_updmail(int fd, int id, char* ip){ struct mmo_account acc; char email[40]; - int account_id = RFIFOL(fd,2); + uint32 account_id = RFIFOL(fd,2); safestrncpy(email, (char*)RFIFOP(fd,6), 40); remove_control_chars(email); RFIFOSKIP(fd,46); @@ -312,7 +307,7 @@ int logchrif_parse_reqchangemail(int fd, int id, char* ip){ char actual_email[40]; char new_email[40]; - int account_id = RFIFOL(fd,2); + uint32 account_id = RFIFOL(fd,2); safestrncpy(actual_email, (char*)RFIFOP(fd,6), 40); safestrncpy(new_email, (char*)RFIFOP(fd,46), 40); RFIFOSKIP(fd, 86); @@ -351,7 +346,7 @@ int logchrif_parse_requpdaccstate(int fd, int id, char* ip){ else{ struct mmo_account acc; - int account_id = RFIFOL(fd,2); + uint32 account_id = RFIFOL(fd,2); unsigned int state = RFIFOL(fd,6); AccountDB* accounts = login_get_accounts_db(); @@ -397,7 +392,7 @@ int logchrif_parse_reqbanacc(int fd, int id, char* ip){ struct mmo_account acc; AccountDB* accounts = login_get_accounts_db(); - int account_id = RFIFOL(fd,2); + uint32 account_id = RFIFOL(fd,2); int timediff = RFIFOL(fd,6); RFIFOSKIP(fd,10); @@ -450,7 +445,7 @@ int logchrif_parse_reqchgsex(int fd, int id, char* ip){ struct mmo_account acc; AccountDB* accounts = login_get_accounts_db(); - int account_id = RFIFOL(fd,2); + uint32 account_id = RFIFOL(fd,2); RFIFOSKIP(fd,6); if( !accounts->load_num(accounts, &acc, account_id) ) @@ -490,7 +485,7 @@ int logchrif_parse_updreg2(int fd, int id, char* ip){ else{ struct mmo_account acc; AccountDB* accounts = login_get_accounts_db(); - int account_id = RFIFOL(fd,4); + uint32 account_id = RFIFOL(fd,4); if( !accounts->load_num(accounts, &acc, account_id) ) ShowStatus("Char-server '%s': receiving (from the char-server) of account_reg2 (account: %d not found, ip: %s).\n", ch_server[id].name, account_id, ip); @@ -535,7 +530,7 @@ int logchrif_parse_requnbanacc(int fd, int id, char* ip){ struct mmo_account acc; AccountDB* accounts = login_get_accounts_db(); - int account_id = RFIFOL(fd,2); + uint32 account_id = RFIFOL(fd,2); RFIFOSKIP(fd,6); if( !accounts->load_num(accounts, &acc, account_id) ) @@ -621,8 +616,8 @@ int logchrif_parse_reqacc2reg(int fd){ AccountDB* accounts = login_get_accounts_db(); size_t off; - int account_id = RFIFOL(fd,2); - int char_id = RFIFOL(fd,6); + uint32 account_id = RFIFOL(fd,2); + uint32 char_id = RFIFOL(fd,6); RFIFOSKIP(fd,10); WFIFOHEAD(fd,ACCOUNT_REG2_NUM*sizeof(struct global_reg)); @@ -739,7 +734,7 @@ int logchrif_parse_bankvault(int fd, int id, char* ip){ struct mmo_account acc; - int account_id = RFIFOL(fd,2); + uint32 account_id = RFIFOL(fd,2); char type = RFIFOB(fd,6); int32 data = RFIFOL(fd,7); AccountDB* accounts = login_get_accounts_db(); diff --git a/src/login/loginclif.c b/src/login/loginclif.c index a39cb7b27a..e39227777c 100644 --- a/src/login/loginclif.c +++ b/src/login/loginclif.c @@ -22,9 +22,7 @@ #include "loginclif.h" #include "loginchrif.h" -#include #include -#include /** * Transmit auth result to client. diff --git a/src/login/logincnslif.c b/src/login/logincnslif.c index 278923d03f..d4580ae93d 100644 --- a/src/login/logincnslif.c +++ b/src/login/logincnslif.c @@ -17,9 +17,7 @@ #include "login.h" #include "logincnslif.h" -#include #include -#include /** * Login-server console help: starting option info. diff --git a/src/login/loginlog.c b/src/login/loginlog.c index 4464c8b4e9..c17c67d237 100644 --- a/src/login/loginlog.c +++ b/src/login/loginlog.c @@ -12,7 +12,7 @@ #include "../common/socket.h" #include "../common/sql.h" #include "../common/strlib.h" -#include +#include "../common/showmsg.h" #include // exit // global sql settings (in ipban_sql.c) @@ -188,6 +188,8 @@ bool loginlog_init(void) { if( SQL_ERROR == Sql_Connect(sql_handle, username, password, hostname, port, database) ) { + ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n", + username, password, hostname, port, database); Sql_ShowDebug(sql_handle); Sql_Free(sql_handle); exit(EXIT_FAILURE); diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 479ffc7f3d..62d2368ae7 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5,7 +5,6 @@ #include "../common/mmo.h" #include "../common/timer.h" #include "../common/nullpo.h" -#include "../common/core.h" #include "../common/showmsg.h" #include "../common/malloc.h" #include "../common/random.h" @@ -19,38 +18,25 @@ #include "battle.h" #include "chat.h" #include "channel.h" -#include "clif.h" #include "chrif.h" #include "duel.h" #include "instance.h" #include "intif.h" -#include "itemdb.h" -#include "log.h" -#include "pc.h" -#include "pc_groups.h" // groupid2name -#include "status.h" -#include "skill.h" -#include "mob.h" -#include "npc.h" #include "pet.h" #include "homunculus.h" #include "mail.h" #include "mercenary.h" #include "elemental.h" #include "party.h" -#include "guild.h" -#include "script.h" #include "storage.h" #include "trade.h" -#include "unit.h" #include "mapreg.h" #include "quest.h" -#include #include -#include #include + #define ATCOMMAND_LENGTH 50 #define ACMD_FUNC(x) static int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message) @@ -8957,7 +8943,7 @@ ACMD_FUNC(set) { return -1; } - is_str = ( reg[strlen(reg) - 1] == '$' ) ? true : false; + is_str = ( reg[strlen(reg) - 1] == '$' ); if( ( len = strlen(val) ) > 1 ) { if( val[0] == '"' && val[len-1] == '"') { @@ -9057,7 +9043,7 @@ ACMD_FUNC(addperm) { parent_cmd = atcommand_checkalias(command+1); - add = (strcmpi(parent_cmd, "addperm") == 0) ? true : false; + add = (strcmpi(parent_cmd, "addperm") == 0); if( !message || !*message ) { sprintf(atcmd_output, msg_txt(sd,1378),command); // Usage: %s @@ -9135,7 +9121,7 @@ ACMD_FUNC(cart) { sd->status.skill[MC_PUSHCART].flag = x?SKILL_FLAG_TEMPORARY:SKILL_FLAG_PERMANENT; int val = atoi(message); - bool need_skill = pc_checkskill(sd, MC_PUSHCART) ? false : true; + bool need_skill = (pc_checkskill(sd, MC_PUSHCART) == 0); if( !message || !*message || val < 0 || val > MAX_CARTS ) { sprintf(atcmd_output, msg_txt(sd,1390),command,MAX_CARTS); // Unknown Cart (usage: %s <0-%d>). @@ -9552,7 +9538,7 @@ ACMD_FUNC(costume) { */ ACMD_FUNC(cloneequip) { struct map_session_data *pl_sd; - int char_id = 0; + uint32 char_id = 0; nullpo_retr(-1, sd); @@ -9628,7 +9614,7 @@ ACMD_FUNC(cloneequip) { */ ACMD_FUNC(clonestat) { struct map_session_data *pl_sd; - int char_id = 0; + uint32 char_id = 0; nullpo_retr(-1, sd); diff --git a/src/map/battle.c b/src/map/battle.c index 27e26333dd..12afb3e605 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -15,24 +15,15 @@ #include "map.h" #include "path.h" #include "pc.h" -#include "status.h" -#include "skill.h" #include "homunculus.h" #include "mercenary.h" #include "elemental.h" -#include "mob.h" -#include "itemdb.h" -#include "clif.h" #include "pet.h" -#include "guild.h" #include "party.h" -#include "battle.h" #include "battleground.h" #include "chrif.h" -#include #include -#include #include int attr_fix_table[4][ELE_MAX][ELE_MAX]; @@ -6985,19 +6976,21 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t } } - sd->state.autocast = 1; - skill_consume_requirement(sd,r_skill,r_lv,3); - switch( type ) { - case CAST_GROUND: - skill_castend_pos2(src, target->x, target->y, r_skill, r_lv, tick, flag); - break; - case CAST_NODAMAGE: - skill_castend_nodamage_id(src, target, r_skill, r_lv, tick, flag); - break; - case CAST_DAMAGE: - skill_castend_damage_id(src, target, r_skill, r_lv, tick, flag); - break; - } + if (sd->state.autocast == 0) { + sd->state.autocast = 1; + skill_consume_requirement(sd, r_skill, r_lv, 3); + switch (type) { + case CAST_GROUND: + skill_castend_pos2(src, target->x, target->y, r_skill, r_lv, tick, flag); + break; + case CAST_NODAMAGE: + skill_castend_nodamage_id(src, target, r_skill, r_lv, tick, flag); + break; + case CAST_DAMAGE: + skill_castend_damage_id(src, target, r_skill, r_lv, tick, flag); + break; + } + } sd->state.autocast = 0; sd->ud.canact_tick = tick + skill_delayfix(src, r_skill, r_lv); diff --git a/src/map/battleground.c b/src/map/battleground.c index 43e753d3dd..91e4fa6874 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -6,22 +6,17 @@ #include "../common/malloc.h" #include "../common/nullpo.h" #include "../common/showmsg.h" -#include "../common/socket.h" #include "../common/strlib.h" #include "battleground.h" #include "battle.h" #include "clif.h" -#include "map.h" #include "npc.h" #include "pc.h" #include "pet.h" #include "homunculus.h" #include "mercenary.h" -#include -#include - static DBMap* bg_team_db; // int bg_id -> struct battleground_data* static unsigned int bg_team_counter = 0; // Next bg_id diff --git a/src/map/buyingstore.c b/src/map/buyingstore.c index 14d3e49846..c60224a36a 100644 --- a/src/map/buyingstore.c +++ b/src/map/buyingstore.c @@ -2,7 +2,6 @@ // For more information, see LICENCE in the main folder #include "../common/nullpo.h" -#include "../common/cbasetypes.h" #include "../common/db.h" // ARR_FIND #include "../common/malloc.h" // aMalloc, aFree #include "../common/showmsg.h" // ShowWarning @@ -27,8 +26,8 @@ struct s_autotrade_entry { /// Struct of autotrader struct s_autotrade { - int account_id; - int char_id; + uint32 account_id; + uint32 char_id; int buyer_id; int m; uint16 x, y; @@ -296,7 +295,7 @@ void buyingstore_close(struct map_session_data* sd) { * @param sd Player * @param account_id Buyer account ID */ -void buyingstore_open(struct map_session_data* sd, int account_id) +void buyingstore_open(struct map_session_data* sd, uint32 account_id) { struct map_session_data* pl_sd; @@ -334,7 +333,7 @@ void buyingstore_open(struct map_session_data* sd, int account_id) * @param *itemlist List of sold items { .W, .W, .W }* * @param count Number of item on the itemlist */ -void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int buyer_id, const uint8* itemlist, unsigned int count) +void buyingstore_trade(struct map_session_data* sd, uint32 account_id, unsigned int buyer_id, const uint8* itemlist, unsigned int count) { int zeny = 0; unsigned int i, weight, listidx, k; @@ -487,7 +486,7 @@ void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int clif_buyingstore_update_item(pl_sd, nameid, amount); } - if( save_settings&128 ) { + if( save_settings&CHARSAVE_BANK ) { chrif_save(sd, 0); chrif_save(pl_sd, 0); } diff --git a/src/map/buyingstore.h b/src/map/buyingstore.h index c5d0d3a02e..cdebb4d1e2 100644 --- a/src/map/buyingstore.h +++ b/src/map/buyingstore.h @@ -25,8 +25,8 @@ struct s_buyingstore char buyingstore_setup(struct map_session_data* sd, unsigned char slots); char buyingstore_create(struct map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const uint8* itemlist, unsigned int count); void buyingstore_close(struct map_session_data* sd); -void buyingstore_open(struct map_session_data* sd, int account_id); -void buyingstore_trade(struct map_session_data* sd, int account_id, unsigned int buyer_id, const uint8* itemlist, unsigned int count); +void buyingstore_open(struct map_session_data* sd, uint32 account_id); +void buyingstore_trade(struct map_session_data* sd, uint32 account_id, unsigned int buyer_id, const uint8* itemlist, unsigned int count); bool buyingstore_search(struct map_session_data* sd, unsigned short nameid); bool buyingstore_searchall(struct map_session_data* sd, const struct s_search_store_search* s); DBMap *buyingstore_getdb(void); diff --git a/src/map/cashshop.c b/src/map/cashshop.c index 9dfed4e4c1..3f6dc6266c 100644 --- a/src/map/cashshop.c +++ b/src/map/cashshop.c @@ -3,13 +3,9 @@ #include "../common/cbasetypes.h" // uint16, uint32 #include "../common/malloc.h" // CREATE, RECREATE, aFree -#include "../common/nullpo.h" // nullpo_retv #include "../common/showmsg.h" // ShowWarning, ShowStatus #include "cashshop.h" -#include "clif.h" // clif_cashshop_result -#include "itemdb.h" // itemdb_exists, itemdb_isstackable, itemdb_weight, itemdb_type -#include "pc.h" // struct map_session_data, pc_checkadditem, pc_paycash, pc_additem #include "pet.h" // pet_create_egg #include // memset diff --git a/src/map/channel.c b/src/map/channel.c index dfa8a71de9..307282a026 100644 --- a/src/map/channel.c +++ b/src/map/channel.c @@ -7,14 +7,11 @@ #include "../common/showmsg.h" #include "../common/strlib.h" //safestrncpy #include "../common/socket.h" //set_eof -#include "../common/nullpo.h" //nullpo chk #include "map.h" //msg_conf #include "clif.h" //clif_chsys_msg #include "channel.h" -#include "pc.h" -#include #include static DBMap* channel_db; // channels @@ -24,7 +21,7 @@ struct Channel_Config channel_config; DBMap* channel_get_db(void){ return channel_db; } struct chan_banentry { - int char_id; + uint32 char_id; char char_name[NAME_LENGTH]; } chan_banentry; diff --git a/src/map/chat.c b/src/map/chat.c index 36e6f40cd3..d90f51c7ba 100644 --- a/src/map/chat.c +++ b/src/map/chat.c @@ -13,11 +13,8 @@ #include "clif.h" #include "npc.h" // npc_event_do() #include "pc.h" -#include "skill.h" // ext_skill_unit_onplace() #include "chat.h" -#include -#include int chat_triggerevent(struct chat_data *cd); // forward declaration @@ -26,7 +23,6 @@ int chat_triggerevent(struct chat_data *cd); // forward declaration static struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl) { struct chat_data* cd; - nullpo_retr(NULL, bl); cd = (struct chat_data *) aMalloc(sizeof(struct chat_data)); diff --git a/src/map/chrif.c b/src/map/chrif.c index 5e7c2aaa00..22e66589cd 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -17,21 +17,14 @@ #include "npc.h" #include "pc.h" #include "pet.h" -#include "skill.h" -#include "status.h" #include "homunculus.h" #include "instance.h" #include "mercenary.h" #include "elemental.h" #include "chrif.h" -#include "quest.h" #include "storage.h" -#include #include -#include -#include -#include static int check_connect_char_server(int tid, unsigned int tick, int id, intptr_t data); int chrif_save_bankdata(struct map_session_data *sd); @@ -143,17 +136,17 @@ void chrif_check_shutdown(void) { runflag = CORE_ST_STOP; } -struct auth_node* chrif_search(int account_id) { +struct auth_node* chrif_search(uint32 account_id) { return (struct auth_node*)idb_get(auth_db, account_id); } -struct auth_node* chrif_auth_check(int account_id, int char_id, enum sd_state state) { +struct auth_node* chrif_auth_check(uint32 account_id, uint32 char_id, enum sd_state state) { struct auth_node *node = chrif_search(account_id); return ( node && node->char_id == char_id && node->state == state ) ? node : NULL; } -bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) { +bool chrif_auth_delete(uint32 account_id, uint32 char_id, enum sd_state state) { struct auth_node *node; if ( (node = chrif_auth_check(account_id, char_id, state) ) ) { @@ -280,7 +273,7 @@ int chrif_isconnected(void) { * Flag = 3: Character used @autotrade *------------------------------------------*/ int chrif_save(struct map_session_data *sd, int flag) { - uint32 mmo_charstatus_len = 0; + uint16 mmo_charstatus_len = 0; nullpo_retr(-1, sd); pc_makesavestatus(sd); @@ -462,7 +455,7 @@ int chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port) { /// map-server change request acknowledgement (positive or negative) /// R 2b06 .L .L .L .L .W .W .W .L .W -int chrif_changemapserverack(int account_id, int login_id1, int login_id2, int char_id, short map_index, short x, short y, uint32 ip, uint16 port) { +int chrif_changemapserverack(uint32 account_id, int login_id1, int login_id2, uint32 char_id, short map_index, short x, short y, uint32 ip, uint16 port) { struct auth_node *node; if ( !( node = chrif_auth_check(account_id, char_id, ST_MAPCHANGE) ) ) @@ -589,7 +582,7 @@ int chrif_sendmapack(int fd) { /*========================================== * Request sc_data from charserver [Skotlex] *------------------------------------------*/ -int chrif_scdata_request(int account_id, int char_id) { +int chrif_scdata_request(uint32 account_id, uint32 char_id) { #ifdef ENABLE_SC_SAVING chrif_check(-1); @@ -606,7 +599,7 @@ int chrif_scdata_request(int account_id, int char_id) { /*========================================== * Request skillcooldown from charserver *------------------------------------------*/ -int chrif_skillcooldown_request(int account_id, int char_id) { +int chrif_skillcooldown_request(uint32 account_id, uint32 char_id) { chrif_check(-1); WFIFOHEAD(char_fd, 10); WFIFOW(char_fd, 0) = 0x2b0a; @@ -643,7 +636,7 @@ void chrif_authreq(struct map_session_data *sd, bool autotrade) { * Auth confirmation ack *------------------------------------------*/ void chrif_authok(int fd) { - int account_id, group_id, char_id; + uint32 account_id, group_id, char_id; uint32 login_id1,login_id2; time_t expiration_time; struct mmo_charstatus* status; @@ -706,7 +699,7 @@ void chrif_authok(int fd) { // client authentication failed void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (but is available) */ - int account_id, char_id; + uint32 account_id, char_id; uint32 login_id1; char sex; struct auth_node* node; @@ -790,7 +783,7 @@ int chrif_charselectreq(struct map_session_data* sd, uint32 s_ip) { /*========================================== * Search Char trough id on char serv *------------------------------------------*/ -int chrif_searchcharid(int char_id) { +int chrif_searchcharid(uint32 char_id) { if( !char_id ) return -1; @@ -1009,7 +1002,7 @@ int chrif_divorce(int partner_id1, int partner_id2) { * Divorce players * only used if 'partner_id' is offline *------------------------------------------*/ -int chrif_divorceack(int char_id, int partner_id) { +int chrif_divorceack(uint32 char_id, int partner_id) { struct map_session_data* sd; int i; @@ -1129,7 +1122,7 @@ int chrif_req_charunban(int aid, const char* character_name){ //packet.w AID.L WHY.B 2+4+1 = 7byte int chrif_disconnectplayer(int fd) { struct map_session_data* sd; - int account_id = RFIFOL(fd, 2); + uint32 account_id = RFIFOL(fd, 2); sd = map_id2sd(account_id); if( sd == NULL ) { @@ -1461,7 +1454,7 @@ int chrif_char_offline(struct map_session_data *sd) { return 0; } -int chrif_char_offline_nsd(int account_id, int char_id) { +int chrif_char_offline_nsd(uint32 account_id, uint32 char_id) { chrif_check(-1); WFIFOHEAD(char_fd,10); @@ -1778,7 +1771,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) { +int chrif_removefriend(uint32 char_id, int friend_id) { chrif_check(-1); @@ -1808,7 +1801,7 @@ int chrif_send_report(char* buf, int len) { * Requets bonus_script datas * @param char_id */ -int chrif_bsdata_request(int char_id) { +int chrif_bsdata_request(uint32 char_id) { chrif_check(-1); WFIFOHEAD(char_fd,6); WFIFOW(char_fd,0) = 0x2b2d; diff --git a/src/map/chrif.h b/src/map/chrif.h index 9cf5526c64..950a61c904 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -9,7 +9,7 @@ enum sd_state { ST_LOGIN, ST_LOGOUT, ST_MAPCHANGE }; struct auth_node { - int account_id, char_id; + uint32 account_id, char_id; int login_id1, login_id2, sex, fd; time_t expiration_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited) struct map_session_data *sd; //Data from logged on char. @@ -46,15 +46,15 @@ void chrif_check_shutdown(void); extern int chrif_connected; extern int other_mapserver_count; -struct auth_node* chrif_search(int account_id); -struct auth_node* chrif_auth_check(int account_id, int char_id, enum sd_state state); -bool chrif_auth_delete(int account_id, int char_id, enum sd_state state); +struct auth_node* chrif_search(uint32 account_id); +struct auth_node* chrif_auth_check(uint32 account_id, uint32 char_id, enum sd_state state); +bool chrif_auth_delete(uint32 account_id, uint32 char_id, enum sd_state state); bool chrif_auth_finished(struct map_session_data* sd); void chrif_authreq(struct map_session_data* sd, bool autotrade); void chrif_authok(int fd); -int chrif_scdata_request(int account_id, int char_id); -int chrif_skillcooldown_request(int account_id, int char_id); +int chrif_scdata_request(uint32 account_id, uint32 char_id); +int chrif_skillcooldown_request(uint32 account_id, uint32 char_id); int chrif_skillcooldown_save(struct map_session_data *sd); int chrif_skillcooldown_load(int fd); @@ -62,7 +62,7 @@ int chrif_save(struct map_session_data* sd, int flag); int chrif_charselectreq(struct map_session_data* sd, uint32 s_ip); int chrif_changemapserver(struct map_session_data* sd, uint32 ip, uint16 port); -int chrif_searchcharid(int char_id); +int chrif_searchcharid(uint32 char_id); int chrif_changeemail(int id, const char *actual_email, const char *new_email); int chrif_req_login_operation(int aid, const char* character_name, unsigned short operation_type, int timediff, int val1, int val2); int chrif_updatefamelist(struct map_session_data *sd); @@ -70,7 +70,7 @@ int chrif_buildfamelist(void); int chrif_save_scdata(struct map_session_data *sd); int chrif_ragsrvinfo(int base_rate,int job_rate, int drop_rate); int chrif_char_offline(struct map_session_data *sd); -int chrif_char_offline_nsd(int account_id, int char_id); +int chrif_char_offline_nsd(uint32 account_id, uint32 char_id); int chrif_char_reset_offline(void); int send_users_tochar(void); int chrif_char_online(struct map_session_data *sd); @@ -78,7 +78,7 @@ int chrif_changesex(struct map_session_data *sd); int chrif_chardisconnect(struct map_session_data *sd); int chrif_divorce(int partner_id1, int partner_id2); -int chrif_removefriend(int char_id, int friend_id); +int chrif_removefriend(uint32 char_id, int friend_id); int chrif_send_report(char* buf, int len); void chrif_parse_ack_vipActive(int fd); @@ -88,7 +88,7 @@ int chrif_req_charunban(int aid, const char* character_name); int chrif_load_bankdata(int fd); -int chrif_bsdata_request(int char_id); +int chrif_bsdata_request(uint32 char_id); int chrif_save_bsdata(struct map_session_data *sd); int chrif_load_bsdata(int fd); diff --git a/src/map/clif.c b/src/map/clif.c index 006cbaf3fb..9c39efde6d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -6908,7 +6908,7 @@ void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag /// 1 = expel /// 2 = cannot leave party on this map /// 3 = cannot expel from party on this map -void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, int account_id, const char* name, int flag) +void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, uint32 account_id, const char* name, int flag) { unsigned char buf[64]; @@ -6937,7 +6937,7 @@ void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, int /// Party chat message (ZC_NOTIFY_CHAT_PARTY). /// 0109 .W .L .?B -void clif_party_message(struct party_data* p, int account_id, const char* mes, int len) +void clif_party_message(struct party_data* p, uint32 account_id, const char* mes, int len) { struct map_session_data *sd; int i; @@ -7996,7 +7996,7 @@ void clif_guild_leave(struct map_session_data *sd,const char *name,const char *m /// Notifies clients of a guild of an expelled member. /// 015c .24B .40B .24B (ZC_ACK_BAN_GUILD) /// 0839 .24B .40B (ZC_ACK_BAN_GUILD_SSO) -void clif_guild_expulsion(struct map_session_data* sd, const char* name, const char* mes, int account_id) +void clif_guild_expulsion(struct map_session_data* sd, const char* name, const char* mes, uint32 account_id) { unsigned char buf[128]; #if PACKETVER < 20100803 @@ -8063,7 +8063,7 @@ void clif_guild_expulsionlist(struct map_session_data* sd) /// Guild chat message (ZC_GUILD_CHAT). /// 017f .W .?B -void clif_guild_message(struct guild *g,int account_id,const char *mes,int len) +void clif_guild_message(struct guild *g,uint32 account_id,const char *mes,int len) {// TODO: account_id is not used, candidate for deletion? [Ai4rei] struct map_session_data *sd; uint8 buf[256]; @@ -8088,7 +8088,7 @@ void clif_guild_message(struct guild *g,int account_id,const char *mes,int len) /// Request for guild alliance (ZC_REQ_ALLY_GUILD). /// 0171 .L .24B -void clif_guild_reqalliance(struct map_session_data *sd,int account_id,const char *name) +void clif_guild_reqalliance(struct map_session_data *sd,uint32 account_id,const char *name) { int fd; @@ -13110,7 +13110,7 @@ void clif_parse_GMShift(int fd, struct map_session_data *sd) /// 0843 .L void clif_parse_GMRemove2(int fd, struct map_session_data* sd) { - int account_id; + uint32 account_id; struct map_session_data* pl_sd; account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); @@ -13147,7 +13147,7 @@ void clif_parse_GMRecall(int fd, struct map_session_data *sd) /// 0842 .L void clif_parse_GMRecall2(int fd, struct map_session_data* sd) { - int account_id; + uint32 account_id; struct map_session_data* pl_sd; account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); @@ -13298,7 +13298,7 @@ void clif_parse_GMRc(int fd, struct map_session_data* sd) /// Result of request to resolve account name (ZC_ACK_ACCOUNTNAME). /// 01e0 .L .24B -void clif_account_name(int fd, int account_id, const char* accname) +void clif_account_name(int fd, uint32 account_id, const char* accname) { WFIFOHEAD(fd,packet_len(0x1e0)); WFIFOW(fd,0) = 0x1e0; @@ -13520,7 +13520,7 @@ void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd) /// state: /// 0 = online /// 1 = offline -void clif_friendslist_toggle(struct map_session_data *sd,int account_id, int char_id, int online) +void clif_friendslist_toggle(struct map_session_data *sd,uint32 account_id, uint32 char_id, int online) { int i, fd = sd->fd; @@ -13543,7 +13543,7 @@ void clif_friendslist_toggle(struct map_session_data *sd,int account_id, int cha //Subfunction called from clif_foreachclient to toggle friends on/off [Skotlex] int clif_friendslist_toggle_sub(struct map_session_data *sd,va_list ap) { - int account_id, char_id, online; + uint32 account_id, char_id, online; account_id = va_arg(ap, int); char_id = va_arg(ap, int); online = va_arg(ap, int); @@ -13606,7 +13606,7 @@ void clif_friendslist_reqack(struct map_session_data *sd, struct map_session_dat /// Asks a player for permission to be added as friend (ZC_REQ_ADD_FRIENDS). /// 0207 .L .L .24B -void clif_friendlist_req(struct map_session_data* sd, int account_id, int char_id, const char* name) +void clif_friendlist_req(struct map_session_data* sd, uint32 account_id, uint32 char_id, const char* name) { int fd = sd->fd; @@ -13676,7 +13676,7 @@ void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) void clif_parse_FriendsListReply(int fd, struct map_session_data *sd) { struct map_session_data *f_sd; - int account_id; + uint32 account_id; char reply; struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; @@ -13740,7 +13740,7 @@ void clif_parse_FriendsListReply(int fd, struct map_session_data *sd) void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) { struct map_session_data *f_sd = NULL; - int account_id, char_id; + uint32 account_id, char_id; int i, j; struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; @@ -16341,7 +16341,7 @@ void clif_buyingstore_disappear_entry_single(struct map_session_data* sd, struct /// 0817 .L static void clif_parse_ReqClickBuyingStore(int fd, struct map_session_data* sd) { - int account_id; + uint32 account_id; account_id = RFIFOL(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]); @@ -16381,7 +16381,7 @@ static void clif_parse_ReqTradeBuyingStore(int fd, struct map_session_data* sd) { const unsigned int blocksize = 6; uint8* itemlist; - int account_id; + uint32 account_id; unsigned int count, packet_len, buyer_id; struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; @@ -16647,7 +16647,7 @@ static void clif_parse_CloseSearchStoreInfo(int fd, struct map_session_data* sd) static void clif_parse_SearchStoreInfoListItemClick(int fd, struct map_session_data* sd) { unsigned short nameid; - int account_id, store_id; + uint32 account_id, store_id; struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; account_id = RFIFOL(fd,info->pos[0]); diff --git a/src/map/clif.h b/src/map/clif.h index 0ec2ed8373..3ab83ebd01 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -608,8 +608,8 @@ void clif_party_info(struct party_data* p, struct map_session_data *sd); void clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd); void clif_party_inviteack(struct map_session_data* sd, const char* nick, int result); void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag); -void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, int account_id, const char* name, int flag); -void clif_party_message(struct party_data* p, int account_id, const char* mes, int len); +void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, uint32 account_id, const char* name, int flag); +void clif_party_message(struct party_data* p, uint32 account_id, const char* mes, int len); void clif_party_xy(struct map_session_data *sd); void clif_party_xy_single(int fd, struct map_session_data *sd); void clif_party_hp(struct map_session_data *sd); @@ -628,14 +628,14 @@ void clif_guild_memberlogin_notice(struct guild *g,int idx,int flag); void clif_guild_invite(struct map_session_data *sd,struct guild *g); void clif_guild_inviteack(struct map_session_data *sd,int flag); void clif_guild_leave(struct map_session_data *sd,const char *name,const char *mes); -void clif_guild_expulsion(struct map_session_data* sd, const char* name, const char* mes, int account_id); +void clif_guild_expulsion(struct map_session_data* sd, const char* name, const char* mes, uint32 account_id); void clif_guild_positionchanged(struct guild *g,int idx); void clif_guild_memberpositionchanged(struct guild *g,int idx); void clif_guild_emblem(struct map_session_data *sd,struct guild *g); void clif_guild_emblem_area(struct block_list* bl); void clif_guild_notice(struct map_session_data* sd, struct guild* g); -void clif_guild_message(struct guild *g,int account_id,const char *mes,int len); -void clif_guild_reqalliance(struct map_session_data *sd,int account_id,const char *name); +void clif_guild_message(struct guild *g,uint32 account_id,const char *mes,int len); +void clif_guild_reqalliance(struct map_session_data *sd,uint32 account_id,const char *name); void clif_guild_allianceack(struct map_session_data *sd,int flag); void clif_guild_delalliance(struct map_session_data *sd,int guild_id,int flag); void clif_guild_oppositionack(struct map_session_data *sd,int flag); @@ -887,7 +887,7 @@ void clif_crimson_marker(struct map_session_data *sd, struct block_list *bl, boo void clif_showscript(struct block_list* bl, const char* message); void clif_party_leaderchanged(struct map_session_data *sd, int prev_leader_aid, int new_leader_aid); -void clif_account_name(int fd, int account_id, const char* accname); +void clif_account_name(int fd, uint32 account_id, const char* accname); //void clif_broadcast_obtain_special_item(); ///TODO! diff --git a/src/map/duel.c b/src/map/duel.c index c386b1513e..b342d0a15a 100644 --- a/src/map/duel.c +++ b/src/map/duel.c @@ -10,9 +10,7 @@ #include "pc.h" #include -#include #include -#include //global var (extern) struct duel duel_list[MAX_DUEL]; //list of current duel diff --git a/src/map/elemental.c b/src/map/elemental.c index 1df15f1381..5d7017ec5d 100644 --- a/src/map/elemental.c +++ b/src/map/elemental.c @@ -3,39 +3,23 @@ #include "../common/cbasetypes.h" #include "../common/malloc.h" -#include "../common/socket.h" #include "../common/timer.h" #include "../common/nullpo.h" #include "../common/mmo.h" #include "../common/showmsg.h" -#include "../common/utils.h" #include "../common/random.h" #include "../common/strlib.h" #include "log.h" #include "clif.h" -#include "chrif.h" #include "intif.h" #include "itemdb.h" -#include "map.h" #include "pc.h" -#include "status.h" -#include "skill.h" -#include "mob.h" -#include "pet.h" -#include "battle.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" -#include "script.h" -#include "npc.h" #include "trade.h" -#include "unit.h" #include "elemental.h" -#include #include -#include #include struct s_elemental_db elemental_db[MAX_ELEMENTAL_CLASS]; // Elemental Database @@ -564,11 +548,7 @@ int elemental_unlocktarget(struct elemental_data *ed) { bool elemental_skillnotok(uint16 skill_id, struct elemental_data *ed) { uint16 idx = skill_get_index(skill_id); nullpo_retr(1,ed); - - if (idx == 0) - return false; // invalid skill id - - return skill_isNotOk(skill_id,ed->master); + return idx == 0 ? false : skill_isNotOk(skill_id,ed->master); // return false or check if it,s ok for master as well } struct skill_condition elemental_skill_get_requirements(uint16 skill_id, uint16 skill_lv){ diff --git a/src/map/guild.c b/src/map/guild.c index 97383cfbad..5b04dd5326 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -17,21 +17,15 @@ #include "battle.h" #include "npc.h" #include "pc.h" -#include "status.h" -#include "mob.h" #include "intif.h" -#include "clif.h" #include "channel.h" -#include "skill.h" -#include "log.h" -#include #include -#include + static DBMap* guild_db; // int guild_id -> struct guild* static DBMap* castle_db; // int castle_id -> struct guild_castle* -static DBMap* guild_expcache_db; // int char_id -> struct guild_expcache* +static DBMap* guild_expcache_db; // uint32 char_id -> struct guild_expcache* static DBMap* guild_infoevent_db; // int guild_id -> struct eventlist* struct eventlist { @@ -72,7 +66,7 @@ unsigned short guild_flags_count; /*========================================== * Retrieves and validates the sd pointer for this guild member [Skotlex] *------------------------------------------*/ -static TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id) { +static TBL_PC* guild_sd_check(int guild_id, uint32 account_id, uint32 char_id) { TBL_PC* sd = map_id2sd(account_id); if (!(sd && sd->status.char_id == char_id)) @@ -224,7 +218,7 @@ struct map_session_data* guild_getavailablesd(struct guild* g) { } /// lookup: player AID/CID -> member index -int guild_getindex(struct guild *g,int account_id,int char_id) { +int guild_getindex(struct guild *g,uint32 account_id,uint32 char_id) { int i; if( g == NULL ) @@ -370,7 +364,7 @@ int guild_create(struct map_session_data *sd, const char *name) { } //Whether or not to create guild -int guild_created(int account_id,int guild_id) { +int guild_created(uint32 account_id,int guild_id) { struct map_session_data *sd=map_id2sd(account_id); if(sd==NULL) @@ -684,7 +678,7 @@ void guild_member_joined(struct map_session_data *sd) { /*========================================== * Add a player to a given guild_id *----------------------------------------*/ -int guild_member_added(int guild_id,int account_id,int char_id,int flag) { +int guild_member_added(int guild_id,uint32 account_id,uint32 char_id,int flag) { struct map_session_data *sd= map_id2sd(account_id),*sd2; struct guild *g; @@ -731,7 +725,7 @@ int guild_member_added(int guild_id,int account_id,int char_id,int flag) { /*========================================== * Player request leaving a given guild_id *----------------------------------------*/ -int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int char_id, const char* mes) { +int guild_leave(struct map_session_data* sd, int guild_id, uint32 account_id, uint32 char_id, const char* mes) { struct guild *g; nullpo_ret(sd); @@ -753,7 +747,7 @@ int guild_leave(struct map_session_data* sd, int guild_id, int account_id, int c /*========================================== * Request remove a player to a given guild_id *----------------------------------------*/ -int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, int char_id, const char* mes) { +int guild_expulsion(struct map_session_data* sd, int guild_id, uint32 account_id, uint32 char_id, const char* mes) { struct map_session_data *tsd; struct guild *g; int i,ps; @@ -785,7 +779,7 @@ int guild_expulsion(struct map_session_data* sd, int guild_id, int account_id, i return 0; } -int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, const char* name, const char* mes) { +int guild_member_withdraw(int guild_id, uint32 account_id, uint32 char_id, int flag, const char* name, const char* mes) { int i; struct guild* g = guild_search(guild_id); struct map_session_data* sd = map_charid2sd(char_id); @@ -839,7 +833,7 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c } #ifdef BOUND_ITEMS -void guild_retrieveitembound(int char_id,int aid,int guild_id) { +void guild_retrieveitembound(uint32 char_id,int aid,int guild_id) { TBL_PC *sd = map_id2sd(aid); if(sd){ //Character is online int idxlist[MAX_INVENTORY]; @@ -902,7 +896,7 @@ int guild_send_memberinfoshort(struct map_session_data *sd,int online) { // clea return 0; } -int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_) { // cleaned up [LuzZza] +int guild_recv_memberinfoshort(int guild_id,uint32 account_id,uint32 char_id,int online,int lv,int class_) { // cleaned up [LuzZza] int i,alv,c,idx=-1,om=0,oldonline=-1; struct guild *g = guild_search(guild_id); @@ -984,7 +978,7 @@ int guild_send_message(struct map_session_data *sd,const char *mes,int len) { /*==================================================== * Guild receive a message, will be displayed to whole member *---------------------------------------------------*/ -int guild_recv_message(int guild_id,int account_id,const char *mes,int len) { +int guild_recv_message(int guild_id,uint32 account_id,const char *mes,int len) { struct guild *g; if( (g=guild_search(guild_id))==NULL) return 0; @@ -995,7 +989,7 @@ int guild_recv_message(int guild_id,int account_id,const char *mes,int len) { /*==================================================== * Member changing position in guild *---------------------------------------------------*/ -int guild_change_memberposition(int guild_id,int account_id,int char_id,short idx) { +int guild_change_memberposition(int guild_id,uint32 account_id,uint32 char_id,short idx) { return intif_guild_change_memberinfo(guild_id,account_id,char_id,GMI_POSITION,&idx,sizeof(idx)); } @@ -1249,7 +1243,7 @@ int guild_skillup(TBL_PC* sd, uint16 skill_id) { /*==================================================== * Notification of guildskill skill_id increase request *---------------------------------------------------*/ -int guild_skillupack(int guild_id,uint16 skill_id,int account_id) { +int guild_skillupack(int guild_id,uint16 skill_id,uint32 account_id) { struct map_session_data *sd=map_id2sd(account_id); struct guild *g=guild_search(guild_id); int i; @@ -1403,7 +1397,7 @@ int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd) /*==================================================== * Player sd, answer to player tsd (account_id) for an alliance request *---------------------------------------------------*/ -int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag) { +int guild_reply_reqalliance(struct map_session_data *sd,uint32 account_id,int flag) { struct map_session_data *tsd; nullpo_ret(sd); @@ -1520,7 +1514,7 @@ int guild_opposition(struct map_session_data *sd,struct map_session_data *tsd) { /*==================================================== * Notification of a relationship between 2 guilds *---------------------------------------------------*/ -int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag,const char *name1,const char *name2) +int guild_allianceack(int guild_id1,int guild_id2,uint32 account_id1,uint32 account_id2,int flag,const char *name1,const char *name2) { struct guild *g[2]; int guild_id[2]; @@ -1700,7 +1694,7 @@ int guild_gm_change(int guild_id, struct map_session_data *sd) { } //Notification from Char server that a guild's master has changed. [Skotlex] -int guild_gm_changed(int guild_id, int account_id, int char_id) { +int guild_gm_changed(int guild_id, uint32 account_id, uint32 char_id) { struct guild *g; struct guild_member gm; int pos, i; diff --git a/src/map/guild.h b/src/map/guild.h index 7eea1212d2..3641634df0 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -39,13 +39,13 @@ struct guild_castle* guild_mapname2gc(const char* mapname); struct guild_castle* guild_mapindex2gc(short mapindex); struct map_session_data *guild_getavailablesd(struct guild *g); -int guild_getindex(struct guild *g,int account_id,int char_id); +int guild_getindex(struct guild *g,uint32 account_id,uint32 char_id); int guild_getposition(struct guild *g, struct map_session_data *sd); unsigned int guild_payexp(struct map_session_data *sd,unsigned int exp); int guild_getexp(struct map_session_data *sd,int exp); // [Celest] int guild_create(struct map_session_data *sd, const char *name); -int guild_created(int account_id,int guild_id); +int guild_created(uint32 account_id,int guild_id); int guild_request_info(int guild_id); int guild_recv_noinfo(int guild_id); int guild_recv_info(struct guild *sg); @@ -53,27 +53,27 @@ int guild_npc_request_info(int guild_id,const char *ev); int guild_invite(struct map_session_data *sd,struct map_session_data *tsd); int guild_reply_invite(struct map_session_data *sd,int guild_id,int flag); void guild_member_joined(struct map_session_data *sd); -int guild_member_added(int guild_id,int account_id,int char_id,int flag); +int guild_member_added(int guild_id,uint32 account_id,uint32 char_id,int flag); int guild_leave(struct map_session_data *sd,int guild_id, - int account_id,int char_id,const char *mes); -int guild_member_withdraw(int guild_id,int account_id,int char_id,int flag, + uint32 account_id,uint32 char_id,const char *mes); +int guild_member_withdraw(int guild_id,uint32 account_id,uint32 char_id,int flag, const char *name,const char *mes); int guild_expulsion(struct map_session_data *sd,int guild_id, - int account_id,int char_id,const char *mes); + uint32 account_id,uint32 char_id,const char *mes); int guild_skillup(struct map_session_data* sd, uint16 skill_id); void guild_block_skill(struct map_session_data *sd, int time); int guild_reqalliance(struct map_session_data *sd,struct map_session_data *tsd); -int guild_reply_reqalliance(struct map_session_data *sd,int account_id,int flag); -int guild_alliance(int guild_id1,int guild_id2,int account_id1,int account_id2); -int guild_allianceack(int guild_id1,int guild_id2,int account_id1,int account_id2, +int guild_reply_reqalliance(struct map_session_data *sd,uint32 account_id,int flag); +int guild_alliance(int guild_id1,int guild_id2,uint32 account_id1,uint32 account_id2); +int guild_allianceack(int guild_id1,int guild_id2,uint32 account_id1,uint32 account_id2, int flag,const char *name1,const char *name2); int guild_delalliance(struct map_session_data *sd,int guild_id,int flag); int guild_opposition(struct map_session_data *sd,struct map_session_data *tsd); int guild_check_alliance(int guild_id1, int guild_id2, int flag); int guild_send_memberinfoshort(struct map_session_data *sd,int online); -int guild_recv_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_); -int guild_change_memberposition(int guild_id,int account_id,int char_id,short idx); +int guild_recv_memberinfoshort(int guild_id,uint32 account_id,uint32 char_id,int online,int lv,int class_); +int guild_change_memberposition(int guild_id,uint32 account_id,uint32 char_id,short idx); int guild_memberposition_changed(struct guild *g,int idx,int pos); int guild_change_position(int guild_id,int idx,int mode,int exp_mode,const char *name); int guild_position_changed(int guild_id,int idx,struct guild_position *p); @@ -82,13 +82,13 @@ int guild_notice_changed(int guild_id,const char *mes1,const char *mes2); int guild_change_emblem(struct map_session_data *sd,int len,const char *data); int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data); int guild_send_message(struct map_session_data *sd,const char *mes,int len); -int guild_recv_message(int guild_id,int account_id,const char *mes,int len); +int guild_recv_message(int guild_id,uint32 account_id,const char *mes,int len); int guild_send_dot_remove(struct map_session_data *sd); -int guild_skillupack(int guild_id,uint16 skill_id,int account_id); +int guild_skillupack(int guild_id,uint16 skill_id,uint32 account_id); int guild_break(struct map_session_data *sd,char *name); int guild_broken(int guild_id,int flag); int guild_gm_change(int guild_id, struct map_session_data *sd); -int guild_gm_changed(int guild_id, int account_id, int char_id); +int guild_gm_changed(int guild_id, uint32 account_id, uint32 char_id); void guild_castle_map_init(void); int guild_castledatasave(int castle_id,int index,int value); @@ -107,7 +107,7 @@ void guild_flags_clear(void); void guild_guildaura_refresh(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv); #ifdef BOUND_ITEMS -void guild_retrieveitembound(int char_id,int aid,int guild_id); +void guild_retrieveitembound(uint32 char_id,int aid,int guild_id); #endif void do_final_guild(void); diff --git a/src/map/homunculus.c b/src/map/homunculus.c index ec4a8fdc2e..2577959fed 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -3,7 +3,6 @@ #include "../common/cbasetypes.h" #include "../common/malloc.h" -#include "../common/socket.h" #include "../common/timer.h" #include "../common/nullpo.h" #include "../common/mmo.h" @@ -14,30 +13,15 @@ #include "log.h" #include "clif.h" -#include "chrif.h" #include "intif.h" #include "itemdb.h" -#include "map.h" #include "pc.h" -#include "status.h" -#include "skill.h" -#include "mob.h" -#include "pet.h" -#include "battle.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" -#include "script.h" -#include "npc.h" #include "trade.h" -#include "unit.h" #include "homunculus.h" -#include #include -#include -#include struct s_homunculus_db homunculus_db[MAX_HOMUNCULUS_CLASS]; //[orn] struct homun_skill_tree_entry hskill_tree[MAX_HOMUNCULUS_CLASS][MAX_SKILL_TREE]; @@ -1076,7 +1060,7 @@ bool hom_call(struct map_session_data *sd) * @param flag : does the creation in inter-serv was a success (0:no,1:yes) * @return 0:failure, 1:sucess */ -int hom_recv_data(int account_id, struct s_homunculus *sh, int flag) +int hom_recv_data(uint32 account_id, struct s_homunculus *sh, int flag) { struct map_session_data *sd; struct homun_data *hd; @@ -1547,8 +1531,7 @@ void read_homunculus_expdb(void) if (fp == NULL) { if (i != 0) continue; - if (i == 0) - ShowError("Can't read %s\n",line); + ShowError("Can't read %s\n",line); return; } while (fgets(line, sizeof(line), fp) && j < MAX_LEVEL) { diff --git a/src/map/homunculus.h b/src/map/homunculus.h index 79365c281e..f764dba5d6 100644 --- a/src/map/homunculus.h +++ b/src/map/homunculus.h @@ -117,7 +117,7 @@ enum homun_setting { // merc_is_hom_alive(struct homun_data *) #define hom_is_active(x) (x && x->homunculus.vaporize == HOM_ST_ACTIVE && x->battle_status.hp > 0) -int hom_recv_data(int account_id, struct s_homunculus *sh, int flag); //albator +int hom_recv_data(uint32 account_id, struct s_homunculus *sh, int flag); //albator struct view_data* hom_get_viewdata(int class_); int hom_class2mapid(int hom_class); enum homun_type hom_class2type(int class_); diff --git a/src/map/instance.c b/src/map/instance.c index 3ece3bcf99..defd12d716 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -4,11 +4,9 @@ #include "../common/cbasetypes.h" #include "../common/socket.h" #include "../common/timer.h" -#include "../common/malloc.h" #include "../common/nullpo.h" #include "../common/showmsg.h" #include "../common/strlib.h" -#include "../common/utils.h" #include "../common/db.h" #include "clif.h" @@ -18,11 +16,7 @@ #include "party.h" #include "pc.h" -#include #include -#include -#include -#include #define MAX_INSTANCE_DB 15 // Max number of instance types #define INSTANCE_INTERVAL 60000 // Interval used to check when an instance is to be destroyed (ms) diff --git a/src/map/intif.c b/src/map/intif.c index 2e2e6aea7a..de0ba6ea3b 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -3,34 +3,26 @@ #include "../common/showmsg.h" #include "../common/socket.h" -#include "../common/timer.h" #include "../common/nullpo.h" #include "../common/malloc.h" #include "../common/strlib.h" +#include "../common/mmo.h" #include "map.h" #include "battle.h" #include "chrif.h" #include "clif.h" #include "pc.h" #include "intif.h" -#include "log.h" #include "storage.h" #include "party.h" -#include "guild.h" #include "pet.h" -#include "atcommand.h" #include "mercenary.h" #include "homunculus.h" #include "elemental.h" #include "mail.h" #include "quest.h" -#include -#include #include -#include -#include -#include static const int packet_len_table[]={ -1,-1,27,-1, -1, 0,37,-1, 10+NAME_LENGTH, 0, 0, 0, 0, 0, 0, 0, //0x3800-0x380f @@ -75,7 +67,7 @@ int CheckForCharServer(void) * @param pet_name * @return */ -int intif_create_pet(int account_id,int char_id,short pet_class,short pet_lv,short pet_egg_id, +int intif_create_pet(uint32 account_id,uint32 char_id,short pet_class,short pet_lv,short pet_egg_id, short pet_equip,short intimate,short hungry,char rename_flag,char incubate,char *pet_name) { if (CheckForCharServer()) @@ -105,7 +97,7 @@ int intif_create_pet(int account_id,int char_id,short pet_class,short pet_lv,sho * @param pet_id * @return */ -int intif_request_petdata(int account_id,int char_id,int pet_id) +int intif_request_petdata(uint32 account_id,uint32 char_id,int pet_id) { if (CheckForCharServer()) return 0; @@ -125,7 +117,7 @@ int intif_request_petdata(int account_id,int char_id,int pet_id) * @param p * @return */ -int intif_save_petdata(int account_id,struct s_pet *p) +int intif_save_petdata(uint32 account_id,struct s_pet *p) { if (CheckForCharServer()) return 0; @@ -462,7 +454,7 @@ int intif_request_registry(struct map_session_data *sd, int flag) * @param guild_id : Guild of player * @return 0:error, 1=msg sent */ -int intif_request_guild_storage(int account_id,int guild_id) +int intif_request_guild_storage(uint32 account_id,int guild_id) { if (CheckForCharServer()) return 0; @@ -480,7 +472,7 @@ int intif_request_guild_storage(int account_id,int guild_id) * @param gstor : Guild storage struct to save * @return */ -int intif_send_guild_storage(int account_id,struct guild_storage *gstor) +int intif_send_guild_storage(uint32 account_id,struct guild_storage *gstor) { if (CheckForCharServer()) return 0; @@ -525,7 +517,7 @@ int intif_create_party(struct party_member *member,char *name,int item,int item2 * @param char_id : Player id requesting * @return 0=error, 1=msg sent */ -int intif_request_partyinfo(int party_id, int char_id) +int intif_request_partyinfo(int party_id, uint32 char_id) { if (CheckForCharServer()) return 0; @@ -564,7 +556,7 @@ int intif_party_addmember(int party_id,struct party_member *member) * @param item : sharing item option * @return 0=error, 1=msg sent */ -int intif_party_changeoption(int party_id,int account_id,int exp,int item) +int intif_party_changeoption(int party_id,uint32 account_id,int exp,int item) { if (CheckForCharServer()) return 0; @@ -585,7 +577,7 @@ int intif_party_changeoption(int party_id,int account_id,int exp,int item) * @param char_id : cid of player to leave * @return 0:char-serv disconected, 1=msg sent */ -int intif_party_leave(int party_id,int account_id, int char_id) +int intif_party_leave(int party_id,uint32 account_id, uint32 char_id) { if (CheckForCharServer()) return 0; @@ -657,7 +649,7 @@ int intif_break_party(int party_id) * @param len : Size of the message * @return 0=error, 1=msg sent */ -int intif_party_message(int party_id,int account_id,const char *mes,int len) +int intif_party_message(int party_id,uint32 account_id,const char *mes,int len) { if (CheckForCharServer()) return 0; @@ -682,7 +674,7 @@ int intif_party_message(int party_id,int account_id,const char *mes,int len) * @param char_id : player to set as new leader * @return 0=error, 1=msg sent */ -int intif_party_leaderchange(int party_id,int account_id,int char_id) +int intif_party_leaderchange(int party_id,uint32 account_id,uint32 char_id) { if (CheckForCharServer()) return 0; @@ -797,7 +789,7 @@ int intif_guild_change_gm(int guild_id, const char* name, int len) * @param mes : quitting message (max 40) * @return 0=error, 1=msg_sent */ -int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const char *mes) +int intif_guild_leave(int guild_id,uint32 account_id,uint32 char_id,int flag,const char *mes) { if (CheckForCharServer()) return 0; @@ -822,7 +814,7 @@ int intif_guild_leave(int guild_id,int account_id,int char_id,int flag,const cha * @param class_ : player class * @return 0=error, 1=msg_sent */ -int intif_guild_memberinfoshort(int guild_id,int account_id,int char_id,int online,int lv,int class_) +int intif_guild_memberinfoshort(int guild_id,uint32 account_id,uint32 char_id,int online,int lv,int class_) { if (CheckForCharServer()) return 0; @@ -863,7 +855,7 @@ int intif_guild_break(int guild_id) * @param len : Size of the message * @return 0=error, 1=msg_sent */ -int intif_guild_message(int guild_id,int account_id,const char *mes,int len) +int intif_guild_message(int guild_id,uint32 account_id,const char *mes,int len) { if (CheckForCharServer()) return 0; @@ -914,7 +906,7 @@ int intif_guild_change_basicinfo(int guild_id,int type,const void *data,int len) * @param len : Size of value * @return 0=error, 1=msg_sent */ -int intif_guild_change_memberinfo(int guild_id,int account_id,int char_id, +int intif_guild_change_memberinfo(int guild_id,uint32 account_id,uint32 char_id, int type,const void *data,int len) { if (CheckForCharServer()) @@ -960,7 +952,7 @@ int intif_guild_position(int guild_id,int idx,struct guild_position *p) * @param max : skill max level * @return 0=error, 1=msg_sent */ -int intif_guild_skillup(int guild_id, uint16 skill_id, int account_id, int max) +int intif_guild_skillup(int guild_id, uint16 skill_id, uint32 account_id, int max) { if( CheckForCharServer() ) return 0; @@ -983,7 +975,7 @@ int intif_guild_skillup(int guild_id, uint16 skill_id, int account_id, int max) * @param flag : (GUILD_ALLIANCE_REMOVE|0|1) * @return 0=error, 1=msg_sent */ -int intif_guild_alliance(int guild_id1,int guild_id2,int account_id1,int account_id2,int flag) +int intif_guild_alliance(int guild_id1,int guild_id2,uint32 account_id1,uint32 account_id2,int flag) { if (CheckForCharServer()) return 0; @@ -1088,7 +1080,7 @@ int intif_guild_castle_datasave(int castle_id,int index, int value) * @param sh : TMp homunlus data * @return 0=error, 1=msg_sent */ -int intif_homunculus_create(int account_id, struct s_homunculus *sh) +int intif_homunculus_create(uint32 account_id, struct s_homunculus *sh) { if (CheckForCharServer()) return 0; @@ -1107,7 +1099,7 @@ int intif_homunculus_create(int account_id, struct s_homunculus *sh) * @param homun_id * @return 0=error, 1=msg sent */ -int intif_homunculus_requestload(int account_id, int homun_id) +int intif_homunculus_requestload(uint32 account_id, int homun_id) { if (CheckForCharServer()) return 0; @@ -1125,7 +1117,7 @@ int intif_homunculus_requestload(int account_id, int homun_id) * @param sh : homunculus struct * @return : 0=error, 1=msg sent */ -int intif_homunculus_requestsave(int account_id, struct s_homunculus* sh) +int intif_homunculus_requestsave(uint32 account_id, struct s_homunculus* sh) { if (CheckForCharServer()) return 0; @@ -1280,7 +1272,7 @@ int intif_parse_Registers(int fd) struct map_session_data *sd; struct global_reg *reg; int *qty; - int account_id = RFIFOL(fd,4), char_id = RFIFOL(fd,8); + uint32 account_id = RFIFOL(fd,4), char_id = RFIFOL(fd,8); struct auth_node *node = chrif_auth_check(account_id, char_id, ST_LOGIN); if (node) sd = node->sd; @@ -1601,8 +1593,8 @@ int intif_parse_GuildMemberInfoChanged(int fd) { //int len = RFIFOW(fd,2) - 18; int guild_id = RFIFOL(fd,4); - int account_id = RFIFOL(fd,8); - int char_id = RFIFOL(fd,12); + uint32 account_id = RFIFOL(fd,8); + uint32 char_id = RFIFOL(fd,12); int type = RFIFOW(fd,16); //void* data = RFIFOP(fd,18); @@ -1895,7 +1887,7 @@ void intif_request_questlog(TBL_PC *sd) */ void intif_parse_questlog(int fd) { - int char_id = RFIFOL(fd,4), num_received = (RFIFOW(fd,2) - 8) / sizeof(struct quest); + uint32 char_id = RFIFOL(fd,4), num_received = (RFIFOW(fd,2) - 8) / sizeof(struct quest); TBL_PC *sd = map_charid2sd(char_id); if(!sd) // User not online anymore @@ -1990,7 +1982,7 @@ int intif_quest_save(TBL_PC *sd) * @param flag 0 Update Inbox | 1 OpenMail * @return 0=errur, 1=msg_sent */ -int intif_Mail_requestinbox(int char_id, unsigned char flag) +int intif_Mail_requestinbox(uint32 char_id, unsigned char flag) { if (CheckForCharServer()) return 0; @@ -2068,7 +2060,7 @@ int intif_Mail_read(int mail_id) * @param mail_id : Mail identification * @return 0=error, 1=msg sent */ -int intif_Mail_getattach(int char_id, int mail_id) +int intif_Mail_getattach(uint32 char_id, int mail_id) { if (CheckForCharServer()) return 0; @@ -2119,7 +2111,7 @@ int intif_parse_Mail_getattach(int fd) * @param mail_id : mail to delete * @return 0=error, 1=msg sent */ -int intif_Mail_delete(int char_id, int mail_id) +int intif_Mail_delete(uint32 char_id, int mail_id) { if (CheckForCharServer()) return 0; @@ -2140,7 +2132,7 @@ int intif_Mail_delete(int char_id, int mail_id) */ int intif_parse_Mail_delete(int fd) { - int char_id = RFIFOL(fd,2); + uint32 char_id = RFIFOL(fd,2); int mail_id = RFIFOL(fd,6); bool failed = RFIFOB(fd,10); @@ -2179,7 +2171,7 @@ int intif_parse_Mail_delete(int fd) * @param mail_id : mail to return * @return 0=error, 1=msg sent */ -int intif_Mail_return(int char_id, int mail_id) +int intif_Mail_return(uint32 char_id, int mail_id) { if (CheckForCharServer()) return 0; @@ -2238,7 +2230,7 @@ int intif_parse_Mail_return(int fd) * @param msg : mail struct * @return 0=error, 1=msg sent */ -int intif_Mail_send(int account_id, struct mail_message *msg) +int intif_Mail_send(uint32 account_id, struct mail_message *msg) { int len = sizeof(struct mail_message) + 8; @@ -2283,7 +2275,7 @@ static void intif_parse_Mail_send(int fd) else { clif_Mail_send(sd->fd, false); - if( save_settings&16 ) + if( save_settings&CHARSAVE_MAIL ) chrif_save(sd, 0); } } @@ -2321,7 +2313,7 @@ static void intif_parse_Mail_new(int fd) * @param page : in case of huge result list display 5 entry per page, (kinda suck that we redo the request atm) * @return 0=error, 1=msg sent */ -int intif_Auction_requestlist(int char_id, short type, int price, const char* searchtext, short page) +int intif_Auction_requestlist(uint32 char_id, short type, int price, const char* searchtext, short page) { int len = NAME_LENGTH + 16; @@ -2401,7 +2393,7 @@ static void intif_parse_Auction_register(int fd) if( auction.auction_id > 0 ) { clif_Auction_message(sd->fd, 1); // Confirmation Packet ?? - if( save_settings&32 ) + if( save_settings&CHARSAVE_AUCTION ) chrif_save(sd,0); } else @@ -2421,7 +2413,7 @@ static void intif_parse_Auction_register(int fd) * @param auction_id : auction to cancel * @return 0=error, 1=msg sent */ -int intif_Auction_cancel(int char_id, unsigned int auction_id) +int intif_Auction_cancel(uint32 char_id, unsigned int auction_id) { if( CheckForCharServer() ) return 0; @@ -2462,7 +2454,7 @@ static void intif_parse_Auction_cancel(int fd) * @param auction_id : auction to stop * @return 0=error, 1=msg sent */ -int intif_Auction_close(int char_id, unsigned int auction_id) +int intif_Auction_close(uint32 char_id, unsigned int auction_id) { if( CheckForCharServer() ) return 0; @@ -2505,7 +2497,7 @@ static void intif_parse_Auction_close(int fd) * @param bid * @return 0=error, 1=msg sent */ -int intif_Auction_bid(int char_id, const char* name, unsigned int auction_id, int bid) +int intif_Auction_bid(uint32 char_id, const char* name, unsigned int auction_id, int bid) { int len = 16 + NAME_LENGTH; @@ -2614,7 +2606,7 @@ int intif_parse_mercenary_received(int fd) * @param char_id : player cid requesting data * @return 0=error, 1=msg sent */ -int intif_mercenary_request(int merc_id, int char_id) +int intif_mercenary_request(int merc_id, uint32 char_id) { if (CheckForCharServer()) return 0; @@ -2739,7 +2731,7 @@ int intif_parse_elemental_received(int fd) * @param char_id : player identification * @return 0=error, 1=msg sent */ -int intif_elemental_request(int ele_id, int char_id) +int intif_elemental_request(int ele_id, uint32 char_id) { if (CheckForCharServer()) return 0; @@ -2888,7 +2880,7 @@ void intif_parse_MessageToFD(int fd) { * @param aid : Account to delete item ID * @param guild_id : Guild of char */ -void intif_itembound_req(int char_id,int aid,int guild_id) { +void intif_itembound_req(uint32 char_id, uint32 aid,int guild_id) { struct guild_storage *gstor = guild2storage2(guild_id); if( CheckForCharServer() ) diff --git a/src/map/intif.h b/src/map/intif.h index 98c6859dd8..b2534291ec 100644 --- a/src/map/intif.h +++ b/src/map/intif.h @@ -27,54 +27,54 @@ int intif_wis_message_to_gm(char *Wisp_name, int permission, char *mes); int intif_saveregistry(struct map_session_data *sd, int type); int intif_request_registry(struct map_session_data *sd, int flag); -int intif_request_guild_storage(int account_id, int guild_id); -int intif_send_guild_storage(int account_id, struct guild_storage *gstor); +int intif_request_guild_storage(uint32 account_id, int guild_id); +int intif_send_guild_storage(uint32 account_id, struct guild_storage *gstor); int intif_create_party(struct party_member *member,char *name,int item,int item2); -int intif_request_partyinfo(int party_id, int char_id); +int intif_request_partyinfo(int party_id, uint32 char_id); int intif_party_addmember(int party_id,struct party_member *member); -int intif_party_changeoption(int party_id, int account_id, int exp, int item); -int intif_party_leave(int party_id,int account_id, int char_id); +int intif_party_changeoption(int party_id, uint32 account_id, int exp, int item); +int intif_party_leave(int party_id,uint32 account_id, uint32 char_id); int intif_party_changemap(struct map_session_data *sd, int online); int intif_break_party(int party_id); -int intif_party_message(int party_id, int account_id, const char *mes,int len); -int intif_party_leaderchange(int party_id,int account_id,int char_id); +int intif_party_message(int party_id, uint32 account_id, const char *mes,int len); +int intif_party_leaderchange(int party_id,uint32 account_id,uint32 char_id); int intif_party_sharelvlupdate(unsigned int share_lvl); int intif_guild_create(const char *name, const struct guild_member *master); int intif_guild_request_info(int guild_id); int intif_guild_addmember(int guild_id, struct guild_member *m); -int intif_guild_leave(int guild_id, int account_id, int char_id, int flag, const char *mes); -int intif_guild_memberinfoshort(int guild_id, int account_id, int char_id, int online, int lv, int class_); +int intif_guild_leave(int guild_id, uint32 account_id, uint32 char_id, int flag, const char *mes); +int intif_guild_memberinfoshort(int guild_id, uint32 account_id, uint32 char_id, int online, int lv, int class_); int intif_guild_break(int guild_id); -int intif_guild_message(int guild_id, int account_id, const char *mes, int len); +int intif_guild_message(int guild_id, uint32 account_id, const char *mes, int len); int intif_guild_change_gm(int guild_id, const char* name, int len); int intif_guild_change_basicinfo(int guild_id, int type, const void *data, int len); -int intif_guild_change_memberinfo(int guild_id, int account_id, int char_id, int type, const void *data, int len); +int intif_guild_change_memberinfo(int guild_id, uint32 account_id, uint32 char_id, int type, const void *data, int len); int intif_guild_position(int guild_id, int idx, struct guild_position *p); -int intif_guild_skillup(int guild_id, uint16 skill_id, int account_id, int max); -int intif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag); +int intif_guild_skillup(int guild_id, uint16 skill_id, uint32 account_id, int max); +int intif_guild_alliance(int guild_id1, int guild_id2, uint32 account_id1, uint32 account_id2, int flag); int intif_guild_notice(int guild_id, const char *mes1, const char *mes2); int intif_guild_emblem(int guild_id, int len, const char *data); int intif_guild_castle_dataload(int num, int *castle_ids); int intif_guild_castle_datasave(int castle_id, int index, int value); #ifdef BOUND_ITEMS -void intif_itembound_req(int char_id, int aid, int guild_id); +void intif_itembound_req(uint32 char_id, uint32 aid, int guild_id); #endif -int intif_create_pet(int account_id, int char_id, short pet_type, short pet_lv, short pet_egg_id, +int intif_create_pet(uint32 account_id, uint32 char_id, short pet_type, short pet_lv, short pet_egg_id, short pet_equip, short intimate, short hungry, char rename_flag, char incubate, char *pet_name); -int intif_request_petdata(int account_id, int char_id, int pet_id); -int intif_save_petdata(int account_id, struct s_pet *p); +int intif_request_petdata(uint32 account_id, uint32 char_id, int pet_id); +int intif_save_petdata(uint32 account_id, struct s_pet *p); int intif_delete_petdata(int pet_id); int intif_rename(struct map_session_data *sd, int type, char *name); #define intif_rename_pc(sd, name) intif_rename(sd, 0, name) #define intif_rename_pet(sd, name) intif_rename(sd, 1, name) #define intif_rename_hom(sd, name) intif_rename(sd, 2, name) -int intif_homunculus_create(int account_id, struct s_homunculus *sh); -int intif_homunculus_requestload(int account_id, int homun_id); -int intif_homunculus_requestsave(int account_id, struct s_homunculus* sh); +int intif_homunculus_create(uint32 account_id, struct s_homunculus *sh); +int intif_homunculus_requestload(uint32 account_id, int homun_id); +int intif_homunculus_requestsave(uint32 account_id, struct s_homunculus* sh); int intif_homunculus_requestdelete(int homun_id); /******QUEST SYTEM*******/ @@ -83,26 +83,26 @@ int intif_quest_save(struct map_session_data * sd); // MERCENARY SYSTEM int intif_mercenary_create(struct s_mercenary *merc); -int intif_mercenary_request(int merc_id, int char_id); +int intif_mercenary_request(int merc_id, uint32 char_id); int intif_mercenary_delete(int merc_id); int intif_mercenary_save(struct s_mercenary *merc); // MAIL SYSTEM -int intif_Mail_requestinbox(int char_id, unsigned char flag); +int intif_Mail_requestinbox(uint32 char_id, unsigned char flag); int intif_Mail_read(int mail_id); -int intif_Mail_getattach(int char_id, int mail_id); -int intif_Mail_delete(int char_id, int mail_id); -int intif_Mail_return(int char_id, int mail_id); -int intif_Mail_send(int account_id, struct mail_message *msg); +int intif_Mail_getattach(uint32 char_id, int mail_id); +int intif_Mail_delete(uint32 char_id, int mail_id); +int intif_Mail_return(uint32 char_id, int mail_id); +int intif_Mail_send(uint32 account_id, struct mail_message *msg); // AUCTION SYSTEM -int intif_Auction_requestlist(int char_id, short type, int price, const char* searchtext, short page); +int intif_Auction_requestlist(uint32 char_id, short type, int price, const char* searchtext, short page); 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); +int intif_Auction_cancel(uint32 char_id, unsigned int auction_id); +int intif_Auction_close(uint32 char_id, unsigned int auction_id); +int intif_Auction_bid(uint32 char_id, const char* name, unsigned int auction_id, int bid); // ELEMENTAL SYSTEM int intif_elemental_create(struct s_elemental *ele); -int intif_elemental_request(int ele_id, int char_id); +int intif_elemental_request(int ele_id, uint32 char_id); int intif_elemental_delete(int ele_id); int intif_elemental_save(struct s_elemental *ele); diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 10a13b7f5b..1c10975fb6 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -8,16 +8,11 @@ #include "../common/strlib.h" #include "../common/utils.h" #include "itemdb.h" -#include "map.h" #include "battle.h" // struct battle_config #include "cashshop.h" -#include "script.h" // item script processing -#include "pc.h" // W_MUSICAL, W_WHIP #include "intif.h" -#include #include -#include static DBMap *itemdb; /// Item DB static DBMap *itemdb_combo; /// Item Combo DB @@ -1472,9 +1467,7 @@ bool itemdb_is_spellbook2(unsigned short nameid) { if (!nameid || !itemdb_exists(nameid) || !skill_spellbook_count) return false; ARR_FIND(0, MAX_SKILL_SPELLBOOK_DB, i, skill_spellbook_db[i].nameid == nameid); - if (i == MAX_SKILL_SPELLBOOK_DB) - return false; - return true; + return i == MAX_SKILL_SPELLBOOK_DB ? false : true; } /** diff --git a/src/map/log.c b/src/map/log.c index 359ec4d4da..e5ff9d0147 100644 --- a/src/map/log.c +++ b/src/map/log.c @@ -13,9 +13,8 @@ #include "mob.h" #include "pc.h" -#include #include -#include + /// filters for item logging typedef enum e_log_filter diff --git a/src/map/mail.c b/src/map/mail.c index 360e5c7213..a5acb13815 100644 --- a/src/map/mail.c +++ b/src/map/mail.c @@ -10,12 +10,8 @@ #include "itemdb.h" #include "clif.h" #include "pc.h" -#include "log.h" #include "intif.h" -#include -#include - void mail_clear(struct map_session_data *sd) { sd->mail.nameid = 0; diff --git a/src/map/map.c b/src/map/map.c index a3be12a046..ae6f1223bc 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -23,41 +23,24 @@ #include "intif.h" #include "npc.h" #include "pc.h" -#include "status.h" -#include "mob.h" -#include "npc.h" // npc_setcells(), npc_unsetcells() #include "chat.h" -#include "itemdb.h" #include "storage.h" -#include "skill.h" #include "trade.h" #include "party.h" -#include "unit.h" -#include "battle.h" #include "battleground.h" #include "quest.h" -#include "script.h" #include "mapreg.h" -#include "guild.h" #include "pet.h" #include "homunculus.h" #include "instance.h" #include "mercenary.h" #include "elemental.h" -#include "atcommand.h" -#include "log.h" -#include "mail.h" #include "cashshop.h" #include "channel.h" -#include "vending.h" -#include #include -#include -#include #include #ifndef _WIN32 -#include #endif char default_codepage[32] = ""; @@ -100,8 +83,8 @@ static DBMap* pc_db=NULL; /// int id -> struct map_session_data* static DBMap* mobid_db=NULL; /// int id -> struct mob_data* static DBMap* bossid_db=NULL; /// int id -> struct mob_data* (MVP db) static DBMap* map_db=NULL; /// unsigned int mapindex -> struct map_data* -static DBMap* nick_db=NULL; /// int char_id -> struct charid2nick* (requested names of offline characters) -static DBMap* charid_db=NULL; /// int char_id -> struct map_session_data* +static DBMap* nick_db=NULL; /// uint32 char_id -> struct charid2nick* (requested names of offline characters) +static DBMap* charid_db=NULL; /// uint32 char_id -> struct map_session_data* static DBMap* regen_db=NULL; /// int id -> struct block_list* (status_natural_heal processing) static DBMap* map_msg_db=NULL; @@ -124,7 +107,7 @@ int map_port=0; int autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; int minsave_interval = 100; -int save_settings = 0xFFFF; +unsigned char save_settings = CHARSAVE_ALL; int agit_flag = 0; int agit2_flag = 0; int night_flag = 0; // 0=day, 1=night [Yor] @@ -3596,7 +3579,7 @@ int map_config_read(char *cfgName) if (minsave_interval < 1) minsave_interval = 1; } else if (strcmpi(w1, "save_settings") == 0) - save_settings = atoi(w2); + save_settings = cap_value(atoi(w2),CHARSAVE_NONE,CHARSAVE_ALL); else if (strcmpi(w1, "motd_txt") == 0) strcpy(motd_txt, w2); else if (strcmpi(w1, "help_txt") == 0) @@ -3788,8 +3771,13 @@ int map_sql_init(void) mmysql_handle = Sql_Malloc(); ShowInfo("Connecting to the Map DB Server....\n"); - if( SQL_ERROR == Sql_Connect(mmysql_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) ) - exit(EXIT_FAILURE); + if( SQL_ERROR == Sql_Connect(mmysql_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) ){ + ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n", + map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db); + Sql_ShowDebug(mmysql_handle); + Sql_Free(mmysql_handle); + exit(EXIT_FAILURE); + } ShowStatus("Connect success! (Map Server Connection)\n"); if( strlen(default_codepage) > 0 ) @@ -3822,8 +3810,13 @@ int log_sql_init(void) logmysql_handle = Sql_Malloc(); ShowInfo(""CL_WHITE"[SQL]"CL_RESET": Connecting to the Log Database "CL_WHITE"%s"CL_RESET" At "CL_WHITE"%s"CL_RESET"...\n",log_db_db,log_db_ip); - if ( SQL_ERROR == Sql_Connect(logmysql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db) ) + if ( SQL_ERROR == Sql_Connect(logmysql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db) ){ + ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n", + log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db); + Sql_ShowDebug(logmysql_handle); + Sql_Free(logmysql_handle); exit(EXIT_FAILURE); + } ShowStatus(""CL_WHITE"[SQL]"CL_RESET": Successfully '"CL_GREEN"connected"CL_RESET"' to Database '"CL_WHITE"%s"CL_RESET"'.\n", log_db_db); if( strlen(default_codepage) > 0 ) diff --git a/src/map/map.h b/src/map/map.h index 1bbd442b1f..10906d083f 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -740,7 +740,7 @@ extern int map_num; extern int autosave_interval; extern int minsave_interval; -extern int save_settings; +extern unsigned char save_settings; extern int agit_flag; extern int agit2_flag; extern int night_flag; // 0=day, 1=night [Yor] @@ -753,6 +753,20 @@ extern char charhelp_txt[]; extern char wisp_server_name[]; +/// Type of 'save_settings' +enum save_settings_type { + CHARSAVE_NONE = 0, + CHARSAVE_TRADE = 0x01, /// After trading + CHARSAVE_VENDING = 0x02, /// After vending (open/transaction) + CHARSAVE_STORAGE = 0x04, /// After closing storage/guild storage. + CHARSAVE_PET = 0x08, /// After hatching/returning to egg a pet. + CHARSAVE_MAIL = 0x10, /// After successfully sending a mail with attachment + CHARSAVE_AUCTION = 0x20, /// After successfully submitting an item for auction + CHARSAVE_QUEST = 0x40, /// After successfully get/delete/complete a quest + CHARSAVE_BANK = 0x80, /// After every bank transaction (deposit/withdraw) + CHARSAVE_ALL = 0xFF, +}; + // users void map_setusers(int); int map_getusers(void); diff --git a/src/map/mapreg.c b/src/map/mapreg.c index ca3b185bcb..9bb7091bdc 100644 --- a/src/map/mapreg.c +++ b/src/map/mapreg.c @@ -4,14 +4,12 @@ #include "../common/cbasetypes.h" #include "../common/db.h" #include "../common/malloc.h" -#include "../common/showmsg.h" #include "../common/sql.h" #include "../common/strlib.h" #include "../common/timer.h" #include "map.h" // mmysql_handle #include "script.h" #include -#include static DBMap* mapreg_db = NULL; // int var_id -> int value static DBMap* mapregstr_db = NULL; // int var_id -> char* value @@ -20,6 +18,7 @@ static char mapreg_table[32] = "mapreg"; 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) { diff --git a/src/map/mercenary.c b/src/map/mercenary.c index d00fa4654d..b6485fa66f 100644 --- a/src/map/mercenary.c +++ b/src/map/mercenary.c @@ -3,7 +3,6 @@ #include "../common/cbasetypes.h" #include "../common/malloc.h" -#include "../common/socket.h" #include "../common/timer.h" #include "../common/nullpo.h" #include "../common/mmo.h" @@ -14,28 +13,14 @@ #include "log.h" #include "clif.h" -#include "chrif.h" #include "intif.h" #include "itemdb.h" -#include "map.h" #include "pc.h" -#include "status.h" -#include "skill.h" -#include "mob.h" -#include "pet.h" -#include "battle.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" -#include "script.h" -#include "npc.h" #include "trade.h" -#include "unit.h" #include "mercenary.h" -#include #include -#include #include struct s_mercenary_db mercenary_db[MAX_MERCENARY_CLASS]; // Mercenary Database diff --git a/src/map/mob.c b/src/map/mob.c index e721cab83a..4b55a4fcc2 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -19,27 +19,13 @@ #include "intif.h" #include "pc.h" #include "pet.h" -#include "status.h" -#include "mob.h" #include "homunculus.h" #include "mercenary.h" #include "elemental.h" -#include "guild.h" -#include "itemdb.h" -#include "skill.h" -#include "battle.h" #include "party.h" -#include "npc.h" -#include "log.h" -#include "script.h" -#include "atcommand.h" -#include "date.h" #include "quest.h" -#include #include -#include -#include #include #define ACTIVE_AI_RANGE 2 //Distance added on top of 'AREA_SIZE' at which mobs enter active AI mode. @@ -1971,7 +1957,8 @@ int mob_respawn(int tid, unsigned int tick, int id, intptr_t data) void mob_log_damage(struct mob_data *md, struct block_list *src, int damage) { - int char_id = 0, flag = MDLF_NORMAL; + uint32 char_id = 0; + int flag = MDLF_NORMAL; if( damage < 0 ) return; //Do nothing for absorbed damage. diff --git a/src/map/npc.c b/src/map/npc.c index da86cdfb9e..00ff00d211 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -10,32 +10,19 @@ #include "../common/utils.h" #include "../common/ers.h" #include "../common/db.h" -#include "../common/socket.h" #include "map.h" -#include "mapreg.h" #include "log.h" #include "clif.h" #include "intif.h" #include "pc.h" -#include "status.h" -#include "itemdb.h" -#include "script.h" -#include "mob.h" #include "pet.h" #include "instance.h" -#include "battle.h" -#include "skill.h" -#include "unit.h" -#include "npc.h" #include "chat.h" -#include #include -#include -#include -#include #include + struct npc_data* fake_nd; // linked list of npc source files diff --git a/src/map/npc_chat.c b/src/map/npc_chat.c index 92bbf6dda0..6033b83c11 100644 --- a/src/map/npc_chat.c +++ b/src/map/npc_chat.c @@ -5,21 +5,14 @@ #include "../common/timer.h" #include "../common/malloc.h" -#include "../common/nullpo.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "mob.h" // struct mob_data -#include "npc.h" // struct npc_data #include "pc.h" // struct map_session_data -#include "script.h" // set_var() #include "../../3rdparty/pcre/include/pcre.h" -#include -#include -#include -#include /** * Written by MouseJstr in a vision... (2/21/2005) diff --git a/src/map/party.c b/src/map/party.c index b10b766639..9ff31fec0c 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -14,23 +14,15 @@ #include "party.h" #include "atcommand.h" //msg_txt() #include "pc.h" -#include "map.h" #include "instance.h" -#include "battle.h" #include "intif.h" -#include "clif.h" -#include "log.h" -#include "skill.h" -#include "status.h" -#include "itemdb.h" #include "mapreg.h" -#include #include -#include + static DBMap* party_db; // int party_id -> struct party_data* (releases data) -static DBMap* party_booking_db; // int char_id -> struct party_booking_ad_info* (releases data) // Party Booking [Spiria] +static DBMap* party_booking_db; // uint32 char_id -> struct party_booking_ad_info* (releases data) // Party Booking [Spiria] static unsigned long party_booking_nextid = 1; int party_send_xy_timer(int tid, unsigned int tick, int id, intptr_t data); @@ -57,19 +49,14 @@ static void party_fill_member(struct party_member* member, struct map_session_da int party_getmemberid(struct party_data* p, struct map_session_data* sd) { int member_id; - nullpo_retr(-1, p); - if( sd == NULL ) - return -1; // no player - + return -1;// no player ARR_FIND(0, MAX_PARTY, member_id, p->party.member[member_id].account_id == sd->status.account_id && p->party.member[member_id].char_id == sd->status.char_id); - if( member_id == MAX_PARTY ) - return -1; // not found - + return -1;// not found return member_id; } @@ -79,18 +66,16 @@ int party_getmemberid(struct party_data* p, struct map_session_data* sd) struct map_session_data* party_getavailablesd(struct party_data *p) { int i; - nullpo_retr(NULL, p); - ARR_FIND(0, MAX_PARTY, i, p->data[i].sd != NULL); - return( i < MAX_PARTY ) ? p->data[i].sd : NULL; } /*========================================== * Retrieves and validates the sd pointer for this party member [Skotlex] *------------------------------------------*/ -static TBL_PC* party_sd_check(int party_id, int account_id, int char_id) + +static TBL_PC* party_sd_check(int party_id, uint32 account_id, uint32 char_id) { TBL_PC* sd = map_id2sd(account_id); @@ -98,9 +83,9 @@ static TBL_PC* party_sd_check(int party_id, int account_id, int char_id) return NULL; if( sd->status.party_id == 0 ) - sd->status.party_id = party_id; // auto-join if not in a party - - if (sd->status.party_id != party_id) { // If player belongs to a different party, kick him out. + sd->status.party_id = party_id;// auto-join if not in a party + if (sd->status.party_id != party_id) + { //If player belongs to a different party, kick him out. intif_party_leave(party_id,account_id,char_id); return NULL; } @@ -117,7 +102,6 @@ void do_final_party(void) party_db->destroy(party_db,NULL); party_booking_db->destroy(party_booking_db,NULL); // Party Booking [Spiria] } - // Constructor, init vars void do_init_party(void) { @@ -132,7 +116,6 @@ struct party_data* party_search(int party_id) { if(!party_id) return NULL; - return (struct party_data*)idb_get(party_db,party_id); } @@ -173,7 +156,7 @@ int party_create(struct map_session_data *sd,char *name,int item,int item2) return 1; } -void party_created(int account_id,int char_id,int fail,int party_id,char *name) +void party_created(uint32 account_id,uint32 char_id,int fail,int party_id,char *name) { struct map_session_data *sd; @@ -200,13 +183,13 @@ void party_created(int account_id,int char_id,int fail,int party_id,char *name) clif_party_created(sd,1); // "party name already exists" } -int party_request_info(int party_id, int char_id) +int party_request_info(int party_id, uint32 char_id) { return intif_request_partyinfo(party_id, char_id); } /// Invoked (from char-server) when the party info is not found. -int party_recv_noinfo(int party_id, int char_id) +int party_recv_noinfo(int party_id, uint32 char_id) { party_broken(party_id); if( char_id != 0 ) { // requester @@ -251,7 +234,7 @@ static void party_check_state(struct party_data *p) } } -int party_recv_info(struct party* sp, int char_id) +int party_recv_info(struct party* sp, uint32 char_id) { struct party_data* p; struct party_member* member; @@ -438,7 +421,6 @@ int party_reply_invite(struct map_session_data *sd,int party_id,int flag) if( tsd != NULL ) clif_party_inviteack(tsd,sd->status.name,1); - return 0; } return 0; @@ -471,7 +453,7 @@ void party_member_joined(struct map_session_data *sd) /// Invoked (from char-server) when a new member is added to the party. /// flag: 0-success, 1-failure -int party_member_added(int party_id,int account_id,int char_id, int flag) +int party_member_added(int party_id,uint32 account_id,uint32 char_id, int flag) { struct map_session_data *sd = map_id2sd(account_id),*sd2; struct party_data *p = party_search(party_id); @@ -528,7 +510,7 @@ int party_member_added(int party_id,int account_id,int char_id, int flag) } /// Party member 'sd' requesting kick of member with . -int party_removemember(struct map_session_data* sd, int account_id, char* name) +int party_removemember(struct map_session_data* sd, uint32 account_id, char* name) { struct party_data *p; int i; @@ -554,14 +536,12 @@ int party_removemember(struct map_session_data* sd, int account_id, char* name) return 1; } -int party_removemember2(struct map_session_data *sd,int char_id,int party_id) +int party_removemember2(struct map_session_data *sd,uint32 char_id,int party_id) { if( sd ) { if( !sd->status.party_id ) return -3; - intif_party_leave(sd->status.party_id,sd->status.account_id,sd->status.char_id); - return 1; } else { int i; @@ -573,13 +553,9 @@ int party_removemember2(struct map_session_data *sd,int char_id,int party_id) ARR_FIND(0,MAX_PARTY,i,p->party.member[i].char_id == char_id ); if( i >= MAX_PARTY ) return -1; - intif_party_leave(party_id,p->party.member[i].account_id,char_id); - return 1; } - - return 0; } /// Party member 'sd' requesting exit from party. @@ -602,14 +578,13 @@ int party_leave(struct map_session_data *sd) } /// Invoked (from char-server) when a party member leaves the party. -int party_member_withdraw(int party_id, int account_id, int char_id) +int party_member_withdraw(int party_id, uint32 account_id, uint32 char_id) { struct map_session_data* sd = map_id2sd(account_id); struct party_data* p = party_search(party_id); if( p ) { int i; - ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id ); if( i < MAX_PARTY ) { clif_party_withdraw(p,sd,account_id,p->party.member[i].name,0x0); @@ -721,7 +696,7 @@ int party_setoption(struct party_data *party, int option, int flag) return 1; } -int party_optionchanged(int party_id,int account_id,int exp,int item,int flag) +int party_optionchanged(int party_id,uint32 account_id,int exp,int item,int flag) { struct party_data *p; struct map_session_data *sd=map_id2sd(account_id); @@ -798,7 +773,7 @@ int party_changeleader(struct map_session_data *sd, struct map_session_data *tsd /// - changes maps /// - logs in or out /// - gains a level (disabled) -int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map_idx,int online,int lv) +int party_recv_movemap(int party_id,uint32 account_id,uint32 char_id, unsigned short map_idx,int online,int lv) { struct party_member* m; struct party_data* p; @@ -836,10 +811,8 @@ void party_send_movemap(struct map_session_data *sd) intif_party_changemap(sd,1); - p = party_search(sd->status.party_id); - - if (!p) - return; + p=party_search(sd->status.party_id); + if (!p) return; if(sd->state.connect_new) { //Note that this works because this function is invoked before connect_new is cleared. @@ -877,10 +850,8 @@ int party_send_logout(struct map_session_data *sd) return 0; intif_party_changemap(sd,0); - p = party_search(sd->status.party_id); - - if(!p) - return 0; + p=party_search(sd->status.party_id); + if(!p) return 0; ARR_FIND( 0, MAX_PARTY, i, p->data[i].sd == sd ); if( i < MAX_PARTY ) @@ -895,7 +866,6 @@ int party_send_message(struct map_session_data *sd,const char *mes,int len) { if(sd->status.party_id == 0) return 0; - intif_party_message(sd->status.party_id,sd->status.account_id,mes,len); party_recv_message(sd->status.party_id,sd->status.account_id,mes,len); @@ -905,15 +875,12 @@ int party_send_message(struct map_session_data *sd,const char *mes,int len) return 0; } -int party_recv_message(int party_id,int account_id,const char *mes,int len) +int party_recv_message(int party_id,uint32 account_id,const char *mes,int len) { struct party_data *p; - - if( (p = party_search(party_id)) == NULL) + if( (p=party_search(party_id))==NULL) return 0; - clif_party_message(p,account_id,mes,len); - return 0; } @@ -925,7 +892,6 @@ int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id if(!party_id || (p = party_search(party_id)) == NULL) return 0; - switch(skill_id) { case TK_COUNTER: //Increase Triple Attack rate of Monks. if (!p->state.monk) return 0; diff --git a/src/map/party.h b/src/map/party.h index 68dbadf718..66a048eb47 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -57,22 +57,22 @@ int party_getmemberid(struct party_data* p, struct map_session_data* sd); struct map_session_data* party_getavailablesd(struct party_data *p); int party_create(struct map_session_data *sd,char *name, int item, int item2); -void party_created(int account_id,int char_id,int fail,int party_id,char *name); -int party_request_info(int party_id, int char_id); +void party_created(uint32 account_id,uint32 char_id,int fail,int party_id,char *name); +int party_request_info(int party_id, uint32 char_id); int party_invite(struct map_session_data *sd,struct map_session_data *tsd); void party_member_joined(struct map_session_data *sd); -int party_member_added(int party_id,int account_id,int char_id,int flag); +int party_member_added(int party_id,uint32 account_id,uint32 char_id,int flag); int party_leave(struct map_session_data *sd); -int party_removemember(struct map_session_data *sd,int account_id,char *name); -int party_removemember2(struct map_session_data *sd,int char_id,int party_id); -int party_member_withdraw(int party_id,int account_id,int char_id); +int party_removemember(struct map_session_data *sd,uint32 account_id,char *name); +int party_removemember2(struct map_session_data *sd,uint32 char_id,int party_id); +int party_member_withdraw(int party_id,uint32 account_id,uint32 char_id); int party_reply_invite(struct map_session_data *sd,int party_id,int flag); #define party_add_member(party_id,sd) party_reply_invite(sd,party_id,1) -int party_recv_noinfo(int party_id, int char_id); -int party_recv_info(struct party* sp, int char_id); -int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map,int online,int lv); +int party_recv_noinfo(int party_id, uint32 char_id); +int party_recv_info(struct party* sp, uint32 char_id); +int party_recv_movemap(int party_id,uint32 account_id,uint32 char_id, unsigned short map,int online,int lv); int party_broken(int party_id); -int party_optionchanged(int party_id,int account_id,int exp,int item,int flag); +int party_optionchanged(int party_id,uint32 account_id,int exp,int item,int flag); int party_changeoption(struct map_session_data *sd,int exp,int item); int party_setoption(struct party_data *party, int option, int flag); int party_changeleader(struct map_session_data *sd, struct map_session_data *t_sd, struct party_data *p); @@ -80,7 +80,7 @@ void party_send_movemap(struct map_session_data *sd); void party_send_levelup(struct map_session_data *sd); int party_send_logout(struct map_session_data *sd); int party_send_message(struct map_session_data *sd,const char *mes,int len); -int party_recv_message(int party_id,int account_id,const char *mes,int len); +int party_recv_message(int party_id,uint32 account_id,const char *mes,int len); int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id, uint16 skill_lv); int party_send_xy_clear(struct party_data *p); int party_exp_share(struct party_data *p,struct block_list *src,unsigned int base_exp,unsigned int job_exp,int zeny); diff --git a/src/map/path.h b/src/map/path.h index 2b8f86bc0b..4672ae781a 100644 --- a/src/map/path.h +++ b/src/map/path.h @@ -22,8 +22,6 @@ struct shootpath_data { int y[MAX_WALKPATH]; }; -struct path_interface *path; - #define check_distance_bl(bl1, bl2, distance) check_distance((bl1)->x - (bl2)->x, (bl1)->y - (bl2)->y, distance) #define check_distance_blxy(bl, x1, y1, distance) check_distance((bl)->x-(x1), (bl)->y-(y1), distance) #define check_distance_xy(x0, y0, x1, y1, distance) check_distance((x0)-(x1), (y0)-(y1), distance) diff --git a/src/map/pc.c b/src/map/pc.c index d8d7995983..9e81d88abf 100755 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -20,34 +20,18 @@ #include "channel.h" #include "chat.h" #include "chrif.h" -#include "clif.h" #include "date.h" // is_day_of_*() #include "duel.h" #include "intif.h" -#include "itemdb.h" -#include "log.h" -#include "mail.h" -#include "path.h" #include "homunculus.h" #include "instance.h" #include "mercenary.h" #include "elemental.h" -#include "npc.h" // fake_nd #include "pet.h" // pet_unlocktarget() #include "party.h" // party_search() -#include "guild.h" // guild_search(), guild_request_info() -#include "script.h" // script_config -#include "skill.h" -#include "status.h" // struct status_data #include "storage.h" -#include "pc.h" -#include "pc_groups.h" -#include "quest.h" -#include #include -#include -#include #include int pc_split_atoui(char* str, unsigned int* val, char sep, int max); @@ -406,7 +390,7 @@ void pc_addfame(struct map_session_data *sd,int count) * @param job Job use enum e_mapid * @return Rank */ -unsigned char pc_famerank(int char_id, int job) +unsigned char pc_famerank(uint32 char_id, int job) { uint8 i; @@ -670,7 +654,7 @@ void pc_makesavestatus(struct map_session_data *sd) /*========================================== * Off init ? Connection? *------------------------------------------*/ -void pc_setnewpc(struct map_session_data *sd, int account_id, int char_id, int login_id1, unsigned int client_tick, int sex, int fd) +void pc_setnewpc(struct map_session_data *sd, uint32 account_id, uint32 char_id, int login_id1, unsigned int client_tick, int sex, int fd) { nullpo_retv(sd); @@ -733,7 +717,7 @@ void pc_setinventorydata(struct map_session_data *sd) /** * 'Calculates' weapon type -* @param sd +* @param sd : player */ void pc_calcweapontype(struct map_session_data *sd) { @@ -779,7 +763,7 @@ void pc_calcweapontype(struct map_session_data *sd) /** * Set equip index -* @param sd +* @param sd : Player */ void pc_setequipindex(struct map_session_data *sd) { @@ -1089,7 +1073,7 @@ bool pc_isequip(struct map_session_data *sd,int n) * No problem with the session id * set the status that has been sent from char server *------------------------------------------*/ -bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers) +bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers) { int i; #ifdef BOUND_ITEMS @@ -2164,13 +2148,13 @@ void pc_delautobonus(struct map_session_data* sd, struct s_autobonus *autobonus, if( autobonus[i].bonus_script ) { int j; - unsigned int equip_pos = 0; + unsigned int equip_pos_idx = 0; //Create a list of all equipped positions to see if all items needed for the autobonus are still present [Playtester] for(j = 0; j < EQI_MAX; j++) { if(sd->equip_index[j] >= 0) - equip_pos |= sd->status.inventory[sd->equip_index[j]].equip; + equip_pos_idx |= sd->status.inventory[sd->equip_index[j]].equip; } - if((equip_pos&autobonus[i].pos) == autobonus[i].pos) + if((equip_pos_idx&autobonus[i].pos) == autobonus[i].pos) script_run_autobonus(autobonus[i].bonus_script,sd,autobonus[i].pos); } continue; @@ -2198,13 +2182,13 @@ void pc_exeautobonus(struct map_session_data *sd,struct s_autobonus *autobonus) if( autobonus->other_script ) { int j; - unsigned int equip_pos = 0; + unsigned int equip_pos_idx = 0; //Create a list of all equipped positions to see if all items needed for the autobonus are still present [Playtester] for(j = 0; j < EQI_MAX; j++) { if(sd->equip_index[j] >= 0) - equip_pos |= sd->status.inventory[sd->equip_index[j]].equip; + equip_pos_idx |= sd->status.inventory[sd->equip_index[j]].equip; } - if((equip_pos&autobonus->pos) == autobonus->pos) + if((equip_pos_idx&autobonus->pos) == autobonus->pos) script_run_autobonus(autobonus->other_script,sd,autobonus->pos); } @@ -9076,7 +9060,7 @@ static int pc_removecombo(struct map_session_data *sd, struct item_data *data ) int x = 0, cursor = 0, j; ARR_FIND( 0, sd->combos.count, x, sd->combos.id[x] == data->combos[i]->id ); /* no match, skip this combo */ - if( !(x < sd->combos.count) ) + if(x >= sd->combos.count) continue; sd->combos.bonus[x] = NULL; @@ -10804,7 +10788,7 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) { * @param sd * @param md **/ -static void pc_clear_log_damage_sub(int char_id, struct mob_data *md) +static void pc_clear_log_damage_sub(uint32 char_id, struct mob_data *md) { uint8 i; ARR_FIND(0,DAMAGELOG_SIZE,i,md->dmglog[i].id == char_id); @@ -10979,7 +10963,7 @@ enum e_BANKING_DEPOSIT_ACK pc_bank_deposit(struct map_session_data *sd, int mone return BDA_NO_MONEY; sd->status.bank_vault += money; - if( save_settings&256 ) + if( save_settings&CHARSAVE_BANK ) chrif_save(sd,0); return BDA_SUCCESS; } @@ -11006,7 +10990,7 @@ enum e_BANKING_WITHDRAW_ACK pc_bank_withdraw(struct map_session_data *sd, int mo return BWA_NO_MONEY; sd->status.bank_vault -= money; - if( save_settings&256 ) + if( save_settings&CHARSAVE_BANK ) chrif_save(sd,0); return BWA_SUCCESS; } diff --git a/src/map/pc.h b/src/map/pc.h index ed7c8d0f3a..43dbf09cfd 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -242,7 +242,7 @@ struct map_session_data { unsigned int no_knockback : 1; unsigned int bonus_coma : 1; } special_state; - int login_id1, login_id2; + uint32 login_id1, login_id2; unsigned short class_; //This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex] int group_id, group_pos, group_level; unsigned int permissions;/* group permissions */ @@ -837,8 +837,8 @@ bool pc_should_log_commands(struct map_session_data *sd); void pc_setrestartvalue(struct map_session_data *sd, char type); void pc_makesavestatus(struct map_session_data *sd); void pc_respawn(struct map_session_data* sd, clr_type clrtype); -void pc_setnewpc(struct map_session_data *sd, int account_id, int char_id, int login_id1, unsigned int client_tick, int sex, int fd); -bool pc_authok(struct map_session_data *sd, int login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers); +void pc_setnewpc(struct map_session_data *sd, uint32 account_id, uint32 char_id, int login_id1, unsigned int client_tick, int sex, int fd); +bool pc_authok(struct map_session_data *sd, uint32 login_id2, time_t expiration_time, int group_id, struct mmo_charstatus *st, bool changing_mapservers); void pc_authfail(struct map_session_data *sd); void pc_reg_received(struct map_session_data *sd); void pc_close_npc(struct map_session_data *sd,int flag); @@ -1051,7 +1051,7 @@ void pc_delinvincibletimer(struct map_session_data* sd); void pc_addspiritball(struct map_session_data *sd,int interval,int max); void pc_delspiritball(struct map_session_data *sd,int count,int type); void pc_addfame(struct map_session_data *sd,int count); -unsigned char pc_famerank(int char_id, int job); +unsigned char pc_famerank(uint32 char_id, int job); bool pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl); extern struct fame_list smith_fame_list[MAX_FAME_LIST]; diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index 838fcc5eb7..62dff1709f 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -4,7 +4,6 @@ #include "../common/conf.h" #include "../common/db.h" #include "../common/malloc.h" -#include "../common/nullpo.h" #include "../common/showmsg.h" #include "../common/strlib.h" // strcmp #include "../common/socket.h" @@ -369,9 +368,7 @@ void pc_group_pc_load(struct map_session_data * sd) { bool pc_group_has_permission(int group_id, int permission) { GroupSettings *group = NULL; - if ((group = id2group(group_id)) == NULL) - return false; - return ((group->e_permissions&permission) != 0); + return (group = id2group(group_id)) == NULL ? false : (group->e_permissions&permission) != 0; } /** @@ -381,9 +378,7 @@ bool pc_group_has_permission(int group_id, int permission) bool pc_group_should_log_commands(int group_id) { GroupSettings *group = NULL; - if ((group = id2group(group_id)) == NULL) - return false; - return group->log_commands; + return (group = id2group(group_id)) == NULL ? false : group->log_commands; } /** diff --git a/src/map/pet.c b/src/map/pet.c index 32df095f64..45fac8d85e 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -12,26 +12,12 @@ #include "../common/ers.h" #include "pc.h" -#include "status.h" -#include "map.h" -#include "path.h" #include "intif.h" -#include "clif.h" #include "chrif.h" #include "pet.h" -#include "itemdb.h" -#include "battle.h" -#include "mob.h" -#include "npc.h" -#include "script.h" -#include "skill.h" -#include "unit.h" -#include "atcommand.h" // msg_txt() -#include "log.h" -#include #include -#include + #define MIN_PETTHINKTIME 100 @@ -524,8 +510,8 @@ int pet_birth_process(struct map_session_data *sd, struct s_pet *pet) } intif_save_petdata(sd->status.account_id,pet); - - if (save_settings&8) + + if (save_settings&CHARSAVE_PET) chrif_save(sd,0); //is it REALLY Needed to save the char for hatching a pet? [Skotlex] if(sd->bl.prev != NULL) { @@ -551,7 +537,7 @@ int pet_birth_process(struct map_session_data *sd, struct s_pet *pet) * @param flag : 1:stop loading of pet * @return 0:success, 1:failure */ -int pet_recv_petdata(int account_id,struct s_pet *p,int flag) +int pet_recv_petdata(uint32 account_id,struct s_pet *p,int flag) { struct map_session_data *sd; @@ -709,7 +695,7 @@ int pet_catch_process2(struct map_session_data* sd, int target_id) * @param pet_id : pet ID otherwise means failure * @return true : success, false : failure **/ -bool pet_get_egg(int account_id, short pet_class, int pet_id ) { +bool pet_get_egg(uint32 account_id, short pet_class, int pet_id ) { struct map_session_data *sd; struct item tmp_item; int i = 0, ret = 0; diff --git a/src/map/pet.h b/src/map/pet.h index 02f7fa7c67..aa0fd7ef9a 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -111,11 +111,11 @@ int search_petDB_index(int key,int type); int pet_hungry_timer_delete(struct pet_data *pd); int pet_data_init(struct map_session_data *sd, struct s_pet *pet); int pet_birth_process(struct map_session_data *sd, struct s_pet *pet); -int pet_recv_petdata(int account_id,struct s_pet *p,int flag); +int pet_recv_petdata(uint32 account_id,struct s_pet *p,int flag); int pet_select_egg(struct map_session_data *sd,short egg_index); int pet_catch_process1(struct map_session_data *sd,int target_class); int pet_catch_process2(struct map_session_data *sd,int target_id); -bool pet_get_egg(int account_id, short pet_class, int pet_id); +bool pet_get_egg(uint32 account_id, short pet_class, int pet_id); int pet_menu(struct map_session_data *sd,int menunum); int pet_change_name(struct map_session_data *sd,char *name); int pet_change_name_ack(struct map_session_data *sd, char* name, int flag); diff --git a/src/map/quest.c b/src/map/quest.c index 2fe30046c9..3f9c24d623 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -3,34 +3,18 @@ #include "../common/cbasetypes.h" #include "../common/socket.h" -#include "../common/timer.h" #include "../common/malloc.h" #include "../common/nullpo.h" #include "../common/showmsg.h" #include "../common/strlib.h" -#include "../common/utils.h" #include "map.h" #include "pc.h" -#include "npc.h" -#include "itemdb.h" -#include "script.h" -#include "intif.h" -#include "battle.h" -#include "mob.h" #include "party.h" -#include "unit.h" -#include "log.h" -#include "clif.h" #include "quest.h" -#include "intif.h" #include "chrif.h" -#include #include -#include -#include -#include /** * Searches a quest by ID. @@ -111,7 +95,7 @@ int quest_add(TBL_PC *sd, int quest_id) clif_quest_add(sd, &sd->quest_log[n]); clif_quest_update_objective(sd, &sd->quest_log[n]); - if( save_settings&64 ) + if( save_settings&CHARSAVE_QUEST ) chrif_save(sd,0); return 0; @@ -164,7 +148,7 @@ int quest_change(TBL_PC *sd, int qid1, int qid2) clif_quest_add(sd, &sd->quest_log[i]); clif_quest_update_objective(sd, &sd->quest_log[i]); - if( save_settings&64 ) + if( save_settings&CHARSAVE_QUEST ) chrif_save(sd,0); return 0; @@ -203,7 +187,7 @@ int quest_delete(TBL_PC *sd, int quest_id) clif_quest_delete(sd, quest_id); - if( save_settings&64 ) + if( save_settings&CHARSAVE_QUEST ) chrif_save(sd,0); return 0; @@ -287,7 +271,7 @@ int quest_update_status(TBL_PC *sd, int quest_id, enum quest_state status) sd->save_quest = true; if( status < Q_COMPLETE ) { - clif_quest_update_status(sd, quest_id, status == Q_ACTIVE ? true : false); + clif_quest_update_status(sd, quest_id, status == Q_ACTIVE); return 0; } @@ -302,7 +286,7 @@ int quest_update_status(TBL_PC *sd, int quest_id, enum quest_state status) clif_quest_delete(sd, quest_id); - if( save_settings&64 ) + if( save_settings&CHARSAVE_QUEST ) chrif_save(sd,0); return 0; diff --git a/src/map/script.c b/src/map/script.c index b242126bef..c6261bceb4 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -24,32 +24,20 @@ #include "chrif.h" #include "itemdb.h" #include "pc.h" -#include "status.h" #include "storage.h" -#include "mob.h" -#include "npc.h" #include "pet.h" #include "mapreg.h" #include "homunculus.h" #include "instance.h" #include "mercenary.h" #include "intif.h" -#include "skill.h" -#include "status.h" #include "chat.h" -#include "battle.h" #include "battleground.h" #include "party.h" -#include "guild.h" -#include "atcommand.h" -#include "log.h" -#include "unit.h" -#include "pet.h" #include "mail.h" #include "script.h" #include "quest.h" #include "elemental.h" -#include "../config/core.h" #ifdef PCRE_SUPPORT #include "../../3rdparty/pcre/include/pcre.h" // preg_match @@ -60,9 +48,8 @@ #include #include #ifndef WIN32 - #include #endif -#include + #include #include @@ -4245,8 +4232,13 @@ static void *queryThread_main(void *x) { Sql *queryThread_handle = Sql_Malloc(); int i; - if ( SQL_ERROR == Sql_Connect(queryThread_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) ) + if ( SQL_ERROR == Sql_Connect(queryThread_handle, map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db) ){ + ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n", + map_server_id, map_server_pw, map_server_ip, map_server_port, map_server_db); + Sql_ShowDebug(queryThread_handle); + Sql_Free(queryThread_handle); exit(EXIT_FAILURE); + } if( strlen(default_codepage) > 0 ) if ( SQL_ERROR == Sql_SetEncoding(queryThread_handle, default_codepage) ) @@ -4255,8 +4247,13 @@ static void *queryThread_main(void *x) { if( log_config.sql_logs ) { logmysql_handle = Sql_Malloc(); - if ( SQL_ERROR == Sql_Connect(logmysql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db) ) - exit(EXIT_FAILURE); + if ( SQL_ERROR == Sql_Connect(logmysql_handle, log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db) ){ + ShowError("Couldn't connect with uname='%s',passwd='%s',host='%s',port='%d',database='%s'\n", + log_db_id, log_db_pw, log_db_ip, log_db_port, log_db_db); + Sql_ShowDebug(logmysql_handle); + Sql_Free(logmysql_handle); + exit(EXIT_FAILURE); + } if( strlen(default_codepage) > 0 ) if ( SQL_ERROR == Sql_SetEncoding(logmysql_handle, default_codepage) ) @@ -7247,7 +7244,7 @@ BUILDIN_FUNC(delitem) if( script_hasdata(st,4) ) { - int account_id = script_getnum(st,4); + uint32 account_id = script_getnum(st,4); sd = map_id2sd(account_id); // if( sd == NULL ) { @@ -7334,7 +7331,7 @@ BUILDIN_FUNC(delitem2) if( script_hasdata(st,11) ) { - int account_id = script_getnum(st,11); + uint32 account_id = script_getnum(st,11); sd = map_id2sd(account_id); // if( sd == NULL ) { @@ -9654,7 +9651,8 @@ BUILDIN_FUNC(killmonsterall) BUILDIN_FUNC(clone) { TBL_PC *sd, *msd=NULL; - int char_id,master_id=0,x,y, mode = 0, flag = 0, m; + uint32 char_id; + int master_id=0,x,y, mode = 0, flag = 0, m; unsigned int duration = 0; const char *mapname,*event; diff --git a/src/map/searchstore.c b/src/map/searchstore.c index b6b6270fcd..910a9a96ee 100644 --- a/src/map/searchstore.c +++ b/src/map/searchstore.c @@ -307,7 +307,7 @@ void searchstore_close(struct map_session_data* sd) * @param store_id : store ID created by client * @param nameid : item being searched */ -void searchstore_click(struct map_session_data* sd, int account_id, int store_id, unsigned short nameid) +void searchstore_click(struct map_session_data* sd, uint32 account_id, int store_id, unsigned short nameid) { unsigned int i; struct map_session_data* pl_sd; @@ -372,7 +372,7 @@ void searchstore_click(struct map_session_data* sd, int account_id, int store_id * @param account_id : account ID of owner's shop * @return : true : shop opened, false : shop not opened */ -bool searchstore_queryremote(struct map_session_data* sd, int account_id) +bool searchstore_queryremote(struct map_session_data* sd, uint32 account_id) { return (bool)( sd->searchstore.open && sd->searchstore.count && sd->searchstore.remote_id == account_id ); } @@ -398,7 +398,7 @@ void searchstore_clearremote(struct map_session_data* sd) * @param card : card in the item * @param refine : refine of the item */ -bool searchstore_result(struct map_session_data* sd, int store_id, int account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const unsigned short* card, unsigned char refine) +bool searchstore_result(struct map_session_data* sd, int store_id, uint32 account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const unsigned short* card, unsigned char refine) { struct s_search_store_info_item* ssitem; diff --git a/src/map/searchstore.h b/src/map/searchstore.h index 223461147e..f02cc210a6 100644 --- a/src/map/searchstore.h +++ b/src/map/searchstore.h @@ -19,7 +19,7 @@ struct s_search_store_search { struct s_search_store_info_item { int store_id; - int account_id; + uint32 account_id; char store_name[MESSAGE_SIZE]; unsigned short nameid; unsigned short amount; @@ -46,9 +46,9 @@ bool searchstore_querynext(struct map_session_data* sd); void searchstore_next(struct map_session_data* sd); void searchstore_clear(struct map_session_data* sd); void searchstore_close(struct map_session_data* sd); -void searchstore_click(struct map_session_data* sd, int account_id, int store_id, unsigned short nameid); -bool searchstore_queryremote(struct map_session_data* sd, int account_id); +void searchstore_click(struct map_session_data* sd, uint32 account_id, int store_id, unsigned short nameid); +bool searchstore_queryremote(struct map_session_data* sd, uint32 account_id); void searchstore_clearremote(struct map_session_data* sd); -bool searchstore_result(struct map_session_data* sd, int store_id, int account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const unsigned short* card, unsigned char refine); +bool searchstore_result(struct map_session_data* sd, int store_id, uint32 account_id, const char* store_name, unsigned short nameid, unsigned short amount, unsigned int price, const unsigned short* card, unsigned char refine); #endif // _SEARCHSTORE_H_ diff --git a/src/map/skill.c b/src/map/skill.c index 0648bc6250..af7bc27d8c 100755 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -3043,8 +3043,8 @@ int64 skill_attack (int attack_type, struct block_list* src, struct block_list * case SL_STIN: case SL_STUN: if (skill_lv >= 7) { - struct status_change *sc = status_get_sc(src); - if (sc && !sc->data[SC_SMA]) + struct status_change *sc_cur = status_get_sc(src); + if (sc_cur && !sc_cur->data[SC_SMA]) sc_start(src,src,SC_SMA,100,skill_lv,skill_get_time(SL_SMA, skill_lv)); } break; @@ -17307,9 +17307,9 @@ int skill_delunitgroup_(struct skill_unit_group *group, const char* file, int li ShowError("skill_delunitgroup: Group not found! (src_id: %d skill_id: %d)\n", group->src_id, group->skill_id); if(link_group_id) { - struct skill_unit_group* group = skill_id2group(link_group_id); - if(group) - skill_delunitgroup(group); + struct skill_unit_group* group_cur = skill_id2group(link_group_id); + if(group_cur) + skill_delunitgroup(group_cur); } return 1; diff --git a/src/map/status.c b/src/map/status.c index f3cac0a2f6..6e84ba2917 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -15,29 +15,12 @@ #include "path.h" #include "pc.h" #include "pet.h" -#include "npc.h" -#include "mob.h" -#include "clif.h" -#include "guild.h" -#include "skill.h" -#include "itemdb.h" -#include "battle.h" #include "battleground.h" -#include "chrif.h" -#include "skill.h" -#include "status.h" -#include "script.h" -#include "unit.h" #include "homunculus.h" #include "mercenary.h" #include "elemental.h" -#include "vending.h" -#include -#include #include -#include -#include #include // Regen related flags. diff --git a/src/map/storage.c b/src/map/storage.c index 479ff0752e..105992ad15 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -5,7 +5,6 @@ #include "../common/db.h" #include "../common/nullpo.h" #include "../common/malloc.h" -#include "../common/showmsg.h" #include "map.h" // struct map_session_data #include "storage.h" @@ -14,15 +13,11 @@ #include "clif.h" #include "intif.h" #include "pc.h" -#include "guild.h" -#include "battle.h" -#include "atcommand.h" -#include "log.h" -#include #include #include + static DBMap* guild_storage_db; ///Databases of guild_storage : int guild_id -> struct guild_storage* /** @@ -751,7 +746,7 @@ void storage_guild_storagegettocart(struct map_session_data* sd, int index, int * @param flag : 1=char quitting, close the storage * @return 0 : fail (no storage), 1 : success (requested) */ -int storage_guild_storagesave(int account_id, int guild_id, int flag) +int storage_guild_storagesave(uint32 account_id, int guild_id, int flag) { struct guild_storage *stor = guild2storage2(guild_id); @@ -801,7 +796,7 @@ int storage_guild_storageclose(struct map_session_data* sd) clif_storageclose(sd); if (stor->storage_status) { - if (save_settings&4) + if (save_settings&CHARSAVE_STORAGE) chrif_save(sd, 0); //This one also saves the storage. [Skotlex] else storage_guild_storagesave(sd->status.account_id, sd->status.guild_id,0); @@ -832,14 +827,14 @@ int storage_guild_storage_quit(struct map_session_data* sd, int flag) stor->storage_status = 0; clif_storageclose(sd); - if (save_settings&4) + if (save_settings&CHARSAVE_STORAGE) chrif_save(sd,0); return 0; } if(stor->storage_status) { - if (save_settings&4) + if (save_settings&CHARSAVE_STORAGE) chrif_save(sd,0); else storage_guild_storagesave(sd->status.account_id,sd->status.guild_id,1); diff --git a/src/map/storage.h b/src/map/storage.h index 5d08763905..b3dc1c01e2 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -36,7 +36,7 @@ void storage_guild_storageaddfromcart(struct map_session_data *sd,int index,int void storage_guild_storagegettocart(struct map_session_data *sd,int index,int amount); int storage_guild_storageclose(struct map_session_data *sd); int storage_guild_storage_quit(struct map_session_data *sd,int flag); -int storage_guild_storagesave(int account_id, int guild_id, int flag); +int storage_guild_storagesave(uint32 account_id, int guild_id, int flag); int storage_guild_storagesaved(int guild_id); //Ack from char server that guild store was saved. int compare_item(struct item *a, struct item *b); diff --git a/src/map/trade.c b/src/map/trade.c index 3d1097c984..619da43caf 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -5,17 +5,12 @@ #include "../common/socket.h" #include "clif.h" #include "itemdb.h" -#include "map.h" #include "path.h" #include "trade.h" #include "pc.h" -#include "npc.h" -#include "battle.h" #include "chrif.h" #include "storage.h" #include "intif.h" -#include "atcommand.h" -#include "log.h" #include #include @@ -638,7 +633,7 @@ void trade_tradecommit(struct map_session_data *sd) clif_tradecompleted(tsd, 0); // save both player to avoid crash: they always have no advantage/disadvantage between the 2 players - if (save_settings&1) { + if (save_settings&CHARSAVE_TRADE) { chrif_save(sd,0); chrif_save(tsd,0); } diff --git a/src/map/unit.c b/src/map/unit.c index 28b5f701ce..66e695b609 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -12,35 +12,23 @@ #include "map.h" #include "path.h" #include "pc.h" -#include "mob.h" #include "pet.h" #include "homunculus.h" -#include "instance.h" #include "mercenary.h" #include "elemental.h" -#include "skill.h" #include "channel.h" -#include "clif.h" #include "duel.h" -#include "npc.h" -#include "guild.h" -#include "status.h" -#include "unit.h" -#include "battle.h" #include "battleground.h" #include "chat.h" #include "trade.h" -#include "vending.h" #include "party.h" #include "intif.h" -#include "chrif.h" -#include "script.h" #include "storage.h" -#include #include #include + // Directions values // 1 0 7 // 2 . 6 diff --git a/src/map/vending.c b/src/map/vending.c index 520311b685..d8e2f6a31d 100755 --- a/src/map/vending.c +++ b/src/map/vending.c @@ -5,23 +5,15 @@ #include "../common/malloc.h" // aMalloc, aFree #include "../common/showmsg.h" // ShowInfo #include "../common/strlib.h" -#include "../common/utils.h" #include "clif.h" #include "itemdb.h" #include "atcommand.h" -#include "map.h" #include "path.h" #include "chrif.h" #include "vending.h" #include "pc.h" -#include "npc.h" -#include "skill.h" -#include "battle.h" -#include "log.h" -#include #include // atoi -#include /// Struct for vending entry of autotrader struct s_autotrade_entry { @@ -33,8 +25,8 @@ struct s_autotrade_entry { /// Struct of autotrader struct s_autotrade { - int account_id; - int char_id; + uint32 account_id; + uint32 char_id; int vendor_id; int m; uint16 x, @@ -272,7 +264,7 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui vsd->vend_num = cursor; //Always save BOTH: customer (buyer) and vender - if( save_settings&2 ) { + if( save_settings&CHARSAVE_VENDING ) { chrif_save(sd,0); chrif_save(vsd,0); } @@ -324,7 +316,7 @@ char vending_openvending(struct map_session_data* sd, const char* message, const return 3; } - if (save_settings&2) // Avoid invalid data from saving + if (save_settings&CHARSAVE_VENDING) // Avoid invalid data from saving chrif_save(sd, 0); // filter out invalid items diff --git a/src/test/Makefile.in b/src/test/Makefile.in deleted file mode 100644 index 66369788d7..0000000000 --- a/src/test/Makefile.in +++ /dev/null @@ -1,65 +0,0 @@ - -COMMON_H = $(shell ls ../common/*.h) - -MT19937AR_OBJ = ../../3rdparty/mt19937ar/mt19937ar.o -MT19937AR_H = ../../3rdparty/mt19937ar/mt19937ar.h -MT19937AR_INCLUDE = -I../../3rdparty/mt19937ar - -LIBCONFIG_H = $(shell ls ../../3rdparty/libconfig/*.h) -LIBCONFIG_AR = ../../3rdparty/libconfig/obj/libconfig.a -LIBCONFIG_INCLUDE = -I../../3rdparty/libconfig - -TEST_SPINLOCK_OBJ=obj/test_spinlock.o -TEST_SPINLOCK_H= -TEST_SPINLOCK_DEPENDS=obj $(TEST_SPINLOCK_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) - -@SET_MAKE@ - -##################################################################### -.PHONY :all test clean - -all: test - -test: test_spinlock - -clean: - @echo " CLEAN test" - @rm -rf *.o obj ../../test_spinlock@EXEEXT@ - -help: - @echo "possible targets are 'all' 'test' 'clean' 'help'" - @echo "'test' - builds test_spinlock test atm" - @echo "'all' - builds all above targets" - @echo "'clean' - cleans builds and objects" - @echo "'help' - outputs this message" - -##################################################################### - -test_spinlock: $(TEST_SPINLOCK_DEPENDS) - @echo " LD $@" - @@CC@ @LDFLAGS@ -o ../../test_spinlock@EXEEXT@ $(TEST_SPINLOCK_OBJ) ../common/obj_sql/common_sql.a ../common/obj_all/common.a $(MT19937AR_OBJ) $(LIBCONFIG_AR) @LIBS@ @MYSQL_LIBS@ - -# object directories - -obj: - @echo " MKDIR obj" - @-mkdir obj - -# login object files - -obj/%.o: %.c $(COMMON_H) $(MT19937AR_H) $(LIBCONFIG_H) - @echo " CC $<" - @@CC@ @CFLAGS@ $(MT19937AR_INCLUDE) $(LIBCONFIG_INCLUDE) -DWITH_SQL @MYSQL_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $< - -# missing object files -../common/obj_all/common.a: - @$(MAKE) -C ../common sql - -../common/obj_sql/common_sql.a: - @$(MAKE) -C ../common sql - -MT19937AR_OBJ: - @$(MAKE) -C ../../3rdparty/mt19937ar - -LIBCONFIG_AR: - @$(MAKE) -C ../../3rdparty/libconfig diff --git a/src/test/test_spinlock.c b/src/test/test_spinlock.c deleted file mode 100644 index 878ee8babd..0000000000 --- a/src/test/test_spinlock.c +++ /dev/null @@ -1,117 +0,0 @@ - -#include "../common/core.h" -#include "../common/atomic.h" -#include "../common/thread.h" -#include "../common/spinlock.h" -#include "../common/showmsg.h" - -#include -#include - -// -// Simple test for the spinlock implementation to see if it works properly.. -// - - - -#define THRC 32 //thread Count -#define PERINC 100000 -#define LOOPS 47 - - -static SPIN_LOCK lock; -static int val = 0; -static volatile int32 done_threads = 0; - -static void *worker(void *p){ - register int i; - - for(i = 0; i < PERINC; i++){ - EnterSpinLock(&lock); - EnterSpinLock(&lock); - - val++; - - LeaveSpinLock(&lock); - LeaveSpinLock(&lock); - } - - InterlockedIncrement(&done_threads); - - return NULL; -}//end: worker() - - -int do_init(int argc, char **argv){ - rAthread t[THRC]; - int j, i; - int ok; - - ShowStatus("==========\n"); - ShowStatus("TEST: %u Runs, (%u Threads)\n", LOOPS, THRC); - ShowStatus("This can take a while\n"); - ShowStatus("\n\n"); - - ok =0; - for(j = 0; j < LOOPS; j++){ - val = 0; - done_threads = 0; - - InitializeSpinLock(&lock); - - - for(i =0; i < THRC; i++){ - t[i] = rathread_createEx( worker, NULL, 1024*512, RAT_PRIO_NORMAL); - } - - - while(1){ - if(InterlockedCompareExchange(&done_threads, THRC, THRC) == THRC) - break; - - rathread_yield(); - } - - FinalizeSpinLock(&lock); - - // Everything fine? - if(val != (THRC*PERINC) ){ - printf("FAILED! (Result: %u, Expected: %u)\n", val, (THRC*PERINC) ); - }else{ - printf("OK! (Result: %u, Expected: %u)\n", val, (THRC*PERINC) ); - ok++; - } - - } - - - if(ok != LOOPS){ - ShowFatalError("Test failed.\n"); - exit(1); - }else{ - ShowStatus("Test passed.\n"); - exit(0); - } - - -return 0; -}//end: do_init() - - -void do_abort(){ -}//end: do_abort() - - -void set_server_type(){ - SERVER_TYPE = ATHENA_SERVER_NONE; -}//end: set_server_type() - - -void do_final(){ -}//end: do_final() - - -int parse_console(const char* command){ - return 0; -}//end: parse_console -