瀏覽代碼

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.
lighta 10 年之前
父節點
當前提交
8066bdef46
共有 100 個文件被更改,包括 580 次插入994 次删除
  1. 0 6
      Makefile.in
  2. 0 3
      configure
  3. 0 1
      configure.in
  4. 16 20
      src/char/char.c
  5. 20 19
      src/char/char.h
  6. 12 12
      src/char/char_clif.c
  7. 3 3
      src/char/char_clif.h
  8. 0 1
      src/char/char_cnslif.c
  9. 6 8
      src/char/char_logif.c
  10. 3 3
      src/char/char_logif.h
  11. 9 11
      src/char/char_mapif.c
  12. 2 6
      src/char/int_elemental.c
  13. 26 39
      src/char/int_guild.c
  14. 5 5
      src/char/int_guild.h
  15. 8 11
      src/char/int_homun.c
  16. 6 10
      src/char/int_mail.c
  17. 5 9
      src/char/int_mercenary.c
  18. 3 3
      src/char/int_mercenary.h
  19. 18 21
      src/char/int_party.c
  20. 3 3
      src/char/int_party.h
  21. 7 9
      src/char/int_pet.c
  22. 6 11
      src/char/int_quest.c
  23. 5 8
      src/char/int_storage.c
  24. 3 3
      src/char/int_storage.h
  25. 9 9
      src/char/inter.c
  26. 2 2
      src/char/inter.h
  27. 0 2
      src/common/conf.c
  28. 1 13
      src/common/core.c
  29. 0 1
      src/common/db.c
  30. 0 3
      src/common/grfio.c
  31. 0 1
      src/common/malloc.c
  32. 0 4
      src/common/mapindex.c
  33. 0 1
      src/common/md5calc.c
  34. 0 2
      src/common/mempool.c
  35. 15 15
      src/common/mmo.h
  36. 1 2
      src/common/mutex.c
  37. 0 15
      src/common/netbuffer.c
  38. 5 25
      src/common/network.c
  39. 1 1
      src/common/random.c
  40. 0 5
      src/common/showmsg.c
  41. 2 9
      src/common/socket.c
  42. 10 2
      src/common/sql.c
  43. 0 2
      src/common/strlib.c
  44. 0 4
      src/common/timer.c
  45. 0 4
      src/common/utils.c
  46. 12 13
      src/login/account.c
  47. 3 3
      src/login/account.h
  48. 5 4
      src/login/ipban.c
  49. 2 5
      src/login/login.c
  50. 7 7
      src/login/login.h
  51. 11 16
      src/login/loginchrif.c
  52. 0 2
      src/login/loginclif.c
  53. 0 2
      src/login/logincnslif.c
  54. 3 1
      src/login/loginlog.c
  55. 6 20
      src/map/atcommand.c
  56. 15 22
      src/map/battle.c
  57. 0 5
      src/map/battleground.c
  58. 5 6
      src/map/buyingstore.c
  59. 2 2
      src/map/buyingstore.h
  60. 0 4
      src/map/cashshop.c
  61. 1 4
      src/map/channel.c
  62. 0 4
      src/map/chat.c
  63. 15 22
      src/map/chrif.c
  64. 10 10
      src/map/chrif.h
  65. 16 16
      src/map/clif.c
  66. 6 6
      src/map/clif.h
  67. 0 2
      src/map/duel.c
  68. 1 21
      src/map/elemental.c
  69. 17 23
      src/map/guild.c
  70. 15 15
      src/map/guild.h
  71. 2 19
      src/map/homunculus.c
  72. 1 1
      src/map/homunculus.h
  73. 0 6
      src/map/instance.c
  74. 39 47
      src/map/intif.c
  75. 31 31
      src/map/intif.h
  76. 1 8
      src/map/itemdb.c
  77. 1 2
      src/map/log.c
  78. 0 4
      src/map/mail.c
  79. 17 24
      src/map/map.c
  80. 15 1
      src/map/map.h
  81. 1 2
      src/map/mapreg.c
  82. 0 15
      src/map/mercenary.c
  83. 2 15
      src/map/mob.c
  84. 1 14
      src/map/npc.c
  85. 0 7
      src/map/npc_chat.c
  86. 25 59
      src/map/party.c
  87. 11 11
      src/map/party.h
  88. 0 2
      src/map/path.h
  89. 15 31
      src/map/pc.c
  90. 4 4
      src/map/pc.h
  91. 2 7
      src/map/pc_groups.c
  92. 6 20
      src/map/pet.c
  93. 2 2
      src/map/pet.h
  94. 5 21
      src/map/quest.c
  95. 18 20
      src/map/script.c
  96. 3 3
      src/map/searchstore.c
  97. 4 4
      src/map/searchstore.h
  98. 5 5
      src/map/skill.c
  99. 0 17
      src/map/status.c
  100. 5 10
      src/map/storage.c

+ 0 - 6
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"

+ 0 - 3
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

+ 0 - 1
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
 

+ 16 - 20
src/char/char.c

@@ -2,11 +2,9 @@
 // For more information, see LICENCE in the main folder
 
 #include <time.h>
-#include <signal.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <sys/types.h>
 #include <string.h>
 
 #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;
 

+ 20 - 19
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

+ 12 - 12
src/char/char_clif.c

@@ -17,9 +17,7 @@
 #include "char_mapif.h"
 #include "char_clif.h"
 
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 
 //------------------------------------------------
@@ -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 <char id>.L <Msg:0-5>.L <deleteDate>.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 <char id>.L <Msg:0-5>.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 <char id>.L <Msg:1-2>.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 <char id>.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 <char id>.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;

+ 3 - 3
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);

+ 0 - 1
src/char/char_cnslif.c

@@ -9,7 +9,6 @@
 #include "char.h"
 #include "char_cnslif.h"
 
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 

+ 6 - 8
src/char/char_logif.c

@@ -14,15 +14,13 @@
 #include "char_mapif.h"
 #include "char_logif.h"
 
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 //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;

+ 3 - 3
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);

+ 9 - 11
src/char/char_mapif.c

@@ -17,9 +17,7 @@
 #include "char_logif.h"
 #include "char_mapif.h"
 
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 /**
  * 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);

+ 2 - 6
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 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);

+ 26 - 39
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 <string.h>
-#include <stdio.h>
 #include <stdlib.h>
 
 #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 **");
 }

+ 5 - 5
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_ */

+ 8 - 11
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 
 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);

+ 6 - 10
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 <stdio.h>
-#include <string.h>
 #include <stdlib.h>
 
-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;

+ 5 - 9
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
-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);

+ 3 - 3
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);
 

+ 18 - 21
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 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;
 

+ 3 - 3
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_ */

+ 7 - 9
src/char/int_pet.c

@@ -11,9 +11,7 @@
 #include "char.h"
 #include "inter.h"
 
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 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);

+ 6 - 11
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 <stdio.h>
-#include <string.h>
 #include <stdlib.h>
 
 /**
@@ -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;
 

+ 5 - 8
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 <stdio.h>
-#include <string.h>
 #include <stdlib.h>
 
 
@@ -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);
 

+ 3 - 3
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_ */

+ 9 - 9
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 <stdio.h>
-#include <string.h>
 #include <stdlib.h>
 
 #include <sys/stat.h> // 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;
 

+ 2 - 2
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_ */

+ 0 - 2
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)

+ 1 - 13
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 <stdio.h>
 #include <stdlib.h>
 #include <signal.h>
-#include <string.h>
 #ifndef _WIN32
 #include <unistd.h>
 #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]

+ 0 - 1
src/common/db.c

@@ -69,7 +69,6 @@
 #include <stdlib.h>
 
 #include "db.h"
-#include "../common/mmo.h"
 #include "../common/malloc.h"
 #include "../common/showmsg.h"
 #include "../common/ers.h"

+ 0 - 3
src/common/grfio.c

@@ -9,10 +9,7 @@
 #include "../common/utils.h"
 #include "grfio.h"
 
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
 #include <zlib.h>
 
 //----------------------------

+ 0 - 1
src/common/malloc.c

@@ -5,7 +5,6 @@
 #include "../common/core.h"
 #include "../common/showmsg.h"
 
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>

+ 0 - 4
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 <string.h>
-#include <stdio.h>
 #include <stdlib.h>
 
 DBMap *mapindex_db;

+ 0 - 1
src/common/md5calc.c

@@ -10,7 +10,6 @@
 #include "md5calc.h"
 #include <string.h>
 #include <stdio.h>
-#include <stdlib.h>
 
 #ifndef UINT_MAX
 #define UINT_MAX 4294967295U

+ 0 - 2
src/common/mempool.c

@@ -13,7 +13,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <time.h>
 
 #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"
 

+ 15 - 15
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 {

+ 1 - 2
src/common/mutex.c

@@ -5,8 +5,7 @@
 #include "../common/winapi.h"
 #else
 #include <pthread.h>
-#include <time.h>
-#include <sys/time.h>
+
 #endif
 
 #include "../common/cbasetypes.h"

+ 0 - 15
src/common/netbuffer.c

@@ -10,21 +10,6 @@
 //
 //
 
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-#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:

+ 5 - 25
src/common/network.c

@@ -11,26 +11,6 @@
 #define _GNU_SOURCE
 //#endif
 
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include <sys/types.h>
-#include <sys/fcntl.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-
-
-#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;
 		}

+ 1 - 1
src/common/random.c

@@ -10,7 +10,7 @@
 	#include <sys/types.h>
 	#include <unistd.h>
 #endif
-#include <time.h> // time
+
 #include <mt19937ar.h> // init_genrand, genrand_int32, genrand_res53
 
 

+ 0 - 5
src/common/showmsg.c

@@ -6,14 +6,9 @@
 #include "showmsg.h"
 #include "core.h" //[Ind] - For SERVER_TYPE
 
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
 #include <time.h>
 #include <stdlib.h> // atexit
 
-#include "libconfig.h"
-
 #ifdef WIN32
 	#include "../common/winapi.h"
 

+ 2 - 9
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
 
 #ifdef WIN32
 	#include "../common/winapi.h"
 #else
 	#include <errno.h>
-	#include <sys/socket.h>
-	#include <netinet/in.h>
-	#include <netinet/tcp.h>
+#include <netinet/tcp.h>
 	#include <net/if.h>
 	#include <unistd.h>
-	#include <sys/time.h>
-	#include <sys/ioctl.h>
+#include <sys/ioctl.h>
 	#include <netdb.h>
 	#include <arpa/inet.h>
 

+ 10 - 2
src/common/sql.c

@@ -12,7 +12,6 @@
 #include "../common/winapi.h"
 #endif
 #include <mysql.h>
-#include <string.h>// strlen/strnlen/memcpy/memset
 #include <stdlib.h>// 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 )

+ 0 - 2
src/common/strlib.c

@@ -6,9 +6,7 @@
 #include "../common/showmsg.h"
 #include "strlib.h"
 
-#include <stdio.h>
 #include <stdlib.h>
-#include <errno.h>
 
 
 #define J_MAX_MALLOC_SIZE 65535

+ 0 - 4
src/common/timer.c

@@ -9,16 +9,12 @@
 #include "../common/nullpo.h"
 #include "timer.h"
 
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <time.h>
 
 #ifdef WIN32
 #include "../common/winapi.h" // GetTickCount()
 #else
-#include <unistd.h>
-#include <sys/time.h> // struct timeval, gettimeofday()
 #endif
 
 // If the server can't handle processing thousands of monsters

+ 0 - 4
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 <stdio.h>
-#include <stdarg.h>
 #include <stdlib.h>
 #include <string.h>
 #include <math.h> // floor()

+ 12 - 13
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 <stdlib.h>
-#include <string.h>
 
 /// 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;

+ 3 - 3
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.
 	///

+ 5 - 4
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 <stdlib.h>
-#include <string.h>
 
 // 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);
 

+ 2 - 5
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 #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 )

+ 7 - 7
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.

+ 11 - 16
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 //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();

+ 0 - 2
src/login/loginclif.c

@@ -22,9 +22,7 @@
 #include "loginclif.h"
 #include "loginchrif.h"
 
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 /**
  * Transmit auth result to client.

+ 0 - 2
src/login/logincnslif.c

@@ -17,9 +17,7 @@
 #include "login.h"
 #include "logincnslif.h"
 
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 /**
  * Login-server console help: starting option info.

+ 3 - 1
src/login/loginlog.c

@@ -12,7 +12,7 @@
 #include "../common/socket.h"
 #include "../common/sql.h"
 #include "../common/strlib.h"
-#include <string.h>
+#include "../common/showmsg.h"
 #include <stdlib.h> // 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);

+ 6 - 20
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <math.h>
 
+
 #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 <permission_name>
@@ -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);
 

+ 15 - 22
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <math.h>
 
 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);

+ 0 - 5
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 <string.h>
-#include <stdio.h>
-
 static DBMap* bg_team_db; // int bg_id -> struct battleground_data*
 static unsigned int bg_team_counter = 0; // Next bg_id
 

+ 5 - 6
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 { <index>.W, <nameid>.W, <amount>.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);
 	}

+ 2 - 2
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);

+ 0 - 4
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 <string.h> // memset

+ 1 - 4
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 <stdio.h>
 #include <stdlib.h>
 
 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;
 

+ 0 - 4
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 <stdio.h>
-#include <string.h>
 
 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));

+ 15 - 22
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <time.h>
 
 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 <account_id>.L <login_id1>.L <login_id2>.L <char_id>.L <map_index>.W <x>.W <y>.W <ip>.L <port>.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;

+ 10 - 10
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);
 

+ 16 - 16
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 <packet len>.W <account id>.L <message>.?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 <char name>.24B <reason>.40B <account name>.24B (ZC_ACK_BAN_GUILD)
 /// 0839 <char name>.24B <reason>.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 <packet len>.W <message>.?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 <inviter account id>.L <guild name>.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 <account id>.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 <account id>.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 <account id>.L <account name>.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 <req account id>.L <req char id>.L <req char name>.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 <account id>.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]);

+ 6 - 6
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!
 

+ 0 - 2
src/map/duel.c

@@ -10,9 +10,7 @@
 #include "pc.h"
 
 #include <stdio.h>
-#include <stdlib.h>
 #include <string.h>
-#include <time.h>
 
 //global var (extern)
 struct duel duel_list[MAX_DUEL]; //list of current duel

+ 1 - 21
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <math.h>
 
 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){

+ 17 - 23
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
+
 
 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;

+ 15 - 15
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);

+ 2 - 19
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <math.h>
 
 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) {

+ 1 - 1
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_);

+ 0 - 6
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include <time.h>
 
 #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)

+ 39 - 47
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 <sys/types.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <string.h>
 
 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() )

+ 31 - 31
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);
 

+ 1 - 8
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 
 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;
 }
 
 /**

+ 1 - 2
src/map/log.c

@@ -13,9 +13,8 @@
 #include "mob.h"
 #include "pc.h"
 
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
+
 
 /// filters for item logging
 typedef enum e_log_filter

+ 0 - 4
src/map/mail.c

@@ -10,12 +10,8 @@
 #include "itemdb.h"
 #include "clif.h"
 #include "pc.h"
-#include "log.h"
 #include "intif.h"
 
-#include <time.h>
-#include <string.h>
-
 void mail_clear(struct map_session_data *sd)
 {
 	sd->mail.nameid = 0;

+ 17 - 24
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
 #include <math.h>
 #ifndef _WIN32
-#include <unistd.h>
 #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 )

+ 15 - 1
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);

+ 1 - 2
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 <stdlib.h>
-#include <string.h>
 
 static DBMap* mapreg_db = NULL; // int var_id -> int value
 static DBMap* mapregstr_db = NULL; // int var_id -> char* value
@@ -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)
 {

+ 0 - 15
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <math.h>
 
 struct s_mercenary_db mercenary_db[MAX_MERCENARY_CLASS]; // Mercenary Database

+ 2 - 15
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 <stdio.h>
 #include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
 #include <math.h>
 
 #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.

+ 1 - 14
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <time.h>
 #include <errno.h>
 
+
 struct npc_data* fake_nd;
 
 // linked list of npc source files

+ 0 - 7
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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
 
 /**
  *  Written by MouseJstr in a vision... (2/21/2005)

+ 25 - 59
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
+
 
 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 <account_id, name>.
-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;

+ 11 - 11
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);

+ 0 - 2
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)

+ 15 - 31
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <time.h>
 #include <math.h>
 
 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;
 }

+ 4 - 4
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];

+ 2 - 7
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;
 }
 
 /**

+ 6 - 20
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 <stdio.h>
+
 #include <stdlib.h>
-#include <string.h>
+
 
 #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;

+ 2 - 2
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);

+ 5 - 21
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 <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <stdarg.h>
-#include <time.h>
 
 /**
  * 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;

+ 18 - 20
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 <string.h>
 #include <math.h>
 #ifndef WIN32
-	#include <sys/time.h>
 #endif
-#include <time.h>
+
 #include <setjmp.h>
 #include <errno.h>
 
@@ -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); // <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); // <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;
 

+ 3 - 3
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;
 

+ 4 - 4
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_

+ 5 - 5
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;

+ 0 - 17
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 <time.h>
-#include <stdio.h>
 #include <stdlib.h>
-#include <memory.h>
-#include <string.h>
 #include <math.h>
 
 // Regen related flags.

+ 5 - 10
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 <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
+
 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);

Some files were not shown because too many files changed in this diff