Ver Fonte

Changed all unsigned int to uint32 (#8781)

Lemongrass3110 há 6 meses atrás
pai
commit
3e9c432395
83 ficheiros alterados com 696 adições e 697 exclusões
  1. 2 2
      src/char/char.cpp
  2. 1 1
      src/char/char.hpp
  3. 1 1
      src/char/char_logif.cpp
  4. 1 1
      src/char/char_logif.hpp
  5. 4 4
      src/char/char_mapif.cpp
  6. 3 3
      src/char/char_mapif.hpp
  7. 3 3
      src/char/int_auction.cpp
  8. 1 1
      src/char/int_homun.cpp
  9. 5 5
      src/char/int_party.cpp
  10. 5 5
      src/char/inter.cpp
  11. 1 1
      src/char/inter.hpp
  12. 37 37
      src/common/db.cpp
  13. 23 23
      src/common/db.hpp
  14. 11 11
      src/common/ers.cpp
  15. 1 1
      src/common/ers.hpp
  16. 4 4
      src/common/grfio.cpp
  17. 1 1
      src/common/grfio.hpp
  18. 23 28
      src/common/md5calc.cpp
  19. 13 13
      src/common/mmo.hpp
  20. 6 6
      src/common/socket.cpp
  21. 1 1
      src/common/socket.hpp
  22. 9 9
      src/common/sql.cpp
  23. 1 1
      src/common/sql.hpp
  24. 1 1
      src/common/timer.cpp
  25. 1 1
      src/common/timer.hpp
  26. 4 4
      src/common/utils.cpp
  27. 1 1
      src/common/utils.hpp
  28. 3 3
      src/login/account.cpp
  29. 3 3
      src/login/account.hpp
  30. 4 4
      src/login/login.cpp
  31. 8 8
      src/login/login.hpp
  32. 1 1
      src/login/loginchrif.cpp
  33. 1 1
      src/login/loginlog.cpp
  34. 1 1
      src/login/loginlog.hpp
  35. 26 26
      src/map/atcommand.cpp
  36. 4 4
      src/map/battle.cpp
  37. 12 12
      src/map/buyingstore.cpp
  38. 2 2
      src/map/buyingstore.hpp
  39. 3 3
      src/map/cashshop.cpp
  40. 1 1
      src/map/channel.cpp
  41. 3 3
      src/map/channel.hpp
  42. 14 14
      src/map/clif.cpp
  43. 5 5
      src/map/clif.hpp
  44. 1 1
      src/map/clif_obfuscation.hpp
  45. 1 1
      src/map/duel.cpp
  46. 1 1
      src/map/duel.hpp
  47. 1 1
      src/map/elemental.cpp
  48. 1 1
      src/map/elemental.hpp
  49. 3 3
      src/map/homunculus.cpp
  50. 4 4
      src/map/homunculus.hpp
  51. 4 4
      src/map/intif.cpp
  52. 5 5
      src/map/intif.hpp
  53. 1 1
      src/map/itemdb.cpp
  54. 1 1
      src/map/log.cpp
  55. 9 9
      src/map/map.cpp
  56. 6 6
      src/map/map.hpp
  57. 1 1
      src/map/mercenary.cpp
  58. 1 1
      src/map/mercenary.hpp
  59. 14 14
      src/map/mob.cpp
  60. 20 20
      src/map/mob.hpp
  61. 5 5
      src/map/npc.cpp
  62. 3 3
      src/map/npc.hpp
  63. 5 5
      src/map/party.cpp
  64. 1 1
      src/map/party.hpp
  65. 2 2
      src/map/path.cpp
  66. 1 1
      src/map/path.hpp
  67. 43 43
      src/map/pc.cpp
  68. 73 73
      src/map/pc.hpp
  69. 1 1
      src/map/pet.cpp
  70. 2 2
      src/map/quest.cpp
  71. 98 99
      src/map/script.cpp
  72. 15 15
      src/map/script.hpp
  73. 3 3
      src/map/searchstore.cpp
  74. 7 7
      src/map/searchstore.hpp
  75. 21 22
      src/map/skill.cpp
  76. 57 57
      src/map/status.cpp
  77. 21 15
      src/map/status.hpp
  78. 1 1
      src/map/storage.cpp
  79. 1 1
      src/map/storage.hpp
  80. 1 1
      src/map/unit.cpp
  81. 4 4
      src/map/vending.cpp
  82. 1 1
      src/map/vending.hpp
  83. 1 1
      src/tool/csv2yaml.hpp

+ 2 - 2
src/char/char.cpp

@@ -65,7 +65,7 @@ static char* msg_table[CHAR_MAX_MSG]; // Login Server messages_conf
 // check for exit signal
 // 0 is saving complete
 // other is char_id
-unsigned int save_flag = 0;
+uint32 save_flag = 0;
 
 // Advanced subnet check [LuzZza]
 struct s_subnet {
@@ -504,7 +504,7 @@ int char_mmo_char_tosql(uint32 char_id, struct mmo_charstatus* p){
 		{
 			if( diff )
 				StringBuf_AppendStr(&buf, ",");// not the first hotkey
-			StringBuf_Printf(&buf, "('%d','%u','%u','%u','%u')", char_id, (unsigned int)i, (unsigned int)p->hotkeys[i].type, p->hotkeys[i].id , (unsigned int)p->hotkeys[i].lv);
+			StringBuf_Printf(&buf, "('%d','%u','%u','%u','%u')", char_id, (uint32)i, (uint32)p->hotkeys[i].type, p->hotkeys[i].id , (uint32)p->hotkeys[i].lv);
 			diff = 1;
 		}
 	}

+ 1 - 1
src/char/char.hpp

@@ -269,7 +269,7 @@ struct char_session_data {
 	uint16 pincode_try;
 	bool pincode_correct;
 	// Addon system
-	unsigned int char_moves[MAX_CHARS]; // character moves left
+	uint32 char_moves[MAX_CHARS]; // character moves left
 	uint8 isvip;
 	time_t unban_time[MAX_CHARS];
 	int charblock_timer;

+ 1 - 1
src/char/char_logif.cpp

@@ -172,7 +172,7 @@ void chlogif_prepsend_global_accreg(void) {
 	}
 }
 
-void chlogif_send_global_accreg(const char *key, unsigned int index, int64 int_value, const char* string_value, bool is_string) {
+void chlogif_send_global_accreg(const char *key, uint32 index, int64 int_value, const char* string_value, bool is_string) {
 	if (!chlogif_isconnected())
 		return;
 

+ 1 - 1
src/char/char_logif.hpp

@@ -19,7 +19,7 @@ TIMER_FUNC(chlogif_broadcast_user_count);
 void chlogif_send_usercount(int users);
 void chlogif_upd_global_accreg(uint32 account_id, uint32 char_id);
 void chlogif_prepsend_global_accreg(void);
-void chlogif_send_global_accreg(const char *key, unsigned int index, int64 int_value, const char* string_value, bool is_string);
+void chlogif_send_global_accreg(const char *key, uint32 index, int64 int_value, const char* string_value, bool is_string);
 void chlogif_request_accreg2(uint32 account_id, uint32 char_id);
 void chlogif_send_reqaccdata(int fd, struct char_session_data *sd);
 void chlogif_send_setacconline(int aid);

+ 4 - 4
src/char/char_mapif.cpp

@@ -27,7 +27,7 @@ using namespace rathena;
  * @param len: size of packet
  * @return : the number of map-serv the packet was sent to
  */
-int chmapif_sendall(unsigned char *buf, unsigned int len){
+int chmapif_sendall(unsigned char *buf, uint32 len){
 	int i, c;
 
 	c = 0;
@@ -51,7 +51,7 @@ int chmapif_sendall(unsigned char *buf, unsigned int len){
  * @param len: size of packet
  * @return : the number of map-serv the packet was sent to
  */
-int chmapif_sendallwos(int sfd, unsigned char *buf, unsigned int len){
+int chmapif_sendallwos(int sfd, unsigned char *buf, uint32 len){
 	int i, c;
 
 	c = 0;
@@ -75,7 +75,7 @@ int chmapif_sendallwos(int sfd, unsigned char *buf, unsigned int len){
  * @param len: size of packet
  * @return : the number of map-serv the packet was sent to (O|1)
  */
-int chmapif_send(int fd, unsigned char *buf, unsigned int len){
+int chmapif_send(int fd, unsigned char *buf, uint32 len){
 	if (session_isValid(fd)) {
 		int i;
 		ARR_FIND( 0, ARRAYLENGTH(map_server), i, fd == map_server[i].fd );
@@ -1241,7 +1241,7 @@ int chmapif_parse_reqcharban(int fd){
 					WBUFW(buf,0) = 0x2b14;
 					WBUFL(buf,2) = t_cid;
 					WBUFB(buf,6) = 2;
-					WBUFL(buf,7) = (unsigned int)unban_time;
+					WBUFL(buf,7) = (uint32)unban_time;
 					chmapif_sendall(buf, 11);
 					// disconnect player if online on char-server
 					char_disconnect_player(t_aid);

+ 3 - 3
src/char/char_mapif.hpp

@@ -6,9 +6,9 @@
 
 #include <common/cbasetypes.hpp>
 
-int chmapif_sendall(unsigned char *buf, unsigned int len);
-int chmapif_sendallwos(int sfd, unsigned char *buf, unsigned int len);
-int chmapif_send(int fd, unsigned char *buf, unsigned int len);
+int chmapif_sendall(unsigned char *buf, uint32 len);
+int chmapif_sendallwos(int sfd, unsigned char *buf, uint32 len);
+int chmapif_send(int fd, unsigned char *buf, uint32 len);
 int chmapif_send_fame_list(int fd);
 void chmapif_update_fame_list(int type, int index, int fame);
 void chmapif_sendall_playercount(int users);

+ 3 - 3
src/char/int_auction.cpp

@@ -128,7 +128,7 @@ uint32 auction_create( std::shared_ptr<struct auction_data> auction ){
 		auction->item.identify = 1;
 		auction->item.expire_time = 0;
 
-		auction->auction_id = (unsigned int)SqlStmt_LastInsertId(stmt);
+		auction->auction_id = (uint32)SqlStmt_LastInsertId(stmt);
 		auction->auction_end_timer = add_timer( gettick() + tick , auction_end_timer, auction->auction_id, 0);
 		ShowInfo("New Auction %u | time left %" PRtf " ms | By %s.\n", auction->auction_id, tick, auction->seller_name);
 
@@ -174,7 +174,7 @@ TIMER_FUNC(auction_end_timer){
 }
 
 void auction_delete( std::shared_ptr<struct auction_data> auction ){
-	unsigned int auction_id = auction->auction_id;
+	uint32 auction_id = auction->auction_id;
 
 	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `auction_id` = '%d'", schema_config.auction_db, auction_id) )
 		Sql_ShowDebug(sql_handle);
@@ -255,7 +255,7 @@ void inter_auctions_fromsql(void)
 		}
 
 		if( auction->timestamp > now )
-			endtick = ((unsigned int)(auction->timestamp - now) * 1000) + tick;
+			endtick = ((uint32)(auction->timestamp - now) * 1000) + tick;
 		else
 			endtick = tick + 10000; // 10 Second's to process ended auctions
 

+ 1 - 1
src/char/int_homun.cpp

@@ -181,7 +181,7 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
 	Sql_GetData(sql_handle,  4, &data, &len); safestrncpy(hd->name, data, sizeof(hd->name));
 	Sql_GetData(sql_handle,  5, &data, nullptr); hd->level = atoi(data);
 	Sql_GetData(sql_handle,  6, &data, nullptr); hd->exp = strtoull( data, nullptr, 10 );
-	Sql_GetData(sql_handle,  7, &data, nullptr); hd->intimacy = (unsigned int)strtoul(data, nullptr, 10);
+	Sql_GetData(sql_handle,  7, &data, nullptr); hd->intimacy = (uint32)strtoul(data, nullptr, 10);
 	Sql_GetData(sql_handle,  8, &data, nullptr); hd->hunger = atoi(data);
 	Sql_GetData(sql_handle,  9, &data, nullptr); hd->str = atoi(data);
 	Sql_GetData(sql_handle, 10, &data, nullptr); hd->agi = atoi(data);

+ 5 - 5
src/char/int_party.cpp

@@ -25,7 +25,7 @@ using namespace rathena;
 
 struct party_data {
 	struct party party;
-	unsigned int min_lv, max_lv;
+	uint32 min_lv, max_lv;
 	int family; //Is this party a family? if so, this holds the child id.
 	unsigned char size; //Total size of party.
 };
@@ -43,7 +43,7 @@ int party_check_family_share( std::shared_ptr<struct party_data> p );
 //Updates party's level range and unsets even share if broken.
 static int int_party_check_lv( std::shared_ptr<struct party_data> p ){
 	int i;
-	unsigned int lv;
+	uint32 lv;
 	p->min_lv = UINT_MAX;
 	p->max_lv = 0;
 	for(i=0;i<MAX_PARTY;i++){
@@ -98,7 +98,7 @@ void int_party_calc_state( std::shared_ptr<struct party_data> p ){
 	}
 	//max/min levels.
 	for(i=0;i<MAX_PARTY;i++){
-		unsigned int lv=p->party.member[i].lv;
+		uint32 lv=p->party.member[i].lv;
 		if (!lv) 
 			continue;
 		if (p->party.member[i].online) {
@@ -683,7 +683,7 @@ int mapif_parse_PartyLeave(int fd, int party_id, uint32 account_id, uint32 char_
 	return 0;
 }
 // When member goes to other map or levels up.
-int mapif_parse_PartyChangeMap( int fd, int party_id, uint32 account_id, uint32 char_id, int online, unsigned int lv, const char* map ){
+int mapif_parse_PartyChangeMap( int fd, int party_id, uint32 account_id, uint32 char_id, int online, uint32 lv, const char* map ){
 	int i;
 
 	std::shared_ptr<struct party_data> p = inter_party_fromsql( party_id );
@@ -784,7 +784,7 @@ int mapif_parse_PartyLeaderChange(int fd,int party_id,uint32 account_id,uint32 c
  * @param share_lvl : Max level number of difference to share exp
  * @return 
  */
-int mapif_parse_PartyShareLevel(int fd,unsigned int share_lvl)
+int mapif_parse_PartyShareLevel(int fd,uint32 share_lvl)
 {
 	party_share_level = share_lvl;
 

+ 5 - 5
src/char/inter.cpp

@@ -52,7 +52,7 @@ std::string char_server_id = "ragnarok";
 std::string char_server_pw = ""; // Allow user to send empty password (bugreport:7787)
 std::string char_server_db = "ragnarok";
 std::string default_codepage = ""; //Feature by irmin.
-unsigned int party_share_level = 10;
+uint32 party_share_level = 10;
 
 /// Received packet Lengths from map-server
 int inter_recv_packet_length[] = {
@@ -416,8 +416,8 @@ void geoip_readdb(void){
 /* There are millions of entries in GeoIP and it has its own algorithm to go quickly through them */
 const char* geoip_getcountry(uint32 ipnum){
 	int depth;
-	unsigned int x;
-	unsigned int offset = 0;
+	uint32 x;
+	uint32 offset = 0;
 
 	for (depth = 31; depth >= 0; depth--) {
 		const unsigned char *buf;
@@ -666,7 +666,7 @@ int inter_accreg_fromsql(uint32 account_id, uint32 char_id, int fd, int type)
 {
 	char* data;
 	size_t len;
-	unsigned int plen = 0;
+	uint32 plen = 0;
 
 	switch( type ) {
 		case 3: //char reg
@@ -864,7 +864,7 @@ int inter_config_read(const char* cfgName)
 		else if(!strcmpi(w1,"default_codepage"))
 			default_codepage = w2;
 		else if(!strcmpi(w1,"party_share_level"))
-			party_share_level = (unsigned int)atof(w2);
+			party_share_level = (uint32)atof(w2);
 		else if(!strcmpi(w1,"log_inter"))
 			charserv_config.log_inter = atoi(w2);
 		else if(!strcmpi(w1,"inter_server_conf"))

+ 1 - 1
src/char/inter.hpp

@@ -37,7 +37,7 @@ void mapif_accinfo_ack(bool success, int map_fd, int u_fd, int u_aid, int accoun
 
 int inter_log(const char *fmt,...);
 
-extern unsigned int party_share_level;
+extern uint32 party_share_level;
 
 extern Sql* sql_handle;
 extern Sql* lsql_handle;

+ 37 - 37
src/common/db.cpp

@@ -187,9 +187,9 @@ typedef struct DBMap_impl {
 	int alloc_line;
 	// Lock system
 	struct db_free *free_list;
-	unsigned int free_count;
-	unsigned int free_max;
-	unsigned int free_lock;
+	uint32 free_count;
+	uint32 free_max;
+	uint32 free_lock;
 	// Other
 	ERS *nodes;
 	DBComparator cmp;
@@ -715,7 +715,7 @@ static void db_free_add(DBMap_impl* db, DBNode *node, DBNode **root)
 	DBKey old_key;
 
 	DB_COUNTSTAT(db_free_add);
-	if (db->free_lock == (unsigned int)~0) {
+	if (db->free_lock == (uint32)~0) {
 		ShowFatalError("db_free_add: free_lock overflow\n"
 				"Database allocated at %s:%d\n",
 				db->alloc_file, db->alloc_line);
@@ -729,13 +729,13 @@ static void db_free_add(DBMap_impl* db, DBNode *node, DBNode **root)
 	if (db->free_count == db->free_max) { // No more space, expand free_list
 		db->free_max = (db->free_max<<2) +3; // = db->free_max*4 +3
 		if (db->free_max <= db->free_count) {
-			if (db->free_count == (unsigned int)~0) {
+			if (db->free_count == (uint32)~0) {
 				ShowFatalError("db_free_add: free_count overflow\n"
 						"Database allocated at %s:%d\n",
 						db->alloc_file, db->alloc_line);
 				exit(EXIT_FAILURE);
 			}
-			db->free_max = (unsigned int)~0;
+			db->free_max = (uint32)~0;
 		}
 		RECREATE(db->free_list, struct db_free, db->free_max);
 	}
@@ -761,7 +761,7 @@ static void db_free_add(DBMap_impl* db, DBNode *node, DBNode **root)
  */
 static void db_free_remove(DBMap_impl* db, DBNode *node)
 {
-	unsigned int i;
+	uint32 i;
 
 	DB_COUNTSTAT(db_free_remove);
 	for (i = 0; i < db->free_count; i++) {
@@ -791,7 +791,7 @@ static void db_free_remove(DBMap_impl* db, DBNode *node)
 static void db_free_lock(DBMap_impl* db)
 {
 	DB_COUNTSTAT(db_free_lock);
-	if (db->free_lock == (unsigned int)~0) {
+	if (db->free_lock == (uint32)~0) {
 		ShowFatalError("db_free_lock: free_lock overflow\n"
 				"Database allocated at %s:%d\n",
 				db->alloc_file, db->alloc_line);
@@ -813,7 +813,7 @@ static void db_free_lock(DBMap_impl* db)
  */
 static void db_free_unlock(DBMap_impl* db)
 {
-	unsigned int i;
+	uint32 i;
 
 	DB_COUNTSTAT(db_free_unlock);
 	if (db->free_lock == 0) {
@@ -984,7 +984,7 @@ static int db_uint64_cmp(DBKey key1, DBKey key2, unsigned short maxlen)
 
 /**
  * Default hasher for DB_INT databases.
- * Returns the value of the key as an unsigned int.
+ * Returns the value of the key as an uint64.
  * <code>maxlen</code> is ignored.
  * @param key Key to be hashed
  * @param maxlen Maximum length of the key to hash
@@ -1030,7 +1030,7 @@ static uint64 db_uint_hash(DBKey key, unsigned short maxlen)
 static uint64 db_string_hash(DBKey key, unsigned short maxlen)
 {
 	const char *k = key.str;
-	unsigned int hash = 0;
+	uint32 hash = 0;
 	unsigned short i;
 
 	DB_COUNTSTAT(db_string_hash);
@@ -1056,7 +1056,7 @@ static uint64 db_string_hash(DBKey key, unsigned short maxlen)
 static uint64 db_istring_hash(DBKey key, unsigned short maxlen)
 {
 	const char *k = key.str;
-	unsigned int hash = 0;
+	uint32 hash = 0;
 	unsigned short i;
 
 	DB_COUNTSTAT(db_istring_hash);
@@ -1073,7 +1073,7 @@ static uint64 db_istring_hash(DBKey key, unsigned short maxlen)
 
 /**
  * Default hasher for DB_INT64 databases.
- * Returns the value of the key as an unsigned int.
+ * Returns the value of the key as an uint64.
  * <code>maxlen</code> is ignored.
  * @param key Key to be hashed
  * @param maxlen Maximum length of the key to hash
@@ -1627,13 +1627,13 @@ static DBData* db_obj_get(DBMap* self, DBKey key)
  * @protected
  * @see DBMap#vgetall
  */
-static unsigned int db_obj_vgetall(DBMap* self, DBData **buf, unsigned int max, DBMatcher match, va_list args)
+static uint32 db_obj_vgetall(DBMap* self, DBData **buf, uint32 max, DBMatcher match, va_list args)
 {
 	DBMap_impl* db = (DBMap_impl*)self;
-	unsigned int i;
+	uint32 i;
 	DBNode *node;
 	DBNode *parent;
-	unsigned int ret = 0;
+	uint32 ret = 0;
 
 	DB_COUNTSTAT(db_vgetall);
 	if (db == nullptr) return 0; // nullpo candidate
@@ -1699,10 +1699,10 @@ static unsigned int db_obj_vgetall(DBMap* self, DBData **buf, unsigned int max,
  * @see DBMap#vgetall
  * @see DBMap#getall
  */
-static unsigned int db_obj_getall(DBMap* self, DBData **buf, unsigned int max, DBMatcher match, ...)
+static uint32 db_obj_getall(DBMap* self, DBData **buf, uint32 max, DBMatcher match, ...)
 {
 	va_list args;
-	unsigned int ret;
+	uint32 ret;
 
 	DB_COUNTSTAT(db_getall);
 	if (self == nullptr) return 0; // nullpo candidate
@@ -1730,7 +1730,7 @@ static DBData* db_obj_vensure(DBMap* self, DBKey key, DBCreateData create, va_li
 	DBMap_impl* db = (DBMap_impl*)self;
 	DBNode *node;
 	DBNode *parent = nullptr;
-	unsigned int hash;
+	uint32 hash;
 	int c = 0;
 	DBData *data = nullptr;
 
@@ -1860,7 +1860,7 @@ static int db_obj_put(DBMap* self, DBKey key, DBData data, DBData *out_data)
 	DBNode *node;
 	DBNode *parent = nullptr;
 	int c = 0, retval = 0;
-	unsigned int hash;
+	uint32 hash;
 
 	DB_COUNTSTAT(db_put);
 	if (db == nullptr) return 0; // nullpo candidate
@@ -1963,7 +1963,7 @@ static int db_obj_remove(DBMap* self, DBKey key, DBData *out_data)
 {
 	DBMap_impl* db = (DBMap_impl*)self;
 	DBNode *node;
-	unsigned int hash;
+	uint32 hash;
 	int retval = 0;
 
 	DB_COUNTSTAT(db_remove);
@@ -2017,7 +2017,7 @@ static int db_obj_remove(DBMap* self, DBKey key, DBData *out_data)
 static int db_obj_vforeach(DBMap* self, DBApply func, va_list args)
 {
 	DBMap_impl* db = (DBMap_impl*)self;
-	unsigned int i;
+	uint32 i;
 	int sum = 0;
 	DBNode *node;
 	DBNode *parent;
@@ -2104,7 +2104,7 @@ static int db_obj_vclear(DBMap* self, DBApply func, va_list args)
 {
 	DBMap_impl* db = (DBMap_impl*)self;
 	int sum = 0;
-	unsigned int i;
+	uint32 i;
 	DBNode *node;
 	DBNode *parent;
 
@@ -2279,10 +2279,10 @@ static int db_obj_destroy(DBMap* self, DBApply func, ...)
  * @see DBMap_impl#item_count
  * @see DBMap#size
  */
-static unsigned int db_obj_size(DBMap* self)
+static uint32 db_obj_size(DBMap* self)
 {
 	DBMap_impl* db = (DBMap_impl*)self;
-	unsigned int item_count;
+	uint32 item_count;
 
 	DB_COUNTSTAT(db_size);
 	if (db == nullptr) return 0; // nullpo candidate
@@ -2349,15 +2349,15 @@ static DBOptions db_obj_options(DBMap* self)
  *  db_custom_release  - Get a releaser that behaves a certain way.
  *  db_alloc           - Allocate a new database.
  *  db_i2key           - Manual cast from 'int' to 'DBKey'.
- *  db_ui2key          - Manual cast from 'unsigned int' to 'DBKey'.
+ *  db_ui2key          - Manual cast from 'uint32' to 'DBKey'.
  *  db_str2key         - Manual cast from 'unsigned char *' to 'DBKey'.
  *  db_i642key         - Manual cast from 'int64' to 'DBKey'.
  *  db_ui642key        - Manual cast from 'uin64' to 'DBKey'.
  *  db_i2data          - Manual cast from 'int' to 'DBData'.
- *  db_ui2data         - Manual cast from 'unsigned int' to 'DBData'.
+ *  db_ui2data         - Manual cast from 'uint32' to 'DBData'.
  *  db_ptr2data        - Manual cast from 'void*' to 'DBData'.
  *  db_data2i          - Gets 'int' value from 'DBData'.
- *  db_data2ui         - Gets 'unsigned int' value from 'DBData'.
+ *  db_data2ui         - Gets 'uint32' value from 'DBData'.
  *  db_data2ptr        - Gets 'void*' value from 'DBData'.
  *  db_init            - Initializes the database system.
  *  db_final           - Finalizes the database system.
@@ -2520,7 +2520,7 @@ DBReleaser db_custom_release(DBRelease which)
  */
 DBMap* db_alloc(const char *file, const char *func, int line, DBType type, DBOptions options, unsigned short maxlen) {
 	DBMap_impl* db;
-	unsigned int i;
+	uint32 i;
 	char ers_name[50];
 
 #ifdef DB_ENABLE_STATS
@@ -2601,12 +2601,12 @@ DBKey db_i2key(int key)
 }
 
 /**
- * Manual cast from 'unsigned int' to the union DBKey.
+ * Manual cast from 'uint32' to the union DBKey.
  * @param key Key to be casted
  * @return The key as a DBKey union
  * @public
  */
-DBKey db_ui2key(unsigned int key)
+DBKey db_ui2key(uint32 key)
 {
 	DBKey ret;
 
@@ -2677,12 +2677,12 @@ DBData db_i2data(int data)
 }
 
 /**
- * Manual cast from 'unsigned int' to the struct DBData.
+ * Manual cast from 'uint32' to the struct DBData.
  * @param data Data to be casted
  * @return The data as a DBData struct
  * @public
  */
-DBData db_ui2data(unsigned int data)
+DBData db_ui2data(uint32 data)
 {
 	DBData ret;
 
@@ -2740,13 +2740,13 @@ int db_data2i(DBData *data)
 }
 
 /**
- * Gets unsigned int type data from struct DBData.
- * If data is not unsigned int type, returns 0.
+ * Gets uint32 type data from struct DBData.
+ * If data is not uint32 type, returns 0.
  * @param data Data
- * @return Unsigned int value of the data.
+ * @return uint32 value of the data.
  * @public
  */
-unsigned int db_data2ui(DBData *data)
+uint32 db_data2ui(DBData *data)
 {
 	DB_COUNTSTAT(db_data2ui);
 	if (data && DB_DATA_UINT == data->type)

+ 23 - 23
src/common/db.hpp

@@ -83,7 +83,7 @@ typedef enum DBRelease {
  * See {@link #db_fix_options(DBType,DBOptions)} for restrictions of the
  * types of databases.
  * @param DB_INT Uses int's for keys
- * @param DB_UINT Uses unsigned int's for keys
+ * @param DB_UINT Uses uint32's for keys
  * @param DB_STRING Uses strings for keys.
  * @param DB_ISTRING Uses case insensitive strings for keys.
  * @param DB_INT64 Uses int64's for keys
@@ -150,7 +150,7 @@ typedef enum DBOptions {
  */
 typedef union DBKey {
 	int i;
-	unsigned int ui;
+	uint32 ui;
 	const char *str;
 	int64 i64;
 	uint64 ui64;
@@ -158,8 +158,8 @@ typedef union DBKey {
 
 /**
  * Supported types of database data.
- * @param DB_DATA_INT Uses ints for data.
- * @param DB_DATA_UINT Uses unsigned ints for data.
+ * @param DB_DATA_INT Uses int's for data.
+ * @param DB_DATA_UINT Uses uint32's for data.
  * @param DB_DATA_PTR Uses void pointers for data.
  * @public
  * @see #DBData
@@ -176,7 +176,7 @@ typedef enum DBDataType {
  * @param type Type of data
  * @param u Union of available data types
  * @param u.i Data of int type
- * @param u.ui Data of unsigned int type
+ * @param u.ui Data of uint32 type
  * @param u.ptr Data of void* type
  * @param u.i64 Data of int64 type
  * @public
@@ -185,7 +185,7 @@ typedef struct DBData {
 	DBDataType type;
 	union {
 		int i;
-		unsigned int ui;
+		uint32 ui;
 		void *ptr;
 		int64 i64;
 	} u;
@@ -420,9 +420,9 @@ struct DBMap {
 	 * @param ... Extra arguments for match
 	 * @return The number of entries that matched
 	 * @protected
-	 * @see DBMap#vgetall(DBMap*,void **,unsigned int,DBMatcher,va_list)
+	 * @see DBMap#vgetall(DBMap*,void **,uint32,DBMatcher,va_list)
 	 */
-	unsigned int (*getall)(DBMap* self, DBData** buf, unsigned int max, DBMatcher match, ...);
+	uint32 (*getall)(DBMap* self, DBData** buf, uint32 max, DBMatcher match, ...);
 
 	/**
 	 * Get the data of the entries matched by <code>match</code>.
@@ -438,9 +438,9 @@ struct DBMap {
 	 * @param ... Extra arguments for match
 	 * @return The number of entries that matched
 	 * @protected
-	 * @see DBMap#getall(DBMap*,void **,unsigned int,DBMatcher,...)
+	 * @see DBMap#getall(DBMap*,void **,uint32,DBMatcher,...)
 	 */
-	unsigned int (*vgetall)(DBMap* self, DBData** buf, unsigned int max, DBMatcher match, va_list args);
+	uint32 (*vgetall)(DBMap* self, DBData** buf, uint32 max, DBMatcher match, va_list args);
 
 	/**
 	 * Just calls {@link DBMap#vensure}.
@@ -588,7 +588,7 @@ struct DBMap {
 	 * @return Size of the database
 	 * @protected
 	 */
-	unsigned int (*size)(DBMap* self);
+	uint32 (*size)(DBMap* self);
 
 	/**
 	 * Return the type of the database.
@@ -701,7 +701,7 @@ struct DBMap {
 
 // Database creation and destruction macros
 #define idb_alloc(opt)            db_alloc(__FILE__,__func__,__LINE__,DB_INT,(opt),sizeof(int))
-#define uidb_alloc(opt)           db_alloc(__FILE__,__func__,__LINE__,DB_UINT,(opt),sizeof(unsigned int))
+#define uidb_alloc(opt)           db_alloc(__FILE__,__func__,__LINE__,DB_UINT,(opt),sizeof(uint32))
 #define strdb_alloc(opt,maxlen)   db_alloc(__FILE__,__func__,__LINE__,DB_STRING,(opt),(maxlen))
 #define stridb_alloc(opt,maxlen)  db_alloc(__FILE__,__func__,__LINE__,DB_ISTRING,(opt),(maxlen))
 #define i64db_alloc(opt)          db_alloc(__FILE__,__func__,__LINE__,DB_INT64,(opt),sizeof(int64))
@@ -729,15 +729,15 @@ struct DBMap {
  *  db_custom_release  - Get the releaser that behaves as specified.         *
  *  db_alloc           - Allocate a new database.                            *
  *  db_i2key           - Manual cast from 'int' to 'DBKey'.                  *
- *  db_ui2key          - Manual cast from 'unsigned int' to 'DBKey'.         *
+ *  db_ui2key          - Manual cast from 'uint32' to 'DBKey'.               *
  *  db_str2key         - Manual cast from 'unsigned char *' to 'DBKey'.      *
  *  db_i642key         - Manual cast from 'int64' to 'DBKey'.                *
  *  db_ui642key        - Manual cast from 'uint64' to 'DBKey'.               *
  *  db_i2data          - Manual cast from 'int' to 'DBData'.                 *
- *  db_ui2data         - Manual cast from 'unsigned int' to 'DBData'.        *
+ *  db_ui2data         - Manual cast from 'uint32' to 'DBData'.              *
  *  db_ptr2data        - Manual cast from 'void*' to 'DBData'.               *
  *  db_data2i          - Gets 'int' value from 'DBData'.                     *
- *  db_data2ui         - Gets 'unsigned int' value from 'DBData'.            *
+ *  db_data2ui         - Gets 'uint32' value from 'DBData'.                  *
  *  db_data2ptr        - Gets 'void*' value from 'DBData'.                   *
  *  db_init            - Initializes the database system.                    *
  *  db_final           - Finalizes the database system.                      *
@@ -837,12 +837,12 @@ DBMap* db_alloc(const char *file, const char *func, int line, DBType type, DBOpt
 DBKey db_i2key(int key);
 
 /**
- * Manual cast from 'unsigned int' to the union DBKey.
+ * Manual cast from 'uint32' to the union DBKey.
  * @param key Key to be casted
  * @return The key as a DBKey union
  * @public
  */
-DBKey db_ui2key(unsigned int key);
+DBKey db_ui2key(uint32 key);
 
 /**
  * Manual cast from 'unsigned char *' to the union DBKey.
@@ -877,12 +877,12 @@ DBKey db_ui642key(uint64 key);
 DBData db_i2data(int data);
 
 /**
- * Manual cast from 'unsigned int' to the struct DBData.
+ * Manual cast from 'uint32' to the struct DBData.
  * @param data Data to be casted
  * @return The data as a DBData struct
  * @public
  */
-DBData db_ui2data(unsigned int data);
+DBData db_ui2data(uint32 data);
 
 /**
  * Manual cast from 'void *' to the struct DBData.
@@ -910,13 +910,13 @@ DBData db_i642data(int64 data);
 int db_data2i(DBData *data);
 
 /**
- * Gets unsigned int type data from struct DBData.
- * If data is not unsigned int type, returns 0.
+ * Gets uint32 type data from struct DBData.
+ * If data is not uint32 type, returns 0.
  * @param data Data
- * @return Unsigned int value of the data.
+ * @return uint32 value of the data.
  * @public
  */
-unsigned int db_data2ui(DBData *data);
+uint32 db_data2ui(DBData *data);
 
 /**
  * Gets void* type data from struct DBData.

+ 11 - 11
src/common/ers.cpp

@@ -64,7 +64,7 @@ struct ers_instance_t;
 typedef struct ers_cache
 {
 	// Allocated object size, including ers_list size
-	unsigned int ObjectSize;
+	uint32 ObjectSize;
 
 	// Number of ers_instances referencing this
 	int ReferenceCount;
@@ -76,19 +76,19 @@ typedef struct ers_cache
 	unsigned char **Blocks;
 
 	// Max number of blocks
-	unsigned int Max;
+	uint32 Max;
 
 	// Free objects count
-	unsigned int Free;
+	uint32 Free;
 
 	// Used blocks count
-	unsigned int Used;
+	uint32 Used;
 
 	// Objects in-use count
-	unsigned int UsedObjs;
+	uint32 UsedObjs;
 
 	// Default = ERS_BLOCK_ENTRIES, can be adjusted for performance for individual cache sizes.
-	unsigned int ChunkSize;
+	uint32 ChunkSize;
 
 	// Misc options, some options are shared from the instance
 	enum ERSOptions Options;
@@ -111,7 +111,7 @@ struct ers_instance_t {
 	ers_cache_t *Cache;
 
 	// Count of objects in use, used for detecting memory leaks
-	unsigned int Count;
+	uint32 Count;
 
 	struct ers_instance_t *Next, *Prev;
 };
@@ -124,7 +124,7 @@ static struct ers_instance_t *InstanceList = nullptr;
 /**
  * @param Options the options from the instance seeking a cache, we use it to give it a cache with matching configuration
  **/
-static ers_cache_t *ers_find_cache(unsigned int size, enum ERSOptions Options) {
+static ers_cache_t *ers_find_cache(uint32 size, enum ERSOptions Options) {
 	ers_cache_t *cache;
 
 	for (cache = CacheList; cache; cache = cache->Next)
@@ -160,7 +160,7 @@ static ers_cache_t *ers_find_cache(unsigned int size, enum ERSOptions Options) {
 
 static void ers_free_cache(ers_cache_t *cache, bool remove)
 {
-	unsigned int i;
+	uint32 i;
 
 	for (i = 0; i < cache->Used; i++)
 		aFree(cache->Blocks[i]);
@@ -277,7 +277,7 @@ static void ers_obj_destroy(ERS *self)
 	aFree(instance);
 }
 
-void ers_cache_size(ERS *self, unsigned int new_size) {
+void ers_cache_size(ERS *self, uint32 new_size) {
 	struct ers_instance_t *instance = (struct ers_instance_t *)self;
 
 	nullpo_retv(instance);
@@ -331,7 +331,7 @@ ERS *ers_new(uint32 size, const char *name, enum ERSOptions options)
 
 void ers_report(void) {
 	ers_cache_t *cache;
-	unsigned int cache_c = 0, blocks_u = 0, blocks_a = 0, memory_b = 0, memory_t = 0;
+	uint32 cache_c = 0, blocks_u = 0, blocks_a = 0, memory_b = 0, memory_t = 0;
 
 	for (cache = CacheList; cache; cache = cache->Next) {
 		cache_c++;

+ 1 - 1
src/common/ers.hpp

@@ -127,7 +127,7 @@ typedef struct eri {
 	void (*destroy)(struct eri *self);
 
 	/* */
-	void (*chunk_size) (struct eri *self, unsigned int new_size);
+	void (*chunk_size) (struct eri *self, uint32 new_size);
 } ERS;
 
 #ifdef DISABLE_ERS

+ 4 - 4
src/common/grfio.cpp

@@ -58,7 +58,7 @@ char data_dir[1024] = "";
 
 
 // little endian char array to uint conversion
-static unsigned int getlong(unsigned char* p)
+static uint32 getlong(unsigned char* p)
 {
 	return (p[0] << 0 | p[1] << 8 | p[2] << 16 | p[3] << 24);
 }
@@ -235,7 +235,7 @@ static void grf_decode(unsigned char* buf, size_t len, char entry_type, int entr
  ******************************************************/
 
 /// zlib crc32
-unsigned long grfio_crc32(const unsigned char* buf, unsigned int len)
+unsigned long grfio_crc32(const unsigned char* buf, uint32 len)
 {
 	return crc32(crc32(0L, Z_NULL, 0), buf, len);
 }
@@ -272,7 +272,7 @@ static void hashinit(void)
 // hashes a filename string into a number from {0..255}
 static int filehash(const char* fname)
 {
-	unsigned int hash = 0;
+	uint32 hash = 0;
 	while(*fname) {
 		hash = (hash<<1) + (hash>>7)*9 + TOLOWER(*fname);
 		fname++;
@@ -363,7 +363,7 @@ static void filelist_compact(void)
 /// Combines are resource path with the data folder location to create local resource path.
 static void grfio_localpath_create(char* buffer, size_t size, const char* filename)
 {
-	unsigned int i;
+	uint32 i;
 	size_t len;
 
 	len = strlen(data_dir);

+ 1 - 1
src/common/grfio.hpp

@@ -14,7 +14,7 @@ void* grfio_reads(const char* fname, size_t* size = nullptr);
 char* grfio_find_file(const char* fname);
 int32 grfio_read_rsw_water_level( const char* fname );
 
-unsigned long grfio_crc32(const unsigned char *buf, unsigned int len);
+unsigned long grfio_crc32(const unsigned char *buf, uint32 len);
 int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen);
 int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen);
 

+ 23 - 28
src/common/md5calc.cpp

@@ -21,10 +21,10 @@
 #endif
 
 // Global variable
-static unsigned int *pX;
+static uint32 *pX;
 
 // String Table
-static const unsigned int T[] = {
+static const uint32 T[] = {
    0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee, //0
    0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501, //4
    0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be, //8
@@ -47,70 +47,65 @@ static const unsigned int T[] = {
 #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
 
 // The function used for other calculation
-static unsigned int F(unsigned int X, unsigned int Y, unsigned int Z)
+static uint32 F(uint32 X, uint32 Y, uint32 Z)
 {
    return (X & Y) | (~X & Z);
 }
-static unsigned int G(unsigned int X, unsigned int Y, unsigned int Z)
+static uint32 G(uint32 X, uint32 Y, uint32 Z)
 {
    return (X & Z) | (Y & ~Z);
 }
-static unsigned int H(unsigned int X, unsigned int Y, unsigned int Z)
+static uint32 H(uint32 X, uint32 Y, uint32 Z)
 {
    return X ^ Y ^ Z;
 }
-static unsigned int I(unsigned int X, unsigned int Y, unsigned int Z)
+static uint32 I(uint32 X, uint32 Y, uint32 Z)
 {
    return Y ^ (X | ~Z);
 }
 
-static unsigned int Round(unsigned int a, unsigned int b, unsigned int FGHI,
-                     unsigned int k, unsigned int s, unsigned int i)
+static uint32 Round(uint32 a, uint32 b, uint32 FGHI, uint32 k, uint32 s, uint32 i)
 {
    return b + ROTATE_LEFT(a + FGHI + pX[k] + T[i], s);
 }
 
-static void Round1(unsigned int *a, unsigned int b, unsigned int c,
-		unsigned int d,unsigned int k, unsigned int s, unsigned int i)
+static void Round1(uint32 *a, uint32 b, uint32 c, uint32 d,uint32 k, uint32 s, uint32 i)
 {
 	*a = Round(*a, b, F(b,c,d), k, s, i);
 }
-static void Round2(unsigned int *a, unsigned int b, unsigned int c,
-		unsigned int d,unsigned int k, unsigned int s, unsigned int i)
+static void Round2(uint32 *a, uint32 b, uint32 c, uint32 d,uint32 k, uint32 s, uint32 i)
 {
 	*a = Round(*a, b, G(b,c,d), k, s, i);
 }
-static void Round3(unsigned int *a, unsigned int b, unsigned int c,
-		unsigned int d,unsigned int k, unsigned int s, unsigned int i)
+static void Round3(uint32 *a, uint32 b, uint32 c, uint32 d,uint32 k, uint32 s, uint32 i)
 {
 	*a = Round(*a, b, H(b,c,d), k, s, i);
 }
-static void Round4(unsigned int *a, unsigned int b, unsigned int c,
-		unsigned int d,unsigned int k, unsigned int s, unsigned int i)
+static void Round4(uint32 *a, uint32 b, uint32 c, uint32 d,uint32 k, uint32 s, uint32 i)
 {
 	*a = Round(*a, b, I(b,c,d), k, s, i);
 }
 
 static void MD5_Round_Calculate(const unsigned char *block,
-	unsigned int *A2, unsigned int *B2, unsigned int *C2, unsigned int *D2)
+	uint32 *A2, uint32 *B2, uint32 *C2, uint32 *D2)
 {
 	//create X It is since it is required.
-	unsigned int X[16]; //512bit 64byte
+	uint32 X[16]; //512bit 64byte
 	int j,k;
 
 	//Save A as AA, B as BB, C as CC, and and D as DD (saving of A, B, C, and D)
-	unsigned int A=*A2, B=*B2, C=*C2, D=*D2;
-	unsigned int AA = A,BB = B,CC = C,DD = D;
+	uint32 A=*A2, B=*B2, C=*C2, D=*D2;
+	uint32 AA = A,BB = B,CC = C,DD = D;
 
 	//It is a large region variable reluctantly because of calculation of a round. . . for Round1...4
 	pX = X;
 
 	//Copy block(padding_message) i into X
 	for (j=0,k=0; j<64; j+=4,k++)
-		X[k] = ( (unsigned int )block[j] )         // 8byte*4 -> 32byte conversion
-			| ( ((unsigned int )block[j+1]) << 8 ) // A function called Decode as used in the field of RFC
-			| ( ((unsigned int )block[j+2]) << 16 )
-			| ( ((unsigned int )block[j+3]) << 24 );
+		X[k] = ( (uint32)block[j] )         // 8byte*4 -> 32byte conversion
+			| ( ((uint32)block[j+1]) << 8 ) // A function called Decode as used in the field of RFC
+			| ( ((uint32)block[j+2]) << 16 )
+			| ( ((uint32)block[j+3]) << 24 );
 
 
    //Round 1
@@ -155,11 +150,11 @@ static void MD5_String2binary(const char * string, unsigned char * output)
    unsigned char *pstring;            //The position of string in the present scanning notes is held.
 
    /*32bit*/
-   unsigned int string_byte_len,     //The byte chief of string is held.
+   uint32 string_byte_len,     //The byte chief of string is held.
                 string_bit_len,      //The bit length of string is held.
                 copy_len,            //The number of bytes which is used by 1-3 and which remained
                 msg_digest[4];       //Message digest   128bit 4byte
-   unsigned int *A = &msg_digest[0], //The message digest in accordance with RFC (reference)
+   uint32 *A = &msg_digest[0], //The message digest in accordance with RFC (reference)
                 *B = &msg_digest[1],
                 *C = &msg_digest[2],
                 *D = &msg_digest[3];
@@ -174,7 +169,7 @@ static void MD5_String2binary(const char * string, unsigned char * output)
 
    //Step 1.Append Padding Bits (extension of a mark bit)
    //1-1
-   string_byte_len = (unsigned int)strlen(string);    //The byte chief of a character sequence is acquired.
+   string_byte_len = (uint32)strlen(string);    //The byte chief of a character sequence is acquired.
    pstring = (unsigned char *)string; //The position of the present character sequence is set.
 
    //1-2  Repeat calculation until length becomes less than 64 bytes.
@@ -200,7 +195,7 @@ static void MD5_String2binary(const char * string, unsigned char * output)
 
    //When bit length cannot be expressed in 32 bytes of low rank, it is a beam raising to a higher rank.
   if (UINT_MAX / 8 < string_byte_len) {
-      unsigned int high = (string_byte_len - UINT_MAX / 8) * 8;
+      uint32 high = (string_byte_len - UINT_MAX / 8) * 8;
       memcpy(&padding_message[60], &high, 4);
   } else
       memset(&padding_message[60], 0, 4); //In this case, it is good for a higher rank at 0.

+ 13 - 13
src/common/mmo.hpp

@@ -314,16 +314,16 @@ struct item {
 	int id;
 	t_itemid nameid;
 	short amount;
-	unsigned int equip; // location(s) where item is equipped (using enum equip_pos for bitmasking)
+	uint32 equip; // location(s) where item is equipped (using enum equip_pos for bitmasking)
 	char identify;
 	char refine;
 	char attribute;
 	t_itemid card[MAX_SLOTS];
 	struct s_item_randomoption option[MAX_ITEM_RDM_OPT];		// max of 5 random options can be supported.
-	unsigned int expire_time;
+	uint32 expire_time;
 	char favorite, bound;
 	uint64 unique_id;
-	unsigned int equipSwitch; // location(s) where item is equipped for equip switching (using enum equip_pos for bitmasking)
+	uint32 equipSwitch; // location(s) where item is equipped for equip switching (using enum equip_pos for bitmasking)
 	uint8 enchantgrade;
 } __attribute__((packed));
 
@@ -398,8 +398,8 @@ struct s_skill {
 };
 
 struct script_reg_state {
-	unsigned int type : 1; // because I'm a memory hoarder and having them in the same struct would be a 8-byte/instance waste while ints outnumber str on a 10000-to-1 ratio.
-	unsigned int update : 1; // whether it needs to be sent to char server for insertion/update/delete
+	uint32 type : 1; // because I'm a memory hoarder and having them in the same struct would be a 8-byte/instance waste while ints outnumber str on a 10000-to-1 ratio.
+	uint32 update : 1; // whether it needs to be sent to char server for insertion/update/delete
 };
 
 struct script_reg_num {
@@ -498,7 +498,7 @@ struct s_homunculus {	//[orn]
 	short class_;
 	short prev_class;
 	uint32 hp,max_hp,sp,max_sp;
-	unsigned int intimacy;	//[orn]
+	uint32 intimacy;	//[orn]
 	short hunger;
 	struct s_skill hskill[MAX_HOMUNSKILL]; //albator
 	short skillpts;
@@ -529,7 +529,7 @@ struct s_mercenary {
 	uint32 char_id;
 	short class_;
 	int hp, sp;
-	unsigned int kill_count;
+	uint32 kill_count;
 	t_tick life_time;
 };
 
@@ -551,7 +551,7 @@ struct s_friend {
 
 #ifdef HOTKEY_SAVING
 struct hotkey {
-	unsigned int id;
+	uint32 id;
 	unsigned short lv;
 	unsigned char type; // 0: item, 1: skill
 };
@@ -569,9 +569,9 @@ struct mmo_charstatus {
 	int zeny;
 
 	short class_; ///< Player's JobID
-	unsigned int status_point,skill_point,trait_point;
+	uint32 status_point,skill_point,trait_point;
 	int hp,max_hp,sp,max_sp,ap,max_ap;
-	unsigned int option;
+	uint32 option;
 	short manner; // Defines how many minutes a char will be muted, each negative point is equivalent to a minute.
 	unsigned char karma;
 	short hair,hair_color,clothes_color,body;
@@ -590,7 +590,7 @@ struct mmo_charstatus {
 	uint8 body_direction;
 
 	char name[NAME_LENGTH];
-	unsigned int base_level,job_level;
+	uint32 base_level,job_level;
 	unsigned short str,agi,vit,int_,dex,luk;
 	unsigned short pow,sta,wis,spl,con,crt;
 	unsigned char slot,sex;
@@ -616,7 +616,7 @@ struct mmo_charstatus {
 	time_t unban_time;
 
 	// Char server addon system
-	unsigned int character_moves;
+	uint32 character_moves;
 
 	unsigned char font;
 
@@ -675,7 +675,7 @@ struct mail_data {
 };
 
 struct auction_data {
-	unsigned int auction_id;
+	uint32 auction_id;
 	int seller_id;
 	char seller_name[NAME_LENGTH];
 	int buyer_id;

+ 6 - 6
src/common/socket.cpp

@@ -754,7 +754,7 @@ static void delete_session(int fd)
 	}
 }
 
-int _realloc_fifo( int fd, unsigned int rfifo_size, unsigned int wfifo_size, const char* file, int line, const char* func ){
+int _realloc_fifo( int fd, uint32 rfifo_size, uint32 wfifo_size, const char* file, int line, const char* func ){
 	if( !session_isValid(fd) )
 		return 0;
 
@@ -831,7 +831,7 @@ int WFIFOSET(int fd, size_t len)
 	if(s->wdata_size+len > s->max_wdata)
 	{	// actually there was a buffer overflow already
 		uint32 ip = s->client_addr;
-		ShowFatalError("WFIFOSET: Write Buffer Overflow. Connection %d (%d.%d.%d.%d) has written %u bytes on a %u/%u bytes buffer.\n", fd, CONVIP(ip), (unsigned int)len, (unsigned int)s->wdata_size, (unsigned int)s->max_wdata);
+		ShowFatalError("WFIFOSET: Write Buffer Overflow. Connection %d (%d.%d.%d.%d) has written %u bytes on a %u/%u bytes buffer.\n", fd, CONVIP(ip), (uint32)len, (uint32)s->wdata_size, (uint32)s->max_wdata);
 		ShowDebug("Likely command that caused it: 0x%x\n", (*(uint16*)(s->wdata + s->wdata_size)));
 		// no other chance, make a better fifo model
 		exit(EXIT_FAILURE);
@@ -841,7 +841,7 @@ int WFIFOSET(int fd, size_t len)
 	{
 		// dynamic packets allow up to UINT16_MAX bytes (<packet_id>.W <packet_len>.W ...)
 		// all known fixed-size packets are within this limit, so use the same limit
-		ShowFatalError("WFIFOSET: Packet 0x%x is too big. (len=%u, max=%u)\n", (*(uint16*)(s->wdata + s->wdata_size)), (unsigned int)len, 0xFFFF);
+		ShowFatalError("WFIFOSET: Packet 0x%x is too big. (len=%u, max=%u)\n", (*(uint16*)(s->wdata + s->wdata_size)), (uint32)len, 0xFFFF);
 		exit(EXIT_FAILURE);
 	}
 	else if( len == 0 )
@@ -1255,8 +1255,8 @@ int access_ipmask(const char* str, AccessControl* acc)
 		ip   = 0;
 		mask = 0;
 	} else {
-		unsigned int a[4];
-		unsigned int m[4];
+		uint32 a[4];
+		uint32 m[4];
 		int n;
 		if( ((n=sscanf(str,"%3u.%3u.%3u.%3u/%3u.%3u.%3u.%3u",a,a+1,a+2,a+3,m,m+1,m+2,m+3)) != 8 && // not an ip + standard mask
 				(n=sscanf(str,"%3u.%3u.%3u.%3u/%3u",a,a+1,a+2,a+3,m)) != 5 && // not an ip + bit mask
@@ -1532,7 +1532,7 @@ int socket_getips(uint32* ips, int max)
 void socket_init(void)
 {
 	const char *SOCKET_CONF_FILENAME = "conf/packet_athena.conf";
-	unsigned int rlim_cur = MAXCONN;
+	uint32 rlim_cur = MAXCONN;
 
 #ifdef WIN32
 	{// Start up windows networking

+ 1 - 1
src/common/socket.hpp

@@ -136,7 +136,7 @@ int make_listen_bind(uint32 ip, uint16 port);
 int make_connection(uint32 ip, uint16 port, bool silent, int timeout);
 #define realloc_fifo( fd, rfifo_size, wfifo_size ) _realloc_fifo( ( fd ), ( rfifo_size ), ( wfifo_size ), ALC_MARK )
 #define realloc_writefifo( fd, addition ) _realloc_writefifo( ( fd ), ( addition ), ALC_MARK )
-int _realloc_fifo( int fd, unsigned int rfifo_size, unsigned int wfifo_size, const char* file, int line, const char* func );
+int _realloc_fifo( int fd, uint32 rfifo_size, uint32 wfifo_size, const char* file, int line, const char* func );
 int _realloc_writefifo( int fd, size_t addition, const char* file, int line, const char* func );
 int WFIFOSET(int fd, size_t len);
 int RFIFOSKIP(int fd, size_t len);

+ 9 - 9
src/common/sql.cpp

@@ -25,10 +25,10 @@
 #define my_bool bool
 #endif
 
-void ra_mysql_error_handler(unsigned int ecode);
+void ra_mysql_error_handler(uint32 ecode);
 
 int mysql_reconnect_type;
-unsigned int mysql_reconnect_count;
+uint32 mysql_reconnect_count;
 
 /// Sql handle
 struct Sql
@@ -98,7 +98,7 @@ Sql* Sql_Malloc(void)
  * @param self : sql handle
  * @return last error number
  */
-unsigned int Sql_GetError( Sql* self ){
+uint32 Sql_GetError( Sql* self ){
 	return mysql_errno( &self->handle );
 }
 
@@ -122,14 +122,14 @@ int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* hos
 	StringBuf_Clear(&self->buf);
 
 #if !defined(MARIADB_BASE_VERSION) && !defined(MARIADB_VERSION_ID) && MYSQL_VERSION_ID >= 50710
-	unsigned int md = SSL_MODE_DISABLED;
+	uint32 md = SSL_MODE_DISABLED;
 
 	if( mysql_options( &self->handle, MYSQL_OPT_SSL_MODE, &md ) ){
 		ShowSQL( "Your MySQL version does not understand \"MYSQL_OPT_SSL_MODE\" yet. Please consider upgrading - especially if you encounter SSL related error messages from your MySQL server.\n" );
 	}
 #endif
 
-	if( !mysql_real_connect(&self->handle, host, user, passwd, db, (unsigned int)port, nullptr/*unix_socket*/, 0/*clientflag*/) )
+	if( !mysql_real_connect(&self->handle, host, user, passwd, db, (uint32)port, nullptr/*unix_socket*/, 0/*clientflag*/) )
 	{
 		ShowSQL("%s\n", mysql_error(&self->handle));
 		return SQL_ERROR;
@@ -659,7 +659,7 @@ static void SqlStmt_P_ShowDebugTruncatedColumn(SqlStmt* self, size_t i)
 	MYSQL_BIND* column;
 
 	meta = mysql_stmt_result_metadata(self->stmt);
-	field = mysql_fetch_field_direct(meta, (unsigned int)i);
+	field = mysql_fetch_field_direct(meta, (uint32)i);
 	ShowSQL("DB error - data of field '%s' was truncated.\n", field->name);
 	ShowDebug("column - %lu\n", (unsigned long)i);
 	Sql_P_ShowDebugMysqlFieldInfo("data   - ", field->type, field->flags&UNSIGNED_FLAG, self->column_lengths[i].length, "");
@@ -947,7 +947,7 @@ int SqlStmt_NextRow(SqlStmt* self)
 		{
 			MYSQL_BIND* column = &self->columns[i];
 			column->error = &truncated;
-			mysql_stmt_fetch_column(self->stmt, column, (unsigned int)i, 0);
+			mysql_stmt_fetch_column(self->stmt, column, (uint32)i, 0);
 			column->error = nullptr;
 			if( truncated )
 			{// report truncated column
@@ -1045,11 +1045,11 @@ void SqlStmt_Free(SqlStmt* self)
 
 
 /// Receives MySQL error codes during runtime (not on first-time-connects).
-void ra_mysql_error_handler(unsigned int ecode) {
+void ra_mysql_error_handler(uint32 ecode) {
 	switch( ecode ) {
 		case 2003:// Can't connect to MySQL (this error only happens here when failing to reconnect)
 			if( mysql_reconnect_type == 1 ) {
-				static unsigned int retry = 1;
+				static uint32 retry = 1;
 				if( ++retry > mysql_reconnect_count ) {
 					ShowFatalError("MySQL has been unreachable for too long, %d reconnects were attempted. Shutting Down\n", retry);
 					exit(EXIT_FAILURE);

+ 1 - 1
src/common/sql.hpp

@@ -69,7 +69,7 @@ struct Sql* Sql_Malloc(void);
 
 
 /// Retrieves the last error number.
-unsigned int Sql_GetError( Sql* self );
+uint32 Sql_GetError( Sql* self );
 
 
 

+ 1 - 1
src/common/timer.cpp

@@ -146,7 +146,7 @@ static t_tick tick(void)
 #endif
 #elif defined(ENABLE_RDTSC)
 	//
-		return (unsigned int)((_rdtsc() - RDTSC_BEGINTICK) / RDTSC_CLOCK);
+		return (uint32)((_rdtsc() - RDTSC_BEGINTICK) / RDTSC_CLOCK);
 	//
 #elif defined(HAVE_MONOTONIC_CLOCK)
 	struct timespec tval;

+ 1 - 1
src/common/timer.hpp

@@ -38,7 +38,7 @@ typedef TIMER_FUNC((*TimerFunc));
 struct TimerData {
 	t_tick tick;
 	TimerFunc func;
-	unsigned int type;
+	uint32 type;
 	int interval;
 
 	// general-purpose storage

+ 4 - 4
src/common/utils.cpp

@@ -40,14 +40,14 @@ void WriteDump(FILE* fp, const void* buffer, size_t length)
 
 		if( (i%16) == 15 )
 		{
-			fprintf(fp, "%03X %s  %s\n", (unsigned int)(i/16), hex, ascii);
+			fprintf(fp, "%03X %s  %s\n", (uint32)(i/16), hex, ascii);
 		}
 	}
 
 	if( (i%16) != 0 )
 	{
 		ascii[i%16] = 0;
-		fprintf(fp, "%03X %-48s  %-16s\n", (unsigned int)(i/16), hex, ascii);
+		fprintf(fp, "%03X %-48s  %-16s\n", (uint32)(i/16), hex, ascii);
 	}
 }
 
@@ -359,7 +359,7 @@ float GetFloat(const unsigned char* buf)
 }
 
 /// calculates the value of A / B, in percent (rounded down)
-unsigned int get_percentage(const unsigned int A, const unsigned int B)
+uint32 get_percentage(const uint32 A, const uint32 B)
 {
 	double result;
 
@@ -377,7 +377,7 @@ unsigned int get_percentage(const unsigned int A, const unsigned int B)
 		return UINT_MAX;
 	}
 
-	return (unsigned int)floor(result);
+	return (uint32)floor(result);
 }
 
 uint32 get_percentage_exp(const uint64 a, const uint64 b)

+ 1 - 1
src/common/utils.hpp

@@ -26,7 +26,7 @@ bool exists(const char* filename);
 #define apply_rate2(val, rate, per) (((rate) == (per)) ? (val) : ((val) > 100000) ? ((val) / (per) * (rate)) : ((val) * (rate) / (per)))
 
 /// calculates the value of A / B, in percent (rounded down)
-unsigned int get_percentage(const unsigned int A, const unsigned int B);
+uint32 get_percentage(const uint32 A, const uint32 B);
 uint32 get_percentage_exp(const uint64 a, const uint64 b);
 
 //////////////////////////////////////////////////////////////////////////

+ 3 - 3
src/login/account.cpp

@@ -514,11 +514,11 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, uint32
 	Sql_GetData(sql_handle,  2, &data, nullptr); safestrncpy(acc->pass, data, sizeof(acc->pass));
 	Sql_GetData(sql_handle,  3, &data, nullptr); acc->sex = data[0];
 	Sql_GetData(sql_handle,  4, &data, nullptr); safestrncpy(acc->email, data, sizeof(acc->email));
-	Sql_GetData(sql_handle,  5, &data, nullptr); acc->group_id = (unsigned int) atoi(data);
-	Sql_GetData(sql_handle,  6, &data, nullptr); acc->state = (unsigned int) strtoul(data, nullptr, 10);
+	Sql_GetData(sql_handle,  5, &data, nullptr); acc->group_id = (uint32)atoi(data);
+	Sql_GetData(sql_handle,  6, &data, nullptr); acc->state = (uint32)strtoul(data, nullptr, 10);
 	Sql_GetData(sql_handle,  7, &data, nullptr); acc->unban_time = atol(data);
 	Sql_GetData(sql_handle,  8, &data, nullptr); acc->expiration_time = atol(data);
-	Sql_GetData(sql_handle,  9, &data, nullptr); acc->logincount = (unsigned int) strtoul(data, nullptr, 10);
+	Sql_GetData(sql_handle,  9, &data, nullptr); acc->logincount = (uint32)strtoul(data, nullptr, 10);
 	Sql_GetData(sql_handle, 10, &data, nullptr); safestrncpy(acc->lastlogin, data==nullptr?"":data, sizeof(acc->lastlogin));
 	Sql_GetData(sql_handle, 11, &data, nullptr); safestrncpy(acc->last_ip, data, sizeof(acc->last_ip));
 	Sql_GetData(sql_handle, 12, &data, nullptr); safestrncpy(acc->birthdate, data==nullptr?"":data, sizeof(acc->birthdate));

+ 3 - 3
src/login/account.hpp

@@ -21,12 +21,12 @@ struct mmo_account {
 	char pass[32+1];        // 23+1 for plaintext, 32+1 for md5-ed passwords
 	char sex;               // gender (M/F/S)
 	char email[40];         // e-mail (by default: a@a.com)
-	unsigned int group_id;  // player group id
+	uint32 group_id;        // player group id
 	uint8 char_slots;       // this accounts maximum character slots (maximum is limited to MAX_CHARS define in char server)
-	unsigned int state;     // packet 0x006a value + 1 (0: compte OK)
+	uint32 state;           // packet 0x006a value + 1 (0: compte OK)
 	time_t unban_time;      // (timestamp): ban time limit of the account (0 = no ban)
 	time_t expiration_time; // (timestamp): validity limit of the account (0 = unlimited)
-	unsigned int logincount;// number of successful auth attempts
+	uint32 logincount;      // number of successful auth attempts
 	char lastlogin[24];     // date+time of last successful login
 	char last_ip[16];       // save of last IP of connection
 	char birthdate[10+1];   // assigned birth date (format: YYYY-MM-DD)

+ 4 - 4
src/login/login.cpp

@@ -656,9 +656,9 @@ bool login_config_read(const char* cfgName, bool normal) {
 		else if(!strcmpi(w1, "dnsbl_servers"))
 			safestrncpy(login_config.dnsbl_servs, w2, sizeof(login_config.dnsbl_servs));
 		else if(!strcmpi(w1, "ipban_cleanup_interval"))
-			login_config.ipban_cleanup_interval = (unsigned int)atoi(w2);
+			login_config.ipban_cleanup_interval = (uint32)atoi(w2);
 		else if(!strcmpi(w1, "ip_sync_interval"))
-			login_config.ip_sync_interval = (unsigned int)1000*60*atoi(w2); //w2 comes in minutes.
+			login_config.ip_sync_interval = (uint32)1000*60*atoi(w2); //w2 comes in minutes.
 		else if(!strcmpi(w1, "client_hash_check"))
 			login_config.client_hash_check = config_switch(w2);
 		else if(!strcmpi(w1, "use_web_auth_token"))
@@ -678,7 +678,7 @@ bool login_config_read(const char* cfgName, bool normal) {
 					int i;
 					for (i = 0; i < 32; i += 2) {
 						char buf[3];
-						unsigned int byte;
+						uint32 byte;
 
 						memcpy(buf, &md5[i], 2);
 						buf[2] = 0;
@@ -717,7 +717,7 @@ bool login_config_read(const char* cfgName, bool normal) {
 				login_config.vip_sys.char_increase = MAX_CHAR_VIP;
 			else
 				login_config.vip_sys.char_increase = atoi(w2);
-			if (login_config.vip_sys.char_increase > (unsigned int) MAX_CHARS-login_config.char_per_account) {
+			if (login_config.vip_sys.char_increase > (uint32)MAX_CHARS-login_config.char_per_account) {
 				ShowWarning("vip_char_increase too high, can only go up to %d, according to your char_per_account config %d\n",
 					MAX_CHARS-login_config.char_per_account,login_config.char_per_account);
 				login_config.vip_sys.char_increase = MAX_CHARS-login_config.char_per_account;

+ 8 - 8
src/login/login.hpp

@@ -75,7 +75,7 @@ struct mmo_char_server {
 extern struct mmo_char_server ch_server[MAX_SERVERS];
 
 struct client_hash_node {
-	unsigned int group_id;			//inferior or egal group to apply restriction
+	uint32 group_id;				//inferior or egal group to apply restriction
 	uint8 hash[16];					///hash required for that groupid or below
 	struct client_hash_node *next;	///next entry
 };
@@ -83,8 +83,8 @@ struct client_hash_node {
 struct Login_Config {
 	uint32 login_ip;                                /// the address to bind to
 	uint16 login_port;                              /// the port to bind to
-	unsigned int ipban_cleanup_interval;            /// interval (in seconds) to clean up expired IP bans
-	unsigned int ip_sync_interval;                  /// interval (in minutes) to execute a DNS/IP update (for dynamic IPs)
+	uint32 ipban_cleanup_interval;                  /// interval (in seconds) to clean up expired IP bans
+	uint32 ip_sync_interval;                        /// interval (in minutes) to execute a DNS/IP update (for dynamic IPs)
 	bool log_login;                                 /// whether to log login server actions or not
 	char date_format[32];                           /// date format used in messages
 	bool console;                                   /// console input system enabled?
@@ -98,9 +98,9 @@ struct Login_Config {
 
 	bool ipban;                                     /// perform IP blocking (via contents of `ipbanlist`) ?
 	bool dynamic_pass_failure_ban;                  /// automatic IP blocking due to failed login attempts ?
-	unsigned int dynamic_pass_failure_ban_interval; /// how far to scan the loginlog for password failures in minutes
-	unsigned int dynamic_pass_failure_ban_limit;    /// number of failures needed to trigger the ipban
-	unsigned int dynamic_pass_failure_ban_duration; /// duration of the ipban in minutes
+	uint32 dynamic_pass_failure_ban_interval;       /// how far to scan the loginlog for password failures in minutes
+	uint32 dynamic_pass_failure_ban_limit;          /// number of failures needed to trigger the ipban
+	uint32 dynamic_pass_failure_ban_duration;       /// duration of the ipban in minutes
 	bool use_dnsbl;                                 /// dns blacklist blocking ?
 	char dnsbl_servs[1024];                         /// comma-separated list of dnsbl servers
 
@@ -118,8 +118,8 @@ struct Login_Config {
 	int char_per_account;							/// number of characters an account can have
 #ifdef VIP_ENABLE
 	struct {
-		unsigned int group;							/// VIP group ID
-		unsigned int char_increase;					/// number of char-slot to increase in VIP state
+		uint32 group;								/// VIP group ID
+		uint32 char_increase;						/// number of char-slot to increase in VIP state
 	} vip_sys;
 #endif
 	bool use_web_auth_token;						/// Enable web authentication token system

+ 1 - 1
src/login/loginchrif.cpp

@@ -315,7 +315,7 @@ int logchrif_parse_requpdaccstate(int fd, int id, char* ip){
 		struct mmo_account acc;
 
 		uint32 account_id = RFIFOL(fd,2);
-		unsigned int state = RFIFOL(fd,6);
+		uint32 state = RFIFOL(fd,6);
 		AccountDB* accounts = login_get_accounts_db();
 
 		RFIFOSKIP(fd,10);

+ 1 - 1
src/login/loginlog.cpp

@@ -32,7 +32,7 @@ static bool enabled = false;
  * @param minutes: intervall to search
  * @return number of failed attempts
  */
-unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes) {
+unsigned long loginlog_failedattempts(uint32 ip, uint32 minutes) {
 	unsigned long failures = 0;
 
 	if( !enabled )

+ 1 - 1
src/login/loginlog.hpp

@@ -14,7 +14,7 @@
  * @param minutes: intervall to search
  * @return number of failed attempts
  */
-unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes);
+unsigned long loginlog_failedattempts(uint32 ip, uint32 minutes);
 
 /**
  * Records an event in the login log.

+ 26 - 26
src/map/atcommand.cpp

@@ -1639,7 +1639,7 @@ ACMD_FUNC(baselevelup)
 			clif_displaymessage(fd, msg_txt(sd,47)); // Base level can't go any higher.
 			return -1;
 		} // End Addition
-		if ((unsigned int)level > pc_maxbaselv(sd) || (unsigned int)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
+		if ((uint32)level > pc_maxbaselv(sd) || (uint32)level > pc_maxbaselv(sd) - sd->status.base_level) // fix positive overflow
 			level = pc_maxbaselv(sd) - sd->status.base_level;
 		for (i = 0; i < level; i++)
 		{
@@ -1648,7 +1648,7 @@ ACMD_FUNC(baselevelup)
 		}
 		sd->status.status_point += status_point;
 		sd->status.trait_point += trait_point;
-		sd->status.base_level += (unsigned int)level;
+		sd->status.base_level += (uint32)level;
 		status_calc_pc(sd, SCO_FORCE);
 		status_percent_heal(&sd->bl, 100, 100);
 		clif_misceffect( sd->bl, NOTIFYEFFECT_BASE_LEVEL_UP );
@@ -1663,7 +1663,7 @@ ACMD_FUNC(baselevelup)
 			return -1;
 		}
 		level*=-1;
-		if ((unsigned int)level >= sd->status.base_level)
+		if ((uint32)level >= sd->status.base_level)
 			level = sd->status.base_level-1;
 		for (i = 0; i > -level; i--)
 		{
@@ -1680,7 +1680,7 @@ ACMD_FUNC(baselevelup)
 			sd->status.trait_point = 0;
 		else
 			sd->status.trait_point -= trait_point;
-		sd->status.base_level -= (unsigned int)level;
+		sd->status.base_level -= (uint32)level;
 		clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
 		status_calc_pc(sd, SCO_FORCE);
 		level*=-1;
@@ -1720,9 +1720,9 @@ ACMD_FUNC(joblevelup)
 			clif_displaymessage(fd, msg_txt(sd,23)); // Job level can't go any higher.
 			return -1;
 		}
-		if ((unsigned int)level > pc_maxjoblv(sd) || (unsigned int)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
+		if ((uint32)level > pc_maxjoblv(sd) || (uint32)level > pc_maxjoblv(sd) - sd->status.job_level) // fix positive overflow
 			level = pc_maxjoblv(sd) - sd->status.job_level;
-		sd->status.job_level += (unsigned int)level;
+		sd->status.job_level += (uint32)level;
 		sd->status.skill_point += level;
 		clif_misceffect( sd->bl, NOTIFYEFFECT_JOB_LEVEL_UP );
 		for (uint32 i = sd->status.job_level - level; i <= sd->status.job_level; i++)
@@ -1734,9 +1734,9 @@ ACMD_FUNC(joblevelup)
 			return -1;
 		}
 		level *=-1;
-		if ((unsigned int)level >= sd->status.job_level) // fix negative overflow
+		if ((uint32)level >= sd->status.job_level) // fix negative overflow
 			level = sd->status.job_level-1;
-		sd->status.job_level -= (unsigned int)level;
+		sd->status.job_level -= (uint32)level;
 		if (sd->status.skill_point < level)
 			pc_resetskill(sd,0);	//Reset skills since we need to subtract more points.
 		if (sd->status.skill_point < level)
@@ -2256,7 +2256,7 @@ ACMD_FUNC(monster)
 	int count;
 	int i, range;
 	short mx, my;
-	unsigned int size;
+	uint32 size;
 	nullpo_retr(-1, sd);
 
 	memset(name, '\0', sizeof(name));
@@ -2706,7 +2706,7 @@ ACMD_FUNC(displaystatus)
 ACMD_FUNC(statuspoint)
 {
 	int point;
-	unsigned int new_status_point;
+	uint32 new_status_point;
 
 	if (!message || !*message || (point = atoi(message)) == 0) {
 		clif_displaymessage(fd, msg_txt(sd,1010)); // Please enter a number (usage: @stpoint <number of points>).
@@ -2715,7 +2715,7 @@ ACMD_FUNC(statuspoint)
 
 	if(point < 0)
 	{
-		if(sd->status.status_point < (unsigned int)(-point))
+		if(sd->status.status_point < (uint32)(-point))
 		{
 			new_status_point = 0;
 		}
@@ -2724,7 +2724,7 @@ ACMD_FUNC(statuspoint)
 			new_status_point = sd->status.status_point + point;
 		}
 	}
-	else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
+	else if(UINT_MAX - sd->status.status_point < (uint32)point)
 	{
 		new_status_point = UINT_MAX;
 	}
@@ -2754,7 +2754,7 @@ ACMD_FUNC(statuspoint)
 ACMD_FUNC(traitpoint)
 {
 	int point;
-	unsigned int new_trait_point;
+	uint32 new_trait_point;
 
 	if (!message || !*message || (point = atoi(message)) == 0) {
 		clif_displaymessage(fd, msg_txt(sd, 820)); // Please enter a number (usage: @trpoint <number of points>).
@@ -2763,7 +2763,7 @@ ACMD_FUNC(traitpoint)
 
 	if (point < 0)
 	{
-		if (sd->status.trait_point < (unsigned int)(-point))
+		if (sd->status.trait_point < (uint32)(-point))
 		{
 			new_trait_point = 0;
 		}
@@ -2772,7 +2772,7 @@ ACMD_FUNC(traitpoint)
 			new_trait_point = sd->status.trait_point + point;
 		}
 	}
-	else if (UINT_MAX - sd->status.trait_point < (unsigned int)point)
+	else if (UINT_MAX - sd->status.trait_point < (uint32)point)
 	{
 		new_trait_point = UINT_MAX;
 	}
@@ -2803,7 +2803,7 @@ ACMD_FUNC(traitpoint)
 ACMD_FUNC(skillpoint)
 {
 	int point;
-	unsigned int new_skill_point;
+	uint32 new_skill_point;
 	nullpo_retr(-1, sd);
 
 	if (!message || !*message || (point = atoi(message)) == 0) {
@@ -2813,7 +2813,7 @@ ACMD_FUNC(skillpoint)
 
 	if(point < 0)
 	{
-		if(sd->status.skill_point < (unsigned int)(-point))
+		if(sd->status.skill_point < (uint32)(-point))
 		{
 			new_skill_point = 0;
 		}
@@ -2822,7 +2822,7 @@ ACMD_FUNC(skillpoint)
 			new_skill_point = sd->status.skill_point + point;
 		}
 	}
-	else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
+	else if(UINT_MAX - sd->status.skill_point < (uint32)point)
 	{
 		new_skill_point = UINT_MAX;
 	}
@@ -4388,7 +4388,7 @@ ACMD_FUNC(reload) {
  * Temporary - Permanent update in inter_athena.conf
  *------------------------------------------*/
 ACMD_FUNC(partysharelvl) {
-	unsigned int share_lvl;
+	uint32 share_lvl;
 
 	nullpo_retr(-1, sd);
 
@@ -4759,7 +4759,7 @@ ACMD_FUNC(mount_peco)
 
 	if( (sd->class_&MAPID_THIRDMASK) == MAPID_RUNE_KNIGHT && pc_checkskill(sd,RK_DRAGONTRAINING) > 0 ) {
 		if( !(sd->sc.option&OPTION_DRAGON) ) {
-			unsigned int option = OPTION_DRAGON1;
+			uint32 option = OPTION_DRAGON1;
 			if( message[0] ) {
 				int color = atoi(message);
 				option = ( color == 2 ? OPTION_DRAGON2 :
@@ -7885,7 +7885,7 @@ ACMD_FUNC(mobinfo)
 		// drops
 		clif_displaymessage(fd, msg_txt(sd,1245)); //  Drops:
 		strcpy(atcmd_output, " ");
-		unsigned int j = 0;
+		uint32 j = 0;
 		int drop_modifier = 100;
 #ifdef RENEWAL_DROP
 		if( battle_config.atcommand_mobinfo_type ){
@@ -8983,7 +8983,7 @@ ACMD_FUNC(invite)
 
 ACMD_FUNC(duel)
 {
-	unsigned int maxpl = 0;
+	uint32 maxpl = 0;
 
 	if(sd->duel_group > 0) {
 		duel_showinfo(sd->duel_group, sd);
@@ -9508,13 +9508,13 @@ ACMD_FUNC(itemlist)
 
 		if( it->card[0] == CARD0_PET ) { // pet egg
 			if (it->card[3]&1)
-				StringBuf_Printf(&buf, msg_txt(sd,1348), (unsigned int)MakeDWord(it->card[1], it->card[2])); //  -> (pet egg, pet id: %u, named)
+				StringBuf_Printf(&buf, msg_txt(sd,1348), (uint32)MakeDWord(it->card[1], it->card[2])); //  -> (pet egg, pet id: %u, named)
 			else
-				StringBuf_Printf(&buf, msg_txt(sd,1349), (unsigned int)MakeDWord(it->card[1], it->card[2])); //  -> (pet egg, pet id: %u, unnamed)
+				StringBuf_Printf(&buf, msg_txt(sd,1349), (uint32)MakeDWord(it->card[1], it->card[2])); //  -> (pet egg, pet id: %u, unnamed)
 		} else if(it->card[0] == CARD0_FORGE) { // forged item
-			StringBuf_Printf(&buf, msg_txt(sd,1350), (unsigned int)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); //  -> (crafted item, creator id: %u, star crumbs %d, element %d)
+			StringBuf_Printf(&buf, msg_txt(sd,1350), (uint32)MakeDWord(it->card[2], it->card[3]), it->card[1]>>8, it->card[1]&0x0f); //  -> (crafted item, creator id: %u, star crumbs %d, element %d)
 		} else if(it->card[0] == CARD0_CREATE) { // created item
-			StringBuf_Printf(&buf, msg_txt(sd,1351), (unsigned int)MakeDWord(it->card[2], it->card[3])); //  -> (produced item, creator id: %u)
+			StringBuf_Printf(&buf, msg_txt(sd,1351), (uint32)MakeDWord(it->card[2], it->card[3])); //  -> (produced item, creator id: %u)
 		} else { // normal item
 			int counter2 = 0;
 

+ 4 - 4
src/map/battle.cpp

@@ -2491,7 +2491,7 @@ static int battle_calc_base_weapon_attack(struct block_list *src, struct status_
  */
 static int64 battle_calc_base_damage(struct block_list *src, struct status_data *status, struct weapon_atk *wa, status_change *sc, unsigned short t_size, int flag)
 {
-	unsigned int atkmin = 0, atkmax = 0;
+	uint32 atkmin = 0, atkmax = 0;
 	short type = 0;
 	int64 damage = 0;
 	map_session_data *sd = nullptr;
@@ -5421,7 +5421,7 @@ static int battle_calc_attack_skill_ratio(struct Damage* wd, struct block_list *
  			break;
 		case SR_TIGERCANNON:
 			{
-				unsigned int hp = sstatus->max_hp * (10 + (skill_lv * 2)) / 100,
+				uint32 hp = sstatus->max_hp * (10 + (skill_lv * 2)) / 100,
 							 sp = sstatus->max_sp * (5 + skill_lv) / 100;
 
 				if (wd->miscflag&8)
@@ -7055,7 +7055,7 @@ static void battle_calc_weapon_final_atk_modifiers(struct Damage* wd, struct blo
 	if( sc ) {
 		//SC_FUSION hp penalty [Komurka]
 		if (sc->getSCE(SC_FUSION)) {
-			unsigned int hp = sstatus->max_hp;
+			uint32 hp = sstatus->max_hp;
 
 			if (sd && tsd) {
 				hp = hp / 13;
@@ -7857,7 +7857,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
 	}
 
 	if (!flag.infdef) { //No need to do the math for plants
-		unsigned int skillratio = 100; //Skill dmg modifiers.
+		uint32 skillratio = 100; //Skill dmg modifiers.
 #ifdef RENEWAL
 		// Some skills do not use S.MATK and skillratio
 		bool has_skillratio = false;

+ 12 - 12
src/map/buyingstore.cpp

@@ -50,12 +50,12 @@ enum e_buyingstore_failure
 };
 
 
-static unsigned int buyingstore_nextid = 0;
+static uint32 buyingstore_nextid = 0;
 static const t_itemid buyingstore_blankslots[MAX_SLOTS] = { 0 };  // used when checking whether or not an item's card slots are blank
 
 
 /// Returns unique buying store id
-static unsigned int buyingstore_getuid(void)
+static uint32 buyingstore_getuid(void)
 {
 	return ++buyingstore_nextid;
 }
@@ -113,8 +113,8 @@ int8 buyingstore_setup(map_session_data* sd, unsigned char slots){
 * @param at Autotrader info, or nullptr if requetsed not from autotrade persistance
 * @return 0 If success, 1 - Cannot open, 2 - Manner penalty, 3 - Mapflag restiction, 4 - Cell restriction, 5 - Invalid count/result, 6 - Cannot give item, 7 - Will be overweight
 */
-int8 buyingstore_create( map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub* itemlist, unsigned int count, struct s_autotrader *at ){
-	unsigned int i, weight, listidx;
+int8 buyingstore_create( map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub* itemlist, uint32 count, struct s_autotrader *at ){
+	uint32 i, weight, listidx;
 	char message_sql[MESSAGE_SIZE*2];
 	StringBuf buf;
 
@@ -323,9 +323,9 @@ void buyingstore_open(map_session_data* sd, uint32 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( map_session_data* sd, uint32 account_id, unsigned int buyer_id, const struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub* itemlist, unsigned int count ){
+void buyingstore_trade( map_session_data* sd, uint32 account_id, uint32 buyer_id, const struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub* itemlist, uint32 count ){
 	int zeny = 0;
-	unsigned int weight;
+	uint32 weight;
 	map_session_data* pl_sd;
 
 	nullpo_retv(sd);
@@ -420,7 +420,7 @@ void buyingstore_trade( map_session_data* sd, uint32 account_id, unsigned int bu
 
 		// normally this is not supposed to happen, as the total weight is
 		// checked upon creation, but the buyer could have gained items
-		if( item->amount * (unsigned int)sd->inventory_data[index]->weight > pl_sd->max_weight - weight ){
+		if( item->amount * (uint32)sd->inventory_data[index]->weight > pl_sd->max_weight - weight ){
 			clif_buyingstore_trade_failed_seller( sd, BUYINGSTORE_TRADE_SELLER_FAILED, item->itemId );
 			return;
 		}
@@ -510,7 +510,7 @@ void buyingstore_trade( map_session_data* sd, uint32 account_id, unsigned int bu
 /// Checks if an item is being bought in given player's buying store.
 bool buyingstore_search(map_session_data* sd, t_itemid nameid)
 {
-	unsigned int i;
+	uint32 i;
 
 	nullpo_ret(sd);
 
@@ -533,7 +533,7 @@ bool buyingstore_search(map_session_data* sd, t_itemid nameid)
 /// @return Whether or not the search should be continued.
 bool buyingstore_searchall(map_session_data* sd, const struct s_search_store_search* s)
 {
-	unsigned int i, idx;
+	uint32 i, idx;
 	struct s_buyingstore_item* it;
 
 	nullpo_ret(sd);
@@ -552,12 +552,12 @@ bool buyingstore_searchall(map_session_data* sd, const struct s_search_store_sea
 		}
 		it = &sd->buyingstore.items[i];
 
-		if( s->min_price && s->min_price > (unsigned int)it->price )
+		if( s->min_price && s->min_price > (uint32)it->price )
 		{// too low price
 			continue;
 		}
 
-		if( s->max_price && s->max_price < (unsigned int)it->price )
+		if( s->max_price && s->max_price < (uint32)it->price )
 		{// too high price
 			continue;
 		}
@@ -568,7 +568,7 @@ bool buyingstore_searchall(map_session_data* sd, const struct s_search_store_sea
 		}
 
 		// Check if the result set is full
-		if( s->search_sd->searchstore.items.size() >= (unsigned int)battle_config.searchstore_maxresults ){
+		if( s->search_sd->searchstore.items.size() >= (uint32)battle_config.searchstore_maxresults ){
 			return false;
 		}
 

+ 2 - 2
src/map/buyingstore.hpp

@@ -56,10 +56,10 @@ struct s_autotrader {
 };
 
 int8 buyingstore_setup(map_session_data* sd, unsigned char slots);
-int8 buyingstore_create(map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub* itemlist, unsigned int count, struct s_autotrader *at);
+int8 buyingstore_create(map_session_data* sd, int zenylimit, unsigned char result, const char* storename, const struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub* itemlist, uint32 count, struct s_autotrader *at);
 void buyingstore_close(map_session_data* sd);
 void buyingstore_open(map_session_data* sd, uint32 account_id);
-void buyingstore_trade(map_session_data* sd, uint32 account_id, unsigned int buyer_id, const struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub* itemlist, unsigned int count);
+void buyingstore_trade(map_session_data* sd, uint32 account_id, uint32 buyer_id, const struct PACKET_CZ_REQ_TRADE_BUYING_STORE_sub* itemlist, uint32 count);
 bool buyingstore_search(map_session_data* sd, t_itemid nameid);
 bool buyingstore_searchall(map_session_data* sd, const struct s_search_store_search* s);
 DBMap *buyingstore_getdb(void);

+ 3 - 3
src/map/cashshop.cpp

@@ -249,7 +249,7 @@ static TIMER_FUNC(sale_start_timer){
 	}
 
 	// Init sale end
-	sale_item->timer_end = add_timer( gettick() + (unsigned int)( sale_item->end - time(nullptr) ) * 1000, sale_end_timer, 0, (intptr_t)sale_item );
+	sale_item->timer_end = add_timer( gettick() + (uint32)( sale_item->end - time(nullptr) ) * 1000, sale_end_timer, 0, (intptr_t)sale_item );
 
 	return 1;
 }
@@ -293,7 +293,7 @@ enum e_sale_add_result sale_add_item( t_itemid nameid, int32 count, time_t from,
 	sale_item->start = from;
 	sale_item->end = to;
 	sale_item->amount = count;
-	sale_item->timer_start = add_timer( gettick() + (unsigned int)(from - time(nullptr)) * 1000, sale_start_timer, 0, (intptr_t)sale_item );
+	sale_item->timer_start = add_timer( gettick() + (uint32)(from - time(nullptr)) * 1000, sale_start_timer, 0, (intptr_t)sale_item );
 	sale_item->timer_end = INVALID_TIMER;
 
 	return SALE_ADD_SUCCESS;
@@ -421,7 +421,7 @@ static void cashshop_read_db( void ){
 		struct sale_item_data* it = sale_items.item[i];
 
 		if( it->start > now ){
-			it->timer_start = add_timer( gettick() + (unsigned int)( it->start - time(nullptr) ) * 1000, sale_start_timer, 0, (intptr_t)it );
+			it->timer_start = add_timer( gettick() + (uint32)( it->start - time(nullptr) ) * 1000, sale_start_timer, 0, (intptr_t)it );
 		}else{
 			sale_start_timer( 0, gettick(), 0, (intptr_t)it );
 		}

+ 1 - 1
src/map/channel.cpp

@@ -86,7 +86,7 @@ struct Channel* channel_create(struct Channel *tmp_chan) {
  * @param owner: Owner ID
  * @return nullptr on failure or Channel on success
  */
-struct Channel* channel_create_simple(char *name, char *pass, enum Channel_Type chantype, unsigned int owner) {
+struct Channel* channel_create_simple(char *name, char *pass, enum Channel_Type chantype, uint32 owner) {
 	struct Channel tmp_chan;
 	memset(&tmp_chan, 0, sizeof(struct Channel));
 

+ 3 - 3
src/map/channel.hpp

@@ -46,7 +46,7 @@ struct Channel {
 	unsigned long color;		  ///< Channel color in BGR
 	unsigned char opt;			  ///< Channel options @see enum Channel_Opt
 	unsigned short msg_delay;	  ///< Chat delay in miliseconds
-	unsigned int char_id;		  ///< If CHAN_TYPE_PRIVATE, owner is char_id of channel creator
+	uint32 char_id;		  ///< If CHAN_TYPE_PRIVATE, owner is char_id of channel creator
 	uint16 m;					  ///< If CHAN_TYPE_MAP, owner is map id
 	int gid;					  ///< If CHAN_TYPE_ALLY, owner is first logged guild_id
 	DBMap *users;				  ///< List of users
@@ -70,7 +70,7 @@ struct Channel_Config {
 	struct {
 		unsigned char opt;			 ///< Options @see enum Channel_Opt
 		unsigned long color;		 ///< Default color
-		unsigned int delay;			 ///< Message delay
+		uint32 delay;			 ///< Message delay
 		unsigned short max_member;	 ///< Max member for each channel
 		unsigned allow : 1;			 ///< Allow private channel creation?
 		unsigned ban : 1;			 ///< Allow player to ban
@@ -89,7 +89,7 @@ extern struct Channel_Config channel_config;
 DBMap* channel_get_db(void);
 
 struct Channel* channel_create(struct Channel *tmp_chan);
-struct Channel* channel_create_simple(char *name, char *pass, enum Channel_Type chantype, unsigned int owner);
+struct Channel* channel_create_simple(char *name, char *pass, enum Channel_Type chantype, uint32 owner);
 int channel_delete(struct Channel *channel, bool force);
 
 int channel_join(struct Channel *channel, map_session_data *sd);

+ 14 - 14
src/map/clif.cpp

@@ -256,7 +256,7 @@ static inline bool disguised(struct block_list* bl) {
 
 
 //Guarantees that the given string does not exceeds the allowed size, as well as making sure it's null terminated. [Skotlex]
-static inline unsigned int mes_len_check(char* mes, unsigned int len, unsigned int max) {
+static inline uint32 mes_len_check(char* mes, uint32 len, uint32 max) {
 	if( len > max )
 		len = max;
 
@@ -5028,7 +5028,7 @@ void clif_getareachar_unit( map_session_data* sd,struct block_list *bl ){
 	struct unit_data *ud;
 	struct view_data *vd;
 	bool option = false;
-	unsigned int option_val = 0;
+	uint32 option_val = 0;
 
 	vd = status_get_viewdata(bl);
 	if (!vd || vd->class_ == JT_INVISIBLE)
@@ -10253,7 +10253,7 @@ void clif_hate_info(map_session_data *sd, unsigned char hate_level,int class_, u
 	} else if( mobdb_checkid(class_) ) {
 		clif_starskill(sd, mob_db.find(class_)->jname.c_str(), class_, hate_level, type ? 10 : 11);
 	} else {
-		ShowWarning("clif_hate_info: Received invalid class %d for this packet (char_id=%d, hate_level=%u, type=%u).\n", class_, sd->status.char_id, (unsigned int)hate_level, (unsigned int)type);
+		ShowWarning("clif_hate_info: Received invalid class %d for this packet (char_id=%d, hate_level=%u, type=%u).\n", class_, sd->status.char_id, (uint32)hate_level, (uint32)type);
 	}
 }
 
@@ -11262,7 +11262,7 @@ void clif_parse_Hotkey(int fd, map_session_data *sd) {
 
 /// Displays cast-like progress bar (ZC_PROGRESS).
 /// 02f0 <color>.L <time>.L
-void clif_progressbar(map_session_data * sd, unsigned long color, unsigned int second)
+void clif_progressbar(map_session_data * sd, unsigned long color, uint32 second)
 {
 	int fd = sd->fd;
 
@@ -11942,7 +11942,7 @@ void clif_parse_WisMessage(int fd, map_session_data* sd)
 void clif_parse_Broadcast(int fd, map_session_data* sd) {
 	char command[CHAT_SIZE_MAX+11];
 	struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
-	unsigned int len = RFIFOW(fd,info->pos[0])-4;
+	uint32 len = RFIFOW(fd,info->pos[0])-4;
 	char* msg = RFIFOCP(fd,info->pos[1]);
 
 	// as the length varies depending on the command used, just block unreasonably long strings
@@ -13477,7 +13477,7 @@ void clif_parse_LocalBroadcast(int fd, map_session_data* sd)
 {
 	struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
 	char command[CHAT_SIZE_MAX+16];
-	unsigned int len = RFIFOW(fd,info->pos[0])-4;
+	uint32 len = RFIFOW(fd,info->pos[0])-4;
 	char* msg = RFIFOCP(fd,info->pos[1]);
 
 	// as the length varies depending on the command used, just block unreasonably long strings
@@ -16979,7 +16979,7 @@ void clif_parse_Auction_register(int fd, map_session_data *sd)
 /// Cancels an auction (CZ_AUCTION_ADD_CANCEL).
 /// 024e <auction id>.L
 void clif_parse_Auction_cancel(int fd, map_session_data *sd){
-	unsigned int auction_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
+	uint32 auction_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
 	intif_Auction_cancel(sd->status.char_id, auction_id);
 }
 
@@ -16987,7 +16987,7 @@ void clif_parse_Auction_cancel(int fd, map_session_data *sd){
 /// Closes an auction (CZ_AUCTION_REQ_MY_SELL_STOP).
 /// 025d <auction id>.L
 void clif_parse_Auction_close(int fd, map_session_data *sd){
-	unsigned int auction_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
+	uint32 auction_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
 	intif_Auction_close(sd->status.char_id, auction_id);
 }
 
@@ -16996,7 +16996,7 @@ void clif_parse_Auction_close(int fd, map_session_data *sd){
 /// 024f <auction id>.L <money>.L
 void clif_parse_Auction_bid(int fd, map_session_data *sd){
 	struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
-	unsigned int auction_id = RFIFOL(fd,info->pos[0]);
+	uint32 auction_id = RFIFOL(fd,info->pos[0]);
 	int bid = RFIFOL(fd,info->pos[1]);
 
 	if( !pc_can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish]
@@ -17481,10 +17481,10 @@ void clif_bossmapinfo( map_session_data& sd, mob_data* md, e_bossmap_info flag )
 			break;
 		case BOSS_INFO_DEAD: {
 			const struct TimerData * timer_data = get_timer(md->spawn_timer);
-			unsigned int seconds;
+			uint32 seconds;
 			int hours, minutes;
 
-			seconds = (unsigned int)(DIFF_TICK(timer_data->tick, gettick()) / 1000 + 60);
+			seconds = (uint32)(DIFF_TICK(timer_data->tick, gettick()) / 1000 + 60);
 			hours = seconds / (60 * 60);
 			seconds = seconds - (60 * 60 * hours);
 			minutes = seconds / 60;
@@ -18639,7 +18639,7 @@ void clif_instance_changewait(int instance_id, int num)
 
 /// Notify the current status to members
 /// S 0x2cd <Instance Name>.61B <Instance Remaining Time>.L <Instance Noplayers close time>.L
-void clif_instance_status(int instance_id, unsigned int limit1, unsigned int limit2)
+void clif_instance_status(int instance_id, uint32 limit1, uint32 limit2)
 {
 #if PACKETVER >= 20071128
 	map_session_data *sd = nullptr;
@@ -18673,7 +18673,7 @@ void clif_instance_status(int instance_id, unsigned int limit1, unsigned int lim
 /// 2 = The Memorial Dungeon's entry time limit expired; it has been destroyed
 /// 3 = The Memorial Dungeon has been removed.
 /// 4 = Create failure (removes the instance window)
-void clif_instance_changestatus(int instance_id, e_instance_notify type, unsigned int limit)
+void clif_instance_changestatus(int instance_id, e_instance_notify type, uint32 limit)
 {
 #if PACKETVER >= 20071128
 	map_session_data *sd = nullptr;
@@ -18999,7 +18999,7 @@ static void clif_parse_ReqOpenBuyingStore( int fd, map_session_data* sd ){
 ///     2 = "Total amount of then possessed items exceeds the weight limit by <weight/10-maxweight*90%>. Please re-enter." (0x6ce, MSI_BUYINGSTORE_OVERWEIGHT)
 ///     8 = "No sale (purchase) information available." (0x705)
 ///     ? = nothing
-void clif_buyingstore_open_failed(map_session_data* sd, unsigned short result, unsigned int weight)
+void clif_buyingstore_open_failed(map_session_data* sd, unsigned short result, uint32 weight)
 {
 	int fd = sd->fd;
 

+ 5 - 5
src/map/clif.hpp

@@ -71,7 +71,7 @@ struct s_packet_db {
 #ifdef PACKET_OBFUSCATION
 /// Keys based on packet versions
 struct s_packet_keys {
-	unsigned int keys[3]; ///< 3-Keys
+	uint32 keys[3]; ///< 3-Keys
 };
 #endif
 
@@ -1090,8 +1090,8 @@ void clif_bg_queue_ack_lobby(bool result, const char *name, const char *lobbynam
 // Instancing
 void clif_instance_create( int instance_id, size_t num );
 void clif_instance_changewait(int instance_id, int num);
-void clif_instance_status(int instance_id, unsigned int limit1, unsigned int limit2);
-void clif_instance_changestatus(int instance_id, e_instance_notify type, unsigned int limit);
+void clif_instance_status(int instance_id, uint32 limit1, uint32 limit2);
+void clif_instance_changestatus(int instance_id, e_instance_notify type, uint32 limit);
 void clif_parse_MemorialDungeonCommand(int fd, map_session_data *sd);
 void clif_instance_info( map_session_data& sd );
 
@@ -1237,7 +1237,7 @@ void clif_readbook(int fd, int book_id, int page);
 void clif_party_show_picker(map_session_data * sd, struct item * item_data);
 
 // Progress Bar [Inkfish]
-void clif_progressbar(map_session_data * sd, unsigned long color, unsigned int second);
+void clif_progressbar(map_session_data * sd, unsigned long color, uint32 second);
 void clif_progressbar_abort(map_session_data * sd);
 void clif_progressbar_npc(struct npc_data *nd, map_session_data* sd);
 #define clif_progressbar_npc_area(nd) clif_progressbar_npc((nd),nullptr)
@@ -1260,7 +1260,7 @@ void clif_showdigit(map_session_data* sd, unsigned char type, int value);
 
 /// Buying Store System
 void clif_buyingstore_open(map_session_data* sd);
-void clif_buyingstore_open_failed(map_session_data* sd, unsigned short result, unsigned int weight);
+void clif_buyingstore_open_failed(map_session_data* sd, unsigned short result, uint32 weight);
 void clif_buyingstore_myitemlist( map_session_data& sd );
 void clif_buyingstore_entry( map_session_data& sd, struct block_list* tbl = nullptr );
 void clif_buyingstore_disappear_entry( map_session_data& sd, struct block_list* tbl = nullptr );

+ 1 - 1
src/map/clif_obfuscation.hpp

@@ -5,7 +5,7 @@
 #define CLIF_OBFUSCATION_HPP
 
 #if defined(PACKET_OBFUSCATION) || defined(PACKET_OBFUSCATION_WARN)
-	#define packet_keys(a,b,c) static unsigned int clif_cryptKey[] = { a, b, c };
+	#define packet_keys(a,b,c) static uint32 clif_cryptKey[] = { a, b, c };
 
 	#if defined(PACKET_OBFUSCATION_KEY1) || defined(PACKET_OBFUSCATION_KEY2) || defined(PACKET_OBFUSCATION_KEY3)
 		#ifndef PACKET_OBFUSCATION_KEY1

+ 1 - 1
src/map/duel.cpp

@@ -157,7 +157,7 @@ static void duel_set(const size_t did, map_session_data* sd) {
  * Create a new duel for sd
  * return new duel_id or 0 when fail
  */
-size_t duel_create(map_session_data* sd, const unsigned int maxpl)
+size_t duel_create(map_session_data* sd, const uint32 maxpl)
 {
 	static size_t lastID=0;
 	lastID++;

+ 1 - 1
src/map/duel.hpp

@@ -19,7 +19,7 @@ size_t duel_counttotal();
 size_t duel_countactives();
 
 //Duel functions // [LuzZza]
-size_t duel_create(map_session_data* sd, const unsigned int maxpl);
+size_t duel_create(map_session_data* sd, const uint32 maxpl);
 bool duel_invite(const size_t did, map_session_data* sd, map_session_data* target_sd);
 bool duel_accept(const size_t did, map_session_data* sd);
 bool duel_reject(const size_t did, map_session_data* sd);

+ 1 - 1
src/map/elemental.cpp

@@ -39,7 +39,7 @@ struct view_data * elemental_get_viewdata(int class_) {
 	return &db->vd;
 }
 
-int elemental_create(map_session_data *sd, int class_, unsigned int lifetime) {
+int elemental_create(map_session_data *sd, int class_, uint32 lifetime) {
 	nullpo_retr(1,sd);
 
 	std::shared_ptr<s_elemental_db> db = elemental_db.find(class_);

+ 1 - 1
src/map/elemental.hpp

@@ -107,7 +107,7 @@ extern ElementalDatabase elemental_db;
 
 struct view_data * elemental_get_viewdata(int class_);
 
-int elemental_create(map_session_data *sd, int class_, unsigned int lifetime);
+int elemental_create(map_session_data *sd, int class_, uint32 lifetime);
 int elemental_data_received(s_elemental *ele, bool flag);
 int elemental_save(s_elemental_data *ed);
 

+ 3 - 3
src/map/homunculus.cpp

@@ -753,7 +753,7 @@ void hom_gainexp(struct homun_data *hd,t_exp exp)
 * @param value Added intimacy
 * @return New intimacy value
 */
-int hom_increase_intimacy(struct homun_data * hd, unsigned int value)
+int hom_increase_intimacy(struct homun_data * hd, uint32 value)
 {
 	nullpo_ret(hd);
 	if (battle_config.homunculus_friendly_rate != 100)
@@ -772,7 +772,7 @@ int hom_increase_intimacy(struct homun_data * hd, unsigned int value)
 * @param value Reduced intimacy
 * @return New intimacy value
 */
-int hom_decrease_intimacy(struct homun_data * hd, unsigned int value)
+int hom_decrease_intimacy(struct homun_data * hd, uint32 value)
 {
 	nullpo_ret(hd);
 	if (hd->homunculus.intimacy >= value)
@@ -1301,7 +1301,7 @@ int hom_ressurect(map_session_data* sd, unsigned char per, short x, short y)
 * @param hp
 * @param sp
 */
-void hom_revive(struct homun_data *hd, unsigned int hp, unsigned int sp)
+void hom_revive(struct homun_data *hd, uint32 hp, uint32 sp)
 {
 	map_session_data *sd = hd->master;
 	hd->homunculus.hp = hd->battle_status.hp;

+ 4 - 4
src/map/homunculus.hpp

@@ -43,7 +43,7 @@ public:
 };
 
 struct s_hom_stats {
-	unsigned int HP, SP;
+	uint32 HP, SP;
 	unsigned short str, agi, vit, int_, dex, luk;
 };
 
@@ -219,7 +219,7 @@ int hom_mutate(struct homun_data *hd,int homun_id);
 void hom_heal(homun_data& hd, bool hp, bool sp);
 int hom_vaporize(map_session_data *sd, int flag);
 int hom_ressurect(map_session_data *sd, unsigned char per, short x, short y);
-void hom_revive(struct homun_data *hd, unsigned int hp, unsigned int sp);
+void hom_revive(struct homun_data *hd, uint32 hp, uint32 sp);
 void hom_reset_stats(struct homun_data *hd);
 int hom_shuffle(struct homun_data *hd); // [Zephyrus]
 void hom_save(struct homun_data *hd);
@@ -232,8 +232,8 @@ int hom_change_name(map_session_data *sd,char *name);
 void hom_change_name_ack(map_session_data *sd, char* name, int flag);
 #define hom_stop_walking(hd, type) unit_stop_walking(&(hd)->bl, type)
 #define hom_stop_attack(hd) unit_stop_attack(&(hd)->bl)
-int hom_increase_intimacy(struct homun_data * hd, unsigned int value);
-int hom_decrease_intimacy(struct homun_data * hd, unsigned int value);
+int hom_increase_intimacy(struct homun_data * hd, uint32 value);
+int hom_decrease_intimacy(struct homun_data * hd, uint32 value);
 int hom_skill_tree_get_max(int skill_id, int b_class);
 void hom_init_timers(struct homun_data * hd);
 void hom_reload(void);

+ 4 - 4
src/map/intif.cpp

@@ -791,7 +791,7 @@ int intif_party_leaderchange(int party_id,uint32 account_id,uint32 char_id)
  * @param share_lvl : Max level number of difference to share exp
  * @return  0=error, 1=msg sent
  */
-int intif_party_sharelvlupdate(unsigned int share_lvl)
+int intif_party_sharelvlupdate(uint32 share_lvl)
 {
 	if (CheckForCharServer())
 		return 0;
@@ -2800,7 +2800,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(uint32 char_id, unsigned int auction_id)
+int intif_Auction_cancel(uint32 char_id, uint32 auction_id)
 {
 	if( CheckForCharServer() )
 		return 0;
@@ -2841,7 +2841,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(uint32 char_id, unsigned int auction_id)
+int intif_Auction_close(uint32 char_id, uint32 auction_id)
 {
 	if( CheckForCharServer() )
 		return 0;
@@ -2884,7 +2884,7 @@ static void intif_parse_Auction_close(int fd)
  * @param bid
  * @return 0=error, 1=msg sent
  */
-int intif_Auction_bid(uint32 char_id, const char* name, unsigned int auction_id, int bid)
+int intif_Auction_bid(uint32 char_id, const char* name, uint32 auction_id, int bid)
 {
 	int len = 16 + NAME_LENGTH;
 

+ 5 - 5
src/map/intif.hpp

@@ -25,7 +25,7 @@ int intif_parse(int fd);
 
 int intif_broadcast( const char* mes, size_t len, int type );
 int intif_broadcast2( const char* mes, size_t len, unsigned long fontColor, short fontType, short fontSize, short fontAlign, short fontY );
-int intif_broadcast_obtain_special_item(map_session_data *sd, t_itemid nameid, unsigned int sourceid, unsigned char type);
+int intif_broadcast_obtain_special_item(map_session_data *sd, t_itemid nameid, uint32 sourceid, unsigned char type);
 int intif_broadcast_obtain_special_item_npc(map_session_data *sd, t_itemid nameid);
 int intif_main_message(map_session_data* sd, const char* message);
 
@@ -48,7 +48,7 @@ int intif_party_changemap(map_session_data *sd, int online);
 int intif_break_party(int party_id);
 int intif_party_message(int party_id, uint32 account_id, const char *mes, size_t len);
 int intif_party_leaderchange(int party_id,uint32 account_id,uint32 char_id);
-int intif_party_sharelvlupdate(unsigned int share_lvl);
+int intif_party_sharelvlupdate(uint32 share_lvl);
 
 int intif_guild_create(const char *name, const struct guild_member *master);
 int intif_guild_request_info(int guild_id);
@@ -106,9 +106,9 @@ bool intif_mail_checkreceiver(map_session_data* sd, char* name);
 // AUCTION SYSTEM
 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(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);
+int intif_Auction_cancel(uint32 char_id, uint32 auction_id);
+int intif_Auction_close(uint32 char_id, uint32 auction_id);
+int intif_Auction_bid(uint32 char_id, const char* name, uint32 auction_id, int bid);
 // ELEMENTAL SYSTEM
 int intif_elemental_create(struct s_elemental *ele);
 int intif_elemental_request(int ele_id, uint32 char_id);

+ 1 - 1
src/map/itemdb.cpp

@@ -2953,7 +2953,7 @@ void ItemGroupDatabase::pc_get_itemgroup_sub( map_session_data& sd, bool identif
 	tmp.nameid = data->nameid;
 	tmp.bound = data->bound;
 	tmp.identify = identify ? identify : itemdb_isidentified(data->nameid);
-	tmp.expire_time = (data->duration) ? (unsigned int)(time(nullptr) + data->duration*60) : 0;
+	tmp.expire_time = (data->duration) ? (uint32)(time(nullptr) + data->duration*60) : 0;
 	if (data->isNamed) {
 		tmp.card[0] = itemdb_isequip(data->nameid) ? CARD0_FORGE : CARD0_CREATE;
 		tmp.card[1] = 0;

+ 1 - 1
src/map/log.cpp

@@ -540,7 +540,7 @@ void log_cash( map_session_data* sd, e_log_pick_type type, e_log_cash_type cash_
  * @param nameid Item used as food
  **/
 void log_feeding(map_session_data *sd, e_log_feeding_type type, t_itemid nameid) {
-	unsigned int target_id = 0, intimacy = 0;
+	uint32 target_id = 0, intimacy = 0;
 	unsigned short target_class = 0;
 
 	nullpo_retv( sd );

+ 9 - 9
src/map/map.cpp

@@ -109,7 +109,7 @@ static DBMap* id_db=nullptr; /// int id -> struct block_list*
 static DBMap* pc_db=nullptr; /// int id -> map_session_data*
 static DBMap* mobid_db=nullptr; /// int id -> struct mob_data*
 static DBMap* bossid_db=nullptr; /// int id -> struct mob_data* (MVP db)
-static DBMap* map_db=nullptr; /// unsigned int mapindex -> struct map_data*
+static DBMap* map_db=nullptr; /// uint32 mapindex -> struct map_data*
 static DBMap* nick_db=nullptr; /// uint32 char_id -> struct charid2nick* (requested names of offline characters)
 static DBMap* charid_db=nullptr; /// uint32 char_id -> map_session_data*
 static DBMap* regen_db=nullptr; /// int id -> struct block_list* (status_natural_heal processing)
@@ -3024,7 +3024,7 @@ int16 map_mapindex2mapid(unsigned short mapindex)
 	if (!mapindex)
 		return -1;
 
-	md = (struct map_data*)uidb_get(map_db,(unsigned int)mapindex);
+	md = (struct map_data*)uidb_get(map_db,(uint32)mapindex);
 	if(md==nullptr || md->cell==nullptr)
 		return -1;
 	return md->m;
@@ -3037,7 +3037,7 @@ int map_mapname2ipport(unsigned short name, uint32* ip, uint16* port)
 {
 	struct map_data_other_server *mdos;
 
-	mdos = (struct map_data_other_server*)uidb_get(map_db,(unsigned int)name);
+	mdos = (struct map_data_other_server*)uidb_get(map_db,(uint32)name);
 	if(mdos==nullptr || mdos->cell) //If gat isn't null, this is a local map.
 		return -1;
 	*ip=mdos->ip;
@@ -3459,7 +3459,7 @@ int map_setipport(unsigned short mapindex, uint32 ip, uint16 port)
 {
 	struct map_data_other_server *mdos;
 
-	mdos= (struct map_data_other_server *)uidb_ensure(map_db,(unsigned int)mapindex, create_map_data_other_server);
+	mdos= (struct map_data_other_server *)uidb_ensure(map_db,(uint32)mapindex, create_map_data_other_server);
 
 	if(mdos->cell) //Local map,Do nothing. Give priority to our own local maps over ones from another server. [Skotlex]
 		return 0;
@@ -3500,12 +3500,12 @@ int map_eraseipport(unsigned short mapindex, uint32 ip, uint16 port)
 {
 	struct map_data_other_server *mdos;
 
-	mdos = (struct map_data_other_server*)uidb_get(map_db,(unsigned int)mapindex);
+	mdos = (struct map_data_other_server*)uidb_get(map_db,(uint32)mapindex);
 	if(!mdos || mdos->cell) //Map either does not exists or is a local map.
 		return 0;
 
 	if(mdos->ip==ip && mdos->port == port) {
-		uidb_remove(map_db,(unsigned int)mapindex);
+		uidb_remove(map_db,(uint32)mapindex);
 		aFree(mdos);
 		return 1;
 	}
@@ -3775,12 +3775,12 @@ int map_readgat (struct map_data* m)
  *--------------------------------------*/
 void map_addmap2db(struct map_data *m)
 {
-	uidb_put(map_db, (unsigned int)m->index, m);
+	uidb_put(map_db, (uint32)m->index, m);
 }
 
 void map_removemapdb(struct map_data *m)
 {
-	uidb_remove(map_db, (unsigned int)m->index);
+	uidb_remove(map_db, (uint32)m->index);
 }
 
 /*======================================
@@ -3859,7 +3859,7 @@ int map_readallmaps (void)
 
 		mapdata->index = idx;
 
-		if (uidb_get(map_db,(unsigned int)mapdata->index) != nullptr) {
+		if (uidb_get(map_db,(uint32)mapdata->index) != nullptr) {
 			ShowWarning("Map %s already loaded!" CL_CLL "\n", mapdata->name);
 			if (mapdata->cell) {
 				aFree(mapdata->cell);

+ 6 - 6
src/map/map.hpp

@@ -462,13 +462,13 @@ struct spawn_data {
 	signed short xs, ys;
 	unsigned short num; //Number of mobs using this structure
 	unsigned short active;//Number of mobs that are already spawned (for mob_remove_damaged: no)
-	unsigned int delay1, delay2; //Spawn delay (fixed base + random variance)
-	unsigned int level;
+	uint32 delay1, delay2; //Spawn delay (fixed base + random variance)
+	uint32 level;
 	struct {
-		unsigned int size : 2; //Holds if mob has to be tiny/large
+		uint32 size : 2; //Holds if mob has to be tiny/large
 		enum mob_ai ai; //Special ai for summoned monsters.
-		unsigned int dynamic : 1; //Whether this data is indexed by a map's dynamic mob list
-		unsigned int boss : 1; //0: Non-boss monster | 1: Boss monster
+		uint32 dynamic : 1; //Whether this data is indexed by a map's dynamic mob list
+		uint32 boss : 1; //0: Non-boss monster | 1: Boss monster
 	} state;
 	char name[NAME_LENGTH], eventname[EVENT_NAME_LENGTH]; //Name/event
 };
@@ -694,7 +694,7 @@ enum e_skill_damage_type : uint8 {
 
 /// Struct for MF_SKILL_DAMAGE
 struct s_skill_damage {
-	unsigned int map; ///< Maps (used for skill_damage_db.txt)
+	uint32 map; ///< Maps (used for skill_damage_db.txt)
 	uint16 caster; ///< Caster type
 	int rate[SKILLDMG_MAX]; ///< Used for when all skills are adjusted
 };

+ 1 - 1
src/map/mercenary.cpp

@@ -53,7 +53,7 @@ struct view_data *mercenary_get_viewdata( uint16 class_ ){
 * @param lifetime Contract duration
 * @return false if failed, true otherwise
 **/
-bool mercenary_create(map_session_data *sd, uint16 class_, unsigned int lifetime) {
+bool mercenary_create(map_session_data *sd, uint16 class_, uint32 lifetime) {
 	nullpo_retr(false,sd);
 
 	std::shared_ptr<s_mercenary_db> db = mercenary_db.find(class_);

+ 1 - 1
src/map/mercenary.hpp

@@ -71,7 +71,7 @@ public:
 
 extern MercenaryDatabase mercenary_db;
 
-bool mercenary_create(map_session_data *sd, uint16 class_, unsigned int lifetime);
+bool mercenary_create(map_session_data *sd, uint16 class_, uint32 lifetime);
 bool mercenary_recv_data(s_mercenary *merc, bool flag);
 void mercenary_save(s_mercenary_data *md);
 

+ 14 - 14
src/map/mob.cpp

@@ -626,7 +626,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target)
 	return false;
 }
 
-struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int16 y, const char *mobname, int mob_id, const char *event, unsigned int size, enum mob_ai ai)
+struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int16 y, const char *mobname, int mob_id, const char *event, uint32 size, enum mob_ai ai)
 {
 	struct spawn_data data;
 
@@ -669,7 +669,7 @@ struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int
 /*==========================================
  * Spawn a single mob on the specified coordinates.
  *------------------------------------------*/
-int mob_once_spawn(map_session_data* sd, int16 m, int16 x, int16 y, const char* mobname, int mob_id, int amount, const char* event, unsigned int size, enum mob_ai ai)
+int mob_once_spawn(map_session_data* sd, int16 m, int16 x, int16 y, const char* mobname, int mob_id, int amount, const char* event, uint32 size, enum mob_ai ai)
 {
 	struct mob_data* md = nullptr;
 	int count, lv;
@@ -722,7 +722,7 @@ int mob_once_spawn(map_session_data* sd, int16 m, int16 x, int16 y, const char*
 /*==========================================
  * Spawn mobs in the specified area.
  *------------------------------------------*/
-int mob_once_spawn_area(map_session_data* sd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, const char* mobname, int mob_id, int amount, const char* event, unsigned int size, enum mob_ai ai)
+int mob_once_spawn_area(map_session_data* sd, int16 m, int16 x0, int16 y0, int16 x1, int16 y1, const char* mobname, int mob_id, int amount, const char* event, uint32 size, enum mob_ai ai)
 {
 	int i, max, id = 0;
 	int lx = -1, ly = -1;
@@ -931,7 +931,7 @@ int mob_spawn_guardian(const char* mapname, int16 x, int16 y, const char* mobnam
 /*==========================================
  * Summoning BattleGround [Zephyrus]
  *------------------------------------------*/
-int mob_spawn_bg(const char* mapname, int16 x, int16 y, const char* mobname, int mob_id, const char* event, unsigned int bg_id)
+int mob_spawn_bg(const char* mapname, int16 x, int16 y, const char* mobname, int mob_id, const char* event, uint32 bg_id)
 {
 	struct mob_data *md = nullptr;
 	struct spawn_data data;
@@ -1055,7 +1055,7 @@ TIMER_FUNC(mob_delayspawn){
  *------------------------------------------*/
 int mob_setdelayspawn(struct mob_data *md)
 {
-	unsigned int spawntime;
+	uint32 spawntime;
 
 	if (!md->spawn) //Doesn't has respawn data!
 		return unit_free(&md->bl,CLR_DEAD);
@@ -2485,7 +2485,7 @@ void mob_log_damage(struct mob_data *md, struct block_list *src, int damage)
 	if( char_id )
 	{ //Log damage...
 		int i,minpos;
-		unsigned int mindmg;
+		uint32 mindmg;
 		for(i=0,minpos=DAMAGELOG_SIZE-1,mindmg=UINT_MAX;i<DAMAGELOG_SIZE;i++){
 			if(md->dmglog[i].id==char_id &&
 				md->dmglog[i].flag==flag)
@@ -2525,7 +2525,7 @@ void mob_damage(struct mob_data *md, struct block_list *src, int damage)
 	}
 
 	if (src && damage > 0) { //Store total damage...
-		if (UINT_MAX - (unsigned int)damage > md->tdmg)
+		if (UINT_MAX - (uint32)damage > md->tdmg)
 			md->tdmg += damage;
 		else if (md->tdmg == UINT_MAX)
 			damage = 0; //Stop recording damage once the cap has been reached.
@@ -2571,7 +2571,7 @@ int mob_getdroprate(struct block_list *src, std::shared_ptr<s_mob_db> mob, int b
 	int drop_rate = base_rate;
 
 	if (md && battle_config.mob_size_influence) {  // Change drops depending on monsters size [Valaris]
-		unsigned int mob_size = md->special_state.size;
+		uint32 mob_size = md->special_state.size;
 		if (mob_size == SZ_MEDIUM && drop_rate >= 2)
 			drop_rate /= 2; // SZ_MEDIUM actually is small size modification... this is not a bug!
 		else if (mob_size == SZ_BIG)
@@ -2656,7 +2656,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 	} pt[DAMAGELOG_SIZE];
 	int i, temp, count, m = md->bl.m;
 	int dmgbltypes = 0;  // bitfield of all bl types, that caused damage to the mob and are elligible for exp distribution
-	unsigned int mvp_damage;
+	uint32 mvp_damage;
 	t_tick tick = gettick();
 	bool rebirth, homkillonly, merckillonly;
 
@@ -3308,7 +3308,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
  * @param md : mob pointer
  * @param hp : hp to resurrect it with (only used for exp calculation)
  */
-void mob_revive(struct mob_data *md, unsigned int hp)
+void mob_revive(struct mob_data *md, uint32 hp)
 {
 	t_tick tick = gettick();
 	md->state.skillstate = MSS_IDLE;
@@ -3525,7 +3525,7 @@ int mob_class_change (struct mob_data *md, int mob_id)
 /*==========================================
  * mob heal, update display hp info of mob for players
  *------------------------------------------*/
-void mob_heal(struct mob_data *md,unsigned int heal)
+void mob_heal(struct mob_data *md,uint32 heal)
 {
 	if (battle_config.show_mob_info&3)
 		clif_name_area(&md->bl);
@@ -4175,7 +4175,7 @@ static bool mob_clone_disabled_skills(uint16 skill_id) {
 //If mode is not passed, a default aggressive mode is used.
 //If master_id is passed, clone is attached to him.
 //Returns: ID of newly crafted copy.
-int mob_clone_spawn(map_session_data *sd, int16 m, int16 x, int16 y, const char *event, int master_id, enum e_mode mode, int flag, unsigned int duration)
+int mob_clone_spawn(map_session_data *sd, int16 m, int16 x, int16 y, const char *event, int master_id, enum e_mode mode, int flag, uint32 duration)
 {
 	int mob_id;
 	int inf, fd;
@@ -4398,7 +4398,7 @@ int mob_clone_delete(struct mob_data *md){
 }
 
 //Adjusts the drop rate of item according to the criteria given. [Skotlex]
-static unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned short rate_min, unsigned short rate_max)
+static uint32 mob_drop_adjust(int baserate, int rate_adjust, unsigned short rate_min, unsigned short rate_max)
 {
 	double rate = baserate;
 
@@ -4410,7 +4410,7 @@ static unsigned int mob_drop_adjust(int baserate, int rate_adjust, unsigned shor
 		//Classical linear rate adjustment.
 		rate = rate * rate_adjust/100;
 
-	return (unsigned int)cap_value(rate,rate_min,rate_max);
+	return (uint32)cap_value(rate,rate_min,rate_max);
 }
 
 /**

+ 20 - 20
src/map/mob.hpp

@@ -327,19 +327,19 @@ struct mob_data {
 	std::shared_ptr<s_mob_db> db;	//For quick data access (saves doing mob_db(md->mob_id) all the time) [Skotlex]
 	char name[NAME_LENGTH];
 	struct s_specialState {
-		unsigned int size : 2; //Small/Big monsters.
+		uint32 size : 2; //Small/Big monsters.
 		enum mob_ai ai; //Special ai for summoned monsters.
-		unsigned int clone : 1;/* is clone? 1:0 */
+		uint32 clone : 1;/* is clone? 1:0 */
 	} special_state; //Special mob information that does not needs to be zero'ed on mob respawn.
 	struct s_MobState {
-		unsigned int aggressive : 1; //Signals whether the mob AI is in aggressive mode or reactive mode. [Skotlex]
-		unsigned int steal_coin_flag : 1;
-		unsigned int soul_change_flag : 1; // Celest
-		unsigned int can_escape: 1;
-		unsigned int npc_killmonster: 1; //for new killmonster behavior
-		unsigned int rebirth: 1; // NPC_Rebirth used
-		unsigned int boss : 1;
-		unsigned int copy_master_mode : 1; ///< Whether the spawned monster should copy the master's mode.
+		uint32 aggressive : 1; //Signals whether the mob AI is in aggressive mode or reactive mode. [Skotlex]
+		uint32 steal_coin_flag : 1;
+		uint32 soul_change_flag : 1; // Celest
+		uint32 can_escape: 1;
+		uint32 npc_killmonster: 1; //for new killmonster behavior
+		uint32 rebirth: 1; // NPC_Rebirth used
+		uint32 boss : 1;
+		uint32 copy_master_mode : 1; ///< Whether the spawned monster should copy the master's mode.
 		enum MobSkillState skillstate;
 		unsigned char steal_flag; //number of steal tries (to prevent steal exploit on mobs with few items) [Lupus]
 		unsigned char attacked_count; //For rude attacked.
@@ -348,8 +348,8 @@ struct mob_data {
 	struct guardian_data* guardian_data;
 	struct s_dmglog {
 		int id; //char id
-		unsigned int dmg;
-		unsigned int flag : 2; //0: Normal. 1: Homunc exp. 2: Pet exp
+		uint32 dmg;
+		uint32 flag : 2; //0: Normal. 1: Homunc exp. 2: Pet exp
 	} dmglog[DAMAGELOG_SIZE];
 	uint32 spotted_log[DAMAGELOG_SIZE];
 	struct spawn_data *spawn; //Spawn data.
@@ -357,7 +357,7 @@ struct mob_data {
 	int16 centerX, centerY; // Spawn center of this individual monster
 	struct s_mob_lootitem *lootitems;
 	short mob_id;
-	unsigned int tdmg; //Stores total damage given to the mob, for exp calculations. [Skotlex]
+	uint32 tdmg; //Stores total damage given to the mob, for exp calculations. [Skotlex]
 	int level;
 	int target_id,attacked_id,norm_attacked_id;
 	int areanpc_id; //Required in OnTouchNPC (to avoid multiple area touchs)
@@ -491,18 +491,18 @@ struct view_data* mob_get_viewdata(int mob_id);
 void mob_set_dynamic_viewdata( struct mob_data* md );
 void mob_free_dynamic_viewdata( struct mob_data* md );
 
-struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int16 y, const char *mobname, int mob_id, const char *event, unsigned int size, enum mob_ai ai);
+struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int16 y, const char *mobname, int mob_id, const char *event, uint32 size, enum mob_ai ai);
 
 int mob_once_spawn(map_session_data* sd, int16 m, int16 x, int16 y,
-	const char* mobname, int mob_id, int amount, const char* event, unsigned int size, enum mob_ai ai);
+	const char* mobname, int mob_id, int amount, const char* event, uint32 size, enum mob_ai ai);
 
 int mob_once_spawn_area(map_session_data* sd, int16 m,
-	int16 x0, int16 y0, int16 x1, int16 y1, const char* mobname, int mob_id, int amount, const char* event, unsigned int size, enum mob_ai ai);
+	int16 x0, int16 y0, int16 x1, int16 y1, const char* mobname, int mob_id, int amount, const char* event, uint32 size, enum mob_ai ai);
 
 bool mob_ksprotected (struct block_list *src, struct block_list *target);
 
 int mob_spawn_guardian(const char* mapname, int16 x, int16 y, const char* mobname, int mob_id, const char* event, int guardian, bool has_index);	// Spawning Guardians [Valaris]
-int mob_spawn_bg(const char* mapname, int16 x, int16 y, const char* mobname, int mob_id, const char* event, unsigned int bg_id);
+int mob_spawn_bg(const char* mapname, int16 x, int16 y, const char* mobname, int mob_id, const char* event, uint32 bg_id);
 int mob_guardian_guildchange(struct mob_data *md); //Change Guardian's ownership. [Skotlex]
 
 int mob_randomwalk(struct mob_data *md,t_tick tick);
@@ -517,8 +517,8 @@ int mob_parse_dataset(struct spawn_data *data);
 void mob_log_damage(struct mob_data *md, struct block_list *src, int damage);
 void mob_damage(struct mob_data *md, struct block_list *src, int damage);
 int mob_dead(struct mob_data *md, struct block_list *src, int type);
-void mob_revive(struct mob_data *md, unsigned int hp);
-void mob_heal(struct mob_data *md,unsigned int heal);
+void mob_revive(struct mob_data *md, uint32 hp);
+void mob_heal(struct mob_data *md,uint32 heal);
 
 #define mob_stop_walking(md, type) unit_stop_walking(&(md)->bl, type)
 #define mob_stop_attack(md) unit_stop_attack(&(md)->bl)
@@ -546,7 +546,7 @@ int mob_removeslaves(block_list* bl);
 
 int mob_is_clone(int mob_id);
 
-int mob_clone_spawn(map_session_data *sd, int16 m, int16 x, int16 y, const char *event, int master_id, enum e_mode mode, int flag, unsigned int duration);
+int mob_clone_spawn(map_session_data *sd, int16 m, int16 x, int16 y, const char *event, int master_id, enum e_mode mode, int flag, uint32 duration);
 int mob_clone_delete(struct mob_data *md);
 
 void mob_reload_itemmob_data(void);

+ 5 - 5
src/map/npc.cpp

@@ -1009,7 +1009,7 @@ bool npc_enable_target(npc_data& nd, uint32 char_id, e_npcv_status flag)
 			return false;
 		}
 
-		unsigned int option = nd.sc.option;
+		uint32 option = nd.sc.option;
 		if (flag & NPCVIEW_CLOAKOFF)
 			nd.sc.option &= ~OPTION_CLOAK;
 		else
@@ -1100,7 +1100,7 @@ struct npc_data* npc_name2id(const char* name)
  **/
 TIMER_FUNC(npc_secure_timeout_timer){
 	map_session_data* sd = nullptr;
-	unsigned int timeout = NPC_SECURE_TIMEOUT_NEXT;
+	uint32 timeout = NPC_SECURE_TIMEOUT_NEXT;
 	t_tick cur_tick = gettick(); //ensure we are on last tick
 
 	if ((sd = map_id2sd(id)) == nullptr || !sd->npc_id || sd->state.ignoretimeout) {
@@ -3641,7 +3641,7 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta
 	if( p ) { // <Display name>::<Unique name>
 		size_t len = p-name;
 		if( len > NPC_NAME_LENGTH ) {
-			ShowWarning("npc_parsename: Display name of '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NPC_NAME_LENGTH);
+			ShowWarning("npc_parsename: Display name of '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (uint32)len, filepath, strline(buffer,start-buffer), NPC_NAME_LENGTH);
 			safestrncpy(nd->name, name, sizeof(nd->name));
 		} else {
 			memcpy(nd->name, name, len);
@@ -3649,12 +3649,12 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta
 		}
 		len = strlen(p+2);
 		if( len > NPC_NAME_LENGTH )
-			ShowWarning("npc_parsename: Unique name of '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NPC_NAME_LENGTH);
+			ShowWarning("npc_parsename: Unique name of '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (uint32)len, filepath, strline(buffer,start-buffer), NPC_NAME_LENGTH);
 		safestrncpy(nd->exname, p+2, sizeof(nd->exname));
 	} else {// <Display name>
 		size_t len = strlen(name);
 		if( len > NPC_NAME_LENGTH )
-			ShowWarning("npc_parsename: Name '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (unsigned int)len, filepath, strline(buffer,start-buffer), NPC_NAME_LENGTH);
+			ShowWarning("npc_parsename: Name '%s' is too long (len=%u) in file '%s', line'%d'. Truncating to %u characters.\n", name, (uint32)len, filepath, strline(buffer,start-buffer), NPC_NAME_LENGTH);
 		safestrncpy(nd->name, name, sizeof(nd->name));
 		safestrncpy(nd->exname, name, sizeof(nd->exname));
 	}

+ 3 - 3
src/map/npc.hpp

@@ -33,7 +33,7 @@ struct npc_label_list {
 /// Item list for NPC sell/buy list
 struct npc_item_list {
 	t_itemid nameid;
-	unsigned int value;
+	uint32 value;
 #if PACKETVER >= 20131223
 	int32 qty; ///< Stock counter (Market shop)
 	uint8 flag; ///< 1: Item added by npcshopitem/npcshopadditem, force load! (Market shop)
@@ -164,14 +164,14 @@ struct npc_data {
 	char name[NPC_NAME_LENGTH+1];// display name
 	char exname[NPC_NAME_LENGTH+1];// unique npc name
 	int chat_id,touching_id;
-	unsigned int next_walktime;
+	uint32 next_walktime;
 	int instance_id;
 	e_npcv_status state{NPCVIEW_ENABLE};
 
 	unsigned size : 2;
 
 	struct status_data status;
-	unsigned int level,stat_point;
+	uint32 level,stat_point;
 	struct s_npc_params {
 		unsigned short str, agi, vit, int_, dex, luk;
 	} params;

+ 5 - 5
src/map/party.cpp

@@ -40,7 +40,7 @@ int party_create_byscript;
  * Fills the given party_member structure according to the sd provided.
  * Used when creating/adding people to a party. [Skotlex]
  *------------------------------------------*/
-static void party_fill_member( struct party_member& member, map_session_data& sd, unsigned int leader ){
+static void party_fill_member( struct party_member& member, map_session_data& sd, uint32 leader ){
 	member.account_id = sd.status.account_id;
 	member.char_id = sd.status.char_id;
 	safestrncpy(member.name, sd.status.name, NAME_LENGTH);
@@ -1238,7 +1238,7 @@ int party_send_xy_clear(struct party_data *p)
 void party_exp_share(struct party_data* p, struct block_list* src, t_exp base_exp, t_exp job_exp, int zeny)
 {
 	map_session_data* sd[MAX_PARTY];
-	unsigned int i, c;
+	uint32 i, c;
 #ifdef RENEWAL_EXP
 	TBL_MOB *md = BL_CAST(BL_MOB, src);
 
@@ -1269,7 +1269,7 @@ void party_exp_share(struct party_data* p, struct block_list* src, t_exp base_ex
 		if (job_exp)
 			job_exp = (t_exp) cap_value(job_exp * bonus/100, 0, MAX_EXP);
 		if (zeny)
-			zeny = (unsigned int) cap_value(zeny * bonus/100, INT_MIN, INT_MAX);
+			zeny = (uint32)cap_value(zeny * bonus/100, INT_MIN, INT_MAX);
 	}
 
 	for (i = 0; i < c; i++) {
@@ -1398,8 +1398,8 @@ int party_sub_count(struct block_list *bl, va_list ap)
 int party_sub_count_class(struct block_list *bl, va_list ap)
 {
 	map_session_data *sd = (TBL_PC *)bl;
-	unsigned int mask = va_arg(ap, unsigned int);
-	unsigned int mapid_class = va_arg(ap, unsigned int);
+	uint32 mask = va_arg(ap, uint32);
+	uint32 mapid_class = va_arg(ap, uint32);
 
 	if( !party_sub_count(bl, ap) )
 		return 0;

+ 1 - 1
src/map/party.hpp

@@ -18,7 +18,7 @@ struct item;
 
 struct party_member_data {
 	map_session_data *sd;
-	unsigned int hp; //For HP,x,y refreshing.
+	uint32 hp; //For HP,x,y refreshing.
 	unsigned short x, y;
 };
 

+ 2 - 2
src/map/path.cpp

@@ -445,10 +445,10 @@ bool check_distance(int dx, int dy, int distance)
 #endif
 }
 
-unsigned int distance(int dx, int dy)
+uint32 distance(int dx, int dy)
 {
 #ifdef CIRCULAR_AREA
-	unsigned int min, max;
+	uint32 min, max;
 
 	if ( dx < 0 ) dx = -dx;
 	if ( dy < 0 ) dy = -dy;

+ 1 - 1
src/map/path.hpp

@@ -64,7 +64,7 @@ bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16
 
 // distance related functions
 bool check_distance(int dx, int dy, int distance);
-unsigned int distance(int dx, int dy);
+uint32 distance(int dx, int dy);
 bool check_distance_client(int dx, int dy, int distance);
 int distance_client(int dx, int dy);
 

+ 43 - 43
src/map/pc.cpp

@@ -71,7 +71,7 @@ JobDatabase job_db;
 CaptchaDatabase captcha_db;
 const char *macro_allowed_answer_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
 
-int pc_split_atoui(char* str, unsigned int* val, char sep, int max);
+int pc_split_atoui(char* str, uint32* val, char sep, int max);
 static inline bool pc_attendance_rewarded_today( map_session_data* sd );
 
 #define PVP_CALCRANK_INTERVAL 1000	// PVP calculation interval
@@ -628,7 +628,7 @@ bool reg_load;
 /**
  * Translation table from athena equip index to aegis bitmask
 */
-unsigned int equip_bitmask[EQI_MAX] = {
+uint32 equip_bitmask[EQI_MAX] = {
 	EQP_ACC_L,				// EQI_ACC_L
 	EQP_ACC_R,				// EQI_ACC_R
 	EQP_SHOES,				// EQI_SHOES
@@ -1131,7 +1131,7 @@ void pc_inventory_rental_clear(map_session_data *sd)
 void pc_inventory_rentals(map_session_data *sd)
 {
 	int i, c = 0;
-	unsigned int next_tick = UINT_MAX;
+	uint32 next_tick = UINT_MAX;
 
 	for( i = 0; i < MAX_INVENTORY; i++ ) { // Check for Rentals on Inventory
 		if( sd->inventory.u.items_inventory[i].nameid == 0 )
@@ -1144,7 +1144,7 @@ void pc_inventory_rentals(map_session_data *sd)
 			clif_rental_expired(sd, i, sd->inventory.u.items_inventory[i].nameid);
 			pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 0, 0, LOG_TYPE_OTHER);
 		} else {
-			unsigned int expire_tick = (unsigned int)(sd->inventory.u.items_inventory[i].expire_time - time(nullptr));
+			uint32 expire_tick = (uint32)(sd->inventory.u.items_inventory[i].expire_time - time(nullptr));
 
 			clif_rental_time(sd, sd->inventory.u.items_inventory[i].nameid, (int)expire_tick);
 			next_tick = umin(expire_tick * 1000U, next_tick);
@@ -1163,7 +1163,7 @@ void pc_inventory_rentals(map_session_data *sd)
  * @param sd: Player data
  * @param seconds: Rental time
  */
-void pc_inventory_rental_add(map_session_data *sd, unsigned int seconds)
+void pc_inventory_rental_add(map_session_data *sd, uint32 seconds)
 {
 	t_tick tick = seconds * 1000;
 
@@ -1811,9 +1811,9 @@ uint8 pc_isequip(map_session_data *sd,int n)
 			}
 	}
 
-	if(item->elv && sd->status.base_level < static_cast<unsigned int>(item->elv))
+	if(item->elv && sd->status.base_level < static_cast<uint32>(item->elv))
 		return ITEM_EQUIP_ACK_FAILLEVEL;
-	if(item->elvmax && sd->status.base_level > static_cast<unsigned int>(item->elvmax))
+	if(item->elvmax && sd->status.base_level > static_cast<uint32>(item->elvmax))
 		return ITEM_EQUIP_ACK_FAILLEVEL;
 	if(item->sex != SEX_BOTH && sd->status.sex != item->sex)
 		return ITEM_EQUIP_ACK_FAIL;
@@ -2271,7 +2271,7 @@ bool pc_set_hate_mob(map_session_data *sd, int pos, struct block_list *bl)
 
 	class_ = status_get_class(bl);
 	if (!pcdb_checkid(class_)) {
-		unsigned int max_hp = status_get_max_hp(bl);
+		uint32 max_hp = status_get_max_hp(bl);
 		if ((pos == 1 && max_hp < 6000) || (pos == 2 && max_hp < 20000))
 			return false;
 		if (pos != status_get_size(bl))
@@ -3141,7 +3141,7 @@ static void pc_bonus_autospell_onskill(std::vector<s_autospell> &spell, uint16 s
  * @param flag: Target flag
  * @param duration: Duration. If 0 use default duration lookup for associated skill with level 7
  */
-static void pc_bonus_addeff(std::vector<s_addeffect> &effect, enum sc_type sc, int rate, short arrow_rate, unsigned char flag, unsigned int duration)
+static void pc_bonus_addeff(std::vector<s_addeffect> &effect, enum sc_type sc, int rate, short arrow_rate, unsigned char flag, uint32 duration)
 {
 	if (effect.size() == MAX_PC_BONUS) {
 		ShowWarning("pc_bonus_addeff: Reached max (%d) number of add effects per character!\n", MAX_PC_BONUS);
@@ -3156,7 +3156,7 @@ static void pc_bonus_addeff(std::vector<s_addeffect> &effect, enum sc_type sc, i
 		flag |= ATF_WEAPON; //Default type: weapon.
 
 	if (!duration)
-		duration = (unsigned int)skill_get_time2(status_db.getSkill(sc), 7);
+		duration = (uint32)skill_get_time2(status_db.getSkill(sc), 7);
 
 	for (auto &it : effect) {
 		if (it.sc == sc && it.flag == flag) {
@@ -3187,7 +3187,7 @@ static void pc_bonus_addeff(std::vector<s_addeffect> &effect, enum sc_type sc, i
  * @param target: Target type
  * @param duration: Duration. If 0 use default duration lookup for associated skill with level 7
  */
-static void pc_bonus_addeff_onskill(std::vector<s_addeffectonskill> &effect, enum sc_type sc, int rate, short skill_id, unsigned char target, unsigned int duration)
+static void pc_bonus_addeff_onskill(std::vector<s_addeffectonskill> &effect, enum sc_type sc, int rate, short skill_id, unsigned char target, uint32 duration)
 {
 	if (effect.size() == MAX_PC_BONUS) {
 		ShowWarning("pc_bonus_addeff_onskill: Reached max (%d) number of add effects per character!\n", MAX_PC_BONUS);
@@ -3195,7 +3195,7 @@ static void pc_bonus_addeff_onskill(std::vector<s_addeffectonskill> &effect, enu
 	}
 
 	if (!duration)
-		duration = (unsigned int)skill_get_time2(status_db.getSkill(sc), 7);
+		duration = (uint32)skill_get_time2(status_db.getSkill(sc), 7);
 
 	for (auto &it : effect) {
 		if (it.sc == sc && it.skill_id == skill_id && it.target == target) {
@@ -3308,7 +3308,7 @@ s_autobonus::~s_autobonus(){
  * @param onskill: Skill used to trigger autobonus
  * @return True on success or false otherwise
  */
-bool pc_addautobonus(std::vector<std::shared_ptr<s_autobonus>> &bonus, const char *script, short rate, unsigned int dur, uint16 flag, const char *other_script, unsigned int pos, bool onskill){
+bool pc_addautobonus(std::vector<std::shared_ptr<s_autobonus>> &bonus, const char *script, short rate, uint32 dur, uint16 flag, const char *other_script, uint32 pos, bool onskill){
 	// Check if the same bonus already exists
 	for( std::shared_ptr<s_autobonus> autobonus : bonus ){
 		// Compare based on position and bonus script
@@ -3366,7 +3366,7 @@ void pc_delautobonus(map_session_data &sd, std::vector<std::shared_ptr<s_autobon
 		std::shared_ptr<s_autobonus> b = *it;
 
 		if( b->active != INVALID_TIMER && restore && b->bonus_script != nullptr ){
-			unsigned int equip_pos_idx = 0;
+			uint32 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 (uint8 j = 0; j < EQI_MAX; j++) {
@@ -3404,7 +3404,7 @@ void pc_exeautobonus(map_session_data &sd, std::vector<std::shared_ptr<s_autobon
 	if( autobonus->other_script )
 	{
 		int j;
-		unsigned int equip_pos_idx = 0;
+		uint32 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)
@@ -5872,7 +5872,7 @@ short pc_search_inventory(map_session_data *sd, t_itemid nameid) {
 enum e_additem_result pc_additem(map_session_data *sd,struct item *item,int amount,e_log_pick_type log_type) {
 	struct item_data *id;
 	int16 i;
-	unsigned int w;
+	uint32 w;
 
 	nullpo_retr(ADDITEM_INVALID, sd);
 	nullpo_retr(ADDITEM_INVALID, item);
@@ -5960,7 +5960,7 @@ enum e_additem_result pc_additem(map_session_data *sd,struct item *item,int amou
 			clif_rental_expired(sd, i, sd->inventory.u.items_inventory[i].nameid);
 			pc_delitem(sd, i, sd->inventory.u.items_inventory[i].amount, 1, 0, LOG_TYPE_OTHER);
 		} else {
-			unsigned int seconds = (unsigned int)( item->expire_time - time(nullptr) );
+			uint32 seconds = (uint32)( item->expire_time - time(nullptr) );
 			clif_rental_time(sd, sd->inventory.u.items_inventory[i].nameid, seconds);
 			pc_inventory_rental_add(sd, seconds);
 		}
@@ -6295,9 +6295,9 @@ bool pc_isUseitem(map_session_data *sd,int n)
 	if(item->sex != SEX_BOTH && sd->status.sex != item->sex)
 		return false;
 	//Required level check
-	if(item->elv && sd->status.base_level < (unsigned int)item->elv)
+	if(item->elv && sd->status.base_level < (uint32)item->elv)
 		return false;
-	if(item->elvmax && sd->status.base_level > (unsigned int)item->elvmax)
+	if(item->elvmax && sd->status.base_level > (uint32)item->elvmax)
 		return false;
 
 	//Not equipable by class. [Skotlex]
@@ -8170,7 +8170,7 @@ void pc_baselevelchanged(map_session_data *sd) {
 	uint8 i;
 	for( i = 0; i < EQI_MAX; i++ ) {
 		if( sd->equip_index[i] >= 0 && sd->inventory_data[sd->equip_index[i]] ) {
-			if( sd->inventory_data[ sd->equip_index[i] ]->elvmax && sd->status.base_level > (unsigned int)sd->inventory_data[ sd->equip_index[i] ]->elvmax )
+			if( sd->inventory_data[ sd->equip_index[i] ]->elvmax && sd->status.base_level > (uint32)sd->inventory_data[ sd->equip_index[i] ]->elvmax )
 				pc_unequipitem(sd, sd->equip_index[i], 3);
 		}
 	}
@@ -8361,12 +8361,12 @@ void pc_gainexp(map_session_data *sd, struct block_list *src, t_exp base_exp, t_
 		if (nextb > 0) {
 			float nextbp = (float) base_exp / (float) nextb;
 			if (nextbp > battle_config.max_exp_gain_rate/1000.)
-				base_exp = (unsigned int)(battle_config.max_exp_gain_rate/1000.*nextb);
+				base_exp = (uint32)(battle_config.max_exp_gain_rate/1000.*nextb);
 		}
 		if (nextj > 0) {
 			float nextjp = (float) job_exp / (float) nextj;
 			if (nextjp > battle_config.max_exp_gain_rate/1000.)
-				job_exp = (unsigned int)(battle_config.max_exp_gain_rate/1000.*nextj);
+				job_exp = (uint32)(battle_config.max_exp_gain_rate/1000.*nextj);
 		}
 	}
 
@@ -8439,7 +8439,7 @@ uint32 JobDatabase::get_maxBaseLv(uint16 job_id) {
  * @param sd Player
  * @return Max Base Level
  **/
-unsigned int pc_maxbaselv(map_session_data *sd){
+uint32 pc_maxbaselv(map_session_data *sd){
 	return job_db.get_maxBaseLv(sd->status.class_);
 }
 
@@ -8459,7 +8459,7 @@ uint32 JobDatabase::get_maxJobLv(uint16 job_id) {
  * @param sd Player
  * @return Max Job Level
  **/
-unsigned int pc_maxjoblv(map_session_data *sd){
+uint32 pc_maxjoblv(map_session_data *sd){
 	return job_db.get_maxJobLv(sd->status.class_);
 }
 
@@ -9543,7 +9543,7 @@ static TIMER_FUNC(pc_respawn_timer){
 /*==========================================
  * Invoked when a player has received damage
  *------------------------------------------*/
-void pc_damage(map_session_data *sd,struct block_list *src,unsigned int hp, unsigned int sp, unsigned int ap)
+void pc_damage(map_session_data *sd,struct block_list *src,uint32 hp, uint32 sp, uint32 ap)
 {
 	if (ap) clif_updatestatus(*sd,SP_AP);
 	if (sp) clif_updatestatus(*sd,SP_SP);
@@ -9778,7 +9778,7 @@ int pc_dead(map_session_data *sd,struct block_list *src)
 			if(md->target_id==sd->bl.id)
 				mob_unlocktarget(md,tick);
 			if(battle_config.mobs_level_up && md->status.hp &&
-				(unsigned int)md->level < pc_maxbaselv(sd) &&
+				(uint32)md->level < pc_maxbaselv(sd) &&
 				!md->guardian_data && !md->special_state.ai// Guardians/summons should not level. [Skotlex]
 			) { 	// monster level up [Valaris]
 				clif_misceffect( md->bl, NOTIFYEFFECT_BASE_LEVEL_UP );
@@ -9999,7 +9999,7 @@ int pc_dead(map_session_data *sd,struct block_list *src)
 	return 1;
 }
 
-void pc_revive(map_session_data *sd,unsigned int hp, unsigned int sp, unsigned int ap) {
+void pc_revive(map_session_data *sd,uint32 hp, uint32 sp, uint32 ap) {
 	if(hp) clif_updatestatus(*sd,SP_HP);
 	if(sp) clif_updatestatus(*sd,SP_SP);
 	if(ap) clif_updatestatus(*sd,SP_AP);
@@ -10257,7 +10257,7 @@ bool pc_setparam(map_session_data *sd,int64 type,int64 val_tmp)
 {
 	nullpo_retr(false,sd);
 
-	int val = static_cast<unsigned int>(val_tmp);
+	int val = static_cast<uint32>(val_tmp);
 
 	switch(type){
 	case SP_BASELEVEL:
@@ -10505,7 +10505,7 @@ bool pc_setparam(map_session_data *sd,int64 type,int64 val_tmp)
 /*==========================================
  * HP/SP/AP Healing. If flag is passed, the heal type is through clif_heal, otherwise update status.
  *------------------------------------------*/
-void pc_heal(map_session_data *sd,unsigned int hp,unsigned int sp, unsigned int ap, int type)
+void pc_heal(map_session_data *sd,uint32 hp,uint32 sp, uint32 ap, int type)
 {// Is there going to be a effect for gaining AP soon??? [Rytech]
 	nullpo_retv(sd);
 
@@ -11264,7 +11264,7 @@ char* pc_readregstr(map_session_data* sd, int64 reg)
 bool pc_setregstr(map_session_data* sd, int64 reg, const char* str)
 {
 	struct script_reg_str *p = nullptr;
-	unsigned int index = script_getvaridx(reg);
+	uint32 index = script_getvaridx(reg);
 	DBData prev;
 
 	nullpo_retr(false, sd);
@@ -11407,7 +11407,7 @@ bool pc_setregistry_str(map_session_data *sd, int64 reg, const char *val)
 {
 	struct script_reg_str *p = nullptr;
 	const char *regname = get_str(script_getvarid(reg));
-	unsigned int index = script_getvaridx(reg);
+	uint32 index = script_getvaridx(reg);
 	size_t vlen = 0;
 
 	if (!reg_load && !sd->vars_ok) {
@@ -11683,7 +11683,7 @@ static int pc_checkcombo(map_session_data *sd, item_data *data) {
 		};
 		std::vector<s_itemchk> combo_idx(nb_itemCombo);
 		size_t j;
-		unsigned int pos = 0;
+		uint32 pos = 0;
 
 		for (j = 0; j < nb_itemCombo; j++) {
 			t_itemid id = item_combo->nameid[j];
@@ -13232,7 +13232,7 @@ int pc_split_str(char *str,char **val,int num)
 	return i;
 }
 
-int pc_split_atoui(char* str, unsigned int* val, char sep, int max)
+int pc_split_atoui(char* str, uint32* val, char sep, int max)
 {
 	static int warning=0;
 	int i,j;
@@ -13249,7 +13249,7 @@ int pc_split_atoui(char* str, unsigned int* val, char sep, int max)
 				ShowWarning("pc_readdb (exp.txt): Required exp per level is capped to %u\n", UINT_MAX);
 			}
 		} else
-			val[i] = (unsigned int)f;
+			val[i] = (uint32)f;
 		str = strchr(str,sep);
 		if (str)
 			*str++=0;
@@ -13568,7 +13568,7 @@ void SkillTreeDatabase::loadingFinished() {
  * @return base_hp
  * @author [Cydh]
  */
-static unsigned int pc_calc_basehp(uint16 level, uint16 job_id) {
+static uint32 pc_calc_basehp(uint16 level, uint16 job_id) {
 	std::shared_ptr<s_job_info> job = job_db.find(job_id);
 	double base_hp = 35 + level * (job->hp_increase / 100.);
 
@@ -13580,7 +13580,7 @@ static unsigned int pc_calc_basehp(uint16 level, uint16 job_id) {
 		base_hp += floor(((job->hp_factor / 100.) * i) + 0.5); //Don't have round()
 	if (job_id == JOB_SUMMONER || job_id == JOB_SPIRIT_HANDLER)
 		base_hp += floor((base_hp / 2) + 0.5);
-	return (unsigned int)base_hp;
+	return (uint32)base_hp;
 }
 
 /**
@@ -13590,7 +13590,7 @@ static unsigned int pc_calc_basehp(uint16 level, uint16 job_id) {
  * @return base_sp
  * @author [Playtester]
  */
-static unsigned int pc_calc_basesp(uint16 level, uint16 job_id) {
+static uint32 pc_calc_basesp(uint16 level, uint16 job_id) {
 	std::shared_ptr<s_job_info> job = job_db.find(job_id);
 	double base_sp = 10 + floor(level * (job->sp_increase / 100.));
 
@@ -13613,7 +13613,7 @@ static unsigned int pc_calc_basesp(uint16 level, uint16 job_id) {
 			break;
 	}
 
-	return (unsigned int)base_sp;
+	return (uint32)base_sp;
 }
 
 const std::string JobDatabase::getDefaultLocation() {
@@ -14348,12 +14348,12 @@ int pc_read_motd(void)
 	// read current MOTD
 	if( ( fp = fopen(motd_txt, "r") ) != nullptr )
 	{
-		unsigned int entries = 0;
+		uint32 entries = 0;
 		char buf[CHAT_SIZE_MAX];
 
 		while( entries < MOTD_LINE_SIZE && fgets(buf, CHAT_SIZE_MAX, fp) )
 		{
-			unsigned int lines = 0;
+			uint32 lines = 0;
 			size_t len;
 			lines++;
 			if( buf[0] == '/' && buf[1] == '/' )
@@ -14684,7 +14684,7 @@ void pc_expire_check(map_session_data *sd) {
 		return;
 	}
 
-	sd->expiration_tid = add_timer(gettick() + (unsigned int)(sd->expiration_time - time(nullptr)) * 1000, pc_expiration_timer, sd->bl.id, 0);
+	sd->expiration_tid = add_timer(gettick() + (uint32)(sd->expiration_time - time(nullptr)) * 1000, pc_expiration_timer, sd->bl.id, 0);
 }
 
 /**
@@ -14697,7 +14697,7 @@ enum e_BANKING_DEPOSIT_ACK pc_bank_deposit(map_session_data *sd, int money) {
 		return BDA_ERROR;
 	}
 
-	unsigned int limit_check = money + sd->bank_vault;
+	uint32 limit_check = money + sd->bank_vault;
 	if( money <= 0 || limit_check > MAX_BANK_ZENY ) {
 		return BDA_OVERFLOW;
 	} else if ( money > sd->status.zeny ) {
@@ -14724,7 +14724,7 @@ enum e_BANKING_WITHDRAW_ACK pc_bank_withdraw(map_session_data *sd, int money) {
 		return BWA_UNKNOWN_ERROR;
 	}
 
-	unsigned int limit_check = money + sd->status.zeny;
+	uint32 limit_check = money + sd->status.zeny;
 	if( money <= 0 ) {
 		return BWA_UNKNOWN_ERROR;
 	} else if ( money > sd->bank_vault ) {

+ 73 - 73
src/map/pc.hpp

@@ -183,7 +183,7 @@ struct skill_cooldown_entry {
 
 #ifdef VIP_ENABLE
 struct vip_info {
-	unsigned int enabled : 1;
+	uint32 enabled : 1;
 	time_t time;
 	bool disableshowrate; //State to disable clif_display_pinfo(). [Cydh]
 };
@@ -227,7 +227,7 @@ static const char* parameter_names[PARAM_MAX] = {
 	"Crt"
 };
 
-extern unsigned int equip_bitmask[EQI_MAX];
+extern uint32 equip_bitmask[EQI_MAX];
 
 #define equip_index_check(i) ( (i) >= EQI_ACC_L && (i) < EQI_MAX )
 
@@ -304,7 +304,7 @@ struct s_addeffect {
 	int rate; /// Rate
 	short arrow_rate; /// Arrow rate
 	unsigned char flag; /// Flag
-	unsigned int duration; /// Duration the effect applied
+	uint32 duration; /// Duration the effect applied
 };
 
 /// AddEffOnSkill bonus struct
@@ -313,7 +313,7 @@ struct s_addeffectonskill {
 	int rate; /// Rate
 	short skill_id; /// Skill ID
 	unsigned char target; /// Target
-	unsigned int duration; /// Duration the effect applied
+	uint32 duration; /// Duration the effect applied
 };
 
 ///Struct of add drop item/group rate
@@ -335,10 +335,10 @@ struct s_vanish_bonus {
 struct s_autobonus {
 	short rate;
 	uint16 atk_type;
-	unsigned int duration;
+	uint32 duration;
 	char *bonus_script, *other_script;
 	int active;
-	unsigned int pos;
+	uint32 pos;
 
 	~s_autobonus();
 };
@@ -386,57 +386,57 @@ public:
 	//NOTE: When deciding to add a flag to state or special_state, take into consideration that state is preserved in
 	//status_calc_pc, while special_state is recalculated in each call. [Skotlex]
 	struct s_state {
-		unsigned int active : 1; //Marks active player (not active is logging in/out, or changing map servers)
-		unsigned int menu_or_input : 1;// if a script is waiting for feedback from the player
-		unsigned int dead_sit : 2;
-		unsigned int lr_flag : 3;//1: left h. weapon; 2: arrow; 3: shield
-		unsigned int connect_new : 1;
-		unsigned int arrow_atk : 1;
-		unsigned int gangsterparadise : 1;
-		unsigned int rest : 1;
-		unsigned int storage_flag : 3; //0: closed, 1: Normal Storage open, 2: guild storage open [Skotlex], 3: Premium Storage
-		unsigned int snovice_dead_flag : 1; //Explosion spirits on death: 0 off, 1 used.
-		unsigned int abra_flag : 2; // Abracadabra bugfix by Aru
-		unsigned int autocast : 1; // Autospell flag [Inkfish]
-		unsigned int autotrade : 3;	//By Fantik. &2 Requested by vending autotrade; &4 Requested by buyingstore autotrade
-		unsigned int showdelay :1;
-		unsigned int showexp :1;
-		unsigned int showzeny :1;
-		unsigned int noask :1; // [LuzZza]
-		unsigned int trading :1; //[Skotlex] is 1 only after a trade has started.
-		unsigned int deal_locked :2; //1: Clicked on OK. 2: Clicked on TRADE
-		unsigned int size :2; // for tiny/large types
-		unsigned int night :1; //Holds whether or not the player currently has the SI_NIGHT effect on. [Skotlex]
-		unsigned int using_fake_npc :1;
-		unsigned int rewarp :1; //Signals that a player should warp as soon as he is done loading a map. [Skotlex]
-		unsigned int killer : 1;
-		unsigned int killable : 1;
-		unsigned int doridori : 1;
-		unsigned int ignoreAll : 1;
-		unsigned int debug_remove_map : 1; // temporary state to track double remove_map's [FlavioJS]
-		unsigned int buyingstore : 1;
-		unsigned int lesseffect : 1;
-		unsigned int vending : 1;
-		unsigned int noks : 3; // [Zeph Kill Steal Protection]
-		unsigned int changemap : 1;
-		unsigned int callshop : 1; // flag to indicate that a script used callshop; on a shop
+		uint32 active : 1; //Marks active player (not active is logging in/out, or changing map servers)
+		uint32 menu_or_input : 1;// if a script is waiting for feedback from the player
+		uint32 dead_sit : 2;
+		uint32 lr_flag : 3;//1: left h. weapon; 2: arrow; 3: shield
+		uint32 connect_new : 1;
+		uint32 arrow_atk : 1;
+		uint32 gangsterparadise : 1;
+		uint32 rest : 1;
+		uint32 storage_flag : 3; //0: closed, 1: Normal Storage open, 2: guild storage open [Skotlex], 3: Premium Storage
+		uint32 snovice_dead_flag : 1; //Explosion spirits on death: 0 off, 1 used.
+		uint32 abra_flag : 2; // Abracadabra bugfix by Aru
+		uint32 autocast : 1; // Autospell flag [Inkfish]
+		uint32 autotrade : 3;	//By Fantik. &2 Requested by vending autotrade; &4 Requested by buyingstore autotrade
+		uint32 showdelay :1;
+		uint32 showexp :1;
+		uint32 showzeny :1;
+		uint32 noask :1; // [LuzZza]
+		uint32 trading :1; //[Skotlex] is 1 only after a trade has started.
+		uint32 deal_locked :2; //1: Clicked on OK. 2: Clicked on TRADE
+		uint32 size :2; // for tiny/large types
+		uint32 night :1; //Holds whether or not the player currently has the SI_NIGHT effect on. [Skotlex]
+		uint32 using_fake_npc :1;
+		uint32 rewarp :1; //Signals that a player should warp as soon as he is done loading a map. [Skotlex]
+		uint32 killer : 1;
+		uint32 killable : 1;
+		uint32 doridori : 1;
+		uint32 ignoreAll : 1;
+		uint32 debug_remove_map : 1; // temporary state to track double remove_map's [FlavioJS]
+		uint32 buyingstore : 1;
+		uint32 lesseffect : 1;
+		uint32 vending : 1;
+		uint32 noks : 3; // [Zeph Kill Steal Protection]
+		uint32 changemap : 1;
+		uint32 callshop : 1; // flag to indicate that a script used callshop; on a shop
 		short pmap; // Previous map on Map Change
 		unsigned short autoloot;
 		t_itemid autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus]
 		unsigned short autoloottype;
-		unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid
-		unsigned int gmaster_flag : 1;
-		unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
+		uint32 autolooting : 1; //performance-saver, autolooting state for @alootid
+		uint32 gmaster_flag : 1;
+		uint32 prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
 		bool pending_vending_ui; // flag whether the vending packet should still be sent to this player or not
-		unsigned int warping : 1;//states whether you're in the middle of a warp processing
-		unsigned int permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
+		uint32 warping : 1;//states whether you're in the middle of a warp processing
+		uint32 permanent_speed : 1; // When 1, speed cannot be changed through status_calc_pc().
 		bool hold_recalc;
-		unsigned int banking : 1; //1 when we using the banking system 0 when closed
-		unsigned int hpmeter_visible : 1;
+		uint32 banking : 1; //1 when we using the banking system 0 when closed
+		uint32 hpmeter_visible : 1;
 		unsigned disable_atcommand_on_npc : 1; //Prevent to use atcommand while talking with NPC [Kichi]
 		uint8 isBoundTrading; // Player is currently add bound item to trade list [Cydh]
 		bool ignoretimeout; // Prevent the SECURE_NPCTIMEOUT function from closing current script.
-		unsigned int workinprogress : 2; // See clif.hpp::e_workinprogress
+		uint32 workinprogress : 2; // See clif.hpp::e_workinprogress
 		bool pc_loaded; // Ensure inventory data and status data is loaded before we calculate player stats
 		bool keepshop; // Whether shop data should be removed when the player disconnects
 		bool mail_writing; // Whether the player is currently writing a mail in RODEX or not
@@ -459,17 +459,17 @@ public:
 	} state;
 	struct {
 		unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
-		unsigned int restart_full_recover : 1;
-		unsigned int no_castcancel : 1;
-		unsigned int no_castcancel2 : 1;
-		unsigned int no_sizefix : 1;
-		unsigned int no_gemstone : 2;
-		unsigned int intravision : 1; // Maya Purple Card effect [DracoRPG]
-		unsigned int perfect_hiding : 1; // [Valaris]
-		unsigned int no_knockback : 1;
-		unsigned int bonus_coma : 1;
-		unsigned int no_mado_fuel : 1; // Disable Magic_Gear_Fuel consumption [Secret]
-		unsigned int no_walk_delay : 1;
+		uint32 restart_full_recover : 1;
+		uint32 no_castcancel : 1;
+		uint32 no_castcancel2 : 1;
+		uint32 no_sizefix : 1;
+		uint32 no_gemstone : 2;
+		uint32 intravision : 1; // Maya Purple Card effect [DracoRPG]
+		uint32 perfect_hiding : 1; // [Valaris]
+		uint32 no_knockback : 1;
+		uint32 bonus_coma : 1;
+		uint32 no_mado_fuel : 1; // Disable Magic_Gear_Fuel consumption [Secret]
+		uint32 no_walk_delay : 1;
 	} special_state;
 	uint32 login_id1, login_id2;
 	uint64 class_;	//This is the internal job ID used by the map server to simplify comparisons/queries/etc. [Skotlex]
@@ -489,7 +489,7 @@ public:
 	struct item_data* inventory_data[MAX_INVENTORY]; // direct pointers to itemdb entries (faster than doing item_id lookups)
 	short equip_index[EQI_MAX];
 	short equip_switch_index[EQI_MAX];
-	unsigned int weight,max_weight,add_max_weight;
+	uint32 weight,max_weight,add_max_weight;
 	int cart_weight,cart_num,cart_weight_max;
 	int fd;
 	unsigned short mapindex;
@@ -504,7 +504,7 @@ public:
 	struct script_state *st;
 	char npc_str[CHATBOX_SIZE]; // for passing npc input box text to script engine
 	int npc_timer_id; //For player attached npc timers. [Skotlex]
-	unsigned int chatID;
+	uint32 chatID;
 	time_t idletime;
 	time_t idletime_hom;
 	time_t idletime_mer;
@@ -657,7 +657,7 @@ public:
 		int itemhealrate2; // [Epoque] Increase heal rate of all healing items.
 		int itemsphealrate2;
 		int shieldmdef;//royal guard's
-		unsigned int setitem_hash, setitem_hash2; //Split in 2 because shift operations only work on int ranges. [Skotlex]
+		uint32 setitem_hash, setitem_hash2; //Split in 2 because shift operations only work on int ranges. [Skotlex]
 
 		short splash_range, splash_add_range;
 		short add_steal_rate;
@@ -708,7 +708,7 @@ public:
 
 	struct{
 		uint32 id;
-		unsigned int lv;
+		uint32 lv;
 	}trade_partner;
 
 	struct s_deal {
@@ -740,7 +740,7 @@ public:
 	char message[MESSAGE_SIZE];
 	struct s_vending vending[MAX_VENDING];
 
-	unsigned int buyer_id;  // uid of open buying store
+	uint32 buyer_id;  // uid of open buying store
 	struct s_buyingstore buyingstore;
 
 	struct s_search_store_info searchstore;
@@ -906,7 +906,7 @@ public:
 	int bank_vault; ///< Bank Vault
 
 #ifdef PACKET_OBFUSCATION
-	unsigned int cryptKey; ///< Packet obfuscation key to be used for the next received packet
+	uint32 cryptKey; ///< Packet obfuscation key to be used for the next received packet
 #endif
 
 	struct {
@@ -1226,7 +1226,7 @@ enum e_mado_type : uint16 {
 	( (class_) >= JOB_SKY_EMPEROR			&& (class_) <= JOB_SPIRIT_HANDLER ) || \
 	  (class_) == JOB_SKY_EMPEROR2 \
 )
-#define pcdb_checkid(class_) pcdb_checkid_sub((unsigned int)class_)
+#define pcdb_checkid(class_) pcdb_checkid_sub((uint32)class_)
 
 // clientside display macros (values to the left/right of the "+")
 #ifdef RENEWAL
@@ -1462,7 +1462,7 @@ bool pc_adoption(map_session_data *p1_sd, map_session_data *p2_sd, map_session_d
 
 void pc_updateweightstatus(map_session_data *sd);
 
-bool pc_addautobonus(std::vector<std::shared_ptr<s_autobonus>> &bonus, const char *script, short rate, unsigned int dur, uint16 atk_type, const char *o_script, unsigned int pos, bool onskill);
+bool pc_addautobonus(std::vector<std::shared_ptr<s_autobonus>> &bonus, const char *script, short rate, uint32 dur, uint16 atk_type, const char *o_script, uint32 pos, bool onskill);
 void pc_exeautobonus(map_session_data &sd, std::vector<std::shared_ptr<s_autobonus>> *bonus, std::shared_ptr<s_autobonus> autobonus);
 TIMER_FUNC(pc_endautobonus);
 void pc_delautobonus(map_session_data &sd, std::vector<std::shared_ptr<s_autobonus>> &bonus, bool restore);
@@ -1497,8 +1497,8 @@ int pc_modifysellvalue(map_session_data*,int);
 int pc_follow(map_session_data*, int); // [MouseJstr]
 int pc_stop_following(map_session_data*);
 
-unsigned int pc_maxbaselv(map_session_data *sd);
-unsigned int pc_maxjoblv(map_session_data *sd);
+uint32 pc_maxbaselv(map_session_data *sd);
+uint32 pc_maxjoblv(map_session_data *sd);
 bool pc_is_maxbaselv(map_session_data *sd);
 bool pc_is_maxjoblv(map_session_data *sd);
 int pc_checkbaselevelup(map_session_data *sd);
@@ -1538,11 +1538,11 @@ int pc_sub_skillatk_bonus(map_session_data *sd, uint16 skill_id);
 int pc_skillheal_bonus(map_session_data *sd, uint16 skill_id);
 int pc_skillheal2_bonus(map_session_data *sd, uint16 skill_id);
 
-void pc_damage(map_session_data *sd,struct block_list *src,unsigned int hp, unsigned int sp, unsigned int ap);
+void pc_damage(map_session_data *sd,struct block_list *src,uint32 hp, uint32 sp, uint32 ap);
 int pc_dead(map_session_data *sd,struct block_list *src);
-void pc_revive(map_session_data *sd,unsigned int hp, unsigned int sp, unsigned int ap = 0);
+void pc_revive(map_session_data *sd,uint32 hp, uint32 sp, uint32 ap = 0);
 bool pc_revive_item(map_session_data *sd);
-void pc_heal(map_session_data *sd,unsigned int hp,unsigned int sp, unsigned int ap, int type);
+void pc_heal(map_session_data *sd,uint32 hp,uint32 sp, uint32 ap, int type);
 int pc_itemheal(map_session_data *sd, t_itemid itemid, int hp,int sp);
 int pc_percentheal(map_session_data *sd,int,int);
 bool pc_jobchange(map_session_data *sd, int job, char upper);
@@ -1683,7 +1683,7 @@ TIMER_FUNC(map_night_timer); // by [yor]
 // Rental System
 void pc_inventory_rentals(map_session_data *sd);
 void pc_inventory_rental_clear(map_session_data *sd);
-void pc_inventory_rental_add(map_session_data *sd, unsigned int seconds);
+void pc_inventory_rental_add(map_session_data *sd, uint32 seconds);
 
 int pc_read_motd(void); // [Valaris]
 int pc_disguise(map_session_data *sd, int class_);

+ 1 - 1
src/map/pet.cpp

@@ -2091,7 +2091,7 @@ TIMER_FUNC(pet_recovery_timer){
 TIMER_FUNC(pet_heal_timer){
 	map_session_data *sd = map_id2sd(id);
 	struct pet_data *pd;
-	unsigned int rate = 100;
+	uint32 rate = 100;
 
 	if(sd == nullptr || sd->pd == nullptr || sd->pd->s_skill == nullptr)
 		return 1;

+ 2 - 2
src/map/quest.cpp

@@ -909,7 +909,7 @@ int quest_check(map_session_data *sd, int quest_id, e_quest_check_type type)
 				return 1;
 			return sd->quest_log[i].state;
 		case PLAYTIME:
-			return (sd->quest_log[i].time < (unsigned int)time(nullptr) ? 2 : sd->quest_log[i].state == Q_COMPLETE ? 1 : 0);
+			return (sd->quest_log[i].time < (uint32)time(nullptr) ? 2 : sd->quest_log[i].state == Q_COMPLETE ? 1 : 0);
 		case HUNTING:
 			if (sd->quest_log[i].state == Q_INACTIVE || sd->quest_log[i].state == Q_ACTIVE) {
 				int j;
@@ -918,7 +918,7 @@ int quest_check(map_session_data *sd, int quest_id, e_quest_check_type type)
 				ARR_FIND(0, qi->objectives.size(), j, sd->quest_log[i].count[j] < qi->objectives[j]->count);
 				if (j == qi->objectives.size())
 					return 2;
-				if (sd->quest_log[i].time < (unsigned int)time(nullptr))
+				if (sd->quest_log[i].time < (uint32)time(nullptr))
 					return 1;
 			}
 			return 0;

+ 98 - 99
src/map/script.cpp

@@ -70,8 +70,8 @@ const int64 SCRIPT_INT_MAX = INT64_MAX;
 
 struct eri *array_ers;
 DBMap *st_db;
-unsigned int active_scripts;
-unsigned int next_id;
+uint32 active_scripts;
+uint32 next_id;
 struct eri *st_ers;
 struct eri *stack_ers;
 
@@ -358,13 +358,13 @@ const char* parse_syntax(const char* p);
 static int parse_syntax_for_flag = 0;
 
 extern short current_equip_item_index; //for New CARDS Scripts. It contains Inventory Index of the EQUIP_SCRIPT caller item. [Lupus]
-extern unsigned int current_equip_combo_pos;
+extern uint32 current_equip_combo_pos;
 
 int potion_flag=0; //For use on Alchemist improved potions/Potion Pitcher. [Skotlex]
 int potion_hp=0, potion_per_hp=0, potion_sp=0, potion_per_sp=0;
 int potion_target = 0;
-unsigned int *generic_ui_array = nullptr;
-unsigned int generic_ui_array_size = 0;
+uint32 *generic_ui_array = nullptr;
+uint32 generic_ui_array_size = 0;
 
 
 c_op get_com(unsigned char *script,int *pos);
@@ -624,9 +624,9 @@ static void check_event(struct script_state *st, const char *evt)
 /*==========================================
  * Hashes the input string
  *------------------------------------------*/
-static unsigned int calc_hash(const char* p)
+static uint32 calc_hash(const char* p)
 {
-	unsigned int h;
+	uint32 h;
 
 #if defined(SCRIPT_HASH_DJB2)
 	h = 5381;
@@ -639,7 +639,7 @@ static unsigned int calc_hash(const char* p)
 #elif defined(SCRIPT_HASH_ELF) // UNIX ELF hash
 	h = 0;
 	while( *p ){
-		unsigned int g;
+		uint32 g;
 		h = ( h << 4 ) + ((unsigned char)TOLOWER(*p++));
 		g = h & 0xF0000000;
 		if( g )
@@ -2913,7 +2913,7 @@ void script_array_ensure_zero(struct script_state *st, map_session_data *sd, int
 	if (src && src->arrays) {
 		struct script_array *sa = static_cast<script_array *>(idb_get(src->arrays, script_getvarid(uid)));
 		if (sa) {
-			unsigned int i;
+			uint32 i;
 
 			ARR_FIND(0, sa->size, i, sa->members[i] == 0);
 			if( i != sa->size ) {
@@ -2932,7 +2932,7 @@ void script_array_ensure_zero(struct script_state *st, map_session_data *sd, int
 /**
  * Returns array size by ID
  **/
-unsigned int script_array_size(struct script_state *st, map_session_data *sd, const char *name, struct reg_db *ref)
+uint32 script_array_size(struct script_state *st, map_session_data *sd, const char *name, struct reg_db *ref)
 {
 	struct script_array *sa = nullptr;
 	struct reg_db *src = script_array_src(st, sd, name, ref);
@@ -2946,7 +2946,7 @@ unsigned int script_array_size(struct script_state *st, map_session_data *sd, co
 /**
  * Returns array's highest key (for that awful getarraysize implementation that doesn't really gets the array size)
  **/
-unsigned int script_array_highest_key(struct script_state *st, map_session_data *sd, const char *name, struct reg_db *ref)
+uint32 script_array_highest_key(struct script_state *st, map_session_data *sd, const char *name, struct reg_db *ref)
 {
 	struct script_array *sa = nullptr;
 	struct reg_db *src = script_array_src(st, sd, name, ref);
@@ -2957,7 +2957,7 @@ unsigned int script_array_highest_key(struct script_state *st, map_session_data
 		script_array_ensure_zero(st,sd,reference_uid(key, 0), ref);
 
 		if( ( sa = static_cast<script_array *>(idb_get(src->arrays, key)) ) ) {
-			unsigned int i, highest_key = 0;
+			uint32 i, highest_key = 0;
 
 			for(i = 0; i < sa->size; i++) {
 				if( sa->members[i] > highest_key )
@@ -2994,9 +2994,9 @@ void script_array_delete(struct reg_db *src, struct script_array *sa)
  *
  * @param idx the index of the member in script_array struct list, not of the actual array member
  **/
-void script_array_remove_member(struct reg_db *src, struct script_array *sa, unsigned int idx)
+void script_array_remove_member(struct reg_db *src, struct script_array *sa, uint32 idx)
 {
-	unsigned int i, cursor;
+	uint32 i, cursor;
 
 	// it's the only member left, no need to do anything other than delete the array data
 	if( sa->size == 1 ) {
@@ -3022,9 +3022,9 @@ void script_array_remove_member(struct reg_db *src, struct script_array *sa, uns
  *
  * @param idx the index of the array member being inserted
  **/
-void script_array_add_member(struct script_array *sa, unsigned int idx)
+void script_array_add_member(struct script_array *sa, uint32 idx)
 {
-	RECREATE(sa->members, unsigned int, ++sa->size);
+	RECREATE(sa->members, uint32, ++sa->size);
 
 	sa->members[sa->size - 1] = idx;
 }
@@ -3087,7 +3087,7 @@ void script_array_update(struct reg_db *src, int64 num, bool empty)
 {
 	struct script_array *sa = nullptr;
 	int id = script_getvarid(num);
-	unsigned int index = script_getvaridx(num);
+	uint32 index = script_getvaridx(num);
 
 	if (!src->arrays) {
 		src->arrays = idb_alloc(DB_OPT_BASE);
@@ -3096,7 +3096,7 @@ void script_array_update(struct reg_db *src, int64 num, bool empty)
 	}
 
 	if( sa ) {
-		unsigned int i;
+		uint32 i;
 
 		// search
 		for(i = 0; i < sa->size; i++) {
@@ -4584,7 +4584,7 @@ static int db_script_free_code_sub(DBKey key, DBData *data, va_list ap)
 	return 0;
 }
 
-void script_run_autobonus(const char *autobonus, map_session_data *sd, unsigned int pos)
+void script_run_autobonus(const char *autobonus, map_session_data *sd, uint32 pos)
 {
 	struct script_code *script = (struct script_code *)strdb_get(autobonus_db, autobonus);
 
@@ -4642,7 +4642,7 @@ void script_add_petautobonus(const std::string &autobonus) {
 void script_cleararray_pc( map_session_data* sd, const char* varname ){
 	struct script_array *sa = nullptr;
 	struct reg_db *src = nullptr;
-	unsigned int i, *list = nullptr, size = 0;
+	uint32 i, *list = nullptr, size = 0;
 	int key;
 
 	key = add_str(varname);
@@ -4728,18 +4728,18 @@ void script_reg_destroy_single(map_session_data *sd, int64 reg, struct script_re
 	}
 }
 
-unsigned int *script_array_cpy_list(struct script_array *sa)
+uint32 *script_array_cpy_list(struct script_array *sa)
 {
 	if( sa->size > generic_ui_array_size )
 		script_generic_ui_array_expand(sa->size);
-	memcpy(generic_ui_array, sa->members, sizeof(unsigned int)*sa->size);
+	memcpy(generic_ui_array, sa->members, sizeof(uint32)*sa->size);
 	return generic_ui_array;
 }
 
-void script_generic_ui_array_expand (unsigned int plus)
+void script_generic_ui_array_expand (uint32 plus)
 {
 	generic_ui_array_size += plus + 100;
-	RECREATE(generic_ui_array, unsigned int, generic_ui_array_size);
+	RECREATE(generic_ui_array, uint32, generic_ui_array_size);
 }
 
 /*==========================================
@@ -4767,7 +4767,7 @@ void do_final_script() {
 			fprintf(fp,"num : hash : data_name\n");
 			fprintf(fp,"---------------------------------------------------------------\n");
 			for(i=LABEL_START; i<str_num; i++) {
-				unsigned int h = calc_hash(get_str(i));
+				uint32 h = calc_hash(get_str(i));
 				fprintf(fp,"%04d : %4u : %s\n",i,h, get_str(i));
 				++count[h];
 			}
@@ -5653,9 +5653,8 @@ BUILDIN_FUNC(warp)
 static int buildin_areawarp_sub(struct block_list *bl,va_list ap)
 {
 	int x2,y2,x3,y3;
-	unsigned int index;
 
-	index = va_arg(ap,unsigned int);
+	uint32 index = va_arg(ap,uint32);
 	x2 = va_arg(ap,int);
 	y2 = va_arg(ap,int);
 	x3 = va_arg(ap,int);
@@ -5690,7 +5689,7 @@ static int buildin_areawarp_sub(struct block_list *bl,va_list ap)
 BUILDIN_FUNC(areawarp)
 {
 	int16 m, x0,y0,x1,y1, x2,y2,x3=0,y3=0;
-	unsigned int index;
+	uint32 index;
 	const char *str;
 	const char *mapname;
 
@@ -6503,7 +6502,7 @@ BUILDIN_FUNC(getarraysize)
 }
 
 int script_array_index_cmp(const void *a, const void *b) {
-	return ( *(unsigned int*)a - *(unsigned int*)b );
+	return ( *(uint32*)a - *(uint32*)b );
 }
 
 /// Deletes count or all the elements in an array, from the starting index.
@@ -6515,7 +6514,7 @@ BUILDIN_FUNC(deletearray)
 {
 	struct script_data* data;
 	const char* name;
-	unsigned int start, end, i;
+	uint32 start, end, i;
 	int id;
 	TBL_PC *sd = nullptr;
 	struct script_array *sa = nullptr;
@@ -6557,7 +6556,7 @@ BUILDIN_FUNC(deletearray)
 		return SCRIPT_CMD_SUCCESS;// nothing to free
 
 	if( script_hasdata(st,3) ) {
-		unsigned int count = script_getnum(st, 3);
+		uint32 count = script_getnum(st, 3);
 		if( count > end - start )
 			count = end - start;
 		if( count <= 0 )
@@ -6585,10 +6584,10 @@ BUILDIN_FUNC(deletearray)
 			}
 		} else {
 			// using sa to speed up
-			unsigned int *list = nullptr, size = 0;
+			uint32 *list = nullptr, size = 0;
 			list = script_array_cpy_list(sa);
 			size = sa->size;
-			qsort(list, size, sizeof(unsigned int), script_array_index_cmp);
+			qsort(list, size, sizeof(uint32), script_array_index_cmp);
 			
 			ARR_FIND(0, size, i, list[i] >= start);
 			
@@ -6614,7 +6613,7 @@ BUILDIN_FUNC(deletearray)
 			}
 		}
 	} else {
-		unsigned int *list = nullptr, size = 0;
+		uint32 *list = nullptr, size = 0;
 		list = script_array_cpy_list(sa);
 		size = sa->size;
 		
@@ -7426,7 +7425,7 @@ BUILDIN_FUNC(checkweight)
 {
 	int slots = 0;
 	unsigned short amount2 = 0;
-	unsigned int weight = 0, i, nbargs;
+	uint32 weight = 0, i, nbargs;
 	std::shared_ptr<item_data> id;
 	map_session_data* sd;
 
@@ -7898,7 +7897,7 @@ BUILDIN_FUNC(rentitem) {
 
 	it.nameid = nameid;
 	it.identify = 1;
-	it.expire_time = (unsigned int)(time(nullptr) + seconds);
+	it.expire_time = (uint32)(time(nullptr) + seconds);
 	it.bound = BOUND_NONE;
 
 	if( (flag = pc_additem(sd, &it, 1, LOG_TYPE_SCRIPT)) )
@@ -7990,7 +7989,7 @@ BUILDIN_FUNC(rentitem2) {
 	it.card[1] = c2;
 	it.card[2] = c3;
 	it.card[3] = c4;
-	it.expire_time = (unsigned int)(time(nullptr) + seconds);
+	it.expire_time = (uint32)(time(nullptr) + seconds);
 	it.bound = BOUND_NONE;
 
 	if (funcname[strlen(funcname)-1] == '3') {
@@ -9620,7 +9619,7 @@ BUILDIN_FUNC(successrefitem) {
 	if (equip_index_check(pos))
 		i = pc_checkequip(sd,equip_bitmask[pos]);
 	if (i >= 0) {
-		unsigned int ep = sd->inventory.u.items_inventory[i].equip;
+		uint32 ep = sd->inventory.u.items_inventory[i].equip;
 
 		//Logs items, got from (N)PC scripts [Lupus]
 		log_pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->inventory.u.items_inventory[i]);
@@ -9727,7 +9726,7 @@ BUILDIN_FUNC(downrefitem) {
 	if (equip_index_check(pos))
 		i = pc_checkequip(sd,equip_bitmask[pos]);
 	if (i >= 0) {
-		unsigned int ep = sd->inventory.u.items_inventory[i].equip;
+		uint32 ep = sd->inventory.u.items_inventory[i].equip;
 
 		//Logs items, got from (N)PC scripts [Lupus]
 		log_pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->inventory.u.items_inventory[i]);
@@ -10004,7 +10003,7 @@ BUILDIN_FUNC(bonus)
 
 BUILDIN_FUNC(autobonus)
 {
-	unsigned int dur, pos;
+	uint32 dur, pos;
 	short rate;
 	uint16 atk_type = 0;
 	TBL_PC* sd;
@@ -10041,7 +10040,7 @@ BUILDIN_FUNC(autobonus)
 
 BUILDIN_FUNC(autobonus2)
 {
-	unsigned int dur, pos;
+	uint32 dur, pos;
 	short rate;
 	uint16 atk_type = 0;
 	TBL_PC* sd;
@@ -10078,7 +10077,7 @@ BUILDIN_FUNC(autobonus2)
 
 BUILDIN_FUNC(autobonus3)
 {
-	unsigned int dur, pos;
+	uint32 dur, pos;
 	short rate;
 	uint16 skill_id = 0;
 	TBL_PC* sd;
@@ -11123,7 +11122,7 @@ BUILDIN_FUNC(monster)
 	int class_;
 	int amount			= script_getnum(st,7);
 	const char* event	= "";
-	unsigned int size	= SZ_SMALL;
+	uint32 size	= SZ_SMALL;
 	enum mob_ai ai		= AI_NONE;
 
 	map_session_data* sd;
@@ -11247,7 +11246,7 @@ BUILDIN_FUNC(areamonster)
 	int class_;
 	int amount			= script_getnum(st,9);
 	const char* event	= "";
-	unsigned int size	= SZ_SMALL;
+	uint32 size	= SZ_SMALL;
 	enum mob_ai ai		= AI_NONE;
 
 	map_session_data* sd;
@@ -11431,7 +11430,7 @@ BUILDIN_FUNC(clone)
 	int16 m;
 	enum e_mode mode = MD_NONE;
 
-	unsigned int duration = 0;
+	uint32 duration = 0;
 	const char *mapname,*event;
 
 	mapname=script_getstr(st,2);
@@ -14161,7 +14160,7 @@ BUILDIN_FUNC(mapwarp)	// Added by RoVeRT
 	struct party_data *p = nullptr;
 	const char *str;
 	const char *mapname;
-	unsigned int index;
+	uint32 index;
 	mapname=script_getstr(st,2);
 	str=script_getstr(st,3);
 	x=script_getnum(st,4);
@@ -16586,7 +16585,7 @@ BUILDIN_FUNC(isequipped)
 	int i, id = 1;
 	int ret = -1;
 	//Original hash to reverse it when full check fails.
-	unsigned int setitem_hash = 0, setitem_hash2 = 0;
+	uint32 setitem_hash = 0, setitem_hash2 = 0;
 
 	if (!script_rid2sd(sd)) { //If the player is not attached it is a script error anyway... but better prevent the map server from crashing...
 		script_pushint(st,0);
@@ -16623,7 +16622,7 @@ BUILDIN_FUNC(isequipped)
 
 				for (k = 0; k < MAX_SLOTS; k++)
 				{	//New hash system which should support up to 4 slots on any equipment. [Skotlex]
-					unsigned int hash = 0;
+					uint32 hash = 0;
 					if (sd->inventory.u.items_inventory[index].card[k] != id)
 						continue;
 
@@ -16885,7 +16884,7 @@ BUILDIN_FUNC(charisalpha)
 	const char *str=script_getstr(st,2);
 	int pos=script_getnum(st,3);
 
-	int val = ( str && pos >= 0 && (unsigned int)pos < strlen(str) ) ? ISALPHA( str[pos] ) != 0 : 0;
+	int val = ( str && pos >= 0 && (uint32)pos < strlen(str) ) ? ISALPHA( str[pos] ) != 0 : 0;
 
 	script_pushint(st,val);
 	return SCRIPT_CMD_SUCCESS;
@@ -16899,7 +16898,7 @@ BUILDIN_FUNC(charisupper)
 	const char *str = script_getstr(st,2);
 	int pos = script_getnum(st,3);
 
-	int val = ( str && pos >= 0 && (unsigned int)pos < strlen(str) ) ? ISUPPER( str[pos] ) : 0;
+	int val = ( str && pos >= 0 && (uint32)pos < strlen(str) ) ? ISUPPER( str[pos] ) : 0;
 
 	script_pushint(st,val);
 	return SCRIPT_CMD_SUCCESS;
@@ -16913,7 +16912,7 @@ BUILDIN_FUNC(charislower)
 	const char *str = script_getstr(st,2);
 	int pos = script_getnum(st,3);
 
-	int val = ( str && pos >= 0 && (unsigned int)pos < strlen(str) ) ? ISLOWER( str[pos] ) : 0;
+	int val = ( str && pos >= 0 && (uint32)pos < strlen(str) ) ? ISLOWER( str[pos] ) : 0;
 
 	script_pushint(st,val);
 	return SCRIPT_CMD_SUCCESS;
@@ -16926,7 +16925,7 @@ BUILDIN_FUNC(charat) {
 	const char *str = script_getstr(st,2);
 	int pos = script_getnum(st,3);
 
-	if( pos >= 0 && (unsigned int)pos < strlen(str) ) {
+	if( pos >= 0 && (uint32)pos < strlen(str) ) {
 		char output[2];
 		output[0] = str[pos];
 		output[1] = '\0';
@@ -17220,7 +17219,7 @@ BUILDIN_FUNC(implode)
 //-------------------------------------------------------
 BUILDIN_FUNC(sprintf)
 {
-	unsigned int argc = 0, arg = 0;
+	uint32 argc = 0, arg = 0;
 	size_t buf2_len = 0;
 	const char* format;
 	char* p;
@@ -17362,7 +17361,7 @@ BUILDIN_FUNC(sprintf)
 // Implements C sscanf.
 //-------------------------------------------------------
 BUILDIN_FUNC(sscanf){
-	unsigned int argc, arg = 0;
+	uint32 argc, arg = 0;
 	struct script_data* data;
 	map_session_data* sd = nullptr;
 	const char* str;
@@ -17838,7 +17837,7 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle)
 	const char* query;
 	struct script_data* data;
 	const char* name;
-	unsigned int max_rows = SCRIPT_MAX_ARRAYSIZE; // maximum number of rows
+	uint32 max_rows = SCRIPT_MAX_ARRAYSIZE; // maximum number of rows
 	int num_vars;
 	int num_cols;
 
@@ -17881,10 +17880,10 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle)
 	// Count the number of columns to store
 	num_cols = Sql_NumColumns(handle);
 	if( num_vars < num_cols ) {
-		ShowWarning("script:query_sql: Too many columns, discarding last %u columns.\n", (unsigned int)(num_cols-num_vars));
+		ShowWarning("script:query_sql: Too many columns, discarding last %u columns.\n", (uint32)(num_cols-num_vars));
 		script_reportsrc(st);
 	} else if( num_vars > num_cols ) {
-		ShowWarning("script:query_sql: Too many variables (%u extra).\n", (unsigned int)(num_vars-num_cols));
+		ShowWarning("script:query_sql: Too many variables (%u extra).\n", (uint32)(num_vars-num_cols));
 		script_reportsrc(st);
 	}
 
@@ -17906,7 +17905,7 @@ int buildin_query_sql_sub(struct script_state* st, Sql* handle)
 		}
 	}
 	if( i == max_rows && max_rows < Sql_NumRows(handle) ) {
-		ShowWarning("script:query_sql: Only %d/%u rows have been stored.\n", max_rows, (unsigned int)Sql_NumRows(handle));
+		ShowWarning("script:query_sql: Only %d/%u rows have been stored.\n", max_rows, (uint32)Sql_NumRows(handle));
 		script_reportsrc(st);
 	}
 
@@ -19214,8 +19213,8 @@ BUILDIN_FUNC(setunitdata)
 		switch (type) {
 			case UMOB_SIZE: md->status.size = md->base_status->size = (unsigned char)value; break;
 			case UMOB_LEVEL: md->level = (unsigned short)value; clif_name_area(&md->bl); break;
-			case UMOB_HP: md->base_status->hp = (unsigned int)value; status_set_hp(bl, (unsigned int)value, 0); clif_name_area(&md->bl); break;
-			case UMOB_MAXHP: md->base_status->hp = md->base_status->max_hp = (unsigned int)value; status_set_maxhp(bl, (unsigned int)value, 0); clif_name_area(&md->bl); break;
+			case UMOB_HP: md->base_status->hp = (uint32)value; status_set_hp(bl, (uint32)value, 0); clif_name_area(&md->bl); break;
+			case UMOB_MAXHP: md->base_status->hp = md->base_status->max_hp = (uint32)value; status_set_maxhp(bl, (uint32)value, 0); clif_name_area(&md->bl); break;
 			case UMOB_MASTERAID: md->master_id = value; break;
 			case UMOB_MAPID: if (mapname) value = map_mapname2mapid(mapname); unit_warp(bl, (short)value, 0, 0, CLR_TELEPORT); break;
 			case UMOB_X: if (!unit_walktoxy(bl, (short)value, md->bl.y, 2)) unit_movepos(bl, (short)value, md->bl.y, 0, 0); break;
@@ -19240,7 +19239,7 @@ BUILDIN_FUNC(setunitdata)
 			case UMOB_SHIELD: clif_changelook(bl, LOOK_SHIELD, (unsigned short)value); break;
 			case UMOB_WEAPON: clif_changelook(bl, LOOK_WEAPON, (unsigned short)value); break;
 			case UMOB_LOOKDIR: unit_setdir(bl, (uint8)value); break;
-			case UMOB_CANMOVETICK: md->ud.canmove_tick = value > 0 ? (unsigned int)value : 0; break;
+			case UMOB_CANMOVETICK: md->ud.canmove_tick = value > 0 ? (uint32)value : 0; break;
 			case UMOB_STR: md->base_status->str = (unsigned short)value; status_calc_misc(bl, &md->status, md->level); calc_status = true; break;
 			case UMOB_AGI: md->base_status->agi = (unsigned short)value; status_calc_misc(bl, &md->status, md->level); calc_status = true; break;
 			case UMOB_VIT: md->base_status->vit = (unsigned short)value; status_calc_misc(bl, &md->status, md->level); calc_status = true; break;
@@ -19312,19 +19311,19 @@ BUILDIN_FUNC(setunitdata)
 		switch (type) {
 			case UHOM_SIZE: hd->battle_status.size = hd->base_status.size = (unsigned char)value; break;
 			case UHOM_LEVEL: hd->homunculus.level = (unsigned short)value; break;
-			case UHOM_HP: hd->base_status.hp = (unsigned int)value; status_set_hp(bl, (unsigned int)value, 0); break;
-			case UHOM_MAXHP: hd->base_status.hp = hd->base_status.max_hp = (unsigned int)value; status_set_maxhp(bl, (unsigned int)value, 0); break;
-			case UHOM_SP: hd->base_status.sp = (unsigned int)value; status_set_sp(bl, (unsigned int)value, 0); break;
-			case UHOM_MAXSP: hd->base_status.sp = hd->base_status.max_sp = (unsigned int)value; status_set_maxsp(bl, (unsigned int)value, 0); break;
+			case UHOM_HP: hd->base_status.hp = (uint32)value; status_set_hp(bl, (uint32)value, 0); break;
+			case UHOM_MAXHP: hd->base_status.hp = hd->base_status.max_hp = (uint32)value; status_set_maxhp(bl, (uint32)value, 0); break;
+			case UHOM_SP: hd->base_status.sp = (uint32)value; status_set_sp(bl, (uint32)value, 0); break;
+			case UHOM_MAXSP: hd->base_status.sp = hd->base_status.max_sp = (uint32)value; status_set_maxsp(bl, (uint32)value, 0); break;
 			case UHOM_MASTERCID: hd->homunculus.char_id = (uint32)value; break;
 			case UHOM_MAPID: if (mapname) value = map_mapname2mapid(mapname); unit_warp(bl, (short)value, 0, 0, CLR_TELEPORT); break;
 			case UHOM_X: if (!unit_walktoxy(bl, (short)value, hd->bl.y, 2)) unit_movepos(bl, (short)value, hd->bl.y, 0, 0); break;
 			case UHOM_Y: if (!unit_walktoxy(bl, hd->bl.x, (short)value, 2)) unit_movepos(bl, hd->bl.x, (short)value, 0, 0); break;
 			case UHOM_HUNGER: hd->homunculus.hunger = (short)value; clif_send_homdata(*hd, SP_HUNGRY); break;
-			case UHOM_INTIMACY: hom_increase_intimacy(hd, (unsigned int)value); clif_send_homdata(*hd, SP_INTIMATE); break;
+			case UHOM_INTIMACY: hom_increase_intimacy(hd, (uint32)value); clif_send_homdata(*hd, SP_INTIMATE); break;
 			case UHOM_SPEED: hd->base_status.speed = (unsigned short)value; status_calc_misc(bl, &hd->base_status, hd->homunculus.level); calc_status = true; break;
 			case UHOM_LOOKDIR: unit_setdir(bl, (uint8)value); break;
-			case UHOM_CANMOVETICK: hd->ud.canmove_tick = value > 0 ? (unsigned int)value : 0; break;
+			case UHOM_CANMOVETICK: hd->ud.canmove_tick = value > 0 ? (uint32)value : 0; break;
 			case UHOM_STR: hd->base_status.str = (unsigned short)value; status_calc_misc(bl, &hd->base_status, hd->homunculus.level); calc_status = true; break;
 			case UHOM_AGI: hd->base_status.agi = (unsigned short)value; status_calc_misc(bl, &hd->base_status, hd->homunculus.level); calc_status = true; break;
 			case UHOM_VIT: hd->base_status.vit = (unsigned short)value; status_calc_misc(bl, &hd->base_status, hd->homunculus.level); calc_status = true; break;
@@ -19380,17 +19379,17 @@ BUILDIN_FUNC(setunitdata)
 		switch (type) {
 			case UPET_SIZE: pd->status.size = (unsigned char)value; break;
 			case UPET_LEVEL: pd->pet.level = (unsigned short)value; break;
-			case UPET_HP: pd->status.hp = pd->status.max_hp = (unsigned int)value; status_set_hp(bl, (unsigned int)value, 0); break;
-			case UPET_MAXHP: pd->status.hp = pd->status.max_hp = (unsigned int)value; status_set_maxhp(bl, (unsigned int)value, 0); break;
-			case UPET_MASTERAID: pd->pet.account_id = (unsigned int)value; break;
+			case UPET_HP: pd->status.hp = pd->status.max_hp = (uint32)value; status_set_hp(bl, (uint32)value, 0); break;
+			case UPET_MAXHP: pd->status.hp = pd->status.max_hp = (uint32)value; status_set_maxhp(bl, (uint32)value, 0); break;
+			case UPET_MASTERAID: pd->pet.account_id = (uint32)value; break;
 			case UPET_MAPID: if (mapname) value = map_mapname2mapid(mapname); unit_warp(bl, (short)value, 0, 0, CLR_TELEPORT); break;
 			case UPET_X: if (!unit_walktoxy(bl, (short)value, pd->bl.y, 2)) unit_movepos(bl, (short)value, pd->bl.y, 0, 0); break;
 			case UPET_Y: if (!unit_walktoxy(bl, pd->bl.x, (short)value, 2)) unit_movepos(bl, pd->bl.x, (short)value, 0, 0); break;
 			case UPET_HUNGER: pd->pet.hungry = cap_value((short)value, 0, 100); clif_send_petdata(map_id2sd(pd->pet.account_id), pd, 2, pd->pet.hungry); break;
-			case UPET_INTIMACY: pet_set_intimate(pd, (unsigned int)value); clif_send_petdata(map_id2sd(pd->pet.account_id), pd, 1, pd->pet.intimate); break;
+			case UPET_INTIMACY: pet_set_intimate(pd, (uint32)value); clif_send_petdata(map_id2sd(pd->pet.account_id), pd, 1, pd->pet.intimate); break;
 			case UPET_SPEED: pd->status.speed = (unsigned short)value; status_calc_misc(bl, &pd->status, pd->pet.level); break;
 			case UPET_LOOKDIR: unit_setdir(bl, (uint8)value); break;
-			case UPET_CANMOVETICK: pd->ud.canmove_tick = value > 0 ? (unsigned int)value : 0; break;
+			case UPET_CANMOVETICK: pd->ud.canmove_tick = value > 0 ? (uint32)value : 0; break;
 			case UPET_STR: pd->status.str = (unsigned short)value; status_calc_misc(bl, &pd->status, pd->pet.level); break;
 			case UPET_AGI: pd->status.agi = (unsigned short)value; status_calc_misc(bl, &pd->status, pd->pet.level); break;
 			case UPET_VIT: pd->status.vit = (unsigned short)value; status_calc_misc(bl, &pd->status, pd->pet.level); break;
@@ -19430,17 +19429,17 @@ BUILDIN_FUNC(setunitdata)
 
 		switch (type) {
 			case UMER_SIZE: mc->battle_status.size = mc->base_status.size = (unsigned char)value; break;
-			case UMER_HP: mc->base_status.hp = (unsigned int)value; status_set_hp(bl, (unsigned int)value, 0); break;
-			case UMER_MAXHP: mc->base_status.hp = mc->base_status.max_hp = (unsigned int)value; status_set_maxhp(bl, (unsigned int)value, 0); break;
+			case UMER_HP: mc->base_status.hp = (uint32)value; status_set_hp(bl, (uint32)value, 0); break;
+			case UMER_MAXHP: mc->base_status.hp = mc->base_status.max_hp = (uint32)value; status_set_maxhp(bl, (uint32)value, 0); break;
 			case UMER_MASTERCID: mc->mercenary.char_id = (uint32)value; break;
 			case UMER_MAPID: if (mapname) value = map_mapname2mapid(mapname); unit_warp(bl, (short)value, 0, 0, CLR_TELEPORT); break;
 			case UMER_X: if (!unit_walktoxy(bl, (short)value, mc->bl.y, 2)) unit_movepos(bl, (short)value, mc->bl.y, 0, 0); break;
 			case UMER_Y: if (!unit_walktoxy(bl, mc->bl.x, (short)value, 2)) unit_movepos(bl, mc->bl.x, (short)value, 0, 0); break;
-			case UMER_KILLCOUNT: mc->mercenary.kill_count = (unsigned int)value; break;
-			case UMER_LIFETIME: mc->mercenary.life_time = (unsigned int)value; break;
+			case UMER_KILLCOUNT: mc->mercenary.kill_count = (uint32)value; break;
+			case UMER_LIFETIME: mc->mercenary.life_time = (uint32)value; break;
 			case UMER_SPEED: mc->base_status.speed = (unsigned short)value; status_calc_misc(bl, &mc->base_status, mc->db->lv); calc_status = true; break;
 			case UMER_LOOKDIR: unit_setdir(bl, (uint8)value); break;
-			case UMER_CANMOVETICK: mc->ud.canmove_tick = value > 0 ? (unsigned int)value : 0; break;
+			case UMER_CANMOVETICK: mc->ud.canmove_tick = value > 0 ? (uint32)value : 0; break;
 			case UMER_STR: mc->base_status.str = (unsigned short)value; status_calc_misc(bl, &mc->base_status, mc->db->lv); calc_status = true; break;
 			case UMER_AGI: mc->base_status.agi = (unsigned short)value; status_calc_misc(bl, &mc->base_status, mc->db->lv); calc_status = true; break;
 			case UMER_VIT: mc->base_status.vit = (unsigned short)value; status_calc_misc(bl, &mc->base_status, mc->db->lv); calc_status = true; break;
@@ -19498,19 +19497,19 @@ BUILDIN_FUNC(setunitdata)
 
 		switch (type) {
 			case UELE_SIZE: ed->battle_status.size = ed->base_status.size = (unsigned char)value; break;
-			case UELE_HP: ed->base_status.hp = (unsigned int)value; status_set_hp(bl, (unsigned int)value, 0); break;
-			case UELE_MAXHP: ed->base_status.hp = ed->base_status.max_hp = (unsigned int)value; status_set_maxhp(bl, (unsigned int)value, 0); break;
-			case UELE_SP: ed->base_status.sp = (unsigned int)value; status_set_sp(bl, (unsigned int)value, 0); break;
-			case UELE_MAXSP: ed->base_status.sp = ed->base_status.max_sp = (unsigned int)value; status_set_maxsp(bl, (unsigned int)value, 0); break;
+			case UELE_HP: ed->base_status.hp = (uint32)value; status_set_hp(bl, (uint32)value, 0); break;
+			case UELE_MAXHP: ed->base_status.hp = ed->base_status.max_hp = (uint32)value; status_set_maxhp(bl, (uint32)value, 0); break;
+			case UELE_SP: ed->base_status.sp = (uint32)value; status_set_sp(bl, (uint32)value, 0); break;
+			case UELE_MAXSP: ed->base_status.sp = ed->base_status.max_sp = (uint32)value; status_set_maxsp(bl, (uint32)value, 0); break;
 			case UELE_MASTERCID: ed->elemental.char_id = (uint32)value; break;
 			case UELE_MAPID: if (mapname) value = map_mapname2mapid(mapname); unit_warp(bl, (short)value, 0, 0, CLR_TELEPORT); break;
 			case UELE_X: if (!unit_walktoxy(bl, (short)value, ed->bl.y, 2)) unit_movepos(bl, (short)value, ed->bl.y, 0, 0); break;
 			case UELE_Y: if (!unit_walktoxy(bl, ed->bl.x, (short)value, 2)) unit_movepos(bl, ed->bl.x, (short)value, 0, 0); break;
-			case UELE_LIFETIME: ed->elemental.life_time = (unsigned int)value; break;
+			case UELE_LIFETIME: ed->elemental.life_time = (uint32)value; break;
 			case UELE_MODE: ed->elemental.mode = (enum e_mode)value; calc_status = true; break;
 			case UELE_SPEED: ed->base_status.speed = (unsigned short)value; status_calc_misc(bl, &ed->base_status, ed->db->lv); calc_status = true; break;
 			case UELE_LOOKDIR: unit_setdir(bl, (uint8)value); break;
-			case UELE_CANMOVETICK: ed->ud.canmove_tick = value > 0 ? (unsigned int)value : 0; break;
+			case UELE_CANMOVETICK: ed->ud.canmove_tick = value > 0 ? (uint32)value : 0; break;
 			case UELE_STR: ed->base_status.str = (unsigned short)value; status_calc_misc(bl, &ed->base_status, ed->db->lv); calc_status = true; break;
 			case UELE_AGI: ed->base_status.agi = (unsigned short)value; status_calc_misc(bl, &ed->base_status, ed->db->lv); calc_status = true; break;
 			case UELE_VIT: ed->base_status.vit = (unsigned short)value; status_calc_misc(bl, &ed->base_status, ed->db->lv); calc_status = true; break;
@@ -19571,9 +19570,9 @@ BUILDIN_FUNC(setunitdata)
 		}
 
 		switch (type) {
-			case UNPC_LEVEL: nd->level = (unsigned int)value; break;
-			case UNPC_HP: nd->status.hp = (unsigned int)value; status_set_hp(bl, (unsigned int)value, 0); break;
-			case UNPC_MAXHP: nd->status.hp = nd->status.max_hp = (unsigned int)value; status_set_maxhp(bl, (unsigned int)value, 0); break;
+			case UNPC_LEVEL: nd->level = (uint32)value; break;
+			case UNPC_HP: nd->status.hp = (uint32)value; status_set_hp(bl, (uint32)value, 0); break;
+			case UNPC_MAXHP: nd->status.hp = nd->status.max_hp = (uint32)value; status_set_maxhp(bl, (uint32)value, 0); break;
 			case UNPC_MAPID: if (mapname) value = map_mapname2mapid(mapname); unit_warp(bl, (short)value, 0, 0, CLR_TELEPORT); break;
 			case UNPC_X: if (!unit_walktoxy(bl, (short)value, nd->bl.y, 2)) unit_movepos(bl, (short)value, nd->bl.x, 0, 0); break;
 			case UNPC_Y: if (!unit_walktoxy(bl, nd->bl.x, (short)value, 2)) unit_movepos(bl, nd->bl.x, (short)value, 0, 0); break;
@@ -19584,7 +19583,7 @@ BUILDIN_FUNC(setunitdata)
 			case UNPC_INT: nd->params.int_ = (unsigned short)value; status_calc_misc(bl, &nd->status, nd->level); break;
 			case UNPC_DEX: nd->params.dex = (unsigned short)value; status_calc_misc(bl, &nd->status, nd->level); break;
 			case UNPC_LUK: nd->params.luk = (unsigned short)value; status_calc_misc(bl, &nd->status, nd->level); break;
-			case UNPC_PLUSALLSTAT: nd->stat_point = (unsigned int)value; break;
+			case UNPC_PLUSALLSTAT: nd->stat_point = (uint32)value; break;
 			case UNPC_ATKRANGE: nd->status.rhw.range = (unsigned short)value; break;
 			case UNPC_ATKMIN: nd->status.rhw.atk = (unsigned short)value; break;
 			case UNPC_ATKMAX: nd->status.rhw.atk2 = (unsigned short)value; break;
@@ -21657,7 +21656,7 @@ BUILDIN_FUNC(instance_id)
  *------------------------------------------*/
 static int buildin_instance_warpall_sub(struct block_list *bl, va_list ap)
 {
-	unsigned int m = va_arg(ap,unsigned int);
+	uint32 m = va_arg(ap,uint32);
 	int x = va_arg(ap,int);
 	int y = va_arg(ap,int);
 	int instance_id = va_arg(ap, int);
@@ -22292,7 +22291,7 @@ BUILDIN_FUNC(progressbar)
 {
 	map_session_data * sd;
 	const char * color;
-	unsigned int second;
+	uint32 second;
 
 	if( !script_rid2sd(sd) )
 		return SCRIPT_CMD_SUCCESS;
@@ -22498,7 +22497,7 @@ BUILDIN_FUNC(searchstores)
 /// showdigit <value>[,<type>];
 BUILDIN_FUNC(showdigit)
 {
-	unsigned int type = 0;
+	uint32 type = 0;
 	int value;
 	map_session_data* sd;
 
@@ -22587,7 +22586,7 @@ BUILDIN_FUNC(setdragon) {
 		pc_setoption(sd, sd->sc.option&~OPTION_DRAGON);
 		script_pushint(st,1);
 	} else {//Not mounted; Mount now.
-		unsigned int option = OPTION_DRAGON1;
+		uint32 option = OPTION_DRAGON1;
 		if( color ) {
 			option = ( color == 1 ? OPTION_DRAGON1 :
 					   color == 2 ? OPTION_DRAGON2 :
@@ -23041,8 +23040,8 @@ BUILDIN_FUNC(npcskill)
 {
 	uint16 skill_id;
 	unsigned short skill_level;
-	unsigned int stat_point;
-	unsigned int npc_level;
+	uint32 stat_point;
+	uint32 npc_level;
 	struct npc_data *nd;
 	map_session_data *sd;
 
@@ -24317,7 +24316,7 @@ BUILDIN_FUNC(adopt)
 */
 BUILDIN_FUNC(minmax){
 	char *functionname;
-	unsigned int i;
+	uint32 i;
 	int64 value;
 	// Function pointer for our comparison function (either min or max at the moment)
 	int64 (*func)(int64, int64);
@@ -24360,7 +24359,7 @@ BUILDIN_FUNC(minmax){
 		}else if( data_isreference( data ) ){
 			const char *name;
 			map_session_data* sd;
-			unsigned int start, end;
+			uint32 start, end;
 
 			// Get the name of the variable
 			name = reference_getname(data);
@@ -25192,7 +25191,7 @@ BUILDIN_FUNC(channel_chat) {
 BUILDIN_FUNC(channel_ban) {
 	struct Channel *ch = nullptr;
 	const char *chname = script_getstr(st,2);
-	unsigned int char_id = script_getnum(st,3);
+	uint32 char_id = script_getnum(st,3);
 	TBL_PC *tsd;
 
 	if (!(ch = channel_name2channel((char *)chname, nullptr, 0))) {
@@ -25241,7 +25240,7 @@ BUILDIN_FUNC(channel_ban) {
 BUILDIN_FUNC(channel_unban) {
 	struct Channel *ch = nullptr;
 	const char *chname = script_getstr(st,2);
-	unsigned int char_id = script_getnum(st,3);
+	uint32 char_id = script_getnum(st,3);
 
 	if (!(ch = channel_name2channel((char *)chname, nullptr, 0))) {
 		ShowError("buildin_channel_unban: Channel name '%s' is invalid.\n", chname);
@@ -25838,7 +25837,7 @@ BUILDIN_FUNC(getequiptradability) {
 	return SCRIPT_CMD_SUCCESS;
 }
 
-static inline bool mail_sub( struct script_state *st, struct script_data *data, map_session_data *sd, int i, const char **out_name, unsigned int *start, unsigned int *end, int32 *id ){
+static inline bool mail_sub( struct script_state *st, struct script_data *data, map_session_data *sd, int i, const char **out_name, uint32 *start, uint32 *end, int32 *id ){
 	const char *name;
 
 	// Check if it is a variable
@@ -25888,7 +25887,7 @@ BUILDIN_FUNC(mail){
 	struct mail_message msg;
 	struct script_data *data;
 	map_session_data *sd = nullptr;
-	unsigned int i, j, k, num_items, start, end;
+	uint32 i, j, k, num_items, start, end;
 	int32 id;
 
 	memset(&msg, 0, sizeof(struct mail_message));

+ 15 - 15
src/map/script.hpp

@@ -147,8 +147,8 @@ struct eri;
 extern int potion_flag; //For use on Alchemist improved potions/Potion Pitcher. [Skotlex]
 extern int potion_hp, potion_per_hp, potion_sp, potion_per_sp;
 extern int potion_target;
-extern unsigned int *generic_ui_array;
-extern unsigned int generic_ui_array_size;
+extern uint32 *generic_ui_array;
+extern uint32 generic_ui_array_size;
 
 struct Script_Config {
 	unsigned warn_func_mismatch_argtypes : 1;
@@ -331,7 +331,7 @@ struct script_state {
 	unsigned mes_active : 1;  // Store if invoking character has a NPC dialog box open.
 	unsigned clear_cutin : 1;
 	char* funcname; // Stores the current running function name
-	unsigned int id;
+	uint32 id;
 };
 
 struct script_reg {
@@ -345,9 +345,9 @@ struct script_regstr {
 };
 
 struct script_array {
-	unsigned int id;       ///< the first 32b of the 64b uid, aka the id
-	unsigned int size;     ///< how many members
-	unsigned int *members; ///< member list
+	uint32 id;       ///< the first 32b of the 64b uid, aka the id
+	uint32 size;     ///< how many members
+	uint32 *members; ///< member list
 };
 
 enum script_parse_options {
@@ -2226,8 +2226,8 @@ public:
  **/
 extern struct eri *array_ers;
 extern DBMap *st_db;
-extern unsigned int active_scripts;
-extern unsigned int next_id;
+extern uint32 active_scripts;
+extern uint32 next_id;
 extern struct eri *st_ers;
 extern struct eri *stack_ers;
 
@@ -2263,7 +2263,7 @@ void script_free_state(struct script_state* st);
 
 struct DBMap* script_get_label_db(void);
 struct DBMap* script_get_userfunc_db(void);
-void script_run_autobonus(const char *autobonus, map_session_data *sd, unsigned int pos);
+void script_run_autobonus(const char *autobonus, map_session_data *sd, uint32 pos);
 void script_run_petautobonus(const std::string &autobonus, map_session_data &sd);
 
 const char* script_get_constant_str(const char* prefix, int64 value);
@@ -2292,18 +2292,18 @@ void setd_sub_str( struct script_state* st, map_session_data* sd, const char* va
 struct reg_db *script_array_src(struct script_state *st, map_session_data *sd, const char *name, struct reg_db *ref);
 void script_array_update(struct reg_db *src, int64 num, bool empty);
 void script_array_delete(struct reg_db *src, struct script_array *sa);
-void script_array_remove_member(struct reg_db *src, struct script_array *sa, unsigned int idx);
-void script_array_add_member(struct script_array *sa, unsigned int idx);
-unsigned int script_array_size(struct script_state *st, map_session_data *sd, const char *name, struct reg_db *ref);
-unsigned int script_array_highest_key(struct script_state *st, map_session_data *sd, const char *name, struct reg_db *ref);
+void script_array_remove_member(struct reg_db *src, struct script_array *sa, uint32 idx);
+void script_array_add_member(struct script_array *sa, uint32 idx);
+uint32 script_array_size(struct script_state *st, map_session_data *sd, const char *name, struct reg_db *ref);
+uint32 script_array_highest_key(struct script_state *st, map_session_data *sd, const char *name, struct reg_db *ref);
 void script_array_ensure_zero(struct script_state *st, map_session_data *sd, int64 uid, struct reg_db *ref);
 int script_free_array_db(DBKey key, DBData *data, va_list ap);
 /* */
 void script_reg_destroy_single(map_session_data *sd, int64 reg, struct script_reg_state *data);
 int script_reg_destroy(DBKey key, DBData *data, va_list ap);
 /* */
-void script_generic_ui_array_expand(unsigned int plus);
-unsigned int *script_array_cpy_list(struct script_array *sa);
+void script_generic_ui_array_expand(uint32 plus);
+uint32 *script_array_cpy_list(struct script_array *sa);
 
 bool script_check_RegistryVariableLength(int pType, const char *val, size_t* vlen);
 

+ 3 - 3
src/map/searchstore.cpp

@@ -112,9 +112,9 @@ bool searchstore_open(map_session_data& sd, uint16 uses, e_searchstore_effecttyp
  * @param cardlist : list with stored cards (cards attached to items)
  * @param card_count : amount of items in cardlist
  */
-void searchstore_query(map_session_data& sd, e_searchstore_searchtype type, unsigned int min_price, unsigned int max_price, const struct PACKET_CZ_SEARCH_STORE_INFO_item* itemlist, unsigned int item_count, const struct PACKET_CZ_SEARCH_STORE_INFO_item* cardlist, unsigned int card_count)
+void searchstore_query(map_session_data& sd, e_searchstore_searchtype type, uint32 min_price, uint32 max_price, const struct PACKET_CZ_SEARCH_STORE_INFO_item* itemlist, uint32 item_count, const struct PACKET_CZ_SEARCH_STORE_INFO_item* cardlist, uint32 card_count)
 {
-	unsigned int i;
+	uint32 i;
 	map_session_data* pl_sd;
 	struct DBIterator *iter;
 	struct s_search_store_search s;
@@ -283,7 +283,7 @@ void searchstore_close(map_session_data& sd)
  */
 void searchstore_click(map_session_data& sd, uint32 account_id, int store_id, t_itemid nameid)
 {
-	unsigned int i;
+	uint32 i;
 	map_session_data* pl_sd;
 	searchstore_search_t store_search;
 

+ 7 - 7
src/map/searchstore.hpp

@@ -61,10 +61,10 @@ struct s_search_store_search {
 	map_session_data* search_sd;  // sd of the searching player
 	const struct PACKET_CZ_SEARCH_STORE_INFO_item* itemlist;
 	const struct PACKET_CZ_SEARCH_STORE_INFO_item* cardlist;
-	unsigned int item_count;
-	unsigned int card_count;
-	unsigned int min_price;
-	unsigned int max_price;
+	uint32 item_count;
+	uint32 card_count;
+	uint32 min_price;
+	uint32 max_price;
 };
 
 struct s_search_store_info_item {
@@ -73,7 +73,7 @@ struct s_search_store_info_item {
 	char store_name[MESSAGE_SIZE];
 	t_itemid nameid;
 	unsigned short amount;
-	unsigned int price;
+	uint32 price;
 	t_itemid card[MAX_SLOTS];
 	unsigned char refine;
 	uint8 enchantgrade;
@@ -81,7 +81,7 @@ struct s_search_store_info_item {
 
 struct s_search_store_info {
 	std::vector<std::shared_ptr<s_search_store_info_item>> items;
-	unsigned int pages;  // amount of pages already sent to client
+	uint32 pages;  // amount of pages already sent to client
 	uint16 uses;
 	int remote_id;
 	time_t nextquerytime;
@@ -92,7 +92,7 @@ struct s_search_store_info {
 };
 
 bool searchstore_open(map_session_data& sd, uint16 uses, e_searchstore_effecttype effect, int16 mapid);
-void searchstore_query(map_session_data& sd, e_searchstore_searchtype type, unsigned int min_price, unsigned int max_price, const struct PACKET_CZ_SEARCH_STORE_INFO_item* itemlist, unsigned int item_count, const struct PACKET_CZ_SEARCH_STORE_INFO_item* cardlist, unsigned int card_count);
+void searchstore_query(map_session_data& sd, e_searchstore_searchtype type, uint32 min_price, uint32 max_price, const struct PACKET_CZ_SEARCH_STORE_INFO_item* itemlist, uint32 item_count, const struct PACKET_CZ_SEARCH_STORE_INFO_item* cardlist, uint32 card_count);
 bool searchstore_querynext(map_session_data& sd);
 void searchstore_next(map_session_data& sd);
 void searchstore_clear(map_session_data& sd);

+ 21 - 22
src/map/skill.cpp

@@ -1027,7 +1027,7 @@ bool skill_isNotOk_hom(struct homun_data *hd, uint16 skill_id, uint16 skill_lv)
 			}
 			break;
 		case HVAN_EXPLOSION:
-			if (hd->homunculus.intimacy < (unsigned int)battle_config.hvan_explosion_intimate) {
+			if (hd->homunculus.intimacy < (uint32)battle_config.hvan_explosion_intimate) {
 				clif_skill_fail( *sd, skill_id, USESKILL_FAIL_RELATIONGRADE );
 				return true;
 			}
@@ -4443,12 +4443,12 @@ static int skill_check_condition_mercenary(struct block_list *bl, uint16 skill_i
 
 	if( !(type&2) )
 	{
-		if( hp > 0 && status->hp <= (unsigned int)hp )
+		if( hp > 0 && status->hp <= (uint32)hp )
 		{
 			clif_skill_fail( *sd, skill_id, USESKILL_FAIL_HP_INSUFFICIENT );
 			return 0;
 		}
-		if( sp > 0 && status->sp <= (unsigned int)sp )
+		if( sp > 0 && status->sp <= (uint32)sp )
 		{
 			clif_skill_fail( *sd, skill_id, USESKILL_FAIL_SP_INSUFFICIENT );
 			return 0;
@@ -5378,7 +5378,7 @@ int skill_castend_damage_id (struct block_list* src, struct block_list *bl, uint
 #ifdef RENEWAL
 		int dist = skill_get_blewcount(skill_id, skill_lv);
 #else
-		unsigned int dist = distance_bl(src, bl);
+		uint32 dist = distance_bl(src, bl);
 #endif
 		uint8 dir = map_calc_dir(bl, src->x, src->y);
 
@@ -9444,7 +9444,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 					return 1;
 				}
 				if( skill_id == AM_BERSERKPITCHER ) {
-					if( dstsd && dstsd->status.base_level < (unsigned int)sd->inventory_data[j]->elv ) {
+					if( dstsd && dstsd->status.base_level < (uint32)sd->inventory_data[j]->elv ) {
 						clif_skill_fail( *sd, skill_id );
 						map_freeblock_unlock();
 						return 1;
@@ -9562,7 +9562,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 	case AM_CP_ARMOR:
 	case AM_CP_HELM:
 		{
-			unsigned int equip[] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HEAD_TOP};
+			uint32 equip[] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HEAD_TOP};
 
 			if( sd && ( bl->type != BL_PC || ( dstsd && pc_checkequip(dstsd,equip[skill_id - AM_CP_WEAPON]) < 0 ) ) ){
 				clif_skill_fail( *sd, skill_id );
@@ -10282,7 +10282,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 
 	case PF_SOULCHANGE:
 		{
-			unsigned int sp1 = 0, sp2 = 0;
+			uint32 sp1 = 0, sp2 = 0;
 			if (dstmd) {
 				if (dstmd->state.soul_change_flag) {
 					if(sd) clif_skill_fail( *sd, skill_id );
@@ -10353,7 +10353,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 	// Full Chemical Protection
 	case CR_FULLPROTECTION:
 		{
-			unsigned int equip[] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HEAD_TOP};
+			uint32 equip[] = {EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HEAD_TOP};
 			int i_eqp, s = 0, skilltime = skill_get_time(skill_id,skill_lv);
 
 			for (i_eqp = 0; i_eqp < 4; i_eqp++) {
@@ -11669,7 +11669,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 
 	case SR_GENTLETOUCH_CURE:
 		{
-			unsigned int heal;
+			uint32 heal;
 
 			if (dstmd && (dstmd->mob_id == MOBID_EMPERIUM || status_get_class_(bl) == CLASS_BATTLEFIELD))
 				heal = 0;
@@ -12582,7 +12582,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 
 	case SU_TUNABELLY:
 	{
-		unsigned int heal = 0;
+		uint32 heal = 0;
 
 		if (dstmd && (dstmd->mob_id == MOBID_EMPERIUM || status_get_class_(bl) == CLASS_BATTLEFIELD))
 			heal = 0;
@@ -12701,7 +12701,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 
 	case BO_THE_WHOLE_PROTECTION:
 		if (sd == nullptr || sd->status.party_id == 0 || (flag & 1)) {
-			unsigned int equip[] = { EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HEAD_TOP };
+			uint32 equip[] = { EQP_WEAPON, EQP_SHIELD, EQP_ARMOR, EQP_HEAD_TOP };
 
 			for (uint8 i_eqp = 0; i_eqp < 4; i_eqp++) {
 				if (bl->type != BL_PC || (dstsd && pc_checkequip(dstsd, equip[i_eqp]) < 0))
@@ -17008,7 +17008,7 @@ static int skill_unit_effect(struct block_list* bl, va_list ap)
 {
 	struct skill_unit* unit = va_arg(ap,struct skill_unit*);
 	t_tick tick = va_arg(ap,t_tick);
-	unsigned int flag = va_arg(ap,unsigned int);
+	uint32 flag = va_arg(ap,uint32);
 	uint16 skill_id;
 	bool dissonance = false;
 	bool isTarget = false;
@@ -17830,7 +17830,7 @@ bool skill_check_condition_castbegin( map_session_data& sd, uint16 skill_id, uin
 			//Auron insists we should implement SP consumption when you are not Soul Linked. [Skotlex]
 			//Only invoke on skill begin cast (instant cast skill). [Kevin]
 			if( require.sp > 0 ) {
-				if (status->sp < (unsigned int)require.sp)
+				if (status->sp < (uint32)require.sp)
 					clif_skill_fail( sd, skill_id, USESKILL_FAIL_SP_INSUFFICIENT );
 				else
 					status_zap(&sd.bl, 0, require.sp);
@@ -18370,7 +18370,7 @@ bool skill_check_condition_castbegin( map_session_data& sd, uint16 skill_id, uin
 			case RA_AIMEDBOLT:
 				break;
 			default:
-				switch((unsigned int)log2(require.weapon)) {
+				switch((uint32)log2(require.weapon)) {
 					case W_REVOLVER:
 						clif_msg(&sd, MSI_FAIL_NEED_EQUIPPED_GUN_HANDGUN);
 						break;
@@ -18394,12 +18394,12 @@ bool skill_check_condition_castbegin( map_session_data& sd, uint16 skill_id, uin
 		}
 	}
 
-	if( require.sp > 0 && status->sp < (unsigned int)require.sp) {
+	if( require.sp > 0 && status->sp < (uint32)require.sp) {
 		clif_skill_fail( sd, skill_id, USESKILL_FAIL_SP_INSUFFICIENT );
 		return false;
 	}
 
-	if (require.ap > 0 && status->ap < (unsigned int)require.ap) {
+	if (require.ap > 0 && status->ap < (uint32)require.ap) {
 		clif_skill_fail( sd, skill_id, USESKILL_FAIL_AP_INSUFFICIENT );
 		return false;
 	}
@@ -18613,7 +18613,7 @@ bool skill_check_condition_castend( map_session_data& sd, uint16 skill_id, uint1
 
 	require = skill_get_requirement(&sd,skill_id,skill_lv);
 
-	if( require.hp > 0 && status->hp <= (unsigned int)require.hp) {
+	if( require.hp > 0 && status->hp <= (uint32)require.hp) {
 		clif_skill_fail( sd, skill_id, USESKILL_FAIL_HP_INSUFFICIENT );
 		return false;
 	}
@@ -20715,16 +20715,15 @@ bool skill_check_camouflage(struct block_list *bl, struct status_change_entry *s
 int skill_getareachar_skillunit_visibilty_sub(struct block_list *bl, va_list ap) {
 	struct skill_unit *su = nullptr;
 	struct block_list *src = nullptr;
-	unsigned int party1 = 0;
 	bool visible = true;
 
 	nullpo_ret(bl);
 	nullpo_ret((su = va_arg(ap, struct skill_unit*)));
 	nullpo_ret((src = va_arg(ap, struct block_list*)));
-	party1 = va_arg(ap, unsigned int);
+	uint32 party1 = va_arg(ap, uint32);
 
 	if (src != bl) {
-		unsigned int party2 = status_get_party_id(bl);
+		uint32 party2 = status_get_party_id(bl);
 		if (!party1 || !party2 || party1 != party2)
 			visible = false;
 	}
@@ -20768,8 +20767,8 @@ void skill_getareachar_skillunit_visibilty_single(struct skill_unit *su, struct
 	nullpo_retv((src = battle_get_master(&su->bl)));
 
 	if (su->hidden && src != bl) {
-		unsigned int party1 = status_get_party_id(src);
-		unsigned int party2 = status_get_party_id(bl);
+		uint32 party1 = status_get_party_id(src);
+		uint32 party2 = status_get_party_id(bl);
 		if (!party1 || !party2 || party1 != party2)
 			visible = false;
 	}

+ 57 - 57
src/map/status.cpp

@@ -51,7 +51,7 @@ static struct eri *sc_data_ers; /// For sc_data entries
 static struct status_data dummy_status;
 
 short current_equip_item_index; /// Contains inventory index of an equipped item. To pass it into the EQUP_SCRIPT [Lupus]
-unsigned int current_equip_combo_pos; /// For combo items we need to save the position of all involved items here
+uint32 current_equip_combo_pos; /// For combo items we need to save the position of all involved items here
 int current_equip_card_id; /// To prevent card-stacking (from jA) [Skotlex]
 // We need it for new cards 15 Feb 2005, to check if the combo cards are insrerted into the CURRENT weapon only to avoid cards exploits
 short current_equip_opt_index; /// Contains random option index of an equipped item. [Secret]
@@ -93,20 +93,20 @@ static signed short status_calc_res(struct block_list *, status_change *, int);
 static signed short status_calc_mres(struct block_list *, status_change *, int);
 static signed short status_calc_hplus(struct block_list *, status_change *, int);
 static signed short status_calc_crate(struct block_list *, status_change *, int);
-static unsigned int status_calc_maxhp(struct block_list *bl, uint64 maxhp);
-static unsigned int status_calc_maxsp(struct block_list *bl, uint64 maxsp);
-static unsigned int status_calc_maxap(struct block_list *bl, uint64 maxap);
+static uint32 status_calc_maxhp(struct block_list *bl, uint64 maxhp);
+static uint32 status_calc_maxsp(struct block_list *bl, uint64 maxsp);
+static uint32 status_calc_maxap(struct block_list *bl, uint64 maxap);
 static unsigned char status_calc_element(struct block_list *bl, status_change *sc, int element);
 static unsigned char status_calc_element_lv(struct block_list *bl, status_change *sc, int lv);
 static int status_calc_mode(struct block_list *bl, status_change *sc, int mode);
 static int status_get_hpbonus(struct block_list *bl, enum e_status_bonus type);
 static int status_get_spbonus(struct block_list *bl, enum e_status_bonus type);
 static int status_get_apbonus(struct block_list *bl, enum e_status_bonus type);
-static unsigned int status_calc_maxhpsp_pc(map_session_data* sd, unsigned int stat, bool isHP);
-static unsigned int status_calc_maxap_pc(map_session_data* sd);
+static uint32 status_calc_maxhpsp_pc(map_session_data* sd, uint32 stat, bool isHP);
+static uint32 status_calc_maxap_pc(map_session_data* sd);
 static int status_get_sc_interval(enum sc_type type);
 
-static bool status_change_isDisabledOnMap_(sc_type type, bool mapIsVS, bool mapIsPVP, bool mapIsGVG, bool mapIsBG, unsigned int mapZone, bool mapIsTE);
+static bool status_change_isDisabledOnMap_(sc_type type, bool mapIsVS, bool mapIsPVP, bool mapIsGVG, bool mapIsBG, uint32 mapZone, bool mapIsTE);
 #define status_change_isDisabledOnMap(type, m) ( status_change_isDisabledOnMap_((type), mapdata_flag_vs2((m)), m->getMapFlag(MF_PVP) != 0, mapdata_flag_gvg2_no_te((m)), m->getMapFlag(MF_BATTLEGROUND) != 0, (m->zone << 3) != 0, mapdata_flag_gvg2_te((m))) )
 
 const std::string RefineDatabase::getDefaultLocation(){
@@ -1237,7 +1237,7 @@ static inline void status_cpy(struct status_data* a, const struct status_data* b
  *		Use 2 to display healing effect
  * @return heal or zapped HP if valid
  */
-int status_set_hp(struct block_list *bl, unsigned int hp, int flag)
+int status_set_hp(struct block_list *bl, uint32 hp, int flag)
 {
 	if (hp < 1)
 		return 0;
@@ -1264,7 +1264,7 @@ int status_set_hp(struct block_list *bl, unsigned int hp, int flag)
  *		Use 2 to display healing effect
  * @return heal or zapped HP if valid
  */
-int status_set_maxhp(struct block_list *bl, unsigned int maxhp, int flag)
+int status_set_maxhp(struct block_list *bl, uint32 maxhp, int flag)
 {
 	int64 heal;
 
@@ -1298,7 +1298,7 @@ int status_set_maxhp(struct block_list *bl, unsigned int maxhp, int flag)
  *		Use 2 to display healing effect		
  * @return heal or zapped SP if valid
  */
-int status_set_sp(struct block_list *bl, unsigned int sp, int flag)
+int status_set_sp(struct block_list *bl, uint32 sp, int flag)
 {
 	status_data* status = status_get_status_data(*bl);
 
@@ -1322,7 +1322,7 @@ int status_set_sp(struct block_list *bl, unsigned int sp, int flag)
  *		Use 2 to display healing effect
  * @return heal or zapped HP if valid
  */
-int status_set_maxsp(struct block_list *bl, unsigned int maxsp, int flag)
+int status_set_maxsp(struct block_list *bl, uint32 maxsp, int flag)
 {
 	if (maxsp < 1)
 		return 0;
@@ -1351,7 +1351,7 @@ int status_set_maxsp(struct block_list *bl, unsigned int maxsp, int flag)
 *		Use 2 to display healing effect
 * @return heal or zapped AP if valid
 */
-int status_set_ap(struct block_list *bl, unsigned int ap, int flag)
+int status_set_ap(struct block_list *bl, uint32 ap, int flag)
 {
 	status_data *status = status_get_status_data(*bl);
 
@@ -1375,7 +1375,7 @@ int status_set_ap(struct block_list *bl, unsigned int ap, int flag)
 *		Use 2 to display healing effect
 * @return heal or zapped AP if valid
 */
-int status_set_maxap(struct block_list *bl, unsigned int maxap, int flag)
+int status_set_maxap(struct block_list *bl, uint32 maxap, int flag)
 {
 	if (maxap < 1)
 		return 0;
@@ -1471,17 +1471,17 @@ int status_damage(struct block_list *src,struct block_list *target,int64 dhp, in
 	if( status == &dummy_status )
 		return 0;
 
-	if ((unsigned int)hp >= status->hp) {
+	if ((uint32)hp >= status->hp) {
 		if (flag&2) return 0;
 		hp = status->hp;
 	}
 
-	if ((unsigned int)sp > status->sp) {
+	if ((uint32)sp > status->sp) {
 		if (flag&2) return 0;
 		sp = status->sp;
 	}
 
-	if ((unsigned int)ap > status->ap) {
+	if ((uint32)ap > status->ap) {
 		if (flag & 2) return 0;
 		ap = status->ap;
 	}
@@ -1756,7 +1756,7 @@ int status_heal(struct block_list *bl,int64 hhp,int64 hsp, int64 hap, int flag)
 				hp = 0;
 		}
 
-		if((unsigned int)hp > status->max_hp - status->hp)
+		if((uint32)hp > status->max_hp - status->hp)
 			hp = status->max_hp - status->hp;
 	}
 
@@ -1768,7 +1768,7 @@ int status_heal(struct block_list *bl,int64 hhp,int64 hsp, int64 hap, int flag)
 	}
 
 	if(sp) {
-		if((unsigned int)sp > status->max_sp - status->sp)
+		if((uint32)sp > status->max_sp - status->sp)
 			sp = status->max_sp - status->sp;
 	}
 
@@ -1780,7 +1780,7 @@ int status_heal(struct block_list *bl,int64 hhp,int64 hsp, int64 hap, int flag)
 	}
 
 	if (ap) {
-		if ((unsigned int)ap > status->max_ap - status->ap)
+		if ((uint32)ap > status->max_ap - status->ap)
 			ap = status->max_ap - status->ap;
 	}
 
@@ -1837,7 +1837,7 @@ int status_heal(struct block_list *bl,int64 hhp,int64 hsp, int64 hap, int flag)
  */
 int status_percent_change(struct block_list *src, struct block_list *target, int8 hp_rate, int8 sp_rate, int8 ap_rate, uint8 flag)
 {
-	unsigned int hp = 0, sp = 0, ap = 0;
+	uint32 hp = 0, sp = 0, ap = 0;
 	status_data* status = status_get_status_data(*target);
 
 	// It's safe now [MarkZD]
@@ -1915,7 +1915,7 @@ int status_percent_change(struct block_list *src, struct block_list *target, int
  */
 int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per_sp, unsigned char per_ap)
 {
-	unsigned int hp, sp, ap;
+	uint32 hp, sp, ap;
 	if (!status_isdead(*bl)) return 0;
 
 	status_data* status = status_get_status_data(*bl);
@@ -2441,7 +2441,7 @@ unsigned short status_base_atk(const struct block_list *bl, const struct status_
  * @param status: Player status
  * @return weapon attack
  */
-unsigned int status_weapon_atk(weapon_atk &wa)
+uint32 status_weapon_atk(weapon_atk &wa)
 {
 	return wa.atk + wa.atk2;
 }
@@ -3490,7 +3490,7 @@ static int status_get_apbonus_item(block_list *bl) {
  * @param isHP true - calculates Max HP, false - calculated Max SP
  * @return max The max value of HP or SP
  */
-static unsigned int status_calc_maxhpsp_pc(map_session_data* sd, unsigned int stat, bool isHP) {
+static uint32 status_calc_maxhpsp_pc(map_session_data* sd, uint32 stat, bool isHP) {
 	nullpo_ret(sd);
 
 	double dmax = 0;
@@ -3521,10 +3521,10 @@ static unsigned int status_calc_maxhpsp_pc(map_session_data* sd, unsigned int st
 		dmax += (int64)(dmax * status_get_spbonus(&sd->bl,STATUS_BONUS_RATE) / 100); //Aegis accuracy
 	}
 
-	//Make sure it's not negative before casting to unsigned int
+	//Make sure it's not negative before casting to uint32
 	if(dmax < 1) dmax = 1;
 
-	return cap_value((unsigned int)dmax,1,UINT_MAX);
+	return cap_value((uint32)dmax,1,UINT_MAX);
 }
 
 /**
@@ -3532,7 +3532,7 @@ static unsigned int status_calc_maxhpsp_pc(map_session_data* sd, unsigned int st
  * @param sd: Player data
  * @return AP amount
  */
-static unsigned int status_calc_maxap_pc(map_session_data* sd) {
+static uint32 status_calc_maxap_pc(map_session_data* sd) {
 	double dmax = 0, equip_bonus = 0, item_bonus = 0;
 
 	nullpo_ret(sd);
@@ -3544,10 +3544,10 @@ static unsigned int status_calc_maxap_pc(map_session_data* sd) {
 	dmax += equip_bonus + item_bonus;
 	dmax += (int64)(dmax * status_get_apbonus(&sd->bl, STATUS_BONUS_RATE) / 100);// Aegis accuracy
 
-	//Make sure it's not negative before casting to unsigned int
+	//Make sure it's not negative before casting to uint32
 	if (dmax < 0) dmax = 0;
 
-	return cap_value((unsigned int)dmax, 0, UINT_MAX);
+	return cap_value((uint32)dmax, 0, UINT_MAX);
 }
 
 /**
@@ -4246,30 +4246,30 @@ int status_calc_pc_sub(map_session_data* sd, uint8 opt)
 	base_status->max_hp = sd->status.max_hp = status_calc_maxhpsp_pc(sd,base_status->vit,true);
 
 	if(battle_config.hp_rate != 100)
-		base_status->max_hp = (unsigned int)(battle_config.hp_rate * (base_status->max_hp/100.));
+		base_status->max_hp = (uint32)(battle_config.hp_rate * (base_status->max_hp/100.));
 
 	if (sd->status.base_level < 100)
-		base_status->max_hp = cap_value(base_status->max_hp,1,(unsigned int)battle_config.max_hp_lv99);
+		base_status->max_hp = cap_value(base_status->max_hp,1,(uint32)battle_config.max_hp_lv99);
 	else if (sd->status.base_level < 151)
-		base_status->max_hp = cap_value(base_status->max_hp,1,(unsigned int)battle_config.max_hp_lv150);
+		base_status->max_hp = cap_value(base_status->max_hp,1,(uint32)battle_config.max_hp_lv150);
 	else
-		base_status->max_hp = cap_value(base_status->max_hp,1,(unsigned int)battle_config.max_hp);
+		base_status->max_hp = cap_value(base_status->max_hp,1,(uint32)battle_config.max_hp);
 
 // ----- SP MAX CALCULATION -----
 	base_status->max_sp = sd->status.max_sp = status_calc_maxhpsp_pc(sd,base_status->int_,false);
 
 	if(battle_config.sp_rate != 100)
-		base_status->max_sp = (unsigned int)(battle_config.sp_rate * (base_status->max_sp/100.));
+		base_status->max_sp = (uint32)(battle_config.sp_rate * (base_status->max_sp/100.));
 
-	base_status->max_sp = cap_value(base_status->max_sp,1,(unsigned int)battle_config.max_sp);
+	base_status->max_sp = cap_value(base_status->max_sp,1,(uint32)battle_config.max_sp);
 
 // ----- AP MAX CALCULATION -----
 	base_status->max_ap = sd->status.max_ap = status_calc_maxap_pc(sd);
 
 	if (battle_config.ap_rate != 100)
-		base_status->max_ap = (unsigned int)(battle_config.ap_rate * (base_status->max_ap / 100.));
+		base_status->max_ap = (uint32)(battle_config.ap_rate * (base_status->max_ap / 100.));
 
-	base_status->max_ap = cap_value(base_status->max_ap, 0, (unsigned int)battle_config.max_ap);
+	base_status->max_ap = cap_value(base_status->max_ap, 0, (uint32)battle_config.max_ap);
 
 // ----- RESPAWN HP/SP/AP -----
 
@@ -6098,14 +6098,14 @@ void status_calc_bl_main(struct block_list& bl, std::bitset<SCB_MAX> flag)
 			status->max_hp = status_calc_maxhpsp_pc(sd,status->vit,true);
 
 			if(battle_config.hp_rate != 100)
-				status->max_hp = (unsigned int)(battle_config.hp_rate * (status->max_hp/100.));
+				status->max_hp = (uint32)(battle_config.hp_rate * (status->max_hp/100.));
 
 			if (sd->status.base_level < 100)
-				status->max_hp = umin(status->max_hp,(unsigned int)battle_config.max_hp_lv99);
+				status->max_hp = umin(status->max_hp,(uint32)battle_config.max_hp_lv99);
 			else if (sd->status.base_level < 151)
-				status->max_hp = umin(status->max_hp,(unsigned int)battle_config.max_hp_lv150);
+				status->max_hp = umin(status->max_hp,(uint32)battle_config.max_hp_lv150);
 			else
-				status->max_hp = umin(status->max_hp,(unsigned int)battle_config.max_hp);
+				status->max_hp = umin(status->max_hp,(uint32)battle_config.max_hp);
 		}
 		else
 			status->max_hp = status_calc_maxhp(&bl, b_status->max_hp);
@@ -6121,9 +6121,9 @@ void status_calc_bl_main(struct block_list& bl, std::bitset<SCB_MAX> flag)
 			status->max_sp = status_calc_maxhpsp_pc(sd,status->int_,false);
 
 			if(battle_config.sp_rate != 100)
-				status->max_sp = (unsigned int)(battle_config.sp_rate * (status->max_sp/100.));
+				status->max_sp = (uint32)(battle_config.sp_rate * (status->max_sp/100.));
 
-			status->max_sp = umin(status->max_sp,(unsigned int)battle_config.max_sp);
+			status->max_sp = umin(status->max_sp,(uint32)battle_config.max_sp);
 		}
 		else
 			status->max_sp = status_calc_maxsp(&bl, b_status->max_sp);
@@ -6383,9 +6383,9 @@ void status_calc_bl_main(struct block_list& bl, std::bitset<SCB_MAX> flag)
 			status->max_ap = status_calc_maxap_pc(sd);
 
 			if (battle_config.ap_rate != 100)
-				status->max_ap = (unsigned int)(battle_config.ap_rate * (status->max_ap / 100.));
+				status->max_ap = (uint32)(battle_config.ap_rate * (status->max_ap / 100.));
 
-			status->max_ap = umin(status->max_ap, (unsigned int)battle_config.max_ap);
+			status->max_ap = umin(status->max_ap, (uint32)battle_config.max_ap);
 		} else
 			status->max_ap = status_calc_maxap(&bl, b_status->max_ap);
 
@@ -8834,7 +8834,7 @@ static signed short status_calc_crate(struct block_list *bl, status_change *sc,
  * @param maxhp: Object's current max HP
  * @return modified maxhp
  */
-static unsigned int status_calc_maxhp(struct block_list *bl, uint64 maxhp)
+static uint32 status_calc_maxhp(struct block_list *bl, uint64 maxhp)
 {
 	int rate = 100;
 
@@ -8843,7 +8843,7 @@ static unsigned int status_calc_maxhp(struct block_list *bl, uint64 maxhp)
 	if ((rate += status_get_hpbonus(bl,STATUS_BONUS_RATE)) != 100)
 		maxhp = maxhp * rate / 100;
 
-	return (unsigned int)cap_value(maxhp,1,UINT_MAX);
+	return (uint32)cap_value(maxhp,1,UINT_MAX);
 }
 
 /**
@@ -8853,7 +8853,7 @@ static unsigned int status_calc_maxhp(struct block_list *bl, uint64 maxhp)
  * @param maxsp: Object's current max SP
  * @return modified maxsp
  */
-static unsigned int status_calc_maxsp(struct block_list *bl, uint64 maxsp)
+static uint32 status_calc_maxsp(struct block_list *bl, uint64 maxsp)
 {
 	int rate = 100;
 
@@ -8862,7 +8862,7 @@ static unsigned int status_calc_maxsp(struct block_list *bl, uint64 maxsp)
 	if ((rate += status_get_spbonus(bl,STATUS_BONUS_RATE)) != 100)
 		maxsp = maxsp * rate / 100;
 	
-	return (unsigned int)cap_value(maxsp,1,UINT_MAX);
+	return (uint32)cap_value(maxsp,1,UINT_MAX);
 }
 
 /**
@@ -8872,7 +8872,7 @@ static unsigned int status_calc_maxsp(struct block_list *bl, uint64 maxsp)
 * @param maxap: Object's current max AP
 * @return modified maxap
 */
-static unsigned int status_calc_maxap(struct block_list *bl, uint64 maxap)
+static uint32 status_calc_maxap(struct block_list *bl, uint64 maxap)
 {
 	int rate = 100;
 
@@ -8881,7 +8881,7 @@ static unsigned int status_calc_maxap(struct block_list *bl, uint64 maxap)
 	if ((rate += status_get_apbonus(bl, STATUS_BONUS_RATE)) != 100)
 		maxap = maxap * rate / 100;
 
-	return (unsigned int)cap_value(maxap, 0, UINT_MAX);
+	return (uint32)cap_value(maxap, 0, UINT_MAX);
 }
 
 /**
@@ -14178,7 +14178,7 @@ TIMER_FUNC(status_change_timer){
 	case SC_POISON:
 	case SC_DPOISON:
 		if (sce->val4 >= 0 && !sc->getSCE(SC_SLOWPOISON)) {
-			unsigned int damage = 0;
+			uint32 damage = 0;
 			if (sd)
 				damage = (type == SC_DPOISON) ? 2 + status->max_hp / 50 : 2 + status->max_hp * 3 / 200;
 			else
@@ -15414,7 +15414,7 @@ static int status_natural_heal(struct block_list* bl, va_list args)
 			if (regen->state.overweight)
 				rate /= 2; // Half as fast when overweight.
 			sregen->tick.hp += rate;
-			while(sregen->tick.hp >= (unsigned int)battle_config.natural_heal_skill_interval) {
+			while(sregen->tick.hp >= (uint32)battle_config.natural_heal_skill_interval) {
 				sregen->tick.hp -= battle_config.natural_heal_skill_interval;
 				if(status_heal(bl, sregen->hp, 0, 3) < sregen->hp) { // Full
 					flag &= ~RGN_SHP;
@@ -15427,7 +15427,7 @@ static int status_natural_heal(struct block_list* bl, va_list args)
 			if (regen->state.overweight)
 				rate /= 2; // Half as fast when overweight.
 			sregen->tick.sp += rate;
-			while(sregen->tick.sp >= (unsigned int)battle_config.natural_heal_skill_interval) {
+			while(sregen->tick.sp >= (uint32)battle_config.natural_heal_skill_interval) {
 				sregen->tick.sp -= battle_config.natural_heal_skill_interval;
 				if(status_heal(bl, 0, sregen->sp, 3) < sregen->sp) { // Full
 					flag &= ~RGN_SSP;
@@ -15530,7 +15530,7 @@ static int status_natural_heal(struct block_list* bl, va_list args)
 	if(flag&RGN_SHP) { // Skill HP regen
 		sregen->tick.hp += (int)(natural_heal_diff_tick * (sregen->rate.hp / 100.));
 
-		while(sregen->tick.hp >= (unsigned int)battle_config.natural_heal_skill_interval) {
+		while(sregen->tick.hp >= (uint32)battle_config.natural_heal_skill_interval) {
 			sregen->tick.hp -= battle_config.natural_heal_skill_interval;
 			if(status_heal(bl, sregen->hp, 0, 3) < sregen->hp)
 				break; // Full
@@ -15538,7 +15538,7 @@ static int status_natural_heal(struct block_list* bl, va_list args)
 	}
 	if(flag&RGN_SSP) { // Skill SP regen
 		sregen->tick.sp += (int)(natural_heal_diff_tick * (sregen->rate.sp /100.));
-		while(sregen->tick.sp >= (unsigned int)battle_config.natural_heal_skill_interval) {
+		while(sregen->tick.sp >= (uint32)battle_config.natural_heal_skill_interval) {
 			int val = sregen->sp;
 			if (sd && sd->state.doridori) {
 				val *= 2;
@@ -15612,7 +15612,7 @@ TIMER_FUNC(status_clear_lastEffect_timer) {
  * @param mapIsTE: If the map us WOE TE
  * @return True - SC disabled on map; False - SC not disabled on map/Invalid SC
  */
-static bool status_change_isDisabledOnMap_(sc_type type, bool mapIsVS, bool mapIsPVP, bool mapIsGVG, bool mapIsBG, unsigned int mapZone, bool mapIsTE)
+static bool status_change_isDisabledOnMap_(sc_type type, bool mapIsVS, bool mapIsPVP, bool mapIsGVG, bool mapIsBG, uint32 mapZone, bool mapIsTE)
 {
 	if (!status_db.validateStatus(type))
 		return false;
@@ -15681,7 +15681,7 @@ static bool status_readdb_status_disabled( char **str, size_t columns, size_t cu
 		return false;
 	}
 
-	SCDisabled[type] = (unsigned int)atol(str[1]);
+	SCDisabled[type] = (uint32)atol(str[1]);
 	return true;
 }
 

+ 21 - 15
src/map/status.hpp

@@ -2814,7 +2814,7 @@ enum e_joint_break : uint8 {
 };
 
 extern short current_equip_item_index;
-extern unsigned int current_equip_combo_pos;
+extern uint32 current_equip_combo_pos;
 extern int current_equip_card_id;
 extern short current_equip_opt_index;
 
@@ -3221,9 +3221,13 @@ struct weapon_atk {
 
 ///For holding basic status (which can be modified by status changes)
 struct status_data {
-	unsigned int
-		hp, sp, ap, // see status_cpy before adding members before hp and sp
-		max_hp, max_sp, max_ap;
+	// see status_cpy before adding members before hp and sp
+	uint32 hp;
+	uint32 sp;
+	uint32 ap;
+	uint32 max_hp;
+	uint32 max_sp;
+	uint32 max_ap;
 	short
 		str, agi, vit, int_, dex, luk,
 		pow, sta, wis, spl, con, crt,
@@ -3269,7 +3273,8 @@ struct regen_data_sub {
 
 	//tick accumulation before healing.
 	struct {
-		unsigned int hp,sp;
+		uint32 hp;
+		uint32 sp;
 	} tick;
 
 	//Regen rates. n/100
@@ -3286,7 +3291,8 @@ struct regen_data {
 	//tick accumulation before healing.
 	struct {
 		t_tick hp, sp; //time of last natural recovery
-		unsigned int shp,ssp;
+		uint32 shp;
+		uint32 ssp;
 	} tick;
 
 	//Regen rates. n/100
@@ -3320,8 +3326,8 @@ struct status_change_entry {
 ///Status change
 class status_change {
 public:
-	unsigned int option;// effect state (bitfield)
-	unsigned int opt3;// skill state (bitfield)
+	uint32 option;// effect state (bitfield)
+	uint32 opt3;// skill state (bitfield)
 	unsigned short opt1;// body state
 	unsigned short opt2;// health state (bitfield)
 	unsigned char count;
@@ -3403,12 +3409,12 @@ static int status_kill( struct block_list* bl ){
 	return status_percent_damage( nullptr, bl, 100, 0, 0, true );
 }
 //Used to set the hp/sp/ap of an object to an absolute value (can't kill)
-int status_set_hp(struct block_list *bl, unsigned int hp, int flag);
-int status_set_maxhp(struct block_list *bl, unsigned int hp, int flag);
-int status_set_sp(struct block_list *bl, unsigned int sp, int flag);
-int status_set_maxsp(struct block_list *bl, unsigned int hp, int flag);
-int status_set_ap(struct block_list *bl, unsigned int ap, int flag);
-int status_set_maxap(struct block_list *bl, unsigned int ap, int flag);
+int status_set_hp(struct block_list *bl, uint32 hp, int flag);
+int status_set_maxhp(struct block_list *bl, uint32 hp, int flag);
+int status_set_sp(struct block_list *bl, uint32 sp, int flag);
+int status_set_maxsp(struct block_list *bl, uint32 hp, int flag);
+int status_set_ap(struct block_list *bl, uint32 ap, int flag);
+int status_set_maxap(struct block_list *bl, uint32 ap, int flag);
 int status_heal( struct block_list *bl,int64 hhp,int64 hsp, int64 hap, int flag );
 static int status_heal( struct block_list *bl,int64 hhp,int64 hsp, int flag ){
 	return status_heal( bl, hhp, hsp, 0, flag );
@@ -3565,7 +3571,7 @@ int status_change_spread(block_list *src, block_list *bl);
 unsigned short status_base_matk_min(const struct status_data* status);
 unsigned short status_base_matk_max(const struct status_data* status);
 #else
-unsigned int status_weapon_atk(struct weapon_atk wa, map_session_data *sd);
+uint32 status_weapon_atk(struct weapon_atk wa, map_session_data *sd);
 unsigned short status_base_atk_min(struct block_list *bl, const struct status_data* status, int level);
 unsigned short status_base_atk_max(struct block_list *bl, const struct status_data* status, int level);
 unsigned short status_base_matk_min(struct block_list *bl, const struct status_data* status, int level);

+ 1 - 1
src/map/storage.cpp

@@ -83,7 +83,7 @@ static int storage_comp_item(const void *_i1, const void *_i2)
  * @param items : list of items to sort
  * @param size : number of item in list
  */
-void storage_sortitem(struct item* items, unsigned int size)
+void storage_sortitem(struct item* items, uint32 size)
 {
 	nullpo_retv(items);
 

+ 1 - 1
src/map/storage.hpp

@@ -60,7 +60,7 @@ void storage_storageaddfromcart(map_session_data *sd, struct s_storage *stor, in
 void storage_storagegettocart(map_session_data *sd, struct s_storage *stor, int index, int amount);
 void storage_storagesave(map_session_data *sd);
 void storage_storageclose(map_session_data *sd);
-void storage_sortitem(struct item* items, unsigned int size);
+void storage_sortitem(struct item* items, uint32 size);
 void do_init_storage(void);
 void do_final_storage(void);
 void do_reconnect_storage(void);

+ 1 - 1
src/map/unit.cpp

@@ -2063,7 +2063,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
 #ifndef RENEWAL_CAST
 		case KN_CHARGEATK:
 		{
-			unsigned int k = (distance_bl(src,target)-1)/3; //Range 0-3: 500ms, Range 4-6: 1000ms, Range 7+: 1500ms
+			uint32 k = (distance_bl(src,target)-1)/3; //Range 0-3: 500ms, Range 4-6: 1000ms, Range 7+: 1500ms
 			if(k > 2)
 				k = 2;
 			casttime += casttime * k;

+ 4 - 4
src/map/vending.cpp

@@ -334,7 +334,7 @@ int8 vending_openvending( map_session_data& sd, const char* message, const uint8
 	for( j = 0; j < count; j++ ) {
 		short index        = *(uint16*)(data + 8*j + 0);
 		short amount       = *(uint16*)(data + 8*j + 2);
-		unsigned int value = *(uint32*)(data + 8*j + 4);
+		uint32 value       = *(uint32*)(data + 8*j + 4);
 
 		index -= 2; // offset adjustment (client says that the first cart position is 2)
 
@@ -350,7 +350,7 @@ int8 vending_openvending( map_session_data& sd, const char* message, const uint8
 
 		sd.vending[i].index = index;
 		sd.vending[i].amount = amount;
-		sd.vending[i].value = min(value, (unsigned int)battle_config.vending_max_value);
+		sd.vending[i].value = min(value, (uint32)battle_config.vending_max_value);
 		total += static_cast<int64>(sd.vending[i].value) * amount;
 		i++; // item successfully added
 	}
@@ -449,7 +449,7 @@ bool vending_search(map_session_data* sd, t_itemid nameid)
 bool vending_searchall(map_session_data* sd, const struct s_search_store_search* s)
 {
 	int i, c, slot;
-	unsigned int idx, cidx;
+	uint32 idx, cidx;
 	struct item* it;
 
 	if( !sd->state.vending ) // not vending
@@ -489,7 +489,7 @@ bool vending_searchall(map_session_data* sd, const struct s_search_store_search*
 		}
 
 		// Check if the result set is full
-		if( s->search_sd->searchstore.items.size() >= (unsigned int)battle_config.searchstore_maxresults ){
+		if( s->search_sd->searchstore.items.size() >= (uint32)battle_config.searchstore_maxresults ){
 			return false;
 		}
 

+ 1 - 1
src/map/vending.hpp

@@ -15,7 +15,7 @@ struct s_autotrader;
 struct s_vending {
 	short index; /// cart index (return item data)
 	short amount; ///amout of the item for vending
-	unsigned int value; ///at wich price
+	uint32 value; ///at which price
 };
 
 DBMap * vending_getdb();

+ 1 - 1
src/tool/csv2yaml.hpp

@@ -65,7 +65,7 @@ std::unordered_map<uint16, s_skill_db> skill_nearnpc;
 
 std::unordered_map<int32, std::vector<s_homun_skill_tree_entry>> hom_skill_tree;
 
-static unsigned int level_penalty[3][CLASS_MAX][MAX_LEVEL * 2 + 1];
+static uint32 level_penalty[3][CLASS_MAX][MAX_LEVEL * 2 + 1];
 
 struct s_item_flag_csv2yaml {
 	bool buyingstore, dead_branch, group, guid, broadcast, bindOnEquip, delay_consume;