瀏覽代碼

Replaced NULL with nullptr (#8298)

Lemongrass3110 1 年之前
父節點
當前提交
b48948822a
共有 100 個文件被更改,包括 2731 次插入2731 次删除
  1. 221 221
      src/char/char.cpp
  2. 14 14
      src/char/char_clif.cpp
  3. 1 1
      src/char/char_cnslif.cpp
  4. 8 8
      src/char/char_logif.cpp
  5. 22 22
      src/char/char_mapif.cpp
  6. 10 10
      src/char/int_achievement.cpp
  7. 27 27
      src/char/int_auction.cpp
  8. 3 3
      src/char/int_clan.cpp
  9. 15 15
      src/char/int_elemental.cpp
  10. 49 49
      src/char/int_guild.cpp
  11. 27 27
      src/char/int_homun.cpp
  12. 38 38
      src/char/int_mail.cpp
  13. 12 12
      src/char/int_mercenary.cpp
  14. 24 24
      src/char/int_party.cpp
  15. 14 14
      src/char/int_pet.cpp
  16. 13 13
      src/char/int_quest.cpp
  17. 15 15
      src/char/int_storage.cpp
  18. 25 25
      src/char/inter.cpp
  19. 1 1
      src/common/cli.cpp
  20. 3 3
      src/common/conf.cpp
  21. 9 9
      src/common/core.cpp
  22. 124 124
      src/common/db.cpp
  23. 58 58
      src/common/db.hpp
  24. 20 20
      src/common/ers.cpp
  25. 1 1
      src/common/ers.hpp
  26. 32 32
      src/common/grfio.cpp
  27. 1 1
      src/common/grfio.hpp
  28. 32 32
      src/common/malloc.cpp
  29. 4 4
      src/common/mapindex.cpp
  30. 3 3
      src/common/msg_conf.cpp
  31. 5 5
      src/common/nullpo.cpp
  32. 12 12
      src/common/nullpo.hpp
  33. 8 8
      src/common/showmsg.cpp
  34. 18 18
      src/common/socket.cpp
  35. 33 33
      src/common/sql.cpp
  36. 1 1
      src/common/sql.hpp
  37. 21 21
      src/common/strlib.cpp
  38. 11 11
      src/common/timer.cpp
  39. 6 6
      src/common/utils.cpp
  40. 7 7
      src/common/winapi.cpp
  41. 32 32
      src/login/account.cpp
  42. 4 4
      src/login/ipban.cpp
  43. 13 13
      src/login/login.cpp
  44. 6 6
      src/login/loginchrif.cpp
  45. 1 1
      src/login/loginclif.cpp
  46. 7 7
      src/login/loginlog.cpp
  47. 8 8
      src/map/achievement.cpp
  48. 113 113
      src/map/atcommand.cpp
  49. 36 36
      src/map/battle.cpp
  50. 19 19
      src/map/buyingstore.cpp
  51. 25 25
      src/map/cashshop.cpp
  52. 46 46
      src/map/channel.cpp
  53. 10 10
      src/map/chat.cpp
  54. 27 27
      src/map/chrif.cpp
  55. 11 11
      src/map/clan.cpp
  56. 106 106
      src/map/clif.cpp
  57. 6 6
      src/map/clif.hpp
  58. 5 5
      src/map/clif_packetdb.hpp
  59. 129 129
      src/map/clif_shuffle.hpp
  60. 8 8
      src/map/date.cpp
  61. 10 10
      src/map/elemental.cpp
  62. 61 61
      src/map/guild.cpp
  63. 4 4
      src/map/homunculus.cpp
  64. 1 1
      src/map/instance.cpp
  65. 36 36
      src/map/intif.cpp
  66. 10 10
      src/map/itemdb.cpp
  67. 11 11
      src/map/log.cpp
  68. 3 3
      src/map/mail.cpp
  69. 133 133
      src/map/map.cpp
  70. 5 5
      src/map/map.hpp
  71. 11 11
      src/map/mapreg.cpp
  72. 12 12
      src/map/mercenary.cpp
  73. 58 58
      src/map/mob.cpp
  74. 3 3
      src/map/navi.cpp
  75. 93 93
      src/map/npc.cpp
  76. 38 38
      src/map/npc_chat.cpp
  77. 38 38
      src/map/party.cpp
  78. 5 5
      src/map/path.cpp
  79. 135 135
      src/map/pc.cpp
  80. 1 1
      src/map/pc.hpp
  81. 28 28
      src/map/pet.cpp
  82. 1 1
      src/map/quest.cpp
  83. 129 129
      src/map/script.cpp
  84. 5 5
      src/map/script.hpp
  85. 4 4
      src/map/searchstore.cpp
  86. 126 126
      src/map/skill.cpp
  87. 51 51
      src/map/status.cpp
  88. 17 17
      src/map/storage.cpp
  89. 6 6
      src/map/trade.cpp
  90. 66 66
      src/map/unit.cpp
  91. 17 17
      src/map/vending.cpp
  92. 14 14
      src/tool/csv2yaml.cpp
  93. 4 4
      src/tool/mapcache.cpp
  94. 8 8
      src/tool/yaml.hpp
  95. 2 2
      src/web/charconfig_controller.cpp
  96. 1 1
      src/web/emblem_controller.cpp
  97. 1 1
      src/web/merchantstore_controller.cpp
  98. 11 11
      src/web/partybooking_controller.cpp
  99. 2 2
      src/web/userconfig_controller.cpp
  100. 10 10
      src/web/web.cpp

+ 221 - 221
src/char/char.cpp

@@ -201,7 +201,7 @@ void char_set_char_offline(uint32 char_id, uint32 account_id){
 	}
 
 	//Remove char if 1- Set all offline, or 2- character is no longer connected to char-server.
-	if (char_id == -1 || character == NULL || character->fd == -1){
+	if (char_id == -1 || character == nullptr || character->fd == -1){
 		chlogif_send_setaccoffline(login_fd,account_id);
 	}
 }
@@ -594,27 +594,27 @@ int char_memitemdata_to_sql(const struct item items[], int max, int id, enum sto
 		return 1;
 	}
 
-	SqlStmt_BindColumn(stmt, 0, SQLDT_INT,       &item.id,          0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 1, SQLDT_UINT,      &item.nameid,      0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT,     &item.amount,      0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 3, SQLDT_UINT,      &item.equip,       0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR,      &item.identify,    0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR,      &item.refine,      0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR,      &item.attribute,   0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 7, SQLDT_UINT,      &item.expire_time, 0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 8, SQLDT_UINT,      &item.bound,       0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 9, SQLDT_UINT64,    &item.unique_id,   0, NULL, NULL);
-	SqlStmt_BindColumn(stmt,10, SQLDT_INT8,      &item.enchantgrade,0, NULL, NULL);
+	SqlStmt_BindColumn(stmt, 0, SQLDT_INT,       &item.id,          0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 1, SQLDT_UINT,      &item.nameid,      0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT,     &item.amount,      0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 3, SQLDT_UINT,      &item.equip,       0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR,      &item.identify,    0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR,      &item.refine,      0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR,      &item.attribute,   0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 7, SQLDT_UINT,      &item.expire_time, 0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 8, SQLDT_UINT,      &item.bound,       0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 9, SQLDT_UINT64,    &item.unique_id,   0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt,10, SQLDT_INT8,      &item.enchantgrade,0, nullptr, nullptr);
 	if (tableswitch == TABLE_INVENTORY){
-		SqlStmt_BindColumn(stmt, 11, SQLDT_CHAR, &item.favorite,    0, NULL, NULL);
-		SqlStmt_BindColumn(stmt, 12, SQLDT_UINT, &item.equipSwitch, 0, NULL, NULL);
+		SqlStmt_BindColumn(stmt, 11, SQLDT_CHAR, &item.favorite,    0, nullptr, nullptr);
+		SqlStmt_BindColumn(stmt, 12, SQLDT_UINT, &item.equipSwitch, 0, nullptr, nullptr);
 	}
 	for( i = 0; i < MAX_SLOTS; ++i )
-		SqlStmt_BindColumn(stmt, 11+offset+i, SQLDT_UINT, &item.card[i], 0, NULL, NULL);
+		SqlStmt_BindColumn(stmt, 11+offset+i, SQLDT_UINT, &item.card[i], 0, nullptr, nullptr);
 	for( i = 0; i < MAX_ITEM_RDM_OPT; ++i ) {
-		SqlStmt_BindColumn(stmt, 11+offset+MAX_SLOTS+i*3, SQLDT_SHORT, &item.option[i].id, 0, NULL, NULL);
-		SqlStmt_BindColumn(stmt, 12+offset+MAX_SLOTS+i*3, SQLDT_SHORT, &item.option[i].value, 0, NULL, NULL);
-		SqlStmt_BindColumn(stmt, 13+offset+MAX_SLOTS+i*3, SQLDT_CHAR, &item.option[i].param, 0, NULL, NULL);
+		SqlStmt_BindColumn(stmt, 11+offset+MAX_SLOTS+i*3, SQLDT_SHORT, &item.option[i].id, 0, nullptr, nullptr);
+		SqlStmt_BindColumn(stmt, 12+offset+MAX_SLOTS+i*3, SQLDT_SHORT, &item.option[i].value, 0, nullptr, nullptr);
+		SqlStmt_BindColumn(stmt, 13+offset+MAX_SLOTS+i*3, SQLDT_CHAR, &item.option[i].param, 0, nullptr, nullptr);
 	}
 	// bit array indicating which inventory items have already been matched
 	flag = (bool*) aCalloc(max, sizeof(bool));
@@ -792,7 +792,7 @@ bool char_memitemdata_from_sql(struct s_storage* p, int max, int id, enum storag
 	p->max_amount = max2;
 
 	stmt = SqlStmt_Malloc(sql_handle);
-	if (stmt == NULL) {
+	if (stmt == nullptr) {
 		SqlStmt_ShowDebug(stmt);
 		return false;
 	}
@@ -822,27 +822,27 @@ bool char_memitemdata_from_sql(struct s_storage* p, int max, int id, enum storag
 		return false;
 	}
 
-	SqlStmt_BindColumn(stmt, 0, SQLDT_INT,          &item.id,        0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 1, SQLDT_UINT,         &item.nameid,    0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT,        &item.amount,    0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 3, SQLDT_UINT,         &item.equip,     0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR,         &item.identify,  0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR,         &item.refine,    0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR,         &item.attribute, 0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 7, SQLDT_UINT,         &item.expire_time, 0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 8, SQLDT_CHAR,         &item.bound,     0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 9, SQLDT_ULONGLONG,    &item.unique_id, 0, NULL, NULL);
-	SqlStmt_BindColumn(stmt,10, SQLDT_INT8,         &item.enchantgrade, 0, NULL, NULL);
+	SqlStmt_BindColumn(stmt, 0, SQLDT_INT,          &item.id,        0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 1, SQLDT_UINT,         &item.nameid,    0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT,        &item.amount,    0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 3, SQLDT_UINT,         &item.equip,     0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR,         &item.identify,  0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR,         &item.refine,    0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR,         &item.attribute, 0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 7, SQLDT_UINT,         &item.expire_time, 0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 8, SQLDT_CHAR,         &item.bound,     0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 9, SQLDT_ULONGLONG,    &item.unique_id, 0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt,10, SQLDT_INT8,         &item.enchantgrade, 0, nullptr, nullptr);
 	if (tableswitch == TABLE_INVENTORY){
-		SqlStmt_BindColumn(stmt, 11, SQLDT_CHAR, &item.favorite,    0, NULL, NULL);
-		SqlStmt_BindColumn(stmt, 12, SQLDT_UINT, &item.equipSwitch, 0, NULL, NULL);
+		SqlStmt_BindColumn(stmt, 11, SQLDT_CHAR, &item.favorite,    0, nullptr, nullptr);
+		SqlStmt_BindColumn(stmt, 12, SQLDT_UINT, &item.equipSwitch, 0, nullptr, nullptr);
 	}
 	for( i = 0; i < MAX_SLOTS; ++i )
-		SqlStmt_BindColumn(stmt, 11+offset+i, SQLDT_UINT, &item.card[i],   0, NULL, NULL);
+		SqlStmt_BindColumn(stmt, 11+offset+i, SQLDT_UINT, &item.card[i],   0, nullptr, nullptr);
  	for( i = 0; i < MAX_ITEM_RDM_OPT; ++i ) {
-		SqlStmt_BindColumn(stmt, 11+offset+MAX_SLOTS+i*3, SQLDT_SHORT, &item.option[i].id, 0, NULL, NULL);
-		SqlStmt_BindColumn(stmt, 12+offset+MAX_SLOTS+i*3, SQLDT_SHORT, &item.option[i].value, 0, NULL, NULL);
-		SqlStmt_BindColumn(stmt, 13+offset+MAX_SLOTS+i*3, SQLDT_CHAR, &item.option[i].param, 0, NULL, NULL);
+		SqlStmt_BindColumn(stmt, 11+offset+MAX_SLOTS+i*3, SQLDT_SHORT, &item.option[i].id, 0, nullptr, nullptr);
+		SqlStmt_BindColumn(stmt, 12+offset+MAX_SLOTS+i*3, SQLDT_SHORT, &item.option[i].value, 0, nullptr, nullptr);
+		SqlStmt_BindColumn(stmt, 13+offset+MAX_SLOTS+i*3, SQLDT_CHAR, &item.option[i].param, 0, nullptr, nullptr);
  	}
 
 	for( i = 0; i < max && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i )
@@ -916,7 +916,7 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf, uint8* coun
 	char sex[2];
 
 	stmt = SqlStmt_Malloc(sql_handle);
-	if( stmt == NULL ) {
+	if( stmt == nullptr ) {
 		SqlStmt_ShowDebug(stmt);
 		return 0;
 	}
@@ -939,64 +939,64 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf, uint8* coun
 		"`inventory_slots`,`body_direction`,`disable_call`"
 		" FROM `%s` WHERE `account_id`='%d' AND `char_num` < '%d'", schema_config.char_db, sd->account_id, MAX_CHARS)
 	||	SQL_ERROR == SqlStmt_Execute(stmt)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0,  SQLDT_INT,    &p.char_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1,  SQLDT_UCHAR,  &p.slot, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2,  SQLDT_STRING, &p.name, sizeof(p.name), NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 3,  SQLDT_SHORT,  &p.class_, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 4,  SQLDT_UINT,   &p.base_level, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 5,  SQLDT_UINT,   &p.job_level, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 6,  SQLDT_UINT64, &p.base_exp, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 7,  SQLDT_UINT64, &p.job_exp, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 8,  SQLDT_INT,    &p.zeny, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 9,  SQLDT_SHORT,  &p.str, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 10, SQLDT_SHORT,  &p.agi, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 11, SQLDT_SHORT,  &p.vit, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 12, SQLDT_SHORT,  &p.int_, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 13, SQLDT_SHORT,  &p.dex, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 14, SQLDT_SHORT,  &p.luk, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 15, SQLDT_UINT,   &p.max_hp, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 16, SQLDT_UINT,   &p.hp, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 17, SQLDT_UINT,   &p.max_sp, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 18, SQLDT_UINT,   &p.sp, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 19, SQLDT_UINT,   &p.status_point, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 20, SQLDT_UINT,   &p.skill_point, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 21, SQLDT_UINT,   &p.option, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 22, SQLDT_UCHAR,  &p.karma, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 23, SQLDT_SHORT,  &p.manner, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 24, SQLDT_SHORT,  &p.hair, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 25, SQLDT_SHORT,  &p.hair_color, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 26, SQLDT_SHORT,  &p.clothes_color, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 27, SQLDT_SHORT,  &p.body, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 28, SQLDT_SHORT,  &p.weapon, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_SHORT,  &p.shield, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT,  &p.head_top, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT,  &p.head_mid, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 32, SQLDT_SHORT,  &p.head_bottom, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 33, SQLDT_STRING, &p.last_point.map, sizeof(p.last_point.map), NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 34, SQLDT_SHORT,	&p.rename, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 35, SQLDT_UINT32, &p.delete_date, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 36, SQLDT_SHORT,  &p.robe, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 37, SQLDT_UINT,   &p.character_moves, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 38, SQLDT_LONG,   &p.unban_time, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 39, SQLDT_UCHAR,  &p.font, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 40, SQLDT_UINT,   &p.uniqueitem_counter, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 41, SQLDT_ENUM,   &sex, sizeof(sex), NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 42, SQLDT_UCHAR,  &p.hotkey_rowshift, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 43, SQLDT_ULONG,  &p.title_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 44, SQLDT_UINT16, &p.show_equip, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 45, SQLDT_UCHAR,  &p.hotkey_rowshift2, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 46, SQLDT_UINT,   &p.max_ap, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 47, SQLDT_UINT,   &p.ap, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 48, SQLDT_UINT,   &p.trait_point, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 49, SQLDT_SHORT,  &p.pow, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 50, SQLDT_SHORT,  &p.sta, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 51, SQLDT_SHORT,  &p.wis, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 52, SQLDT_SHORT,  &p.spl, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 53, SQLDT_SHORT,  &p.con, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 54, SQLDT_SHORT,  &p.crt, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 55, SQLDT_UINT16, &p.inventory_slots, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 56, SQLDT_UINT8,  &p.body_direction, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 57, SQLDT_UINT16, &p.disable_call, 0, NULL, NULL)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0,  SQLDT_INT,    &p.char_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1,  SQLDT_UCHAR,  &p.slot, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2,  SQLDT_STRING, &p.name, sizeof(p.name), nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 3,  SQLDT_SHORT,  &p.class_, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 4,  SQLDT_UINT,   &p.base_level, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 5,  SQLDT_UINT,   &p.job_level, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 6,  SQLDT_UINT64, &p.base_exp, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 7,  SQLDT_UINT64, &p.job_exp, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 8,  SQLDT_INT,    &p.zeny, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 9,  SQLDT_SHORT,  &p.str, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 10, SQLDT_SHORT,  &p.agi, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 11, SQLDT_SHORT,  &p.vit, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 12, SQLDT_SHORT,  &p.int_, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 13, SQLDT_SHORT,  &p.dex, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 14, SQLDT_SHORT,  &p.luk, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 15, SQLDT_UINT,   &p.max_hp, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 16, SQLDT_UINT,   &p.hp, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 17, SQLDT_UINT,   &p.max_sp, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 18, SQLDT_UINT,   &p.sp, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 19, SQLDT_UINT,   &p.status_point, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 20, SQLDT_UINT,   &p.skill_point, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 21, SQLDT_UINT,   &p.option, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 22, SQLDT_UCHAR,  &p.karma, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 23, SQLDT_SHORT,  &p.manner, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 24, SQLDT_SHORT,  &p.hair, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 25, SQLDT_SHORT,  &p.hair_color, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 26, SQLDT_SHORT,  &p.clothes_color, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 27, SQLDT_SHORT,  &p.body, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 28, SQLDT_SHORT,  &p.weapon, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_SHORT,  &p.shield, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT,  &p.head_top, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT,  &p.head_mid, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 32, SQLDT_SHORT,  &p.head_bottom, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 33, SQLDT_STRING, &p.last_point.map, sizeof(p.last_point.map), nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 34, SQLDT_SHORT,	&p.rename, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 35, SQLDT_UINT32, &p.delete_date, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 36, SQLDT_SHORT,  &p.robe, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 37, SQLDT_UINT,   &p.character_moves, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 38, SQLDT_LONG,   &p.unban_time, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 39, SQLDT_UCHAR,  &p.font, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 40, SQLDT_UINT,   &p.uniqueitem_counter, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 41, SQLDT_ENUM,   &sex, sizeof(sex), nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 42, SQLDT_UCHAR,  &p.hotkey_rowshift, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 43, SQLDT_ULONG,  &p.title_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 44, SQLDT_UINT16, &p.show_equip, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 45, SQLDT_UCHAR,  &p.hotkey_rowshift2, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 46, SQLDT_UINT,   &p.max_ap, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 47, SQLDT_UINT,   &p.ap, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 48, SQLDT_UINT,   &p.trait_point, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 49, SQLDT_SHORT,  &p.pow, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 50, SQLDT_SHORT,  &p.sta, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 51, SQLDT_SHORT,  &p.wis, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 52, SQLDT_SHORT,  &p.spl, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 53, SQLDT_SHORT,  &p.con, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 54, SQLDT_SHORT,  &p.crt, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 55, SQLDT_UINT16, &p.inventory_slots, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 56, SQLDT_UINT8,  &p.body_direction, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 57, SQLDT_UINT16, &p.disable_call, 0, nullptr, nullptr)
 	)
 	{
 		SqlStmt_ShowDebug(stmt);
@@ -1046,7 +1046,7 @@ int char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_ev
 	if (charserv_config.save_log) ShowInfo("Char load request (%d)\n", char_id);
 
 	stmt = SqlStmt_Malloc(sql_handle);
-	if( stmt == NULL )
+	if( stmt == nullptr )
 	{
 		SqlStmt_ShowDebug(stmt);
 		return 0;
@@ -1065,82 +1065,82 @@ int char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_ev
 		" FROM `%s` WHERE `char_id`=? LIMIT 1", schema_config.char_db)
 	||	SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
 	||	SQL_ERROR == SqlStmt_Execute(stmt)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0,  SQLDT_INT,    &p->char_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1,  SQLDT_INT,    &p->account_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2,  SQLDT_UCHAR,  &p->slot, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 3,  SQLDT_STRING, &p->name, sizeof(p->name), NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 4,  SQLDT_SHORT,  &p->class_, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 5,  SQLDT_UINT,   &p->base_level, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 6,  SQLDT_UINT,   &p->job_level, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 7,  SQLDT_UINT64, &p->base_exp, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 8,  SQLDT_UINT64, &p->job_exp, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 9,  SQLDT_INT,    &p->zeny, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 10, SQLDT_SHORT,  &p->str, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 11, SQLDT_SHORT,  &p->agi, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 12, SQLDT_SHORT,  &p->vit, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 13, SQLDT_SHORT,  &p->int_, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 14, SQLDT_SHORT,  &p->dex, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 15, SQLDT_SHORT,  &p->luk, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 16, SQLDT_UINT,   &p->max_hp, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 17, SQLDT_UINT,   &p->hp, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 18, SQLDT_UINT,   &p->max_sp, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 19, SQLDT_UINT,   &p->sp, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 20, SQLDT_UINT,   &p->status_point, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 21, SQLDT_UINT,   &p->skill_point, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 22, SQLDT_UINT,   &p->option, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 23, SQLDT_UCHAR,  &p->karma, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 24, SQLDT_SHORT,  &p->manner, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 25, SQLDT_INT,    &p->party_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 26, SQLDT_INT,    &p->guild_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 27, SQLDT_INT,    &p->pet_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 28, SQLDT_INT,    &p->hom_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_INT,    &p->ele_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT,  &p->hair, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT,  &p->hair_color, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 32, SQLDT_SHORT,  &p->clothes_color, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 33, SQLDT_SHORT,  &p->body, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 34, SQLDT_SHORT,  &p->weapon, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 35, SQLDT_SHORT,  &p->shield, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 36, SQLDT_SHORT,  &p->head_top, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 37, SQLDT_SHORT,  &p->head_mid, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 38, SQLDT_SHORT,  &p->head_bottom, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 39, SQLDT_STRING, &p->last_point.map, sizeof(p->last_point.map), NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 40, SQLDT_SHORT,  &p->last_point.x, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 41, SQLDT_SHORT,  &p->last_point.y, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 42, SQLDT_STRING, &p->save_point.map, sizeof(p->save_point.map), NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 43, SQLDT_SHORT,  &p->save_point.x, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 44, SQLDT_SHORT,  &p->save_point.y, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 45, SQLDT_UINT32,    &p->partner_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 46, SQLDT_UINT32,    &p->father, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 47, SQLDT_UINT32,    &p->mother, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 48, SQLDT_UINT32,    &p->child, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 49, SQLDT_INT,    &p->fame, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 50, SQLDT_SHORT,  &p->rename, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 51, SQLDT_UINT32, &p->delete_date, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 52, SQLDT_SHORT,  &p->robe, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 53, SQLDT_UINT32, &p->character_moves, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 54, SQLDT_LONG,   &p->unban_time, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 55, SQLDT_UCHAR,  &p->font, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 56, SQLDT_UINT,   &p->uniqueitem_counter, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 57, SQLDT_ENUM,   &sex, sizeof(sex), NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 58, SQLDT_UCHAR,  &p->hotkey_rowshift, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 59, SQLDT_INT,    &p->clan_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 60, SQLDT_ULONG,  &p->title_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 61, SQLDT_UINT16, &p->show_equip, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 62, SQLDT_UCHAR,  &p->hotkey_rowshift2, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 63, SQLDT_UINT,   &p->max_ap, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 64, SQLDT_UINT,   &p->ap, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 65, SQLDT_UINT,   &p->trait_point, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 66, SQLDT_SHORT,  &p->pow, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 67, SQLDT_SHORT,  &p->sta, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 68, SQLDT_SHORT,  &p->wis, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 69, SQLDT_SHORT,  &p->spl, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 70, SQLDT_SHORT,  &p->con, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 71, SQLDT_SHORT,  &p->crt, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 72, SQLDT_UINT16, &p->inventory_slots, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 73, SQLDT_UINT8,  &p->body_direction, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 74, SQLDT_UINT8,	&p->disable_call, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 75, SQLDT_INT,    &p->last_point_instanceid, 0, NULL, NULL)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0,  SQLDT_INT,    &p->char_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1,  SQLDT_INT,    &p->account_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2,  SQLDT_UCHAR,  &p->slot, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 3,  SQLDT_STRING, &p->name, sizeof(p->name), nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 4,  SQLDT_SHORT,  &p->class_, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 5,  SQLDT_UINT,   &p->base_level, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 6,  SQLDT_UINT,   &p->job_level, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 7,  SQLDT_UINT64, &p->base_exp, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 8,  SQLDT_UINT64, &p->job_exp, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 9,  SQLDT_INT,    &p->zeny, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 10, SQLDT_SHORT,  &p->str, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 11, SQLDT_SHORT,  &p->agi, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 12, SQLDT_SHORT,  &p->vit, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 13, SQLDT_SHORT,  &p->int_, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 14, SQLDT_SHORT,  &p->dex, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 15, SQLDT_SHORT,  &p->luk, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 16, SQLDT_UINT,   &p->max_hp, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 17, SQLDT_UINT,   &p->hp, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 18, SQLDT_UINT,   &p->max_sp, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 19, SQLDT_UINT,   &p->sp, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 20, SQLDT_UINT,   &p->status_point, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 21, SQLDT_UINT,   &p->skill_point, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 22, SQLDT_UINT,   &p->option, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 23, SQLDT_UCHAR,  &p->karma, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 24, SQLDT_SHORT,  &p->manner, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 25, SQLDT_INT,    &p->party_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 26, SQLDT_INT,    &p->guild_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 27, SQLDT_INT,    &p->pet_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 28, SQLDT_INT,    &p->hom_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 29, SQLDT_INT,    &p->ele_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 30, SQLDT_SHORT,  &p->hair, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 31, SQLDT_SHORT,  &p->hair_color, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 32, SQLDT_SHORT,  &p->clothes_color, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 33, SQLDT_SHORT,  &p->body, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 34, SQLDT_SHORT,  &p->weapon, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 35, SQLDT_SHORT,  &p->shield, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 36, SQLDT_SHORT,  &p->head_top, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 37, SQLDT_SHORT,  &p->head_mid, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 38, SQLDT_SHORT,  &p->head_bottom, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 39, SQLDT_STRING, &p->last_point.map, sizeof(p->last_point.map), nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 40, SQLDT_SHORT,  &p->last_point.x, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 41, SQLDT_SHORT,  &p->last_point.y, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 42, SQLDT_STRING, &p->save_point.map, sizeof(p->save_point.map), nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 43, SQLDT_SHORT,  &p->save_point.x, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 44, SQLDT_SHORT,  &p->save_point.y, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 45, SQLDT_UINT32,    &p->partner_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 46, SQLDT_UINT32,    &p->father, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 47, SQLDT_UINT32,    &p->mother, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 48, SQLDT_UINT32,    &p->child, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 49, SQLDT_INT,    &p->fame, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 50, SQLDT_SHORT,  &p->rename, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 51, SQLDT_UINT32, &p->delete_date, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 52, SQLDT_SHORT,  &p->robe, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 53, SQLDT_UINT32, &p->character_moves, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 54, SQLDT_LONG,   &p->unban_time, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 55, SQLDT_UCHAR,  &p->font, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 56, SQLDT_UINT,   &p->uniqueitem_counter, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 57, SQLDT_ENUM,   &sex, sizeof(sex), nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 58, SQLDT_UCHAR,  &p->hotkey_rowshift, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 59, SQLDT_INT,    &p->clan_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 60, SQLDT_ULONG,  &p->title_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 61, SQLDT_UINT16, &p->show_equip, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 62, SQLDT_UCHAR,  &p->hotkey_rowshift2, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 63, SQLDT_UINT,   &p->max_ap, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 64, SQLDT_UINT,   &p->ap, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 65, SQLDT_UINT,   &p->trait_point, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 66, SQLDT_SHORT,  &p->pow, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 67, SQLDT_SHORT,  &p->sta, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 68, SQLDT_SHORT,  &p->wis, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 69, SQLDT_SHORT,  &p->spl, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 70, SQLDT_SHORT,  &p->con, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 71, SQLDT_SHORT,  &p->crt, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 72, SQLDT_UINT16, &p->inventory_slots, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 73, SQLDT_UINT8,  &p->body_direction, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 74, SQLDT_UINT8,	&p->disable_call, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 75, SQLDT_INT,    &p->last_point_instanceid, 0, nullptr, nullptr)
 	)
 	{
 		SqlStmt_ShowDebug(stmt);
@@ -1153,7 +1153,7 @@ int char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_ev
 		SqlStmt_Free(stmt);
 		return 0;
 	}
-	p->sex = char_mmo_gender(NULL, p, sex[0]);
+	p->sex = char_mmo_gender(nullptr, p, sex[0]);
 
 	StringBuf_Init(&msg_buf);
 	StringBuf_AppendStr(&msg_buf, " status");
@@ -1170,9 +1170,9 @@ int char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_ev
 	if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `map`,`x`,`y` FROM `%s` WHERE `char_id`=? ORDER by `memo_id` LIMIT %d", schema_config.memo_db, MAX_MEMOPOINTS)
 	||	SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
 	||	SQL_ERROR == SqlStmt_Execute(stmt)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &tmp_point.map, sizeof(tmp_point.map), NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT,  &tmp_point.x, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT,  &tmp_point.y, 0, NULL, NULL) )
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &tmp_point.map, sizeof(tmp_point.map), nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT,  &tmp_point.x, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT,  &tmp_point.y, 0, nullptr, nullptr) )
 		SqlStmt_ShowDebug(stmt);
 
 	for( i = 0; i < MAX_MEMOPOINTS && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i )
@@ -1186,9 +1186,9 @@ int char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_ev
 	if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `id`, `lv`,`flag` FROM `%s` WHERE `char_id`=? LIMIT %d", schema_config.skill_db, MAX_SKILL)
 		||	SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
 		||	SQL_ERROR == SqlStmt_Execute(stmt)
-		||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_UINT16, &tmp_skill.id  , 0, NULL, NULL)
-		||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_UINT8 , &tmp_skill.lv  , 0, NULL, NULL)
-		||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT8 , &tmp_skill.flag, 0, NULL, NULL) )
+		||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_UINT16, &tmp_skill.id  , 0, nullptr, nullptr)
+		||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_UINT8 , &tmp_skill.lv  , 0, nullptr, nullptr)
+		||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT8 , &tmp_skill.flag, 0, nullptr, nullptr) )
 		SqlStmt_ShowDebug(stmt);
 
 	if( tmp_skill.flag != SKILL_FLAG_PERM_GRANTED )
@@ -1209,9 +1209,9 @@ int char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_ev
 	if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT c.`account_id`, c.`char_id`, c.`name` FROM `%s` c LEFT JOIN `%s` f ON f.`friend_id` = c.`char_id` WHERE f.`char_id`=? LIMIT %d", schema_config.char_db, schema_config.friend_db, MAX_FRIENDS)
 	||	SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
 	||	SQL_ERROR == SqlStmt_Execute(stmt)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT,    &tmp_friend.account_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT,    &tmp_friend.char_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &tmp_friend.name, sizeof(tmp_friend.name), NULL, NULL) )
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT,    &tmp_friend.account_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT,    &tmp_friend.char_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &tmp_friend.name, sizeof(tmp_friend.name), nullptr, nullptr) )
 		SqlStmt_ShowDebug(stmt);
 
 	for( i = 0; i < MAX_FRIENDS && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i )
@@ -1224,10 +1224,10 @@ int char_mmo_char_fromsql(uint32 char_id, struct mmo_charstatus* p, bool load_ev
 	if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `hotkey`, `type`, `itemskill_id`, `skill_lvl` FROM `%s` WHERE `char_id`=?", schema_config.hotkey_db)
 	||	SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
 	||	SQL_ERROR == SqlStmt_Execute(stmt)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT,    &hotkey_num, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_UCHAR,  &tmp_hotkey.type, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT,   &tmp_hotkey.id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &tmp_hotkey.lv, 0, NULL, NULL) )
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT,    &hotkey_num, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_UCHAR,  &tmp_hotkey.type, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT,   &tmp_hotkey.id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_USHORT, &tmp_hotkey.lv, 0, nullptr, nullptr) )
 		SqlStmt_ShowDebug(stmt);
 
 	while( SQL_SUCCESS == SqlStmt_NextRow(stmt) )
@@ -1378,13 +1378,13 @@ int char_check_char_name(char * name, char * esc_name)
 	if( charserv_config.char_config.char_name_option == 1 )
 	{ // only letters/symbols in char_name_letters are authorised
 		for( i = 0; i < NAME_LENGTH && name[i]; i++ )
-			if( strchr(charserv_config.char_config.char_name_letters, name[i]) == NULL )
+			if( strchr(charserv_config.char_config.char_name_letters, name[i]) == nullptr )
 				return -2;
 	}
 	else if( charserv_config.char_config.char_name_option == 2 )
 	{ // letters/symbols in char_name_letters are forbidden
 		for( i = 0; i < NAME_LENGTH && name[i]; i++ )
-			if( strchr(charserv_config.char_config.char_name_letters, name[i]) != NULL )
+			if( strchr(charserv_config.char_config.char_name_letters, name[i]) != nullptr )
 				return -2;
 	}
 	if( charserv_config.char_config.name_ignoring_case ) {
@@ -1589,16 +1589,16 @@ enum e_char_del_response char_delete(struct char_session_data* sd, uint32 char_i
 	}
 
 	Sql_GetData(sql_handle, 0, &data, &len); safestrncpy(name, data, NAME_LENGTH);
-	Sql_GetData(sql_handle, 1, &data, NULL); account_id = atoi(data);
-	Sql_GetData(sql_handle, 2, &data, NULL); party_id = atoi(data);
-	Sql_GetData(sql_handle, 3, &data, NULL); guild_id = atoi(data);
-	Sql_GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
-	Sql_GetData(sql_handle, 5, &data, NULL); hom_id = atoi(data);
-	Sql_GetData(sql_handle, 6, &data, NULL); partner_id = atoi(data);
-	Sql_GetData(sql_handle, 7, &data, NULL); father_id = atoi(data);
-	Sql_GetData(sql_handle, 8, &data, NULL); mother_id = atoi(data);
-	Sql_GetData(sql_handle, 9, &data, NULL); elemental_id = atoi(data);
-	Sql_GetData(sql_handle,10, &data, NULL); delete_date = strtoul(data, NULL, 10);
+	Sql_GetData(sql_handle, 1, &data, nullptr); account_id = atoi(data);
+	Sql_GetData(sql_handle, 2, &data, nullptr); party_id = atoi(data);
+	Sql_GetData(sql_handle, 3, &data, nullptr); guild_id = atoi(data);
+	Sql_GetData(sql_handle, 4, &data, nullptr); base_level = atoi(data);
+	Sql_GetData(sql_handle, 5, &data, nullptr); hom_id = atoi(data);
+	Sql_GetData(sql_handle, 6, &data, nullptr); partner_id = atoi(data);
+	Sql_GetData(sql_handle, 7, &data, nullptr); father_id = atoi(data);
+	Sql_GetData(sql_handle, 8, &data, nullptr); mother_id = atoi(data);
+	Sql_GetData(sql_handle, 9, &data, nullptr); elemental_id = atoi(data);
+	Sql_GetData(sql_handle,10, &data, nullptr); delete_date = strtoul(data, nullptr, 10);
 
 	Sql_EscapeStringLen(sql_handle, esc_name, name, zmin(len, NAME_LENGTH));
 	Sql_FreeResult(sql_handle);
@@ -1623,7 +1623,7 @@ enum e_char_del_response char_delete(struct char_session_data* sd, uint32 char_i
 		return CHAR_DELETE_PARTY;
 	}
 
-	if( charserv_config.char_config.char_del_delay > 0 && ( !delete_date || delete_date > time(NULL) ) ){ // not queued or delay not yet passed
+	if( charserv_config.char_config.char_del_delay > 0 && ( !delete_date || delete_date > time(nullptr) ) ){ // not queued or delay not yet passed
 		ShowInfo("Char deletion aborted: %s, Time was not set or has not been reached ye\n", name );
 		return CHAR_DELETE_TIME;
 	}
@@ -1792,7 +1792,7 @@ int char_count_users(void)
 // Used in packets 0x6b (chars info) and 0x6d (new char info)
 // Returns the size
 int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p){
-	if( buffer == NULL || p == NULL )
+	if( buffer == nullptr || p == nullptr )
 		return 0;
 
 	struct CHARACTER_INFO* info = (struct CHARACTER_INFO*)buffer;
@@ -1851,7 +1851,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p){
 #endif
 #if PACKETVER >= 20100803
 #if PACKETVER_CHAR_DELETEDATE
-	info->DelRevDate = ( p->delete_date ? TOL( p->delete_date - time( NULL ) ) : 0 );
+	info->DelRevDate = ( p->delete_date ? TOL( p->delete_date - time( nullptr ) ) : 0 );
 #else
 	info->DelRevDate = TOL( p->delete_date );
 #endif
@@ -1887,7 +1887,7 @@ int char_married(int pl1, int pl2)
 	{
 		char* data;
 
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		if( pl2 == atoi(data) )
 		{
 			Sql_FreeResult(sql_handle);
@@ -1908,7 +1908,7 @@ int char_child(int parent_id, int child_id)
 	{
 		char* data;
 
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		if( child_id == atoi(data) )
 		{
 			Sql_FreeResult(sql_handle);
@@ -1932,9 +1932,9 @@ int char_family(int cid1, int cid2, int cid3)
 		int childid;
 		char* data;
 
-		Sql_GetData(sql_handle, 0, &data, NULL); charid = atoi(data);
-		Sql_GetData(sql_handle, 1, &data, NULL); partnerid = atoi(data);
-		Sql_GetData(sql_handle, 2, &data, NULL); childid = atoi(data);
+		Sql_GetData(sql_handle, 0, &data, nullptr); charid = atoi(data);
+		Sql_GetData(sql_handle, 1, &data, nullptr); partnerid = atoi(data);
+		Sql_GetData(sql_handle, 2, &data, nullptr); childid = atoi(data);
 
 		if( (cid1 == charid    && ((cid2 == partnerid && cid3 == childid  ) || (cid2 == childid   && cid3 == partnerid))) ||
 			(cid1 == partnerid && ((cid2 == charid    && cid3 == childid  ) || (cid2 == childid   && cid3 == charid   ))) ||
@@ -2029,7 +2029,7 @@ void char_read_fame_list(void)
 	for( i = 0; i < fame_list_size_smith && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
 	{
 		// char_id
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		smith_fame_list[i].id = atoi(data);
 		// fame
 		Sql_GetData(sql_handle, 1, &data, &len);
@@ -2044,7 +2044,7 @@ void char_read_fame_list(void)
 	for( i = 0; i < fame_list_size_chemist && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
 	{
 		// char_id
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		chemist_fame_list[i].id = atoi(data);
 		// fame
 		Sql_GetData(sql_handle, 1, &data, &len);
@@ -2059,7 +2059,7 @@ void char_read_fame_list(void)
 	for( i = 0; i < fame_list_size_taekwon && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
 	{
 		// char_id
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		taekwon_fame_list[i].id = atoi(data);
 		// fame
 		Sql_GetData(sql_handle, 1, &data, &len);
@@ -2249,7 +2249,7 @@ int char_lan_config_read(const char *lancfgName) {
 	int line_num = 0, s_subnet=ARRAYLENGTH(subnet);
 	char line[1024], w1[64], w2[64], w3[64], w4[64];
 
-	if((fp = fopen(lancfgName, "r")) == NULL) {
+	if((fp = fopen(lancfgName, "r")) == nullptr) {
 		ShowWarning("LAN Support configuration file is not found: %s\n", lancfgName);
 		return 1;
 	}
@@ -2567,7 +2567,7 @@ void char_sql_config_read(const char* cfgName) {
 	char line[1024], w1[1024], w2[1024];
 	FILE* fp;
 
-	if ((fp = fopen(cfgName, "r")) == NULL) {
+	if ((fp = fopen(cfgName, "r")) == nullptr) {
 		ShowError("File not found: %s\n", cfgName);
 		return;
 	}
@@ -2826,17 +2826,17 @@ void char_config_split_startpoint( char* w1_value, char* w2_value, struct s_poin
 	(*count) = 0; // Reset to begin reading
 
 	fields = (char **)aMalloc(fields_length * sizeof(char *));
-	if (fields == NULL)
+	if (fields == nullptr)
 		return; // Failed to allocate memory.
 	lineitem = strtok(w2_value, ":");
 
-	while (lineitem != NULL && (*count) < MAX_STARTPOINT) {
+	while (lineitem != nullptr && (*count) < MAX_STARTPOINT) {
 		bool error;
 		size_t n = sv_split( lineitem, strlen( lineitem ), 0, ',', fields, fields_length, SV_NOESCAPE_NOTERMINATE, error );
 
 		if( error || ( n + 1 ) < fields_length ){
 			ShowDebug("%s: not enough arguments for %s! Skipping...\n", w1_value, lineitem);
-			lineitem = strtok(NULL, ":"); //next lineitem
+			lineitem = strtok(nullptr, ":"); //next lineitem
 			continue;
 		}
 
@@ -2845,7 +2845,7 @@ void char_config_split_startpoint( char* w1_value, char* w2_value, struct s_poin
 		start_point[i].y = max( 0, atoi( fields[3] ) );
 		(*count)++;
 
-		lineitem = strtok(NULL, ":"); //next lineitem
+		lineitem = strtok(nullptr, ":"); //next lineitem
 		i++;
 	}
 	aFree(fields);
@@ -2864,17 +2864,17 @@ void char_config_split_startitem(char *w1_value, char *w2_value, struct startite
 	size_t fields_length = 3 + 1;
 
 	fields = (char **)aMalloc(fields_length * sizeof(char *));
-	if (fields == NULL)
+	if (fields == nullptr)
 		return; // Failed to allocate memory.
 	lineitem = strtok(w2_value, ":");
 
-	while (lineitem != NULL && i < MAX_STARTITEM) {
+	while (lineitem != nullptr && i < MAX_STARTITEM) {
 		bool error;
 		size_t n = sv_split( lineitem, strlen( lineitem ), 0, ',', fields, fields_length, SV_NOESCAPE_NOTERMINATE, error );
 
 		if( error || ( n + 1 ) < fields_length ){
 			ShowDebug("%s: not enough arguments for %s! Skipping...\n", w1_value, lineitem);
-			lineitem = strtok(NULL, ":"); //next lineitem
+			lineitem = strtok(nullptr, ":"); //next lineitem
 			continue;
 		}
 
@@ -2884,7 +2884,7 @@ void char_config_split_startitem(char *w1_value, char *w2_value, struct startite
 		start_items[i].amount = min( (uint16)strtoul( fields[2], nullptr, 10 ), MAX_AMOUNT );
 		start_items[i].pos = strtoul( fields[3], nullptr, 10 );
 
-		lineitem = strtok(NULL, ":"); //next lineitem
+		lineitem = strtok(nullptr, ":"); //next lineitem
 		i++;
 	}
 	aFree(fields);
@@ -2894,7 +2894,7 @@ bool char_config_read(const char* cfgName, bool normal){
 	char line[1024], w1[1024], w2[1024];
 	FILE* fp = fopen(cfgName, "r");
 
-	if (fp == NULL) {
+	if (fp == nullptr) {
 		ShowError("Configuration file not found: %s.\n", cfgName);
 		return false;
 	}
@@ -3242,7 +3242,7 @@ bool CharacterServer::initialize( int argc, char *argv[] ){
 		ShowFatalError("char : A tables is missing in sql-server, please fix it, see (sql-files main.sql for structure) \n");
 		return false;
 	}
-	//Cleaning the tables for NULL entrys @ startup [Sirius]
+	//Cleaning the tables for nullptr entrys @ startup [Sirius]
 	//Chardb clean
 	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '0'", schema_config.char_db) )
 		Sql_ShowDebug(sql_handle);

+ 14 - 14
src/char/char_clif.cpp

@@ -452,7 +452,7 @@ void chclif_char_delete2_ack(int fd, uint32 char_id, uint32 result, time_t delet
 	WFIFOL(fd,2) = char_id;
 	WFIFOL(fd,6) = result;
 #if PACKETVER_CHAR_DELETEDATE
-	WFIFOL(fd,10) = TOL(delete_date-time(NULL));
+	WFIFOL(fd,10) = TOL(delete_date-time(nullptr));
 #else
 	WFIFOL(fd,10) = TOL(delete_date);
 #endif
@@ -522,9 +522,9 @@ int chclif_parse_char_delete2_req(int fd, struct char_session_data* sd) {
 			return 1;
 		}
 
-		Sql_GetData(sql_handle, 0, &data, NULL); delete_date = strtoul(data, NULL, 10);
-		Sql_GetData(sql_handle, 1, &data, NULL); party_id    = strtoul(data, NULL, 10);
-		Sql_GetData(sql_handle, 2, &data, NULL); guild_id    = strtoul(data, NULL, 10);
+		Sql_GetData(sql_handle, 0, &data, nullptr); delete_date = strtoul(data, nullptr, 10);
+		Sql_GetData(sql_handle, 1, &data, nullptr); party_id    = strtoul(data, nullptr, 10);
+		Sql_GetData(sql_handle, 2, &data, nullptr); guild_id    = strtoul(data, nullptr, 10);
 
 		if( delete_date ) {// character already queued for deletion
 			chclif_char_delete2_ack(fd, char_id, 0, 0);
@@ -544,7 +544,7 @@ int chclif_parse_char_delete2_req(int fd, struct char_session_data* sd) {
 		}
 		
 		// success
-		delete_date = time(NULL)+(charserv_config.char_config.char_del_delay);
+		delete_date = time(nullptr)+(charserv_config.char_config.char_del_delay);
 
 		if( SQL_SUCCESS != Sql_Query(sql_handle, "UPDATE `%s` SET `delete_date`='%lu' WHERE `char_id`='%d'", schema_config.char_db, (unsigned long)delete_date, char_id) )
 		{
@@ -853,7 +853,7 @@ int chclif_parse_select_accessible_map( int fd, struct char_session_data* sd, ui
 	}
 
 	/* client doesn't let it get to this point if you're banned, so its a forged packet */
-	if( sd->found_char[p.slot] == char_id && sd->unban_time[p.slot] > time(NULL) ) {
+	if( sd->found_char[p.slot] == char_id && sd->unban_time[p.slot] > time(nullptr) ) {
 		chclif_reject( fd, 0 ); // rejected from server
 		return 1;
 	}
@@ -1000,7 +1000,7 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){
 		// Check if the character exists and is not scheduled for deletion
 		if ( SQL_SUCCESS != Sql_Query(sql_handle, "SELECT `char_id` FROM `%s` WHERE `account_id`='%d' AND `char_num`='%d' AND `delete_date` = 0", schema_config.char_db, sd->account_id, slot)
 		  || SQL_SUCCESS != Sql_NextRow(sql_handle)
-		  || SQL_SUCCESS != Sql_GetData(sql_handle, 0, &data, NULL) )
+		  || SQL_SUCCESS != Sql_GetData(sql_handle, 0, &data, nullptr) )
 		{	//Not found?? May be forged packet.
 			Sql_ShowDebug(sql_handle);
 			Sql_FreeResult(sql_handle);
@@ -1018,7 +1018,7 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){
 		}
 
 		/* client doesn't let it get to this point if you're banned, so its a forged packet */
-		if( sd->found_char[slot] == char_id && sd->unban_time[slot] > time(NULL) ) {
+		if( sd->found_char[slot] == char_id && sd->unban_time[slot] > time(nullptr) ) {
 			chclif_reject(fd, 0); // rejected from server
 			return 1;
 		}
@@ -1087,7 +1087,7 @@ int chclif_parse_charselect(int fd, struct char_session_data* sd,uint32 ipl){
 
 		//Send NEW auth packet [Kevin]
 		//FIXME: is this case even possible? [ultramage]
-		if ((map_fd = map_server[i].fd) < 1 || session[map_fd] == NULL)
+		if ((map_fd = map_server[i].fd) < 1 || session[map_fd] == nullptr)
 		{
 			ShowError("parse_char: Attempting to write to invalid session %d! Map Server #%d disconnected.\n", map_fd, i);
 			map_server[i] = {};
@@ -1348,11 +1348,11 @@ int chclif_parse_reqrename( int fd, struct char_session_data* sd ){
 
 
 TIMER_FUNC(charblock_timer){
-	struct char_session_data* sd=NULL;
+	struct char_session_data* sd=nullptr;
 	int i=0;
 	ARR_FIND( 0, fd_max, i, session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == id);
 
-	if(sd == NULL || sd->charblock_timer==INVALID_TIMER) //has disconected or was required to stop
+	if(sd == nullptr || sd->charblock_timer==INVALID_TIMER) //has disconected or was required to stop
 		return 0;
 	if (sd->charblock_timer != tid){
 		sd->charblock_timer = INVALID_TIMER;
@@ -1368,7 +1368,7 @@ TIMER_FUNC(charblock_timer){
  */
 void chclif_block_character( int fd, struct char_session_data* sd){
 	int i=0, j=0, len=4;
-	time_t now = time(NULL);
+	time_t now = time(nullptr);
 
 	WFIFOHEAD(fd, 4+MAX_CHARS*24);
 	WFIFOW(fd, 0) = 0x20d;
@@ -1532,7 +1532,7 @@ int chclif_parse(int fd) {
 		set_eof(fd);
 
 	if(session[fd]->flag.eof) {
-		if( sd != NULL && sd->auth ) { // already authed client
+		if( sd != nullptr && sd->auth ) { // already authed client
 			std::shared_ptr<struct online_char_data> data = util::umap_find( char_get_onlinedb(), sd->account_id );
 
 			if( data != nullptr && data->fd == fd ){
@@ -1596,7 +1596,7 @@ int chclif_parse(int fd) {
 				break;
 			// unknown packet received
 			default:
-				ShowError("parse_char: Received unknown packet " CL_WHITE "0x%x" CL_RESET " from ip '" CL_WHITE "%s" CL_RESET "'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, NULL));
+				ShowError("parse_char: Received unknown packet " CL_WHITE "0x%x" CL_RESET " from ip '" CL_WHITE "%s" CL_RESET "'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, nullptr));
 				set_eof(fd);
 				return 0;
 		}

+ 1 - 1
src/char/char_cnslif.cpp

@@ -47,7 +47,7 @@ TIMER_FUNC(cnslif_console_timer){
 	memset(buf,0,MAX_CONSOLE_IN); //clear out buf
 
 	if(cli_hasevent()){
-		if(fgets(buf, MAX_CONSOLE_IN, stdin)==NULL)
+		if(fgets(buf, MAX_CONSOLE_IN, stdin)==nullptr)
 			return -1;
 		else if(strlen(buf)>MIN_CONSOLE_IN)
 			cnslif_parse(buf);

+ 8 - 8
src/char/char_logif.cpp

@@ -62,7 +62,7 @@ void chlogif_pincode_start(int fd, struct char_session_data* sd){
 			}
 		}else{
 			if( !(charserv_config.pincode_config.pincode_changetime)
-			|| ( sd->pincode_change + charserv_config.pincode_config.pincode_changetime ) > time(NULL) ){
+			|| ( sd->pincode_change + charserv_config.pincode_config.pincode_changetime ) > time(nullptr) ){
 				std::shared_ptr<struct online_char_data> node = util::umap_find( char_get_onlinedb(), sd->account_id );
 
 				if( node != nullptr && node->pincode_success ){
@@ -491,9 +491,9 @@ int chlogif_parse_ackchangesex(int fd)
 				SqlStmt_Free(stmt);
 			}
 
-			SqlStmt_BindColumn(stmt, 0, SQLDT_INT,   &char_id,  0, NULL, NULL);
-			SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &class_,   0, NULL, NULL);
-			SqlStmt_BindColumn(stmt, 2, SQLDT_INT,   &guild_id, 0, NULL, NULL);
+			SqlStmt_BindColumn(stmt, 0, SQLDT_INT,   &char_id,  0, nullptr, nullptr);
+			SqlStmt_BindColumn(stmt, 1, SQLDT_SHORT, &class_,   0, nullptr, nullptr);
+			SqlStmt_BindColumn(stmt, 2, SQLDT_INT,   &guild_id, 0, nullptr, nullptr);
 
 			for (i = 0; i < MAX_CHARS && SQL_SUCCESS == SqlStmt_NextRow(stmt); ++i) {
 				chlogif_parse_change_sex_sub(sex, acc, char_id, class_, guild_id);
@@ -536,9 +536,9 @@ int chlogif_parse_ackchangecharsex(int char_id, int sex)
 		return 1;
 	}
 
-	Sql_GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
-	Sql_GetData(sql_handle, 1, &data, NULL); class_ = atoi(data);
-	Sql_GetData(sql_handle, 2, &data, NULL); guild_id = atoi(data);
+	Sql_GetData(sql_handle, 0, &data, nullptr); account_id = atoi(data);
+	Sql_GetData(sql_handle, 1, &data, nullptr); class_ = atoi(data);
+	Sql_GetData(sql_handle, 2, &data, nullptr); guild_id = atoi(data);
 	Sql_FreeResult(sql_handle);
 
 	chlogif_parse_change_sex_sub(sex, account_id, char_id, class_, guild_id);
@@ -722,7 +722,7 @@ int chlogif_parse_AccInfoAck(int fd) {
 	else {
 		int8 type = RFIFOB(fd, 18);
 		if (type == 0 || RFIFOREST(fd) < 122+NAME_LENGTH) {
-			mapif_accinfo_ack(false, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), 0, -1, 0, 0, NULL, NULL, NULL, NULL, NULL);
+			mapif_accinfo_ack(false, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), 0, -1, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr);
 			RFIFOSKIP(fd,19);
 			return 1;
 		}

+ 22 - 22
src/char/char_mapif.cpp

@@ -305,12 +305,12 @@ int chmapif_parse_askscdata(int fd){
 			WFIFOL(fd,8) = cid;
 			for( count = 0; count < 50 && SQL_SUCCESS == Sql_NextRow(sql_handle); ++count )
 			{
-				Sql_GetData(sql_handle, 0, &data, NULL); scdata.type = atoi(data);
-				Sql_GetData(sql_handle, 1, &data, NULL); scdata.tick = strtoll( data, nullptr, 10 );
-				Sql_GetData(sql_handle, 2, &data, NULL); scdata.val1 = atoi(data);
-				Sql_GetData(sql_handle, 3, &data, NULL); scdata.val2 = atoi(data);
-				Sql_GetData(sql_handle, 4, &data, NULL); scdata.val3 = atoi(data);
-				Sql_GetData(sql_handle, 5, &data, NULL); scdata.val4 = atoi(data);
+				Sql_GetData(sql_handle, 0, &data, nullptr); scdata.type = atoi(data);
+				Sql_GetData(sql_handle, 1, &data, nullptr); scdata.tick = strtoll( data, nullptr, 10 );
+				Sql_GetData(sql_handle, 2, &data, nullptr); scdata.val1 = atoi(data);
+				Sql_GetData(sql_handle, 3, &data, nullptr); scdata.val2 = atoi(data);
+				Sql_GetData(sql_handle, 4, &data, nullptr); scdata.val3 = atoi(data);
+				Sql_GetData(sql_handle, 5, &data, nullptr); scdata.val4 = atoi(data);
 				memcpy(WFIFOP(fd, 14+count*sizeof(struct status_change_data)), &scdata, sizeof(struct status_change_data));
 			}
 			if (count >= 50)
@@ -566,8 +566,8 @@ int chmapif_parse_req_skillcooldown(int fd){
 			WFIFOL(fd,8) = cid;
 			for( count = 0; count < MAX_SKILLCOOLDOWN && SQL_SUCCESS == Sql_NextRow(sql_handle); ++count )
 			{
-				Sql_GetData(sql_handle, 0, &data, NULL); scd.skill_id = atoi(data);
-				Sql_GetData(sql_handle, 1, &data, NULL); scd.tick = strtoll( data, nullptr, 10 );
+				Sql_GetData(sql_handle, 0, &data, nullptr); scd.skill_id = atoi(data);
+				Sql_GetData(sql_handle, 1, &data, nullptr); scd.tick = strtoll( data, nullptr, 10 );
 				memcpy(WFIFOP(fd,14+count*sizeof(struct skill_cooldown_data)), &scd, sizeof(struct skill_cooldown_data));
 			}
 			if( count >= MAX_SKILLCOOLDOWN )
@@ -780,8 +780,8 @@ int chmapif_parse_fwlog_changestatus(int fd){
 			int t_cid; // target char id
 			char* data;
 
-			Sql_GetData(sql_handle, 0, &data, NULL); t_aid = atoi(data);
-			Sql_GetData(sql_handle, 1, &data, NULL); t_cid = atoi(data);
+			Sql_GetData(sql_handle, 0, &data, nullptr); t_aid = atoi(data);
+			Sql_GetData(sql_handle, 1, &data, nullptr); t_cid = atoi(data);
 			Sql_FreeResult(sql_handle);
 
 			if(!chlogif_isconnected())
@@ -1049,8 +1049,8 @@ int chmapif_parse_reqauth(int fd, int id){
 
 			char_set_char_online(id, char_id, account_id);
 		} else if( global_core->is_running() &&
-			cd != NULL &&
-			node != NULL &&
+			cd != nullptr &&
+			node != nullptr &&
 			node->account_id == account_id &&
 			node->char_id == char_id &&
 			node->login_id1 == login_id1
@@ -1128,7 +1128,7 @@ int chmapif_parse_updfamelist(int fd){
 				case RANK_BLACKSMITH:	size = fame_list_size_smith;	list = smith_fame_list;		break;
 				case RANK_ALCHEMIST:	size = fame_list_size_chemist;	list = chemist_fame_list;	break;
 				case RANK_TAEKWON:		size = fame_list_size_taekwon;	list = taekwon_fame_list;	break;
-				default:				size = 0;						list = NULL;				break;
+				default:				size = 0;						list = nullptr;				break;
             }
 
             ARR_FIND(0, size, player_pos, list[player_pos].id == cid);// position of the player
@@ -1206,12 +1206,12 @@ int chmapif_parse_reqcharban(int fd){
 			int t_cid=0,t_aid=0;
 			char* data;
 			time_t unban_time;
-			time_t now = time(NULL);
+			time_t now = time(nullptr);
 			SqlStmt* stmt = SqlStmt_Malloc(sql_handle);
 
-			Sql_GetData(sql_handle, 0, &data, NULL); t_aid = atoi(data);
-			Sql_GetData(sql_handle, 1, &data, NULL); t_cid = atoi(data);
-			Sql_GetData(sql_handle, 2, &data, NULL); unban_time = atol(data);
+			Sql_GetData(sql_handle, 0, &data, nullptr); t_aid = atoi(data);
+			Sql_GetData(sql_handle, 1, &data, nullptr); t_cid = atoi(data);
+			Sql_GetData(sql_handle, 2, &data, nullptr); unban_time = atol(data);
 			Sql_FreeResult(sql_handle);
 
 			if(timediff<0 && unban_time==0) 
@@ -1292,11 +1292,11 @@ int chmapif_bonus_script_get(int fd) {
 			"SELECT `script`, `tick`, `flag`, `type`, `icon` FROM `%s` WHERE `char_id` = '%d' LIMIT %d",
 			schema_config.bonus_script_db, cid, MAX_PC_BONUS_SCRIPT) ||
 			SQL_ERROR == SqlStmt_Execute(stmt) ||
-			SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &tmp_bsdata.script_str, sizeof(tmp_bsdata.script_str), NULL, NULL) ||
-			SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT64, &tmp_bsdata.tick, 0, NULL, NULL) ||
-			SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT16, &tmp_bsdata.flag, 0, NULL, NULL) ||
-			SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_UINT8,  &tmp_bsdata.type, 0, NULL, NULL) ||
-			SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_INT16,  &tmp_bsdata.icon, 0, NULL, NULL)
+			SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &tmp_bsdata.script_str, sizeof(tmp_bsdata.script_str), nullptr, nullptr) ||
+			SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT64, &tmp_bsdata.tick, 0, nullptr, nullptr) ||
+			SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT16, &tmp_bsdata.flag, 0, nullptr, nullptr) ||
+			SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_UINT8,  &tmp_bsdata.type, 0, nullptr, nullptr) ||
+			SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_INT16,  &tmp_bsdata.icon, 0, nullptr, nullptr)
 			)
 		{
 			SqlStmt_ShowDebug(stmt);

+ 10 - 10
src/char/int_achievement.cpp

@@ -27,14 +27,14 @@
  */
 struct achievement *mapif_achievements_fromsql(uint32 char_id, int *count)
 {
-	struct achievement *achievelog = NULL;
+	struct achievement *achievelog = nullptr;
 	struct achievement tmp_achieve;
 	SqlStmt *stmt;
 	StringBuf buf;
 	int i;
 
 	if (!count)
-		return NULL;
+		return nullptr;
 
 	memset(&tmp_achieve, 0, sizeof(tmp_achieve));
 
@@ -52,14 +52,14 @@ struct achievement *mapif_achievements_fromsql(uint32 char_id, int *count)
 		SqlStmt_Free(stmt);
 		StringBuf_Destroy(&buf);
 		*count = 0;
-		return NULL;
+		return nullptr;
 	}
 
-	SqlStmt_BindColumn(stmt, 0, SQLDT_INT,  &tmp_achieve.achievement_id, 0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 1, SQLDT_INT,  &tmp_achieve.completed, 0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 2, SQLDT_INT,  &tmp_achieve.rewarded, 0, NULL, NULL);
+	SqlStmt_BindColumn(stmt, 0, SQLDT_INT,  &tmp_achieve.achievement_id, 0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 1, SQLDT_INT,  &tmp_achieve.completed, 0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 2, SQLDT_INT,  &tmp_achieve.rewarded, 0, nullptr, nullptr);
 	for (i = 0; i < MAX_ACHIEVEMENT_OBJECTIVES; ++i)
-		SqlStmt_BindColumn(stmt, 3 + i, SQLDT_INT, &tmp_achieve.count[i], 0, NULL, NULL);
+		SqlStmt_BindColumn(stmt, 3 + i, SQLDT_INT, &tmp_achieve.count[i], 0, nullptr, nullptr);
 
 	*count = (int)SqlStmt_NumRows(stmt);
 	if (*count > 0) {
@@ -209,7 +209,7 @@ int mapif_parse_achievement_save(int fd)
 {
 	int i, j, k, old_n, new_n = (RFIFOW(fd, 2) - 8) / sizeof(struct achievement);
 	uint32 char_id = RFIFOL(fd, 4);
-	struct achievement *old_ad = NULL, *new_ad = NULL;
+	struct achievement *old_ad = nullptr, *new_ad = nullptr;
 	bool success = true;
 
 	if (new_n > 0)
@@ -257,7 +257,7 @@ int mapif_parse_achievement_save(int fd)
  * Sends the achievementlog of a character to the map-server.
  */
 void mapif_achievement_load( int fd, uint32 char_id ){
-	struct achievement *tmp_achievementlog = NULL;
+	struct achievement *tmp_achievementlog = nullptr;
 	int num_achievements = 0;
 
 	tmp_achievementlog = mapif_achievements_fromsql(char_id, &num_achievements);
@@ -305,7 +305,7 @@ void mapif_achievement_reward( int fd, uint32 char_id, int32 achievement_id, tim
  * @see inter_parse_frommap
  */
 int mapif_parse_achievement_reward(int fd){
-	time_t current = time(NULL);
+	time_t current = time(nullptr);
 	uint32 char_id = RFIFOL(fd, 2);
 	int32 achievement_id = RFIFOL(fd, 6);
 

+ 27 - 27
src/char/int_auction.cpp

@@ -88,7 +88,7 @@ uint32 auction_create( std::shared_ptr<struct auction_data> auction ){
 	if( !auction )
 		return false;
 
-	auction->timestamp = time(NULL) + (auction->hours * 3600);
+	auction->timestamp = time(nullptr) + (auction->hours * 3600);
 
 	StringBuf_Init(&buf);
 	StringBuf_Printf(&buf, "INSERT INTO `%s` (`seller_id`,`seller_name`,`buyer_id`,`buyer_name`,`price`,`buynow`,`hours`,`timestamp`,`nameid`,`item_name`,`type`,`refine`,`attribute`,`unique_id`,`enchantgrade`", schema_config.auction_db);
@@ -159,7 +159,7 @@ TIMER_FUNC(auction_end_timer){
 		{
 			mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(202), 0, &auction->item, 1);
 			mapif_Auction_message(auction->buyer_id, 6); // You have won the auction
-			mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(203), auction->price, NULL, 0);
+			mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(203), auction->price, nullptr, 0);
 		}
 		else
 			mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(204), 0, &auction->item, 1);
@@ -191,7 +191,7 @@ void inter_auctions_fromsql(void)
 	char *data;
 	StringBuf buf;
 	t_tick tick = gettick(), endtick;
-	time_t now = time(NULL);
+	time_t now = time(nullptr);
 
 	StringBuf_Init(&buf);
 	StringBuf_AppendStr(&buf, "SELECT `auction_id`,`seller_id`,`seller_name`,`buyer_id`,`buyer_name`,"
@@ -215,25 +215,25 @@ void inter_auctions_fromsql(void)
 		struct item *item;
 		std::shared_ptr<struct auction_data> auction = std::make_shared<struct auction_data>();
 
-		Sql_GetData(sql_handle, 0, &data, NULL); auction->auction_id = atoi(data);
-		Sql_GetData(sql_handle, 1, &data, NULL); auction->seller_id = atoi(data);
-		Sql_GetData(sql_handle, 2, &data, NULL); safestrncpy(auction->seller_name, data, NAME_LENGTH);
-		Sql_GetData(sql_handle, 3, &data, NULL); auction->buyer_id = atoi(data);
-		Sql_GetData(sql_handle, 4, &data, NULL); safestrncpy(auction->buyer_name, data, NAME_LENGTH);
-		Sql_GetData(sql_handle, 5, &data, NULL); auction->price	= atoi(data);
-		Sql_GetData(sql_handle, 6, &data, NULL); auction->buynow = atoi(data);
-		Sql_GetData(sql_handle, 7, &data, NULL); auction->hours = atoi(data);
-		Sql_GetData(sql_handle, 8, &data, NULL); auction->timestamp = atoi(data);
+		Sql_GetData(sql_handle, 0, &data, nullptr); auction->auction_id = atoi(data);
+		Sql_GetData(sql_handle, 1, &data, nullptr); auction->seller_id = atoi(data);
+		Sql_GetData(sql_handle, 2, &data, nullptr); safestrncpy(auction->seller_name, data, NAME_LENGTH);
+		Sql_GetData(sql_handle, 3, &data, nullptr); auction->buyer_id = atoi(data);
+		Sql_GetData(sql_handle, 4, &data, nullptr); safestrncpy(auction->buyer_name, data, NAME_LENGTH);
+		Sql_GetData(sql_handle, 5, &data, nullptr); auction->price	= atoi(data);
+		Sql_GetData(sql_handle, 6, &data, nullptr); auction->buynow = atoi(data);
+		Sql_GetData(sql_handle, 7, &data, nullptr); auction->hours = atoi(data);
+		Sql_GetData(sql_handle, 8, &data, nullptr); auction->timestamp = atoi(data);
 
 		item = &auction->item;
-		Sql_GetData(sql_handle, 9, &data, NULL); item->nameid = strtoul(data, nullptr, 10);
-		Sql_GetData(sql_handle,10, &data, NULL); safestrncpy(auction->item_name, data, ITEM_NAME_LENGTH);
-		Sql_GetData(sql_handle,11, &data, NULL); auction->type = atoi(data);
+		Sql_GetData(sql_handle, 9, &data, nullptr); item->nameid = strtoul(data, nullptr, 10);
+		Sql_GetData(sql_handle,10, &data, nullptr); safestrncpy(auction->item_name, data, ITEM_NAME_LENGTH);
+		Sql_GetData(sql_handle,11, &data, nullptr); auction->type = atoi(data);
 
-		Sql_GetData(sql_handle,12, &data, NULL); item->refine = atoi(data);
-		Sql_GetData(sql_handle,13, &data, NULL); item->attribute = atoi(data);
-		Sql_GetData(sql_handle,14, &data, NULL); item->unique_id = strtoull(data, NULL, 10);
-		Sql_GetData(sql_handle,15, &data, NULL); item->enchantgrade = atoi(data);
+		Sql_GetData(sql_handle,12, &data, nullptr); item->refine = atoi(data);
+		Sql_GetData(sql_handle,13, &data, nullptr); item->attribute = atoi(data);
+		Sql_GetData(sql_handle,14, &data, nullptr); item->unique_id = strtoull(data, nullptr, 10);
+		Sql_GetData(sql_handle,15, &data, nullptr); item->enchantgrade = atoi(data);
 
 		item->identify = 1;
 		item->amount = 1;
@@ -241,16 +241,16 @@ void inter_auctions_fromsql(void)
 
 		for( i = 0; i < MAX_SLOTS; i++ )
 		{
-			Sql_GetData(sql_handle, 16 + i, &data, NULL);
+			Sql_GetData(sql_handle, 16 + i, &data, nullptr);
 			item->card[i] = strtoul(data, nullptr, 10);
 		}
 
 		for (i = 0; i < MAX_ITEM_RDM_OPT; i++) {
-			Sql_GetData(sql_handle, 16 + MAX_SLOTS + i*3, &data, NULL);
+			Sql_GetData(sql_handle, 16 + MAX_SLOTS + i*3, &data, nullptr);
 			item->option[i].id = atoi(data);
-			Sql_GetData(sql_handle, 17 + MAX_SLOTS + i*3, &data, NULL);
+			Sql_GetData(sql_handle, 17 + MAX_SLOTS + i*3, &data, nullptr);
 			item->option[i].value = atoi(data);
-			Sql_GetData(sql_handle, 18 + MAX_SLOTS + i*3, &data, NULL);
+			Sql_GetData(sql_handle, 18 + MAX_SLOTS + i*3, &data, nullptr);
 			item->option[i].param = atoi(data);
 		}
 
@@ -423,7 +423,7 @@ void mapif_parse_Auction_close(int fd)
 	}
 
 	// Send Money to Seller
-	mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(206), auction->price, NULL, 0);
+	mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(206), auction->price, nullptr, 0);
 	// Send Item to Buyer
 	mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(207), 0, &auction->item, 1);
 	mapif_Auction_message(auction->buyer_id, 6); // You have won the auction
@@ -463,11 +463,11 @@ void mapif_parse_Auction_bid(int fd)
 	{ // Send Money back to the previous Buyer
 		if( auction->buyer_id != char_id )
 		{
-			mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(208), auction->price, NULL, 0);
+			mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(208), auction->price, nullptr, 0);
 			mapif_Auction_message(auction->buyer_id, 7); // You have failed to win the auction
 		}
 		else
-			mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(209), auction->price, NULL, 0);
+			mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(209), auction->price, nullptr, 0);
 	}
 
 	auction->buyer_id = char_id;
@@ -480,7 +480,7 @@ void mapif_parse_Auction_bid(int fd)
 
 		mail_sendmail(0, msg_txt(200), auction->buyer_id, auction->buyer_name, msg_txt(201), msg_txt(210), 0, &auction->item, 1);
 		mapif_Auction_message(char_id, 6); // You have won the auction
-		mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(211), auction->buynow, NULL, 0);
+		mail_sendmail(0, msg_txt(200), auction->seller_id, auction->seller_name, msg_txt(201), msg_txt(211), auction->buynow, nullptr, 0);
 
 		auction_delete(auction);
 		return;

+ 3 - 3
src/char/int_clan.cpp

@@ -63,7 +63,7 @@ std::shared_ptr<struct clan> inter_clan_fromsql(int clan_id){
 	Sql_GetData(sql_handle,  0, &data, &len); memcpy(clan->name, data, min(len, NAME_LENGTH));
 	Sql_GetData(sql_handle,  1, &data, &len); memcpy(clan->master, data, min(len, NAME_LENGTH));
 	Sql_GetData(sql_handle,  2, &data, &len); memcpy(clan->map, data, min(len, MAP_NAME_LENGTH_EXT));
-	Sql_GetData(sql_handle,  3, &data, NULL); clan->max_member = atoi(data);
+	Sql_GetData(sql_handle,  3, &data, nullptr); clan->max_member = atoi(data);
 
 	clan->connect_member = 0;
 
@@ -82,8 +82,8 @@ std::shared_ptr<struct clan> inter_clan_fromsql(int clan_id){
 	for( i = 0; i < MAX_CLANALLIANCE && SQL_SUCCESS == Sql_NextRow(sql_handle); i++ ){
 		struct clan_alliance* a = &clan->alliance[i];
 
-		Sql_GetData(sql_handle, 0, &data, NULL); a->opposition = atoi(data);
-		Sql_GetData(sql_handle, 1, &data, NULL); a->clan_id = atoi(data);
+		Sql_GetData(sql_handle, 0, &data, nullptr); a->opposition = atoi(data);
+		Sql_GetData(sql_handle, 1, &data, nullptr); a->clan_id = atoi(data);
 		Sql_GetData(sql_handle, 2, &data, &len); memcpy(a->name, data, zmin(len, NAME_LENGTH));
 	}
 

+ 15 - 15
src/char/int_elemental.cpp

@@ -61,21 +61,21 @@ bool mapif_elemental_load(int ele_id, uint32 char_id, struct s_elemental *ele) {
 		return false;
 	}
 
-	Sql_GetData(sql_handle,  0, &data, NULL); ele->class_ = atoi(data);
-	Sql_GetData(sql_handle,  1, &data, NULL); ele->mode = (e_mode)atoi(data);
-	Sql_GetData(sql_handle,  2, &data, NULL); ele->hp = atoi(data);
-	Sql_GetData(sql_handle,  3, &data, NULL); ele->sp = atoi(data);
-	Sql_GetData(sql_handle,  4, &data, NULL); ele->max_hp = atoi(data);
-	Sql_GetData(sql_handle,  5, &data, NULL); ele->max_sp = atoi(data);
-	Sql_GetData(sql_handle,  6, &data, NULL); ele->atk = atoi(data);
-	Sql_GetData(sql_handle,  7, &data, NULL); ele->atk2 = atoi(data);
-	Sql_GetData(sql_handle,  8, &data, NULL); ele->matk = atoi(data);
-	Sql_GetData(sql_handle,  9, &data, NULL); ele->amotion = atoi(data);
-	Sql_GetData(sql_handle, 10, &data, NULL); ele->def = atoi(data);
-	Sql_GetData(sql_handle, 11, &data, NULL); ele->mdef = atoi(data);
-	Sql_GetData(sql_handle, 12, &data, NULL); ele->flee = atoi(data);
-	Sql_GetData(sql_handle, 13, &data, NULL); ele->hit = atoi(data);
-	Sql_GetData(sql_handle, 14, &data, NULL); ele->life_time = strtoll( data, nullptr, 10 );
+	Sql_GetData(sql_handle,  0, &data, nullptr); ele->class_ = atoi(data);
+	Sql_GetData(sql_handle,  1, &data, nullptr); ele->mode = (e_mode)atoi(data);
+	Sql_GetData(sql_handle,  2, &data, nullptr); ele->hp = atoi(data);
+	Sql_GetData(sql_handle,  3, &data, nullptr); ele->sp = atoi(data);
+	Sql_GetData(sql_handle,  4, &data, nullptr); ele->max_hp = atoi(data);
+	Sql_GetData(sql_handle,  5, &data, nullptr); ele->max_sp = atoi(data);
+	Sql_GetData(sql_handle,  6, &data, nullptr); ele->atk = atoi(data);
+	Sql_GetData(sql_handle,  7, &data, nullptr); ele->atk2 = atoi(data);
+	Sql_GetData(sql_handle,  8, &data, nullptr); ele->matk = atoi(data);
+	Sql_GetData(sql_handle,  9, &data, nullptr); ele->amotion = atoi(data);
+	Sql_GetData(sql_handle, 10, &data, nullptr); ele->def = atoi(data);
+	Sql_GetData(sql_handle, 11, &data, nullptr); ele->mdef = atoi(data);
+	Sql_GetData(sql_handle, 12, &data, nullptr); ele->flee = atoi(data);
+	Sql_GetData(sql_handle, 13, &data, nullptr); ele->hit = atoi(data);
+	Sql_GetData(sql_handle, 14, &data, nullptr); ele->life_time = strtoll( data, nullptr, 10 );
 	Sql_FreeResult(sql_handle);
 	if( charserv_config.save_log )
 		ShowInfo("Elemental loaded (ID: %d / Class: %d / CID: %d).\n", ele->elemental_id, ele->class_, ele->char_id);

+ 49 - 49
src/char/int_guild.cpp

@@ -368,23 +368,23 @@ std::shared_ptr<CharGuild> inter_guild_fromsql( int32 guild_id ){
 	g->guild.guild_id = guild_id;
 	Sql_GetData(sql_handle,  0, &data, &len); memcpy(g->guild.name, data, zmin(len, NAME_LENGTH));
 	Sql_GetData(sql_handle,  1, &data, &len); memcpy(g->guild.master, data, zmin(len, NAME_LENGTH));
-	Sql_GetData(sql_handle,  2, &data, NULL); g->guild.guild_lv = atoi(data);
-	Sql_GetData(sql_handle,  3, &data, NULL); g->guild.connect_member = atoi(data);
-	Sql_GetData(sql_handle,  4, &data, NULL); g->guild.max_member = atoi(data);
+	Sql_GetData(sql_handle,  2, &data, nullptr); g->guild.guild_lv = atoi(data);
+	Sql_GetData(sql_handle,  3, &data, nullptr); g->guild.connect_member = atoi(data);
+	Sql_GetData(sql_handle,  4, &data, nullptr); g->guild.max_member = atoi(data);
 	if( g->guild.max_member > MAX_GUILD )
 	{	// Fix reduction of MAX_GUILD [PoW]
 		ShowWarning("Guild %d:%s specifies higher capacity (%d) than MAX_GUILD (%d)\n", guild_id, g->guild.name, g->guild.max_member, MAX_GUILD);
 		g->guild.max_member = MAX_GUILD;
 	}
-	Sql_GetData(sql_handle,  5, &data, NULL); g->guild.average_lv = atoi(data);
-	Sql_GetData(sql_handle,  6, &data, NULL); g->guild.exp = strtoull(data, NULL, 10);
-	Sql_GetData(sql_handle,  7, &data, NULL); g->guild.next_exp = strtoull(data, nullptr, 10);
-	Sql_GetData(sql_handle,  8, &data, NULL); g->guild.skill_point = atoi(data);
+	Sql_GetData(sql_handle,  5, &data, nullptr); g->guild.average_lv = atoi(data);
+	Sql_GetData(sql_handle,  6, &data, nullptr); g->guild.exp = strtoull(data, nullptr, 10);
+	Sql_GetData(sql_handle,  7, &data, nullptr); g->guild.next_exp = strtoull(data, nullptr, 10);
+	Sql_GetData(sql_handle,  8, &data, nullptr); g->guild.skill_point = atoi(data);
 	Sql_GetData(sql_handle,  9, &data, &len); memcpy(g->guild.mes1, data, zmin(len, sizeof(g->guild.mes1)));
 	Sql_GetData(sql_handle, 10, &data, &len); memcpy(g->guild.mes2, data, zmin(len, sizeof(g->guild.mes2)));
 	Sql_GetData(sql_handle, 11, &data, &len); g->guild.emblem_len = atoi(data);
 	Sql_GetData(sql_handle, 12, &data, &len); g->guild.emblem_id = atoi(data);
-	Sql_GetData(sql_handle, 13, &data, NULL); g->guild.last_leader_change = atoi(data);
+	Sql_GetData(sql_handle, 13, &data, nullptr); g->guild.last_leader_change = atoi(data);
 	Sql_GetData(sql_handle, 14, &data, &len);
 	// convert emblem data from hexadecimal to binary
 	//TODO: why not store it in the db as binary directly? [ultramage]
@@ -419,11 +419,11 @@ std::shared_ptr<CharGuild> inter_guild_fromsql( int32 guild_id ){
 	{
 		struct guild_member* m = &g->guild.member[i];
 
-		Sql_GetData(sql_handle,  0, &data, NULL); m->account_id = atoi(data);
-		Sql_GetData(sql_handle,  1, &data, NULL); m->char_id = atoi(data);
-		Sql_GetData(sql_handle,  2, &data, NULL); m->hair = atoi(data);
-		Sql_GetData(sql_handle,  3, &data, NULL); m->hair_color = atoi(data);
-		Sql_GetData(sql_handle,  4, &data, NULL);
+		Sql_GetData(sql_handle,  0, &data, nullptr); m->account_id = atoi(data);
+		Sql_GetData(sql_handle,  1, &data, nullptr); m->char_id = atoi(data);
+		Sql_GetData(sql_handle,  2, &data, nullptr); m->hair = atoi(data);
+		Sql_GetData(sql_handle,  3, &data, nullptr); m->hair_color = atoi(data);
+		Sql_GetData(sql_handle,  4, &data, nullptr);
 		switch( *data ){
 			case 'F':
 				m->gender = SEX_FEMALE;
@@ -436,15 +436,15 @@ std::shared_ptr<CharGuild> inter_guild_fromsql( int32 guild_id ){
 				m->gender = SEX_MALE;
 				break;
 		}
-		Sql_GetData(sql_handle,  5, &data, NULL); m->class_ = atoi(data);
-		Sql_GetData(sql_handle,  6, &data, NULL); m->lv = atoi(data);
-		Sql_GetData(sql_handle,  7, &data, NULL); m->exp = strtoull(data, NULL, 10);
-		Sql_GetData(sql_handle,  8, &data, NULL); m->online = atoi(data);
-		Sql_GetData(sql_handle,  9, &data, NULL); m->position = atoi(data);
+		Sql_GetData(sql_handle,  5, &data, nullptr); m->class_ = atoi(data);
+		Sql_GetData(sql_handle,  6, &data, nullptr); m->lv = atoi(data);
+		Sql_GetData(sql_handle,  7, &data, nullptr); m->exp = strtoull(data, nullptr, 10);
+		Sql_GetData(sql_handle,  8, &data, nullptr); m->online = atoi(data);
+		Sql_GetData(sql_handle,  9, &data, nullptr); m->position = atoi(data);
 		if( m->position >= MAX_GUILDPOSITION ) // Fix reduction of MAX_GUILDPOSITION [PoW]
 			m->position = MAX_GUILDPOSITION - 1;
 		Sql_GetData(sql_handle, 10, &data, &len); memcpy(m->name, data, zmin(len, NAME_LENGTH));
-		Sql_GetData(sql_handle, 11, &data, NULL); m->last_login = atoi(data);
+		Sql_GetData(sql_handle, 11, &data, nullptr); m->last_login = atoi(data);
 		m->modified = GS_MEMBER_UNMODIFIED;
 	}
 
@@ -459,13 +459,13 @@ std::shared_ptr<CharGuild> inter_guild_fromsql( int32 guild_id ){
 		int position;
 		struct guild_position* gpos;
 
-		Sql_GetData(sql_handle, 0, &data, NULL); position = atoi(data);
+		Sql_GetData(sql_handle, 0, &data, nullptr); position = atoi(data);
 		if( position < 0 || position >= MAX_GUILDPOSITION )
 			continue;// invalid position
 		gpos = &g->guild.position[position];
 		Sql_GetData(sql_handle, 1, &data, &len); memcpy(gpos->name, data, zmin(len, NAME_LENGTH));
-		Sql_GetData(sql_handle, 2, &data, NULL); gpos->mode = atoi(data);
-		Sql_GetData(sql_handle, 3, &data, NULL); gpos->exp_mode = atoi(data);
+		Sql_GetData(sql_handle, 2, &data, nullptr); gpos->mode = atoi(data);
+		Sql_GetData(sql_handle, 3, &data, nullptr); gpos->exp_mode = atoi(data);
 		gpos->modified = GS_POSITION_UNMODIFIED;
 	}
 
@@ -479,8 +479,8 @@ std::shared_ptr<CharGuild> inter_guild_fromsql( int32 guild_id ){
 	{
 		struct guild_alliance* a = &g->guild.alliance[i];
 
-		Sql_GetData(sql_handle, 0, &data, NULL); a->opposition = atoi(data);
-		Sql_GetData(sql_handle, 1, &data, NULL); a->guild_id = atoi(data);
+		Sql_GetData(sql_handle, 0, &data, nullptr); a->opposition = atoi(data);
+		Sql_GetData(sql_handle, 1, &data, nullptr); a->guild_id = atoi(data);
 		Sql_GetData(sql_handle, 2, &data, &len); memcpy(a->name, data, zmin(len, NAME_LENGTH));
 	}
 
@@ -494,7 +494,7 @@ std::shared_ptr<CharGuild> inter_guild_fromsql( int32 guild_id ){
 	{
 		struct guild_expulsion *e = &g->guild.expulsion[i];
 
-		Sql_GetData(sql_handle, 0, &data, NULL); e->account_id = atoi(data);
+		Sql_GetData(sql_handle, 0, &data, nullptr); e->account_id = atoi(data);
 		Sql_GetData(sql_handle, 1, &data, &len); memcpy(e->name, data, zmin(len, NAME_LENGTH));
 		Sql_GetData(sql_handle, 2, &data, &len); memcpy(e->mes, data, zmin(len, sizeof(e->mes)));
 	}
@@ -514,10 +514,10 @@ std::shared_ptr<CharGuild> inter_guild_fromsql( int32 guild_id ){
 	while( SQL_SUCCESS == Sql_NextRow(sql_handle) )
 	{
 		int id;
-		Sql_GetData(sql_handle, 0, &data, NULL); id = atoi(data) - GD_SKILLBASE;
+		Sql_GetData(sql_handle, 0, &data, nullptr); id = atoi(data) - GD_SKILLBASE;
 		if( id < 0 || id >= MAX_GUILDSKILL )
 			continue;// invalid guild skill
-		Sql_GetData(sql_handle, 1, &data, NULL); g->guild.skill[id].lv = atoi(data);
+		Sql_GetData(sql_handle, 1, &data, nullptr); g->guild.skill[id].lv = atoi(data);
 	}
 	Sql_FreeResult(sql_handle);
 
@@ -602,7 +602,7 @@ std::shared_ptr<struct guild_castle> inter_guildcastle_fromsql( int castle_id ){
 	if (SQL_ERROR == Sql_Query(sql_handle, StringBuf_Value(&buf))) {
 		Sql_ShowDebug(sql_handle);
 		StringBuf_Destroy(&buf);
-		return NULL;
+		return nullptr;
 	}
 	StringBuf_Destroy(&buf);
 
@@ -611,17 +611,17 @@ std::shared_ptr<struct guild_castle> inter_guildcastle_fromsql( int castle_id ){
 	gc->castle_id = castle_id;
 
 	if (SQL_SUCCESS == Sql_NextRow(sql_handle)) {
-		Sql_GetData(sql_handle, CD_GUILD_ID, &data, NULL); gc->guild_id =  atoi(data);
-		Sql_GetData(sql_handle, CD_CURRENT_ECONOMY, &data, NULL); gc->economy = atoi(data);
-		Sql_GetData(sql_handle, CD_CURRENT_DEFENSE, &data, NULL); gc->defense = atoi(data);
-		Sql_GetData(sql_handle, CD_INVESTED_ECONOMY, &data, NULL); gc->triggerE = atoi(data);
-		Sql_GetData(sql_handle, CD_INVESTED_DEFENSE, &data, NULL); gc->triggerD = atoi(data);
-		Sql_GetData(sql_handle, CD_NEXT_TIME, &data, NULL); gc->nextTime = atoi(data);
-		Sql_GetData(sql_handle, CD_PAY_TIME, &data, NULL); gc->payTime = atoi(data);
-		Sql_GetData(sql_handle, CD_CREATE_TIME, &data, NULL); gc->createTime = atoi(data);
-		Sql_GetData(sql_handle, CD_ENABLED_KAFRA, &data, NULL); gc->visibleC = atoi(data);
+		Sql_GetData(sql_handle, CD_GUILD_ID, &data, nullptr); gc->guild_id =  atoi(data);
+		Sql_GetData(sql_handle, CD_CURRENT_ECONOMY, &data, nullptr); gc->economy = atoi(data);
+		Sql_GetData(sql_handle, CD_CURRENT_DEFENSE, &data, nullptr); gc->defense = atoi(data);
+		Sql_GetData(sql_handle, CD_INVESTED_ECONOMY, &data, nullptr); gc->triggerE = atoi(data);
+		Sql_GetData(sql_handle, CD_INVESTED_DEFENSE, &data, nullptr); gc->triggerD = atoi(data);
+		Sql_GetData(sql_handle, CD_NEXT_TIME, &data, nullptr); gc->nextTime = atoi(data);
+		Sql_GetData(sql_handle, CD_PAY_TIME, &data, nullptr); gc->payTime = atoi(data);
+		Sql_GetData(sql_handle, CD_CREATE_TIME, &data, nullptr); gc->createTime = atoi(data);
+		Sql_GetData(sql_handle, CD_ENABLED_KAFRA, &data, nullptr); gc->visibleC = atoi(data);
 		for (i = CD_ENABLED_GUARDIAN00; i < CD_MAX; i++) {
-			Sql_GetData(sql_handle, i, &data, NULL); gc->guardian[i - CD_ENABLED_GUARDIAN00].visible = atoi(data);
+			Sql_GetData(sql_handle, i, &data, nullptr); gc->guardian[i - CD_ENABLED_GUARDIAN00].visible = atoi(data);
 		}
 	}
 	Sql_FreeResult(sql_handle);
@@ -651,7 +651,7 @@ int inter_guild_CharOnline(uint32 char_id, int guild_id)
 		{
 			char* data;
 
-			Sql_GetData(sql_handle, 0, &data, NULL);
+			Sql_GetData(sql_handle, 0, &data, nullptr);
 			guild_id = atoi(data);
 		}
 		else
@@ -702,7 +702,7 @@ int inter_guild_CharOffline(uint32 char_id, int guild_id)
 		{
 			char* data;
 
-			Sql_GetData(sql_handle, 0, &data, NULL);
+			Sql_GetData(sql_handle, 0, &data, nullptr);
 			guild_id = atoi(data);
 		}
 		else
@@ -838,7 +838,7 @@ int search_guildname(char *str)
 	{
 		char* data;
 
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		guild_id = atoi(data);
 	}
 	else
@@ -935,7 +935,7 @@ int mapif_guild_created( int fd, uint32 account_id, struct mmo_guild *g ){
 	WFIFOHEAD(fd, 10);
 	WFIFOW(fd,0)=0x3830;
 	WFIFOL(fd,2)=account_id;
-	if(g != NULL)
+	if(g != nullptr)
 	{
 		WFIFOL(fd,6)=g->guild_id;
 		ShowInfo("int_guild: Guild created (%d - %s)\n",g->guild_id,g->name);
@@ -1191,20 +1191,20 @@ int mapif_parse_CreateGuild(int fd,uint32 account_id,char *name,struct guild_mem
 #endif
 	if(search_guildname(name) != 0){
 		ShowInfo("int_guild: guild with same name exists [%s]\n",name);
-		mapif_guild_created(fd,account_id,NULL);
+		mapif_guild_created(fd,account_id,nullptr);
 		return 0;
 	}
 	// Check Authorised letters/symbols in the name of the character
 	if (charserv_config.char_config.char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
 		for (i = 0; i < NAME_LENGTH && name[i]; i++)
-			if (strchr(charserv_config.char_config.char_name_letters, name[i]) == NULL) {
-				mapif_guild_created(fd,account_id,NULL);
+			if (strchr(charserv_config.char_config.char_name_letters, name[i]) == nullptr) {
+				mapif_guild_created(fd,account_id,nullptr);
 				return 0;
 			}
 	} else if (charserv_config.char_config.char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
 		for (i = 0; i < NAME_LENGTH && name[i]; i++)
-			if (strchr(charserv_config.char_config.char_name_letters, name[i]) != NULL) {
-				mapif_guild_created(fd,account_id,NULL);
+			if (strchr(charserv_config.char_config.char_name_letters, name[i]) != nullptr) {
+				mapif_guild_created(fd,account_id,nullptr);
 				return 0;
 			}
 	}
@@ -1239,7 +1239,7 @@ int mapif_parse_CreateGuild(int fd,uint32 account_id,char *name,struct guild_mem
 	if (!inter_guild_tosql(g->guild,GS_BASIC|GS_POSITION|GS_SKILL|GS_MEMBER)) {
 		//Failed to Create guild....
 		ShowError("Failed to create Guild %s (Guild Master: %s)\n", g->guild.name, g->guild.master);
-		mapif_guild_created(fd,account_id,NULL);
+		mapif_guild_created(fd,account_id,nullptr);
 		return 0;
 	}
 	ShowInfo("Created Guild %d - %s (Guild Master: %s)\n", g->guild.guild_id, g->guild.name, g->guild.master);
@@ -1887,7 +1887,7 @@ int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int le
 	g->guild.member[0].modified = GS_MEMBER_MODIFIED;
 
 	// Store changing time
-	g->guild.last_leader_change = time(NULL);
+	g->guild.last_leader_change = time(nullptr);
 
 	safestrncpy(g->guild.master, name, len);
 	if (len < NAME_LENGTH)

+ 27 - 27
src/char/int_homun.cpp

@@ -50,7 +50,7 @@ void mapif_homunculus_loaded(int fd, uint32 account_id, struct s_homunculus *hd)
 	WFIFOW(fd,0) = 0x3891;
 	WFIFOW(fd,2) = sizeof(struct s_homunculus)+9;
 	WFIFOL(fd,4) = account_id;
-	if( hd != NULL )
+	if( hd != nullptr )
 	{
 		WFIFOB(fd,8) = 1; // success
 		memcpy(WFIFOP(fd,9), hd, sizeof(struct s_homunculus));
@@ -175,28 +175,28 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
 	}
 
 	hd->hom_id = homun_id;
-	Sql_GetData(sql_handle,  1, &data, NULL); hd->char_id = atoi(data);
-	Sql_GetData(sql_handle,  2, &data, NULL); hd->class_ = atoi(data);
-	Sql_GetData(sql_handle,  3, &data, NULL); hd->prev_class = atoi(data);
+	Sql_GetData(sql_handle,  1, &data, nullptr); hd->char_id = atoi(data);
+	Sql_GetData(sql_handle,  2, &data, nullptr); hd->class_ = atoi(data);
+	Sql_GetData(sql_handle,  3, &data, nullptr); hd->prev_class = atoi(data);
 	Sql_GetData(sql_handle,  4, &data, &len); safestrncpy(hd->name, data, sizeof(hd->name));
-	Sql_GetData(sql_handle,  5, &data, NULL); hd->level = atoi(data);
-	Sql_GetData(sql_handle,  6, &data, NULL); hd->exp = strtoull( data, nullptr, 10 );
-	Sql_GetData(sql_handle,  7, &data, NULL); hd->intimacy = (unsigned int)strtoul(data, NULL, 10);
-	Sql_GetData(sql_handle,  8, &data, NULL); hd->hunger = atoi(data);
-	Sql_GetData(sql_handle,  9, &data, NULL); hd->str = atoi(data);
-	Sql_GetData(sql_handle, 10, &data, NULL); hd->agi = atoi(data);
-	Sql_GetData(sql_handle, 11, &data, NULL); hd->vit = atoi(data);
-	Sql_GetData(sql_handle, 12, &data, NULL); hd->int_ = atoi(data);
-	Sql_GetData(sql_handle, 13, &data, NULL); hd->dex = atoi(data);
-	Sql_GetData(sql_handle, 14, &data, NULL); hd->luk = atoi(data);
-	Sql_GetData(sql_handle, 15, &data, NULL); hd->hp = atoi(data);
-	Sql_GetData(sql_handle, 16, &data, NULL); hd->max_hp = atoi(data);
-	Sql_GetData(sql_handle, 17, &data, NULL); hd->sp = atoi(data);
-	Sql_GetData(sql_handle, 18, &data, NULL); hd->max_sp = atoi(data);
-	Sql_GetData(sql_handle, 19, &data, NULL); hd->skillpts = atoi(data);
-	Sql_GetData(sql_handle, 20, &data, NULL); hd->rename_flag = atoi(data);
-	Sql_GetData(sql_handle, 21, &data, NULL); hd->vaporize = atoi(data);
-	Sql_GetData(sql_handle, 22, &data, NULL); hd->autofeed = atoi(data) != 0;
+	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,  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);
+	Sql_GetData(sql_handle, 11, &data, nullptr); hd->vit = atoi(data);
+	Sql_GetData(sql_handle, 12, &data, nullptr); hd->int_ = atoi(data);
+	Sql_GetData(sql_handle, 13, &data, nullptr); hd->dex = atoi(data);
+	Sql_GetData(sql_handle, 14, &data, nullptr); hd->luk = atoi(data);
+	Sql_GetData(sql_handle, 15, &data, nullptr); hd->hp = atoi(data);
+	Sql_GetData(sql_handle, 16, &data, nullptr); hd->max_hp = atoi(data);
+	Sql_GetData(sql_handle, 17, &data, nullptr); hd->sp = atoi(data);
+	Sql_GetData(sql_handle, 18, &data, nullptr); hd->max_sp = atoi(data);
+	Sql_GetData(sql_handle, 19, &data, nullptr); hd->skillpts = atoi(data);
+	Sql_GetData(sql_handle, 20, &data, nullptr); hd->rename_flag = atoi(data);
+	Sql_GetData(sql_handle, 21, &data, nullptr); hd->vaporize = atoi(data);
+	Sql_GetData(sql_handle, 22, &data, nullptr); hd->autofeed = atoi(data) != 0;
 	Sql_FreeResult(sql_handle);
 
 	hd->intimacy = umin(hd->intimacy,100000);
@@ -212,7 +212,7 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
 	{
 		int i;
 		// id
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		i = atoi(data);
 		if( i < HM_SKILLBASE || i >= HM_SKILLBASE + MAX_HOMUNSKILL )
 			continue;// invalid skill id
@@ -220,7 +220,7 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd)
 		hd->hskill[i].id = (unsigned short)atoi(data);
 
 		// lv
-		Sql_GetData(sql_handle, 1, &data, NULL);
+		Sql_GetData(sql_handle, 1, &data, nullptr);
 		hd->hskill[i].lv = (unsigned char)atoi(data);
 	}
 	Sql_FreeResult(sql_handle);
@@ -251,13 +251,13 @@ bool mapif_homunculus_rename(char *name)
 	if( charserv_config.char_config.char_name_option == 1 )
 	{// only letters/symbols in char_name_letters are authorised
 		for( i = 0; i < NAME_LENGTH && name[i]; i++ )
-			if( strchr(charserv_config.char_config.char_name_letters, name[i]) == NULL )
+			if( strchr(charserv_config.char_config.char_name_letters, name[i]) == nullptr )
 				return false;
 	} else
 	if( charserv_config.char_config.char_name_option == 2 )
 	{// letters/symbols in char_name_letters are forbidden
 		for( i = 0; i < NAME_LENGTH && name[i]; i++ )
-			if( strchr(charserv_config.char_config.char_name_letters, name[i]) != NULL )
+			if( strchr(charserv_config.char_config.char_name_letters, name[i]) != nullptr )
 				return false;
 	}
 
@@ -281,7 +281,7 @@ void mapif_parse_homunculus_load(int fd, uint32 account_id, int homun_id)
 {
 	struct s_homunculus hd;
 	bool result = mapif_homunculus_load(homun_id, &hd);
-	mapif_homunculus_loaded(fd, account_id, ( result ? &hd : NULL ));
+	mapif_homunculus_loaded(fd, account_id, ( result ? &hd : nullptr ));
 }
 
 void mapif_parse_homunculus_save(int fd, int len, uint32 account_id, struct s_homunculus* phd)

+ 38 - 38
src/char/int_mail.cpp

@@ -42,7 +42,7 @@ int mail_fromsql(uint32 char_id, struct mail_data* md)
 	md->full = (Sql_NumRows(sql_handle) > MAIL_MAX_INBOX);
 
 	for( i = 0; i < MAIL_MAX_INBOX && SQL_SUCCESS == Sql_NextRow(sql_handle); i++ ){
-		Sql_GetData(sql_handle, 0, &data, NULL); md->msg[i].id = atoi(data);
+		Sql_GetData(sql_handle, 0, &data, nullptr); md->msg[i].id = atoi(data);
 	}
 
 	md->amount = i;
@@ -178,17 +178,17 @@ bool mail_loadmessage(int mail_id, struct mail_message* msg)
 		Sql_FreeResult(sql_handle);
 		return false;
 	}else{
-		Sql_GetData(sql_handle, 0, &data, NULL); msg->id = atoi(data);
-		Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(msg->send_name, data, NAME_LENGTH);
-		Sql_GetData(sql_handle, 2, &data, NULL); msg->send_id = atoi(data);
-		Sql_GetData(sql_handle, 3, &data, NULL); safestrncpy(msg->dest_name, data, NAME_LENGTH);
-		Sql_GetData(sql_handle, 4, &data, NULL); msg->dest_id = atoi(data);
-		Sql_GetData(sql_handle, 5, &data, NULL); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
-		Sql_GetData(sql_handle, 6, &data, NULL); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
-		Sql_GetData(sql_handle, 7, &data, NULL); msg->timestamp = atoi(data);
-		Sql_GetData(sql_handle, 8, &data, NULL); msg->status = (mail_status)atoi(data);
-		Sql_GetData(sql_handle, 9, &data, NULL); msg->zeny = atoi(data);
-		Sql_GetData(sql_handle,10, &data, NULL); msg->type = (mail_inbox_type)atoi(data);
+		Sql_GetData(sql_handle, 0, &data, nullptr); msg->id = atoi(data);
+		Sql_GetData(sql_handle, 1, &data, nullptr); safestrncpy(msg->send_name, data, NAME_LENGTH);
+		Sql_GetData(sql_handle, 2, &data, nullptr); msg->send_id = atoi(data);
+		Sql_GetData(sql_handle, 3, &data, nullptr); safestrncpy(msg->dest_name, data, NAME_LENGTH);
+		Sql_GetData(sql_handle, 4, &data, nullptr); msg->dest_id = atoi(data);
+		Sql_GetData(sql_handle, 5, &data, nullptr); safestrncpy(msg->title, data, MAIL_TITLE_LENGTH);
+		Sql_GetData(sql_handle, 6, &data, nullptr); safestrncpy(msg->body, data, MAIL_BODY_LENGTH);
+		Sql_GetData(sql_handle, 7, &data, nullptr); msg->timestamp = atoi(data);
+		Sql_GetData(sql_handle, 8, &data, nullptr); msg->status = (mail_status)atoi(data);
+		Sql_GetData(sql_handle, 9, &data, nullptr); msg->zeny = atoi(data);
+		Sql_GetData(sql_handle,10, &data, nullptr); msg->type = (mail_inbox_type)atoi(data);
 
 		if( msg->type == MAIL_INBOX_NORMAL && charserv_config.mail_return_days > 0 ){
 			msg->scheduled_deletion = msg->timestamp + charserv_config.mail_return_days * 24 * 60 * 60;
@@ -225,24 +225,24 @@ bool mail_loadmessage(int mail_id, struct mail_message* msg)
 	memset(msg->item, 0, sizeof(struct item) * MAIL_MAX_ITEM);
 
 	for( i = 0; i < MAIL_MAX_ITEM && SQL_SUCCESS == Sql_NextRow(sql_handle); i++ ){
-		Sql_GetData(sql_handle,0, &data, NULL); msg->item[i].amount = (short)atoi(data);
-		Sql_GetData(sql_handle,1, &data, NULL); msg->item[i].nameid = strtoul(data, nullptr, 10);
-		Sql_GetData(sql_handle,2, &data, NULL); msg->item[i].refine = atoi(data);
-		Sql_GetData(sql_handle,3, &data, NULL); msg->item[i].attribute = atoi(data);
-		Sql_GetData(sql_handle,4, &data, NULL); msg->item[i].identify = atoi(data);
-		Sql_GetData(sql_handle,5, &data, NULL); msg->item[i].unique_id = strtoull(data, NULL, 10);
-		Sql_GetData(sql_handle,6, &data, NULL); msg->item[i].bound = atoi(data);
-		Sql_GetData(sql_handle,7, &data, NULL); msg->item[i].enchantgrade = atoi(data);
+		Sql_GetData(sql_handle,0, &data, nullptr); msg->item[i].amount = (short)atoi(data);
+		Sql_GetData(sql_handle,1, &data, nullptr); msg->item[i].nameid = strtoul(data, nullptr, 10);
+		Sql_GetData(sql_handle,2, &data, nullptr); msg->item[i].refine = atoi(data);
+		Sql_GetData(sql_handle,3, &data, nullptr); msg->item[i].attribute = atoi(data);
+		Sql_GetData(sql_handle,4, &data, nullptr); msg->item[i].identify = atoi(data);
+		Sql_GetData(sql_handle,5, &data, nullptr); msg->item[i].unique_id = strtoull(data, nullptr, 10);
+		Sql_GetData(sql_handle,6, &data, nullptr); msg->item[i].bound = atoi(data);
+		Sql_GetData(sql_handle,7, &data, nullptr); msg->item[i].enchantgrade = atoi(data);
 		msg->item[i].expire_time = 0;
 
 		for( j = 0; j < MAX_SLOTS; j++ ){
-			Sql_GetData(sql_handle,8 + j, &data, NULL); msg->item[i].card[j] = strtoul(data, nullptr, 10);
+			Sql_GetData(sql_handle,8 + j, &data, nullptr); msg->item[i].card[j] = strtoul(data, nullptr, 10);
 		}
 
 		for( j = 0; j < MAX_ITEM_RDM_OPT; j++ ){
-			Sql_GetData(sql_handle, 8 + MAX_SLOTS + j * 3, &data, NULL); msg->item[i].option[j].id = atoi(data);
-			Sql_GetData(sql_handle, 9 + MAX_SLOTS + j * 3, &data, NULL); msg->item[i].option[j].value = atoi(data);
-			Sql_GetData(sql_handle,10 + MAX_SLOTS + j * 3, &data, NULL); msg->item[i].option[j].param = atoi(data);
+			Sql_GetData(sql_handle, 8 + MAX_SLOTS + j * 3, &data, nullptr); msg->item[i].option[j].id = atoi(data);
+			Sql_GetData(sql_handle, 9 + MAX_SLOTS + j * 3, &data, nullptr); msg->item[i].option[j].value = atoi(data);
+			Sql_GetData(sql_handle,10 + MAX_SLOTS + j * 3, &data, nullptr); msg->item[i].option[j].param = atoi(data);
 		}
 	}
 
@@ -291,10 +291,10 @@ int mail_timer_sub( int limit, enum mail_inbox_type type ){
 	for( int i = 0; i < MAIL_ITERATION_SIZE && SQL_SUCCESS == Sql_NextRow( sql_handle ); i++ ){
 		char* data;
 
-		Sql_GetData(sql_handle, 0, &data, NULL); mails[i].mail_id = atoi(data);
-		Sql_GetData(sql_handle, 1, &data, NULL); mails[i].char_id = atoi(data);
-		Sql_GetData(sql_handle, 2, &data, NULL); mails[i].account_id = atoi(data);
-		Sql_GetData( sql_handle, 3, &data, NULL ); mails[i].account_id_sender = atoi( data );
+		Sql_GetData(sql_handle, 0, &data, nullptr); mails[i].mail_id = atoi(data);
+		Sql_GetData(sql_handle, 1, &data, nullptr); mails[i].char_id = atoi(data);
+		Sql_GetData(sql_handle, 2, &data, nullptr); mails[i].account_id = atoi(data);
+		Sql_GetData( sql_handle, 3, &data, nullptr ); mails[i].account_id_sender = atoi( data );
 	}
 
 	Sql_FreeResult(sql_handle);
@@ -558,7 +558,7 @@ void mapif_Mail_return( int fd, uint32 char_id, int mail_id, uint32 account_id_r
 
 	msg.status = MAIL_NEW;
 	msg.type = MAIL_INBOX_RETURNED;
-	msg.timestamp = time( NULL );
+	msg.timestamp = time( nullptr );
 
 	int new_mail = mail_savemessage( &msg );
 	mapif_Mail_new( &msg );
@@ -625,7 +625,7 @@ void mapif_parse_Mail_send(int fd)
 		msg.dest_name[0] = '\0';
 
 		if( SQL_SUCCESS == Sql_NextRow(sql_handle) ){
-			Sql_GetData(sql_handle, 0, &data, NULL);
+			Sql_GetData(sql_handle, 0, &data, nullptr);
 			msg.dest_id = atoi(data);
 			Sql_GetData(sql_handle, 1, &data, &len);
 			safestrncpy(msg.dest_name, data, NAME_LENGTH);
@@ -642,15 +642,15 @@ void mapif_parse_Mail_send(int fd)
 #if PACKETVER < 20150513
 		uint32 account_id = RFIFOL(fd,4);
 
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		if (atoi(data) != account_id)
 		{ // Cannot send mail to char in the same account
-			Sql_GetData(sql_handle, 1, &data, NULL);
+			Sql_GetData(sql_handle, 1, &data, nullptr);
 			msg.dest_id = atoi(data);
 		}
 #else
 		// In RODEX you can even send mails to yourself
-		Sql_GetData(sql_handle, 1, &data, NULL);
+		Sql_GetData(sql_handle, 1, &data, nullptr);
 		msg.dest_id = atoi(data);
 #endif
 	}
@@ -676,7 +676,7 @@ bool mail_sendmail(int send_id, const char* send_name, int dest_id, const char*
 	safestrncpy(msg.title, title, MAIL_TITLE_LENGTH);
 	safestrncpy(msg.body, body, MAIL_BODY_LENGTH);
 	msg.zeny = zeny;
-	if( item != NULL ){
+	if( item != nullptr ){
 		int i;
 
 		for( i = 0; i < amount && i < MAIL_MAX_ITEM; i++ ){
@@ -684,7 +684,7 @@ bool mail_sendmail(int send_id, const char* send_name, int dest_id, const char*
 		}
 	}
 
-	msg.timestamp = time(NULL);
+	msg.timestamp = time(nullptr);
 	msg.type = MAIL_INBOX_NORMAL;
 
 	if( !mail_savemessage(&msg) ){
@@ -721,9 +721,9 @@ void mapif_parse_Mail_receiver_check( int fd ){
 	}else if( SQL_SUCCESS == Sql_NextRow(sql_handle) ){
 		char *data;
 
-		Sql_GetData(sql_handle, 0, &data, NULL); char_id = atoi(data);
-		Sql_GetData(sql_handle, 1, &data, NULL); class_ = atoi(data);
-		Sql_GetData(sql_handle, 2, &data, NULL); base_level = atoi(data);
+		Sql_GetData(sql_handle, 0, &data, nullptr); char_id = atoi(data);
+		Sql_GetData(sql_handle, 1, &data, nullptr); class_ = atoi(data);
+		Sql_GetData(sql_handle, 2, &data, nullptr); base_level = atoi(data);
 	}
 
 	Sql_FreeResult(sql_handle);

+ 12 - 12
src/char/int_mercenary.cpp

@@ -31,13 +31,13 @@ bool mercenary_owner_fromsql(uint32 char_id, struct mmo_charstatus *status)
 		return false;
 	}
 
-	Sql_GetData(sql_handle,  0, &data, NULL); status->mer_id = atoi(data);
-	Sql_GetData(sql_handle,  1, &data, NULL); status->arch_calls = atoi(data);
-	Sql_GetData(sql_handle,  2, &data, NULL); status->arch_faith = atoi(data);
-	Sql_GetData(sql_handle,  3, &data, NULL); status->spear_calls = atoi(data);
-	Sql_GetData(sql_handle,  4, &data, NULL); status->spear_faith = atoi(data);
-	Sql_GetData(sql_handle,  5, &data, NULL); status->sword_calls = atoi(data);
-	Sql_GetData(sql_handle,  6, &data, NULL); status->sword_faith = atoi(data);
+	Sql_GetData(sql_handle,  0, &data, nullptr); status->mer_id = atoi(data);
+	Sql_GetData(sql_handle,  1, &data, nullptr); status->arch_calls = atoi(data);
+	Sql_GetData(sql_handle,  2, &data, nullptr); status->arch_faith = atoi(data);
+	Sql_GetData(sql_handle,  3, &data, nullptr); status->spear_calls = atoi(data);
+	Sql_GetData(sql_handle,  4, &data, nullptr); status->spear_faith = atoi(data);
+	Sql_GetData(sql_handle,  5, &data, nullptr); status->sword_calls = atoi(data);
+	Sql_GetData(sql_handle,  6, &data, nullptr); status->sword_faith = atoi(data);
 	Sql_FreeResult(sql_handle);
 
 	return true;
@@ -113,11 +113,11 @@ bool mapif_mercenary_load(int merc_id, uint32 char_id, struct s_mercenary *merc)
 		return false;
 	}
 
-	Sql_GetData(sql_handle,  0, &data, NULL); merc->class_ = atoi(data);
-	Sql_GetData(sql_handle,  1, &data, NULL); merc->hp = atoi(data);
-	Sql_GetData(sql_handle,  2, &data, NULL); merc->sp = atoi(data);
-	Sql_GetData(sql_handle,  3, &data, NULL); merc->kill_count = atoi(data);
-	Sql_GetData(sql_handle,  4, &data, NULL); merc->life_time = strtoll( data, nullptr, 10 );
+	Sql_GetData(sql_handle,  0, &data, nullptr); merc->class_ = atoi(data);
+	Sql_GetData(sql_handle,  1, &data, nullptr); merc->hp = atoi(data);
+	Sql_GetData(sql_handle,  2, &data, nullptr); merc->sp = atoi(data);
+	Sql_GetData(sql_handle,  3, &data, nullptr); merc->kill_count = atoi(data);
+	Sql_GetData(sql_handle,  4, &data, nullptr); merc->life_time = strtoll( data, nullptr, 10 );
 	Sql_FreeResult(sql_handle);
 	if( charserv_config.save_log )
 		ShowInfo("Mercenary loaded (ID: %d / Class: %d / CID: %d).\n", merc->mercenary_id, merc->class_, merc->char_id);

+ 24 - 24
src/char/int_party.cpp

@@ -121,7 +121,7 @@ int inter_party_tosql(struct party *p, int flag, int index)
 	char esc_name[NAME_LENGTH*2+1];// escaped party name
 	int32 party_id;
 
-	if( p == NULL || p->party_id == 0 )
+	if( p == nullptr || p->party_id == 0 )
 		return 0;
 	party_id = p->party_id;
 
@@ -201,7 +201,7 @@ std::shared_ptr<struct party_data> inter_party_fromsql( int party_id ){
 	ShowInfo("Load party request (" CL_BOLD "%d" CL_RESET ")\n", party_id);
 #endif
 	if( party_id <= 0 )
-		return NULL;
+		return nullptr;
 
 	//Load from memory
 	std::shared_ptr<struct party_data> p = util::umap_find( party_db, party_id );
@@ -213,38 +213,38 @@ std::shared_ptr<struct party_data> inter_party_fromsql( int party_id ){
 	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `party_id`, `name`,`exp`,`item`, `leader_id`, `leader_char` FROM `%s` WHERE `party_id`='%d'", schema_config.party_db, party_id) )
 	{
 		Sql_ShowDebug(sql_handle);
-		return NULL;
+		return nullptr;
 	}
 
 	if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
-		return NULL;
+		return nullptr;
 
 	p = std::make_shared<struct party_data>();
 
 	p->party.party_id = party_id;
 	Sql_GetData(sql_handle, 1, &data, &len); memcpy(p->party.name, data, zmin(len, NAME_LENGTH));
-	Sql_GetData(sql_handle, 2, &data, NULL); p->party.exp = (atoi(data) ? 1 : 0);
-	Sql_GetData(sql_handle, 3, &data, NULL); p->party.item = atoi(data);
-	Sql_GetData(sql_handle, 4, &data, NULL); leader_id = atoi(data);
-	Sql_GetData(sql_handle, 5, &data, NULL); leader_char = atoi(data);
+	Sql_GetData(sql_handle, 2, &data, nullptr); p->party.exp = (atoi(data) ? 1 : 0);
+	Sql_GetData(sql_handle, 3, &data, nullptr); p->party.item = atoi(data);
+	Sql_GetData(sql_handle, 4, &data, nullptr); leader_id = atoi(data);
+	Sql_GetData(sql_handle, 5, &data, nullptr); leader_char = atoi(data);
 	Sql_FreeResult(sql_handle);
 
 	// Load members
 	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `account_id`,`char_id`,`name`,`base_level`,`last_map`,`online`,`class` FROM `%s` WHERE `party_id`='%d'", schema_config.char_db, party_id) )
 	{
 		Sql_ShowDebug(sql_handle);
-		return NULL;
+		return nullptr;
 	}
 	for( i = 0; i < MAX_PARTY && SQL_SUCCESS == Sql_NextRow(sql_handle); ++i )
 	{
 		m = &p->party.member[i];
-		Sql_GetData(sql_handle, 0, &data, NULL); m->account_id = atoi(data);
-		Sql_GetData(sql_handle, 1, &data, NULL); m->char_id = atoi(data);
+		Sql_GetData(sql_handle, 0, &data, nullptr); m->account_id = atoi(data);
+		Sql_GetData(sql_handle, 1, &data, nullptr); m->char_id = atoi(data);
 		Sql_GetData(sql_handle, 2, &data, &len); memcpy(m->name, data, zmin(len, NAME_LENGTH));
-		Sql_GetData(sql_handle, 3, &data, NULL); m->lv = atoi(data);
+		Sql_GetData(sql_handle, 3, &data, nullptr); m->lv = atoi(data);
 		Sql_GetData(sql_handle, 4, &data, &len); memcpy(m->map, data, zmin(len, sizeof(m->map)));
-		Sql_GetData(sql_handle, 5, &data, NULL); m->online = (atoi(data) ? 1 : 0);
-		Sql_GetData(sql_handle, 6, &data, NULL); m->class_ = atoi(data);
+		Sql_GetData(sql_handle, 5, &data, nullptr); m->online = (atoi(data) ? 1 : 0);
+		Sql_GetData(sql_handle, 6, &data, nullptr); m->class_ = atoi(data);
 		m->leader = (m->account_id == leader_id && m->char_id == leader_char ? 1 : 0);
 	}
 	Sql_FreeResult(sql_handle);
@@ -289,7 +289,7 @@ std::shared_ptr<struct party_data> search_partyname( char* str ){
 		Sql_ShowDebug(sql_handle);
 	else if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
 	{
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		p = inter_party_fromsql(atoi(data));
 	}
 	Sql_FreeResult(sql_handle);
@@ -368,7 +368,7 @@ int mapif_party_created(int fd,uint32 account_id,uint32 char_id,struct party *p)
 	WFIFOW(fd,0)=0x3820;
 	WFIFOL(fd,2)=account_id;
 	WFIFOL(fd,6)=char_id;
-	if(p!=NULL){
+	if(p!=nullptr){
 		WFIFOB(fd,10)=0;
 		WFIFOL(fd,11)=p->party_id;
 		memcpy(WFIFOP(fd,15),p->name,NAME_LENGTH);
@@ -507,27 +507,27 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part
 	std::shared_ptr<struct party_data> p = search_partyname( name );
 
 	if( p != nullptr ){
-		mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
+		mapif_party_created(fd,leader->account_id,leader->char_id,nullptr);
 		return 0;
 	}
 
 	// Check Authorised letters/symbols in the name of the character
 	if (charserv_config.char_config.char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
 		for( int i = 0; i < NAME_LENGTH && name[i]; i++ ){
-			if (strchr(charserv_config.char_config.char_name_letters, name[i]) == NULL) {
+			if (strchr(charserv_config.char_config.char_name_letters, name[i]) == nullptr) {
 				if( name[i] == '"' ) { /* client-special-char */
 					normalize_name(name,"\"");
 					mapif_parse_CreateParty(fd,name,item,item2,leader);
 					return 0;
 				}
-				mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
+				mapif_party_created(fd,leader->account_id,leader->char_id,nullptr);
 				return 0;
 			}
 		}
 	} else if (charserv_config.char_config.char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
 		for( int i = 0; i < NAME_LENGTH && name[i]; i++ ){
-			if (strchr(charserv_config.char_config.char_name_letters, name[i]) != NULL) {
-				mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
+			if (strchr(charserv_config.char_config.char_name_letters, name[i]) != nullptr) {
+				mapif_party_created(fd,leader->account_id,leader->char_id,nullptr);
 				return 0;
 			}
 		}
@@ -552,7 +552,7 @@ int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct part
 		mapif_party_created(fd,leader->account_id,leader->char_id,&p->party);
 	}else{
 		// Failed to create party.
-		mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
+		mapif_party_created(fd,leader->account_id,leader->char_id,nullptr);
 	}
 
 	return 0;
@@ -851,7 +851,7 @@ int inter_party_CharOnline(uint32 char_id, int party_id)
 		if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
 			return 0; //Eh? No party?
 
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		party_id = atoi(data);
 		Sql_FreeResult(sql_handle);
 	}
@@ -897,7 +897,7 @@ int inter_party_CharOffline(uint32 char_id, int party_id) {
 		if( SQL_SUCCESS != Sql_NextRow(sql_handle) )
 			return 0; //Eh? No party?
 
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		party_id = atoi(data);
 		Sql_FreeResult(sql_handle);
 	}

+ 14 - 14
src/char/int_pet.cpp

@@ -80,18 +80,18 @@ int inter_pet_fromsql(int pet_id, struct s_pet* p)
 	if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
 	{
 		p->pet_id = pet_id;
-		Sql_GetData(sql_handle,  1, &data, NULL); p->class_ = atoi(data);
+		Sql_GetData(sql_handle,  1, &data, nullptr); p->class_ = atoi(data);
 		Sql_GetData(sql_handle,  2, &data, &len); memcpy(p->name, data, zmin(len, NAME_LENGTH));
-		Sql_GetData(sql_handle,  3, &data, NULL); p->account_id = atoi(data);
-		Sql_GetData(sql_handle,  4, &data, NULL); p->char_id = atoi(data);
-		Sql_GetData(sql_handle,  5, &data, NULL); p->level = atoi(data);
-		Sql_GetData(sql_handle,  6, &data, NULL); p->egg_id = strtoul(data, nullptr, 10);
-		Sql_GetData(sql_handle,  7, &data, NULL); p->equip = strtoul(data, nullptr, 10);
-		Sql_GetData(sql_handle,  8, &data, NULL); p->intimate = atoi(data);
-		Sql_GetData(sql_handle,  9, &data, NULL); p->hungry = atoi(data);
-		Sql_GetData(sql_handle, 10, &data, NULL); p->rename_flag = atoi(data);
-		Sql_GetData(sql_handle, 11, &data, NULL); p->incubate = atoi(data);
-		Sql_GetData(sql_handle, 12, &data, NULL); p->autofeed = atoi(data) != 0;
+		Sql_GetData(sql_handle,  3, &data, nullptr); p->account_id = atoi(data);
+		Sql_GetData(sql_handle,  4, &data, nullptr); p->char_id = atoi(data);
+		Sql_GetData(sql_handle,  5, &data, nullptr); p->level = atoi(data);
+		Sql_GetData(sql_handle,  6, &data, nullptr); p->egg_id = strtoul(data, nullptr, 10);
+		Sql_GetData(sql_handle,  7, &data, nullptr); p->equip = strtoul(data, nullptr, 10);
+		Sql_GetData(sql_handle,  8, &data, nullptr); p->intimate = atoi(data);
+		Sql_GetData(sql_handle,  9, &data, nullptr); p->hungry = atoi(data);
+		Sql_GetData(sql_handle, 10, &data, nullptr); p->rename_flag = atoi(data);
+		Sql_GetData(sql_handle, 11, &data, nullptr); p->incubate = atoi(data);
+		Sql_GetData(sql_handle, 12, &data, nullptr); p->autofeed = atoi(data) != 0;
 
 		Sql_FreeResult(sql_handle);
 
@@ -128,7 +128,7 @@ int mapif_pet_created(int fd, uint32 account_id, struct s_pet *p)
 	WFIFOHEAD(fd, 12);
 	WFIFOW(fd, 0) = 0x3880;
 	WFIFOL(fd, 2) = account_id;
-	if(p!=NULL){
+	if(p!=nullptr){
 		WFIFOW(fd, 6) = p->class_;
 		WFIFOL(fd, 8) = p->pet_id;
 		ShowInfo("int_pet: created pet %d - %s\n", p->pet_id, p->name);
@@ -221,7 +221,7 @@ int mapif_create_pet(int fd, uint32 account_id, uint32 char_id, short pet_class,
 			mapif_load_pet(fd, account_id, char_id, pet_pt->pet_id);
 		}
 	}else	//Failed...
-		mapif_pet_created(fd, account_id, NULL);
+		mapif_pet_created(fd, account_id, nullptr);
 
 	return 0;
 }
@@ -231,7 +231,7 @@ int mapif_load_pet(int fd, uint32 account_id, uint32 char_id, int pet_id){
 
 	inter_pet_fromsql(pet_id, pet_pt);
 
-	if(pet_pt!=NULL) {
+	if(pet_pt!=nullptr) {
 		if(pet_pt->incubate == 1) {
 			pet_pt->account_id = pet_pt->char_id = 0;
 			mapif_pet_info(fd, account_id, pet_pt);

+ 13 - 13
src/char/int_quest.cpp

@@ -24,18 +24,18 @@
  *         caller to aFree() it afterwards.
  */
 struct quest *mapif_quests_fromsql(uint32 char_id, int *count) {
-	struct quest *questlog = NULL;
+	struct quest *questlog = nullptr;
 	struct quest tmp_quest;
 	SqlStmt *stmt;
 
 	if( !count )
-		return NULL;
+		return nullptr;
 
 	stmt = SqlStmt_Malloc(sql_handle);
-	if( stmt == NULL ) {
+	if( stmt == nullptr ) {
 		SqlStmt_ShowDebug(stmt);
 		*count = 0;
-		return NULL;
+		return nullptr;
 	}
 
 	memset(&tmp_quest, 0, sizeof(struct quest));
@@ -43,17 +43,17 @@ struct quest *mapif_quests_fromsql(uint32 char_id, int *count) {
 	if( SQL_ERROR == SqlStmt_Prepare(stmt, "SELECT `quest_id`, `state`, `time`, `count1`, `count2`, `count3` FROM `%s` WHERE `char_id`=? ", schema_config.quest_db)
 	||	SQL_ERROR == SqlStmt_BindParam(stmt, 0, SQLDT_INT, &char_id, 0)
 	||	SQL_ERROR == SqlStmt_Execute(stmt)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT,  &tmp_quest.quest_id, 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT,  &tmp_quest.state,    0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT, &tmp_quest.time,     0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_INT,  &tmp_quest.count[0], 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_INT,  &tmp_quest.count[1], 0, NULL, NULL)
-	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_INT,  &tmp_quest.count[2], 0, NULL, NULL)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 0, SQLDT_INT,  &tmp_quest.quest_id, 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 1, SQLDT_INT,  &tmp_quest.state,    0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 2, SQLDT_UINT, &tmp_quest.time,     0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 3, SQLDT_INT,  &tmp_quest.count[0], 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 4, SQLDT_INT,  &tmp_quest.count[1], 0, nullptr, nullptr)
+	||	SQL_ERROR == SqlStmt_BindColumn(stmt, 5, SQLDT_INT,  &tmp_quest.count[2], 0, nullptr, nullptr)
 	) {
 		SqlStmt_ShowDebug(stmt);
 		SqlStmt_Free(stmt);
 		*count = 0;
-		return NULL;
+		return nullptr;
 	}
 
 	*count = (int)SqlStmt_NumRows(stmt);
@@ -138,7 +138,7 @@ bool mapif_quest_update(uint32 char_id, struct quest qd) {
 int mapif_parse_quest_save(int fd) {
 	int i, j, k, old_n, new_n = (RFIFOW(fd,2) - 8) / sizeof(struct quest);
 	uint32 char_id = RFIFOL(fd,4);
-	struct quest *old_qd = NULL, *new_qd = NULL;
+	struct quest *old_qd = nullptr, *new_qd = nullptr;
 	bool success = true;
 
 	if( new_n > 0 )
@@ -189,7 +189,7 @@ int mapif_parse_quest_save(int fd) {
  */
 int mapif_parse_quest_load(int fd) {
 	uint32 char_id = RFIFOL(fd,2);
-	struct quest *tmp_questlog = NULL;
+	struct quest *tmp_questlog = nullptr;
 	int num_quests;
 
 	tmp_questlog = mapif_quests_fromsql(char_id, &num_quests);

+ 15 - 15
src/char/int_storage.cpp

@@ -355,23 +355,23 @@ bool mapif_parse_itembound_retrieve(int fd)
 		return true;
 	}
 
-	SqlStmt_BindColumn(stmt, 0, SQLDT_INT,       &item.id,           0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 1, SQLDT_UINT,      &item.nameid,       0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT,     &item.amount,       0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 3, SQLDT_UINT,      &item.equip,        0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR,      &item.identify,     0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR,      &item.refine,       0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR,      &item.attribute,    0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 7, SQLDT_UINT,      &item.expire_time,  0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 8, SQLDT_CHAR,      &item.bound,        0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 9, SQLDT_ULONGLONG, &item.unique_id,    0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 10, SQLDT_INT8,     &item.enchantgrade, 0, NULL, NULL);
+	SqlStmt_BindColumn(stmt, 0, SQLDT_INT,       &item.id,           0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 1, SQLDT_UINT,      &item.nameid,       0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 2, SQLDT_SHORT,     &item.amount,       0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 3, SQLDT_UINT,      &item.equip,        0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 4, SQLDT_CHAR,      &item.identify,     0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR,      &item.refine,       0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR,      &item.attribute,    0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 7, SQLDT_UINT,      &item.expire_time,  0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 8, SQLDT_CHAR,      &item.bound,        0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 9, SQLDT_ULONGLONG, &item.unique_id,    0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 10, SQLDT_INT8,     &item.enchantgrade, 0, nullptr, nullptr);
 	for( j = 0; j < MAX_SLOTS; ++j )
-		SqlStmt_BindColumn(stmt,11+j, SQLDT_UINT, &item.card[j], 0, NULL, NULL);
+		SqlStmt_BindColumn(stmt,11+j, SQLDT_UINT, &item.card[j], 0, nullptr, nullptr);
 	for( j = 0; j < MAX_ITEM_RDM_OPT; ++j ) {
-		SqlStmt_BindColumn(stmt, 11+MAX_SLOTS+j*3, SQLDT_SHORT, &item.option[j].id, 0, NULL, NULL);
-		SqlStmt_BindColumn(stmt, 12+MAX_SLOTS+j*3, SQLDT_SHORT, &item.option[j].value, 0, NULL, NULL);
-		SqlStmt_BindColumn(stmt, 13+MAX_SLOTS+j*3, SQLDT_CHAR, &item.option[j].param, 0, NULL, NULL);
+		SqlStmt_BindColumn(stmt, 11+MAX_SLOTS+j*3, SQLDT_SHORT, &item.option[j].id, 0, nullptr, nullptr);
+		SqlStmt_BindColumn(stmt, 12+MAX_SLOTS+j*3, SQLDT_SHORT, &item.option[j].value, 0, nullptr, nullptr);
+		SqlStmt_BindColumn(stmt, 13+MAX_SLOTS+j*3, SQLDT_CHAR, &item.option[j].param, 0, nullptr, nullptr);
 	}
 	memset(&items, 0, sizeof(items));
 	while( SQL_SUCCESS == SqlStmt_NextRow(stmt) )

+ 25 - 25
src/char/inter.cpp

@@ -44,7 +44,7 @@ InterServerDatabase interServerDb;
 
 #define WISDATA_TTL (60*1000)	//Wis data Time To Live (60 seconds)
 
-Sql* sql_handle = NULL;	///Link to mysql db, connection FD
+Sql* sql_handle = nullptr;	///Link to mysql db, connection FD
 
 int char_server_port = 3306;
 std::string char_server_ip = "127.0.0.1";
@@ -512,7 +512,7 @@ void mapif_parse_accinfo(int fd) {
 		} else {
 			if( Sql_NumRows(sql_handle) == 1 ) {//we found a perfect match
 				Sql_NextRow(sql_handle);
-				Sql_GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
+				Sql_GetData(sql_handle, 0, &data, nullptr); account_id = atoi(data);
 				Sql_FreeResult(sql_handle);
 			} else {// more than one, listing... [Dekamaster/Nightroad]
 				inter_to_fd(fd, u_fd, u_aid, (char *)msg_txt(214),(int)Sql_NumRows(sql_handle));
@@ -521,12 +521,12 @@ void mapif_parse_accinfo(int fd) {
 					short base_level, job_level, online;
 					char name[NAME_LENGTH];
 
-					Sql_GetData(sql_handle, 0, &data, NULL); account_id = atoi(data);
-					Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
-					Sql_GetData(sql_handle, 2, &data, NULL); class_ = atoi(data);
-					Sql_GetData(sql_handle, 3, &data, NULL); base_level = atoi(data);
-					Sql_GetData(sql_handle, 4, &data, NULL); job_level = atoi(data);
-					Sql_GetData(sql_handle, 5, &data, NULL); online = atoi(data);
+					Sql_GetData(sql_handle, 0, &data, nullptr); account_id = atoi(data);
+					Sql_GetData(sql_handle, 1, &data, nullptr); safestrncpy(name, data, sizeof(name));
+					Sql_GetData(sql_handle, 2, &data, nullptr); class_ = atoi(data);
+					Sql_GetData(sql_handle, 3, &data, nullptr); base_level = atoi(data);
+					Sql_GetData(sql_handle, 4, &data, nullptr); job_level = atoi(data);
+					Sql_GetData(sql_handle, 5, &data, nullptr); online = atoi(data);
 
 					inter_to_fd(fd, u_fd, u_aid, (char *)msg_txt(215), account_id, name, job_name(class_), base_level, job_level, online?"Online":"Offline");
 				}
@@ -587,13 +587,13 @@ void mapif_accinfo_ack(bool success, int map_fd, int u_fd, int u_aid, int accoun
 			char name[NAME_LENGTH];
 			char *data;
 
-			Sql_GetData(sql_handle, 0, &data, NULL); char_id = atoi(data);
-			Sql_GetData(sql_handle, 1, &data, NULL); safestrncpy(name, data, sizeof(name));
-			Sql_GetData(sql_handle, 2, &data, NULL); char_num = atoi(data);
-			Sql_GetData(sql_handle, 3, &data, NULL); class_ = atoi(data);
-			Sql_GetData(sql_handle, 4, &data, NULL); base_level = atoi(data);
-			Sql_GetData(sql_handle, 5, &data, NULL); job_level = atoi(data);
-			Sql_GetData(sql_handle, 6, &data, NULL); online = atoi(data);
+			Sql_GetData(sql_handle, 0, &data, nullptr); char_id = atoi(data);
+			Sql_GetData(sql_handle, 1, &data, nullptr); safestrncpy(name, data, sizeof(name));
+			Sql_GetData(sql_handle, 2, &data, nullptr); char_num = atoi(data);
+			Sql_GetData(sql_handle, 3, &data, nullptr); class_ = atoi(data);
+			Sql_GetData(sql_handle, 4, &data, nullptr); base_level = atoi(data);
+			Sql_GetData(sql_handle, 5, &data, nullptr); job_level = atoi(data);
+			Sql_GetData(sql_handle, 6, &data, nullptr); online = atoi(data);
 
 			inter_to_fd(map_fd, u_fd, u_aid, (char *)msg_txt(225), char_num, char_id, name, job_name(class_), base_level, job_level, online?"Online":"Offline");
 		}
@@ -702,7 +702,7 @@ int inter_accreg_fromsql(uint32 account_id, uint32 char_id, int fd, int type)
 	 * { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) }
 	 **/
 	while ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) {
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		len = strlen(data)+1;
 
 		WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 32
@@ -711,12 +711,12 @@ int inter_accreg_fromsql(uint32 account_id, uint32 char_id, int fd, int type)
 		safestrncpy(WFIFOCP(fd,plen), data, len);
 		plen += len;
 
-		Sql_GetData(sql_handle, 1, &data, NULL);
+		Sql_GetData(sql_handle, 1, &data, nullptr);
 
 		WFIFOL(fd, plen) = (uint32)atol(data);
 		plen += 4;
 
-		Sql_GetData(sql_handle, 2, &data, NULL);
+		Sql_GetData(sql_handle, 2, &data, nullptr);
 		len = strlen(data)+1;
 
 		WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 254
@@ -782,7 +782,7 @@ int inter_accreg_fromsql(uint32 account_id, uint32 char_id, int fd, int type)
 	 * { keyLength(B), key(<keyLength>), index(L), value(L) }
 	 **/
 	while ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) {
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		len = strlen(data)+1;
 
 		WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */
@@ -791,14 +791,14 @@ int inter_accreg_fromsql(uint32 account_id, uint32 char_id, int fd, int type)
 		safestrncpy(WFIFOCP(fd,plen), data, len);
 		plen += len;
 
-		Sql_GetData(sql_handle, 1, &data, NULL);
+		Sql_GetData(sql_handle, 1, &data, nullptr);
 
 		WFIFOL(fd, plen) = (uint32)atol(data);
 		plen += 4;
 
-		Sql_GetData(sql_handle, 2, &data, NULL);
+		Sql_GetData(sql_handle, 2, &data, nullptr);
 
-		WFIFOQ(fd, plen) = strtoll(data,NULL,10);
+		WFIFOQ(fd, plen) = strtoll(data,nullptr,10);
 		plen += 8;
 
 		WFIFOW(fd, 14) += 1;
@@ -837,7 +837,7 @@ int inter_config_read(const char* cfgName)
 	FILE* fp;
 
 	fp = fopen(cfgName, "r");
-	if(fp == NULL) {
+	if(fp == nullptr) {
 		ShowError("File not found: %s\n", cfgName);
 		return 1;
 	}
@@ -1376,13 +1376,13 @@ int mapif_parse_NameChangeRequest(int fd)
 	// Check Authorised letters/symbols in the name
 	if (charserv_config.char_config.char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
 		for (i = 0; i < NAME_LENGTH && name[i]; i++)
-		if (strchr(charserv_config.char_config.char_name_letters, name[i]) == NULL) {
+		if (strchr(charserv_config.char_config.char_name_letters, name[i]) == nullptr) {
 			mapif_namechange_ack(fd, account_id, char_id, type, 0, name);
 			return 0;
 		}
 	} else if (charserv_config.char_config.char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
 		for (i = 0; i < NAME_LENGTH && name[i]; i++)
-		if (strchr(charserv_config.char_config.char_name_letters, name[i]) != NULL) {
+		if (strchr(charserv_config.char_config.char_name_letters, name[i]) != nullptr) {
 			mapif_namechange_ack(fd, account_id, char_id, type, 0, name);
 			return 0;
 		}

+ 1 - 1
src/common/cli.cpp

@@ -218,7 +218,7 @@ TIMER_FUNC(parse_console_timer){
 	memset(buf,0,MAX_CONSOLE_IN); //clear out buf
 
 	if(cli_hasevent()){
-		if(fgets(buf, MAX_CONSOLE_IN, stdin)==NULL)
+		if(fgets(buf, MAX_CONSOLE_IN, stdin)==nullptr)
 			return -1;
 		else if(strlen(buf)>MIN_CONSOLE_IN)
 			parse_console(buf);

+ 3 - 3
src/common/conf.cpp

@@ -33,7 +33,7 @@ void config_setting_copy_simple(config_setting_t *parent, const config_setting_t
 	else {
 		config_setting_t *set = config_setting_add(parent, config_setting_name(src), config_setting_type(src));
 
-		if (set == NULL)
+		if (set == nullptr)
 			return;
 
 		if (CONFIG_TYPE_INT == config_setting_type(src)) {
@@ -54,7 +54,7 @@ void config_setting_copy_simple(config_setting_t *parent, const config_setting_t
 
 void config_setting_copy_elem(config_setting_t *parent, const config_setting_t *src)
 {
-	config_setting_t *set = NULL;
+	config_setting_t *set = nullptr;
 
 	if (config_setting_is_aggregate(src))
 		config_setting_copy_aggregate(parent, src);
@@ -80,7 +80,7 @@ void config_setting_copy_aggregate(config_setting_t *parent, const config_settin
 
 	newAgg = config_setting_add(parent, config_setting_name(src), config_setting_type(src));
 
-	if (newAgg == NULL)
+	if (newAgg == nullptr)
 		return;
 
 	n = config_setting_length(src);

+ 9 - 9
src/common/core.cpp

@@ -50,7 +50,7 @@ Core* global_core = nullptr;
 char db_path[12] = "db"; /// relative path for db from server
 char conf_path[12] = "conf"; /// relative path for conf from server
 
-char *SERVER_NAME = NULL;
+char *SERVER_NAME = nullptr;
 
 #ifndef MINICORE	// minimalist Core
 // Added by Gabuzomeu
@@ -177,7 +177,7 @@ const char* get_svn_revision(void) {
 	// - ignores database file structure
 	// - assumes the data in NODES.dav_cache column ends with "!svn/ver/<revision>/<path>)"
 	// - since it's a cache column, the data might not even exist
-	if( (fp = fopen(".svn" PATHSEP_STR "wc.db", "rb")) != NULL || (fp = fopen(".." PATHSEP_STR ".svn" PATHSEP_STR "wc.db", "rb")) != NULL )
+	if( (fp = fopen(".svn" PATHSEP_STR "wc.db", "rb")) != nullptr || (fp = fopen(".." PATHSEP_STR ".svn" PATHSEP_STR "wc.db", "rb")) != nullptr )
 	{
 	#ifndef SVNNODEPATH
 		//not sure how to handle branches, so i'll leave this overridable define until a better solution comes up
@@ -220,7 +220,7 @@ const char* get_svn_revision(void) {
 	}
 
 	// subversion 1.6 and older?
-	if ((fp = fopen(".svn/entries", "r")) != NULL)
+	if ((fp = fopen(".svn/entries", "r")) != nullptr)
 	{
 		char line[1024];
 		int rev;
@@ -239,8 +239,8 @@ const char* get_svn_revision(void) {
 			else
 			{
 				// Bin File format
-				if ( fgets(line, sizeof(line), fp) == NULL ) { printf("Can't get bin name\n"); } // Get the name
-				if ( fgets(line, sizeof(line), fp) == NULL ) { printf("Can't get entries kind\n"); } // Get the entries kind
+				if ( fgets(line, sizeof(line), fp) == nullptr ) { printf("Can't get bin name\n"); } // Get the name
+				if ( fgets(line, sizeof(line), fp) == nullptr ) { printf("Can't get entries kind\n"); } // Get the entries kind
 				if(fgets(line, sizeof(line), fp)) // Get the rev numver
 				{
 					snprintf(svn_version_buffer, sizeof(svn_version_buffer), "%d", atoi(line));
@@ -267,8 +267,8 @@ const char *get_git_hash (void) {
 	if( GitHash[0] != '\0' )
 		return GitHash;
 
-	if( (fp = fopen(".git/refs/remotes/origin/master", "r")) != NULL || // Already pulled once
-		(fp = fopen(".git/refs/heads/master", "r")) != NULL ) { // Cloned only
+	if( (fp = fopen(".git/refs/remotes/origin/master", "r")) != nullptr || // Already pulled once
+		(fp = fopen(".git/refs/heads/master", "r")) != nullptr ) { // Cloned only
 		char line[64];
 		char *rev = (char*)malloc(sizeof(char) * 50);
 
@@ -340,8 +340,8 @@ int Core::start( int argc, char **argv ){
 
 	{// initialize program arguments
 		char *p1;
-		if((p1 = strrchr(argv[0], '/')) != NULL ||  (p1 = strrchr(argv[0], '\\')) != NULL ){
-			char *pwd = NULL; //path working directory
+		if((p1 = strrchr(argv[0], '/')) != nullptr ||  (p1 = strrchr(argv[0], '\\')) != nullptr ){
+			char *pwd = nullptr; //path working directory
 			SERVER_NAME = ++p1;
 			size_t n = p1-argv[0]; //calc dir name len
 			pwd = safestrncpy((char*)malloc(n + 1), argv[0], n);

+ 124 - 124
src/common/db.cpp

@@ -30,7 +30,7 @@
  *  <B>How to add new database types:</B>
  *  1. Add the identifier of the new database type to the enum DBType
  *  2. If not already there, add the data type of the key to the union DBKey
- *  3. If the key can be considered NULL, update the function db_is_key_null
+ *  3. If the key can be considered nullptr, update the function db_is_key_null
  *  4. If the key can be duplicated, update the functions db_dup_key and
  *     db_dup_key_free
  *  5. Create a comparator and update the function db_default_cmp
@@ -343,7 +343,7 @@ struct eri *db_alloc_ers;
  *  db_rotate_right    - Rotate a tree node to the right.                    *
  *  db_rebalance       - Rebalance the tree.                                 *
  *  db_rebalance_erase - Rebalance the tree after a BLACK node was erased.   *
- *  db_is_key_null     - Returns not 0 if the key is considered NULL.        *
+ *  db_is_key_null     - Returns not 0 if the key is considered nullptr.     *
  *  db_dup_key         - Duplicate a key for internal use.                   *
  *  db_dup_key_free    - Free the duplicated key.                            *
  *  db_free_add        - Add a node to the free_list of a database.          *
@@ -491,18 +491,18 @@ static void db_rebalance(DBNode *node, DBNode **root)
 static void db_rebalance_erase(DBNode *node, DBNode **root)
 {
 	DBNode *y = node;
-	DBNode *x = NULL;
-	DBNode *x_parent = NULL;
+	DBNode *x = nullptr;
+	DBNode *x_parent = nullptr;
 
 	DB_COUNTSTAT(db_rebalance_erase);
 	// Select where to change the tree
-	if (y->left == NULL) { // no left
+	if (y->left == nullptr) { // no left
 		x = y->right;
-	} else if (y->right == NULL) { // no right
+	} else if (y->right == nullptr) { // no right
 		x = y->left;
 	} else { // both exist, go to the leftmost node of the right sub-tree
 		y = y->right;
-		while (y->left != NULL)
+		while (y->left != nullptr)
 			y = y->left;
 		x = y->right;
 	}
@@ -559,7 +559,7 @@ static void db_rebalance_erase(DBNode *node, DBNode **root)
 
 	// Restore the RED-BLACK properties
 	if (y->color != RED) {
-		while (x != *root && (x == NULL || x->color == BLACK)) {
+		while (x != *root && (x == nullptr || x->color == BLACK)) {
 			DBNode *w;
 			if (x == x_parent->left) {
 				w = x_parent->right;
@@ -569,13 +569,13 @@ static void db_rebalance_erase(DBNode *node, DBNode **root)
 					db_rotate_left(x_parent, root);
 					w = x_parent->right;
 				}
-				if ((w->left == NULL || w->left->color == BLACK) &&
-					(w->right == NULL || w->right->color == BLACK)) {
+				if ((w->left == nullptr || w->left->color == BLACK) &&
+					(w->right == nullptr || w->right->color == BLACK)) {
 					w->color = RED;
 					x = x_parent;
 					x_parent = x_parent->parent;
 				} else {
-					if (w->right == NULL || w->right->color == BLACK) {
+					if (w->right == nullptr || w->right->color == BLACK) {
 						if (w->left) w->left->color = BLACK;
 						w->color = RED;
 						db_rotate_right(w, root);
@@ -595,13 +595,13 @@ static void db_rebalance_erase(DBNode *node, DBNode **root)
 					db_rotate_right(x_parent, root);
 					w = x_parent->left;
 				}
-				if ((w->right == NULL || w->right->color == BLACK) &&
-					(w->left == NULL || w->left->color == BLACK)) {
+				if ((w->right == nullptr || w->right->color == BLACK) &&
+					(w->left == nullptr || w->left->color == BLACK)) {
 					w->color = RED;
 					x = x_parent;
 					x_parent = x_parent->parent;
 				} else {
-					if (w->left == NULL || w->left->color == BLACK) {
+					if (w->left == nullptr || w->left->color == BLACK) {
 						if (w->right) w->right->color = BLACK;
 						w->color = RED;
 						db_rotate_left(w, root);
@@ -620,10 +620,10 @@ static void db_rebalance_erase(DBNode *node, DBNode **root)
 }
 
 /**
- * Returns not 0 if the key is considered to be NULL.
+ * Returns not 0 if the key is considered to be nullptr.
  * @param type Type of database
  * @param key Key being tested
- * @return not 0 if considered NULL, 0 otherwise
+ * @return not 0 if considered nullptr, 0 otherwise
  * @private
  * @see #db_obj_get(DBMap*,DBKey)
  * @see #db_obj_put(DBMap*,DBKey,DBData)
@@ -635,7 +635,7 @@ static int db_is_key_null(DBType type, DBKey key)
 	switch (type) {
 		case DB_STRING:
 		case DB_ISTRING:
-			return (key.str == NULL);
+			return (key.str == nullptr);
 
 		default: // Not a pointer
 			return 0;
@@ -1155,7 +1155,7 @@ static void db_release_data(DBKey key, DBData data, DBRelease which)
 	DB_COUNTSTAT(db_release_data);
 	if (which&DB_RELEASE_DATA && data.type == DB_DATA_PTR) {
 		aFree(data.u.ptr);
-		data.u.ptr = NULL;
+		data.u.ptr = nullptr;
 	}
 }
 
@@ -1177,7 +1177,7 @@ static void db_release_both(DBKey key, DBData data, DBRelease which)
 	if (which&DB_RELEASE_KEY) aFree((char*)key.str); // needs to be a pointer
 	if (which&DB_RELEASE_DATA && data.type == DB_DATA_PTR) {
 		aFree(data.u.ptr);
-		data.u.ptr = NULL;
+		data.u.ptr = nullptr;
 	}
 }
 
@@ -1217,7 +1217,7 @@ static void db_release_both(DBKey key, DBData data, DBRelease which)
 /**
  * Fetches the first entry in the database.
  * Returns the data of the entry.
- * Puts the key in out_key, if out_key is not NULL.
+ * Puts the key in out_key, if out_key is not nullptr.
  * @param self Iterator
  * @param out_key Key of the entry
  * @return Data of the entry
@@ -1231,7 +1231,7 @@ DBData* dbit_obj_first(DBIterator* self, DBKey* out_key)
 	DB_COUNTSTAT(dbit_first);
 	// position before the first entry
 	it->ht_index = -1;
-	it->node = NULL;
+	it->node = nullptr;
 	// get next entry
 	return self->next(self, out_key);
 }
@@ -1239,7 +1239,7 @@ DBData* dbit_obj_first(DBIterator* self, DBKey* out_key)
 /**
  * Fetches the last entry in the database.
  * Returns the data of the entry.
- * Puts the key in out_key, if out_key is not NULL.
+ * Puts the key in out_key, if out_key is not nullptr.
  * @param self Iterator
  * @param out_key Key of the entry
  * @return Data of the entry
@@ -1253,7 +1253,7 @@ DBData* dbit_obj_last(DBIterator* self, DBKey* out_key)
 	DB_COUNTSTAT(dbit_last);
 	// position after the last entry
 	it->ht_index = HASH_SIZE;
-	it->node = NULL;
+	it->node = nullptr;
 	// get previous entry
 	return self->prev(self, out_key);
 }
@@ -1261,7 +1261,7 @@ DBData* dbit_obj_last(DBIterator* self, DBKey* out_key)
 /**
  * Fetches the next entry in the database.
  * Returns the data of the entry.
- * Puts the key in out_key, if out_key is not NULL.
+ * Puts the key in out_key, if out_key is not nullptr.
  * @param self Iterator
  * @param out_key Key of the entry
  * @return Data of the entry
@@ -1279,17 +1279,17 @@ DBData* dbit_obj_next(DBIterator* self, DBKey* out_key)
 	if( it->ht_index < 0 )
 	{// get first node
 		it->ht_index = 0;
-		it->node = NULL;
+		it->node = nullptr;
 	}
 	node = it->node;
 	memset(&fake, 0, sizeof(fake));
 	for( ; it->ht_index < HASH_SIZE; ++(it->ht_index) )
 	{
 		// Iterate in the order: left tree, current node, right tree
-		if( node == NULL )
+		if( node == nullptr )
 		{// prepare initial node of this hash
 			node = it->db->ht[it->ht_index];
-			if( node == NULL )
+			if( node == nullptr )
 				continue;// next hash
 			fake.right = node;
 			node = &fake;
@@ -1313,9 +1313,9 @@ DBData* dbit_obj_next(DBIterator* self, DBKey* out_key)
 					node = parent;
 					parent = node->parent;
 				}
-				if( parent == NULL )
+				if( parent == nullptr )
 				{// next hash
-					node = NULL;
+					node = nullptr;
 					break;
 				}
 				node = parent;
@@ -1330,14 +1330,14 @@ DBData* dbit_obj_next(DBIterator* self, DBKey* out_key)
 			}
 		}
 	}
-	it->node = NULL;
-	return NULL;// not found
+	it->node = nullptr;
+	return nullptr;// not found
 }
 
 /**
  * Fetches the previous entry in the database.
  * Returns the data of the entry.
- * Puts the key in out_key, if out_key is not NULL.
+ * Puts the key in out_key, if out_key is not nullptr.
  * @param self Iterator
  * @param out_key Key of the entry
  * @return Data of the entry
@@ -1355,17 +1355,17 @@ DBData* dbit_obj_prev(DBIterator* self, DBKey* out_key)
 	if( it->ht_index >= HASH_SIZE )
 	{// get last node
 		it->ht_index = HASH_SIZE-1;
-		it->node = NULL;
+		it->node = nullptr;
 	}
 	node = it->node;
 	memset(&fake, 0, sizeof(fake));
 	for( ; it->ht_index >= 0; --(it->ht_index) )
 	{
 		// Iterate in the order: right tree, current node, left tree
-		if( node == NULL )
+		if( node == nullptr )
 		{// prepare initial node of this hash
 			node = it->db->ht[it->ht_index];
-			if( node == NULL )
+			if( node == nullptr )
 				continue;// next hash
 			fake.left = node;
 			node = &fake;
@@ -1389,9 +1389,9 @@ DBData* dbit_obj_prev(DBIterator* self, DBKey* out_key)
 					node = parent;
 					parent = node->parent;
 				}
-				if( parent == NULL )
+				if( parent == nullptr )
 				{// next hash
-					node = NULL;
+					node = nullptr;
 					break;
 				}
 				node = parent;
@@ -1406,13 +1406,13 @@ DBData* dbit_obj_prev(DBIterator* self, DBKey* out_key)
 			}
 		}
 	}
-	it->node = NULL;
-	return NULL;// not found
+	it->node = nullptr;
+	return nullptr;// not found
 }
 
 /**
  * Returns true if the fetched entry exists.
- * The databases entries might have NULL data, so use this to to test if
+ * The databases entries might have nullptr data, so use this to to test if
  * the iterator is done.
  * @param self Iterator
  * @return true if the entry exists
@@ -1431,7 +1431,7 @@ bool dbit_obj_exists(DBIterator* self)
  * Removes the current entry from the database.
  * NOTE: {@link DBIterator#exists} will return false until another entry
  *       is fetched
- * Puts data of the removed entry in out_data, if out_data is not NULL (unless data has been released)
+ * Puts data of the removed entry in out_data, if out_data is not nullptr (unless data has been released)
  * @param self Iterator
  * @param out_data Data of the removed entry.
  * @return 1 if entry was removed, 0 otherwise
@@ -1451,7 +1451,7 @@ int dbit_obj_remove(DBIterator* self, DBData *out_data)
 	{
 		DBMap_impl* db = it->db;
 		if( db->cache == node )
-			db->cache = NULL;
+			db->cache = nullptr;
 		db->release(node->key, node->data, DB_RELEASE_DATA);
 		if( out_data )
 			memcpy(out_data, &node->data, sizeof(DBData));
@@ -1504,7 +1504,7 @@ static DBIterator* db_obj_iterator(DBMap* self)
 	/* Initial state (before the first entry) */
 	it->db = db;
 	it->ht_index = -1;
-	it->node = NULL;
+	it->node = nullptr;
 	/* Lock the database */
 	db_free_lock(db);
 	return &it->vtable;
@@ -1525,7 +1525,7 @@ static bool db_obj_exists(DBMap* self, DBKey key)
 	bool found = false;
 
 	DB_COUNTSTAT(db_exists);
-	if (db == NULL) return false; // nullpo candidate
+	if (db == nullptr) return false; // nullpo candidate
 	if (!(db->options&DB_OPT_ALLOW_NULL_KEY) && db_is_key_null(db->type, key)) {
 		return false; // nullpo candidate
 	}
@@ -1564,7 +1564,7 @@ static bool db_obj_exists(DBMap* self, DBKey key)
  * Get the data of the entry identified by the key.
  * @param self Interface of the database
  * @param key Key that identifies the entry
- * @return Data of the entry or NULL if not found
+ * @return Data of the entry or nullptr if not found
  * @protected
  * @see DBMap#get
  */
@@ -1572,20 +1572,20 @@ static DBData* db_obj_get(DBMap* self, DBKey key)
 {
 	DBMap_impl* db = (DBMap_impl*)self;
 	DBNode *node;
-	DBData *data = NULL;
+	DBData *data = nullptr;
 
 	DB_COUNTSTAT(db_get);
-	if (db == NULL) return NULL; // nullpo candidate
+	if (db == nullptr) return nullptr; // nullpo candidate
 	if (!(db->options&DB_OPT_ALLOW_NULL_KEY) && db_is_key_null(db->type, key)) {
-		ShowError("db_get: Attempted to retrieve non-allowed NULL key for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
-		return NULL; // nullpo candidate
+		ShowError("db_get: Attempted to retrieve non-allowed nullptr key for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
+		return nullptr; // nullpo candidate
 	}
 
 	if (db->cache && db->cmp(key, db->cache->key, db->maxlen) == 0) {
 #if defined(DEBUG)
 		if (db->cache->deleted) {
 			ShowDebug("db_get: Cache contains a deleted node. Please report this!!!\n");
-			return NULL;
+			return nullptr;
 		}
 #endif
 		return &db->cache->data; // cache hit
@@ -1614,7 +1614,7 @@ static DBData* db_obj_get(DBMap* self, DBKey key)
 /**
  * Get the data of the entries matched by <code>match</code>.
  * It puts a maximum of <code>max</code> entries into <code>buf</code>.
- * If <code>buf</code> is NULL, it only counts the matches.
+ * If <code>buf</code> is nullptr, it only counts the matches.
  * Returns the number of entries that matched.
  * NOTE: if the value returned is greater than <code>max</code>, only the
  * first <code>max</code> entries found are put into the buffer.
@@ -1636,8 +1636,8 @@ static unsigned int db_obj_vgetall(DBMap* self, DBData **buf, unsigned int max,
 	unsigned int ret = 0;
 
 	DB_COUNTSTAT(db_vgetall);
-	if (db == NULL) return 0; // nullpo candidate
-	if (match == NULL) return 0; // nullpo candidate
+	if (db == nullptr) return 0; // nullpo candidate
+	if (match == nullptr) return 0; // nullpo candidate
 
 	db_free_lock(db);
 	for (i = 0; i < HASH_SIZE; i++) {
@@ -1685,7 +1685,7 @@ static unsigned int db_obj_vgetall(DBMap* self, DBData **buf, unsigned int max,
  * Just calls {@link DBMap#vgetall}.
  * Get the data of the entries matched by <code>match</code>.
  * It puts a maximum of <code>max</code> entries into <code>buf</code>.
- * If <code>buf</code> is NULL, it only counts the matches.
+ * If <code>buf</code> is nullptr, it only counts the matches.
  * Returns the number of entries that matched.
  * NOTE: if the value returned is greater than <code>max</code>, only the
  * first <code>max</code> entries found are put into the buffer.
@@ -1705,7 +1705,7 @@ static unsigned int db_obj_getall(DBMap* self, DBData **buf, unsigned int max, D
 	unsigned int ret;
 
 	DB_COUNTSTAT(db_getall);
-	if (self == NULL) return 0; // nullpo candidate
+	if (self == nullptr) return 0; // nullpo candidate
 
 	va_start(args, match);
 	ret = self->vgetall(self, buf, max, match, args);
@@ -1729,20 +1729,20 @@ static DBData* db_obj_vensure(DBMap* self, DBKey key, DBCreateData create, va_li
 {
 	DBMap_impl* db = (DBMap_impl*)self;
 	DBNode *node;
-	DBNode *parent = NULL;
+	DBNode *parent = nullptr;
 	unsigned int hash;
 	int c = 0;
-	DBData *data = NULL;
+	DBData *data = nullptr;
 
 	DB_COUNTSTAT(db_vensure);
-	if (db == NULL) return NULL; // nullpo candidate
-	if (create == NULL) {
-		ShowError("db_ensure: Create function is NULL for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
-		return NULL; // nullpo candidate
+	if (db == nullptr) return nullptr; // nullpo candidate
+	if (create == nullptr) {
+		ShowError("db_ensure: Create function is nullptr for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
+		return nullptr; // nullpo candidate
 	}
 	if (!(db->options&DB_OPT_ALLOW_NULL_KEY) && db_is_key_null(db->type, key)) {
-		ShowError("db_ensure: Attempted to use non-allowed NULL key for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
-		return NULL; // nullpo candidate
+		ShowError("db_ensure: Attempted to use non-allowed nullptr key for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
+		return nullptr; // nullpo candidate
 	}
 
 	if (db->cache && db->cmp(key, db->cache->key, db->maxlen) == 0)
@@ -1763,23 +1763,23 @@ static DBData* db_obj_vensure(DBMap* self, DBKey key, DBCreateData create, va_li
 			node = node->right;
 	}
 	// Create node if necessary
-	if (node == NULL) {
+	if (node == nullptr) {
 		va_list argscopy;
 		if (db->item_count == UINT32_MAX) {
 			ShowError("db_vensure: item_count overflow, aborting item insertion.\n"
 					"Database allocated at %s:%d",
 					db->alloc_file, db->alloc_line);
-				return NULL;
+				return nullptr;
 		}
 		DB_COUNTSTAT(db_node_alloc);
 		node = ers_alloc(db->nodes, struct dbn);
-		node->left = NULL;
-		node->right = NULL;
+		node->left = nullptr;
+		node->right = nullptr;
 		node->deleted = 0;
 		db->item_count++;
 		if (c == 0) { // hash entry is empty
 			node->color = BLACK;
-			node->parent = NULL;
+			node->parent = nullptr;
 			db->ht[hash] = node;
 		} else {
 			node->color = RED;
@@ -1828,10 +1828,10 @@ static DBData* db_obj_vensure(DBMap* self, DBKey key, DBCreateData create, va_li
 static DBData* db_obj_ensure(DBMap* self, DBKey key, DBCreateData create, ...)
 {
 	va_list args;
-	DBData *ret = NULL;
+	DBData *ret = nullptr;
 
 	DB_COUNTSTAT(db_ensure);
-	if (self == NULL) return NULL; // nullpo candidate
+	if (self == nullptr) return nullptr; // nullpo candidate
 
 	va_start(args, create);
 	ret = self->vensure(self, key, create, args);
@@ -1841,7 +1841,7 @@ static DBData* db_obj_ensure(DBMap* self, DBKey key, DBCreateData create, ...)
 
 /**
  * Put the data identified by the key in the database.
- * Puts the previous data in out_data, if out_data is not NULL. (unless data has been released)
+ * Puts the previous data in out_data, if out_data is not nullptr. (unless data has been released)
  * NOTE: Uses the new key, the old one is released.
  * @param self Interface of the database
  * @param key Key that identifies the data
@@ -1858,12 +1858,12 @@ static int db_obj_put(DBMap* self, DBKey key, DBData data, DBData *out_data)
 {
 	DBMap_impl* db = (DBMap_impl*)self;
 	DBNode *node;
-	DBNode *parent = NULL;
+	DBNode *parent = nullptr;
 	int c = 0, retval = 0;
 	unsigned int hash;
 
 	DB_COUNTSTAT(db_put);
-	if (db == NULL) return 0; // nullpo candidate
+	if (db == nullptr) return 0; // nullpo candidate
 	if (db->global_lock) {
 		ShowError("db_put: Database is being destroyed, aborting entry insertion.\n"
 				"Database allocated at %s:%d\n",
@@ -1871,11 +1871,11 @@ static int db_obj_put(DBMap* self, DBKey key, DBData data, DBData *out_data)
 		return 0; // nullpo candidate
 	}
 	if (!(db->options&DB_OPT_ALLOW_NULL_KEY) && db_is_key_null(db->type, key)) {
-		ShowError("db_put: Attempted to use non-allowed NULL key for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
+		ShowError("db_put: Attempted to use non-allowed nullptr key for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
 		return 0; // nullpo candidate
 	}
-	if (!(db->options&DB_OPT_ALLOW_NULL_DATA) && (data.type == DB_DATA_PTR && data.u.ptr == NULL)) {
-		ShowError("db_put: Attempted to use non-allowed NULL data for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
+	if (!(db->options&DB_OPT_ALLOW_NULL_DATA) && (data.type == DB_DATA_PTR && data.u.ptr == nullptr)) {
+		ShowError("db_put: Attempted to use non-allowed nullptr data for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
 		return 0; // nullpo candidate
 	}
 
@@ -1909,16 +1909,16 @@ static int db_obj_put(DBMap* self, DBKey key, DBData data, DBData *out_data)
 		}
 	}
 	// allocate a new node if necessary
-	if (node == NULL) {
+	if (node == nullptr) {
 		DB_COUNTSTAT(db_node_alloc);
 		node = ers_alloc(db->nodes, struct dbn);
-		node->left = NULL;
-		node->right = NULL;
+		node->left = nullptr;
+		node->right = nullptr;
 		node->deleted = 0;
 		db->item_count++;
 		if (c == 0) { // hash entry is empty
 			node->color = BLACK;
-			node->parent = NULL;
+			node->parent = nullptr;
 			db->ht[hash] = node;
 		} else {
 			node->color = RED;
@@ -1949,7 +1949,7 @@ static int db_obj_put(DBMap* self, DBKey key, DBData data, DBData *out_data)
 
 /**
  * Remove an entry from the database.
- * Puts the previous data in out_data, if out_data is not NULL. (unless data has been released)
+ * Puts the previous data in out_data, if out_data is not nullptr. (unless data has been released)
  * NOTE: The key (of the database) is released in {@link #db_free_add(DBMap_impl*,DBNode*,DBNode **)}.
  * @param self Interface of the database
  * @param key Key that identifies the entry
@@ -1967,7 +1967,7 @@ static int db_obj_remove(DBMap* self, DBKey key, DBData *out_data)
 	int retval = 0;
 
 	DB_COUNTSTAT(db_remove);
-	if (db == NULL) return 0; // nullpo candidate
+	if (db == nullptr) return 0; // nullpo candidate
 	if (db->global_lock) {
 		ShowError("db_remove: Database is being destroyed. Aborting entry deletion.\n"
 				"Database allocated at %s:%d\n",
@@ -1975,7 +1975,7 @@ static int db_obj_remove(DBMap* self, DBKey key, DBData *out_data)
 		return 0; // nullpo candidate
 	}
 	if (!(db->options&DB_OPT_ALLOW_NULL_KEY) && db_is_key_null(db->type, key)) {
-		ShowError("db_remove: Attempted to use non-allowed NULL key for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
+		ShowError("db_remove: Attempted to use non-allowed nullptr key for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
 		return 0; // nullpo candidate
 	}
 
@@ -1986,7 +1986,7 @@ static int db_obj_remove(DBMap* self, DBKey key, DBData *out_data)
 		if (c == 0) {
 			if (!(node->deleted)) {
 				if (db->cache == node)
-					db->cache = NULL;
+					db->cache = nullptr;
 				db->release(node->key, node->data, DB_RELEASE_DATA);
 				if (out_data)
 					memcpy(out_data, &node->data, sizeof(*out_data));
@@ -2023,9 +2023,9 @@ static int db_obj_vforeach(DBMap* self, DBApply func, va_list args)
 	DBNode *parent;
 
 	DB_COUNTSTAT(db_vforeach);
-	if (db == NULL) return 0; // nullpo candidate
-	if (func == NULL) {
-		ShowError("db_foreach: Passed function is NULL for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
+	if (db == nullptr) return 0; // nullpo candidate
+	if (func == nullptr) {
+		ShowError("db_foreach: Passed function is nullptr for db allocated at %s:%d\n",db->alloc_file, db->alloc_line);
 		return 0; // nullpo candidate
 	}
 
@@ -2080,7 +2080,7 @@ static int db_obj_foreach(DBMap* self, DBApply func, ...)
 	int ret;
 
 	DB_COUNTSTAT(db_foreach);
-	if (self == NULL) return 0; // nullpo candidate
+	if (self == nullptr) return 0; // nullpo candidate
 
 	va_start(args, func);
 	ret = self->vforeach(self, func, args);
@@ -2109,14 +2109,14 @@ static int db_obj_vclear(DBMap* self, DBApply func, va_list args)
 	DBNode *parent;
 
 	DB_COUNTSTAT(db_vclear);
-	if (db == NULL) return 0; // nullpo candidate
+	if (db == nullptr) return 0; // nullpo candidate
 
 	db_free_lock(db);
-	db->cache = NULL;
+	db->cache = nullptr;
 	for (i = 0; i < HASH_SIZE; i++) {
 		// Apply the func and delete in the order: left tree, right tree, current node
 		node = db->ht[i];
-		db->ht[i] = NULL;
+		db->ht[i] = nullptr;
 		while (node) {
 			parent = node->parent;
 			if (node->left) {
@@ -2143,14 +2143,14 @@ static int db_obj_vclear(DBMap* self, DBApply func, va_list args)
 			DB_COUNTSTAT(db_node_free);
 			if (parent) {
 				if (parent->left == node)
-					parent->left = NULL;
+					parent->left = nullptr;
 				else
-					parent->right = NULL;
+					parent->right = nullptr;
 			}
 			ers_free(db->nodes, node);
 			node = parent;
 		}
-		db->ht[i] = NULL;
+		db->ht[i] = nullptr;
 	}
 	db->free_count = 0;
 	db->item_count = 0;
@@ -2180,7 +2180,7 @@ static int db_obj_clear(DBMap* self, DBApply func, ...)
 	int ret;
 
 	DB_COUNTSTAT(db_clear);
-	if (self == NULL) return 0; // nullpo candidate
+	if (self == nullptr) return 0; // nullpo candidate
 
 	va_start(args, func);
 	ret = self->vclear(self, func, args);
@@ -2207,7 +2207,7 @@ static int db_obj_vdestroy(DBMap* self, DBApply func, va_list args)
 	int sum;
 
 	DB_COUNTSTAT(db_vdestroy);
-	if (db == NULL) return 0; // nullpo candidate
+	if (db == nullptr) return 0; // nullpo candidate
 	if (db->global_lock) {
 		ShowError("db_vdestroy: Database is already locked for destruction. Aborting second database destruction.\n"
 				"Database allocated at %s:%d\n",
@@ -2233,7 +2233,7 @@ static int db_obj_vdestroy(DBMap* self, DBApply func, va_list args)
 	db->global_lock = 1;
 	sum = self->vclear(self, func, args);
 	aFree(db->free_list);
-	db->free_list = NULL;
+	db->free_list = nullptr;
 	db->free_max = 0;
 	ers_destroy(db->nodes);
 	db_free_unlock(db);
@@ -2263,7 +2263,7 @@ static int db_obj_destroy(DBMap* self, DBApply func, ...)
 	int ret;
 
 	DB_COUNTSTAT(db_destroy);
-	if (self == NULL) return 0; // nullpo candidate
+	if (self == nullptr) return 0; // nullpo candidate
 
 	va_start(args, func);
 	ret = self->vdestroy(self, func, args);
@@ -2285,7 +2285,7 @@ static unsigned int db_obj_size(DBMap* self)
 	unsigned int item_count;
 
 	DB_COUNTSTAT(db_size);
-	if (db == NULL) return 0; // nullpo candidate
+	if (db == nullptr) return 0; // nullpo candidate
 
 	db_free_lock(db);
 	item_count = db->item_count;
@@ -2308,7 +2308,7 @@ static DBType db_obj_type(DBMap* self)
 	DBType type;
 
 	DB_COUNTSTAT(db_type);
-	if (db == NULL) return (DBType)-1; // nullpo candidate - TODO what should this return?
+	if (db == nullptr) return (DBType)-1; // nullpo candidate - TODO what should this return?
 
 	db_free_lock(db);
 	type = db->type;
@@ -2331,7 +2331,7 @@ static DBOptions db_obj_options(DBMap* self)
 	DBOptions options;
 
 	DB_COUNTSTAT(db_options);
-	if (db == NULL) return DB_OPT_BASE; // nullpo candidate - TODO what should this return?
+	if (db == nullptr) return DB_OPT_BASE; // nullpo candidate - TODO what should this return?
 
 	db_free_lock(db);
 	options = db->options;
@@ -2396,7 +2396,7 @@ DBOptions db_fix_options(DBType type, DBOptions options)
 /**
  * Returns the default comparator for the specified type of database.
  * @param type Type of database
- * @return Comparator for the type of database or NULL if unknown database
+ * @return Comparator for the type of database or nullptr if unknown database
  * @public
  * @see #db_int_cmp(DBKey,DBKey,unsigned short)
  * @see #db_uint_cmp(DBKey,DBKey,unsigned short)
@@ -2417,14 +2417,14 @@ DBComparator db_default_cmp(DBType type)
 		case DB_UINT64:  return &db_uint64_cmp;
 		default:
 			ShowError("db_default_cmp: Unknown database type %u\n", type);
-			return NULL;
+			return nullptr;
 	}
 }
 
 /**
  * Returns the default hasher for the specified type of database.
  * @param type Type of database
- * @return Hasher of the type of database or NULL if unknown database
+ * @return Hasher of the type of database or nullptr if unknown database
  * @public
  * @see #db_int_hash(DBKey,unsigned short)
  * @see #db_uint_hash(DBKey,unsigned short)
@@ -2445,7 +2445,7 @@ DBHasher db_default_hash(DBType type)
 		case DB_UINT64:  return &db_uint64_hash;
 		default:
 			ShowError("db_default_hash: Unknown database type %u\n", type);
-			return NULL;
+			return nullptr;
 	}
 }
 
@@ -2499,7 +2499,7 @@ DBReleaser db_custom_release(DBRelease which)
 		case DB_RELEASE_BOTH:    return &db_release_both;
 		default:
 			ShowError("db_custom_release: Unknown release options %u\n", which);
-			return NULL;
+			return nullptr;
 	}
 }
 
@@ -2560,7 +2560,7 @@ DBMap* db_alloc(const char *file, const char *func, int line, DBType type, DBOpt
 	db->alloc_file = file;
 	db->alloc_line = line;
 	/* Lock system */
-	db->free_list = NULL;
+	db->free_list = nullptr;
 	db->free_count = 0;
 	db->free_max = 0;
 	db->free_lock = 0;
@@ -2571,8 +2571,8 @@ DBMap* db_alloc(const char *file, const char *func, int line, DBType type, DBOpt
 	db->hash = db_default_hash(type);
 	db->release = db_default_release(type, options);
 	for (i = 0; i < HASH_SIZE; i++)
-		db->ht[i] = NULL;
-	db->cache = NULL;
+		db->ht[i] = nullptr;
+	db->cache = nullptr;
 	db->type = type;
 	db->options = options;
 	db->item_count = 0;
@@ -2756,7 +2756,7 @@ unsigned int db_data2ui(DBData *data)
 
 /**
  * Gets void* type data from struct DBData.
- * If data is not void* type, returns NULL.
+ * If data is not void* type, returns nullptr.
  * @param data Data
  * @return Void* value of the data.
  * @public
@@ -2766,7 +2766,7 @@ void* db_data2ptr(DBData *data)
 	DB_COUNTSTAT(db_data2ptr);
 	if (data && DB_DATA_PTR == data->type)
 		return data->u.ptr;
-	return NULL;
+	return nullptr;
 }
 
 /**
@@ -2904,13 +2904,13 @@ void db_final(void)
 void linkdb_insert( struct linkdb_node** head, void *key, void* data)
 {
 	struct linkdb_node *node;
-	if( head == NULL ) return ;
+	if( head == nullptr ) return ;
 	node = (struct linkdb_node*)aMalloc( sizeof(struct linkdb_node) );
-	if( *head == NULL ) {
+	if( *head == nullptr ) {
 		// first node
 		*head      = node;
-		node->prev = NULL;
-		node->next = NULL;
+		node->prev = nullptr;
+		node->next = nullptr;
 	} else {
 		// link nodes
 		node->next    = *head;
@@ -2924,7 +2924,7 @@ void linkdb_insert( struct linkdb_node** head, void *key, void* data)
 
 void linkdb_vforeach( struct linkdb_node** head, LinkDBFunc func, va_list ap) {
 	struct linkdb_node *node;
-	if( head == NULL ) return;
+	if( head == nullptr ) return;
 	node = *head;
 	while ( node ) {
 		va_list argscopy;
@@ -2946,7 +2946,7 @@ void* linkdb_search( struct linkdb_node** head, void *key)
 {
 	int n = 0;
 	struct linkdb_node *node;
-	if( head == NULL ) return NULL;
+	if( head == nullptr ) return nullptr;
 	node = *head;
 	while( node ) {
 		if( node->key == key ) {
@@ -2964,18 +2964,18 @@ void* linkdb_search( struct linkdb_node** head, void *key)
 		node = node->next;
 		n++;
 	}
-	return NULL;
+	return nullptr;
 }
 
 void* linkdb_erase( struct linkdb_node** head, void *key)
 {
 	struct linkdb_node *node;
-	if( head == NULL ) return NULL;
+	if( head == nullptr ) return nullptr;
 	node = *head;
 	while( node ) {
 		if( node->key == key ) {
 			void *data = node->data;
-			if( node->prev == NULL )
+			if( node->prev == nullptr )
 				*head = node->next;
 			else
 				node->prev->next = node->next;
@@ -2986,14 +2986,14 @@ void* linkdb_erase( struct linkdb_node** head, void *key)
 		}
 		node = node->next;
 	}
-	return NULL;
+	return nullptr;
 }
 
 void linkdb_replace( struct linkdb_node** head, void *key, void *data )
 {
 	int n = 0;
 	struct linkdb_node *node;
-	if( head == NULL ) return ;
+	if( head == nullptr ) return ;
 	node = *head;
 	while( node ) {
 		if( node->key == key ) {
@@ -3019,12 +3019,12 @@ void linkdb_replace( struct linkdb_node** head, void *key, void *data )
 void linkdb_final( struct linkdb_node** head )
 {
 	struct linkdb_node *node, *node2;
-	if( head == NULL ) return ;
+	if( head == nullptr ) return ;
 	node = *head;
 	while( node ) {
 		node2 = node->next;
 		aFree( node );
 		node = node2;
 	}
-	*head = NULL;
+	*head = nullptr;
 }

+ 58 - 58
src/common/db.hpp

@@ -111,7 +111,7 @@ typedef enum DBType {
  * See {@link #db_fix_options(DBType,DBOptions)} for restrictions of the
  * types of databases.
  * @param DB_OPT_BASE Base options: does not duplicate keys, releases nothing
- *          and does not allow NULL keys or NULL data.
+ *          and does not allow nullptr keys or nullptr data.
  * @param DB_OPT_DUP_KEY Duplicates the keys internally. If DB_OPT_RELEASE_KEY
  *          is defined, the real key is freed as soon as the entry is added.
  * @param DB_OPT_RELEASE_KEY Releases the key.
@@ -120,8 +120,8 @@ typedef enum DBType {
  *          WARNING: for functions that return the data (like DBMap::remove),
  *          a dangling pointer will be returned.
  * @param DB_OPT_RELEASE_BOTH Releases both key and data.
- * @param DB_OPT_ALLOW_NULL_KEY Allow NULL keys in the database.
- * @param DB_OPT_ALLOW_NULL_DATA Allow NULL data in the database.
+ * @param DB_OPT_ALLOW_NULL_KEY Allow nullptr keys in the database.
+ * @param DB_OPT_ALLOW_NULL_DATA Allow nullptr data in the database.
  * @public
  * @see #db_fix_options(DBType,DBOptions)
  * @see #db_default_release(DBType,DBOptions)
@@ -295,7 +295,7 @@ struct DBIterator
 	/**
 	 * Fetches the first entry in the database.
 	 * Returns the data of the entry.
-	 * Puts the key in out_key, if out_key is not NULL.
+	 * Puts the key in out_key, if out_key is not nullptr.
 	 * @param self Iterator
 	 * @param out_key Key of the entry
 	 * @return Data of the entry
@@ -306,7 +306,7 @@ struct DBIterator
 	/**
 	 * Fetches the last entry in the database.
 	 * Returns the data of the entry.
-	 * Puts the key in out_key, if out_key is not NULL.
+	 * Puts the key in out_key, if out_key is not nullptr.
 	 * @param self Iterator
 	 * @param out_key Key of the entry
 	 * @return Data of the entry
@@ -317,7 +317,7 @@ struct DBIterator
 	/**
 	 * Fetches the next entry in the database.
 	 * Returns the data of the entry.
-	 * Puts the key in out_key, if out_key is not NULL.
+	 * Puts the key in out_key, if out_key is not nullptr.
 	 * @param self Iterator
 	 * @param out_key Key of the entry
 	 * @return Data of the entry
@@ -328,7 +328,7 @@ struct DBIterator
 	/**
 	 * Fetches the previous entry in the database.
 	 * Returns the data of the entry.
-	 * Puts the key in out_key, if out_key is not NULL.
+	 * Puts the key in out_key, if out_key is not nullptr.
 	 * @param self Iterator
 	 * @param out_key Key of the entry
 	 * @return Data of the entry
@@ -338,7 +338,7 @@ struct DBIterator
 
 	/**
 	 * Returns true if the fetched entry exists.
-	 * The databases entries might have NULL data, so use this to to test if
+	 * The databases entries might have nullptr data, so use this to to test if
 	 * the iterator is done.
 	 * @param self Iterator
 	 * @return true is the entry exists
@@ -350,7 +350,7 @@ struct DBIterator
 	 * Removes the current entry from the database.
 	 * NOTE: {@link DBIterator#exists} will return false until another entry
 	 *       is fetched
-	 * Puts data of the removed entry in out_data, if out_data is not NULL.
+	 * Puts data of the removed entry in out_data, if out_data is not nullptr.
 	 * @param self Iterator
 	 * @param out_data Data of the removed entry.
 	 * @return 1 if entry was removed, 0 otherwise
@@ -400,7 +400,7 @@ struct DBMap {
 	 * Get the data of the entry identified by the key.
 	 * @param self Database
 	 * @param key Key that identifies the entry
-	 * @return Data of the entry or NULL if not found
+	 * @return Data of the entry or nullptr if not found
 	 * @protected
 	 */
 	DBData* (*get)(DBMap* self, DBKey key);
@@ -409,7 +409,7 @@ struct DBMap {
 	 * Just calls {@link DBMap#vgetall}.
 	 * Get the data of the entries matched by <code>match</code>.
 	 * It puts a maximum of <code>max</code> entries into <code>buf</code>.
-	 * If <code>buf</code> is NULL, it only counts the matches.
+	 * If <code>buf</code> is nullptr, it only counts the matches.
 	 * Returns the number of entries that matched.
 	 * NOTE: if the value returned is greater than <code>max</code>, only the
 	 * first <code>max</code> entries found are put into the buffer.
@@ -427,7 +427,7 @@ struct DBMap {
 	/**
 	 * Get the data of the entries matched by <code>match</code>.
 	 * It puts a maximum of <code>max</code> entries into <code>buf</code>.
-	 * If <code>buf</code> is NULL, it only counts the matches.
+	 * If <code>buf</code> is nullptr, it only counts the matches.
 	 * Returns the number of entries that matched.
 	 * NOTE: if the value returned is greater than <code>max</code>, only the
 	 * first <code>max</code> entries found are put into the buffer.
@@ -473,7 +473,7 @@ struct DBMap {
 
 	/**
 	 * Put the data identified by the key in the database.
-	 * Puts the previous data in out_data, if out_data is not NULL.
+	 * Puts the previous data in out_data, if out_data is not nullptr.
 	 * NOTE: Uses the new key, the old one is released.
 	 * @param self Database
 	 * @param key Key that identifies the data
@@ -486,7 +486,7 @@ struct DBMap {
 
 	/**
 	 * Remove an entry from the database.
-	 * Puts the previous data in out_data, if out_data is not NULL.
+	 * Puts the previous data in out_data, if out_data is not nullptr.
 	 * NOTE: The key (of the database) is released.
 	 * @param self Database
 	 * @param key Key that identifies the entry
@@ -651,44 +651,44 @@ struct DBMap {
 #define ui64db_i64get(db,k) ( db_data2i64((db)->get((db),db_ui642key(k))) )
 
 // Put pointer-type data into DBMaps of various key types
-#define db_put(db,k,d)     ( (db)->put((db),(k),db_ptr2data(d),NULL) )
-#define idb_put(db,k,d)    ( (db)->put((db),db_i2key(k),db_ptr2data(d),NULL) )
-#define uidb_put(db,k,d)   ( (db)->put((db),db_ui2key(k),db_ptr2data(d),NULL) )
-#define strdb_put(db,k,d)  ( (db)->put((db),db_str2key(k),db_ptr2data(d),NULL) )
-#define i64db_put(db,k,d)  ( (db)->put((db),db_i642key(k),db_ptr2data(d),NULL) )
-#define ui64db_put(db,k,d) ( (db)->put((db),db_ui642key(k),db_ptr2data(d),NULL) )
+#define db_put(db,k,d)     ( (db)->put((db),(k),db_ptr2data(d),nullptr) )
+#define idb_put(db,k,d)    ( (db)->put((db),db_i2key(k),db_ptr2data(d),nullptr) )
+#define uidb_put(db,k,d)   ( (db)->put((db),db_ui2key(k),db_ptr2data(d),nullptr) )
+#define strdb_put(db,k,d)  ( (db)->put((db),db_str2key(k),db_ptr2data(d),nullptr) )
+#define i64db_put(db,k,d)  ( (db)->put((db),db_i642key(k),db_ptr2data(d),nullptr) )
+#define ui64db_put(db,k,d) ( (db)->put((db),db_ui642key(k),db_ptr2data(d),nullptr) )
 
 // Put int-type data into DBMaps of various key types
-#define db_iput(db,k,d)     ( (db)->put((db),(k),db_i2data(d),NULL) )
-#define idb_iput(db,k,d)    ( (db)->put((db),db_i2key(k),db_i2data(d),NULL) )
-#define uidb_iput(db,k,d)   ( (db)->put((db),db_ui2key(k),db_i2data(d),NULL) )
-#define strdb_iput(db,k,d)  ( (db)->put((db),db_str2key(k),db_i2data(d),NULL) )
-#define i64db_iput(db,k,d)  ( (db)->put((db),db_i642key(k),db_i2data(d),NULL) )
-#define ui64db_iput(db,k,d) ( (db)->put((db),db_ui642key(k),db_i2data(d),NULL) )
+#define db_iput(db,k,d)     ( (db)->put((db),(k),db_i2data(d),nullptr) )
+#define idb_iput(db,k,d)    ( (db)->put((db),db_i2key(k),db_i2data(d),nullptr) )
+#define uidb_iput(db,k,d)   ( (db)->put((db),db_ui2key(k),db_i2data(d),nullptr) )
+#define strdb_iput(db,k,d)  ( (db)->put((db),db_str2key(k),db_i2data(d),nullptr) )
+#define i64db_iput(db,k,d)  ( (db)->put((db),db_i642key(k),db_i2data(d),nullptr) )
+#define ui64db_iput(db,k,d) ( (db)->put((db),db_ui642key(k),db_i2data(d),nullptr) )
 
 // Put uint-type data into DBMaps of various key types
-#define db_uiput(db,k,d)     ( (db)->put((db),(k),db_ui2data(d),NULL) )
-#define idb_uiput(db,k,d)    ( (db)->put((db),db_i2key(k),db_ui2data(d),NULL) )
-#define uidb_uiput(db,k,d)   ( (db)->put((db),db_ui2key(k),db_ui2data(d),NULL) )
-#define strdb_uiput(db,k,d)  ( (db)->put((db),db_str2key(k),db_ui2data(d),NULL) )
-#define i64db_uiput(db,k,d)  ( (db)->put((db),db_i642key(k),db_ui2data(d),NULL) )
-#define ui64db_uiput(db,k,d) ( (db)->put((db),db_ui642key(k),db_ui2data(d),NULL) )
+#define db_uiput(db,k,d)     ( (db)->put((db),(k),db_ui2data(d),nullptr) )
+#define idb_uiput(db,k,d)    ( (db)->put((db),db_i2key(k),db_ui2data(d),nullptr) )
+#define uidb_uiput(db,k,d)   ( (db)->put((db),db_ui2key(k),db_ui2data(d),nullptr) )
+#define strdb_uiput(db,k,d)  ( (db)->put((db),db_str2key(k),db_ui2data(d),nullptr) )
+#define i64db_uiput(db,k,d)  ( (db)->put((db),db_i642key(k),db_ui2data(d),nullptr) )
+#define ui64db_uiput(db,k,d) ( (db)->put((db),db_ui642key(k),db_ui2data(d),nullptr) )
 
 // Put int64 data into DBMaps of various key types
-#define db_i64put(db,k,d)     ( (db)->put((db),(k),db_i642data(d),NULL) )
-#define idb_i64put(db,k,d)    ( (db)->put((db),db_i2key(k),db_i642data(d),NULL) )
-#define uidb_i64put(db,k,d)   ( (db)->put((db),db_ui2key(k),db_i642data(d),NULL) )
-#define strdb_i64put(db,k,d)  ( (db)->put((db),db_str2key(k),db_i642data(d),NULL) )
-#define i64db_i64put(db,k,d)  ( (db)->put((db),db_i642key(k),db_i642data(d),NULL) )
-#define ui64db_i64put(db,k,d) ( (db)->put((db),db_ui642key(k),db_i642data(d),NULL) )
+#define db_i64put(db,k,d)     ( (db)->put((db),(k),db_i642data(d),nullptr) )
+#define idb_i64put(db,k,d)    ( (db)->put((db),db_i2key(k),db_i642data(d),nullptr) )
+#define uidb_i64put(db,k,d)   ( (db)->put((db),db_ui2key(k),db_i642data(d),nullptr) )
+#define strdb_i64put(db,k,d)  ( (db)->put((db),db_str2key(k),db_i642data(d),nullptr) )
+#define i64db_i64put(db,k,d)  ( (db)->put((db),db_i642key(k),db_i642data(d),nullptr) )
+#define ui64db_i64put(db,k,d) ( (db)->put((db),db_ui642key(k),db_i642data(d),nullptr) )
 
 // Remove entry from DBMaps of various key types
-#define db_remove(db,k)     ( (db)->remove((db),(k),NULL) )
-#define idb_remove(db,k)    ( (db)->remove((db),db_i2key(k),NULL) )
-#define uidb_remove(db,k)   ( (db)->remove((db),db_ui2key(k),NULL) )
-#define strdb_remove(db,k)  ( (db)->remove((db),db_str2key(k),NULL) )
-#define i64db_remove(db,k)  ( (db)->remove((db),db_i642key(k),NULL) )
-#define ui64db_remove(db,k) ( (db)->remove((db),db_ui642key(k),NULL) )
+#define db_remove(db,k)     ( (db)->remove((db),(k),nullptr) )
+#define idb_remove(db,k)    ( (db)->remove((db),db_i2key(k),nullptr) )
+#define uidb_remove(db,k)   ( (db)->remove((db),db_ui2key(k),nullptr) )
+#define strdb_remove(db,k)  ( (db)->remove((db),db_str2key(k),nullptr) )
+#define i64db_remove(db,k)  ( (db)->remove((db),db_i642key(k),nullptr) )
+#define ui64db_remove(db,k) ( (db)->remove((db),db_ui642key(k),nullptr) )
 
 //These are discarding the possible vargs you could send to the function, so those
 //that require vargs must not use these defines.
@@ -706,16 +706,16 @@ struct DBMap {
 #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))
 #define ui64db_alloc(opt)         db_alloc(__FILE__,__func__,__LINE__,DB_UINT64,(opt),sizeof(uint64))
-#define db_destroy(db)            ( (db)->destroy((db),NULL) )
+#define db_destroy(db)            ( (db)->destroy((db),nullptr) )
 // Other macros
-#define db_clear(db)        ( (db)->clear((db),NULL) )
+#define db_clear(db)        ( (db)->clear((db),nullptr) )
 #define db_size(db)         ( (db)->size(db) )
 #define db_iterator(db)     ( (db)->iterator(db) )
-#define dbi_first(dbi)      ( db_data2ptr((dbi)->first((dbi),NULL)) )
-#define dbi_last(dbi)       ( db_data2ptr((dbi)->last((dbi),NULL)) )
-#define dbi_next(dbi)       ( db_data2ptr((dbi)->next((dbi),NULL)) )
-#define dbi_prev(dbi)       ( db_data2ptr((dbi)->prev((dbi),NULL)) )
-#define dbi_remove(dbi)     ( (dbi)->remove((dbi),NULL) )
+#define dbi_first(dbi)      ( db_data2ptr((dbi)->first((dbi),nullptr)) )
+#define dbi_last(dbi)       ( db_data2ptr((dbi)->last((dbi),nullptr)) )
+#define dbi_next(dbi)       ( db_data2ptr((dbi)->next((dbi),nullptr)) )
+#define dbi_prev(dbi)       ( db_data2ptr((dbi)->prev((dbi),nullptr)) )
+#define dbi_remove(dbi)     ( (dbi)->remove((dbi),nullptr) )
 #define dbi_exists(dbi)     ( (dbi)->exists(dbi) )
 #define dbi_destroy(dbi)    ( (dbi)->destroy(dbi) )
 
@@ -760,7 +760,7 @@ DBOptions db_fix_options(DBType type, DBOptions options);
 /**
  * Returns the default comparator for the type of database.
  * @param type Type of database
- * @return Comparator for the type of database or NULL if unknown database
+ * @return Comparator for the type of database or nullptr if unknown database
  * @public
  * @see #DBType
  * @see #DBComparator
@@ -770,7 +770,7 @@ DBComparator db_default_cmp(DBType type);
 /**
  * Returns the default hasher for the specified type of database.
  * @param type Type of database
- * @return Hasher of the type of database or NULL if unknown database
+ * @return Hasher of the type of database or nullptr if unknown database
  * @public
  * @see #DBType
  * @see #DBHasher
@@ -920,7 +920,7 @@ unsigned int db_data2ui(DBData *data);
 
 /**
  * Gets void* type data from struct DBData.
- * If data is not void* type, returns NULL.
+ * If data is not void* type, returns nullptr.
  * @param data Data
  * @return Void* value of the data.
  * @public
@@ -1082,7 +1082,7 @@ void  linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...);
 /// @param __type Type of data
 /// @param __var Variable name
 #define VECTOR_VAR(__type,__var) \
-	VECTOR_DECL(__type) __var = {0,0,NULL}
+	VECTOR_DECL(__type) __var = {0,0,nullptr}
 
 
 
@@ -1091,7 +1091,7 @@ void  linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...);
 /// @param __name Structure name
 /// @param __var Variable name
 #define VECTOR_STRUCT_VAR(__name,__var) \
-	struct __name __var = {0,0,NULL}
+	struct __name __var = {0,0,nullptr}
 
 
 
@@ -1177,7 +1177,7 @@ void  linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...);
 		} \
 		else if( (__n) == 0 && VECTOR_CAPACITY(__vec) ) \
 		{ /* clear vector */ \
-			aFree(VECTOR_DATA(__vec)); VECTOR_DATA(__vec) = NULL; /* free data */ \
+			aFree(VECTOR_DATA(__vec)); VECTOR_DATA(__vec) = nullptr; /* free data */ \
 			VECTOR_CAPACITY(__vec) = 0; /* clear capacity */ \
 			VECTOR_LENGTH(__vec) = 0; /* clear length */ \
 		} \
@@ -1368,7 +1368,7 @@ void  linkdb_foreach (struct linkdb_node** head, LinkDBFunc func, ...);
 	do{ \
 		if( VECTOR_CAPACITY(__vec) ) \
 		{ \
-			aFree(VECTOR_DATA(__vec)); VECTOR_DATA(__vec) = NULL; /* clear allocated array */ \
+			aFree(VECTOR_DATA(__vec)); VECTOR_DATA(__vec) = nullptr; /* clear allocated array */ \
 			VECTOR_CAPACITY(__vec) = 0; /* clear capacity */ \
 			VECTOR_LENGTH(__vec) = 0; /* clear length */ \
 		} \

+ 20 - 20
src/common/ers.cpp

@@ -118,8 +118,8 @@ struct ers_instance_t {
 
 
 // Array containing a pointer for all ers_cache structures
-static ers_cache_t *CacheList = NULL;
-static struct ers_instance_t *InstanceList = NULL;
+static ers_cache_t *CacheList = nullptr;
+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
@@ -134,8 +134,8 @@ static ers_cache_t *ers_find_cache(unsigned int size, enum ERSOptions Options) {
 	CREATE(cache, ers_cache_t, 1);
 	cache->ObjectSize = size;
 	cache->ReferenceCount = 0;
-	cache->ReuseList = NULL;
-	cache->Blocks = NULL;
+	cache->ReuseList = nullptr;
+	cache->Blocks = nullptr;
 	cache->Free = 0;
 	cache->Used = 0;
 	cache->UsedObjs = 0;
@@ -143,7 +143,7 @@ static ers_cache_t *ers_find_cache(unsigned int size, enum ERSOptions Options) {
 	cache->ChunkSize = ERS_BLOCK_ENTRIES;
 	cache->Options = (enum ERSOptions)(Options & ERS_CACHE_OPTIONS);
 
-	if (CacheList == NULL)
+	if (CacheList == nullptr)
 	{
 		CacheList = cache;
 	}
@@ -152,7 +152,7 @@ static ers_cache_t *ers_find_cache(unsigned int size, enum ERSOptions Options) {
 		cache->Next = CacheList;
 		cache->Next->Prev = cache;
 		CacheList = cache;
-		CacheList->Prev = NULL;
+		CacheList->Prev = nullptr;
 	}
 
 	return cache;
@@ -183,12 +183,12 @@ static void *ers_obj_alloc_entry(ERS *self)
 	struct ers_instance_t *instance = (struct ers_instance_t *)self;
 	void *ret;
 
-	if (instance == NULL) {
-		ShowError("ers_obj_alloc_entry: NULL object, aborting entry freeing.\n");
-		return NULL;
+	if (instance == nullptr) {
+		ShowError("ers_obj_alloc_entry: nullptr object, aborting entry freeing.\n");
+		return nullptr;
 	}
 
-	if (instance->Cache->ReuseList != NULL) {
+	if (instance->Cache->ReuseList != nullptr) {
 		ret = (void *)((unsigned char *)instance->Cache->ReuseList + sizeof(struct ers_list));
 		instance->Cache->ReuseList = instance->Cache->ReuseList->Next;
 	} else if (instance->Cache->Free > 0) {
@@ -218,11 +218,11 @@ static void ers_obj_free_entry(ERS *self, void *entry)
 	struct ers_instance_t *instance = (struct ers_instance_t *)self;
 	struct ers_list *reuse = (struct ers_list *)((unsigned char *)entry - sizeof(struct ers_list));
 
-	if (instance == NULL) {
-		ShowError("ers_obj_free_entry: NULL object, aborting entry freeing.\n");
+	if (instance == nullptr) {
+		ShowError("ers_obj_free_entry: nullptr object, aborting entry freeing.\n");
 		return;
-	} else if (entry == NULL) {
-		ShowError("ers_obj_free_entry: NULL entry, nothing to free.\n");
+	} else if (entry == nullptr) {
+		ShowError("ers_obj_free_entry: nullptr entry, nothing to free.\n");
 		return;
 	}
 
@@ -239,8 +239,8 @@ static size_t ers_obj_entry_size(ERS *self)
 {
 	struct ers_instance_t *instance = (struct ers_instance_t *)self;
 
-	if (instance == NULL) {
-		ShowError("ers_obj_entry_size: NULL object, aborting entry freeing.\n");
+	if (instance == nullptr) {
+		ShowError("ers_obj_entry_size: nullptr object, aborting entry freeing.\n");
 		return 0;
 	}
 
@@ -251,8 +251,8 @@ static void ers_obj_destroy(ERS *self)
 {
 	struct ers_instance_t *instance = (struct ers_instance_t *)self;
 
-	if (instance == NULL) {
-		ShowError("ers_obj_destroy: NULL object, aborting entry freeing.\n");
+	if (instance == nullptr) {
+		ShowError("ers_obj_destroy: nullptr object, aborting entry freeing.\n");
 		return;
 	}
 
@@ -315,13 +315,13 @@ ERS *ers_new(uint32 size, const char *name, enum ERSOptions options)
 
 	instance->Cache->ReferenceCount++;
 
-	if (InstanceList == NULL) {
+	if (InstanceList == nullptr) {
 		InstanceList = instance;
 	} else {
 		instance->Next = InstanceList;
 		instance->Next->Prev = instance;
 		InstanceList = instance;
-		InstanceList->Prev = NULL;
+		InstanceList->Prev = nullptr;
 	}
 
 	instance->Count = 0;

+ 1 - 1
src/common/ers.hpp

@@ -138,7 +138,7 @@ typedef struct eri {
 #	define ers_destroy(obj)
 #	define ers_chunk_size(obj,size)
 // Disable the public functions
-#	define ers_new(size,name,options) NULL
+#	define ers_new(size,name,options) nullptr
 #	define ers_report()
 #	define ers_final()
 #else /* not DISABLE_ERS */

+ 32 - 32
src/common/grfio.cpp

@@ -44,12 +44,12 @@ typedef struct _FILELIST {
 
 
 // stores info about every loaded file
-FILELIST* filelist		= NULL;
+FILELIST* filelist		= nullptr;
 int filelist_entrys		= 0;
 int filelist_maxentry	= 0;
 
 // stores grf file names
-char** gentry_table		= NULL;
+char** gentry_table		= nullptr;
 int gentry_entrys		= 0;
 int gentry_maxentry		= 0;
 
@@ -286,21 +286,21 @@ static FILELIST* filelist_find(const char* fname)
 	int hash, index;
 
 	if (!filelist)
-		return NULL;
+		return nullptr;
 
 	hash = filelist_hash[filehash(fname)];
 	for (index = hash; index != -1; index = filelist[index].next)
 		if(!strcmpi(filelist[index].fn, fname))
 			break;
 
-	return (index >= 0) ? &filelist[index] : NULL;
+	return (index >= 0) ? &filelist[index] : nullptr;
 }
 
 // returns the original file name
 char* grfio_find_file(const char* fname)
 {
 	FILELIST *filelist_res = filelist_find(fname);
-	if (!filelist_res) return NULL;
+	if (!filelist_res) return nullptr;
 	return (!filelist_res->fnd ? filelist_res->fn : filelist_res->fnd);
 }
 
@@ -332,7 +332,7 @@ static FILELIST* filelist_add(FILELIST* entry)
 static FILELIST* filelist_modify(FILELIST* entry)
 {
 	FILELIST* fentry = filelist_find(entry->fn);
-	if (fentry != NULL) {
+	if (fentry != nullptr) {
 		int tmp = fentry->next;
 		memcpy(fentry, entry, sizeof(FILELIST));
 		fentry->next = tmp;
@@ -345,7 +345,7 @@ static FILELIST* filelist_modify(FILELIST* entry)
 // shrinks the file list array if too long
 static void filelist_compact(void)
 {
-	if (filelist == NULL)
+	if (filelist == nullptr)
 		return;
 
 	if (filelist_entrys < filelist_maxentry) {
@@ -387,16 +387,16 @@ static void grfio_localpath_create(char* buffer, size_t size, const char* filena
 /// Reads a file into a newly allocated buffer (from grf or data directory).
 void* grfio_reads(const char* fname, int* size)
 {
-	unsigned char* buf2 = NULL;
+	unsigned char* buf2 = nullptr;
 
 	FILELIST* entry = filelist_find(fname);
-	if( entry == NULL || entry->gentry <= 0 ) {// LocalFileCheck
+	if( entry == nullptr || entry->gentry <= 0 ) {// LocalFileCheck
 		char lfname[256];
 		FILE* in;
 		grfio_localpath_create(lfname, sizeof(lfname), ( entry && entry->fnd ) ? entry->fnd : fname);
 
 		in = fopen(lfname, "rb");
-		if( in != NULL ) {
+		if( in != nullptr ) {
 			fseek(in,0,SEEK_END);
 			size_t declen = ftell(in);
 			fseek(in,0,SEEK_SET);
@@ -407,19 +407,19 @@ void* grfio_reads(const char* fname, int* size)
 			if( size )
 				*size = declen;
 		} else {
-			if (entry != NULL && entry->gentry < 0) {
+			if (entry != nullptr && entry->gentry < 0) {
 				entry->gentry = -entry->gentry;	// local file checked
 			} else {
 				ShowError("grfio_reads: %s not found (local file: %s)\n", fname, lfname);
-				return NULL;
+				return nullptr;
 			}
 		}
 	}
 
-	if( entry != NULL && entry->gentry > 0 ) {// Archive[GRF] File Read
+	if( entry != nullptr && entry->gentry > 0 ) {// Archive[GRF] File Read
 		char* grfname = gentry_table[entry->gentry - 1];
 		FILE* in = fopen(grfname, "rb");
-		if( in != NULL ) {
+		if( in != nullptr ) {
 			size_t fsize = entry->srclen_aligned;
 			unsigned char *buf = (unsigned char *)aMalloc(fsize);
 			fseek(in, entry->srcpos, 0);
@@ -437,7 +437,7 @@ void* grfio_reads(const char* fname, int* size)
 					ShowError("decode_zip size mismatch err: %d != %d\n", (int)len, entry->declen);
 					aFree(buf);
 					aFree(buf2);
-					return NULL;
+					return nullptr;
 				}
 			} else {// directory?
 				memcpy(buf2, buf, entry->declen);
@@ -449,7 +449,7 @@ void* grfio_reads(const char* fname, int* size)
 			aFree(buf);
 		} else {
 			ShowError("grfio_reads: %s not found (GRF file: %s)\n", fname, grfname);
-			return NULL;
+			return nullptr;
 		}
 	}
 
@@ -510,7 +510,7 @@ static char* decode_filename(unsigned char* buf, int len)
 static bool isFullEncrypt(const char* fname)
 {
 	const char* ext = strrchr(fname, '.');
-	if( ext != NULL ) {
+	if( ext != nullptr ) {
 		static const char extensions[4][5] = { ".gnd", ".gat", ".act", ".str" };
 		size_t i;
 		for( i = 0; i < ARRAYLENGTH(extensions); ++i )
@@ -532,7 +532,7 @@ static int grfio_entryread(const char* grfname, int gentry)
 	unsigned char *grf_filelist;
 
 	FILE* fp = fopen(grfname, "rb");
-	if( fp == NULL ) {
+	if( fp == nullptr ) {
 		ShowWarning("GRF data file not found: '%s'\n",grfname);
 		return 1;	// 1:not found error
 	} else
@@ -584,7 +584,7 @@ static int grfio_entryread(const char* grfname, int gentry)
 				aentry.srcpos         = getlong(grf_filelist+ofs2+13)+0x2e;
 				aentry.type           = type;
 				safestrncpy(aentry.fn, fname, sizeof(aentry.fn));
-				aentry.fnd			  = NULL;
+				aentry.fnd			  = nullptr;
 #ifdef	GRFIO_LOCAL
 				aentry.gentry         = -(gentry+1);	// As Flag for making it a negative number carrying out the first time LocalFileCheck
 #else
@@ -642,7 +642,7 @@ static int grfio_entryread(const char* grfname, int gentry)
 				aentry.srcpos         = getlong(grf_filelist+ofs2+13)+0x2e;
 				aentry.type           = type;
 				safestrncpy(aentry.fn, fname, sizeof(aentry.fn));
-				aentry.fnd			  = NULL;
+				aentry.fnd			  = nullptr;
 #ifdef	GRFIO_LOCAL
 				aentry.gentry         = -(gentry+1);	// As Flag for making it a negative number carrying out the first time LocalFileCheck
 #else
@@ -677,14 +677,14 @@ static bool grfio_parse_restable_row(const char* row)
 	if( sscanf(row, "%255[^#\r\n]#%255[^#\r\n]#", w1, w2) != 2 )
 		return false;
 
-	if( strstr(w2, ".gat") == NULL && strstr(w2, ".rsw") == NULL )
+	if( strstr(w2, ".gat") == nullptr && strstr(w2, ".rsw") == nullptr )
 		return false; // we only need the maps' GAT and RSW files
 
 	sprintf(src, "data\\%s", w1);
 	sprintf(dst, "data\\%s", w2);
 
 	entry = filelist_find(dst);
-	if( entry != NULL )
+	if( entry != nullptr )
 	{// alias for GRF resource
 		FILELIST fentry;
 		memcpy(&fentry, entry, sizeof(FILELIST));
@@ -722,7 +722,7 @@ static void grfio_resourcecheck(void)
 	grfio_localpath_create(restable, sizeof(restable), "data\\resnametable.txt");
 
 	fp = fopen(restable, "rb");
-	if( fp != NULL )
+	if( fp != nullptr )
 	{
 		char line[256];
 		while( fgets(line, sizeof(line), fp) )
@@ -738,7 +738,7 @@ static void grfio_resourcecheck(void)
 
 	// read resnametable from loaded GRF's, only if it cannot be loaded from the data directory
 	buf = (char *)grfio_reads("data\\resnametable.txt", &size);
-	if( buf != NULL )
+	if( buf != nullptr )
 	{
 		char *ptr;
 		buf[size] = '\0';
@@ -750,7 +750,7 @@ static void grfio_resourcecheck(void)
 				++i;
 
 			ptr = strchr(ptr, '\n');
-			if( ptr == NULL ) break;
+			if( ptr == nullptr ) break;
 			ptr++;
 		}
 
@@ -781,25 +781,25 @@ static int grfio_add(const char* fname)
 /// Finalizes grfio.
 void grfio_final(void)
 {
-	if (filelist != NULL) {
+	if (filelist != nullptr) {
 		int i;
 		for (i = 0; i < filelist_entrys; i++)
-			if (filelist[i].fnd != NULL)
+			if (filelist[i].fnd != nullptr)
 				aFree(filelist[i].fnd);
 
 		aFree(filelist);
-		filelist = NULL;
+		filelist = nullptr;
 	}
 	filelist_entrys = filelist_maxentry = 0;
 
-	if (gentry_table != NULL) {
+	if (gentry_table != nullptr) {
 		int i;
 		for (i = 0; i < gentry_entrys; i++)
-			if (gentry_table[i] != NULL)
+			if (gentry_table[i] != nullptr)
 				aFree(gentry_table[i]);
 
 		aFree(gentry_table);
-		gentry_table = NULL;
+		gentry_table = nullptr;
 	}
 	gentry_entrys = gentry_maxentry = 0;
 }
@@ -814,7 +814,7 @@ void grfio_init(const char* fname)
 	hashinit();	// hash table initialization
 
 	data_conf = fopen(fname, "r");
-	if( data_conf != NULL )
+	if( data_conf != nullptr )
 	{
 		char line[1024];
 		while( fgets(line, sizeof(line), data_conf) )

+ 1 - 1
src/common/grfio.hpp

@@ -12,7 +12,7 @@ void grfio_init(const char* fname);
 void grfio_final(void);
 void* grfio_reads(const char* fname, int* size);
 char* grfio_find_file(const char* fname);
-#define grfio_read(fn) grfio_reads(fn, NULL)
+#define grfio_read(fn) grfio_reads(fn, nullptr)
 int32 grfio_read_rsw_water_level( const char* fname );
 
 unsigned long grfio_crc32(const unsigned char *buf, unsigned int len);

+ 32 - 32
src/common/malloc.cpp

@@ -56,7 +56,7 @@
 #	define STRDUP(p,file,line,func)	GC_debug_strdup((p), RETURN_ADDR (file),(line))
 #	define FREE(p,file,line,func)		GC_debug_free(p)
 #	define MEMORY_USAGE()	GC_get_heap_size()
-#	define MEMORY_VERIFY(ptr)	(GC_base(ptr) != NULL)
+#	define MEMORY_VERIFY(ptr)	(GC_base(ptr) != nullptr)
 #	define MEMORY_CHECK()	GC_gcollect()
 
 #else
@@ -76,7 +76,7 @@ void* aMalloc_(size_t size, const char *file, int line, const char *func)
 {
 	void *ret = MALLOC(size, file, line, func);
 	// ShowMessage("%s:%d: in func %s: aMalloc %d\n",file,line,func,size);
-	if (ret == NULL){
+	if (ret == nullptr){
 		ShowFatalError("%s:%d: in func %s: aMalloc error out of memory!\n",file,line,func);
 		exit(EXIT_FAILURE);
 	}
@@ -87,7 +87,7 @@ void* aCalloc_(size_t num, size_t size, const char *file, int line, const char *
 {
 	void *ret = CALLOC(num, size, file, line, func);
 	// ShowMessage("%s:%d: in func %s: aCalloc %d %d\n",file,line,func,num,size);
-	if (ret == NULL){
+	if (ret == nullptr){
 		ShowFatalError("%s:%d: in func %s: aCalloc error out of memory!\n", file, line, func);
 		exit(EXIT_FAILURE);
 	}
@@ -97,7 +97,7 @@ void* aRealloc_(void *p, size_t size, const char *file, int line, const char *fu
 {
 	void *ret = REALLOC(p, size, file, line, func);
 	// ShowMessage("%s:%d: in func %s: aRealloc %p %d\n",file,line,func,p,size);
-	if (ret == NULL){
+	if (ret == nullptr){
 		ShowFatalError("%s:%d: in func %s: aRealloc error out of memory!\n",file,line,func);
 		exit(EXIT_FAILURE);
 	}
@@ -107,7 +107,7 @@ char* aStrdup_(const char *p, const char *file, int line, const char *func)
 {
 	char *ret = STRDUP(p, file, line, func);
 	// ShowMessage("%s:%d: in func %s: aStrdup %p\n",file,line,func,p);
-	if (ret == NULL){
+	if (ret == nullptr){
 		ShowFatalError("%s:%d: in func %s: aStrdup error out of memory!\n", file, line, func);
 		exit(EXIT_FAILURE);
 	}
@@ -195,7 +195,7 @@ struct unit_head_large {
 	struct unit_head        unit_head;
 };
 
-static struct unit_head_large *unit_head_large_first = NULL;
+static struct unit_head_large *unit_head_large_first = nullptr;
 
 static struct block* block_malloc(unsigned short hash);
 static void          block_free(struct block* p);
@@ -239,18 +239,18 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func )
 	memmgr_usage_bytes += size;
 
 	/* To ensure the area that exceeds the length of the block, using malloc () to */
-	/* At that time, the distinction by assigning NULL to unit_head.block */
+	/* At that time, the distinction by assigning nullptr to unit_head.block */
 	if(hash2size(size_hash) > BLOCK_DATA_SIZE - sizeof(struct unit_head)) {
 		struct unit_head_large* p = (struct unit_head_large*)MALLOC(sizeof(struct unit_head_large)+size,file,line,func);
-		if(p != NULL) {
+		if(p != nullptr) {
 			p->size            = size;
-			p->unit_head.block = NULL;
+			p->unit_head.block = nullptr;
 			p->unit_head.size  = 0;
 			p->unit_head.file  = file;
 			p->unit_head.line  = line;
-			p->prev = NULL;
-			if (unit_head_large_first == NULL)
-				p->next = NULL;
+			p->prev = nullptr;
+			if (unit_head_large_first == nullptr)
+				p->next = nullptr;
 			else {
 				unit_head_large_first->prev = p;
 				p->next = unit_head_large_first;
@@ -294,7 +294,7 @@ void* _mmalloc(size_t size, const char *file, int line, const char *func )
 		if( block->unfill_next ) {
 			block->unfill_next->unfill_prev = block->unfill_prev;
 		}
-		block->unfill_prev = NULL;
+		block->unfill_prev = nullptr;
 	}
 
 #ifdef DEBUG_MEMMGR
@@ -337,7 +337,7 @@ void* _mcalloc(size_t num, size_t size, const char *file, int line, const char *
 void* _mrealloc(void *memblock, size_t size, const char *file, int line, const char *func )
 {
 	size_t old_size;
-	if(memblock == NULL) {
+	if(memblock == nullptr) {
 		return _mmalloc(size,file,line,func);
 	}
 
@@ -351,7 +351,7 @@ void* _mrealloc(void *memblock, size_t size, const char *file, int line, const c
 	}  else {
 		// Size Large
 		void *p = _mmalloc(size,file,line,func);
-		if(p != NULL) {
+		if(p != nullptr) {
 			memcpy(p,memblock,old_size);
 		}
 		_mfree(memblock,file,line,func);
@@ -361,8 +361,8 @@ void* _mrealloc(void *memblock, size_t size, const char *file, int line, const c
 
 char* _mstrdup(const char *p, const char *file, int line, const char *func )
 {
-	if(p == NULL) {
-		return NULL;
+	if(p == nullptr) {
+		return nullptr;
 	} else {
 		size_t len = strlen(p);
 		char *string  = (char *)_mmalloc(len + 1,file,line,func);
@@ -375,7 +375,7 @@ void _mfree(void *ptr, const char *file, int line, const char *func )
 {
 	struct unit_head *head;
 
-	if (ptr == NULL)
+	if (ptr == nullptr)
 		return; 
 
 	head = (struct unit_head *)((char *)ptr - sizeof(struct unit_head) + sizeof(long));
@@ -409,13 +409,13 @@ void _mfree(void *ptr, const char *file, int line, const char *func )
 		struct block *block = head->block;
 		if( (size_t)((char*)head - (char*)block) > sizeof(struct block) ) {
 			ShowError("Memory manager: args of aFree 0x%p is invalid pointer %s line %d\n", ptr, file, line);
-		} else if(head->block == NULL) {
+		} else if(head->block == nullptr) {
 			ShowError("Memory manager: args of aFree 0x%p is freed pointer %s:%d@%s\n", ptr, file, line, func);
 		} else if(*(long*)((char*)head + sizeof(struct unit_head) - sizeof(long) + head->size) != FREED_POINTER) {
 			ShowError("Memory manager: args of aFree 0x%p is overflowed pointer %s line %d\n", ptr, file, line);
 		} else {
 			memmgr_usage_bytes -= head->size;
-			head->block         = NULL;
+			head->block         = nullptr;
 #ifdef DEBUG_MEMMGR
 			memset(ptr, 0xfd, block->unit_size - sizeof(struct unit_head) + sizeof(long) );
 			head->file = file;
@@ -426,7 +426,7 @@ void _mfree(void *ptr, const char *file, int line, const char *func )
 				/* Release of the block */
 				block_free(block);
 			} else {
-				if( block->unfill_prev == NULL) {
+				if( block->unfill_prev == nullptr) {
 					// add to unfill list
 					if( hash_unfill[ block->unit_hash ] ) {
 						hash_unfill[ block->unit_hash ]->unfill_prev = block;
@@ -446,7 +446,7 @@ void _mfree(void *ptr, const char *file, int line, const char *func )
 static struct block* block_malloc(unsigned short hash)
 {
 	struct block *p;
-	if(hash_unfill[0] != NULL) {
+	if(hash_unfill[0] != nullptr) {
 		/* Space for the block has already been secured */
 		p = hash_unfill[0];
 		hash_unfill[0] = hash_unfill[0]->unfill_next;
@@ -454,26 +454,26 @@ static struct block* block_malloc(unsigned short hash)
 		int i;
 		/* Newly allocated space for the block */
 		p = (struct block*)MALLOC(sizeof(struct block) * (BLOCK_ALLOC), __FILE__, __LINE__, __func__ );
-		if(p == NULL) {
+		if(p == nullptr) {
 			ShowFatalError("Memory manager::block_alloc failed.\n");
 			exit(EXIT_FAILURE);
 		}
 
-		if(block_first == NULL) {
+		if(block_first == nullptr) {
 			/* First ensure */
 			block_first = p;
 		} else {
 			block_last->block_next = p;
 		}
 		block_last = &p[BLOCK_ALLOC - 1];
-		block_last->block_next = NULL;
+		block_last->block_next = nullptr;
 		/* Linking the block */
 		for(i=0;i<BLOCK_ALLOC;i++) {
 			if(i != 0) {
 				// I do not add the link p [0], so we will use
 				p[i].unfill_next = hash_unfill[0];
 				hash_unfill[0]   = &p[i];
-				p[i].unfill_prev = NULL;
+				p[i].unfill_prev = nullptr;
 				p[i].unit_used = 0;
 			}
 			if(i != BLOCK_ALLOC -1) {
@@ -483,10 +483,10 @@ static struct block* block_malloc(unsigned short hash)
 	}
 
 	// Add to unfill
-	memmgr_assert(hash_unfill[ hash ] == NULL);
+	memmgr_assert(hash_unfill[ hash ] == nullptr);
 	hash_unfill[ hash ] = p;
 	p->unfill_prev  = &block_head;
-	p->unfill_next  = NULL;
+	p->unfill_next  = nullptr;
 	p->unit_size    = (unsigned short)(hash2size( hash ) + sizeof(struct unit_head));
 	p->unit_hash    = hash;
 	p->unit_count   = BLOCK_DATA_SIZE / p->unit_size;
@@ -510,7 +510,7 @@ static void block_free(struct block* p)
 		if( p->unfill_next ) {
 			p->unfill_next->unfill_prev = p->unfill_prev;
 		}
-		p->unfill_prev = NULL;
+		p->unfill_prev = nullptr;
 	}
 
 	p->unfill_next = hash_unfill[0];
@@ -563,7 +563,7 @@ bool memmgr_verify(void* ptr)
 	struct block* block = block_first;
 	struct unit_head_large* large = unit_head_large_first;
 
-	if( ptr == NULL )
+	if( ptr == nullptr )
 		return false;// never valid
 
 	// search small blocks
@@ -575,7 +575,7 @@ bool memmgr_verify(void* ptr)
 			{// memory block is being used and ptr points to a sub-unit
 				size_t i = (size_t)((char*)ptr - block->data)/block->unit_size;
 				struct unit_head* head = block2unit(block, i);
-				if( i < block->unit_maxused && head->block != NULL )
+				if( i < block->unit_maxused && head->block != nullptr )
 				{// memory unit is allocated, check if ptr points to the usable part
 					return ( (char*)ptr >= ((char*)head) + sizeof(struct unit_head) - sizeof(long)
 						&& (char*)ptr < ((char*)head) + sizeof(struct unit_head) - sizeof(long) + head->size );
@@ -613,7 +613,7 @@ static void memmgr_final (void)
 			int i;
 			for (i = 0; i < block->unit_maxused; i++) {
 				struct unit_head *head = block2unit(block, i);
-				if(head->block != NULL) {
+				if(head->block != nullptr) {
 					char* ptr = (char *)head + sizeof(struct unit_head) - sizeof(long);
 #ifdef LOG_MEMMGR
 					char buf[1024];

+ 4 - 4
src/common/mapindex.cpp

@@ -23,7 +23,7 @@ int max_index = 0;
 /// Result gets placed either into 'buf' or in a static local buffer.
 const char* mapindex_getmapname(const char* string, char* output) {
 	static char buf[MAP_NAME_LENGTH];
-	char* dest = (output != NULL) ? output : buf;
+	char* dest = (output != nullptr) ? output : buf;
 
 	size_t len = strnlen(string, MAP_NAME_LENGTH_EXT);
 	if (len == MAP_NAME_LENGTH_EXT) {
@@ -44,7 +44,7 @@ const char* mapindex_getmapname(const char* string, char* output) {
 /// Result gets placed either into 'buf' or in a static local buffer.
 const char* mapindex_getmapname_ext(const char* string, char* output) {
 	static char buf[MAP_NAME_LENGTH_EXT];
-	char* dest = (output != NULL) ? output : buf;
+	char* dest = (output != nullptr) ? output : buf;
 
 	size_t len;
 
@@ -146,7 +146,7 @@ void mapindex_init(void) {
 	for( size_t i = 0; i < ARRAYLENGTH(mapindex_cfgfile); i++ ){
 		sprintf( path, "%s/%s", db_path, mapindex_cfgfile[i] );
 
-		if( ( fp = fopen( path, "r" ) ) == NULL ){
+		if( ( fp = fopen( path, "r" ) ) == nullptr ){
 			// It is only fatal if it is the main file
 			if( i == 0 ){
 				ShowFatalError("Unable to read mapindex config file %s!\n", path );
@@ -182,7 +182,7 @@ void mapindex_init(void) {
  * @param mapname
  **/
 void mapindex_check_mapdefault(const char *mapname) {
-	mapname = mapindex_getmapname(mapname, NULL);
+	mapname = mapindex_getmapname(mapname, nullptr);
 	if( !strdb_iget(mapindex_db, mapname) ) {
 		ShowError("mapindex_init: Default map '%s' not found in cache! Please change in (by default in) char_athena.conf!\n", mapname);
 	}

+ 3 - 3
src/common/msg_conf.cpp

@@ -18,7 +18,7 @@
 const char* _msg_txt(int msg_number,int size, char ** msg_table)
 {
 	if (msg_number >= 0 && msg_number < size &&
-		msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0')
+		msg_table[msg_number] != nullptr && msg_table[msg_number][0] != '\0')
 	return msg_table[msg_number];
 
 	return "??";
@@ -35,7 +35,7 @@ int _msg_config_read(const char* cfgName,int size, char ** msg_table)
 	FILE *fp;
 	static int called = 1;
 
-	if ((fp = fopen(cfgName, "r")) == NULL) {
+	if ((fp = fopen(cfgName, "r")) == nullptr) {
 		ShowError("Messages file not found: %s\n", cfgName);
 		return -1;
 	}
@@ -55,7 +55,7 @@ int _msg_config_read(const char* cfgName,int size, char ** msg_table)
 		else {
 			msg_number = atoi(w1);
 			if (msg_number >= 0 && msg_number < size) {
-				if (msg_table[msg_number] != NULL)
+				if (msg_table[msg_number] != nullptr)
 					aFree(msg_table[msg_number]);
 				size_t len = strnlen(w2,sizeof(w2)) + 1;
 				msg_table[msg_number] = (char *) aMalloc(len * sizeof (char));

+ 5 - 5
src/common/nullpo.cpp

@@ -20,7 +20,7 @@ int nullpo_chk_f(const char *file, int line, const char *func, const void *targe
 {
 	va_list ap;
 	
-	if (target != NULL)
+	if (target != nullptr)
 		return 0;
 	
 	va_start(ap, fmt);
@@ -31,7 +31,7 @@ int nullpo_chk_f(const char *file, int line, const char *func, const void *targe
 
 int nullpo_chk(const char *file, int line, const char *func, const void *target)
 {
- 	if (target != NULL)
+ 	if (target != nullptr)
 		return 0;
 	nullpo_info_core_(file, line, func);
 	return 1;
@@ -57,11 +57,11 @@ void nullpo_info(const char *file, int line, const char *func)
 }
 
 static void nullpo_info_core_(const char *file, int line, const char *func){
-	if (file == NULL)
+	if (file == nullptr)
 		file = "??";
 	
 	func =
-		func == NULL    ? "unknown":
+		func == nullptr    ? "unknown":
 		func[0] == '\0' ? "unknown":
 		                  func;
 	
@@ -76,7 +76,7 @@ static void nullpo_info_core(const char *file, int line, const char *func,
                              const char *fmt, va_list ap)
 {
 	nullpo_info_core_(file,line,func);
-	if (fmt != NULL)
+	if (fmt != nullptr)
 	{
 		if (fmt[0] != '\0')
 		{

+ 12 - 12
src/common/nullpo.hpp

@@ -16,13 +16,13 @@
 #if defined(NULLPO_CHECK)
 
 /**
- * Macros used to check for NULL pointer and output that information.
+ * Macros used to check for nullptr pointer and output that information.
  */
 
 /**
  * Return 0 if pointer is not found.
  * @param t: Pointer to check
- * @return 0 if t is NULL
+ * @return 0 if t is nullptr
  */
 #define nullpo_ret(t) \
 	if (nullpo_chk(NLP_MARK, (void *)(t))) {return(0);}
@@ -30,7 +30,7 @@
 /**
  * Return void if pointer is not found.
  * @param t: Pointer to check
- * @return void if t is NULL
+ * @return void if t is nullptr
  */
 #define nullpo_retv(t) \
 	if (nullpo_chk(NLP_MARK, (void *)(t))) {return;}
@@ -58,7 +58,7 @@
  * Return 0 and display additional information if pointer is not found.
  * @param t: Pointer to check
  * @param fmt: Pass to vprintf, Format and arguments such as description
- * @return 0 if t is NULL
+ * @return 0 if t is nullptr
  */
 #define nullpo_ret_f(t, fmt, ...) \
 	if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), __VA_ARGS__)) {return(0);}
@@ -67,7 +67,7 @@
  * Return void and display additional information if pointer is not found.
  * @param t: Pointer to check
  * @param fmt: Pass to vprintf, Format and arguments such as description
- * @return void if t is NULL
+ * @return void if t is nullptr
  */
 #define nullpo_retv_f(t, fmt, ...) \
 	if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), __VA_ARGS__)) {return;}
@@ -95,7 +95,7 @@
  * Return 0 and display additional information if pointer is not found.
  * @param t: Pointer to check
  * @param fmt: Pass to vprintf, Format and arguments such as description
- * @return 0 if t is NULL
+ * @return 0 if t is nullptr
  */
 #define nullpo_ret_f(t, fmt, args...) \
 	if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), ## args)) {return(0);}
@@ -104,7 +104,7 @@
  * Return void and display additional information if pointer is not found.
  * @param t: Pointer to check
  * @param fmt: Pass to vprintf, Format and arguments such as description
- * @return void if t is NULL
+ * @return void if t is nullptr
  */
 #define nullpo_retv_f(t, fmt, args...) \
 	if (nullpo_chk_f(NLP_MARK, (void *)(t), (fmt), ## args)) {return;}
@@ -164,23 +164,23 @@
 #endif /* NULLPO_CHECK */
 
 /**
- * Check for NULL pointer and output information.
+ * Check for nullptr pointer and output information.
  * @param file: __FILE__
  * @param line: __LINE__
  * @param func: __func__ (name of the function) [NLP_MARK]
  * @param target: Target to check
- * @return 0 on success or 1 on NULL
+ * @return 0 on success or 1 on nullptr
  */
 int nullpo_chk(const char *file, int line, const char *func, const void *target);
 
 /**
- * Check for NULL pointer and output detailed information.
+ * Check for nullptr pointer and output detailed information.
  * @param file: __FILE__
  * @param line: __LINE__
  * @param func: __func__ (name of the function) [NLP_MARK]
  * @param target: Target to check
  * @param fmt: Passed to vprintf
- * @return 0 on success or 1 on NULL
+ * @return 0 on success or 1 on nullptr
  */
 int nullpo_chk_f(const char *file, int line, const char *func, const void *target,
                  const char *fmt, ...)
@@ -196,7 +196,7 @@ int nullpo_chk_f(const char *file, int line, const char *func, const void *targe
 void nullpo_info(const char *file, int line, const char *func);
 
 /**
- * Check for NULL pointer and output detailed information.
+ * Check for nullptr pointer and output detailed information.
  * @param file: __FILE__
  * @param line: __LINE__
  * @param func: __func__ (name of the function) [NLP_MARK]

+ 8 - 8
src/common/showmsg.cpp

@@ -62,7 +62,7 @@ char console_log_filepath[32] = "./log/unknown.log";
 		StringBuf *d_;			\
 		char *v_;				\
 		size_t l_;					\
-	} buf ={"",NULL,NULL,0};	\
+	} buf ={"",nullptr,nullptr,0};	\
 //define NEWBUF
 
 #define BUFVPRINTF(buf,fmt,args)						\
@@ -87,9 +87,9 @@ char console_log_filepath[32] = "./log/unknown.log";
 	if( buf.d_ )				\
 	{							\
 		StringBuf_Free(buf.d_);	\
-		buf.d_ = NULL;			\
+		buf.d_ = nullptr;			\
 	}							\
-	buf.v_ = NULL;				\
+	buf.v_ = nullptr;				\
 //define FREEBUF
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -216,7 +216,7 @@ int	VFPRINTF(HANDLE handle, const char *fmt, va_list argptr)
 
 	// start with processing
 	p = BUFVAL(tempbuf);
-	while ((q = strchr(p, 0x1b)) != NULL)
+	while ((q = strchr(p, 0x1b)) != nullptr)
 	{	// find the escape character
 		if( 0==WriteConsole(handle, p, (DWORD)(q-p), &written, 0) ) // write up to the escape
 			WriteFile(handle, p, (DWORD)(q-p), &written, 0);
@@ -547,7 +547,7 @@ int	VFPRINTF(FILE *file, const char *fmt, va_list argptr)
 
 	// start with processing
 	p = BUFVAL(tempbuf);
-	while ((q = strchr(p, 0x1b)) != NULL)
+	while ((q = strchr(p, 0x1b)) != nullptr)
 	{	// find the escape character
 		fprintf(file, "%.*s", (int)(q-p), p); // write up to the escape
 		if( q[1]!='[' )
@@ -688,7 +688,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
 		( flag == MSG_WARNING && console_msg_log&1 ) ||
 		( ( flag == MSG_ERROR || flag == MSG_SQL ) && console_msg_log&2 ) ||
 		( flag == MSG_DEBUG && console_msg_log&4 ) ) {//[Ind]
-		FILE *log = NULL;
+		FILE *log = nullptr;
 		if( (log = fopen(console_log_filepath, "a+")) ) {
 			char timestring[255];
 			time_t curtime;
@@ -720,7 +720,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
 
 	if (timestamp_format[0] && flag != MSG_NONE)
 	{	//Display time format. [Skotlex]
-		time_t t = time(NULL);
+		time_t t = time(nullptr);
 		strftime(prefix, 80, timestamp_format, localtime(&t));
 	} else prefix[0]='\0';
 
@@ -775,7 +775,7 @@ int _vShowMessage(enum msg_type flag, const char *string, va_list ap)
 #if defined(DEBUGLOGMAP) || defined(DEBUGLOGCHAR) || defined(DEBUGLOGLOGIN)
 	if(strlen(DEBUGLOGPATH) > 0) {
 		fp=fopen(DEBUGLOGPATH,"a");
-		if (fp == NULL)	{
+		if (fp == nullptr)	{
 			FPRINTF(STDERR, CL_RED "[ERROR]" CL_RESET ": Could not open '" CL_WHITE "%s" CL_RESET "', access denied.\n", DEBUGLOGPATH);
 			FFLUSH(STDERR);
 		} else {

+ 18 - 18
src/common/socket.cpp

@@ -159,8 +159,8 @@ char* sErr(int code)
 {
 	static char sbuf[512];
 	// strerror does not handle socket codes
-	if( FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
-			code, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), (LPTSTR)&sbuf, sizeof(sbuf), NULL) == 0 )
+	if( FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, nullptr,
+			code, MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), (LPTSTR)&sbuf, sizeof(sbuf), nullptr) == 0 )
 		snprintf(sbuf, sizeof(sbuf), "unknown error");
 	return sbuf;
 }
@@ -456,7 +456,7 @@ int send_from_fifo(int fd)
 /// Best effort - there's no warranty that the data will be sent.
 void flush_fifo(int fd)
 {
-	if(session[fd] != NULL)
+	if(session[fd] != nullptr)
 		session[fd]->func_send(fd);
 }
 
@@ -650,7 +650,7 @@ int make_connection(uint32 ip, uint16 port, bool silent,int timeout) {
 			tv.tv_sec = timeout;
 			tv.tv_usec = 0;
 
-			result = sSelect(0, NULL, &writeSet, NULL, &tv);
+			result = sSelect(0, nullptr, &writeSet, nullptr, &tv);
 
 			// Connection attempt timed out
 			if( result == 0 ){
@@ -750,7 +750,7 @@ static void delete_session(int fd)
 		aFree(session[fd]->wdata);
 		aFree(session[fd]->session_data);
 		aFree(session[fd]);
-		session[fd] = NULL;
+		session[fd] = nullptr;
 	}
 }
 
@@ -824,7 +824,7 @@ int WFIFOSET(int fd, size_t len)
 	size_t newreserve;
 	struct socket_data* s = session[fd];
 
-	if( !session_isValid(fd) || s->wdata == NULL )
+	if( !session_isValid(fd) || s->wdata == nullptr )
 		return 0;
 
 	// we have written len bytes to the buffer already before calling WFIFOSET
@@ -920,7 +920,7 @@ int do_sockets(t_tick next)
 	timeout.tv_usec = (long)(next%1000*1000);
 
 	memcpy(&rfd, &readfds, sizeof(rfd));
-	ret = sSelect(fd_max, &rfd, NULL, NULL, &timeout);
+	ret = sSelect(fd_max, &rfd, nullptr, nullptr, &timeout);
 
 	if( ret == SOCKET_ERROR )
 	{
@@ -946,7 +946,7 @@ int do_sockets(t_tick next)
 	}
 #endif
 
-	last_tick = time(NULL);
+	last_tick = time(nullptr);
 
 #if defined(WIN32)
 	// on windows, enumerating all members of the fd_set is way faster if we access the internals
@@ -1080,8 +1080,8 @@ enum _aco {
 	ACO_MUTUAL_FAILURE
 };
 
-static AccessControl* access_allow = NULL;
-static AccessControl* access_deny = NULL;
+static AccessControl* access_allow = nullptr;
+static AccessControl* access_deny = nullptr;
 static int access_order    = ACO_DENY_ALLOW;
 static int access_allownum = 0;
 static int access_denynum  = 0;
@@ -1299,7 +1299,7 @@ int socket_config_read(const char* cfgName)
 	FILE *fp;
 
 	fp = fopen(cfgName, "r");
-	if(fp == NULL) {
+	if(fp == nullptr) {
 		ShowError("File not found: %s\n", cfgName);
 		return 1;
 	}
@@ -1400,7 +1400,7 @@ void socket_final(void)
 	aFree(session[0]->wdata);
 	aFree(session[0]->session_data);
 	aFree(session[0]);
-	session[0] = NULL;
+	session[0] = nullptr;
 
 #ifdef WIN32
 	// Shut down windows networking
@@ -1449,7 +1449,7 @@ int socket_getips(uint32* ips, int max)
 {
 	int num = 0;
 
-	if( ips == NULL || max <= 0 )
+	if( ips == nullptr || max <= 0 )
 		return 0;
 
 #ifdef WIN32
@@ -1470,12 +1470,12 @@ int socket_getips(uint32* ips, int max)
 			u_long** a;
 			struct hostent* hent;
 			hent = gethostbyname(fullhost);
-			if( hent == NULL ){
+			if( hent == nullptr ){
 				ShowError("socket_getips: Cannot resolve our own hostname to an IP address\n");
 				return 0;
 			}
 			a = (u_long**)hent->h_addr_list;
-			for( ;num < max && a[num] != NULL; ++num)
+			for( ;num < max && a[num] != nullptr; ++num)
 				ips[num] = (uint32)ntohl(*a[num]);
 		}
 	}
@@ -1608,7 +1608,7 @@ void socket_init(void)
 	socket_config_read(SOCKET_CONF_FILENAME);
 
 	// initialise last send-receive tick
-	last_tick = time(NULL);
+	last_tick = time(nullptr);
 
 	// session[0] is now currently used for disconnected sessions of the map server, and as such,
 	// should hold enough buffer (it is a vacuum so to speak) as it is never flushed. [Skotlex]
@@ -1639,7 +1639,7 @@ bool session_isActive(int fd)
 uint32 host2ip(const char* hostname)
 {
 	struct hostent* h = gethostbyname(hostname);
-	return (h != NULL) ? ntohl(*(uint32*)h->h_addr) : 0;
+	return (h != nullptr) ? ntohl(*(uint32*)h->h_addr) : 0;
 }
 
 // Converts a numeric ip into a dot-formatted string.
@@ -1648,7 +1648,7 @@ const char* ip2str(uint32 ip, char ip_str[16])
 {
 	struct in_addr addr;
 	addr.s_addr = htonl(ip);
-	return (ip_str == NULL) ? inet_ntoa(addr) : strncpy(ip_str, inet_ntoa(addr), 16);
+	return (ip_str == nullptr) ? inet_ntoa(addr) : strncpy(ip_str, inet_ntoa(addr), 16);
 }
 
 // Converts a dot-formatted ip string into a numeric ip.

+ 33 - 33
src/common/sql.cpp

@@ -85,8 +85,8 @@ Sql* Sql_Malloc(void)
 	CREATE(self, Sql, 1);
 	mysql_init(&self->handle);
 	StringBuf_Init(&self->buf);
-	self->lengths = NULL;
-	self->result = NULL;
+	self->lengths = nullptr;
+	self->result = nullptr;
 	self->keepalive = INVALID_TIMER;
 	my_bool reconnect = 1;
 	mysql_options(&self->handle, MYSQL_OPT_RECONNECT, &reconnect);
@@ -117,7 +117,7 @@ static int Sql_P_Keepalive(Sql* self);
  */
 int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* host, uint16 port, const char* db)
 {
-	if( self == NULL )
+	if( self == nullptr )
 		return SQL_ERROR;
 
 	StringBuf_Clear(&self->buf);
@@ -130,7 +130,7 @@ int Sql_Connect(Sql* self, const char* user, const char* passwd, const char* hos
 	}
 #endif
 
-	if( !mysql_real_connect(&self->handle, host, user, passwd, db, (unsigned int)port, NULL/*unix_socket*/, 0/*clientflag*/) )
+	if( !mysql_real_connect(&self->handle, host, user, passwd, db, (unsigned int)port, nullptr/*unix_socket*/, 0/*clientflag*/) )
 	{
 		ShowSQL("%s\n", mysql_error(&self->handle));
 		return SQL_ERROR;
@@ -158,7 +158,7 @@ int Sql_GetTimeout(Sql* self, uint32* out_timeout)
 		if( SQL_SUCCESS == Sql_NextRow(self) &&
 			SQL_SUCCESS == Sql_GetData(self, 1, &data, &len) )
 		{
-			*out_timeout = (uint32)strtoul(data, NULL, 10);
+			*out_timeout = (uint32)strtoul(data, nullptr, 10);
 			Sql_FreeResult(self);
 			return SQL_SUCCESS;
 		}
@@ -176,7 +176,7 @@ int Sql_GetColumnNames(Sql* self, const char* table, char* out_buf, size_t buf_l
 	size_t len;
 	size_t off = 0;
 
-	if( self == NULL || SQL_ERROR == Sql_Query(self, "EXPLAIN `%s`", table) )
+	if( self == nullptr || SQL_ERROR == Sql_Query(self, "EXPLAIN `%s`", table) )
 		return SQL_ERROR;
 
 	out_buf[off] = '\0';
@@ -297,7 +297,7 @@ int Sql_Query(Sql* self, const char* query, ...)
 /// Executes a query.
 int Sql_QueryV(Sql* self, const char* query, va_list args)
 {
-	if( self == NULL )
+	if( self == nullptr )
 		return SQL_ERROR;
 
 	Sql_FreeResult(self);
@@ -324,7 +324,7 @@ int Sql_QueryV(Sql* self, const char* query, va_list args)
 /// Executes a query.
 int Sql_QueryStr(Sql* self, const char* query)
 {
-	if( self == NULL )
+	if( self == nullptr )
 		return SQL_ERROR;
 
 	Sql_FreeResult(self);
@@ -400,7 +400,7 @@ int Sql_NextRow(Sql* self)
 			self->lengths = mysql_fetch_lengths(self->result);
 			return SQL_SUCCESS;
 		}
-		self->lengths = NULL;
+		self->lengths = nullptr;
 		if( mysql_errno(&self->handle) == 0 )
 			return SQL_NO_DATA;
 	}
@@ -421,7 +421,7 @@ int Sql_GetData(Sql* self, size_t col, char** out_buf, size_t* out_len)
 		}
 		else
 		{// out of range - ignore
-			if( out_buf ) *out_buf = NULL;
+			if( out_buf ) *out_buf = nullptr;
 			if( out_len ) *out_len = 0;
 		}
 		return SQL_SUCCESS;
@@ -437,9 +437,9 @@ void Sql_FreeResult(Sql* self)
 	if( self && self->result )
 	{
 		mysql_free_result(self->result);
-		self->result = NULL;
-		self->row = NULL;
-		self->lengths = NULL;
+		self->result = nullptr;
+		self->row = nullptr;
+		self->lengths = nullptr;
 	}
 }
 
@@ -454,8 +454,8 @@ void Sql_Close(Sql* self) {
 /// Shows debug information (last query).
 void Sql_ShowDebug_(Sql* self, const char* debug_file, const unsigned long debug_line)
 {
-	if( self == NULL )
-		ShowDebug("at %s:%lu - self is NULL\n", debug_file, debug_line);
+	if( self == nullptr )
+		ShowDebug("at %s:%lu - self is nullptr\n", debug_file, debug_line);
 	else if( StringBuf_Length(&self->buf) > 0 )
 		ShowDebug("at %s:%lu - %s\n", debug_file, debug_line, StringBuf_Value(&self->buf));
 	else
@@ -680,21 +680,21 @@ SqlStmt* SqlStmt_Malloc(Sql* sql)
 	SqlStmt* self;
 	MYSQL_STMT* stmt;
 
-	if( sql == NULL )
-		return NULL;
+	if( sql == nullptr )
+		return nullptr;
 
 	stmt = mysql_stmt_init(&sql->handle);
-	if( stmt == NULL )
+	if( stmt == nullptr )
 	{
 		ShowSQL("DB error - %s\n", mysql_error(&sql->handle));
-		return NULL;
+		return nullptr;
 	}
 	CREATE(self, SqlStmt, 1);
 	StringBuf_Init(&self->buf);
 	self->stmt = stmt;
-	self->params = NULL;
-	self->columns = NULL;
-	self->column_lengths = NULL;
+	self->params = nullptr;
+	self->columns = nullptr;
+	self->column_lengths = nullptr;
 	self->max_params = 0;
 	self->max_columns = 0;
 	self->bind_params = false;
@@ -723,7 +723,7 @@ int SqlStmt_Prepare(SqlStmt* self, const char* query, ...)
 /// Prepares the statement.
 int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args)
 {
-	if( self == NULL )
+	if( self == nullptr )
 		return SQL_ERROR;
 
 	SqlStmt_FreeResult(self);
@@ -745,7 +745,7 @@ int SqlStmt_PrepareV(SqlStmt* self, const char* query, va_list args)
 /// Prepares the statement.
 int SqlStmt_PrepareStr(SqlStmt* self, const char* query)
 {
-	if( self == NULL )
+	if( self == nullptr )
 		return SQL_ERROR;
 
 	SqlStmt_FreeResult(self);
@@ -778,7 +778,7 @@ size_t SqlStmt_NumParams(SqlStmt* self)
 /// Binds a parameter to a buffer.
 int SqlStmt_BindParam(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, void* buffer, size_t buffer_len)
 {
-	if( self == NULL )
+	if( self == nullptr )
 		return SQL_ERROR;
 
 	if( !self->bind_params )
@@ -798,7 +798,7 @@ int SqlStmt_BindParam(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, v
 		self->bind_params = true;
 	}
 	if( idx < self->max_params )
-		return Sql_P_BindSqlDataType(self->params+idx, buffer_type, buffer, buffer_len, NULL, NULL);
+		return Sql_P_BindSqlDataType(self->params+idx, buffer_type, buffer, buffer_len, nullptr, nullptr);
 	else
 		return SQL_SUCCESS;// out of range - ignore
 }
@@ -808,7 +808,7 @@ int SqlStmt_BindParam(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, v
 /// Executes the prepared statement.
 int SqlStmt_Execute(SqlStmt* self)
 {
-	if( self == NULL )
+	if( self == nullptr )
 		return SQL_ERROR;
 
 	SqlStmt_FreeResult(self);
@@ -857,7 +857,7 @@ size_t SqlStmt_NumColumns(SqlStmt* self)
 /// Binds the result of a column to a buffer.
 int SqlStmt_BindColumn(SqlStmt* self, size_t idx, enum SqlDataType buffer_type, void* buffer, size_t buffer_len, uint32* out_length, int8* out_is_null)
 {
-	if( self == NULL )
+	if( self == nullptr )
 		return SQL_ERROR;
 
 	if( buffer_type == SQLDT_STRING || buffer_type == SQLDT_ENUM )
@@ -918,7 +918,7 @@ int SqlStmt_NextRow(SqlStmt* self)
 	size_t i;
 	size_t cols;
 
-	if( self == NULL )
+	if( self == nullptr )
 		return SQL_ERROR;
 
 	// bind columns
@@ -949,7 +949,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);
-			column->error = NULL;
+			column->error = nullptr;
 			if( truncated )
 			{// report truncated column
 				SqlStmt_P_ShowDebugTruncatedColumn(self, i);
@@ -1014,8 +1014,8 @@ void SqlStmt_FreeResult(SqlStmt* self)
 /// Shows debug information (with statement).
 void SqlStmt_ShowDebug_(SqlStmt* self, const char* debug_file, const unsigned long debug_line)
 {
-	if( self == NULL )
-		ShowDebug("at %s:%lu -  self is NULL\n", debug_file, debug_line);
+	if( self == nullptr )
+		ShowDebug("at %s:%lu -  self is nullptr\n", debug_file, debug_line);
 	else if( StringBuf_Length(&self->buf) > 0 )
 		ShowDebug("at %s:%lu - %s\n", debug_file, debug_line, StringBuf_Value(&self->buf));
 	else
@@ -1065,7 +1065,7 @@ void Sql_inter_server_read(const char* cfgName, bool first) {
 	FILE* fp;
 
 	fp = fopen(cfgName, "r");
-	if(fp == NULL) {
+	if(fp == nullptr) {
 		if( first ) {
 			ShowFatalError("File not found: %s\n", cfgName);
 			exit(EXIT_FAILURE);

+ 1 - 1
src/common/sql.hpp

@@ -237,7 +237,7 @@ void Sql_Free(Sql* self);
 /// It uses the connection of the parent Sql handle.
 /// Queries in Sql and SqlStmt are independent and don't affect each other.
 ///
-/// @return SqlStmt handle or NULL if an error occured
+/// @return SqlStmt handle or nullptr if an error occured
 struct SqlStmt* SqlStmt_Malloc(Sql* sql);
 
 

+ 21 - 21
src/common/strlib.cpp

@@ -33,7 +33,7 @@ char* trim(char* str)
 	size_t start;
 	size_t end;
 
-	if( str == NULL )
+	if( str == nullptr )
 		return str;
 
 	// get start position
@@ -62,7 +62,7 @@ char* normalize_name(char* str,const char* delims)
 	char* out = str;
 	int put_space = 0;
 
-	if( str == NULL || delims == NULL )
+	if( str == nullptr || delims == nullptr )
 		return str;
 
 	// trim start of string
@@ -127,12 +127,12 @@ char* _strtok_r(char *s1, const char *s2, char **lasts)
 {
 	char *ret;
 
-	if (s1 == NULL)
+	if (s1 == nullptr)
 		s1 = *lasts;
 	while(*s1 && strchr(s2, *s1))
 		++s1;
 	if(*s1 == '\0')
-		return NULL;
+		return nullptr;
 	ret = s1;
 	while(*s1 && !strchr(s2, *s1))
 		++s1;
@@ -210,7 +210,7 @@ int e_mail_check(char* email)
 		return 0;
 
 	// part of RFC limits (official reference of e-mail description)
-	if (strchr(email, '@') == NULL || email[len-1] == '@')
+	if (strchr(email, '@') == nullptr || email[len-1] == '@')
 		return 0;
 
 	if (email[len-1] == '.')
@@ -218,14 +218,14 @@ int e_mail_check(char* email)
 
 	last_arobas = strrchr(email, '@');
 
-	if (strstr(last_arobas, "@.") != NULL || strstr(last_arobas, "..") != NULL)
+	if (strstr(last_arobas, "@.") != nullptr || strstr(last_arobas, "..") != nullptr)
 		return 0;
 
 	for(ch = 1; ch < 32; ch++)
-		if (strchr(last_arobas, ch) != NULL)
+		if (strchr(last_arobas, ch) != nullptr)
 			return 0;
 
-	if (strchr(last_arobas, ' ') != NULL || strchr(last_arobas, ';') != NULL)
+	if (strchr(last_arobas, ' ') != nullptr || strchr(last_arobas, ';') != nullptr)
 		return 0;
 
 	// all correct
@@ -243,7 +243,7 @@ int config_switch(const char* str)
 	if (strcmpi(str, "off") == 0 || strcmpi(str, "no") == 0 || strcmpi(str, "non") == 0 || strcmpi(str, "nein") == 0 || strcmpi(str, "nao") == 0)
 		return 0;
 
-	return (int)strtol(str, NULL, 0);
+	return (int)strtol(str, nullptr, 0);
 }
 
 /// strncpy that always nul-terminates the string
@@ -270,7 +270,7 @@ char* safestrncpy(char* dst, const char* src, size_t n)
 /// doesn't crash on null pointer
 size_t safestrnlen(const char* string, size_t maxlen)
 {
-	return ( string != NULL ) ? strnlen(string, maxlen) : 0;
+	return ( string != nullptr ) ? strnlen(string, maxlen) : 0;
 }
 
 /// Works like snprintf, but always nul-terminates the buffer.
@@ -305,14 +305,14 @@ int strline(const char* str, size_t pos)
 	const char* target;
 	int line;
 
-	if( str == NULL || pos == 0 )
+	if( str == nullptr || pos == 0 )
 		return 1;
 
 	target = str+pos;
 	for( line = 1; ; ++line )
 	{
 		str = strchr(str, '\n');
-		if( str == NULL || target <= str )
+		if( str == nullptr || target <= str )
 			break;// found target line
 		++str;// skip newline
 	}
@@ -376,7 +376,7 @@ int sv_parse_next( s_svstate& sv ){
 		return -1;// error
 	}
 
-	if( sv.done || str == NULL )
+	if( sv.done || str == nullptr )
 	{
 		sv.done = true;
 		return 0;// nothing to parse
@@ -498,7 +498,7 @@ int sv_parse_next( s_svstate& sv ){
 /// Other position pairs are the start and end of fields.
 /// Returns the number of fields found or -1 if an error occurs.
 ///
-/// out_pos can be NULL.
+/// out_pos can be nullptr.
 /// If a line terminator is found, the end position is placed there.
 /// out_pos[2] and out_pos[3] for the first field, out_pos[4] and out_pos[5]
 /// for the seconds field and so on.
@@ -571,7 +571,7 @@ size_t sv_parse( const char* str, size_t len, size_t startoff, char delim, size_
 /// Other entries are the start of fields (nul-teminated).
 /// Returns the number of fields found or -1 if an error occurs.
 ///
-/// out_fields can be NULL.
+/// out_fields can be nullptr.
 /// Fields that don't fit in out_fields are not nul-terminated.
 /// Extra entries in out_fields are filled with the end of the last field (empty string).
 ///
@@ -676,14 +676,14 @@ size_t sv_escape_c(char* out_dest, const char* src, size_t len, const char* esca
 	size_t i;
 	size_t j;
 
-	if( out_dest == NULL )
+	if( out_dest == nullptr )
 		return 0;// nothing to do
-	if( src == NULL )
+	if( src == nullptr )
 	{// nothing to escape
 		*out_dest = 0;
 		return 0;
 	}
-	if( escapes == NULL )
+	if( escapes == nullptr )
 		escapes = "";
 
 	for( i = 0, j = 0; i < len; ++i )
@@ -814,7 +814,7 @@ size_t sv_unescape_c(char* out_dest, const char* src, size_t len)
 			}
 			else
 			{// other escape sequence
-				if( strchr(SV_ESCAPE_C_SUPPORTED, src[i]) == NULL )
+				if( strchr(SV_ESCAPE_C_SUPPORTED, src[i]) == nullptr )
 					ShowWarning("sv_unescape_c: unknown escape sequence \\%c\n", src[i]);
 				switch( src[i] )
 				{
@@ -896,7 +896,7 @@ bool sv_readdb( const char* directory, const char* filename, char delim, size_t
 
 	// open file
 	fp = fopen(path, "r");
-	if( fp == NULL )
+	if( fp == nullptr )
 	{
 		if(silent == 0) ShowError("sv_readdb: can't read %s\n", path);
 		return false;
@@ -912,7 +912,7 @@ bool sv_readdb( const char* directory, const char* filename, char delim, size_t
 		char *match;
 		lines++;
 
-		if( ( match = strstr(line, "//") ) != NULL )
+		if( ( match = strstr(line, "//") ) != nullptr )
 		{// strip comments
 			match[0] = 0;
 		}

+ 11 - 11
src/common/timer.cpp

@@ -25,12 +25,12 @@ const t_tick TIMER_MIN_INTERVAL = 20;
 const t_tick TIMER_MAX_INTERVAL = 1000;
 
 // timers (array)
-static struct TimerData* timer_data = NULL;
+static struct TimerData* timer_data = nullptr;
 static int timer_data_max = 0;
 static int timer_data_num = 0;
 
 // free timers (array)
-static int* free_timer_list = NULL;
+static int* free_timer_list = nullptr;
 static int free_timer_list_max = 0;
 static int free_timer_list_pos = 0;
 
@@ -58,7 +58,7 @@ struct timer_func_list {
 	struct timer_func_list* next;
 	TimerFunc func;
 	char* name;
-} *tfl_root = NULL;
+} *tfl_root = nullptr;
 
 /// Sets the name of a timer function.
 int add_timer_func_list(TimerFunc func, const char* name)
@@ -66,7 +66,7 @@ int add_timer_func_list(TimerFunc func, const char* name)
 	struct timer_func_list* tfl;
 
 	if (name) {
-		for( tfl=tfl_root; tfl != NULL; tfl=tfl->next )
+		for( tfl=tfl_root; tfl != nullptr; tfl=tfl->next )
 		{// check suspicious cases
 			if( func == tfl->func )
 				ShowWarning("add_timer_func_list: duplicating function %p(%s) as %s.\n",tfl->func,tfl->name,name);
@@ -87,7 +87,7 @@ const char* search_timer_func_list(TimerFunc func)
 {
 	struct timer_func_list* tfl;
 
-	for( tfl=tfl_root; tfl != NULL; tfl=tfl->next )
+	for( tfl=tfl_root; tfl != nullptr; tfl=tfl->next )
 		if (func == tfl->func)
 			return tfl->name;
 
@@ -154,7 +154,7 @@ static t_tick tick(void)
 	return tval.tv_sec * 1000 + tval.tv_nsec / 1000000;
 #else
 	struct timeval tval;
-	gettimeofday(&tval, NULL);
+	gettimeofday(&tval, nullptr);
 	return tval.tv_sec * 1000 + tval.tv_usec / 1000;
 #endif
 }
@@ -286,7 +286,7 @@ int add_timer_interval(t_tick tick, TimerFunc func, int id, intptr_t data, int i
 /// Retrieves internal timer data
 const struct TimerData* get_timer(int tid)
 {
-	return ( tid >= 0 && tid < timer_data_num ) ? &timer_data[tid] : NULL;
+	return ( tid >= 0 && tid < timer_data_num ) ? &timer_data[tid] : nullptr;
 }
 
 /// Marks a timer specified by 'id' for immediate deletion once it expires.
@@ -305,7 +305,7 @@ int delete_timer(int tid, TimerFunc func)
 		return -2;
 	}
 
-	timer_data[tid].func = NULL;
+	timer_data[tid].func = nullptr;
 	timer_data[tid].type = TIMER_ONCE_AUTODEL;
 
 	return 0;
@@ -406,7 +406,7 @@ t_tick do_timer(t_tick tick)
 
 unsigned long get_uptime(void)
 {
-	return (unsigned long)difftime(time(NULL), start_time);
+	return (unsigned long)difftime(time(nullptr), start_time);
 }
 
 /**
@@ -460,7 +460,7 @@ void split_time(int timein, int* year, int* month, int* day, int* hour, int* min
 double solve_time(char* modif_p) {
 	double totaltime = 0;
 	struct tm then_tm;
-	time_t now = time(NULL);
+	time_t now = time(nullptr);
 	time_t then = now;
 	then_tm = *localtime(&then);
 	
@@ -521,7 +521,7 @@ void timer_final(void)
 	struct timer_func_list *tfl;
 	struct timer_func_list *next;
 
-	for( tfl=tfl_root; tfl != NULL; tfl = next ) {
+	for( tfl=tfl_root; tfl != nullptr; tfl = next ) {
 		next = tfl->next;	// copy next pointer
 		aFree(tfl->name);	// free structures
 		aFree(tfl);

+ 6 - 6
src/common/utils.cpp

@@ -87,7 +87,7 @@ void ShowDump(const void* buffer, size_t length)
 static char* checkpath(char *path, const char *srcpath)
 {	// just make sure the char*path is not const
 	char *p=path;
-	if(NULL!=path && NULL!=srcpath)
+	if(nullptr!=path && nullptr!=srcpath)
 	while(*srcpath) {
 		if (*srcpath=='/') {
 			*p++ = '\\';
@@ -106,8 +106,8 @@ void findfile(const char *p, const char *pat, void (func)(const char*))
 	HANDLE hFind;
 	char tmppath[MAX_PATH+1];
 
-	const char *path    = (p  ==NULL)? "." : p;
-	const char *pattern = (pat==NULL)? "" : pat;
+	const char *path    = (p  ==nullptr)? "." : p;
+	const char *pattern = (pat==nullptr)? "" : pat;
 
 	checkpath(tmppath,path);
 	if( PATHSEP != tmppath[strlen(tmppath)-1])
@@ -198,7 +198,7 @@ int check_filepath(const char* filepath)
 static char* checkpath(char *path, const char*srcpath)
 {	// just make sure the char*path is not const
 	char *p=path;
-	if(NULL!=path && NULL!=srcpath)
+	if(nullptr!=path && nullptr!=srcpath)
 	while(*srcpath) {
 		if (*srcpath=='\\') {
 			*p++ = '/';
@@ -218,8 +218,8 @@ void findfile(const char *p, const char *pat, void (func)(const char*))
 	struct stat dir_stat;       // used by stat().
 	char tmppath[MAX_DIR_PATH * 2];
 	char path[MAX_DIR_PATH+1]= ".";
-	const char *pattern = (pat==NULL)? "" : pat;
-	if(p!=NULL) strcpy(path,p);
+	const char *pattern = (pat==nullptr)? "" : pat;
+	if(p!=nullptr) strcpy(path,p);
 
 	// open the directory for reading
 	dir = opendir( checkpath(path, path) );

+ 7 - 7
src/common/winapi.cpp

@@ -12,16 +12,16 @@ bool IsCurrentUserLocalAdministrator(void){
 	DWORD  dwAccessDesired;
 	DWORD  dwACLSize;
 	DWORD  dwStructureSize = sizeof(PRIVILEGE_SET);
-	PACL   pACL = NULL;
-	PSID   psidAdmin = NULL;
+	PACL   pACL = nullptr;
+	PSID   psidAdmin = nullptr;
 
-	HANDLE hToken = NULL;
-	HANDLE hImpersonationToken = NULL;
+	HANDLE hToken = nullptr;
+	HANDLE hImpersonationToken = nullptr;
 
 	PRIVILEGE_SET   ps;
 	GENERIC_MAPPING GenericMapping;
 
-	PSECURITY_DESCRIPTOR     psdAdmin = NULL;
+	PSECURITY_DESCRIPTOR     psdAdmin = nullptr;
 	SID_IDENTIFIER_AUTHORITY SystemSidAuthority = SECURITY_NT_AUTHORITY;
 
 
@@ -90,7 +90,7 @@ bool IsCurrentUserLocalAdministrator(void){
 			__leave;
 
 		psdAdmin = LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
-		if (psdAdmin == NULL)
+		if (psdAdmin == nullptr)
 			__leave;
 
 		if (!InitializeSecurityDescriptor(psdAdmin,
@@ -103,7 +103,7 @@ bool IsCurrentUserLocalAdministrator(void){
 			GetLengthSid(psidAdmin) - sizeof(DWORD);
 
 		pACL = (PACL)LocalAlloc(LPTR, dwACLSize);
-		if (pACL == NULL)
+		if (pACL == nullptr)
 			__leave;
 
 		if (!InitializeAcl(pACL, dwACLSize, ACL_REVISION2))

+ 32 - 32
src/login/account.cpp

@@ -85,7 +85,7 @@ AccountDB* account_db_sql(void) {
 	db->vtable.iterator     = &account_db_sql_iterator;
 
 	// initialize to default values
-	db->accounts = NULL;
+	db->accounts = nullptr;
 	// other settings
 	db->case_sensitive = false;
 	safestrncpy(db->account_db, "login", sizeof(db->account_db));
@@ -116,7 +116,7 @@ static bool account_db_sql_init(AccountDB* self) {
 			db->db_username.c_str(), db->db_hostname.c_str(), db->db_port, db->db_database.c_str());
 		Sql_ShowDebug(sql_handle);
 		Sql_Free(db->accounts);
-		db->accounts = NULL;
+		db->accounts = nullptr;
 		return false;
 	}
 
@@ -140,7 +140,7 @@ static void account_db_sql_destroy(AccountDB* self){
 	}
 
 	Sql_Free(db->accounts);
-	db->accounts = NULL;
+	db->accounts = nullptr;
 
 	db->~AccountDB_SQL();
 	aFree(db);
@@ -302,7 +302,7 @@ static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc) {
 		}
 
 		Sql_GetData(sql_handle, 0, &data, &len);
-		account_id = ( data != NULL ) ? atoi(data) : 0;
+		account_id = ( data != nullptr ) ? atoi(data) : 0;
 		Sql_FreeResult(sql_handle);
 		account_id = max((uint32_t) START_ACCOUNT_NUM, account_id);
 	}
@@ -407,7 +407,7 @@ static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, co
 		return false;
 	}
 
-	Sql_GetData(sql_handle, 0, &data, NULL);
+	Sql_GetData(sql_handle, 0, &data, nullptr);
 	account_id = atoi(data);
 
 	return account_db_sql_load_num(self, acc, account_id);
@@ -463,8 +463,8 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account
 	}
 
 	if( SQL_SUCCESS == Sql_NextRow(sql_handle) &&
-		SQL_SUCCESS == Sql_GetData(sql_handle, 0, &data, NULL) &&
-		data != NULL )
+		SQL_SUCCESS == Sql_GetData(sql_handle, 0, &data, nullptr) &&
+		data != nullptr )
 	{// get account data
 		uint32 account_id;
 		account_id = atoi(data);
@@ -509,25 +509,25 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, uint32
 		return false;
 	}
 
-	Sql_GetData(sql_handle,  0, &data, NULL); acc->account_id = atoi(data);
-	Sql_GetData(sql_handle,  1, &data, NULL); safestrncpy(acc->userid, data, sizeof(acc->userid));
-	Sql_GetData(sql_handle,  2, &data, NULL); safestrncpy(acc->pass, data, sizeof(acc->pass));
-	Sql_GetData(sql_handle,  3, &data, NULL); acc->sex = data[0];
-	Sql_GetData(sql_handle,  4, &data, NULL); safestrncpy(acc->email, data, sizeof(acc->email));
-	Sql_GetData(sql_handle,  5, &data, NULL); acc->group_id = (unsigned int) atoi(data);
-	Sql_GetData(sql_handle,  6, &data, NULL); acc->state = (unsigned int) strtoul(data, NULL, 10);
-	Sql_GetData(sql_handle,  7, &data, NULL); acc->unban_time = atol(data);
-	Sql_GetData(sql_handle,  8, &data, NULL); acc->expiration_time = atol(data);
-	Sql_GetData(sql_handle,  9, &data, NULL); acc->logincount = (unsigned int) strtoul(data, NULL, 10);
-	Sql_GetData(sql_handle, 10, &data, NULL); safestrncpy(acc->lastlogin, data==NULL?"":data, sizeof(acc->lastlogin));
-	Sql_GetData(sql_handle, 11, &data, NULL); safestrncpy(acc->last_ip, data, sizeof(acc->last_ip));
-	Sql_GetData(sql_handle, 12, &data, NULL); safestrncpy(acc->birthdate, data==NULL?"":data, sizeof(acc->birthdate));
-	Sql_GetData(sql_handle, 13, &data, NULL); acc->char_slots = (uint8) atoi(data);
-	Sql_GetData(sql_handle, 14, &data, NULL); safestrncpy(acc->pincode, data, sizeof(acc->pincode));
-	Sql_GetData(sql_handle, 15, &data, NULL); acc->pincode_change = atol(data);
+	Sql_GetData(sql_handle,  0, &data, nullptr); acc->account_id = atoi(data);
+	Sql_GetData(sql_handle,  1, &data, nullptr); safestrncpy(acc->userid, data, sizeof(acc->userid));
+	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,  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, 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));
+	Sql_GetData(sql_handle, 13, &data, nullptr); acc->char_slots = (uint8) atoi(data);
+	Sql_GetData(sql_handle, 14, &data, nullptr); safestrncpy(acc->pincode, data, sizeof(acc->pincode));
+	Sql_GetData(sql_handle, 15, &data, nullptr); acc->pincode_change = atol(data);
 #ifdef VIP_ENABLE
-	Sql_GetData(sql_handle, 16, &data, NULL); acc->vip_time = atol(data);
-	Sql_GetData(sql_handle, 17, &data, NULL); acc->old_group = atoi(data);
+	Sql_GetData(sql_handle, 16, &data, nullptr); acc->vip_time = atol(data);
+	Sql_GetData(sql_handle, 17, &data, nullptr); acc->old_group = atoi(data);
 #endif
 	Sql_FreeResult(sql_handle);
 	acc->web_auth_token[0] = '\0';
@@ -783,7 +783,7 @@ void mmo_send_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 c
 	 * { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) }
 	 **/
 	while ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) {
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		len = strlen(data)+1;
 
 		WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 32
@@ -792,12 +792,12 @@ void mmo_send_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 c
 		safestrncpy(WFIFOCP(fd,plen), data, len);
 		plen += len;
 
-		Sql_GetData(sql_handle, 1, &data, NULL);
+		Sql_GetData(sql_handle, 1, &data, nullptr);
 
 		WFIFOL(fd, plen) = (uint32)atol(data);
 		plen += 4;
 
-		Sql_GetData(sql_handle, 2, &data, NULL);
+		Sql_GetData(sql_handle, 2, &data, nullptr);
 		len = strlen(data)+1;
 
 		WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 254
@@ -850,7 +850,7 @@ void mmo_send_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 c
 	 * { keyLength(B), key(<keyLength>), index(L), value(L) }
 	 **/
 	while ( SQL_SUCCESS == Sql_NextRow(sql_handle) ) {
-		Sql_GetData(sql_handle, 0, &data, NULL);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
 		len = strlen(data)+1;
 
 		WFIFOB(fd, plen) = (unsigned char)len; // won't be higher; the column size is 32
@@ -859,14 +859,14 @@ void mmo_send_global_accreg(AccountDB* self, int fd, uint32 account_id, uint32 c
 		safestrncpy(WFIFOCP(fd,plen), data, len);
 		plen += len;
 
-		Sql_GetData(sql_handle, 1, &data, NULL);
+		Sql_GetData(sql_handle, 1, &data, nullptr);
 
 		WFIFOL(fd, plen) = (uint32)atol(data);
 		plen += 4;
 
-		Sql_GetData(sql_handle, 2, &data, NULL);
+		Sql_GetData(sql_handle, 2, &data, nullptr);
 
-		WFIFOQ(fd, plen) = strtoll(data,NULL,10);
+		WFIFOQ(fd, plen) = strtoll(data,nullptr,10);
 		plen += 8;
 
 		WFIFOW(fd, 14) += 1;

+ 4 - 4
src/login/ipban.cpp

@@ -25,7 +25,7 @@ std::string ipban_codepage = "";
 std::string ipban_table = "ipbanlist";
 
 // globals
-static Sql* sql_handle = NULL;
+static Sql* sql_handle = nullptr;
 static int cleanup_timer_id = INVALID_TIMER;
 static bool ipban_inited = false;
 
@@ -39,7 +39,7 @@ TIMER_FUNC(ipban_cleanup);
  */
 bool ipban_check(uint32 ip) {
 	uint8* p = (uint8*)&ip;
-	char* data = NULL;
+	char* data = nullptr;
 	int matches;
 
 	if( !login_config.ipban )
@@ -56,7 +56,7 @@ bool ipban_check(uint32 ip) {
 	if( SQL_ERROR == Sql_NextRow(sql_handle) )
 		return true;// Shouldn't happen, but just in case...
 
-	Sql_GetData(sql_handle, 0, &data, NULL);
+	Sql_GetData(sql_handle, 0, &data, nullptr);
 	matches = atoi(data);
 	Sql_FreeResult(sql_handle);
 
@@ -226,5 +226,5 @@ void ipban_final(void) {
 
 	// close connections
 	Sql_Free(sql_handle);
-	sql_handle = NULL;
+	sql_handle = nullptr;
 }

+ 13 - 13
src/login/login.cpp

@@ -44,7 +44,7 @@ std::unordered_map<uint32,struct online_login_data> online_db;
 std::unordered_map<uint32,struct auth_node> auth_db;
 
 // account database
-AccountDB* accounts = NULL;
+AccountDB* accounts = nullptr;
 // Advanced subnet check [LuzZza]
 struct s_subnet {
 	uint32 mask;
@@ -251,7 +251,7 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con
 	safestrncpy(acc.pass, pass, sizeof(acc.pass));
 	acc.sex = sex;
 	safestrncpy(acc.email, "a@a.com", sizeof(acc.email));
-	acc.expiration_time = ( login_config.start_limited_time != -1 ) ? time(NULL) + login_config.start_limited_time : 0;
+	acc.expiration_time = ( login_config.start_limited_time != -1 ) ? time(nullptr) + login_config.start_limited_time : 0;
 	safestrncpy(acc.lastlogin, "", sizeof(acc.lastlogin));
 	safestrncpy(acc.last_ip, last_ip, sizeof(acc.last_ip));
 	safestrncpy(acc.birthdate, "", sizeof(acc.birthdate));
@@ -305,7 +305,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) {
 
 		sprintf(r_ip, "%u.%u.%u.%u", sin_addr[0], sin_addr[1], sin_addr[2], sin_addr[3]);
 
-		for( dnsbl_serv = strtok(login_config.dnsbl_servs,","); dnsbl_serv != NULL; dnsbl_serv = strtok(NULL,",") ) {
+		for( dnsbl_serv = strtok(login_config.dnsbl_servs,","); dnsbl_serv != nullptr; dnsbl_serv = strtok(nullptr,",") ) {
 			sprintf(ip_dnsbl, "%s.%s", r_ip, trim(dnsbl_serv));
 			if( host2ip(ip_dnsbl) ) {
 				ShowInfo("DNSBL: (%s) Blacklisted. User Kicked.\n", r_ip);
@@ -354,12 +354,12 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) {
 		return 1; // 1 = Incorrect Password
 	}
 
-	if( acc.expiration_time != 0 && acc.expiration_time < time(NULL) ) {
+	if( acc.expiration_time != 0 && acc.expiration_time < time(nullptr) ) {
 		ShowNotice("Connection refused (account: %s, expired ID, ip: %s)\n", sd->userid, ip);
 		return 2; // 2 = This ID is expired
 	}
 
-	if( acc.unban_time != 0 && acc.unban_time > time(NULL) ) {
+	if( acc.unban_time != 0 && acc.unban_time > time(nullptr) ) {
 		char tmpstr[24];
 		timestamp2string(tmpstr, sizeof(tmpstr), acc.unban_time, login_config.date_format);
 		ShowNotice("Connection refused (account: %s, banned until %s, ip: %s)\n", sd->userid, tmpstr, ip);
@@ -372,7 +372,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) {
 	}
 
 	if( login_config.client_hash_check && !isServer ) {
-		struct client_hash_node *node = NULL;
+		struct client_hash_node *node = nullptr;
 		bool match = false;
 
 		for( node = login_config.client_hash_nodes; node; node = node->next ) {
@@ -414,7 +414,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) {
 	sd->group_id = acc.group_id;
 
 	// update account data
-	timestamp2string(acc.lastlogin, sizeof(acc.lastlogin), time(NULL), "%Y-%m-%d %H:%M:%S");
+	timestamp2string(acc.lastlogin, sizeof(acc.lastlogin), time(nullptr), "%Y-%m-%d %H:%M:%S");
 	safestrncpy(acc.last_ip, ip, sizeof(acc.last_ip));
 	acc.unban_time = 0;
 	acc.logincount++;
@@ -536,7 +536,7 @@ int login_lan_config_read(const char *lancfgName) {
 	int line_num = 0, s_subnet=ARRAYLENGTH(subnet);
 	char line[1024], w1[64], w2[64], w3[64], w4[64];
 
-	if((fp = fopen(lancfgName, "r")) == NULL) {
+	if((fp = fopen(lancfgName, "r")) == nullptr) {
 		ShowWarning("LAN Support configuration file is not found: %s\n", lancfgName);
 		return 1;
 	}
@@ -588,7 +588,7 @@ int login_lan_config_read(const char *lancfgName) {
 bool login_config_read(const char* cfgName, bool normal) {
 	char line[1024], w1[32], w2[1024];
 	FILE* fp = fopen(cfgName, "r");
-	if (fp == NULL) {
+	if (fp == nullptr) {
 		ShowError("Configuration file (%s) not found.\n", cfgName);
 		return false;
 	}
@@ -767,7 +767,7 @@ void login_set_defaults() {
 	login_config.time_allowed = 10; //in second
 
 	login_config.client_hash_check = 0;
-	login_config.client_hash_nodes = NULL;
+	login_config.client_hash_nodes = nullptr;
 	login_config.usercount_disable = false;
 	login_config.usercount_low = 200;
 	login_config.usercount_medium = 500;
@@ -819,10 +819,10 @@ void LoginServer::finalize(){
 
 	if (db) { // destroy account engine
 		db->destroy(db);
-		db = NULL;
+		db = nullptr;
 	}
 
-	accounts = NULL; // destroyed in account_engine
+	accounts = nullptr; // destroyed in account_engine
 	online_db.clear();
 	auth_db.clear();
 
@@ -880,7 +880,7 @@ bool LoginServer::initialize( int argc, char* argv[] ){
 	add_timer_interval(gettick() + 600*1000, login_online_data_cleanup, 0, 0, 600*1000);
 
 	// Account database init
-	if( accounts == NULL ) {
+	if( accounts == nullptr ) {
 		ShowFatalError("do_init: account engine not found.\n");
 		return false;
 	} else {

+ 6 - 6
src/login/loginchrif.cpp

@@ -180,7 +180,7 @@ int logchrif_send_accdata(int fd, uint32 aid) {
 
 #ifdef VIP_ENABLE
 		char_vip = login_config.vip_sys.char_increase;
-		if( acc.vip_time > time(NULL) ) {
+		if( acc.vip_time > time(nullptr) ) {
 			isvip = true;
 			char_slots += char_vip;
 		}
@@ -368,14 +368,14 @@ int logchrif_parse_reqbanacc(int fd, int id, char* ip){
 			ShowNotice("Char-server '%s': Error of ban request (account: %d not found, ip: %s).\n", ch_server[id].name, account_id, ip);
 		else{
 			time_t timestamp;
-			if (acc.unban_time == 0 || acc.unban_time < time(NULL))
-				timestamp = time(NULL); // new ban
+			if (acc.unban_time == 0 || acc.unban_time < time(nullptr))
+				timestamp = time(nullptr); // new ban
 			else
 				timestamp = acc.unban_time; // add to existing ban
 			timestamp += timediff;
 			if (timestamp == -1)
 				ShowNotice("Char-server '%s': Error of ban request (account: %d, invalid date, ip: %s).\n", ch_server[id].name, account_id, ip);
-			else if( timestamp <= time(NULL) || timestamp == 0 )
+			else if( timestamp <= time(nullptr) || timestamp == 0 )
 				ShowNotice("Char-server '%s': Error of ban request (account: %d, new date unbans the account, ip: %s).\n", ch_server[id].name, account_id, ip);
 			else{
 				uint8 buf[11];
@@ -609,7 +609,7 @@ int logchrif_parse_updpincode(int fd){
 
 		if( accounts->load_num(accounts, &acc, RFIFOL(fd,4) ) ){
 			strncpy( acc.pincode, RFIFOCP(fd,8), PINCODE_LENGTH+1 );
-			acc.pincode_change = time( NULL );
+			acc.pincode_change = time( nullptr );
 			accounts->save(accounts, &acc, false);
 		}
 		RFIFOSKIP(fd,8 + PINCODE_LENGTH+1);
@@ -667,7 +667,7 @@ int logchrif_parse_reqvipdata(int fd) {
 		RFIFOSKIP(fd,15);
 		
 		if( accounts->load_num(accounts, &acc, aid ) ) {
-			time_t now = time(NULL);
+			time_t now = time(nullptr);
 			time_t vip_time = acc.vip_time;
 			bool isvip = false;
 

+ 1 - 1
src/login/loginclif.cpp

@@ -103,7 +103,7 @@ static void logclif_auth_ok(struct login_session_data* sd) {
 				// wipe previous session
 				login_remove_auth_node(sd->account_id);
 				login_remove_online_user(sd->account_id);
-				data = NULL;
+				data = nullptr;
 			}
 		}
 	}

+ 7 - 7
src/login/loginlog.cpp

@@ -22,7 +22,7 @@ std::string log_db_database = "ragnarok";
 std::string log_login_db = "loginlog";
 std::string log_codepage = "";
 
-static Sql* sql_handle = NULL;
+static Sql* sql_handle = nullptr;
 static bool enabled = false;
 
 
@@ -39,14 +39,14 @@ unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes) {
 		return 0;
 
 	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT count(*) FROM `%s` WHERE `ip` = '%s' AND (`rcode` = '0' OR `rcode` = '1') AND `time` > NOW() - INTERVAL %d MINUTE",
-		log_login_db.c_str(), ip2str(ip,NULL), minutes) )// how many times failed account? in one ip.
+		log_login_db.c_str(), ip2str(ip,nullptr), minutes) )// how many times failed account? in one ip.
 		Sql_ShowDebug(sql_handle);
 
 	if( SQL_SUCCESS == Sql_NextRow(sql_handle) )
 	{
 		char* data;
-		Sql_GetData(sql_handle, 0, &data, NULL);
-		failures = strtoul(data, NULL, 10);
+		Sql_GetData(sql_handle, 0, &data, nullptr);
+		failures = strtoul(data, nullptr, 10);
 		Sql_FreeResult(sql_handle);
 	}
 	return failures;
@@ -73,7 +73,7 @@ void login_log(uint32 ip, const char* username, int rcode, const char* message)
 
 	retcode = Sql_Query(sql_handle,
 		"INSERT INTO `%s`(`time`,`ip`,`user`,`rcode`,`log`) VALUES (NOW(), '%s', '%s', '%d', '%s')",
-		log_login_db.c_str(), ip2str(ip,NULL), esc_username, rcode, esc_message);
+		log_login_db.c_str(), ip2str(ip,nullptr), esc_username, rcode, esc_message);
 
 	if( retcode != SQL_SUCCESS )
 		Sql_ShowDebug(sql_handle);
@@ -90,7 +90,7 @@ bool loginlog_config_read(const char* key, const char* value) {
 		log_db_hostname = value;
 	else
 	if( strcmpi(key, "log_db_port") == 0 )
-		log_db_port = (uint16)strtoul(value, NULL, 10);
+		log_db_port = (uint16)strtoul(value, nullptr, 10);
 	else
 	if( strcmpi(key, "log_db_id") == 0 )
 		log_db_username = value;
@@ -148,6 +148,6 @@ bool loginlog_init(void) {
  */
 bool loginlog_final(void) {
 	Sql_Free(sql_handle);
-	sql_handle = NULL;
+	sql_handle = nullptr;
 	return true;
 }

+ 8 - 8
src/map/achievement.cpp

@@ -437,13 +437,13 @@ AchievementLevelDatabase achievement_level_db;
  * Add an achievement to the player's log
  * @param sd: Player data
  * @param achievement_id: Achievement to add
- * @return NULL on failure, achievement data on success
+ * @return nullptr on failure, achievement data on success
  */
 struct achievement *achievement_add(map_session_data *sd, int achievement_id)
 {
 	int i, index;
 
-	nullpo_retr(NULL, sd);
+	nullpo_retr(nullptr, sd);
 
 	std::shared_ptr<s_achievement_db> adb = achievement_db.find( achievement_id );
 
@@ -455,7 +455,7 @@ struct achievement *achievement_add(map_session_data *sd, int achievement_id)
 	ARR_FIND(0, sd->achievement_data.count, i, sd->achievement_data.achievements[i].achievement_id == achievement_id);
 	if (i < sd->achievement_data.count) {
 		ShowError("achievement_add: Character %d already has achievement %d.\n", sd->status.char_id, achievement_id);
-		return NULL;
+		return nullptr;
 	}
 
 	index = sd->achievement_data.incompleteCount;
@@ -512,7 +512,7 @@ bool achievement_remove(map_session_data *sd, int achievement_id)
 	sd->achievement_data.count--;
 	if( sd->achievement_data.count == 0 ){
 		aFree(sd->achievement_data.achievements);
-		sd->achievement_data.achievements = NULL;
+		sd->achievement_data.achievements = nullptr;
 	}else{
 		RECREATE(sd->achievement_data.achievements, struct achievement, sd->achievement_data.count);
 	}
@@ -577,7 +577,7 @@ static int achievement_check_groups(map_session_data *sd, struct s_achievement_d
 {
 	int i;
 
-	if (ad == NULL || sd == NULL)
+	if (ad == nullptr || sd == nullptr)
 		return 0;
 
 	if (ad->group != AG_BATTLE && ad->group != AG_TAMING && ad->group != AG_ADVENTURE)
@@ -630,7 +630,7 @@ bool achievement_update_achievement(map_session_data *sd, int achievement_id, bo
 				sd->achievement_data.achievements[i].count[it.first] = it.second->count;
 		}
 
-		sd->achievement_data.achievements[i].completed = time(NULL);
+		sd->achievement_data.achievements[i].completed = time(nullptr);
 
 		if (i < (--sd->achievement_data.incompleteCount)) { // The achievement needs to be moved to the completed achievements block at the end of the array
 			struct achievement tmp_ach;
@@ -763,7 +763,7 @@ void achievement_free(map_session_data *sd)
 
 	if (sd->achievement_data.count) {
 		aFree(sd->achievement_data.achievements);
-		sd->achievement_data.achievements = NULL;
+		sd->achievement_data.achievements = nullptr;
 		sd->achievement_data.count = sd->achievement_data.incompleteCount = 0;
 	}
 }
@@ -938,7 +938,7 @@ static bool achievement_update_objectives(map_session_data *sd, std::shared_ptr<
 	if (group != ad->group)
 		return false;
 
-	struct achievement *entry = NULL;
+	struct achievement *entry = nullptr;
 	bool isNew = false, changed = false, complete = false;
 	std::array<int, MAX_ACHIEVEMENT_OBJECTIVES> current_count = {}; // Player's current objective values
 	int i;

+ 113 - 113
src/map/atcommand.cpp

@@ -88,7 +88,7 @@ struct s_atcommand_alias_info{
 char atcommand_symbol = '@'; // first char of the commands
 char charcommand_symbol = '#';
 
-static DBMap* atcommand_db = NULL; //name -> AtCommandInfo
+static DBMap* atcommand_db = nullptr; //name -> AtCommandInfo
 
 static AtCommandInfo* get_atcommandinfo_byname( const char* name );
 
@@ -206,14 +206,14 @@ struct atcmd_binding_data* get_atcommandbind_byname(const char* name) {
 
 	ARR_FIND( 0, atcmd_binding_count, i, strcmpi(atcmd_binding[i]->command, name) == 0 );
 
-	return ( i < atcmd_binding_count ) ? atcmd_binding[i] : NULL;
+	return ( i < atcmd_binding_count ) ? atcmd_binding[i] : nullptr;
 }
 
 /**
  * retrieves the help string associated with a given command.
  *
  * @param name the name of the command to retrieve help information for
- * @return the string associated with the command, or NULL
+ * @return the string associated with the command, or nullptr
  */
 static const char* atcommand_help_string( const char* command ){
 	// remove the prefix symbol for the raw name of the command
@@ -611,7 +611,7 @@ ACMD_FUNC(mapmove)
 	if ((x || y) && map_getcell(m, x, y, CELL_CHKNOPASS))
 	{	//This is to prevent the pc_setpos call from printing an error.
 		clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
-		if (!map_search_freecell(NULL, m, &x, &y, 10, 10, 1))
+		if (!map_search_freecell(nullptr, m, &x, &y, 10, 10, 1))
 			x = y = 0; //Invalid cell, use random spot.
 	}
 	if ((map_getmapflag(m, MF_NOWARPTO) && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) || !pc_job_can_entermap((enum e_job)sd->status.class_, m, pc_get_group_level(sd))) {
@@ -647,7 +647,7 @@ ACMD_FUNC(where)
 	}
 
 	pl_sd = map_nick2sd(atcmd_player_name,true);
-	if (pl_sd == NULL ||
+	if (pl_sd == nullptr ||
 	    strncmp(pl_sd->status.name, atcmd_player_name, NAME_LENGTH) != 0 ||
 	    (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > pc_get_group_level(sd) && !pc_has_permission(sd, PC_PERM_WHO_DISPLAY_AID))
 	) {
@@ -677,7 +677,7 @@ ACMD_FUNC(jumpto)
 		return -1;
 	}
 
-	if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
+	if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
 	{
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
@@ -735,7 +735,7 @@ ACMD_FUNC(jump)
 	if ((x || y) && map_getcell(sd->bl.m, x, y, CELL_CHKNOPASS))
 	{	//This is to prevent the pc_setpos call from printing an error.
 		clif_displaymessage(fd, msg_txt(sd,2)); // Invalid coordinates, using random target cell.
-		if (!map_search_freecell(NULL, sd->bl.m, &x, &y, 10, 10, 1))
+		if (!map_search_freecell(nullptr, sd->bl.m, &x, &y, 10, 10, 1))
 			x = y = 0; //Invalid cell, use random spot.
 	}
 
@@ -751,7 +751,7 @@ ACMD_FUNC(jump)
  *------------------------------------------*/
 ACMD_FUNC(who) {
 	map_session_data* pl_sd = nullptr;;
-	struct s_mapiterator *iter = NULL;	
+	struct s_mapiterator *iter = nullptr;	
 	char player_name[NAME_LENGTH] = "";
 	int count = 0;
 	int level = 0;
@@ -766,7 +766,7 @@ ACMD_FUNC(who) {
 
 	nullpo_retr(-1, sd);
 
-	if (strstr(command, "map") != NULL) {
+	if (strstr(command, "map") != nullptr) {
 		char map_name[MAP_NAME_LENGTH_EXT] = "";
 		if (sscanf(message, "%15s %23s", map_name, player_name) < 1 || (map_id = map_mapname2mapid(map_name)) < 0)
 			map_id = sd->bl.m;
@@ -774,9 +774,9 @@ ACMD_FUNC(who) {
 		sscanf(message, "%23s", player_name);
 	}
 
-	if (strstr(command, "2") != NULL)
+	if (strstr(command, "2") != nullptr)
 		display_type = 2;
-	else if (strstr(command, "3") != NULL)
+	else if (strstr(command, "3") != nullptr)
 		display_type = 3;
 
 	level = pc_get_group_level(sd);
@@ -785,7 +785,7 @@ ACMD_FUNC(who) {
 	iter = mapit_getallusers();
 	for (pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter))	{
 		if (!((pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) || pc_isinvisible(pl_sd)) && pc_get_group_level(pl_sd) > level)) { // you can look only lower or same level
-			if (stristr(pl_sd->status.name, player_name) == NULL // search with no case sensitive
+			if (stristr(pl_sd->status.name, player_name) == nullptr // search with no case sensitive
 				|| (map_id >= 0 && pl_sd->bl.m != map_id))
 				continue;
 			switch (display_type) {
@@ -813,9 +813,9 @@ ACMD_FUNC(who) {
 					StringBuf_Printf(&buf, msg_txt(sd,343), pl_sd->status.name); // "Name: %s "
 					if (pc_get_group_id(pl_sd) > 0) // Player title, if exists
 						StringBuf_Printf(&buf, msg_txt(sd,344), pl_sd->group->name.c_str()); // "(%s) "
-					if (p != NULL)
+					if (p != nullptr)
 						StringBuf_Printf(&buf, msg_txt(sd,345), p->party.name); // " | Party: '%s'"
-					if (g != NULL)
+					if (g != nullptr)
 						StringBuf_Printf(&buf, msg_txt(sd,346), g->guild.name); // " | Guild: '%s'"
 					break;
 				}
@@ -889,7 +889,7 @@ ACMD_FUNC(whogm)
 			for (j = 0; player_name[j]; j++)
 				player_name[j] = TOLOWER(player_name[j]);
 			// search with no case sensitive
-			if (strstr(player_name, match_text) == NULL)
+			if (strstr(player_name, match_text) == nullptr)
 				continue;
 		}
 		if (pl_level > level) {
@@ -1262,7 +1262,7 @@ ACMD_FUNC(kami)
 		}
 
 		sscanf(message, "%255[^\n]", atcmd_output);
-		if (strstr(command, "l") != NULL)
+		if (strstr(command, "l") != nullptr)
 			clif_broadcast(&sd->bl, atcmd_output, strlen(atcmd_output) + 1, BC_DEFAULT, ALL_SAMEMAP);
 		else
 			intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, (*(command + 5) == 'b' || *(command + 5) == 'B') ? BC_BLUE : BC_DEFAULT);
@@ -1312,7 +1312,7 @@ ACMD_FUNC(heal)
 	}
 
 	if ( hp < 0 && sp <= 0 ) {
-		status_damage(NULL, &sd->bl, -hp, -sp, 0, 0, 0);
+		status_damage(nullptr, &sd->bl, -hp, -sp, 0, 0, 0);
 		clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
 		clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
 		return 0;
@@ -1323,7 +1323,7 @@ ACMD_FUNC(heal)
 		if (hp > 0)
 			status_heal(&sd->bl, hp, 0, 0);
 		else {
-			status_damage(NULL, &sd->bl, -hp, 0, 0, 0, 0);
+			status_damage(nullptr, &sd->bl, -hp, 0, 0, 0, 0);
 			clif_damage(&sd->bl,&sd->bl, gettick(), 0, 0, -hp, 0, DMG_ENDURE, 0, false);
 		}
 	}
@@ -1332,7 +1332,7 @@ ACMD_FUNC(heal)
 		if (sp > 0)
 			status_heal(&sd->bl, 0, sp, 0);
 		else
-			status_damage(NULL, &sd->bl, 0, -sp, 0, 0, 0);
+			status_damage(nullptr, &sd->bl, 0, -sp, 0, 0, 0);
 	}
 
 	clif_displaymessage(fd, msg_txt(sd,156)); // HP or/and SP modified.
@@ -1365,7 +1365,7 @@ ACMD_FUNC(healap)
 			clif_displaymessage(fd, msg_txt(sd, 821));// AP recovered.
 		return 0;
 	}else{
-		status_damage(NULL, &sd->bl, 0, 0, -ap, 0, 0, 0);
+		status_damage(nullptr, &sd->bl, 0, 0, -ap, 0, 0, 0);
 		clif_displaymessage(fd, msg_txt(sd, 822));// AP modified.
 		return 0;
 	}
@@ -1424,7 +1424,7 @@ ACMD_FUNC(item)
 		}
 
 		items.push_back( item );
-		itemlist = strtok(NULL, ":"); //next itemline
+		itemlist = strtok(nullptr, ":"); //next itemline
 	}
 
 	if (number <= 0)
@@ -3271,7 +3271,7 @@ ACMD_FUNC(recall) {
 		return -1;
 	}
 
-	if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
+	if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
 	{
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
@@ -3607,7 +3607,7 @@ ACMD_FUNC(kick)
 		return -1;
 	}
 
-	if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL)
+	if((pl_sd=map_nick2sd(atcmd_player_name,false)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr)
 	{
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
@@ -3638,7 +3638,7 @@ ACMD_FUNC(kickall)
 	{
 		if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kick only lower or same gm level
 			if (sd->status.account_id != pl_sd->status.account_id)
-				clif_GM_kick(NULL, pl_sd);
+				clif_GM_kick(nullptr, pl_sd);
 		}
 	}
 	mapit_free(iter);
@@ -4156,8 +4156,8 @@ ACMD_FUNC(partyrecall)
 		return -1;
 	}
 
-	if ((p = party_searchname(party_name)) == NULL && // name first to avoid error when name begin with a number
-	    (p = party_search(atoi(message))) == NULL)
+	if ((p = party_searchname(party_name)) == nullptr && // name first to avoid error when name begin with a number
+	    (p = party_search(atoi(message))) == nullptr)
 	{
 		clif_displaymessage(fd, msg_txt(sd,96)); // Incorrect name or ID, or no one from the party is online.
 		return -1;
@@ -4369,7 +4369,7 @@ ACMD_FUNC(partysharelvl) {
 ACMD_FUNC(mapinfo) {
 	map_session_data* pl_sd;
 	struct s_mapiterator* iter;
-	struct chat_data *cd = NULL;
+	struct chat_data *cd = nullptr;
 	char direction[12];
 	int i, m_id, chat_num = 0, list = 0, vend_num = 0;
 	unsigned short m_index;
@@ -4410,7 +4410,7 @@ ACMD_FUNC(mapinfo) {
 		if( pl_sd->mapindex == m_index ) {
 			if( pl_sd->state.vending )
 				vend_num++;
-			else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL && cd->usersd[0] == pl_sd )
+			else if( (cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != nullptr && cd->usersd[0] == pl_sd )
 				chat_num++;
 		}
 	}
@@ -4673,7 +4673,7 @@ ACMD_FUNC(mapinfo) {
 		iter = mapit_getallusers();
 		for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) )
 		{
-			if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != NULL &&
+			if ((cd = (struct chat_data*)map_id2bl(pl_sd->chatID)) != nullptr &&
 			    pl_sd->mapindex == m_index &&
 			    cd->usersd[0] == pl_sd)
 			{
@@ -4843,8 +4843,8 @@ ACMD_FUNC(partyspy)
 		return -1;
 	}
 
-	if ((p = party_searchname(party_name)) != NULL || // name first to avoid error when name begin with a number
-	    (p = party_search(atoi(message))) != NULL) {
+	if ((p = party_searchname(party_name)) != nullptr || // name first to avoid error when name begin with a number
+	    (p = party_search(atoi(message))) != nullptr) {
 		if (sd->partyspy == p->party.party_id) {
 			sd->partyspy = 0;
 			sprintf(atcmd_output, msg_txt(sd,105), p->party.name); // No longer spying on the %s party.
@@ -4880,8 +4880,8 @@ ACMD_FUNC(clanspy){
 		return -1;
 	}
 
-	if ((c = clan_searchname(clan_name)) != NULL || // name first to avoid error when name begin with a number
-		(c = clan_search(atoi(message))) != NULL) {
+	if ((c = clan_searchname(clan_name)) != nullptr || // name first to avoid error when name begin with a number
+		(c = clan_search(atoi(message))) != nullptr) {
 		if (sd->clanspy == c->id) {
 			sd->clanspy = 0;
 			sprintf(atcmd_output, msg_txt(sd, 1500), c->name); // No longer spying on the %s clan.
@@ -4945,7 +4945,7 @@ ACMD_FUNC(nuke)
 		return -1;
 	}
 
-	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != NULL) {
+	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) != nullptr) {
 		if (pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { // you can kill only lower or same GM level
 			skill_castend_nodamage_id(&pl_sd->bl, &pl_sd->bl, NPC_SELFDESTRUCTION, 99, gettick(), 0);
 			clif_displaymessage(fd, msg_txt(sd,109)); // Player has been nuked!
@@ -4978,7 +4978,7 @@ ACMD_FUNC(tonpc)
 		return -1;
 	}
 
-	if ((nd = npc_name2id(npcname)) != NULL) {
+	if ((nd = npc_name2id(npcname)) != nullptr) {
 		if (pc_setpos(sd, map_id2index(nd->bl.m), nd->bl.x, nd->bl.y, CLR_TELEPORT) == SETPOS_OK)
 			clif_displaymessage(fd, msg_txt(sd,0)); // Warped.
 		else
@@ -5080,7 +5080,7 @@ ACMD_FUNC(unloadnpc)
 		return -1;
 	}
 
-	if ((nd = npc_name2id(NPCname)) == NULL) {
+	if ((nd = npc_name2id(NPCname)) == nullptr) {
 		clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
 		return -1;
 	}
@@ -5138,21 +5138,21 @@ char* txt_time(t_tick duration_)
 	seconds = duration - (60 * minutes);
 
 	if (days == 1)
-		sprintf(temp, msg_txt(NULL,219), days); // %d day
+		sprintf(temp, msg_txt(nullptr,219), days); // %d day
 	else if (days > 1)
-		sprintf(temp, msg_txt(NULL,220), days); // %d days
+		sprintf(temp, msg_txt(nullptr,220), days); // %d days
 	if (hours == 1)
-		sprintf(temp1, msg_txt(NULL,221), temp, hours); // %s %d hour
+		sprintf(temp1, msg_txt(nullptr,221), temp, hours); // %s %d hour
 	else if (hours > 1)
-		sprintf(temp1, msg_txt(NULL,222), temp, hours); // %s %d hours
+		sprintf(temp1, msg_txt(nullptr,222), temp, hours); // %s %d hours
 	if (minutes < 2)
-		sprintf(temp, msg_txt(NULL,223), temp1, minutes); // %s %d minute
+		sprintf(temp, msg_txt(nullptr,223), temp1, minutes); // %s %d minute
 	else
-		sprintf(temp, msg_txt(NULL,224), temp1, minutes); // %s %d minutes
+		sprintf(temp, msg_txt(nullptr,224), temp1, minutes); // %s %d minutes
 	if (seconds == 1)
-		sprintf(temp1, msg_txt(NULL,225), temp, seconds); // %s and %d second
+		sprintf(temp1, msg_txt(nullptr,225), temp, seconds); // %s and %d second
 	else if (seconds > 1)
-		sprintf(temp1, msg_txt(NULL,226), temp, seconds); // %s and %d seconds
+		sprintf(temp1, msg_txt(nullptr,226), temp, seconds); // %s and %d seconds
 
 	return temp1;
 }
@@ -5253,7 +5253,7 @@ ACMD_FUNC(jail)
 		return -1;
 	}
 
-	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
+	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
 	}
@@ -5289,7 +5289,7 @@ ACMD_FUNC(unjail)
 		return -1;
 	}
 
-	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
+	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
 	}
@@ -5337,7 +5337,7 @@ ACMD_FUNC(jailfor) {
 		return -1;
 	}
 
-	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
+	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
 	}
@@ -5357,7 +5357,7 @@ ACMD_FUNC(jailfor) {
 		} else {
 			int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
 			char timestr[21];
-			time_t now=time(NULL);
+			time_t now=time(nullptr);
 			split_time(jailtime*60,&year,&month,&day,&hour,&minute,&second);
 			sprintf(atcmd_output,msg_txt(sd,402),msg_txt(sd,1137),year,month,day,hour,minute); // %s in jail for %d years, %d months, %d days, %d hours and %d minutes
 			clif_displaymessage(pl_sd->fd, atcmd_output);
@@ -5382,7 +5382,7 @@ ACMD_FUNC(jailfor) {
 ACMD_FUNC(jailtime){
 	int year, month, day, hour, minute, second;
 	char timestr[21];
-	time_t now = time(NULL);
+	time_t now = time(nullptr);
 
 	nullpo_retr(-1, sd);
 
@@ -5433,7 +5433,7 @@ ACMD_FUNC(disguise)
 		if ((id = mobdb_searchname(message)) == 0)
 		{
 			struct npc_data* nd = npc_name2id(message);
-			if (nd != NULL)
+			if (nd != nullptr)
 				id = nd->class_;
 		}
 	}
@@ -5515,7 +5515,7 @@ ACMD_FUNC(disguiseguild)
 	} else {
 		if( (id = mobdb_searchname(monster)) == 0 ) {
 			struct npc_data* nd = npc_name2id(monster);
-			if( nd != NULL )
+			if( nd != nullptr )
 				id = nd->class_;
 		}
 	}
@@ -5815,7 +5815,7 @@ ACMD_FUNC(npcmove)
 		return -1;
 	}
 
-	if ((nd = npc_name2id(npc_name)) == NULL)
+	if ((nd = npc_name2id(npc_name)) == nullptr)
 	{
 		clif_displaymessage(fd, msg_txt(sd,111)); // This NPC doesn't exist.
 		return -1;
@@ -5859,7 +5859,7 @@ ACMD_FUNC(addwarp)
 	}
 
 	nd = npc_add_warp(warpname, sd->bl.m, sd->bl.x, sd->bl.y, 2, 2, m, x, y);
-	if( nd == NULL )
+	if( nd == nullptr )
 		return -1;
 
 	sprintf(atcmd_output, msg_txt(sd,1158), nd->exname); // New warp NPC '%s' created.
@@ -5887,7 +5887,7 @@ ACMD_FUNC(follow)
 		return 0;
 	}
 
-	if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
+	if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
 	{
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
@@ -6101,7 +6101,7 @@ ACMD_FUNC(cleargstorage)
 	}
 
 	gstorage = guild2storage2(sd->status.guild_id);
-	if (gstorage == NULL) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
+	if (gstorage == nullptr) { // Doesn't have opened @gstorage yet, so we skip the deletion since *shouldn't* have any item there.
 		return -1;
 	}
 
@@ -6217,7 +6217,7 @@ ACMD_FUNC(useskill)
 
 	if(!strcmp(atcmd_player_name,"self"))
 		pl_sd = sd; //quick keyword
-	else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL ){
+	else if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr ){
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
 	}
@@ -6342,7 +6342,7 @@ ACMD_FUNC(skilltree)
 		return -1;
 	}
 
-	if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
+	if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
 	{
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
@@ -6415,7 +6415,7 @@ ACMD_FUNC(marry)
 		return -1;
 	}
 
-	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
+	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
 	}
@@ -6513,7 +6513,7 @@ ACMD_FUNC(autotrade) {
 
 	if( battle_config.at_timeout ) {
 		int timeout = atoi(message);
-		status_change_start(NULL,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, SCSTART_NONE);
+		status_change_start(nullptr,&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, SCSTART_NONE);
 	}
 
 	if (battle_config.at_logout_event)
@@ -6538,7 +6538,7 @@ ACMD_FUNC(changegm)
 
 	memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
 
-	if (sd->status.guild_id == 0 || sd->guild == NULL || strcmp(sd->guild->guild.master,sd->status.name)) {
+	if (sd->status.guild_id == 0 || sd->guild == nullptr || strcmp(sd->guild->guild.master,sd->status.name)) {
 		clif_displaymessage(fd, msg_txt(sd,1181)); // You need to be a Guild Master to use this command.
 		return -1;
 	}
@@ -6553,7 +6553,7 @@ ACMD_FUNC(changegm)
 		return -1;
 	}
 
-	if((pl_sd=map_nick2sd(atcmd_player_name,false)) == NULL || pl_sd->status.guild_id != sd->status.guild_id) {
+	if((pl_sd=map_nick2sd(atcmd_player_name,false)) == nullptr || pl_sd->status.guild_id != sd->status.guild_id) {
 		clif_displaymessage(fd, msg_txt(sd,1184)); // Target character must be online and be a guild member.
 		return -1;
 	}
@@ -6567,7 +6567,7 @@ ACMD_FUNC(changegm)
 		return -1;
 	}
 
-	if( battle_config.guild_leaderchange_delay && DIFF_TICK(time(NULL),sd->guild->guild.last_leader_change) < battle_config.guild_leaderchange_delay ){
+	if( battle_config.guild_leaderchange_delay && DIFF_TICK(time(nullptr),sd->guild->guild.last_leader_change) < battle_config.guild_leaderchange_delay ){
 #if PACKETVER >= 20151001
 		clif_msg(sd, GUILD_MASTER_DELAY);
 #else
@@ -6595,7 +6595,7 @@ ACMD_FUNC(changeleader)
 		return -1;
 	}
 
-	party_changeleader(sd, map_nick2sd(atcmd_player_name,false),NULL);
+	party_changeleader(sd, map_nick2sd(atcmd_player_name,false),nullptr);
 	return 0;
 }
 
@@ -6610,7 +6610,7 @@ ACMD_FUNC(partyoption)
 	char w1[16], w2[16];
 	nullpo_retr(-1, sd);
 
-	if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == NULL)
+	if (sd->status.party_id == 0 || (p = party_search(sd->status.party_id)) == nullptr)
 	{
 		clif_displaymessage(fd, msg_txt(sd,282)); // You need to be a party leader to use this command.
 		return -1;
@@ -7073,7 +7073,7 @@ ACMD_FUNC(sound)
 		return -1;
 	}
 
-	if(strstr(sound_file, ".wav") == NULL)
+	if(strstr(sound_file, ".wav") == nullptr)
 		strcat(sound_file, ".wav");
 
 	clif_soundeffect( sd->bl, sound_file, 0, AREA );
@@ -7118,7 +7118,7 @@ ACMD_FUNC(mobsearch)
 	for(;;)
 	{
 		TBL_MOB* md = (TBL_MOB*)mapit_next(it);
-		if( md == NULL )
+		if( md == nullptr )
 			break;// no more mobs
 
 		if( md->bl.m != sd->bl.m )
@@ -7261,11 +7261,11 @@ ACMD_FUNC(pettalk)
 		if( i == ET_DICE1 ) i = rnd_value<int>(ET_DICE1, ET_DICE6); // randomize /dice
 		if( i < ARRAYLENGTH(emo) )
 		{
-			if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
-					sd->emotionlasttime = time(NULL);
+			if (sd->emotionlasttime + 1 >= time(nullptr)) { // not more than 1 per second
+					sd->emotionlasttime = time(nullptr);
 					return 0;
 			}
-			sd->emotionlasttime = time(NULL);
+			sd->emotionlasttime = time(nullptr);
 
 			clif_emotion(&pd->bl, i);
 			return 0;
@@ -7296,7 +7296,7 @@ ACMD_FUNC(users)
 	for(;;)
 	{
 		map_session_data* sd2 = (map_session_data*)mapit_next(iter);
-		if( sd2 == NULL )
+		if( sd2 == nullptr )
 			break;// no more users
 
 		if( sd2->mapindex >= MAX_MAPINDEX )
@@ -7378,7 +7378,7 @@ ACMD_FUNC(summon)
 	md->deletetimer=add_timer(tick+(duration*60000),mob_timer_delete,md->bl.id,0);
 	clif_specialeffect(&md->bl,EF_ENTRY2,AREA);
 	mob_spawn(md);
-	sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
+	sc_start4(nullptr,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 60000);
 	clif_skill_poseffect(&sd->bl,AM_CALLHOMUN,1,md->bl.x,md->bl.y,tick);
 	clif_displaymessage(fd, msg_txt(sd,39));	// All monster summoned!
 
@@ -7428,7 +7428,7 @@ ACMD_FUNC(trade)
 		return -1;
 	}
 
-	if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == NULL )
+	if ( (pl_sd = map_nick2sd(atcmd_player_name,true)) == nullptr )
 	{
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
@@ -7482,7 +7482,7 @@ ACMD_FUNC(unmute)
 		return -1;
 	}
 
-	if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
+	if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr )
 	{
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
@@ -7581,7 +7581,7 @@ ACMD_FUNC(mute)
 		return -1;
 	}
 
-	if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL )
+	if ( (pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr )
 	{
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
@@ -7598,7 +7598,7 @@ ACMD_FUNC(mute)
 
 	if( pl_sd->status.manner < manner ) {
 		pl_sd->status.manner -= manner;
-		sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
+		sc_start(nullptr,&pl_sd->bl,SC_NOCHAT,100,0,0);
 	} else {
 		pl_sd->status.manner = 0;
 		status_change_end(&pl_sd->bl, SC_NOCHAT);
@@ -7674,7 +7674,7 @@ ACMD_FUNC(gmotd)
 {
 	FILE* fp;
 
-	if( ( fp = fopen(motd_txt, "r") ) != NULL )
+	if( ( fp = fopen(motd_txt, "r") ) != nullptr )
 	{
 		char buf[CHAT_SIZE_MAX];
 		size_t len;
@@ -7930,7 +7930,7 @@ ACMD_FUNC(showmobs)
 	for(;;)
 	{
 		TBL_MOB* md = (TBL_MOB*)mapit_next(it);
-		if( md == NULL )
+		if( md == nullptr )
 			break;// no more mobs
 
 		if( md->bl.m != sd->bl.m )
@@ -8309,7 +8309,7 @@ ACMD_FUNC(iteminfo)
 		sprintf(atcmd_output, msg_txt(sd,1277), // Item: '%s'/'%s' (%u) Type: %s | Extra Effect: %s
 			item_data->name.c_str(), item_db.create_item_link( item_data ).c_str(),item_data->nameid,
 			(item_data->type != IT_AMMO) ? itemdb_typename((enum item_types)item_data->type) : itemdb_typename_ammo((e_ammo_type)item_data->subtype),
-			(item_data->script==NULL)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
+			(item_data->script==nullptr)? msg_txt(sd,1278) : msg_txt(sd,1279) // None / With script
 		);
 		clif_displaymessage(fd, atcmd_output);
 
@@ -8468,7 +8468,7 @@ static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
 
 	int time, id;
 	map_session_data *pl_sd = (map_session_data *)bl;
-	if (pl_sd == NULL)
+	if (pl_sd == nullptr)
 		return 0;
 
 	id = va_arg(ap, int);
@@ -8477,7 +8477,7 @@ static int atcommand_mutearea_sub(struct block_list *bl,va_list ap)
 	if (id != bl->id && !pc_get_group_level(pl_sd)) {
 		pl_sd->status.manner -= time;
 		if (pl_sd->status.manner < 0)
-			sc_start(NULL,&pl_sd->bl,SC_NOCHAT,100,0,0);
+			sc_start(nullptr,&pl_sd->bl,SC_NOCHAT,100,0,0);
 		else
 			status_change_end(&pl_sd->bl, SC_NOCHAT);
 	}
@@ -8865,7 +8865,7 @@ ACMD_FUNC(showdelay)
 ACMD_FUNC(invite)
 {
 	unsigned int did = sd->duel_group;
-	map_session_data *target_sd = NULL;
+	map_session_data *target_sd = nullptr;
 
 	memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
 	memset(atcmd_output, '\0', sizeof(atcmd_output));
@@ -8886,7 +8886,7 @@ ACMD_FUNC(invite)
 		return 0;
 	}
 
-	if((target_sd = map_nick2sd(atcmd_player_name, true)) == NULL) {
+	if((target_sd = map_nick2sd(atcmd_player_name, true)) == nullptr) {
 		clif_displaymessage(fd, msg_txt(sd,352)); // "Duel: Player not found."
 		return 0;
 	}
@@ -8937,7 +8937,7 @@ ACMD_FUNC(duel)
 			}
 			duel_create(sd, maxpl);
 		} else {
-			map_session_data *target_sd = NULL;
+			map_session_data *target_sd = nullptr;
 
 			memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
 			memset(atcmd_output, '\0', sizeof(atcmd_output));
@@ -8950,7 +8950,7 @@ ACMD_FUNC(duel)
 
 			target_sd = map_nick2sd(atcmd_player_name,true);
 
-			if(target_sd != NULL) {
+			if(target_sd != nullptr) {
 				unsigned int newduel;
 				if((newduel = duel_create(sd, 2)) != -1) {
 					if(target_sd->duel_group > 0 ||	target_sd->duel_invite > 0) {
@@ -9094,7 +9094,7 @@ ACMD_FUNC(cash)
 ACMD_FUNC(clone)
 {
 	int x=0,y=0,flag=0,master=0,i=0;
-	map_session_data *pl_sd=NULL;
+	map_session_data *pl_sd=nullptr;
 
 	memset(atcmd_player_name, '\0', sizeof(atcmd_player_name));
 
@@ -9103,7 +9103,7 @@ ACMD_FUNC(clone)
 		return 0;
 	}
 
-	if((pl_sd=map_nick2sd(atcmd_player_name,true)) == NULL && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == NULL) {
+	if((pl_sd=map_nick2sd(atcmd_player_name,true)) == nullptr && (pl_sd=map_charid2sd(atoi(atcmd_player_name))) == nullptr) {
 		clif_displaymessage(fd, msg_txt(sd,3));	// Character not found.
 		return 0;
 	}
@@ -9497,7 +9497,7 @@ ACMD_FUNC(stats)
 		int value;
 	} output_table[] = {
 		{ "Base Level - %d", 0 },
-		{ NULL, 0 },
+		{ nullptr, 0 },
 		{ "Hp - %d", 0 },
 		{ "MaxHp - %d", 0 },
 		{ "Sp - %d", 0 },
@@ -9523,7 +9523,7 @@ ACMD_FUNC(stats)
 		{ "JobChangeLvl (2nd) - %d", 0 },
 		{ "JobChangeLvl (3rd) - %d", 0 },
 		{ "JobChangeLvl (4th) - %d", 0 },
-		{ NULL, 0 }
+		{ nullptr, 0 }
 	};
 
 	memset(job_jobname, '\0', sizeof(job_jobname));
@@ -9564,7 +9564,7 @@ ACMD_FUNC(stats)
 
 	clif_displaymessage(fd, output);
 
-	for (i = 0; output_table[i].format != NULL; i++) {
+	for (i = 0; output_table[i].format != nullptr; i++) {
 		sprintf(output, output_table[i].format, output_table[i].value);
 		clif_displaymessage(fd, output);
 	}
@@ -9773,7 +9773,7 @@ ACMD_FUNC(mount2) {
 	clif_displaymessage(sd->fd,msg_txt(sd,1362)); // NOTICE: If you crash with mount your LUA is outdated.
 	if (!sd->sc.getSCE(SC_ALL_RIDING)) {
 		clif_displaymessage(sd->fd,msg_txt(sd,1363)); // You have mounted.
-		sc_start(NULL, &sd->bl, SC_ALL_RIDING, 10000, 1, INFINITE_TICK);
+		sc_start(nullptr, &sd->bl, SC_ALL_RIDING, 10000, 1, INFINITE_TICK);
 	} else {
 		clif_displaymessage(sd->fd,msg_txt(sd,1364)); // You have released your mount.
 		status_change_end(&sd->bl, SC_ALL_RIDING);
@@ -9855,9 +9855,9 @@ ACMD_FUNC(set) {
 	// Only set the variable if there is a value for it
 	if( toset >= 2 ){
 		if( is_str ){
-			setd_sub_str( NULL, sd, name, index, val, NULL );
+			setd_sub_str( nullptr, sd, name, index, val, nullptr );
 		}else{
-			setd_sub_num( NULL, sd, name, index, strtoll( val, NULL, 10 ), NULL );
+			setd_sub_num( nullptr, sd, name, index, strtoll( val, nullptr, 10 ), nullptr );
 		}
 	}
 
@@ -9884,7 +9884,7 @@ ACMD_FUNC(set) {
 				break;
 		}
 
-		if( value == NULL || *value == '\0' ){// empty string
+		if( value == nullptr || *value == '\0' ){// empty string
 			sprintf(atcmd_output,msg_txt(sd,1375),reg); // %s is empty
 		}else{
 			sprintf(atcmd_output,msg_txt(sd,1374),reg,value); // %s value is now: %s
@@ -10172,11 +10172,11 @@ ACMD_FUNC(channel) {
 	} else if ( strcmpi(key,"kick") == 0 ) {
 		return channel_pckick(sd,sub1,sub2);
 	} else if ( strcmpi(key,"banlist") == 0 ) {
-		return channel_pcban(sd,sub1,NULL,3);
+		return channel_pcban(sd,sub1,nullptr,3);
 	} else if ( strcmpi(key,"unban") == 0 ) {
 		return channel_pcban(sd,sub1,sub2,1);
 	} else if ( strcmpi(key,"unbanall") == 0 ) {
-		return channel_pcban(sd,sub1,NULL,2);
+		return channel_pcban(sd,sub1,nullptr,2);
 	} else {
 		char sub3[CHAN_NAME_LENGTH], sub4[CHAN_NAME_LENGTH];
 		sub3[0] = sub4[0] = '\0';
@@ -10261,7 +10261,7 @@ ACMD_FUNC(vip) {
 	map_session_data* pl_sd = nullptr;;
 	char * modif_p;
 	int32 vipdifftime = 0;
-	time_t now=time(NULL);
+	time_t now=time(nullptr);
 	
 	nullpo_retr(-1, sd);
 
@@ -10282,7 +10282,7 @@ ACMD_FUNC(vip) {
 		return -1;
 	}
 
-	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
+	if ((pl_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
 	}
@@ -10347,7 +10347,7 @@ ACMD_FUNC(fullstrip) {
 		return -1;
 	}
 
-	if((tsd=map_nick2sd(atcmd_player_name,false)) == NULL && (tsd=map_id2sd(atoi(atcmd_player_name))) == NULL){
+	if((tsd=map_nick2sd(atcmd_player_name,false)) == nullptr && (tsd=map_id2sd(atoi(atcmd_player_name))) == nullptr){
 		clif_displaymessage(fd, msg_txt(sd,3)); // Character not found.
 		return -1;
 	}
@@ -10640,7 +10640,7 @@ ACMD_FUNC(adopt)
 		return -1;
 	}
 
-	if ((b_sd = map_nick2sd(atcmd_player_name,false)) == NULL) {
+	if ((b_sd = map_nick2sd(atcmd_player_name,false)) == nullptr) {
 		clif_displaymessage(fd, msg_txt(sd, 3)); // Character not found.
 		return -1;
 	}
@@ -10961,11 +10961,11 @@ ACMD_FUNC(setcard)
 /**
  * Fills the reference of available commands in atcommand DBMap
  **/
-#define ACMD_DEF(x) { #x, atcommand_ ## x, NULL, NULL, 0 }
-#define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, NULL, NULL, 0 }
+#define ACMD_DEF(x) { #x, atcommand_ ## x, nullptr, nullptr, 0 }
+#define ACMD_DEF2(x2, x) { x2, atcommand_ ## x, nullptr, nullptr, 0 }
 // Define with restriction
-#define ACMD_DEFR(x, r) { #x, atcommand_ ## x, NULL, NULL, r }
-#define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, NULL, NULL, r }
+#define ACMD_DEFR(x, r) { #x, atcommand_ ## x, nullptr, nullptr, r }
+#define ACMD_DEF2R(x2, x, r) { x2, atcommand_ ## x, nullptr, nullptr, r }
 void atcommand_basecommands(void) {
 	/**
 	 * Command reference list, place the base of your commands here
@@ -11314,13 +11314,13 @@ static AtCommandInfo* get_atcommandinfo_byname(const char *name)
 {
 	if (strdb_exists(atcommand_db, name))
 		return (AtCommandInfo*)strdb_get(atcommand_db, name);
-	return NULL;
+	return nullptr;
 }
 
 /// AtCommand suggestion
 static void atcommand_get_suggestions(map_session_data* sd, const char *name, bool atcommand) {
 	DBIterator* atcommand_iter;
-	AtCommandInfo* command_info = NULL;
+	AtCommandInfo* command_info = nullptr;
 	AtCommandType type = atcommand ? COMMAND_ATCOMMAND : COMMAND_CHARCOMMAND;
 	char* full_match[MAX_SUGGESTIONS];
 	char* suggestions[MAX_SUGGESTIONS];
@@ -11341,7 +11341,7 @@ static void atcommand_get_suggestions(map_session_data* sd, const char *name, bo
 			suggestions[prefix_count] = command_info->command;
 			++prefix_count;
 		}
-		if ( full_count < MAX_SUGGESTIONS && match != NULL && match != command_info->command && can_use ) {
+		if ( full_count < MAX_SUGGESTIONS && match != nullptr && match != command_info->command && can_use ) {
 			full_match[full_count] = command_info->command;
 			++full_count;
 		}
@@ -11361,7 +11361,7 @@ static void atcommand_get_suggestions(map_session_data* sd, const char *name, bo
 					++prefix_count;
 				}
 
-				if( full_count < MAX_SUGGESTIONS && match != NULL && match != alias ){
+				if( full_count < MAX_SUGGESTIONS && match != nullptr && match != alias ){
 					full_match[full_count] = alias;
 					++full_count;
 				}
@@ -11413,7 +11413,7 @@ bool is_atcommand(const int fd, map_session_data* sd, const char* message, int t
 	//Reconstructed message
 	char atcmd_msg[CHAT_SIZE_MAX * 2];
 
-	TBL_PC * ssd = NULL; //sd for target
+	TBL_PC * ssd = nullptr; //sd for target
 	AtCommandInfo * info;
 
 	bool is_atcommand = true; // false if it's a charcommand
@@ -11478,7 +11478,7 @@ bool is_atcommand(const int fd, map_session_data* sd, const char* message, int t
 		}
 
 		ssd = map_nick2sd(charname,true);
-		if (ssd == NULL) {
+		if (ssd == nullptr) {
 			sprintf(output, msg_txt(sd,1389), command); // %s failed. Player not found.
 			clif_displaymessage(fd, output);
 			return true;
@@ -11515,8 +11515,8 @@ bool is_atcommand(const int fd, map_session_data* sd, const char* message, int t
 	if((type == 1 || type == 3) && atcmd_binding_count > 0) {
 		struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
 
-		// Check if the binding isn't NULL and there is a NPC event, level of usage met, et cetera
-		if( binding != NULL && binding->npc_event[0] &&
+		// Check if the binding isn't nullptr and there is a NPC event, level of usage met, et cetera
+		if( binding != nullptr && binding->npc_event[0] &&
 			((is_atcommand && pc_get_group_level(sd) >= binding->level) ||
 			 (!is_atcommand && pc_get_group_level(sd) >= binding->level2)))
 		{
@@ -11528,7 +11528,7 @@ bool is_atcommand(const int fd, map_session_data* sd, const char* message, int t
 
 	//Grab the command information and check for the proper GM level required to use it or if the command exists
 	info = get_atcommandinfo_byname(atcommand_alias_db.checkAlias(command + 1));
-	if (info == NULL) {
+	if (info == nullptr) {
 		if (pc_get_group_level(sd) == 0) // TODO: remove or replace with proper permission
 			return false;
 
@@ -11594,7 +11594,7 @@ void atcommand_db_load_groups(){
 }
 void atcommand_db_clear(void) {
 
-	if (atcommand_db != NULL) {
+	if (atcommand_db != nullptr) {
 		DBIterator *iter = db_iterator(atcommand_db);
 		AtCommandInfo* cmd;
 

+ 36 - 36
src/map/battle.cpp

@@ -107,12 +107,12 @@ struct block_list* battle_gettargeted(struct block_list *target)
 {
 	struct block_list *bl_list[24];
 	int c = 0;
-	nullpo_retr(NULL, target);
+	nullpo_retr(nullptr, target);
 
 	memset(bl_list, 0, sizeof(bl_list));
 	map_foreachinallrange(battle_gettargeted_sub, target, AREA_SIZE, BL_CHAR, bl_list, &c, target->id);
 	if ( c == 0 )
-		return NULL;
+		return nullptr;
 	if( c > 24 )
 		c = 24;
 	return bl_list[rnd()%c];
@@ -189,7 +189,7 @@ struct block_list* battle_getenemy(struct block_list *target, int type, int rang
 	map_foreachinallrange(battle_getenemy_sub, target, range, type, bl_list, &c, target);
 
 	if ( c == 0 )
-		return NULL;
+		return nullptr;
 
 	if( c > 24 )
 		c = 24;
@@ -249,7 +249,7 @@ struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int
 	map_foreachinallarea(battle_getenemyarea_sub, src->m, x - range, y - range, x + range, y + range, type, bl_list, &c, src, ignore_id);
 
 	if( c == 0 )
-		return NULL;
+		return nullptr;
 	if( c >= 24 )
 		c = 23;
 
@@ -362,8 +362,8 @@ int battle_delay_damage(t_tick tick, int amotion, struct block_list *src, struct
 {
 	struct delay_damage *dat;
 	status_change *sc;
-	struct block_list *d_tbl = NULL;
-	struct block_list *e_tbl = NULL;
+	struct block_list *d_tbl = nullptr;
+	struct block_list *e_tbl = nullptr;
 
 	nullpo_ret(src);
 	nullpo_ret(target);
@@ -429,7 +429,7 @@ int battle_fix_damage(struct block_list* src, struct block_list* target, int64 d
 /**
  * Does attribute fix modifiers.
  * Added passing of the chars so that the status changes can affect it. [Skotlex]
- * Note: Passing src/target == NULL is perfectly valid, it skips SC_ checks.
+ * Note: Passing src/target == nullptr is perfectly valid, it skips SC_ checks.
  * @param src
  * @param target
  * @param damage
@@ -441,7 +441,7 @@ int battle_fix_damage(struct block_list* src, struct block_list* target, int64 d
  */
 int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 damage,int atk_elem,int def_type, int def_lv, int flag)
 {
-	status_change *sc = NULL, *tsc = NULL;
+	status_change *sc = nullptr, *tsc = nullptr;
 	int ratio;
 
 	if (src) sc = status_get_sc(src);
@@ -495,8 +495,8 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d
 			std::shared_ptr<s_skill_unit_group> sg;
 			struct block_list *src2;
 
-			if( !su || !su->alive || (sg = su->group) == NULL || !sg || sg->val3 == -1 ||
-			   (src2 = map_id2bl(sg->src_id)) == NULL || status_isdead(src2) )
+			if( !su || !su->alive || (sg = su->group) == nullptr || !sg || sg->val3 == -1 ||
+			   (src2 = map_id2bl(sg->src_id)) == nullptr || status_isdead(src2) )
 				return 0;
 
 			if( sg->unit_id != UNT_FIREWALL ) {
@@ -1531,7 +1531,7 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe
  */
 int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int64 damage,uint16 skill_id,uint16 skill_lv)
 {
-	map_session_data *sd = NULL, *tsd = BL_CAST(BL_PC, src);
+	map_session_data *sd = nullptr, *tsd = BL_CAST(BL_PC, src);
 	struct status_change_entry *sce;
 	int div_ = d->div_, flag = d->flag;
 
@@ -2456,7 +2456,7 @@ static int battle_calc_base_weapon_attack(struct block_list *src, struct status_
  * Calculates the standard damage of a normal attack assuming it hits
  * This applies to pre-renewal and non-sd in renewal
  *------------------------------------------
- * Pass damage2 as NULL to not calc it.
+ * Pass damage2 as nullptr to not calc it.
  * Flag values (see e_base_damage_flag):
  * &1 : Critical hit
  * &2 : Arrow attack
@@ -2474,7 +2474,7 @@ static int64 battle_calc_base_damage(struct block_list *src, struct status_data
 	unsigned int atkmin = 0, atkmax = 0;
 	short type = 0;
 	int64 damage = 0;
-	map_session_data *sd = NULL;
+	map_session_data *sd = nullptr;
 
 	nullpo_retr(damage, src);
 
@@ -2870,7 +2870,7 @@ bool is_infinite_defense(struct block_list *target, int flag)
  */
 static bool is_skill_using_arrow(struct block_list *src, int skill_id)
 {
-	if(src != NULL) {
+	if(src != nullptr) {
 		struct status_data *sstatus = status_get_status_data(src);
 		map_session_data *sd = BL_CAST(BL_PC, src);
 
@@ -2890,7 +2890,7 @@ static bool is_skill_using_arrow(struct block_list *src, int skill_id)
  */
 static bool is_attack_right_handed(struct block_list *src, int skill_id)
 {
-	if(src != NULL) {
+	if(src != nullptr) {
 		map_session_data *sd = BL_CAST(BL_PC, src);
 
 		//Skills ALWAYS use ONLY your right-hand weapon (tested on Aegis 10.2)
@@ -2910,7 +2910,7 @@ static bool is_attack_right_handed(struct block_list *src, int skill_id)
  */
 static bool is_attack_left_handed(struct block_list *src, int skill_id)
 {
-	if(src != NULL) {
+	if(src != nullptr) {
 		//Skills ALWAYS use ONLY your right-hand weapon (tested on Aegis 10.2)
 		if(!skill_id) {
 			map_session_data *sd = BL_CAST(BL_PC, src);
@@ -3058,7 +3058,7 @@ static int is_attack_piercing(struct Damage* wd, struct block_list *src, struct
 	if (skill_id == MO_INVESTIGATE || skill_id == RL_MASS_SPIRAL)
 		return 2;
 
-	if(src != NULL) {
+	if(src != nullptr) {
 		map_session_data *sd = BL_CAST(BL_PC, src);
 		struct status_data *tstatus = status_get_status_data(target);
 
@@ -3413,7 +3413,7 @@ static bool battle_skill_stacks_masteries_vvs(uint16 skill_id, e_bonus_chk_flag
  */
 static int battle_calc_equip_attack(struct block_list *src, int skill_id)
 {
-	if(src != NULL) {
+	if(src != nullptr) {
 		int eatk = 0;
 		struct status_data *status = status_get_status_data(src);
 		map_session_data *sd = BL_CAST(BL_PC, src);
@@ -6863,10 +6863,10 @@ static void battle_calc_attack_left_right_hands(struct Damage* wd, struct block_
 /**
 * Check if bl is devoted by someone
 * @param bl
-* @return 'd_bl' if devoted or NULL if not devoted
+* @return 'd_bl' if devoted or nullptr if not devoted
 */
 struct block_list *battle_check_devotion(struct block_list *bl) {
-	struct block_list *d_bl = NULL;
+	struct block_list *d_bl = nullptr;
 
 	if (battle_config.devotion_rdamage && battle_config.devotion_rdamage > rnd() % 100) {
 		status_change *sc = status_get_sc(bl);
@@ -7301,7 +7301,7 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src, struct bl
 
 	memset(&wd,0,sizeof(wd));
 
-	if (src == NULL || target == NULL) {
+	if (src == nullptr || target == nullptr) {
 		nullpo_info(NLP_MARK);
 		return wd;
 	}
@@ -7312,9 +7312,9 @@ static struct Damage battle_calc_weapon_attack(struct block_list *src, struct bl
 	left_element = battle_get_weapon_element(&wd, src, target, skill_id, skill_lv, EQI_HAND_L, false);
 
 	if (sc && !sc->count)
-		sc = NULL; //Skip checking as there are no status changes active.
+		sc = nullptr; //Skip checking as there are no status changes active.
 	if (tsc && !tsc->count)
-		tsc = NULL; //Skip checking as there are no status changes active.
+		tsc = nullptr; //Skip checking as there are no status changes active.
 
 	sd = BL_CAST(BL_PC, src);
 	tsd = BL_CAST(BL_PC, target);
@@ -7711,7 +7711,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list
 	memset(&ad,0,sizeof(ad));
 	memset(&flag,0,sizeof(flag));
 
-	if (src == NULL || target == NULL) {
+	if (src == nullptr || target == nullptr) {
 		nullpo_info(NLP_MARK);
 		return ad;
 	}
@@ -8951,7 +8951,7 @@ struct Damage battle_calc_misc_attack(struct block_list *src,struct block_list *
 
 	memset(&md,0,sizeof(md));
 
-	if (src == NULL || target == NULL) {
+	if (src == nullptr || target == nullptr) {
 		nullpo_info(NLP_MARK);
 		return md;
 	}
@@ -9750,7 +9750,7 @@ void battle_autocast_elembuff_skill(map_session_data* sd, struct block_list* tar
  * Do a basic physical attack (call through unit_attack_timer)
  *------------------------------------------*/
 enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* target, t_tick tick, int flag) {
-	map_session_data *sd = NULL, *tsd = NULL;
+	map_session_data *sd = nullptr, *tsd = nullptr;
 	struct status_data *sstatus, *tstatus;
 	status_change *sc, *tsc;
 	int64 damage;
@@ -9761,7 +9761,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
 	nullpo_retr(ATK_NONE, src);
 	nullpo_retr(ATK_NONE, target);
 
-	if (src->prev == NULL || target->prev == NULL)
+	if (src->prev == nullptr || target->prev == nullptr)
 		return ATK_NONE;
 
 	sd = BL_CAST(BL_PC, src);
@@ -9774,9 +9774,9 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
 	tsc = status_get_sc(target);
 
 	if (sc && !sc->count) //Avoid sc checks when there's none to check for. [Skotlex]
-		sc = NULL;
+		sc = nullptr;
 	if (tsc && !tsc->count)
-		tsc = NULL;
+		tsc = nullptr;
 
 	if (sd)
 	{
@@ -9852,7 +9852,7 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t
 #ifndef RENEWAL
 		status_get_class_(src) != CLASS_BOSS &&
 #endif
-		(src->type == BL_PC || tsd == NULL || distance_bl(src, target) <= (tsd->status.weapon == W_FIST ? 1 : 2)) )
+		(src->type == BL_PC || tsd == nullptr || distance_bl(src, target) <= (tsd->status.weapon == W_FIST ? 1 : 2)) )
 	{
 		uint16 skill_lv = tsc->getSCE(SC_BLADESTOP_WAIT)->val1;
 		int duration = skill_get_time2(MO_BLADESTOP,skill_lv);
@@ -10471,7 +10471,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
 	int state = 0; //Initial state none
 	int strip_enemy = 1; //Flag which marks whether to remove the BCT_ENEMY status if it's also friend/ally.
 	struct block_list *s_bl = src, *t_bl = target;
-	struct unit_data *ud = NULL;
+	struct unit_data *ud = nullptr;
 
 	nullpo_ret(src);
 	nullpo_ret(target);
@@ -10481,10 +10481,10 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
 
 	//t_bl/s_bl hold the 'master' of the attack, while src/target are the actual
 	//objects involved.
-	if( (t_bl = battle_get_master(target)) == NULL )
+	if( (t_bl = battle_get_master(target)) == nullptr )
 		t_bl = target;
 
-	if( (s_bl = battle_get_master(src)) == NULL )
+	if( (s_bl = battle_get_master(src)) == nullptr )
 		s_bl = src;
 
 	if ( s_bl->type == BL_PC ) {
@@ -10598,7 +10598,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
 	switch( t_bl->type ) { //Checks on target master
 		case BL_PC: {
 			map_session_data *sd;
-			status_change *sc = NULL;
+			status_change *sc = nullptr;
 
 			if( t_bl == s_bl )
 				break;
@@ -10834,7 +10834,7 @@ bool battle_check_range(struct block_list *src, struct block_list *bl, int range
 	if( d > AREA_SIZE )
 		return false; // Avoid targetting objects beyond your range of sight.
 
-	return path_search_long(NULL,src->m,src->x,src->y,bl->x,bl->y,CELL_CHKWALL);
+	return path_search_long(nullptr,src->m,src->x,src->y,bl->x,bl->y,CELL_CHKWALL);
 }
 
 /*=============================================
@@ -11714,7 +11714,7 @@ int battle_config_read(const char* cfgName)
 	count++;
 
 	fp = fopen(cfgName,"r");
-	if (fp == NULL)
+	if (fp == nullptr)
 		ShowError("File not found: %s\n", cfgName);
 	else {
 		char line[1024], w1[1024], w2[1024];

+ 19 - 19
src/map/buyingstore.cpp

@@ -110,7 +110,7 @@ int8 buyingstore_setup(map_session_data* sd, unsigned char slots){
 * @param storename
 * @param *itemlist { <nameid>.W, <amount>.W, <price>.L }*
 * @param count Number of item on the itemlist
-* @param at Autotrader info, or NULL if requetsed not from autotrade persistance
+* @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 ){
@@ -302,7 +302,7 @@ void buyingstore_open(map_session_data* sd, uint32 account_id)
 		return;
 	}
 
-	if( ( pl_sd = map_id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore )
+	if( ( pl_sd = map_id2sd(account_id) ) == nullptr || !pl_sd->state.buyingstore )
 	{// not online or not buying
 		return;
 	}
@@ -348,7 +348,7 @@ void buyingstore_trade( map_session_data* sd, uint32 account_id, unsigned int bu
 		return;
 	}
 
-	if( ( pl_sd = map_id2sd(account_id) ) == NULL || !pl_sd->state.buyingstore || pl_sd->buyer_id != buyer_id )
+	if( ( pl_sd = map_id2sd(account_id) ) == nullptr || !pl_sd->state.buyingstore || pl_sd->buyer_id != buyer_id )
 	{// not online, not buying or not same store
 		clif_buyingstore_trade_failed_seller(sd, BUYINGSTORE_TRADE_SELLER_FAILED, 0);
 		return;
@@ -385,7 +385,7 @@ void buyingstore_trade( map_session_data* sd, uint32 account_id, unsigned int bu
 		int index = item->index - 2; // TODO: clif::server_index
 
 		// invalid input
-		if( index < 0 || index >= ARRAYLENGTH( sd->inventory.u.items_inventory ) || sd->inventory_data[index] == NULL || sd->inventory.u.items_inventory[index].nameid != item->itemId || sd->inventory.u.items_inventory[index].amount < item->amount ){
+		if( index < 0 || index >= ARRAYLENGTH( sd->inventory.u.items_inventory ) || sd->inventory_data[index] == nullptr || sd->inventory.u.items_inventory[index].nameid != item->itemId || sd->inventory.u.items_inventory[index].amount < item->amount ){
 			clif_buyingstore_trade_failed_seller( sd, BUYINGSTORE_TRADE_SELLER_FAILED, item->itemId );
 			return;
 		}
@@ -597,7 +597,7 @@ bool buyingstore_searchall(map_session_data* sd, const struct s_search_store_sea
 * @param sd Player as autotrader
 */
 void buyingstore_reopen( map_session_data* sd ){
-	struct s_autotrader *at = NULL;
+	struct s_autotrader *at = nullptr;
 	int8 fail = -1;
 
 	nullpo_retv(sd);
@@ -673,25 +673,25 @@ void do_init_buyingstore_autotrade( void ) {
 
 		if( Sql_NumRows(mmysql_handle) > 0 ) {
 			uint16 items = 0;
-			DBIterator *iter = NULL;
-			struct s_autotrader *at = NULL;
+			DBIterator *iter = nullptr;
+			struct s_autotrader *at = nullptr;
 
 			// Init each autotrader data
 			while (SQL_SUCCESS == Sql_NextRow(mmysql_handle)) {
 				size_t len;
 				char* data;
 
-				at = NULL;
+				at = nullptr;
 				CREATE(at, struct s_autotrader, 1);
-				Sql_GetData(mmysql_handle, 0, &data, NULL); at->id = atoi(data);
-				Sql_GetData(mmysql_handle, 1, &data, NULL); at->account_id = atoi(data);
-				Sql_GetData(mmysql_handle, 2, &data, NULL); at->char_id = atoi(data);
-				Sql_GetData(mmysql_handle, 3, &data, NULL); at->sex = (data[0] == 'F') ? SEX_FEMALE : SEX_MALE;
+				Sql_GetData(mmysql_handle, 0, &data, nullptr); at->id = atoi(data);
+				Sql_GetData(mmysql_handle, 1, &data, nullptr); at->account_id = atoi(data);
+				Sql_GetData(mmysql_handle, 2, &data, nullptr); at->char_id = atoi(data);
+				Sql_GetData(mmysql_handle, 3, &data, nullptr); at->sex = (data[0] == 'F') ? SEX_FEMALE : SEX_MALE;
 				Sql_GetData(mmysql_handle, 4, &data, &len); safestrncpy(at->title, data, zmin(len + 1, MESSAGE_SIZE));
-				Sql_GetData(mmysql_handle, 5, &data, NULL); at->limit = atoi(data);
-				Sql_GetData(mmysql_handle, 6, &data, NULL); at->dir = atoi(data);
-				Sql_GetData(mmysql_handle, 7, &data, NULL); at->head_dir = atoi(data);
-				Sql_GetData(mmysql_handle, 8, &data, NULL); at->sit = atoi(data);
+				Sql_GetData(mmysql_handle, 5, &data, nullptr); at->limit = atoi(data);
+				Sql_GetData(mmysql_handle, 6, &data, nullptr); at->dir = atoi(data);
+				Sql_GetData(mmysql_handle, 7, &data, nullptr); at->head_dir = atoi(data);
+				Sql_GetData(mmysql_handle, 8, &data, nullptr); at->sit = atoi(data);
 				at->count = 0;
 
 				if (battle_config.feature_autotrade_direction >= 0)
@@ -744,9 +744,9 @@ void do_init_buyingstore_autotrade( void ) {
 				while (SQL_SUCCESS == Sql_NextRow(mmysql_handle) && j < at->count) {
 					char *data;
 					CREATE(at->entries[j], struct s_autotrade_entry, 1);
-					Sql_GetData(mmysql_handle, 0, &data, NULL); at->entries[j]->item_id = strtoul(data, nullptr, 10);
-					Sql_GetData(mmysql_handle, 1, &data, NULL); at->entries[j]->amount = atoi(data);
-					Sql_GetData(mmysql_handle, 2, &data, NULL); at->entries[j]->price = atoi(data);
+					Sql_GetData(mmysql_handle, 0, &data, nullptr); at->entries[j]->item_id = strtoul(data, nullptr, 10);
+					Sql_GetData(mmysql_handle, 1, &data, nullptr); at->entries[j]->amount = atoi(data);
+					Sql_GetData(mmysql_handle, 2, &data, nullptr); at->entries[j]->price = atoi(data);
 					j++;
 				}
 				items += j;

+ 25 - 25
src/map/cashshop.cpp

@@ -141,8 +141,8 @@ CashShopDatabase cash_shop_db;
 static bool sale_parse_dbrow( char* fields[], int columns, int current ){
 	t_itemid nameid = strtoul(fields[0], nullptr, 10);
 	int start = atoi(fields[1]), end = atoi(fields[2]), amount = atoi(fields[3]);
-	time_t now = time(NULL);
-	struct sale_item_data* sale_item = NULL;
+	time_t now = time(nullptr);
+	struct sale_item_data* sale_item = nullptr;
 
 	if( !item_db.exists(nameid) ){
 		ShowWarning( "sale_parse_dbrow: Invalid ID %u in line '%d', skipping...\n", nameid, current );
@@ -170,7 +170,7 @@ static bool sale_parse_dbrow( char* fields[], int columns, int current ){
 	// Check if there is already an entry
 	sale_item = sale_find_item(nameid,false);
 
-	if( sale_item == NULL ){
+	if( sale_item == nullptr ){
 		RECREATE(sale_items.item, struct sale_item_data *, ++sale_items.count);
 		CREATE(sale_items.item[sale_items.count - 1], struct sale_item_data, 1);
 		sale_item = sale_items.item[sale_items.count - 1];
@@ -202,9 +202,9 @@ static void sale_read_db_sql( void ){
 		lines++;
 
 		for( i = 0; i < 4; i++ ){
-			Sql_GetData( mmysql_handle, i, &str[i], NULL );
+			Sql_GetData( mmysql_handle, i, &str[i], nullptr );
 
-			if( str[i] == NULL ){
+			if( str[i] == nullptr ){
 				str[i] = dummy;
 			}
 		}
@@ -229,7 +229,7 @@ static TIMER_FUNC(sale_end_timer){
 	delete_timer( sale_item->timer_end, sale_end_timer );
 	sale_item->timer_end = INVALID_TIMER;
 	
-	clif_sale_end( sale_item, NULL, ALL_CLIENT );
+	clif_sale_end( sale_item, nullptr, ALL_CLIENT );
 
 	sale_remove_item( sale_item->nameid );
 
@@ -239,8 +239,8 @@ static TIMER_FUNC(sale_end_timer){
 static TIMER_FUNC(sale_start_timer){
 	struct sale_item_data* sale_item = (struct sale_item_data*)data;
 
-	clif_sale_start( sale_item, NULL, ALL_CLIENT );
-	clif_sale_amount( sale_item, NULL, ALL_CLIENT );
+	clif_sale_start( sale_item, nullptr, ALL_CLIENT );
+	clif_sale_amount( sale_item, nullptr, ALL_CLIENT );
 
 	// Clear the start timer
 	if( sale_item->timer_start != INVALID_TIMER ){
@@ -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(NULL) ) * 1000, sale_end_timer, 0, (intptr_t)sale_item );
+	sale_item->timer_end = add_timer( gettick() + (unsigned int)( sale_item->end - time(nullptr) ) * 1000, sale_end_timer, 0, (intptr_t)sale_item );
 
 	return 1;
 }
@@ -261,7 +261,7 @@ enum e_sale_add_result sale_add_item( t_itemid nameid, int32 count, time_t from,
 	}
 
 	// Adding a sale in the past is not possible
-	if( from < time(NULL) ){
+	if( from < time(nullptr) ){
 		return SALE_ADD_FAILED;
 	}
 
@@ -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(NULL)) * 1000, sale_start_timer, 0, (intptr_t)sale_item );
+	sale_item->timer_start = add_timer( gettick() + (unsigned int)(from - time(nullptr)) * 1000, sale_start_timer, 0, (intptr_t)sale_item );
 	sale_item->timer_end = INVALID_TIMER;
 
 	return SALE_ADD_SUCCESS;
@@ -306,7 +306,7 @@ bool sale_remove_item( t_itemid nameid ){
 	// Check if there is an entry for this item id
 	sale_item = sale_find_item(nameid, false);
 
-	if( sale_item == NULL ){
+	if( sale_item == nullptr ){
 		return false;
 	}
 
@@ -327,7 +327,7 @@ bool sale_remove_item( t_itemid nameid ){
 		sale_item->timer_end = INVALID_TIMER;
 
 		// Notify all clients that the sale has ended
-		clif_sale_end(sale_item, NULL, ALL_CLIENT);
+		clif_sale_end(sale_item, nullptr, ALL_CLIENT);
 	}
 
 	// Find the original pointer in the array
@@ -346,7 +346,7 @@ bool sale_remove_item( t_itemid nameid ){
 	}else{
 		aFree(sale_items.item[0]);
 		aFree(sale_items.item);
-		sale_items.item = NULL;
+		sale_items.item = nullptr;
 	}
 
 	return true;
@@ -355,13 +355,13 @@ bool sale_remove_item( t_itemid nameid ){
 struct sale_item_data* sale_find_item( t_itemid nameid, bool onsale ){
 	int i;
 	struct sale_item_data* sale_item;
-	time_t now = time(NULL);
+	time_t now = time(nullptr);
 
 	ARR_FIND( 0, sale_items.count, i, sale_items.item[i]->nameid == nameid );
 
 	// No item with the specified item id was found
 	if( i == sale_items.count ){
-		return NULL;
+		return nullptr;
 	}
 
 	sale_item = sale_items.item[i];
@@ -373,17 +373,17 @@ struct sale_item_data* sale_find_item( t_itemid nameid, bool onsale ){
 
 	// The sale is in the future
 	if( sale_items.item[i]->start > now ){
-		return NULL;
+		return nullptr;
 	}
 
 	// The sale was in the past
 	if( sale_items.item[i]->end < now ){
-		return NULL;
+		return nullptr;
 	}
 
 	// The amount has been used up already
 	if( sale_items.item[i]->amount == 0 ){
-		return NULL;
+		return nullptr;
 	}
 
 	// Return the sale item
@@ -407,7 +407,7 @@ static void cashshop_read_db( void ){
 
 #if PACKETVER_SUPPORTS_SALES
 	int i;
-	time_t now = time(NULL);
+	time_t now = time(nullptr);
 
 	sale_read_db_sql();
 
@@ -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(NULL) ) * 1000, sale_start_timer, 0, (intptr_t)it );
+			it->timer_start = add_timer( gettick() + (unsigned int)( it->start - time(nullptr) ) * 1000, sale_start_timer, 0, (intptr_t)it );
 		}else{
 			sale_start_timer( 0, gettick(), 0, (intptr_t)it );
 		}
@@ -443,7 +443,7 @@ bool cashshop_buylist( map_session_data* sd, uint32 kafrapoints, int n, struct P
 	uint32 totalweight = 0;
 	int i,new_;
 
-	if( sd == NULL || item_list == NULL ){
+	if( sd == nullptr || item_list == nullptr ){
 		clif_cashshop_result( sd, 0, CASHSHOP_RESULT_ERROR_UNKNOWN );
 		return false;
 	}else if( sd->state.trading ){
@@ -488,7 +488,7 @@ bool cashshop_buylist( map_session_data* sd, uint32 kafrapoints, int n, struct P
 #if PACKETVER_SUPPORTS_SALES
 			struct sale_item_data* sale = sale_find_item( nameid, true );
 
-			if( sale == NULL ){
+			if( sale == nullptr ){
 				// Client tried to buy an item from sale that was not even on sale
 				clif_cashshop_result( sd, nameid, CASHSHOP_RESULT_ERROR_UNKNOWN );
 				return false;
@@ -613,7 +613,7 @@ bool cashshop_buylist( map_session_data* sd, uint32 kafrapoints, int n, struct P
 
 					sale->amount = new_amount;
 
-					clif_sale_amount(sale, NULL, ALL_CLIENT);
+					clif_sale_amount(sale, nullptr, ALL_CLIENT);
 				}
 			}
 #endif
@@ -658,7 +658,7 @@ void do_final_cashshop( void ){
 
 		aFree(sale_items.item);
 
-		sale_items.item = NULL;
+		sale_items.item = nullptr;
 		sale_items.count = 0;
 	}
 #endif

+ 46 - 46
src/map/channel.cpp

@@ -34,13 +34,13 @@ DBMap* channel_get_db(void){ return channel_db; }
  * @param pass: Channel password, can be null
  * @param color: Display color
  * @param chantype: Channel type
- * @return NULL on failure or Channel on success
+ * @return nullptr on failure or Channel on success
  */
 struct Channel* channel_create(struct Channel *tmp_chan) {
 	struct Channel* channel;
 
 	if (!tmp_chan->name[0])
-		return NULL;
+		return nullptr;
 
 	CREATE(channel, struct Channel, 1); //will exit on fail allocation
 	//channel->id = tmp_chan->id;
@@ -84,7 +84,7 @@ struct Channel* channel_create(struct Channel *tmp_chan) {
  * @param pass: Channel password, can be null
  * @param chantype: Channel type
  * @param owner: Owner ID
- * @return NULL on failure or Channel on success
+ * @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 tmp_chan;
@@ -125,7 +125,7 @@ struct Channel* channel_create_simple(char *name, char *pass, enum Channel_Type
 			tmp_chan.char_id = owner;
 			break;
 		default:
-			return NULL;
+			return nullptr;
 	}
 
 	return channel_create(&tmp_chan);
@@ -164,16 +164,16 @@ int channel_delete(struct Channel *channel, bool force) {
 	db_destroy(channel->banned);
 	if (channel->groups)
 		aFree(channel->groups);
-	channel->groups = NULL;
+	channel->groups = nullptr;
 	channel->group_count = 0;
 	switch(channel->type){
 	case CHAN_TYPE_MAP:
-		map_getmapdata(channel->m)->channel = NULL;
+		map_getmapdata(channel->m)->channel = nullptr;
 		aFree(channel);
 		break;
 	case CHAN_TYPE_ALLY: {
 		auto g = guild_search(channel->gid);
-		if(g) g->channel = NULL;
+		if(g) g->channel = nullptr;
 		aFree(channel);
 		break;
 	}
@@ -259,7 +259,7 @@ int channel_mjoin(map_session_data *sd) {
 	struct map_data *mapdata = map_getmapdata(sd->bl.m);
 
 	if( !mapdata->channel ) {
-		mapdata->channel = channel_create_simple(NULL,NULL,CHAN_TYPE_MAP,sd->bl.m);
+		mapdata->channel = channel_create_simple(nullptr,nullptr,CHAN_TYPE_MAP,sd->bl.m);
 	}
 
 	if( mapdata->channel->opt & CHAN_OPT_ANNOUNCE_SELF ) {
@@ -317,7 +317,7 @@ int channel_gjoin(map_session_data *sd, int flag){
 
 	channel = g->channel;
 	if(!channel){
-		channel = channel_create_simple(NULL,NULL,CHAN_TYPE_ALLY,g->guild.guild_id);
+		channel = channel_create_simple(nullptr,nullptr,CHAN_TYPE_ALLY,g->guild.guild_id);
 		g->channel = channel;
 		channel_ajoin(*g);
 	}
@@ -353,15 +353,15 @@ int channel_clean(struct Channel *channel, map_session_data *sd, int flag) {
 		return -1;
 
 	if( channel == sd->gcbind )
-		sd->gcbind = NULL;
+		sd->gcbind = nullptr;
 
 	ARR_FIND(0, sd->channel_count, i, sd->channels[i] == channel);
 	if( i < sd->channel_count ) {
 		unsigned char cursor = i;
-		sd->channels[i] = NULL;
+		sd->channels[i] = nullptr;
 		sd->channel_tick[i] = 0;
 		for(; i < sd->channel_count; i++ ) { //slice move list down
-			if( sd->channels[i] == NULL )
+			if( sd->channels[i] == nullptr )
 				continue;
 			if(i != cursor) {
 				sd->channels[cursor] = sd->channels[i];
@@ -372,8 +372,8 @@ int channel_clean(struct Channel *channel, map_session_data *sd, int flag) {
 		if ( !(sd->channel_count = cursor) ) { //if in no more chan delete db
 			aFree(sd->channels);
 			aFree(sd->channel_tick);
-			sd->channels = NULL;
-			sd->channel_tick = NULL;
+			sd->channels = nullptr;
+			sd->channel_tick = nullptr;
 		}
 	}
 
@@ -501,26 +501,26 @@ int channel_chk(char *chname, char *chpass, int type){
 /**
  * Lookup a channel name
  * @param chname: Channel name
- * @param sd: Player data, can be NULL, used to solve #map and #ally cases
+ * @param sd: Player data, can be nullptr, used to solve #map and #ally cases
  * @param flag: Lookup types (1 - Create channel if it does not exist (map or ally only), 2 - Join the channel if not joined yet (map or ally only))
- * @return NULL on channel not found or channel data on success
+ * @return nullptr on channel not found or channel data on success
  */
 struct Channel* channel_name2channel(char *chname, map_session_data *sd, int flag){
-	if(channel_chk(chname, NULL, 1))
-		return NULL;
+	if(channel_chk(chname, nullptr, 1))
+		return nullptr;
 
-	struct map_data *mapdata = sd ? map_getmapdata(sd->bl.m) : NULL;
+	struct map_data *mapdata = sd ? map_getmapdata(sd->bl.m) : nullptr;
 
 	if(sd && strcmpi(chname + 1,channel_config.map_tmpl.name) == 0){
 		if(flag&1 && !mapdata->channel)
-			mapdata->channel = channel_create_simple(NULL,NULL,CHAN_TYPE_MAP,sd->bl.m);
+			mapdata->channel = channel_create_simple(nullptr,nullptr,CHAN_TYPE_MAP,sd->bl.m);
 		if(flag&2 && channel_pc_haschan(sd,mapdata->channel) < 1)
 			channel_mjoin(sd);
 		return mapdata->channel;
 	}
 	else if(sd && (strcmpi(chname + 1,channel_config.ally_tmpl.name) == 0) && sd->guild){
 		if(flag&1 && !sd->guild->channel)
-			sd->guild->channel = channel_create_simple(NULL,NULL,CHAN_TYPE_ALLY,sd->guild->guild.guild_id);
+			sd->guild->channel = channel_create_simple(nullptr,nullptr,CHAN_TYPE_ALLY,sd->guild->guild.guild_id);
 		if(flag&2 && channel_pc_haschan(sd,mapdata->channel) < 1)
 			channel_gjoin(sd,3);
 		return sd->guild->channel;
@@ -699,7 +699,7 @@ int channel_pcdelete(map_session_data *sd, char *chname){
 
 	if(!sd || !chname) return 0;
 
-	if( channel_chk(chname,NULL,1) ) {
+	if( channel_chk(chname,nullptr,1) ) {
 		clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
 		return -1;
 	}
@@ -731,7 +731,7 @@ int channel_pcleave(map_session_data *sd, char *chname){
 	if(!sd || !chname)
 		return 0;
 
-	if( channel_chk(chname,NULL,1) ) {
+	if( channel_chk(chname,nullptr,1) ) {
 		clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
 		return -1;
 	}
@@ -779,7 +779,7 @@ int channel_pcjoin(map_session_data *sd, char *chname, char *pass){
 	if(!sd || !chname)
 		return 0;
 
-	if( channel_chk(chname,NULL,1) ) {
+	if( channel_chk(chname,nullptr,1) ) {
 		clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
 		return -1;
 	}
@@ -845,7 +845,7 @@ int channel_pccolor(map_session_data *sd, char *chname, char *color){
 	if(!sd)
 		return 0;
 
-	if( channel_chk(chname,NULL,1) ) {
+	if( channel_chk(chname,nullptr,1) ) {
 		clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
 		return -1;
 	}
@@ -897,7 +897,7 @@ int channel_pcbind(map_session_data *sd, char *chname){
 	if(!sd)
 		return 0;
 
-	if( channel_chk(chname,NULL,1) ) {
+	if( channel_chk(chname,nullptr,1) ) {
 		clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
 		return -1;
 	}
@@ -925,13 +925,13 @@ int channel_pcunbind(map_session_data *sd){
 	if(!sd)
 		return 0;
 
-	if( sd->gcbind == NULL ) {
+	if( sd->gcbind == nullptr ) {
 		clif_displaymessage(sd->fd, msg_txt(sd,1432));// Your global chat is not binded to any channel.
 		return -1;
 	}
 	sprintf(output, msg_txt(sd,1433),sd->gcbind->name); // Your global chat is now unbinded from the '#%s' channel.
 	clif_displaymessage(sd->fd, output);
-	sd->gcbind = NULL;
+	sd->gcbind = nullptr;
 	return 0;
 }
 
@@ -948,7 +948,7 @@ int channel_pcban(map_session_data *sd, char *chname, char *pname, int flag){
 	char output[CHAT_SIZE_MAX];
 	map_session_data *tsd = map_nick2sd(pname,false);
 
-	if( channel_chk(chname,NULL,1) ) {
+	if( channel_chk(chname,nullptr,1) ) {
 		clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
 		return -1;
 	}
@@ -1057,7 +1057,7 @@ int channel_pckick(map_session_data *sd, char *chname, char *pname) {
 	char output[CHAT_SIZE_MAX];
 	map_session_data *tsd = map_nick2sd(pname,false);
 
-	if( channel_chk(chname,NULL,1) ) {
+	if( channel_chk(chname,nullptr,1) ) {
 		clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
 		return -1;
 	}
@@ -1135,7 +1135,7 @@ int channel_pcsetopt(map_session_data *sd, char *chname, const char *option, con
 		"Autojoin",
 	};
 
-	if( channel_chk(chname,NULL,1) ) {
+	if( channel_chk(chname,nullptr,1) ) {
 		clif_displaymessage(sd->fd, msg_txt(sd,1405));// Channel name must start with '#'.
 		return -1;
 	}
@@ -1271,7 +1271,7 @@ bool channel_pccheckgroup(struct Channel *channel, int group_id) {
  */
 int channel_pcautojoin_sub(DBKey key, DBData *data, va_list ap) {
 	struct Channel *channel = (struct Channel *)db_data2ptr(data);
-	map_session_data *sd = NULL;
+	map_session_data *sd = nullptr;
 	char channame[CHAN_NAME_LENGTH+1];
 
 	nullpo_ret(channel);
@@ -1284,7 +1284,7 @@ int channel_pcautojoin_sub(DBKey key, DBData *data, va_list ap) {
 	if (!pc_has_permission(sd, PC_PERM_CHANNEL_ADMIN) && !channel_pccheckgroup(channel, sd->group_id))
 		return 0;
 	safesnprintf(channame, sizeof(channame), "#%s", channel->name);
-	channel_pcjoin(sd, channame, NULL);
+	channel_pcjoin(sd, channame, nullptr);
 
 	return 1;
 }
@@ -1322,14 +1322,14 @@ unsigned long channel_getColor(const char *color_str) {
  * @return True on success or false on failure
  */
 bool channel_read_sub(config_setting_t *chan, struct Channel *tmp_chan, uint8 i) {
-	config_setting_t  *group_list = NULL;
+	config_setting_t  *group_list = nullptr;
 	int delay = 1000, autojoin = 0, leave = 1, chat = 1, color_override = 0,
 		self_notif = 1, join_notif = 0, leave_notif = 0;
 	int64 type = CHAN_TYPE_PUBLIC;
 	int group_count = 0;
-	const char *name = NULL, *password = NULL, *alias = NULL, *color_str = "Default", *type_str = NULL;
+	const char *name = nullptr, *password = nullptr, *alias = nullptr, *color_str = "Default", *type_str = nullptr;
 
-	if (tmp_chan == NULL)
+	if (tmp_chan == nullptr)
 		return false;
 
 	if (!config_setting_lookup_string(chan, "name", &name)) {
@@ -1389,7 +1389,7 @@ bool channel_read_sub(config_setting_t *chan, struct Channel *tmp_chan, uint8 i)
  */
 void channel_read_config(void) {
 	config_t channels_conf;
-	config_setting_t *chan_setting = NULL;
+	config_setting_t *chan_setting = nullptr;
 
 	if (conf_read_file(&channels_conf, channel_conf)) {
 		ShowError("Cannot read file '%s' for channel connfig.\n", channel_conf);
@@ -1397,12 +1397,12 @@ void channel_read_config(void) {
 	}
 
 	chan_setting = config_lookup(&channels_conf, "channel_config");
-	if (chan_setting != NULL) {
-		config_setting_t *colors, *private_channel = NULL, *channels = NULL;
+	if (chan_setting != nullptr) {
+		config_setting_t *colors, *private_channel = nullptr, *channels = nullptr;
 		int count = 0, channel_count = 0;
 
 		colors = config_setting_get_member(chan_setting, "colors");
-		if (colors != NULL) {
+		if (colors != nullptr) {
 			int i, color_count = config_setting_length(colors);
 
 			CREATE(channel_config.colors, unsigned long, color_count);
@@ -1412,14 +1412,14 @@ void channel_read_config(void) {
 				CREATE(channel_config.colors_name[i], char, CHAN_NAME_LENGTH);
 
 				safestrncpy(channel_config.colors_name[i], config_setting_name(color), CHAN_NAME_LENGTH);
-				channel_config.colors[i] = strtoul(config_setting_get_string_elem(colors,i),NULL,0);
+				channel_config.colors[i] = strtoul(config_setting_get_string_elem(colors,i),nullptr,0);
 				channel_config.colors[i] = (channel_config.colors[i] & 0x0000FF) << 16 | (channel_config.colors[i] & 0x00FF00) | (channel_config.colors[i] & 0xFF0000) >> 16;//RGB to BGR
 			}
 			channel_config.colors_count = color_count;
 		}
 
 		private_channel = config_setting_get_member(chan_setting, "private_channel");
-		if (private_channel != NULL) {
+		if (private_channel != nullptr) {
 			int allow = 1, ban = 1, kick = 1, color_override = 0, change_delay = 0,
 				self_notif = 1, join_notif = 0, leave_notif = 0,
 				delay = 1000, max_member = 1000;
@@ -1453,22 +1453,22 @@ void channel_read_config(void) {
 		}
 
 		channels = config_setting_get_member(chan_setting, "ally");
-		if (channels != NULL) {
+		if (channels != nullptr) {
 			memset(&channel_config.ally_tmpl, 0, sizeof(struct Channel));
 			channel_read_sub(channels, &channel_config.ally_tmpl, 0);
 		}
 		channels = config_setting_get_member(chan_setting, "map");
-		if (channels != NULL) {
+		if (channels != nullptr) {
 			memset(&channel_config.map_tmpl, 0, sizeof(struct Channel));
 			channel_read_sub(channels, &channel_config.map_tmpl, 0);
 		}
 
 		channels = config_setting_get_member(chan_setting, "channels");
-		if (channels != NULL && (count = config_setting_length(channels)) > 0) {
+		if (channels != nullptr && (count = config_setting_length(channels)) > 0) {
 			int i;
 			for (i = 0; i < count; i++) {
 				config_setting_t *chan = config_setting_get_elem(channels, i);
-				struct Channel *channel = NULL, tmp_chan;
+				struct Channel *channel = nullptr, tmp_chan;
 
 				memset(&tmp_chan, 0, sizeof(struct Channel));
 				if (!channel_read_sub(chan, &tmp_chan, i))

+ 10 - 10
src/map/chat.cpp

@@ -24,11 +24,11 @@
 int chat_triggerevent(struct chat_data *cd); // forward declaration
 
 /// Initializes a chatroom object (common functionality for both pc and npc chatrooms).
-/// Returns a chatroom object on success, or NULL on failure.
+/// Returns a chatroom object on success, or nullptr on failure.
 static struct chat_data* chat_createchat(struct block_list* bl, const char* title, const char* pass, int limit, bool pub, int trigger, const char* ev, int zeny, int minLvl, int maxLvl)
 {
 	struct chat_data* cd;
-	nullpo_retr(NULL, bl);
+	nullpo_retr(nullptr, bl);
 
 	cd = (struct chat_data *) aMalloc(sizeof(struct chat_data));
 
@@ -50,11 +50,11 @@ static struct chat_data* chat_createchat(struct block_list* bl, const char* titl
 	cd->bl.x    = bl->x;
 	cd->bl.y    = bl->y;
 	cd->bl.type = BL_CHAT;
-	cd->bl.next = cd->bl.prev = NULL;
+	cd->bl.next = cd->bl.prev = nullptr;
 
 	if( cd->bl.id == 0 ) {
 		aFree(cd);
-		cd = NULL;
+		cd = nullptr;
 	}
 
 	map_addiddb(&cd->bl);
@@ -133,7 +133,7 @@ int chat_joinchat(map_session_data* sd, int chatid, const char* pass)
 
 	cd = (struct chat_data*)map_id2bl(chatid);
 
-	if( cd == NULL || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit ) {
+	if( cd == nullptr || cd->bl.type != BL_CHAT || cd->bl.m != sd->bl.m || sd->state.vending || sd->state.buyingstore || sd->chatID || ((cd->owner->type == BL_NPC) ? cd->users+1 : cd->users) >= cd->limit ) {
 		clif_joinchatfail(sd,0);
 		return 0;
 	}
@@ -196,7 +196,7 @@ int chat_leavechat(map_session_data* sd, bool kicked)
 
 	cd = (struct chat_data*)map_id2bl(sd->chatID);
 
-	if( cd == NULL ) {
+	if( cd == nullptr ) {
 		pc_setchatid(sd, 0);
 		return 1;
 	}
@@ -267,7 +267,7 @@ int chat_changechatowner(map_session_data* sd, const char* nextownername)
 
 	cd = (struct chat_data*)map_id2bl(sd->chatID);
 
-	if( cd == NULL || (struct block_list*) sd != cd->owner )
+	if( cd == nullptr || (struct block_list*) sd != cd->owner )
 		return 1;
 
 	ARR_FIND( 1, cd->users, i, strncmp(cd->usersd[i]->status.name, nextownername, NAME_LENGTH) == 0 );
@@ -317,7 +317,7 @@ int chat_changechatstatus(map_session_data* sd, const char* title, const char* p
 
 	cd = (struct chat_data*)map_id2bl(sd->chatID);
 
-	if( cd == NULL || (struct block_list *)sd != cd->owner )
+	if( cd == nullptr || (struct block_list *)sd != cd->owner )
 		return 1;
 
 	safestrncpy(cd->title, title, CHATROOM_TITLE_SIZE);
@@ -364,7 +364,7 @@ int chat_kickchat(map_session_data* sd, const char* kickusername)
 
 	cd = (struct chat_data *)map_id2bl(sd->chatID);
 
-	if( cd == NULL || (struct block_list *)sd != cd->owner )
+	if( cd == nullptr || (struct block_list *)sd != cd->owner )
 		return -1;
 
 	ARR_FIND( 0, cd->users, i, strncmp(cd->usersd[i]->status.name, kickusername, NAME_LENGTH) == 0 );
@@ -432,7 +432,7 @@ int chat_deletenpcchat(struct npc_data* nd)
 
 	cd = (struct chat_data*)map_id2bl(nd->chat_id);
 
-	if( cd == NULL )
+	if( cd == nullptr )
 		return 0;
 
 	chat_npckickall(cd);

+ 27 - 27
src/map/chrif.cpp

@@ -130,7 +130,7 @@ struct auth_node* chrif_search(uint32 account_id) {
 struct auth_node* chrif_auth_check(uint32 account_id, uint32 char_id, enum sd_state state) {
 	struct auth_node *node = chrif_search(account_id);
 
-	return ( node && node->char_id == char_id && node->state == state ) ? node : NULL;
+	return ( node && node->char_id == char_id && node->state == state ) ? node : nullptr;
 }
 
 bool chrif_auth_delete(uint32 account_id, uint32 char_id, enum sd_state state) {
@@ -140,7 +140,7 @@ bool chrif_auth_delete(uint32 account_id, uint32 char_id, enum sd_state state) {
 		int fd = node->sd ? node->sd->fd : node->fd;
 
 		if ( session[fd] && session[fd]->session_data == node->sd )
-			session[fd]->session_data = NULL;
+			session[fd]->session_data = nullptr;
 
 		if ( node->char_dat )
 			aFree(node->char_dat);
@@ -197,7 +197,7 @@ static bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) {
 	if(sd->fd && state == ST_LOGOUT) { //Disassociate player, and free it after saving ack returns. [Skotlex]
 		//fd info must not be lost for ST_MAPCHANGE as a final packet needs to be sent to the player.
 		if ( session[sd->fd] )
-			session[sd->fd]->session_data = NULL;
+			session[sd->fd]->session_data = nullptr;
 		sd->fd = 0;
 	}
 
@@ -208,7 +208,7 @@ bool chrif_auth_finished(map_session_data* sd) {
 	struct auth_node *node= chrif_search(sd->status.account_id);
 
 	if ( node && node->sd == sd && node->state == ST_LOGIN ) {
-		node->sd = NULL;
+		node->sd = nullptr;
 
 		return chrif_auth_delete(node->account_id, node->char_id, ST_LOGIN);
 	}
@@ -509,7 +509,7 @@ static int chrif_reconnect(DBKey key, DBData *data, va_list ap) {
 
 	switch (node->state) {
 		case ST_LOGIN:
-			if ( node->sd && node->char_dat == NULL ) {//Since there is no way to request the char auth, make it fail.
+			if ( node->sd && node->char_dat == nullptr ) {//Since there is no way to request the char auth, make it fail.
 				pc_authfail(node->sd);
 				chrif_char_offline(node->sd);
 				chrif_auth_delete(node->account_id, node->char_id, ST_LOGIN);
@@ -627,7 +627,7 @@ int chrif_skillcooldown_request(uint32 account_id, uint32 char_id) {
 void chrif_authreq(map_session_data *sd, bool autotrade) {
 	struct auth_node *node= chrif_search(sd->bl.id);
 
-	if( node != NULL || !chrif_isconnected() ) {
+	if( node != nullptr || !chrif_isconnected() ) {
 		set_eof(sd->fd);
 		return;
 	}
@@ -673,16 +673,16 @@ void chrif_authok(int fd) {
 
 	//Check if we don't already have player data in our server
 	//Causes problems if the currently connected player tries to quit or this data belongs to an already connected player which is trying to re-auth.
-	if ( ( sd = map_id2sd(account_id) ) != NULL )
+	if ( ( sd = map_id2sd(account_id) ) != nullptr )
 		return;
 
-	if ( ( node = chrif_search(account_id) ) == NULL )
+	if ( ( node = chrif_search(account_id) ) == nullptr )
 		return; // should not happen
 
 	if ( node->state != ST_LOGIN )
 		return; //character in logout phase, do not touch that data.
 
-	if ( node->sd == NULL ) {
+	if ( node->sd == nullptr ) {
 		/*
 		//When we receive double login info and the client has not connected yet,
 		//discard the older one and keep the new one.
@@ -694,7 +694,7 @@ void chrif_authok(int fd) {
 	sd = node->sd;
 
 	if( global_core->is_running() &&
-		node->char_dat == NULL &&
+		node->char_dat == nullptr &&
 		node->account_id == account_id &&
 		node->char_id == char_id &&
 		node->login_id1 == login_id1 )
@@ -723,7 +723,7 @@ void chrif_authfail(int fd) {/* HELLO WORLD. ip in RFIFOL 15 is not being used (
 
 	node = chrif_search(account_id);
 
-	if( node != NULL &&
+	if( node != nullptr &&
 		node->account_id == account_id &&
 		node->char_id == char_id &&
 		node->login_id1 == login_id1 &&
@@ -906,7 +906,7 @@ static void chrif_ack_login_req(int aid, const char* player_name, uint16 type, u
 
 	sd = map_id2sd(aid);
 
-	if( aid < 0 || sd == NULL ) {
+	if( aid < 0 || sd == nullptr ) {
 		ShowError("chrif_ack_login_req failed - player not online.\n");
 		return;
 	}
@@ -1037,14 +1037,14 @@ int chrif_divorceack(uint32 char_id, int partner_id) {
 	if( !char_id || !partner_id )
 		return 0;
 
-	if( ( sd = map_charid2sd(char_id) ) != NULL && sd->status.partner_id == partner_id ) {
+	if( ( sd = map_charid2sd(char_id) ) != nullptr && sd->status.partner_id == partner_id ) {
 		sd->status.partner_id = 0;
 		for(i = 0; i < MAX_INVENTORY; i++)
 			if (sd->inventory.u.items_inventory[i].nameid == WEDDING_RING_M || sd->inventory.u.items_inventory[i].nameid == WEDDING_RING_F)
 				pc_delitem(sd, i, 1, 0, 0, LOG_TYPE_OTHER);
 	}
 
-	if( ( sd = map_charid2sd(partner_id) ) != NULL && sd->status.partner_id == char_id ) {
+	if( ( sd = map_charid2sd(partner_id) ) != nullptr && sd->status.partner_id == char_id ) {
 		sd->status.partner_id = 0;
 		for(i = 0; i < MAX_INVENTORY; i++)
 			if (sd->inventory.u.items_inventory[i].nameid == WEDDING_RING_M || sd->inventory.u.items_inventory[i].nameid == WEDDING_RING_F)
@@ -1060,7 +1060,7 @@ int chrif_deadopt(uint32 father_id, uint32 mother_id, uint32 child_id) {
 	map_session_data* sd;
 	uint16 idx = skill_get_index(WE_CALLBABY);
 
-	if( father_id && ( sd = map_charid2sd(father_id) ) != NULL && sd->status.child == child_id ) {
+	if( father_id && ( sd = map_charid2sd(father_id) ) != nullptr && sd->status.child == child_id ) {
 		sd->status.child = 0;
 		sd->status.skill[idx].id = 0;
 		sd->status.skill[idx].lv = 0;
@@ -1068,7 +1068,7 @@ int chrif_deadopt(uint32 father_id, uint32 mother_id, uint32 child_id) {
 		clif_deleteskill(sd,WE_CALLBABY);
 	}
 
-	if( mother_id && ( sd = map_charid2sd(mother_id) ) != NULL && sd->status.child == child_id ) {
+	if( mother_id && ( sd = map_charid2sd(mother_id) ) != nullptr && sd->status.child == child_id ) {
 		sd->status.child = 0;
 		sd->status.skill[idx].id = 0;
 		sd->status.skill[idx].lv = 0;
@@ -1095,7 +1095,7 @@ int chrif_ban(int fd) {
 	if(res==2)  sd = map_charid2sd(id);
 	else sd = map_id2sd(id);
 
-	if ( id < 0 || sd == NULL ) {
+	if ( id < 0 || sd == nullptr ) {
 		//nothing to do on map if player not connected
 		return 0;
 	}
@@ -1154,10 +1154,10 @@ int chrif_disconnectplayer(int fd) {
 	uint32 account_id = RFIFOL(fd, 2);
 
 	sd = map_id2sd(account_id);
-	if( sd == NULL ) {
+	if( sd == nullptr ) {
 		struct auth_node* auth = chrif_search(account_id);
 
-		if( auth != NULL && chrif_auth_delete(account_id, auth->char_id, ST_LOGIN) )
+		if( auth != nullptr && chrif_auth_delete(account_id, auth->char_id, ST_LOGIN) )
 			return 0;
 
 		return -1;
@@ -1292,7 +1292,7 @@ int chrif_save_scdata(map_session_data *sd) { //parses the sc_data of the player
 			continue;
 		if (sce->timer != INVALID_TIMER) {
 			timer = get_timer(sce->timer);
-			if (timer == NULL || timer->func != status_change_timer)
+			if (timer == nullptr || timer->func != status_change_timer)
 				continue;
 			if (DIFF_TICK(timer->tick,tick) > 0)
 				data.tick = DIFF_TICK(timer->tick,tick); //Duration that is left before ending.
@@ -1338,7 +1338,7 @@ int chrif_skillcooldown_save(map_session_data *sd) {
 			continue;
 
 		timer = get_timer(sd->scd[i]->timer);
-		if (timer == NULL || timer->func != skill_blockpc_end || DIFF_TICK(timer->tick, tick) < 0)
+		if (timer == nullptr || timer->func != skill_blockpc_end || DIFF_TICK(timer->tick, tick) < 0)
 			continue;
 
 		data.tick = DIFF_TICK(timer->tick, tick);
@@ -1383,7 +1383,7 @@ int chrif_load_scdata(int fd) {
 	for (i = 0; i < count; i++) {
 		struct status_change_data *data = (struct status_change_data*)RFIFOP(fd,14 + i*sizeof(struct status_change_data));
 
-		status_change_start(NULL,&sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, SCSTART_NOAVOID|SCSTART_NOTICKDEF|SCSTART_LOADED|SCSTART_NORATEDEF);
+		status_change_start(nullptr,&sd->bl, (sc_type)data->type, 10000, data->val1, data->val2, data->val3, data->val4, data->tick, SCSTART_NOAVOID|SCSTART_NOTICKDEF|SCSTART_LOADED|SCSTART_NORATEDEF);
 	}
 
 	pc_scdata_received(sd);
@@ -1549,7 +1549,7 @@ void chrif_parse_ack_vipActive(int fd) {
 	TBL_PC *sd = map_id2sd(aid);
 	bool changed = false;
 
-	if(sd == NULL) return;
+	if(sd == nullptr) return;
 
 	sd->group_id = groupid;
 	pc_group_pc_load(sd);
@@ -1633,10 +1633,10 @@ int chrif_bsdata_save(map_session_data *sd, bool quit) {
 
 	if (sd->bonus_script.count) {
 		t_tick tick = gettick();
-		struct linkdb_node *node = NULL;
+		struct linkdb_node *node = nullptr;
 
 		for (node = sd->bonus_script.head; node && i < MAX_PC_BONUS_SCRIPT; node = node->next) {
-			const struct TimerData *timer = NULL;
+			const struct TimerData *timer = nullptr;
 			struct bonus_script_data bs;
 			struct s_bonus_script_entry *entry = (struct s_bonus_script_entry *)node->data;
 
@@ -1690,7 +1690,7 @@ int chrif_bsdata_received(int fd) {
 
 		for (i = 0; i < count; i++) {
 			struct bonus_script_data *bs = (struct bonus_script_data*)RFIFOP(fd,9 + i*sizeof(struct bonus_script_data));
-			struct s_bonus_script_entry *entry = NULL;
+			struct s_bonus_script_entry *entry = nullptr;
 
 			if (bs->script_str[0] == '\0' || !bs->tick)
 				continue;
@@ -1847,7 +1847,7 @@ int send_users_tochar(void) {
  *------------------------------------------*/
 static TIMER_FUNC(check_connect_char_server){
 	static int displayed = 0;
-	if ( char_fd <= 0 || session[char_fd] == NULL ) {
+	if ( char_fd <= 0 || session[char_fd] == nullptr ) {
 		if ( !displayed ) {
 			ShowStatus("Attempting to connect to Char Server. Please wait.\n");
 			displayed = 1;

+ 11 - 11
src/map/clan.cpp

@@ -40,7 +40,7 @@ void clan_load_clandata( int count, struct clan* clans ){
 
 		clanCopy = (struct clan*)aMalloc( sizeof( struct clan ) );
 
-		if( clanCopy == NULL ){
+		if( clanCopy == nullptr ){
 			ShowError("Memory could not be allocated for a clan.\n");
 			break;
 		}
@@ -76,10 +76,10 @@ struct clan* clan_searchname( const char* name ){
 map_session_data* clan_getavailablesd( struct clan* clan ){
 	int i;
 
-	nullpo_retr(NULL, clan);
+	nullpo_retr(nullptr, clan);
 
-	ARR_FIND( 0, clan->max_member, i, clan->members[i] != NULL );
-	return ( i < clan->max_member ) ? clan->members[i] : NULL;
+	ARR_FIND( 0, clan->max_member, i, clan->members[i] != nullptr );
+	return ( i < clan->max_member ) ? clan->members[i] : nullptr;
 }
 
 int clan_getMemberIndex( struct clan* clan, uint32 account_id ){
@@ -87,7 +87,7 @@ int clan_getMemberIndex( struct clan* clan, uint32 account_id ){
 
 	nullpo_retr(-1,clan);
 
-	ARR_FIND( 0, clan->max_member, i, clan->members[i] != NULL && clan->members[i]->status.account_id == account_id );
+	ARR_FIND( 0, clan->max_member, i, clan->members[i] != nullptr && clan->members[i]->status.account_id == account_id );
 
 	if( i == clan->max_member ){
 		return -1;
@@ -101,7 +101,7 @@ int clan_getNextFreeMemberIndex( struct clan* clan ){
 
 	nullpo_retr(-1,clan);
 
-	ARR_FIND( 0, clan->max_member, i, clan->members[i] == NULL );
+	ARR_FIND( 0, clan->max_member, i, clan->members[i] == nullptr );
 
 	if( i == clan->max_member ){
 		return -1;
@@ -144,7 +144,7 @@ void clan_member_left( map_session_data* sd ){
 	nullpo_retv(clan = sd->clan);
 
 	if( ( index = clan_getMemberIndex(clan,sd->status.account_id) ) >= 0 ){
-		clan->members[index] = NULL;
+		clan->members[index] = nullptr;
 		clan->connect_member--;
 
 		intif_clan_member_left(clan->id);
@@ -157,7 +157,7 @@ bool clan_member_join( map_session_data *sd, int clan_id, uint32 account_id, uin
 
 	nullpo_ret(sd);
 
-	if( ( clan = clan_search( clan_id ) ) == NULL ){
+	if( ( clan = clan_search( clan_id ) ) == nullptr ){
 		return false;
 	}
 
@@ -177,13 +177,13 @@ bool clan_member_leave( map_session_data* sd, int clan_id, uint32 account_id, ui
 
 	nullpo_ret(sd);
 
-	if( sd->status.account_id != account_id || sd->status.char_id != char_id || sd->status.clan_id != clan_id || ( clan = sd->clan ) == NULL ){
+	if( sd->status.account_id != account_id || sd->status.char_id != char_id || sd->status.clan_id != clan_id || ( clan = sd->clan ) == nullptr ){
 		return false;
 	}
 
 	clan_member_left(sd);
 
-	sd->clan = NULL;
+	sd->clan = nullptr;
 	sd->status.clan_id = 0;
 
 	clif_clan_leave(sd);
@@ -205,7 +205,7 @@ void clan_send_message( map_session_data *sd, const char *mes, int len ){
 
 	intif_clan_message(sd->status.clan_id,sd->status.account_id,mes,len);
 	clan_recv_message(sd->status.clan_id,sd->status.account_id,mes,len);
-	log_chat( LOG_CHAT_CLAN, sd->status.clan_id, sd->status.char_id, sd->status.account_id, mapindex_id2name( sd->mapindex ), sd->bl.x, sd->bl.y, NULL, mes );
+	log_chat( LOG_CHAT_CLAN, sd->status.clan_id, sd->status.char_id, sd->status.account_id, mapindex_id2name( sd->mapindex ), sd->bl.x, sd->bl.y, nullptr, mes );
 }
 
 int clan_get_alliance_count( struct clan *clan, int flag ){

+ 106 - 106
src/map/clif.cpp

@@ -486,7 +486,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
 {
 	int i;
 	map_session_data *sd, *tsd;
-	struct party_data *p = NULL;
+	struct party_data *p = nullptr;
 	std::shared_ptr<s_battleground_data> bg;
 	int x0 = 0, x1 = 0, y0 = 0, y1 = 0, fd;
 	struct s_mapiterator* iter;
@@ -524,7 +524,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
 
 	case AREA:
 	case AREA_WOSC:
-		if (sd && bl->prev == NULL) //Otherwise source misses the packet.[Skotlex]
+		if (sd && bl->prev == nullptr) //Otherwise source misses the packet.[Skotlex]
 			clif_send (buf, len, bl, SELF);
 		[[fallthrough]];
 	case AREA_WOC:
@@ -546,7 +546,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
 			} else if (bl->type == BL_CHAT) {
 				cd = (struct chat_data*)bl;
 			} else break;
-			if (cd == NULL)
+			if (cd == nullptr)
 				break;
 			for(i = 0; i < cd->users; i++) {
 				if (type == CHAT_WOS && cd->usersd[i] == sd)
@@ -576,7 +576,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target
 
 		if (p) {
 			for(i=0;i<MAX_PARTY;i++){
-				if( (sd = p->data[i].sd) == NULL )
+				if( (sd = p->data[i].sd) == nullptr )
 					continue;
 
 				if( !session_isActive( fd = sd->fd ) )
@@ -858,7 +858,7 @@ void clif_charselectok(int id, uint8 ok)
 	map_session_data* sd;
 	int fd;
 
-	if ((sd = map_id2sd(id)) == NULL || !session_isValid(sd->fd))
+	if ((sd = map_id2sd(id)) == nullptr || !session_isValid(sd->fd))
 		return;
 
 	fd = sd->fd;
@@ -1535,7 +1535,7 @@ void clif_class_change_target(struct block_list *bl,int class_,int type, enum se
 		WBUFL(buf,2)=bl->id;
 		WBUFB(buf,6)=type;
 		WBUFL(buf,7)=class_;
-		clif_send(buf,packet_len(0x1b0),(sd == NULL ? bl : &(sd->bl)),target);
+		clif_send(buf,packet_len(0x1b0),(sd == nullptr ? bl : &(sd->bl)),target);
 	}
 }
 
@@ -1654,7 +1654,7 @@ static void clif_weather_check(map_session_data *sd)
 void clif_weather(int16 m)
 {
 	struct s_mapiterator* iter;
-	map_session_data *sd=NULL;
+	map_session_data *sd=nullptr;
 
 	iter = mapit_getallusers();
 	for( sd = (map_session_data*)mapit_first(iter); mapit_exists(iter); sd = (map_session_data*)mapit_next(iter) )
@@ -1982,7 +1982,7 @@ void clif_walkok(map_session_data *sd)
 
 
 static void clif_move2( struct block_list *bl, struct view_data *vd, struct unit_data *ud ){
-	status_change *sc = NULL;
+	status_change *sc = nullptr;
 
 	if ((sc = status_get_sc(bl)) && sc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_INVISIBLE|OPTION_CHASEWALK))
 		clif_ally_only = true;
@@ -2033,7 +2033,7 @@ void clif_move(struct unit_data *ud)
 	unsigned char buf[16];
 	struct view_data* vd;
 	struct block_list* bl = ud->bl;
-	status_change *sc = NULL;
+	status_change *sc = nullptr;
 
 	vd = status_get_viewdata(bl);
 	if (!vd )
@@ -2083,10 +2083,10 @@ void clif_move(struct unit_data *ud)
  * Delays the map_quit of a player after they are disconnected. [Skotlex]
  *------------------------------------------*/
 static TIMER_FUNC(clif_delayquit){
-	map_session_data *sd = NULL;
+	map_session_data *sd = nullptr;
 
 	//Remove player from map server
-	if ((sd = map_id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player.
+	if ((sd = map_id2sd(id)) != nullptr && sd->fd == 0) //Should be a disconnected player.
 		map_quit(sd);
 	return 0;
 }
@@ -2102,7 +2102,7 @@ void clif_quitsave(int fd,map_session_data *sd) {
 	else if (session_isValid(sd->fd)) {
 		//Disassociate session from player (session is deleted after this function was called)
 		//And set a timer to make him quit later.
-		session[sd->fd]->session_data = NULL;
+		session[sd->fd]->session_data = nullptr;
 		sd->fd = 0;
 		add_timer(gettick() + 10000, clif_delayquit, sd->bl.id, 0);
 	}
@@ -2251,7 +2251,7 @@ void clif_selllist(map_session_data *sd)
 	struct npc_data *nd;
 
 	nullpo_retv(sd);
-	if (!sd->npc_shopid || (nd = map_id2nd(sd->npc_shopid)) == NULL)
+	if (!sd->npc_shopid || (nd = map_id2nd(sd->npc_shopid)) == nullptr)
 		return;
 
 	fd=sd->fd;
@@ -2561,7 +2561,7 @@ void clif_scriptmenu(map_session_data* sd, int npcid, const char* mes)
 	int fd = sd->fd;
 	int16 slen;
 	slen = static_cast<decltype(slen)>( strlen(mes) + 9 );
-	struct block_list *bl = NULL;
+	struct block_list *bl = nullptr;
 
 	if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m ||
 	   bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
@@ -2591,7 +2591,7 @@ void clif_scriptmenu(map_session_data* sd, int npcid, const char* mes)
 void clif_scriptinput(map_session_data *sd, int npcid)
 {
 	int fd;
-	struct block_list *bl = NULL;
+	struct block_list *bl = nullptr;
 
 	nullpo_retv(sd);
 
@@ -2622,7 +2622,7 @@ void clif_scriptinput(map_session_data *sd, int npcid)
 void clif_scriptinputstr(map_session_data *sd, int npcid)
 {
 	int fd;
-	struct block_list *bl = NULL;
+	struct block_list *bl = nullptr;
 
 	nullpo_retv(sd);
 
@@ -3089,7 +3089,7 @@ void clif_inventorylist( map_session_data *sd ){
 /* on 20120925 onwards this is a field on clif_item_equip/normal */
 #if PACKETVER >= 20111122 && PACKETVER < 20120925
 	for( int i = 0; i < MAX_INVENTORY; i++ ){
-		if( sd->inventory.u.items_inventory[i].nameid == 0 || sd->inventory_data[i] == NULL )
+		if( sd->inventory.u.items_inventory[i].nameid == 0 || sd->inventory_data[i] == nullptr )
 			continue;
 
 		if ( sd->inventory.u.items_inventory[i].favorite != 0 )
@@ -3845,7 +3845,7 @@ void clif_updatestatus(map_session_data *sd,int type)
 				struct party_data* p;
 				int i;
 		
-				if( ( p = party_search( sd->status.party_id ) ) != NULL ){
+				if( ( p = party_search( sd->status.party_id ) ) != nullptr ){
 					ARR_FIND(0, MAX_PARTY, i, p->party.member[i].char_id == sd->status.char_id);
 
 					if( i < MAX_PARTY ){
@@ -4506,7 +4506,7 @@ void clif_dispchat(struct chat_data* cd, int fd)
 	unsigned char buf[128];
 	uint8 type;
 
-	if( cd == NULL || cd->owner == NULL )
+	if( cd == nullptr || cd->owner == nullptr )
 		return;
 
 	type = (cd->owner->type == BL_PC ) ? (cd->pub) ? 1 : 0
@@ -4544,7 +4544,7 @@ void clif_changechatstatus(struct chat_data* cd)
 	unsigned char buf[128];
 	uint8 type;
 
-	if( cd == NULL || cd->usersd[0] == NULL )
+	if( cd == nullptr || cd->usersd[0] == nullptr )
 		return;
 
 	type = (cd->owner->type == BL_PC ) ? (cd->pub) ? 1 : 0
@@ -5016,7 +5016,7 @@ static void clif_getareachar_pc(map_session_data* sd,map_session_data* dstsd)
 	int i;
 
 	if( dstsd->chatID ) {
-		struct chat_data *cd = NULL;
+		struct chat_data *cd = nullptr;
 		if( (cd = (struct chat_data*)map_id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd)
 			clif_dispchat(cd,sd->fd);
 	} else if( dstsd->state.vending )
@@ -5051,7 +5051,7 @@ static void clif_getareachar_pc(map_session_data* sd,map_session_data* dstsd)
 	if( i < MAX_DEVOTION )
 		clif_devotion(&dstsd->bl, sd);
 	// display link (dstsd - crusader) to sd
-	if( dstsd->sc.getSCE(SC_DEVOTION) && (d_bl = map_id2bl(dstsd->sc.getSCE(SC_DEVOTION)->val1)) != NULL )
+	if( dstsd->sc.getSCE(SC_DEVOTION) && (d_bl = map_id2bl(dstsd->sc.getSCE(SC_DEVOTION)->val1)) != nullptr )
 		clif_devotion(d_bl, sd);
 }
 
@@ -6551,7 +6551,7 @@ void clif_status_change_sub(struct block_list *bl, int id, int type, int flag, t
  * @param val3
  */
 void clif_status_change(struct block_list *bl, int type, int flag, t_tick tick, int val1, int val2, int val3) {
-	map_session_data *sd = NULL;
+	map_session_data *sd = nullptr;
 
 	if (type == EFST_BLANK)  //It shows nothing on the client...
 		return;
@@ -6617,7 +6617,7 @@ void clif_efst_status_change_sub(struct block_list *tbl, struct block_list *bl,
 	for (i = 0; i < sc_display_count; i++) {
 		enum sc_type type = sc_display[i]->type;
 		status_change *sc = status_get_sc(bl);
-		const struct TimerData *td = (sc && sc->getSCE(type) ? get_timer(sc->getSCE(type)->timer) : NULL);
+		const struct TimerData *td = (sc && sc->getSCE(type) ? get_timer(sc->getSCE(type)->timer) : nullptr);
 		t_tick tick = 0;
 
 		if (td)
@@ -6699,7 +6699,7 @@ void clif_displaymessage(const int fd, const char* mes)
 		message = aStrdup(mes);
 		line = strtok(message, "\n");
 
-		while(line != NULL) {
+		while(line != nullptr) {
 #if PACKETVER == 20141022
 		/** for some reason game client crashes depending on message pattern (only for this packet) **/
 		/** so we redirect to ZC_NPC_CHAT **/
@@ -6725,12 +6725,12 @@ void clif_displaymessage(const int fd, const char* mes)
 			if (len > 0) { // don't send a void message (it's not displaying on the client chat). @help can send void line.
 				WFIFOHEAD(fd, 5 + len);
 				WFIFOW(fd,0) = 0x8e;
-				WFIFOW(fd,2) = 5 + len; // 4 + len + NULL teminate
+				WFIFOW(fd,2) = 5 + len; // 4 + len + nullptr teminate
 				safestrncpy(WFIFOCP(fd,4), line, len + 1);
 				WFIFOSET(fd, 5 + len);
 			}
 #endif
-			line = strtok(NULL, "\n");
+			line = strtok(nullptr, "\n");
 		}
 		aFree(message);
 	}
@@ -7071,7 +7071,7 @@ void clif_wis_message(map_session_data* sd, const char* nick, const char* mes, s
 ///     3 = everyone ignored by target
 void clif_wis_end(int fd, int result)
 {
-	map_session_data *sd = (session_isActive(fd) ? (map_session_data *)session[fd]->session_data : NULL);
+	map_session_data *sd = (session_isActive(fd) ? (map_session_data *)session[fd]->session_data : nullptr);
 #if PACKETVER < 20131223
 	const int cmd = 0x98;
 #else
@@ -7134,7 +7134,7 @@ void clif_use_card(map_session_data *sd,int idx)
 	for(i=c=0;i<MAX_INVENTORY;i++){
 		int j;
 
-		if(sd->inventory_data[i] == NULL)
+		if(sd->inventory_data[i] == nullptr)
 			continue;
 		if(sd->inventory_data[i]->type!=IT_WEAPON && sd->inventory_data[i]->type!=IT_ARMOR)
 			continue;
@@ -7882,7 +7882,7 @@ void clif_vendingreport(map_session_data* sd, int index, int amount, uint32 char
 	WFIFOW(fd,4) = amount;
 #if PACKETVER >= 20141016
 	WFIFOL(fd,6) = char_id;	// GID
-	WFIFOL(fd,10) = (int)time(NULL);	// Date
+	WFIFOL(fd,10) = (int)time(nullptr);	// Date
 	WFIFOL(fd,14) = zeny;		// zeny
 #endif
 	WFIFOSET(fd,packet_len(cmd));
@@ -8366,7 +8366,7 @@ void clif_sendegg(map_session_data *sd)
 	WFIFOHEAD(fd, MAX_INVENTORY * 2 + 4);
 	WFIFOW(fd,0)=0x1a6;
 	for(i=0,n=0;i<MAX_INVENTORY;i++){
-		if(sd->inventory.u.items_inventory[i].nameid == 0 || sd->inventory_data[i] == NULL ||
+		if(sd->inventory.u.items_inventory[i].nameid == 0 || sd->inventory_data[i] == nullptr ||
 		   sd->inventory_data[i]->type != IT_PETEGG ||
 		   sd->inventory.u.items_inventory[i].amount <= 0)
 			continue;
@@ -8592,7 +8592,7 @@ void clif_devotion(struct block_list *src, map_session_data *tsd)
 	{
 		int i;
 		map_session_data *sd = BL_CAST(BL_PC,src);
-		if( sd == NULL )
+		if( sd == nullptr )
 			return;
 
 		for( i = 0; i < 5 /*MAX_DEVOTION*/; i++ ) // Client only able show to 5 links
@@ -8799,14 +8799,14 @@ void clif_guild_memberlogin_notice(const struct mmo_guild &g,int idx,int flag)
 	WBUFL(buf, 6)=g.member[idx].char_id;
 	WBUFL(buf,10)=flag;
 
-	if( ( sd = g.member[idx].sd ) != NULL )
+	if( ( sd = g.member[idx].sd ) != nullptr )
 	{
 		WBUFW(buf,14) = sd->status.sex;
 		WBUFW(buf,16) = sd->status.hair;
 		WBUFW(buf,18) = sd->status.hair_color;
 		clif_send(buf,packet_len(0x1f2),&sd->bl,GUILD_WOS);
 	}
-	else if( ( sd = guild_getavailablesd(g) ) != NULL )
+	else if( ( sd = guild_getavailablesd(g) ) != nullptr )
 	{
 		WBUFW(buf,14) = 0;
 		WBUFW(buf,16) = 0;
@@ -9080,7 +9080,7 @@ void clif_guild_positionchanged(const struct mmo_guild &g,int idx)
 	WBUFL(buf,16)=g.position[idx].exp_mode;
 	safestrncpy(WBUFCP(buf,20),g.position[idx].name,NAME_LENGTH);
 	// }*
-	if( (sd=guild_getavailablesd(g))!=NULL )
+	if( (sd=guild_getavailablesd(g))!=nullptr )
 		clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
 }
 
@@ -9102,7 +9102,7 @@ void clif_guild_memberpositionchanged(const struct mmo_guild &g, int idx)
 	WBUFL(buf, 8)=g.member[idx].char_id;
 	WBUFL(buf,12)=g.member[idx].position;
 	// }*
-	if( (sd=guild_getavailablesd(g))!=NULL )
+	if( (sd=guild_getavailablesd(g))!=nullptr )
 		clif_send(buf,WBUFW(buf,2),&sd->bl,GUILD);
 }
 
@@ -9342,7 +9342,7 @@ void clif_guild_message(const struct mmo_guild &g,uint32 account_id,const char *
 	WBUFW(buf, 2) = len + 5;
 	safestrncpy(WBUFCP(buf,4), mes, len+1);
 
-	if ((sd = guild_getavailablesd(g)) != NULL)
+	if ((sd = guild_getavailablesd(g)) != nullptr)
 		clif_send(buf, WBUFW(buf,2), &sd->bl, GUILD_NOBG);
 }
 
@@ -9627,7 +9627,7 @@ void clif_GM_kick(map_session_data *sd, map_session_data *tsd)
 {
 	nullpo_retv(tsd);
 
-	if (sd == NULL)
+	if (sd == nullptr)
 		tsd->state.keepshop = true;
 
 	if (session_isActive(tsd->fd))
@@ -9877,7 +9877,7 @@ void clif_messagecolor_target(struct block_list *bl, unsigned long color, const
 	WBUFL(buf,8) = color;
 	memcpy(WBUFCP(buf,12), msg, msg_len);
 
-	clif_send(buf, WBUFW(buf,2), (sd == NULL ? bl : &(sd->bl)), type);
+	clif_send(buf, WBUFW(buf,2), (sd == nullptr ? bl : &(sd->bl)), type);
 }
 
 /**
@@ -10436,7 +10436,7 @@ void clif_viewequip_ack( map_session_data* sd, map_session_data* tsd ){
 		int k = tsd->equip_index[i];
 
 		if( k >= 0 ){
-			if( tsd->inventory.u.items_inventory[k].nameid == 0 || tsd->inventory_data[k] == NULL ){ // Item doesn't exist
+			if( tsd->inventory.u.items_inventory[k].nameid == 0 || tsd->inventory_data[k] == nullptr ){ // Item doesn't exist
 				continue;
 			}
 
@@ -10833,7 +10833,7 @@ void clif_parse_LoadEndAck(int fd,map_session_data *sd)
 {
 	bool guild_notice = false;
 
-	if(sd->bl.prev != NULL)
+	if(sd->bl.prev != nullptr)
 		return;
 
 	// Autotraders should ignore this entirely, clif_parse_LoadEndAck is always invoked manually for them
@@ -11230,7 +11230,7 @@ void clif_parse_LoadEndAck(int fd,map_session_data *sd)
 
 #if PACKETVER >= 20150513
 	if( sd->mail.inbox.unread ){
-		clif_Mail_new(sd, 0, NULL, NULL);
+		clif_Mail_new(sd, 0, nullptr, nullptr);
 	}
 #endif
 
@@ -11451,7 +11451,7 @@ void clif_parse_WalkToXY(int fd, map_session_data *sd)
 	if(sd->sc.getSCE(SC_RUN) || sd->sc.getSCE(SC_WUGDASH))
 		return;
 
-	RFIFOPOS(fd, packet_db[RFIFOW(fd,0)].pos[0], &x, &y, NULL);
+	RFIFOPOS(fd, packet_db[RFIFOW(fd,0)].pos[0], &x, &y, nullptr);
 
 	//A move command one cell west is only valid if the target cell is free
 	if(battle_config.official_cell_stack_limit > 0
@@ -11532,7 +11532,7 @@ void clif_parse_GetCharNameRequest(int fd, map_session_data *sd)
 		id = sd->bl.id;
 
 	bl = map_id2bl(id);
-	if( bl == NULL )
+	if( bl == nullptr )
 		return;	// Lagged clients could request names of already gone mobs/players. [Skotlex]
 
 	if( sd->bl.m != bl->m || !check_distance_bl(&sd->bl, bl, AREA_SIZE) )
@@ -11593,7 +11593,7 @@ void clif_parse_GlobalMessage(int fd, map_session_data* sd)
 #endif
 
 	// Chat logging type 'O' / Global Chat
-	log_chat(LOG_CHAT_GLOBAL, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message);
+	log_chat(LOG_CHAT_GLOBAL, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, nullptr, message);
 	//achievement_update_objective(sd, AG_CHAT, 1, sd->bl.m); //! TODO: What's the official use of this achievement type?
 }
 
@@ -11684,12 +11684,12 @@ void clif_parse_Emotion(int fd, map_session_data *sd){
 			return;
 		}
 		// fix flood of emotion icon (ro-proxy): flood only the hacker player
-		if (sd->emotionlasttime + 1 >= time(NULL)) { // not more than 1 per second
-			sd->emotionlasttime = time(NULL);
+		if (sd->emotionlasttime + 1 >= time(nullptr)) { // not more than 1 per second
+			sd->emotionlasttime = time(nullptr);
 			clif_skill_fail( *sd, 1, USESKILL_FAIL_LEVEL, 1 );
 			return;
 		}
-		sd->emotionlasttime = time(NULL);
+		sd->emotionlasttime = time(nullptr);
 
 		if (battle_config.idletime_option&IDLE_EMOTION)
 			sd->idletime = last_tick;
@@ -11927,7 +11927,7 @@ void clif_parse_WisMessage(int fd, map_session_data* sd)
 				str += 3;
 			for( i = 0; i < NUM_WHISPER_VAR; ++i ) {// Splits the message using '#' as separators
 				split = strchr(str,'#');
-				if( split == NULL ) { // use the remaining string
+				if( split == nullptr ) { // use the remaining string
 					safestrncpy(split_data[i], str, ARRAYLENGTH(split_data[i]));
 					for( ++i; i < NUM_WHISPER_VAR; ++i )
 						split_data[i][0] = '\0';
@@ -11950,7 +11950,7 @@ void clif_parse_WisMessage(int fd, map_session_data* sd)
 			return;
 		}
 	} else if( target[0] == '#' ) {
-		struct Channel *channel = NULL;
+		struct Channel *channel = nullptr;
 		char* chname = target;
 
 		channel = channel_name2channel(chname,sd,3);
@@ -11972,7 +11972,7 @@ void clif_parse_WisMessage(int fd, map_session_data* sd)
 	// searching destination character
 	dstsd = map_nick2sd(target,false);
 
-	if (dstsd == NULL || strcmp(dstsd->status.name, target) != 0) {
+	if (dstsd == nullptr || strcmp(dstsd->status.name, target) != 0) {
 		// player is not on this map-server
 		// At this point, don't send wisp/page if it's not exactly the same name, because (example)
 		// if there are 'Test' player on an other map-server and 'test' player on this map-server,
@@ -12051,7 +12051,7 @@ void clif_parse_TakeItem(int fd, map_session_data *sd)
 			break;
 		}
 
-		if (fitem == NULL || fitem->bl.type != BL_ITEM || fitem->bl.m != sd->bl.m)
+		if (fitem == nullptr || fitem->bl.type != BL_ITEM || fitem->bl.m != sd->bl.m)
 			break;
 
 		if (pc_cant_act(sd))
@@ -13348,7 +13348,7 @@ void clif_parse_NpcSelectMenu(int fd,map_session_data *sd){
 	if( (select > sd->npc_menu && select != 0xff) || select == 0 ) {
 			TBL_NPC* nd = map_id2nd(npc_id);
 			ShowWarning("Invalid menu selection on npc %d:'%s' - got %d, valid range is [%d..%d] (player AID:%d, CID:%d, name:'%s')!\n", npc_id, (nd)?nd->name:"invalid npc id", select, 1, sd->npc_menu, sd->bl.id, sd->status.char_id, sd->status.name);
-			clif_GM_kick(NULL,sd);
+			clif_GM_kick(nullptr,sd);
 		return;
 	}
 
@@ -13446,7 +13446,7 @@ void clif_parse_ItemIdentify(int fd,map_session_data *sd) {
 	// - Invalid item ID or item doesn't exist
 	// - Item is already identified
 	if (idx < 0 || idx >= MAX_INVENTORY ||
-		sd->inventory.u.items_inventory[idx].nameid == 0 || sd->inventory_data[idx] == NULL ||
+		sd->inventory.u.items_inventory[idx].nameid == 0 || sd->inventory_data[idx] == nullptr ||
 		sd->inventory.u.items_inventory[idx].identify) {// cancel pressed
 			sd->state.workinprogress = WIP_DISABLE_NONE;
 			clif_menuskill_clear(sd);
@@ -13904,7 +13904,7 @@ void clif_parse_PartyChangeOption(int fd, map_session_data *sd)
 		return;
 
 	p = party_search(sd->status.party_id);
-	if( p == NULL )
+	if( p == nullptr )
 		return;
 	ARR_FIND( 0, MAX_PARTY, i, p->data[i].sd == sd );
 	if( i == MAX_PARTY )
@@ -13939,7 +13939,7 @@ void clif_parse_PartyMessage(int fd, map_session_data* sd){
 /// Changes Party Leader (CZ_CHANGE_GROUP_MASTER).
 /// 07da <account id>.L
 void clif_parse_PartyChangeLeader(int fd, map_session_data* sd){
-	party_changeleader(sd, map_id2sd(RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0])),NULL);
+	party_changeleader(sd, map_id2sd(RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0])),nullptr);
 }
 
 
@@ -14072,7 +14072,7 @@ void clif_PartyBookingInsertNotify(map_session_data* sd, struct party_booking_ad
 	int i;
 	uint8 buf[38+MAX_PARTY_BOOKING_JOBS*2];
 
-	if(pb_ad == NULL) return;
+	if(pb_ad == nullptr) return;
 
 	WBUFW(buf,0) = 0x809;
 	WBUFL(buf,2) = pb_ad->index;
@@ -14094,7 +14094,7 @@ void clif_PartyBookingUpdateNotify(map_session_data* sd, struct party_booking_ad
 	int i;
 	uint8 buf[6+MAX_PARTY_BOOKING_JOBS*2];
 
-	if(pb_ad == NULL) return;
+	if(pb_ad == nullptr) return;
 
 	WBUFW(buf,0) = 0x80a;
 	WBUFL(buf,2) = pb_ad->index;
@@ -14207,7 +14207,7 @@ void clif_parse_OpenVending(int fd, map_session_data* sd){
 	if( message[0] == '\0' ) // invalid input
 		return;
 
-	vending_openvending(*sd, message, data, len/8, NULL);
+	vending_openvending(*sd, message, data, len/8, nullptr);
 }
 
 
@@ -14469,7 +14469,7 @@ void clif_parse_GuildChangeNotice(int fd, map_session_data* sd){
 // Helper function for guild invite functions
 int clif_sub_guild_invite(int fd, map_session_data *sd, map_session_data *t_sd)
 {
-	if (t_sd == NULL) // not online or does not exist
+	if (t_sd == nullptr) // not online or does not exist
 		return 1;
 
 	if (map_getmapflag(sd->bl.m, MF_GUILDLOCK)) {//Guild locked.
@@ -14850,7 +14850,7 @@ void clif_parse_GMRemove2(int fd, map_session_data* sd)
 	map_session_data* pl_sd;
 
 	account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
-	if( (pl_sd = map_id2sd(account_id)) != NULL ) {
+	if( (pl_sd = map_id2sd(account_id)) != nullptr ) {
 		char command[NAME_LENGTH+8];
 		safesnprintf(command,sizeof(command),"%cjumpto %s", atcommand_symbol, pl_sd->status.name);
 		is_atcommand(fd, sd, command, 1);
@@ -14887,7 +14887,7 @@ void clif_parse_GMRecall2(int fd, map_session_data* sd)
 	map_session_data* pl_sd;
 
 	account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]);
-	if( (pl_sd = map_id2sd(account_id)) != NULL ) {
+	if( (pl_sd = map_id2sd(account_id)) != nullptr ) {
 		char command[NAME_LENGTH+8];
 		safesnprintf(command,sizeof(command),"%crecall %s", atcommand_symbol, pl_sd->status.name);
 		is_atcommand(fd, sd, command, 1);
@@ -15010,7 +15010,7 @@ void clif_parse_GMReqNoChat(int fd,map_session_data *sd)
 		return;
 
 	dstsd = map_id2sd(id);
-	if( dstsd == NULL )
+	if( dstsd == nullptr )
 		return;
 
 	safesnprintf(command,sizeof(command),"%cmute %d %s", atcommand_symbol, value, dstsd->status.name);
@@ -15375,7 +15375,7 @@ void clif_parse_FriendsListAdd(int fd, map_session_data *sd)
 	f_sd = map_nick2sd(RFIFOCP(fd,packet_db[RFIFOW(fd,0)].pos[0]),false);
 
 	// Friend doesn't exist (no player with this name)
-	if (f_sd == NULL) {
+	if (f_sd == nullptr) {
 		clif_displaymessage(fd, msg_txt(sd,3));
 		return;
 	}
@@ -15439,7 +15439,7 @@ void clif_parse_FriendsListReply(int fd, map_session_data *sd)
 	}
 
 	f_sd = map_id2sd(account_id); //The account id is the same as the bl.id of players.
-	if (f_sd == NULL)
+	if (f_sd == nullptr)
 		return;
 
 	if (reply == 0 || !( sd->friend_req == f_sd->status.char_id && f_sd->friend_req == sd->status.char_id ) )
@@ -15490,7 +15490,7 @@ void clif_parse_FriendsListReply(int fd, map_session_data *sd)
 /// 0203 <account id>.L <char id>.L
 void clif_parse_FriendsListRemove(int fd, map_session_data *sd)
 {
-	map_session_data *f_sd = NULL;
+	map_session_data *f_sd = nullptr;
 	uint32 account_id, char_id;
 	int i, j;
 	struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
@@ -15633,8 +15633,8 @@ void clif_parse_ChangeHomunculusName(int fd, map_session_data *sd){
 /// 0234 <id>.L
 void clif_parse_HomMoveToMaster(int fd, map_session_data *sd){
 	int id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); // Mercenary or Homunculus
-	struct block_list *bl = NULL;
-	struct unit_data *ud = NULL;
+	struct block_list *bl = nullptr;
+	struct unit_data *ud = nullptr;
 
 	if( sd->md && sd->md->bl.id == id )
 		bl = &sd->md->bl;
@@ -15654,10 +15654,10 @@ void clif_parse_HomMoveToMaster(int fd, map_session_data *sd){
 void clif_parse_HomMoveTo(int fd, map_session_data *sd){
 	struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
 	int id = RFIFOL(fd,info->pos[0]); // Mercenary or Homunculus
-	struct block_list *bl = NULL;
+	struct block_list *bl = nullptr;
 	short x, y;
 
-	RFIFOPOS(fd, info->pos[1], &x, &y, NULL);
+	RFIFOPOS(fd, info->pos[1], &x, &y, nullptr);
 
 	if( sd->md && sd->md->bl.id == id )
 		bl = &sd->md->bl; // Moving Mercenary
@@ -15676,7 +15676,7 @@ void clif_parse_HomMoveTo(int fd, map_session_data *sd){
 ///     always 0
 void clif_parse_HomAttack(int fd,map_session_data *sd)
 {
-	struct block_list *bl = NULL;
+	struct block_list *bl = nullptr;
 	struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
 	int id = RFIFOL(fd,info->pos[0]);
 	int target_id = RFIFOL(fd,info->pos[1]);
@@ -15774,7 +15774,7 @@ void clif_parse_Check(int fd, map_session_data *sd)
 
 	safestrncpy(charname, RFIFOCP(fd,packet_db[RFIFOW(fd,0)].pos[0]), sizeof(charname));
 
-	if( ( pl_sd = map_nick2sd(charname,false) ) == NULL || pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
+	if( ( pl_sd = map_nick2sd(charname,false) ) == nullptr || pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
 	{
 		return;
 	}
@@ -16039,7 +16039,7 @@ void clif_Mail_refreshinbox(map_session_data *sd,enum mail_inbox_type type,int64
 	struct mail_message *msg;
 	int i, j, k, offset, titleLength;
 	uint8 mailType, amount, remaining;
-	uint32 now = (uint32)time(NULL);
+	uint32 now = (uint32)time(nullptr);
 #if PACKETVER >= 20170419
 	int cmd = 0xac2;
 #elif PACKETVER >= 20160601
@@ -16615,7 +16615,7 @@ void clif_parse_Mail_delete(int fd, map_session_data *sd){
 
 		if( intif_Mail_delete(sd->status.char_id, mail_id) && msg->status == MAIL_UNREAD ){
 			sd->mail.inbox.unread--;
-			clif_Mail_new(sd,0,NULL,NULL);
+			clif_Mail_new(sd,0,nullptr,nullptr);
 		}
 	}
 }
@@ -17546,7 +17546,7 @@ void clif_parse_Adopt_reply(int fd, map_session_data *sd){
 	int pid = sd->adopt_invite;
 	sd->adopt_invite = 0;
 
-	if( p1_sd == NULL || p2_sd == NULL )
+	if( p1_sd == nullptr || p2_sd == nullptr )
 		return; // Both players need to be online
 
 	if( pid != p1_sd->status.account_id )
@@ -18121,7 +18121,7 @@ void clif_mercenary_updatestatus(map_session_data *sd, int type)
 	s_mercenary_data *md;
 	struct status_data *status;
 	int fd;
-	if( !clif_session_isValid(sd) || (md = sd->md) == NULL )
+	if( !clif_session_isValid(sd) || (md = sd->md) == nullptr )
 		return;
 
 	fd = sd->fd;
@@ -18191,7 +18191,7 @@ void clif_mercenary_info(map_session_data *sd)
 	struct status_data *status;
 	int atk;
 
-	if( !clif_session_isValid(sd) || (md = sd->md) == NULL )
+	if( !clif_session_isValid(sd) || (md = sd->md) == nullptr )
 		return;
 
 	fd = sd->fd;
@@ -18217,7 +18217,7 @@ void clif_mercenary_info(map_session_data *sd)
 	WFIFOL(fd,52) = status->max_hp;
 	WFIFOL(fd,56) = status->sp;
 	WFIFOL(fd,60) = status->max_sp;
-	WFIFOL(fd,64) = client_tick(time(NULL) + (mercenary_get_lifetime(md) / 1000));
+	WFIFOL(fd,64) = client_tick(time(nullptr) + (mercenary_get_lifetime(md) / 1000));
 	WFIFOW(fd,68) = mercenary_get_faith(md);
 	WFIFOL(fd,70) = mercenary_get_calls(md);
 	WFIFOL(fd,74) = md->mercenary.kill_count;
@@ -18233,7 +18233,7 @@ void clif_mercenary_skillblock(map_session_data *sd)
 	s_mercenary_data *md;
 	int fd, len = 4;
 
-	if( sd == NULL || (md = sd->md) == NULL )
+	if( sd == nullptr || (md = sd->md) == nullptr )
 		return;
 
 	fd = sd->fd;
@@ -18269,7 +18269,7 @@ void clif_mercenary_skillblock(map_session_data *sd)
 void clif_parse_mercenary_action(int fd, map_session_data* sd)
 {
 	int option = RFIFOB(fd,packet_db[RFIFOW(fd,0)].pos[0]);
-	if( sd->md == NULL )
+	if( sd->md == nullptr )
 		return;
 
 	if( option == 2 ) mercenary_delete(sd->md, 2);
@@ -18708,7 +18708,7 @@ void clif_font(map_session_data *sd)
 void clif_instance_create(int instance_id, int num)
 {
 #if PACKETVER >= 20071128
-	map_session_data *sd = NULL;
+	map_session_data *sd = nullptr;
 	enum send_target target = PARTY;
 	unsigned char buf[65];
 
@@ -18736,7 +18736,7 @@ void clif_instance_create(int instance_id, int num)
 void clif_instance_changewait(int instance_id, int num)
 {
 #if PACKETVER >= 20071128
-	map_session_data *sd = NULL;
+	map_session_data *sd = nullptr;
 	enum send_target target = PARTY;
 	unsigned char buf[4];
 
@@ -18758,7 +18758,7 @@ void clif_instance_changewait(int instance_id, int num)
 void clif_instance_status(int instance_id, unsigned int limit1, unsigned int limit2)
 {
 #if PACKETVER >= 20071128
-	map_session_data *sd = NULL;
+	map_session_data *sd = nullptr;
 	enum send_target target = PARTY;
 	unsigned char buf[71];
 
@@ -18792,7 +18792,7 @@ void clif_instance_status(int instance_id, unsigned int limit1, unsigned int lim
 void clif_instance_changestatus(int instance_id, e_instance_notify type, unsigned int limit)
 {
 #if PACKETVER >= 20071128
-	map_session_data *sd = NULL;
+	map_session_data *sd = nullptr;
 	enum send_target target = PARTY;
 	unsigned char buf[10];
 
@@ -19003,7 +19003,7 @@ void clif_elemental_updatestatus(map_session_data *sd, int type) {
 	struct status_data *status;
 	int fd;
 
-	if( !clif_session_isValid(sd) || (ed = sd->ed) == NULL )
+	if( !clif_session_isValid(sd) || (ed = sd->ed) == nullptr )
 		return;
 
 	fd = sd->fd;
@@ -19033,7 +19033,7 @@ void clif_elemental_info(map_session_data *sd) {
 	s_elemental_data *ed;
 	struct status_data *status;
 
-	if( !clif_session_isValid(sd) || (ed = sd->ed) == NULL )
+	if( !clif_session_isValid(sd) || (ed = sd->ed) == nullptr )
 		return;
 
 	fd = sd->fd;
@@ -19102,7 +19102,7 @@ static void clif_parse_ReqOpenBuyingStore( int fd, map_session_data* sd ){
 		return;
 	}
 
-	buyingstore_create( sd, p->zenyLimit, p->result, storename, p->items, packet_len / sizeof( struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub ), NULL );
+	buyingstore_create( sd, p->zenyLimit, p->result, storename, p->items, packet_len / sizeof( struct PACKET_CZ_REQ_OPEN_BUYING_STORE_sub ), nullptr );
 }
 
 
@@ -19305,7 +19305,7 @@ void clif_buyingstore_update_item( map_session_data* sd, t_itemid nameid, unsign
 #if PACKETVER >= 20141016
 	p.zeny = zeny;
 	p.charId = char_id;  // GID
-	p.updateTime = (int)time(NULL);
+	p.updateTime = (int)time(nullptr);
 #endif
 
 	clif_send( &p, sizeof( p ), &sd->bl, SELF );
@@ -19922,7 +19922,7 @@ void clif_sub_ranklist(unsigned char *buf,int idx,map_session_data* sd, enum e_r
 		case RANK_ALCHEMIST:	list = chemist_fame_list; break;
 		case RANK_TAEKWON:		list = taekwon_fame_list; break;
 		// PK currently unsupported
-		case RANK_KILLER:		list = NULL; size = 0; break;
+		case RANK_KILLER:		list = nullptr; size = 0; break;
 		default:
 			ShowError( "clif_sub_ranklist: Unsupported ranking type '%d'. Please report this.\n", rankingtype );
 			return;
@@ -19933,7 +19933,7 @@ void clif_sub_ranklist(unsigned char *buf,int idx,map_session_data* sd, enum e_r
 		if (list[i].id > 0) {
 			const char* name;
 			if (strcmp(list[i].name, "-") == 0 &&
-				(name = map_charid2nick(list[i].id)) != NULL)
+				(name = map_charid2nick(list[i].id)) != nullptr)
 			{
 				safestrncpy(WBUFCP(buf,idx + NAME_LENGTH * i), name, NAME_LENGTH);
 			} else {
@@ -20359,7 +20359,7 @@ void clif_clan_message(struct clan *clan,const char *mes,int len){
 	//safestrncpy(WBUFCP(buf,4), sendername, NAME_LENGTH);
 	safestrncpy(WBUFCP(buf,4+NAME_LENGTH), mes, len+1);
 
-	if((sd = clan_getavailablesd(clan)) != NULL)
+	if((sd = clan_getavailablesd(clan)) != nullptr)
 		clif_send(buf, WBUFW(buf,2), &sd->bl, CLAN);
 #endif
 }
@@ -20447,7 +20447,7 @@ void clif_clan_onlinecount( struct clan* clan ){
 	WBUFW(buf,2) = clan->connect_member;
 	WBUFW(buf,4) = clan->max_member;
 
-	if((sd = clan_getavailablesd(clan)) != NULL)
+	if((sd = clan_getavailablesd(clan)) != nullptr)
 		clif_send(buf, 6, &sd->bl, CLAN);
 #endif
 }
@@ -20542,7 +20542,7 @@ void DumpUnknown(int fd,TBL_PC *sd,int cmd,int packet_len)
 	strftime(datestr, sizeof(datestr)-1, "%A, %B %d %Y %X.", datetime); // Server time (normal time): %A, %B %d %Y %X.
 
 
-	if( ( fp = fopen( packet_txt , "a" ) ) != NULL ) {
+	if( ( fp = fopen( packet_txt , "a" ) ) != nullptr ) {
 		if( sd ) {
 			fprintf(fp, "Unknown packet 0x%04X (length %d), %s session #%d, %d/%d (AID/CID) at %s \n", cmd, packet_len, sd->state.active ? "authed" : "unauthed", fd, sd->status.account_id, sd->status.char_id,datestr);
 		} else {
@@ -21151,7 +21151,7 @@ void clif_broadcast_obtain_special_item( const char *char_name, t_itemid nameid,
 				p.PacketLength = 8 + p.len + p.monsterNameLen;
 #endif
 
-				clif_send( &p, p.PacketLength, NULL, ALL_CLIENT );
+				clif_send( &p, p.PacketLength, nullptr, ALL_CLIENT );
 			}
 			break;
 	}
@@ -21185,7 +21185,7 @@ void clif_parse_Oneclick_Itemidentify(int fd, map_session_data *sd) {
 	// - Invalid item ID or item doesn't exist
 	// - Item is already identified
 	if (idx < 0 || idx >= MAX_INVENTORY ||
-		sd->inventory.u.items_inventory[idx].nameid == 0 || sd->inventory_data[idx] == NULL ||
+		sd->inventory.u.items_inventory[idx].nameid == 0 || sd->inventory_data[idx] == nullptr ||
 		sd->inventory.u.items_inventory[idx].identify)
 			return;
 
@@ -21299,7 +21299,7 @@ void clif_sale_start( struct sale_item_data* sale_item, struct block_list* bl, e
 
 	p.packetType = HEADER_ZC_NOTIFY_BARGAIN_SALE_SELLING;
 	p.itemId = client_nameid( sale_item->nameid );
-	p.remainingTime = (uint32)(sale_item->end - time(NULL)); // time in S
+	p.remainingTime = (uint32)(sale_item->end - time(nullptr)); // time in S
 
 	clif_send( &p, sizeof( p ), bl, target );
 #endif
@@ -21346,7 +21346,7 @@ void clif_parse_sale_refresh( int fd, map_session_data* sd ){
 
 	sale = sale_find_item( p->itemId, true );
 
-	if( sale == NULL ){
+	if( sale == nullptr ){
 		return;
 	}
 
@@ -21435,7 +21435,7 @@ void clif_sale_search_reply( map_session_data* sd, std::shared_ptr<s_cash_item>
 
 	p.packetType = HEADER_ZC_ACK_CASH_BARGAIN_SALE_ITEM_INFO;
 
-	if( item != NULL ){
+	if( item != nullptr ){
 		p.result = 0;
 		p.itemId = client_nameid( item->nameid );
 		p.price = item->price;
@@ -22308,7 +22308,7 @@ void clif_refineui_info( map_session_data* sd, uint16 index ){
 	struct item_data* id = sd->inventory_data[index];
 
 	// No item data was found
-	if( id == NULL ){
+	if( id == nullptr ){
 		return;
 	}
 
@@ -22316,7 +22316,7 @@ void clif_refineui_info( map_session_data* sd, uint16 index ){
 	struct item* item = &sd->inventory.u.items_inventory[index];
 
 	// No item was found at the given index
-	if( item == NULL ){
+	if( item == nullptr ){
 		return;
 	}
 
@@ -22414,7 +22414,7 @@ void clif_parse_refineui_refine( int fd, map_session_data* sd ){
 	struct item_data* id = sd->inventory_data[index];
 
 	// No item data was found
-	if( id == NULL ){
+	if( id == nullptr ){
 		return;
 	}
 
@@ -22422,7 +22422,7 @@ void clif_parse_refineui_refine( int fd, map_session_data* sd ){
 	struct item* item = &sd->inventory.u.items_inventory[index];
 
 	// No item was found at the given index
-	if( item == NULL ){
+	if( item == nullptr ){
 		return;
 	}
 
@@ -25304,7 +25304,7 @@ static int clif_parse(int fd)
 		if (sd) {
 			if (sd->state.autotrade) {
 				//Disassociate character from the socket connection.
-				session[fd]->session_data = NULL;
+				session[fd]->session_data = nullptr;
 				sd->fd = 0;
 				ShowInfo("Character '" CL_WHITE "%s" CL_RESET "' logged off (using @autotrade).\n", sd->status.name);
 			} else
@@ -25318,7 +25318,7 @@ static int clif_parse(int fd)
 				map_quit(sd);
 			}
 		} else {
-			ShowInfo("Closed connection from '" CL_WHITE "%s" CL_RESET "'.\n", ip2str(session[fd]->client_addr, NULL));
+			ShowInfo("Closed connection from '" CL_WHITE "%s" CL_RESET "'.\n", ip2str(session[fd]->client_addr, nullptr));
 		}
 		do_close(fd);
 		return 0;
@@ -25406,11 +25406,11 @@ static int clif_parse(int fd)
 
 	if( packet_db[cmd].func == clif_parse_debug )
 		packet_db[cmd].func(fd, sd);
-	else if( packet_db[cmd].func != NULL ) {
+	else if( packet_db[cmd].func != nullptr ) {
 		if( !sd && packet_db[cmd].func != clif_parse_WantToConnection )
 			; //Only valid packet when there is no session
 		else
-		if( sd && sd->bl.prev == NULL && packet_db[cmd].func != clif_parse_LoadEndAck )
+		if( sd && sd->bl.prev == nullptr && packet_db[cmd].func != clif_parse_LoadEndAck )
 			; //Only valid packet when player is not on a map
 		else
 			packet_db[cmd].func(fd, sd);

+ 6 - 6
src/map/clif.hpp

@@ -679,7 +679,7 @@ void clif_equipitemack( map_session_data& sd, uint8 flag, int index, int pos = 0
 void clif_unequipitemack(map_session_data *sd,int n,int pos,int ok);	// self
 void clif_misceffect(struct block_list* bl,int type);	// area
 void clif_changeoption_target(struct block_list* bl, struct block_list* target);
-#define clif_changeoption(bl) clif_changeoption_target(bl, NULL)	// area
+#define clif_changeoption(bl) clif_changeoption_target(bl, nullptr)	// area
 void clif_changeoption2(struct block_list* bl);	// area
 void clif_useitemack(map_session_data *sd,int index,int amount,bool ok);	// self
 void clif_GlobalMessage(struct block_list* bl, const char* message,enum send_target target);
@@ -727,7 +727,7 @@ int clif_insight(struct block_list *bl,va_list ap);	// map_forallinmovearea call
 int clif_outsight(struct block_list *bl,va_list ap);	// map_forallinmovearea callback
 
 void clif_class_change_target(struct block_list *bl,int class_, int type, enum send_target target, map_session_data *sd);
-#define clif_class_change(bl, class_, type) clif_class_change_target(bl, class_, type, AREA, NULL)
+#define clif_class_change(bl, class_, type) clif_class_change_target(bl, class_, type, AREA, nullptr)
 #define clif_mob_class_change(md, class_) clif_class_change(&md->bl, class_, 1)
 
 void clif_skillinfoblock(map_session_data *sd);
@@ -918,8 +918,8 @@ void clif_sendegg(map_session_data *sd);
 void clif_send_petstatus(map_session_data *sd);
 void clif_send_petdata(map_session_data* sd, struct pet_data* pd, int type, int param);
 #define clif_pet_equip(sd, pd) clif_send_petdata(sd, pd, 3, (pd)->vd.head_bottom)
-#define clif_pet_equip_area(pd) clif_send_petdata(NULL, pd, 3, (pd)->vd.head_bottom)
-#define clif_pet_performance(pd, param) clif_send_petdata(NULL, pd, 4, param)
+#define clif_pet_equip_area(pd) clif_send_petdata(nullptr, pd, 3, (pd)->vd.head_bottom)
+#define clif_pet_performance(pd, param) clif_send_petdata(nullptr, pd, 4, param)
 void clif_pet_emotion(struct pet_data *pd,int param);
 void clif_pet_food(map_session_data *sd,int foodid,int fail);
 void clif_pet_autofeed_status(map_session_data* sd, bool force);
@@ -934,7 +934,7 @@ void clif_specialeffect(struct block_list* bl, int type, enum send_target target
 void clif_specialeffect_single(struct block_list* bl, int type, int fd);
 void clif_specialeffect_remove(struct block_list* bl_src, int effect, enum send_target e_target, struct block_list* bl_target);
 void clif_messagecolor_target(struct block_list *bl, unsigned long color, const char *msg, bool rgb2bgr, enum send_target type, map_session_data *sd);
-#define clif_messagecolor(bl, color, msg, rgb2bgr, type) clif_messagecolor_target(bl, color, msg, rgb2bgr, type, NULL) // Mob/Npc color talk [SnakeDrak]
+#define clif_messagecolor(bl, color, msg, rgb2bgr, type) clif_messagecolor_target(bl, color, msg, rgb2bgr, type, nullptr) // Mob/Npc color talk [SnakeDrak]
 void clif_specialeffect_value(struct block_list* bl, int effect_id, int num, send_target target);
 
 void clif_GM_kickack(map_session_data *sd, int id);
@@ -1040,7 +1040,7 @@ void clif_party_show_picker(map_session_data * sd, struct item * item_data);
 void clif_progressbar(map_session_data * sd, unsigned long color, unsigned int 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),NULL)
+#define clif_progressbar_npc_area(nd) clif_progressbar_npc((nd),nullptr)
 
 void clif_PartyBookingRegisterAck(map_session_data *sd, int flag);
 void clif_PartyBookingDeleteAck(map_session_data* sd, int flag);

+ 5 - 5
src/map/clif_packetdb.hpp

@@ -4,7 +4,7 @@
 #ifndef CLIF_PACKETDB_HPP
 #define CLIF_PACKETDB_HPP
 
-	#define packet(cmd,length) packetdb_addpacket(cmd,length,NULL,0)
+	#define packet(cmd,length) packetdb_addpacket(cmd,length,nullptr,0)
 	#define parseable_packet(cmd,length,func,...) packetdb_addpacket(cmd,length,func,__VA_ARGS__,0)
 
 	packet(0x0064,55);
@@ -1880,19 +1880,19 @@
 	packet(0x08ec,73);
 	packet(0x08ed,43);
 	packet(0x08ee,6);
-	parseable_packet(0x08ef,6,NULL,2);
+	parseable_packet(0x08ef,6,nullptr,2);
 	packet(0x08f0,6);
-	parseable_packet(0x08f1,6,NULL,2);
+	parseable_packet(0x08f1,6,nullptr,2);
 	packet(0x08f2,36);
 	packet(0x08f3,-1);
 	packet(0x08f4,6);
-	parseable_packet(0x08f5,-1,NULL,2,4);
+	parseable_packet(0x08f5,-1,nullptr,2,4);
 	packet(0x08f6,22);
 	packet(0x08f7,3);
 	packet(0x08f8,7);
 	packet(0x08f9,6);
 	packet(0x08fa,6);
-	parseable_packet(0x08fb,6,NULL,2);
+	parseable_packet(0x08fb,6,nullptr,2);
 	parseable_packet( HEADER_CZ_INVENTORY_TAB, sizeof( PACKET_CZ_INVENTORY_TAB ), clif_parse_MoveItem, 0 );
 	parseable_packet(0x08D7,28,clif_parse_bg_queue_apply_request,2,4);
 	packet(0x08D8,27);

文件差異過大導致無法顯示
+ 129 - 129
src/map/clif_shuffle.hpp


+ 8 - 8
src/map/date.cpp

@@ -12,7 +12,7 @@ int date_get_year(void)
 {
 	time_t t;
 	struct tm * lt;
-	t = time(NULL);
+	t = time(nullptr);
 	lt = localtime(&t);
 	return lt->tm_year+1900;
 }
@@ -24,7 +24,7 @@ enum e_month date_get_month(void)
 {
 	time_t t;
 	struct tm * lt;
-	t = time(NULL);
+	t = time(nullptr);
 	lt = localtime(&t);
 	return (enum e_month)(lt->tm_mon+1);
 }
@@ -36,7 +36,7 @@ int date_get_dayofmonth(void)
 {
 	time_t t;
 	struct tm * lt;
-	t = time(NULL);
+	t = time(nullptr);
 	lt = localtime(&t);
 	return lt->tm_mday;
 }
@@ -48,7 +48,7 @@ enum e_dayofweek date_get_dayofweek(void)
 {
 	time_t t;
 	struct tm * lt;
-	t = time(NULL);
+	t = time(nullptr);
 	lt = localtime(&t);
 	return (enum e_dayofweek)lt->tm_wday;
 }
@@ -60,7 +60,7 @@ int date_get_dayofyear(void)
 {
 	time_t t;
 	struct tm * lt;
-	t = time(NULL);
+	t = time(nullptr);
 	lt = localtime(&t);
 	return lt->tm_yday;
 }
@@ -72,7 +72,7 @@ int date_get_hour(void)
 {
 	time_t t;
 	struct tm * lt;
-	t = time(NULL);
+	t = time(nullptr);
 	lt = localtime(&t);
 	return lt->tm_hour;
 }
@@ -84,7 +84,7 @@ int date_get_min(void)
 {
 	time_t t;
 	struct tm * lt;
-	t = time(NULL);
+	t = time(nullptr);
 	lt = localtime(&t);
 	return lt->tm_min;
 }
@@ -96,7 +96,7 @@ int date_get_sec(void)
 {
 	time_t t;
 	struct tm * lt;
-	t = time(NULL);
+	t = time(nullptr);
 	lt = localtime(&t);
 	return lt->tm_sec;
 }

+ 10 - 10
src/map/elemental.cpp

@@ -139,11 +139,11 @@ int elemental_create(map_session_data *sd, int class_, unsigned int lifetime) {
 }
 
 t_tick elemental_get_lifetime(s_elemental_data *ed) {
-	if( ed == NULL || ed->summon_timer == INVALID_TIMER )
+	if( ed == nullptr || ed->summon_timer == INVALID_TIMER )
 		return 0;
 
 	const struct TimerData * td = get_timer(ed->summon_timer);
-	return (td != NULL) ? DIFF_TICK(td->tick, gettick()) : 0;
+	return (td != nullptr) ? DIFF_TICK(td->tick, gettick()) : 0;
 }
 
 int elemental_save(s_elemental_data *ed) {
@@ -167,12 +167,12 @@ int elemental_save(s_elemental_data *ed) {
 static TIMER_FUNC(elemental_summon_end){
 	map_session_data *sd;
 
-	if( (sd = map_id2sd(id)) == NULL )
+	if( (sd = map_id2sd(id)) == nullptr )
 		return 1;
 
 	s_elemental_data *ed;
 
-	if( (ed = sd->ed) == NULL )
+	if( (ed = sd->ed) == nullptr )
 		return 1;
 
 	if( ed->summon_timer != tid ) {
@@ -205,7 +205,7 @@ int elemental_delete(s_elemental_data *ed) {
 	if( !sd )
 		return unit_free(&ed->bl, CLR_OUTSIGHT);
 
-	sd->ed = NULL;
+	sd->ed = nullptr;
 	sd->status.ele_id = 0;
 
 	return unit_remove_map(&ed->bl, CLR_OUTSIGHT);
@@ -228,7 +228,7 @@ int elemental_data_received(s_elemental *ele, bool flag) {
 	map_session_data *sd;
 	t_tick tick = gettick();
 
-	if( (sd = map_charid2sd(ele->char_id)) == NULL )
+	if( (sd = map_charid2sd(ele->char_id)) == nullptr )
 		return 0;
 
 	std::shared_ptr<s_elemental_db> db = elemental_db.find(ele->class_);
@@ -277,7 +277,7 @@ int elemental_data_received(s_elemental *ele, bool flag) {
 
 	sd->status.ele_id = ele->elemental_id;
 
-	if( ed->bl.prev == NULL && sd->bl.prev != NULL ) {
+	if( ed->bl.prev == nullptr && sd->bl.prev != nullptr ) {
 		if(map_addblock(&ed->bl))
 			return 0;
 		clif_spawn(&ed->bl);
@@ -438,7 +438,7 @@ int elemental_change_mode(s_elemental_data *ed, int mode) {
 }
 
 void elemental_heal(s_elemental_data *ed, int hp, int sp) {
-	if (ed->master == NULL)
+	if (ed->master == nullptr)
 		return;
 	if( hp )
 		clif_elemental_updatestatus(ed->master, SP_HP);
@@ -541,7 +541,7 @@ static int elemental_ai_sub_timer(s_elemental_data *ed, map_session_data *sd, t_
 	nullpo_ret(ed);
 	nullpo_ret(sd);
 
-	if( ed->bl.prev == NULL || sd == NULL || sd->bl.prev == NULL )
+	if( ed->bl.prev == nullptr || sd == nullptr || sd->bl.prev == nullptr )
 		return 0;
 
 	// Check if caster can sustain the summoned elemental
@@ -611,7 +611,7 @@ static int elemental_ai_sub_timer(s_elemental_data *ed, map_session_data *sd, t_
 			return 0;
 	}
 
-	block_list *target = NULL;
+	block_list *target = nullptr;
 
 	if( mode == EL_MODE_AGGRESSIVE ) {
 		target = map_id2bl(ed->ud.target);

+ 61 - 61
src/map/guild.cpp

@@ -219,12 +219,12 @@ static TBL_PC* guild_sd_check(int guild_id, uint32 account_id, uint32 char_id) {
 	TBL_PC* sd = map_id2sd(account_id);
 
 	if (!(sd && sd->status.char_id == char_id))
-		return NULL;
+		return nullptr;
 
 	if (sd->status.guild_id != guild_id)
 	{	//If player belongs to a different guild, kick him out.
 		intif_guild_leave(guild_id,account_id,char_id,0,"** Guild Mismatch **");
-		return NULL;
+		return nullptr;
 	}
 
 	return sd;
@@ -575,8 +575,8 @@ std::shared_ptr<guild_castle> CastleDatabase::find_by_clientid( uint16 client_id
 map_session_data* guild_getavailablesd(const struct mmo_guild &g) {
 	int i;
 
-	ARR_FIND( 0, g.max_member, i, g.member[i].sd != NULL );
-	return( i < g.max_member ) ? g.member[i].sd : NULL;
+	ARR_FIND( 0, g.max_member, i, g.member[i].sd != nullptr );
+	return( i < g.max_member ) ? g.member[i].sd : nullptr;
 }
 
 /// lookup: player AID/CID -> member index
@@ -616,7 +616,7 @@ void guild_makemember(struct guild_member *m,map_session_data *sd) {
 	m->online		= 1;
 	m->position		= MAX_GUILDPOSITION-1;
 	safestrncpy(m->name,sd->status.name,NAME_LENGTH);
-	m->last_login	= (uint32)time(NULL);
+	m->last_login	= (uint32)time(nullptr);
 }
 
 /**
@@ -663,7 +663,7 @@ int guild_send_xy_timer_sub(const struct mmo_guild& g) {
 
 	for (int i = 0; i < g.max_member; i++) {
 		map_session_data* sd = g.member[i].sd;
-		if( sd != NULL && sd->fd && (sd->guild_x != sd->bl.x || sd->guild_y != sd->bl.y) && !sd->bg_id ) {
+		if( sd != nullptr && sd->fd && (sd->guild_x != sd->bl.x || sd->guild_y != sd->bl.y) && !sd->bg_id ) {
 			clif_guild_xy(sd);
 			sd->guild_x = sd->bl.x;
 			sd->guild_y = sd->bl.y;
@@ -720,7 +720,7 @@ int guild_create(map_session_data *sd, const char *name) {
 int guild_created(uint32 account_id,int guild_id) {
 	map_session_data *sd=map_id2sd(account_id);
 
-	if(sd==NULL)
+	if(sd==nullptr)
 		return 0;
 	if(!guild_id) {
 		clif_guild_created(sd, 2); // Creation failure (presence of the same name Guild)
@@ -792,7 +792,7 @@ int guild_check_member(const struct mmo_guild &g) {
 
 		i = guild_getindex(g,sd->status.account_id,sd->status.char_id);
 		if (i < 0) {
-			sd->guild = NULL;
+			sd->guild = nullptr;
 			sd->status.guild_id=0;
 			sd->guild_emblem_id=0;
 			ShowWarning("guild: check_member %d[%s] is not member\n",sd->status.account_id,sd->status.name);
@@ -835,7 +835,7 @@ int guild_recv_info(const struct mmo_guild &sg) {
 		before = sg;
 		//Perform the check on the user because the first load
 		guild_check_member(sg);
-		if ((sd = map_nick2sd(sg.master,false)) != NULL) {
+		if ((sd = map_nick2sd(sg.master,false)) != nullptr) {
 #ifndef RENEWAL
 			//If the guild master is online the first time the guild_info is received,
 			//that means he was the first to join, so apply guild skill blocking here.
@@ -865,14 +865,14 @@ int guild_recv_info(const struct mmo_guild &sg) {
 			if (sd) clif_name_area(&sd->bl); // [LuzZza]
 			m++;
 		}else
-			g->guild.member[i].sd=NULL;
+			g->guild.member[i].sd=nullptr;
 		if(before.member[i].account_id>0)
 			bm++;
 	}
 
 	for (i = 0; i < g->guild.max_member; i++) { //Transmission of information at all members
 		sd = g->guild.member[i].sd;
-		if( sd==NULL )
+		if( sd==nullptr )
 			continue;
 		sd->guild = g;
 		if(channel_config.ally_tmpl.name[0] && (channel_config.ally_tmpl.opt&CHAN_OPT_AUTOJOIN)) {
@@ -925,7 +925,7 @@ int guild_invite(map_session_data *sd, map_session_data *tsd) {
 
 	auto &g = sd->guild;
 
-	if(tsd==NULL || g==NULL)
+	if(tsd==nullptr || g==nullptr)
 		return 0;
 
 	if( (i=guild_getposition(*sd))<0 || !(g->guild.position[i].mode&GUILD_PERM_INVITE) )
@@ -977,7 +977,7 @@ int guild_reply_invite(map_session_data* sd, int guild_id, int flag) {
 		return 0; // mismatch
 
 	// look up the person who sent the invite
-	//NOTE: this can be NULL because the person might have logged off in the meantime
+	//NOTE: this can be nullptr because the person might have logged off in the meantime
 	tsd = map_id2sd(sd->guild_invite_account);
 
 	if ( sd->status.guild_id > 0 ) {
@@ -1058,7 +1058,7 @@ int guild_member_added(int guild_id,uint32 account_id,uint32 char_id,int flag) {
 	if (!g)
 		return 0;
 
-	if(sd==NULL || sd->guild_invite==0){
+	if(sd==nullptr || sd->guild_invite==0){
 	// cancel if player not present or invalide guild_id invitation
 		if (flag == 0) {
 			ShowError("guild: member added error %d is not online\n",account_id);
@@ -1071,7 +1071,7 @@ int guild_member_added(int guild_id,uint32 account_id,uint32 char_id,int flag) {
 	sd->guild_invite_account = 0;
 
 	if (flag == 1) { //failure
-		if( sd2!=NULL )
+		if( sd2!=nullptr )
 			clif_guild_inviteack(sd2,3);
 		return 0;
 	}
@@ -1086,7 +1086,7 @@ int guild_member_added(int guild_id,uint32 account_id,uint32 char_id,int flag) {
 
 	//TODO: send new emblem info to others
 
-	if( sd2!=NULL )
+	if( sd2!=nullptr )
 		clif_guild_inviteack(sd2,2);
 
 	//Next line commented because it do nothing, look at guild_recv_info [LuzZza]
@@ -1182,7 +1182,7 @@ int guild_member_withdraw(int guild_id, uint32 account_id, uint32 char_id, int f
 #endif
 
 	online_member_sd = guild_getavailablesd(g->guild);
-	if(online_member_sd == NULL)
+	if(online_member_sd == nullptr)
 		return 0; // noone online to inform
 
 
@@ -1196,14 +1196,14 @@ int guild_member_withdraw(int guild_id, uint32 account_id, uint32 char_id, int f
 	clif_guild_memberlist( *online_member_sd );
 
 	// update char, if online
-	if(sd != NULL && sd->status.guild_id == guild_id) {
+	if(sd != nullptr && sd->status.guild_id == guild_id) {
 		// do stuff that needs the guild_id first, BEFORE we wipe it
 		if (sd->state.storage_flag == 2) //Close the guild storage.
 			storage_guild_storageclose(sd);
 		guild_send_dot_remove(sd);
 		channel_pcquit(sd,3); //leave guild and ally chan
 		sd->status.guild_id = 0;
-		sd->guild = NULL;
+		sd->guild = nullptr;
 		sd->guild_emblem_id = 0;
 
 		if (g->instance_id) {
@@ -1292,7 +1292,7 @@ int guild_send_memberinfoshort(map_session_data *sd,int online) { // cleaned up
 	if(!online){
 		int i=guild_getindex(g->guild, sd->status.account_id,sd->status.char_id);
 		if(i>=0)
-			g->guild.member[i].sd=NULL;
+			g->guild.member[i].sd=nullptr;
 		else
 			ShowError("guild_send_memberinfoshort: Failed to locate member %d:%d in guild %d!\n", sd->status.account_id, sd->status.char_id, g->guild.guild_id);
 		return 0;
@@ -1310,7 +1310,7 @@ int guild_recv_memberinfoshort(int guild_id,uint32 account_id,uint32 char_id,int
 	int i,alv,c,idx=-1,om=0,oldonline=-1;
 	auto g = guild_search(guild_id);
 
-	if(g == NULL)
+	if(g == nullptr)
 		return 0;
 
 	for(i=0,alv=0,c=0,om=0;i<g->guild.max_member;i++){
@@ -1379,7 +1379,7 @@ int guild_send_message(map_session_data *sd, const char *mes, size_t len) {
 	guild_recv_message(sd->status.guild_id,sd->status.account_id,mes,len);
 
 	// Chat logging type 'G' / Guild Chat
-	log_chat(LOG_CHAT_GUILD, sd->status.guild_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes);
+	log_chat(LOG_CHAT_GUILD, sd->status.guild_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, nullptr, mes);
 
 	return 0;
 }
@@ -1411,7 +1411,7 @@ int guild_memberposition_changed(struct mmo_guild &g,int idx,int pos) {
 	clif_guild_memberpositionchanged(g,idx);
 
 	// Update char position in client [LuzZza]
-	if(g.member[idx].sd != NULL)
+	if(g.member[idx].sd != nullptr)
 		clif_name_area(&g.member[idx].sd->bl);
 	return 0;
 }
@@ -1435,14 +1435,14 @@ int guild_change_position(int guild_id,int idx, int mode, int exp_mode, const ch
 int guild_position_changed(int guild_id,int idx,struct guild_position *p) {
 	auto g = guild_search(guild_id);
 	int i;
-	if(g==NULL)
+	if(g==nullptr)
 		return 0;
 	memcpy(&g->guild.position[idx],p,sizeof(struct guild_position));
 	clif_guild_positionchanged(g->guild,idx);
 
 	// Update char name in client [LuzZza]
 	for(i=0;i<g->guild.max_member;i++)
-		if(g->guild.member[i].position == idx && g->guild.member[i].sd != NULL)
+		if(g->guild.member[i].position == idx && g->guild.member[i].sd != nullptr)
 			clif_name_area(&g->guild.member[i].sd->bl);
 	return 0;
 }
@@ -1472,7 +1472,7 @@ int guild_notice_changed(int guild_id,const char *mes1,const char *mes2) {
 
 	for(i=0;i<g->guild.max_member;i++){
 		map_session_data *sd = g->guild.member[i].sd;
-		if(sd != NULL)
+		if(sd != nullptr)
 			clif_guild_notice(sd);
 	}
 	return 0;
@@ -1530,7 +1530,7 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) {
 	g->guild.emblem_id=emblem_id;
 
 	for(i=0;i<g->guild.max_member;i++){
-		if((sd=g->guild.member[i].sd)!=NULL){
+		if((sd=g->guild.member[i].sd)!=nullptr){
 			sd->guild_emblem_id=emblem_id;
 			clif_guild_belonginfo( *sd );
 			clif_guild_emblem(*sd, g->guild);
@@ -1544,8 +1544,8 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) {
 			// update permanent guardians
 			for( i = 0; i < ARRAYLENGTH(it.second->guardian); ++i )
 			{
-				TBL_MOB* md = (it.second->guardian[i].id ? map_id2md(it.second->guardian[i].id) : NULL);
-				if( md == NULL || md->guardian_data == NULL )
+				TBL_MOB* md = (it.second->guardian[i].id ? map_id2md(it.second->guardian[i].id) : nullptr);
+				if( md == nullptr || md->guardian_data == nullptr )
 					continue;
 				md->guardian_data->emblem_id = emblem_id;
 				clif_guild_emblem_area(&md->bl);
@@ -1553,8 +1553,8 @@ int guild_emblem_changed(int len,int guild_id,int emblem_id,const char *data) {
 			// update temporary guardians
 			for( i = 0; i < it.second->temp_guardians_max; ++i )
 			{
-				TBL_MOB* md = (it.second->temp_guardians[i] ? map_id2md(it.second->temp_guardians[i]) : NULL);
-				if( md == NULL || md->guardian_data == NULL )
+				TBL_MOB* md = (it.second->temp_guardians[i] ? map_id2md(it.second->temp_guardians[i]) : nullptr);
+				if( md == nullptr || md->guardian_data == nullptr )
 					continue;
 				md->guardian_data->emblem_id = emblem_id;
 				clif_guild_emblem_area(&md->bl);
@@ -1624,7 +1624,7 @@ t_exp guild_getexp(map_session_data *sd,t_exp exp) {
 	struct guild_expcache *c;
 	nullpo_ret(sd);
 
-	if (sd->status.guild_id == 0 || sd->guild == NULL)
+	if (sd->status.guild_id == 0 || sd->guild == nullptr)
 		return 0;
 
 	c = (struct guild_expcache *)db_data2ptr(guild_expcache_db->ensure(guild_expcache_db, db_i2key(sd->status.char_id), create_expcache, sd));
@@ -1668,9 +1668,9 @@ int guild_skillupack(int guild_id,uint16 skill_id,uint32 account_id) {
 	int i;
 	short idx = guild_skill_get_index(skill_id);
 
-	if (g == NULL || idx == -1)
+	if (g == nullptr || idx == -1)
 		return 0;
-	if (sd != NULL) {
+	if (sd != nullptr) {
 		int lv = g->guild.skill[idx].lv;
 		int range = skill_get_range(skill_id, lv);
 		clif_skillup(sd,skill_id,lv,range,1);
@@ -1688,7 +1688,7 @@ int guild_skillupack(int guild_id,uint16 skill_id,uint32 account_id) {
 
 	// Inform all members
 	for (i = 0; i < g->guild.max_member; i++)
-		if ((sd = g->guild.member[i].sd) != NULL)
+		if ((sd = g->guild.member[i].sd) != nullptr)
 			clif_guild_skillinfo(sd);
 
 	return 0;
@@ -1711,7 +1711,7 @@ void guild_guildaura_refresh(map_session_data *sd, uint16 skill_id, uint16 skill
 	std::shared_ptr<s_skill_unit_group> group = skill_unitsetting(&sd->bl,skill_id,skill_lv,sd->bl.x,sd->bl.y,0);
 
 	if( group )
-		sc_start4(NULL,&sd->bl,type,100,(battle_config.guild_aura&16)?0:skill_lv,0,0,group->group_id,600000);//duration doesn't matter these status never end with val4
+		sc_start4(nullptr,&sd->bl,type,100,(battle_config.guild_aura&16)?0:skill_lv,0,0,group->group_id,600000);//duration doesn't matter these status never end with val4
 	return;
 }
 
@@ -1751,7 +1751,7 @@ int guild_check_alliance(int guild_id1, int guild_id2, int flag) {
 	int i;
 
 	auto g = guild_search(guild_id1);
-	if (g == NULL)
+	if (g == nullptr)
 		return 0;
 
 	ARR_FIND( 0, MAX_GUILDALLIANCE, i, g->guild.alliance[i].guild_id == guild_id2 && g->guild.alliance[i].opposition == flag );
@@ -1772,7 +1772,7 @@ int guild_reqalliance(map_session_data *sd,map_session_data *tsd) {
 
 	nullpo_ret(sd);
 
-	if(tsd==NULL || tsd->status.guild_id<=0)
+	if(tsd==nullptr || tsd->status.guild_id<=0)
 		return 0;
 
 	// Check, is tsd guild master, if not - cancel alliance. [f0und3r]
@@ -1784,7 +1784,7 @@ int guild_reqalliance(map_session_data *sd,map_session_data *tsd) {
 	auto &g = sd->guild;
 	auto &tg = tsd->guild;
 
-	if(g==NULL || tg==NULL)
+	if(g==nullptr || tg==nullptr)
 		return 0;
 
 	// Prevent creation alliance with same guilds [LuzZza]
@@ -1873,7 +1873,7 @@ int guild_reply_reqalliance(map_session_data *sd,uint32 account_id,int flag) {
 	} else { // deny
 		sd->guild_alliance=0;
 		sd->guild_alliance_account=0;
-		if(tsd!=NULL)
+		if(tsd!=nullptr)
 			clif_guild_allianceack(tsd,3);
 	}
 	return 0;
@@ -1903,7 +1903,7 @@ int guild_opposition(map_session_data *sd,map_session_data *tsd) {
 	nullpo_ret(sd);
 
 	auto &g = sd->guild;
-	if(g==NULL || tsd==NULL)
+	if(g==nullptr || tsd==nullptr)
 		return 0;
 
 	// Prevent creation opposition with same guilds [LuzZza]
@@ -1956,21 +1956,21 @@ int guild_allianceack(int guild_id1,int guild_id2,uint32 account_id1,uint32 acco
 	g[0] = &guild_search(guild_id1)->guild;
 	g[1] = &guild_search(guild_id2)->guild;
 
-	if(sd[0]!=NULL && (flag&0x0f)==0){
+	if(sd[0]!=nullptr && (flag&0x0f)==0){
 		sd[0]->guild_alliance=0;
 		sd[0]->guild_alliance_account=0;
 	}
 
 	if (flag & 0x70) { // failure
 		for(i=0;i<2-(flag&1);i++)
-			if( sd[i]!=NULL )
+			if( sd[i]!=nullptr )
 				clif_guild_allianceack(sd[i],((flag>>4)==i+1)?3:4);
 		return 0;
 	}
 
 	if (!(flag & 0x08)) { // new relationship
 		for(i=0;i<2-(flag&1);i++) {
-			if(g[i]!=NULL) {
+			if(g[i]!=nullptr) {
 				ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == 0 );
 				if( j < MAX_GUILDALLIANCE ) {
 					g[i]->alliance[j].guild_id=guild_id[1-i];
@@ -1981,31 +1981,31 @@ int guild_allianceack(int guild_id1,int guild_id2,uint32 account_id1,uint32 acco
 		}
 	} else { // remove relationship
 		for(i=0;i<2-(flag&1);i++) {
-			if(g[i]!=NULL) {
+			if(g[i]!=nullptr) {
 				for(j=0;j<g[i]->max_member;j++) channel_pcquit(g[i]->member[j].sd,2); //leave all alliance chan
 				ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == guild_id[1-i] && g[i]->alliance[j].opposition == (flag&1) );
 				if( j < MAX_GUILDALLIANCE )
 					g[i]->alliance[j].guild_id = 0;
 			}
-		if (sd[i] != NULL) // notify players
+		if (sd[i] != nullptr) // notify players
 				clif_guild_delalliance(sd[i],guild_id[1-i],(flag&1));
 		}
 	}
 
 	if ((flag & 0x0f) == 0) { // alliance notification
-		if( sd[1]!=NULL )
+		if( sd[1]!=nullptr )
 			clif_guild_allianceack(sd[1],2);
 	} else if ((flag & 0x0f) == 1) { // enemy notification
-		if( sd[0]!=NULL )
+		if( sd[0]!=nullptr )
 			clif_guild_oppositionack(sd[0],0);
 	}
 
 
 	for (i = 0; i < 2 - (flag & 1); i++) { // Retransmission of the relationship list to all members
-		if(g[i]!=NULL)
+		if(g[i]!=nullptr)
 			for(j=0;j<g[i]->max_member;j++) {
 				map_session_data *sd_mem = g[i]->member[j].sd;
-				if( sd_mem!=NULL){
+				if( sd_mem!=nullptr){
 					clif_guild_allianceinfo(sd_mem);
 
 					// join ally channel
@@ -2061,16 +2061,16 @@ int guild_broken(int guild_id,int flag) {
 	auto g = guild_search(guild_id);
 	int i;
 
-	if (flag != 0 || g == NULL)
+	if (flag != 0 || g == nullptr)
 		return 0;
 
 	for (i = 0; i < g->guild.max_member; i++){	// Destroy all relationships
 		map_session_data *sd = g->guild.member[i].sd;
-		if(sd != NULL){
+		if(sd != nullptr){
 			if(sd->state.storage_flag == 2)
 				storage_guild_storage_quit(sd,1);
 			sd->status.guild_id=0;
-			sd->guild = NULL;
+			sd->guild = nullptr;
 			sd->state.gmaster_flag = 0;
 			clif_guild_broken(g->guild.member[i].sd,0);
 			clif_name_area(&sd->bl); // [LuzZza]
@@ -2293,7 +2293,7 @@ int guild_castledatasave(int castle_id, int index, int value) {
 		gc->guild_id = value;
 		for (i = 0; i < MAX_GUARDIANS; i++){
 			struct mob_data *gd;
-			if (gc->guardian[i].visible && (gd = map_id2md(gc->guardian[i].id)) != NULL)
+			if (gc->guardian[i].visible && (gd = map_id2md(gc->guardian[i].id)) != nullptr)
 				mob_guardian_guildchange(gd);
 		}
 		break;
@@ -2306,7 +2306,7 @@ int guild_castledatasave(int castle_id, int index, int value) {
 		gc->defense = value;
 		for (i = 0; i < MAX_GUARDIANS; i++){
 			struct mob_data *gd;
-			if (gc->guardian[i].visible && (gd = map_id2md(gc->guardian[i].id)) != NULL)
+			if (gc->guardian[i].visible && (gd = map_id2md(gc->guardian[i].id)) != nullptr)
 				status_calc_mob(gd, SCO_NONE);
 		}
 		break;
@@ -2354,7 +2354,7 @@ void guild_castle_reconnect_sub(void *key, void *data, va_list ap) {
  * @param value
  */
 void guild_castle_reconnect(int castle_id, int index, int value) {
-	static struct linkdb_node *gc_save_pending = NULL;
+	static struct linkdb_node *gc_save_pending = nullptr;
 
 	if (castle_id < 0) { // char-server reconnected
 		linkdb_foreach(&gc_save_pending, guild_castle_reconnect_sub);
@@ -2552,14 +2552,14 @@ void guild_flag_remove(struct npc_data *nd) {
 	/* find it */
 	for( i = 0; i < guild_flags_count; i++ ) {
 		if( guild_flags[i] && guild_flags[i]->bl.id == nd->bl.id ) {/* found */
-			guild_flags[i] = NULL;
+			guild_flags[i] = nullptr;
 			break;
 		}
 	}
 
 	/* compact list */
 	for( i = 0, cursor = 0; i < guild_flags_count; i++ ) {
-		if( guild_flags[i] == NULL )
+		if( guild_flags[i] == nullptr )
 			continue;
 
 		if( cursor != i ) {
@@ -2574,9 +2574,9 @@ void guild_flag_remove(struct npc_data *nd) {
  * @see DBApply
  */
 static int eventlist_db_final(DBKey key, DBData *data, va_list ap) {
-	struct eventlist *next = NULL;
+	struct eventlist *next = nullptr;
 	struct eventlist *current = (struct eventlist *)db_data2ptr(data);
-	while (current != NULL) {
+	while (current != nullptr) {
 		next = current->next;
 		aFree(current);
 		current = next;
@@ -2597,7 +2597,7 @@ void guild_flags_clear(void) {
 	int i;
 	for( i = 0; i < guild_flags_count; i++ ) {
 		if( guild_flags[i] )
-			guild_flags[i] = NULL;
+			guild_flags[i] = nullptr;
 	}
 
 	guild_flags_count = 0;

+ 4 - 4
src/map/homunculus.cpp

@@ -130,7 +130,7 @@ struct view_data* hom_get_viewdata(int class_)
 {	//Returns the viewdata for homunculus
 	if (homdb_checkid(class_))
 		return &hom_viewdb[class_-HM_CLASS_BASE];
-	return NULL;
+	return nullptr;
 }
 
 /**
@@ -840,7 +840,7 @@ void hom_save(struct homun_data *hd)
 void hom_menu(map_session_data *sd, int type)
 {
 	nullpo_retv(sd);
-	if (sd->hd == NULL)
+	if (sd->hd == nullptr)
 		return;
 
 	switch(type) {
@@ -1124,7 +1124,7 @@ bool hom_call(map_session_data *sd)
 
 	hom_init_timers(hd);
 	hd->homunculus.vaporize = HOM_ST_ACTIVE;
-	if (hd->bl.prev == NULL)
+	if (hd->bl.prev == nullptr)
 	{	//Spawn him
 		hd->bl.x = sd->bl.x;
 		hd->bl.y = sd->bl.y;
@@ -1191,7 +1191,7 @@ int hom_recv_data(uint32 account_id, struct s_homunculus *sh, int flag)
 	if (created)
 		status_percent_heal(&hd->bl, 100, 100);
 
-	if(hd && hd->homunculus.hp && !hd->homunculus.vaporize && hd->bl.prev == NULL && sd->bl.prev != NULL)
+	if(hd && hd->homunculus.hp && !hd->homunculus.vaporize && hd->bl.prev == nullptr && sd->bl.prev != nullptr)
 	{
 		if(map_addblock(&hd->bl))
 			return 0;

+ 1 - 1
src/map/instance.cpp

@@ -1024,7 +1024,7 @@ bool instance_destroy(int instance_id)
 
 	if( idata->regs.vars ) {
 		db_destroy(idata->regs.vars);
-		idata->regs.vars = NULL;
+		idata->regs.vars = nullptr;
 	}
 
 	if( idata->regs.arrays )

+ 36 - 36
src/map/intif.cpp

@@ -60,18 +60,18 @@ extern int char_fd; // inter server Fd used for char_fd
  */
 int CheckForCharServer(void)
 {
-	return ((char_fd <= 0) || session[char_fd] == NULL || session[char_fd]->wdata == NULL);
+	return ((char_fd <= 0) || session[char_fd] == nullptr || session[char_fd]->wdata == nullptr);
 }
 
 /**
  * Get sd from pc_db (map_id2db) or auth_db (in case if parsing packet from inter-server when sd not added to pc_db yet)
  * @param account_id
  * @param char_id
- * @return sd Found sd or NULL if not found
+ * @return sd Found sd or nullptr if not found
  */
 map_session_data *inter_search_sd(uint32 account_id, uint32 char_id)
 {
-	map_session_data *sd = NULL;
+	map_session_data *sd = nullptr;
 	struct auth_node *node = chrif_auth_check(account_id, char_id, ST_LOGIN);
 	if (node)
 		sd = node->sd;
@@ -213,7 +213,7 @@ int intif_broadcast(const char* mes, int len, int type)
 	int lp = (type|BC_COLOR_MASK) ? 4 : 0;
 
 	// Send to the local players
-	clif_broadcast(NULL, mes, len, type, ALL_CLIENT);
+	clif_broadcast(nullptr, mes, len, type, ALL_CLIENT);
 
 	if (CheckForCharServer())
 		return 0;
@@ -256,7 +256,7 @@ int intif_broadcast2(const char* mes, int len, unsigned long fontColor, short fo
 		return 0;
 
 	// Send to the local players
-	clif_broadcast2(NULL, mes, len, fontColor, fontType, fontSize, fontAlign, fontY, ALL_CLIENT);
+	clif_broadcast2(nullptr, mes, len, fontColor, fontType, fontSize, fontAlign, fontY, ALL_CLIENT);
 
 	if (CheckForCharServer())
 		return 0;
@@ -296,7 +296,7 @@ int intif_main_message(map_session_data* sd, const char* message)
 	intif_broadcast2( output, strlen(output) + 1, 0xFE000000, 0, 0, 0, 0 );
 
 	// log the chat message
-	log_chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, message );
+	log_chat( LOG_CHAT_MAINCHAT, 0, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, nullptr, message );
 
 	return 1;
 }
@@ -415,8 +415,8 @@ int intif_saveregistry(map_session_data *sd)
 
 	iter = db_iterator(sd->regs.vars);
 	for( data = iter->first(iter,&key); iter->exists(iter); data = iter->next(iter,&key) ) {
-		const char *varname = NULL;
-		struct script_reg_state *src = NULL;
+		const char *varname = nullptr;
+		struct script_reg_state *src = nullptr;
 		bool lValid = false;
 
 		if( data->type != DB_DATA_PTR ) // it's a @number
@@ -1290,7 +1290,7 @@ int intif_parse_WisMessage(int fd)
 
 	safestrncpy(name, RFIFOCP(fd,12+NAME_LENGTH), NAME_LENGTH);
 	sd = map_nick2sd(name,false);
-	if(sd == NULL || strcmp(sd->status.name, name) != 0)
+	if(sd == nullptr || strcmp(sd->status.name, name) != 0)
 	{	//Not found
 		intif_wis_reply(id,1);
 		return 0;
@@ -1328,7 +1328,7 @@ int intif_parse_WisEnd(int fd)
 	if (battle_config.etc_log)
 		ShowInfo("intif_parse_wisend: player: %s, flag: %d\n", RFIFOP(fd,2), RFIFOB(fd,26)); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
 	sd = (map_session_data *)map_nick2sd(RFIFOCP(fd,2),false);
-	if (sd != NULL)
+	if (sd != nullptr)
 		clif_wis_end(sd->fd, RFIFOB(fd,26));
 
 	return 1;
@@ -1450,7 +1450,7 @@ void intif_parse_Registers(int fd)
 				safestrncpy(sval, RFIFOCP(fd, cursor + 1), RFIFOB(fd, cursor));
 				cursor += RFIFOB(fd, cursor) + 1;
 
-				set_reg_str( NULL, sd, reference_uid( add_str( key ), index ), key, sval, NULL );
+				set_reg_str( nullptr, sd, reference_uid( add_str( key ), index ), key, sval, nullptr );
 			}
 		/**
 		 * Vessel!
@@ -1470,7 +1470,7 @@ void intif_parse_Registers(int fd)
 				ival = RFIFOQ(fd, cursor);
 				cursor += 8;
 
-				set_reg_num( NULL, sd, reference_uid( add_str( key ), index ), key, ival, NULL );
+				set_reg_num( nullptr, sd, reference_uid( add_str( key ), index ), key, ival, nullptr );
 			}
 		}
 	}
@@ -1499,7 +1499,7 @@ int intif_parse_LoadGuildStorage(int fd)
 
 	sd = map_id2sd( RFIFOL(fd,4) );
 	if (flag){ //If flag != 0, we attach a player and open the storage
-		if(sd == NULL){
+		if(sd == nullptr){
 			ShowError("intif_parse_LoadGuildStorage: user not found (AID: %d)\n",RFIFOL(fd,4));
 			return 0;
 		}
@@ -1732,7 +1732,7 @@ int intif_parse_GuildBasicInfoChanged(int fd)
 	//void* data = RFIFOP(fd,10);
 
 	auto g = guild_search(guild_id);
-	if( g == NULL )
+	if( g == nullptr )
 		return 0;
 
 	switch(type) {
@@ -1941,8 +1941,8 @@ int intif_parse_DeletePetOk(int fd)
  */
 int intif_parse_ChangeNameOk(int fd)
 {
-	map_session_data *sd = NULL;
-	if((sd=map_id2sd(RFIFOL(fd,2)))==NULL ||
+	map_session_data *sd = nullptr;
+	if((sd=map_id2sd(RFIFOL(fd,2)))==nullptr ||
 		sd->status.char_id != RFIFOL(fd,6))
 		return 0;
 
@@ -2064,7 +2064,7 @@ void intif_parse_questlog(int fd)
 	if(num_received == 0) {
 		if(sd->quest_log) {
 			aFree(sd->quest_log);
-			sd->quest_log = NULL;
+			sd->quest_log = nullptr;
 		}
 	} else {
 		struct quest *received = (struct quest *)RFIFOP(fd,8);
@@ -2171,7 +2171,7 @@ void intif_parse_achievements(int fd)
 	if (num_received == 0) {
 		if (sd->achievement_data.achievements) {
 			aFree(sd->achievement_data.achievements);
-			sd->achievement_data.achievements = NULL;
+			sd->achievement_data.achievements = nullptr;
 			sd->achievement_data.incompleteCount = 0;
 			sd->achievement_data.count = 0;
 		}
@@ -2215,7 +2215,7 @@ void intif_parse_achievements(int fd)
 
 	achievement_level(sd, false); // Calculate level info but don't give any AG_GOAL_ACHIEVE achievements
 	achievement_get_titles(sd->status.char_id); // Populate the title list for completed achievements
-	clif_achievement_update(sd, NULL, 0);
+	clif_achievement_update(sd, nullptr, 0);
 	clif_achievement_list_all(sd);
 }
 
@@ -2338,7 +2338,7 @@ int intif_parse_Mail_inboxreceived(int fd)
 
 	sd = map_charid2sd(RFIFOL(fd,4));
 
-	if (sd == NULL)
+	if (sd == nullptr)
 	{
 		ShowError("intif_parse_Mail_inboxreceived: char not found %d\n",RFIFOL(fd,4));
 		return 0;
@@ -2356,7 +2356,7 @@ int intif_parse_Mail_inboxreceived(int fd)
 
 #if PACKETVER >= 20150513
 	// Refresh top right icon
-	clif_Mail_new(sd, 0, NULL, NULL);
+	clif_Mail_new(sd, 0, nullptr, nullptr);
 #endif
 
 	if (flag){
@@ -2428,7 +2428,7 @@ int intif_parse_Mail_getattach(int fd)
 
 	sd = map_charid2sd( RFIFOL(fd,4) );
 
-	if (sd == NULL)
+	if (sd == nullptr)
 	{
 		ShowError("intif_parse_Mail_getattach: char not found %d\n",RFIFOL(fd,4));
 		return 0;
@@ -2480,7 +2480,7 @@ int intif_parse_Mail_delete(int fd)
 	bool failed = RFIFOB(fd,10) > 0;
 
 	map_session_data *sd = map_charid2sd(char_id);
-	if (sd == NULL)
+	if (sd == nullptr)
 	{
 		ShowError("intif_parse_Mail_delete: char not found %d\n", char_id);
 		return 0;
@@ -2540,7 +2540,7 @@ int intif_parse_Mail_return(int fd)
 	int mail_id = RFIFOL(fd,6);
 	short fail = RFIFOB(fd,10);
 
-	if( sd == NULL )
+	if( sd == nullptr )
 	{
 		ShowError("intif_parse_Mail_return: char not found %d\n",RFIFOL(fd,2));
 		return 1;
@@ -2613,7 +2613,7 @@ static void intif_parse_Mail_send(int fd)
 
 	// notify sender
 	sd = map_charid2sd(msg.send_id);
-	if( sd != NULL )
+	if( sd != nullptr )
 	{
 		if( fail )
 			mail_deliveryfail(sd, &msg);
@@ -2637,7 +2637,7 @@ static void intif_parse_Mail_new(int fd)
 	const char* sender_name = RFIFOCP(fd,10);
 	const char* title = RFIFOCP(fd,34);
 
-	if( sd == NULL )
+	if( sd == nullptr )
 		return;
 	sd->mail.changed = true;
 	sd->mail.inbox.unread++;
@@ -2667,7 +2667,7 @@ bool intif_mail_checkreceiver( map_session_data* sd, char* name ){
 	sd->mail.dest_id = 0;
 
 	// If the target player is online on this map-server
-	if( tsd != NULL ){
+	if( tsd != nullptr ){
 		clif_Mail_Receiver_Ack( sd, tsd->status.char_id, tsd->status.class_, tsd->status.base_level, name );
 		sd->mail.dest_id = tsd->status.char_id;
 		return true;
@@ -2730,7 +2730,7 @@ static void intif_parse_Auction_results(int fd)
 	short pages = RFIFOW(fd,10);
 	uint8* data = RFIFOP(fd,12);
 
-	if( sd == NULL )
+	if( sd == nullptr )
 		return;
 
 	clif_Auction_results(sd, count, pages, data);
@@ -2773,7 +2773,7 @@ static void intif_parse_Auction_register(int fd)
 	}
 
 	memcpy(&auction, RFIFOP(fd,4), sizeof(struct auction_data));
-	if( (sd = map_charid2sd(auction.seller_id)) == NULL )
+	if( (sd = map_charid2sd(auction.seller_id)) == nullptr )
 		return;
 
 	if( auction.auction_id > 0 )
@@ -2822,7 +2822,7 @@ static void intif_parse_Auction_cancel(int fd)
 	map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
 	int result = RFIFOB(fd,6);
 
-	if( sd == NULL )
+	if( sd == nullptr )
 		return;
 
 	switch( result )
@@ -2863,7 +2863,7 @@ static void intif_parse_Auction_close(int fd)
 	map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
 	unsigned char result = RFIFOB(fd,6);
 
-	if( sd == NULL )
+	if( sd == nullptr )
 		return;
 
 	clif_Auction_close(sd->fd, result);
@@ -2913,7 +2913,7 @@ static void intif_parse_Auction_bid(int fd)
 	int bid = RFIFOL(fd,6);
 	unsigned char result = RFIFOB(fd,10);
 
-	if( sd == NULL )
+	if( sd == nullptr )
 		return;
 
 	clif_Auction_message(sd->fd, result);
@@ -2937,7 +2937,7 @@ static void intif_parse_Auction_message(int fd)
 	map_session_data *sd = map_charid2sd(RFIFOL(fd,2));
 	unsigned char result = RFIFOB(fd,6);
 
-	if( sd == NULL )
+	if( sd == nullptr )
 		return;
 
 	clif_Auction_message(sd->fd, result);
@@ -3740,7 +3740,7 @@ int intif_clan_member_joined( int clan_id ){
 int intif_parse_clan_onlinecount( int fd ){
 	struct clan* clan = clan_search(RFIFOL(fd,2));
 
-	if( clan == NULL ){
+	if( clan == nullptr ){
 		return 0;
 	}
 
@@ -3784,9 +3784,9 @@ int intif_parse(int fd)
 	switch(cmd){
 	case 0x3800:
 		if (RFIFOL(fd,4) == 0xFF000000) //Normal announce.
-			clif_broadcast(NULL, RFIFOCP(fd,16), packet_len-16, BC_DEFAULT, ALL_CLIENT);
+			clif_broadcast(nullptr, RFIFOCP(fd,16), packet_len-16, BC_DEFAULT, ALL_CLIENT);
 		else //Color announce.
-			clif_broadcast2(NULL, RFIFOCP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT);
+			clif_broadcast2(nullptr, RFIFOCP(fd,16), packet_len-16, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOW(fd,10), RFIFOW(fd,12), RFIFOW(fd,14), ALL_CLIENT);
 		break;
 	case 0x3801:	intif_parse_WisMessage(fd); break;
 	case 0x3802:	intif_parse_WisEnd(fd); break;

+ 10 - 10
src/map/itemdb.cpp

@@ -2883,7 +2883,7 @@ std::shared_ptr<s_item_group_entry> get_random_itemsubgroup(std::shared_ptr<s_it
 * Return a random group entry from Item Group
 * @param group_id
 * @param sub_group: 0 is 'must' item group, random groups start from 1
-* @return Item group entry or NULL on fail
+* @return Item group entry or nullptr on fail
 */
 std::shared_ptr<s_item_group_entry> ItemGroupDatabase::get_random_entry(uint16 group_id, uint8 sub_group) {
 	std::shared_ptr<s_item_group_db> group = this->find(group_id);
@@ -2930,7 +2930,7 @@ static void itemdb_pc_get_itemgroup_sub(map_session_data *sd, bool identify, std
 	tmp.nameid = data->nameid;
 	tmp.bound = data->bound;
 	tmp.identify = identify ? identify : itemdb_isidentified(data->nameid);
-	tmp.expire_time = (data->duration) ? (unsigned int)(time(NULL) + data->duration*60) : 0;
+	tmp.expire_time = (data->duration) ? (unsigned int)(time(nullptr) + data->duration*60) : 0;
 	if (data->isNamed) {
 		tmp.card[0] = itemdb_isequip(data->nameid) ? CARD0_FORGE : CARD0_CREATE;
 		tmp.card[1] = 0;
@@ -3019,7 +3019,7 @@ uint8 ItemGroupDatabase::pc_get_itemgroup(uint16 group_id, bool identify, map_se
 
 /** Searches for the item_data. Use this to check if item exists or not.
 * @param nameid
-* @return *item_data if item is exist, or NULL if not
+* @return *item_data if item is exist, or nullptr if not
 */
 std::shared_ptr<item_data> itemdb_exists(t_itemid nameid) {
 	return item_db.find(nameid);
@@ -3757,10 +3757,10 @@ bool itemdb_parse_roulette_db(void)
 			unsigned short amount;
 			int level, flag;
 
-			Sql_GetData(mmysql_handle, 1, &data, NULL); level = atoi(data);
-			Sql_GetData(mmysql_handle, 2, &data, NULL); item_id = strtoul(data, nullptr, 10);
-			Sql_GetData(mmysql_handle, 3, &data, NULL); amount = atoi(data);
-			Sql_GetData(mmysql_handle, 4, &data, NULL); flag = atoi(data);
+			Sql_GetData(mmysql_handle, 1, &data, nullptr); level = atoi(data);
+			Sql_GetData(mmysql_handle, 2, &data, nullptr); item_id = strtoul(data, nullptr, 10);
+			Sql_GetData(mmysql_handle, 3, &data, nullptr); amount = atoi(data);
+			Sql_GetData(mmysql_handle, 4, &data, nullptr); flag = atoi(data);
 
 			if (!item_db.exists(item_id)) {
 				ShowWarning("itemdb_parse_roulette_db: Unknown item ID '%u' in level '%d'\n", item_id, level);
@@ -3839,9 +3839,9 @@ static void itemdb_roulette_free(void) {
 			aFree(rd.qty[i]);
 		if (rd.flag[i])
 			aFree(rd.flag[i]);
-		rd.nameid[i] = NULL;
-		rd.qty[i] = NULL;
-		rd.flag[i] = NULL;
+		rd.nameid[i] = nullptr;
+		rd.qty[i] = nullptr;
+		rd.flag[i] = nullptr;
 		rd.items[i] = 0;
 	}
 }

+ 11 - 11
src/map/log.cpp

@@ -196,7 +196,7 @@ void log_branch(map_session_data* sd)
 		time_t curtime;
 		FILE* logfp;
 
-		if( ( logfp = fopen(log_config.log_branch, "a") ) == NULL )
+		if( ( logfp = fopen(log_config.log_branch, "a") ) == nullptr )
 			return;
 		time(&curtime);
 		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
@@ -253,7 +253,7 @@ void log_pick(int id, int16 m, e_log_pick_type type, int amount, struct item* it
 		time_t curtime;
 		FILE* logfp;
 
-		if( ( logfp = fopen(log_config.log_pick, "a") ) == NULL )
+		if( ( logfp = fopen(log_config.log_pick, "a") ) == nullptr )
 			return;
 		time(&curtime);
 		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
@@ -299,7 +299,7 @@ void log_zeny(const map_session_data &target_sd, e_log_pick_type type, uint32 sr
 		time_t curtime;
 		FILE* logfp;
 
-		if( ( logfp = fopen(log_config.log_zeny, "a") ) == NULL )
+		if( ( logfp = fopen(log_config.log_zeny, "a") ) == nullptr )
 			return;
 		time(&curtime);
 		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
@@ -332,7 +332,7 @@ void log_mvpdrop(map_session_data* sd, int monster_id, t_itemid nameid, t_exp ex
 		time_t curtime;
 		FILE* logfp;
 
-		if( ( logfp = fopen(log_config.log_mvpdrop,"a") ) == NULL )
+		if( ( logfp = fopen(log_config.log_mvpdrop,"a") ) == nullptr )
 			return;
 		time(&curtime);
 		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
@@ -373,7 +373,7 @@ void log_atcommand(map_session_data* sd, const char* message)
 		time_t curtime;
 		FILE* logfp;
 
-		if( ( logfp = fopen(log_config.log_gm, "a") ) == NULL )
+		if( ( logfp = fopen(log_config.log_gm, "a") ) == nullptr )
 			return;
 		time(&curtime);
 		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
@@ -410,7 +410,7 @@ void log_npc( struct npc_data* nd, const char* message ){
 		time_t curtime;
 		FILE* logfp;
 
-		if( ( logfp = fopen(log_config.log_npc, "a") ) == NULL )
+		if( ( logfp = fopen(log_config.log_npc, "a") ) == nullptr )
 			return;
 		time(&curtime);
 		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
@@ -448,7 +448,7 @@ void log_npc(map_session_data* sd, const char* message)
 		time_t curtime;
 		FILE* logfp;
 
-		if( ( logfp = fopen(log_config.log_npc, "a") ) == NULL )
+		if( ( logfp = fopen(log_config.log_npc, "a") ) == nullptr )
 			return;
 		time(&curtime);
 		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
@@ -496,7 +496,7 @@ void log_chat(e_log_chat_type type, int type_id, int src_charid, int src_accid,
 		time_t curtime;
 		FILE* logfp;
 
-		if( ( logfp = fopen(log_config.log_chat, "a") ) == NULL )
+		if( ( logfp = fopen(log_config.log_chat, "a") ) == nullptr )
 			return;
 		time(&curtime);
 		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
@@ -524,7 +524,7 @@ void log_cash( map_session_data* sd, e_log_pick_type type, e_log_cash_type cash_
 		time_t curtime;
 		FILE* logfp;
 
-		if( ( logfp = fopen( log_config.log_cash, "a" ) ) == NULL )
+		if( ( logfp = fopen( log_config.log_cash, "a" ) ) == nullptr )
 			return;
 		time( &curtime );
 		strftime( timestring, sizeof( timestring ), log_timestamp_format, localtime( &curtime ) );
@@ -577,7 +577,7 @@ void log_feeding(map_session_data *sd, e_log_feeding_type type, t_itemid nameid)
 		time_t curtime;
 		FILE* logfp;
 
-		if ((logfp = fopen(log_config.log_feeding, "a")) == NULL)
+		if ((logfp = fopen(log_config.log_feeding, "a")) == nullptr)
 			return;
 		time(&curtime);
 		strftime(timestring, sizeof(timestring), log_timestamp_format, localtime(&curtime));
@@ -609,7 +609,7 @@ int log_config_read(const char* cfgName)
 	if( count++ == 0 )
 		log_set_defaults();
 
-	if( ( fp = fopen(cfgName, "r") ) == NULL )
+	if( ( fp = fopen(cfgName, "r") ) == nullptr )
 	{
 		ShowError("Log configuration file not found at: %s\n", cfgName);
 		return 1;

+ 3 - 3
src/map/mail.cpp

@@ -477,7 +477,7 @@ void mail_send(map_session_data *sd, const char *dest_name, const char *title, c
 		mail_refresh_remaining_amount(sd);
 
 		// After calling mail_refresh_remaining_amount the status should always be there
-		if( sd->sc.getSCE(SC_DAILYSENDMAILCNT) == NULL || sd->sc.getSCE(SC_DAILYSENDMAILCNT)->val2 >= battle_config.mail_daily_count ){
+		if( sd->sc.getSCE(SC_DAILYSENDMAILCNT) == nullptr || sd->sc.getSCE(SC_DAILYSENDMAILCNT)->val2 >= battle_config.mail_daily_count ){
 			clif_Mail_send(sd, WRITE_MAIL_FAILED_CNT);
 			return;
 		}else{
@@ -516,7 +516,7 @@ void mail_send(map_session_data *sd, const char *dest_name, const char *title, c
 	else
 		memset(msg.body, 0x00, MAIL_BODY_LENGTH);
 
-	msg.timestamp = time(NULL);
+	msg.timestamp = time(nullptr);
 	if( !intif_Mail_send(sd->status.account_id, &msg) )
 		mail_deliveryfail(sd, &msg);
 
@@ -529,7 +529,7 @@ void mail_refresh_remaining_amount( map_session_data* sd ){
 	nullpo_retv(sd);
 
 	// If it was not yet started or it was started on another day
-	if( sd->sc.getSCE(SC_DAILYSENDMAILCNT) == NULL || sd->sc.getSCE(SC_DAILYSENDMAILCNT)->val1 != doy ){
+	if( sd->sc.getSCE(SC_DAILYSENDMAILCNT) == nullptr || sd->sc.getSCE(SC_DAILYSENDMAILCNT)->val1 != doy ){
 		sc_start2( &sd->bl, &sd->bl, SC_DAILYSENDMAILCNT, 100, doy, 0, INFINITE_TICK );
 	}
 }

+ 133 - 133
src/map/map.cpp

@@ -105,15 +105,15 @@ Sql* logmysql_handle;
 struct inter_conf inter_config {};
 
 // DBMap declaration
-static DBMap* id_db=NULL; /// int id -> struct block_list*
-static DBMap* pc_db=NULL; /// int id -> map_session_data*
-static DBMap* mobid_db=NULL; /// int id -> struct mob_data*
-static DBMap* bossid_db=NULL; /// int id -> struct mob_data* (MVP db)
-static DBMap* map_db=NULL; /// unsigned int mapindex -> struct map_data*
-static DBMap* nick_db=NULL; /// uint32 char_id -> struct charid2nick* (requested names of offline characters)
-static DBMap* charid_db=NULL; /// uint32 char_id -> map_session_data*
-static DBMap* regen_db=NULL; /// int id -> struct block_list* (status_natural_heal processing)
-static DBMap* map_msg_db=NULL;
+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* 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)
+static DBMap* map_msg_db=nullptr;
 
 static int map_users=0;
 
@@ -238,7 +238,7 @@ int map_freeblock (struct block_list *bl)
 	if (block_free_lock == 0 || block_free_count >= block_free_max)
 	{
 		aFree(bl);
-		bl = NULL;
+		bl = nullptr;
 		if (block_free_count >= block_free_max)
 			ShowWarning("map_freeblock: too many free block! %d %d\n", block_free_count, block_free_lock);
 	} else
@@ -264,7 +264,7 @@ int map_freeblock_unlock (void)
 		for (i = 0; i < block_free_count; i++)
 		{
 			aFree(block_free[i]);
-			block_free[i] = NULL;
+			block_free[i] = nullptr;
 		}
 		block_free_count = 0;
 	} else if (block_free_lock < 0) {
@@ -332,8 +332,8 @@ int map_addblock(struct block_list* bl)
 
 	nullpo_ret(bl);
 
-	if (bl->prev != NULL) {
-		ShowError("map_addblock: bl->prev != NULL\n");
+	if (bl->prev != nullptr) {
+		ShowError("map_addblock: bl->prev != nullptr\n");
 		return 1;
 	}
 
@@ -388,10 +388,10 @@ int map_delblock(struct block_list* bl)
 	nullpo_ret(bl);
 
 	// blocklist (2ways chainlist)
-	if (bl->prev == NULL) {
-		if (bl->next != NULL) {
+	if (bl->prev == nullptr) {
+		if (bl->next != nullptr) {
 			// can't delete block (already at the beginning of the chain)
-			ShowError("map_delblock error : bl->next!=NULL\n");
+			ShowError("map_delblock error : bl->next!=nullptr\n");
 		}
 		return 0;
 	}
@@ -420,8 +420,8 @@ int map_delblock(struct block_list* bl)
 	} else {
 		bl->prev->next = bl->next;
 	}
-	bl->next = NULL;
-	bl->prev = NULL;
+	bl->next = nullptr;
+	bl->prev = nullptr;
 
 	return 0;
 }
@@ -441,7 +441,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, t_tick tick)
 	nullpo_ret(bl);
 
 	int x0 = bl->x, y0 = bl->y;
-	status_change *sc = NULL;
+	status_change *sc = nullptr;
 	int moveblock = ( x0/BLOCK_SIZE != x1/BLOCK_SIZE || y0/BLOCK_SIZE != y1/BLOCK_SIZE);
 
 	if (!bl->prev) {
@@ -494,7 +494,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, t_tick tick)
 
 		if( bl->type == BL_PC && ((TBL_PC*)bl)->shadowform_id ) {//Shadow Form Target Moving
 			struct block_list *d_bl;
-			if( (d_bl = map_id2bl(((TBL_PC*)bl)->shadowform_id)) == NULL || !check_distance_bl(bl,d_bl,10) ) {
+			if( (d_bl = map_id2bl(((TBL_PC*)bl)->shadowform_id)) == nullptr || !check_distance_bl(bl,d_bl,10) ) {
 				if( d_bl )
 					status_change_end(d_bl,SC__SHADOWFORM);
 				((TBL_PC*)bl)->shadowform_id = 0;
@@ -505,7 +505,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, t_tick tick)
 			if (sc->getSCE(SC_DANCING))
 				skill_unit_move_unit_group(skill_id2group(sc->getSCE(SC_DANCING)->val2), bl->m, x1-x0, y1-y0);
 			else {
-				if (sc->getSCE(SC_CLOAKING) && sc->getSCE(SC_CLOAKING)->val1 < 3 && !skill_check_cloaking(bl, NULL))
+				if (sc->getSCE(SC_CLOAKING) && sc->getSCE(SC_CLOAKING)->val1 < 3 && !skill_check_cloaking(bl, nullptr))
 					status_change_end(bl, SC_CLOAKING);
 				if (sc->getSCE(SC_WARM))
 					skill_unit_move_unit_group(skill_id2group(sc->getSCE(SC_WARM)->val4), bl->m, x1-x0, y1-y0);
@@ -519,16 +519,16 @@ int map_moveblock(struct block_list *bl, int x1, int y1, t_tick tick)
 
 				if( sc->getSCE(SC__SHADOWFORM) ) {//Shadow Form Caster Moving
 					struct block_list *d_bl;
-					if( (d_bl = map_id2bl(sc->getSCE(SC__SHADOWFORM)->val2)) == NULL || !check_distance_bl(bl,d_bl,10) )
+					if( (d_bl = map_id2bl(sc->getSCE(SC__SHADOWFORM)->val2)) == nullptr || !check_distance_bl(bl,d_bl,10) )
 						status_change_end(bl,SC__SHADOWFORM);
 				}
 
 				if (sc->getSCE(SC_PROPERTYWALK)
 					&& sc->getSCE(SC_PROPERTYWALK)->val3 < skill_get_maxcount(sc->getSCE(SC_PROPERTYWALK)->val1,sc->getSCE(SC_PROPERTYWALK)->val2)
-					&& map_find_skill_unit_oncell(bl,bl->x,bl->y,SO_ELECTRICWALK,NULL,0) == NULL
-					&& map_find_skill_unit_oncell(bl,bl->x,bl->y,NPC_ELECTRICWALK,NULL,0) == NULL
-					&& map_find_skill_unit_oncell(bl,bl->x,bl->y,SO_FIREWALK,NULL,0) == NULL
-					&& map_find_skill_unit_oncell(bl,bl->x,bl->y,NPC_FIREWALK,NULL,0) == NULL
+					&& map_find_skill_unit_oncell(bl,bl->x,bl->y,SO_ELECTRICWALK,nullptr,0) == nullptr
+					&& map_find_skill_unit_oncell(bl,bl->x,bl->y,NPC_ELECTRICWALK,nullptr,0) == nullptr
+					&& map_find_skill_unit_oncell(bl,bl->x,bl->y,SO_FIREWALK,nullptr,0) == nullptr
+					&& map_find_skill_unit_oncell(bl,bl->x,bl->y,NPC_FIREWALK,nullptr,0) == nullptr
 					&& skill_unitsetting(bl,sc->getSCE(SC_PROPERTYWALK)->val1,sc->getSCE(SC_PROPERTYWALK)->val2,x0, y0,0)) {
 						sc->getSCE(SC_PROPERTYWALK)->val3++;
 				}
@@ -573,7 +573,7 @@ int map_count_oncell(int16 m, int16 x, int16 y, int type, int flag)
 	by = y/BLOCK_SIZE;
 
 	if (type&~BL_MOB)
-		for( bl = mapdata->block[bx+by*mapdata->bxs] ; bl != NULL ; bl = bl->next )
+		for( bl = mapdata->block[bx+by*mapdata->bxs] ; bl != nullptr ; bl = bl->next )
 			if(bl->x == x && bl->y == y && bl->type&type) {
 				if (bl->type == BL_NPC) {	// Don't count hidden or invisible npc. Cloaked npc are counted
 					npc_data *nd = BL_CAST(BL_NPC, bl);
@@ -590,7 +590,7 @@ int map_count_oncell(int16 m, int16 x, int16 y, int type, int flag)
 			}
 
 	if (type&BL_MOB)
-		for( bl = mapdata->block_mob[bx+by*mapdata->bxs] ; bl != NULL ; bl = bl->next )
+		for( bl = mapdata->block_mob[bx+by*mapdata->bxs] ; bl != nullptr ; bl = bl->next )
 			if(bl->x == x && bl->y == y) {
 				if(flag&1) {
 					struct unit_data *ud = unit_bl2ud(bl);
@@ -615,12 +615,12 @@ struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int16 x,
 	struct map_data *mapdata = map_getmapdata(target->m);
 
 	if (x < 0 || y < 0 || (x >= mapdata->xs) || (y >= mapdata->ys))
-		return NULL;
+		return nullptr;
 
 	bx = x/BLOCK_SIZE;
 	by = y/BLOCK_SIZE;
 
-	for( bl = mapdata->block[bx+by*mapdata->bxs] ; bl != NULL ; bl = bl->next )
+	for( bl = mapdata->block[bx+by*mapdata->bxs] ; bl != nullptr ; bl = bl->next )
 	{
 		if (bl->x != x || bl->y != y || bl->type != BL_SKILL)
 			continue;
@@ -631,7 +631,7 @@ struct skill_unit* map_find_skill_unit_oncell(struct block_list* target,int16 x,
 		if( !(flag&1) || battle_check_target(&unit->bl,target,unit->group->target_flag) > 0 )
 			return unit;
 	}
-	return NULL;
+	return nullptr;
 }
 
 /*==========================================
@@ -664,13 +664,13 @@ int map_foreachinrangeV(int (*func)(struct block_list*,va_list),struct block_lis
 	if ( type&~BL_MOB ) {
 		for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
 			for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ) {
-				for(bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next ) {
+				for(bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next ) {
 					if( bl->type&type
 						&& bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1
 #ifdef CIRCULAR_AREA
 						&& check_distance_bl(center, bl, range)
 #endif
-						&& ( !wall_check || path_search_long(NULL, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL) )
+						&& ( !wall_check || path_search_long(nullptr, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL) )
 					  	&& bl_list_count < BL_LIST_MAX )
 						bl_list[ bl_list_count++ ] = bl;
 				}
@@ -681,12 +681,12 @@ int map_foreachinrangeV(int (*func)(struct block_list*,va_list),struct block_lis
 	if ( type&BL_MOB ) {
 		for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
 			for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ) {
-				for(bl = mapdata->block_mob[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next ) {
+				for(bl = mapdata->block_mob[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next ) {
 					if( bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1
 #ifdef CIRCULAR_AREA
 						&& check_distance_bl(center, bl, range)
 #endif
-						&& ( !wall_check || path_search_long(NULL, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL) )
+						&& ( !wall_check || path_search_long(nullptr, center->m, center->x, center->y, bl->x, bl->y, CELL_CHKWALL) )
 					  	&& bl_list_count < BL_LIST_MAX )
 						bl_list[ bl_list_count++ ] = bl;
 				}
@@ -792,10 +792,10 @@ int map_foreachinareaV(int(*func)(struct block_list*, va_list), int16 m, int16 x
 	if( type&~BL_MOB ) {
 		for (by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++) {
 			for (bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++) {
-				for(bl = mapdata->block[bx + by * mapdata->bxs]; bl != NULL; bl = bl->next) {
+				for(bl = mapdata->block[bx + by * mapdata->bxs]; bl != nullptr; bl = bl->next) {
 					if ( bl->type&type
 						&& bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1
-						&& ( !wall_check || path_search_long(NULL, m, cx, cy, bl->x, bl->y, CELL_CHKWALL) )
+						&& ( !wall_check || path_search_long(nullptr, m, cx, cy, bl->x, bl->y, CELL_CHKWALL) )
 						&& bl_list_count < BL_LIST_MAX )
 						bl_list[bl_list_count++] = bl;
 				}
@@ -806,9 +806,9 @@ int map_foreachinareaV(int(*func)(struct block_list*, va_list), int16 m, int16 x
 	if( type&BL_MOB ) {
 		for (by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++) {
 			for (bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++) {
-				for(bl = mapdata->block_mob[bx + by * mapdata->bxs]; bl != NULL; bl = bl->next) {
+				for(bl = mapdata->block_mob[bx + by * mapdata->bxs]; bl != nullptr; bl = bl->next) {
 					if ( bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1
-						&& ( !wall_check || path_search_long(NULL, m, cx, cy, bl->x, bl->y, CELL_CHKWALL) )
+						&& ( !wall_check || path_search_long(nullptr, m, cx, cy, bl->x, bl->y, CELL_CHKWALL) )
 						&& bl_list_count < BL_LIST_MAX )
 						bl_list[bl_list_count++] = bl;
 				}
@@ -892,7 +892,7 @@ int map_forcountinrange(int (*func)(struct block_list*,va_list), struct block_li
 	if ( type&~BL_MOB )
 		for ( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
 			for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ) {
-				for( bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next ) {
+				for( bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next ) {
 					if( bl->type&type
 						&& bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1
 #ifdef CIRCULAR_AREA
@@ -906,7 +906,7 @@ int map_forcountinrange(int (*func)(struct block_list*,va_list), struct block_li
 	if( type&BL_MOB )
 		for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
 			for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ){
-				for( bl = mapdata->block_mob[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next ) {
+				for( bl = mapdata->block_mob[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next ) {
 					if( bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1
 #ifdef CIRCULAR_AREA
 						&& check_distance_bl(center, bl, range)
@@ -966,14 +966,14 @@ int map_forcountinarea(int (*func)(struct block_list*,va_list), int16 m, int16 x
 	if ( type&~BL_MOB )
 		for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ )
 			for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ )
-				for( bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next )
+				for( bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next )
 					if( bl->type&type && bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1 && bl_list_count < BL_LIST_MAX )
 						bl_list[ bl_list_count++ ] = bl;
 
 	if( type&BL_MOB )
 		for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ )
 			for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ )
-				for( bl = mapdata->block_mob[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next )
+				for( bl = mapdata->block_mob[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next )
 					if( bl->x >= x0 && bl->x <= x1 && bl->y >= y0 && bl->y <= y1 && bl_list_count < BL_LIST_MAX )
 						bl_list[ bl_list_count++ ] = bl;
 
@@ -1053,7 +1053,7 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
 		for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
 			for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ) {
 				if ( type&~BL_MOB ) {
-					for( bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next ) {
+					for( bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next ) {
 						if( bl->type&type &&
 							bl->x >= x0 && bl->x <= x1 &&
 							bl->y >= y0 && bl->y <= y1 &&
@@ -1062,7 +1062,7 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
 					}
 				}
 				if ( type&BL_MOB ) {
-					for( bl = mapdata->block_mob[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next ) {
+					for( bl = mapdata->block_mob[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next ) {
 						if( bl->x >= x0 && bl->x <= x1 &&
 							bl->y >= y0 && bl->y <= y1 &&
 							bl_list_count < BL_LIST_MAX )
@@ -1080,7 +1080,7 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
 		for( by = y0 / BLOCK_SIZE; by <= y1 / BLOCK_SIZE; by++ ) {
 			for( bx = x0 / BLOCK_SIZE; bx <= x1 / BLOCK_SIZE; bx++ ) {
 				if ( type & ~BL_MOB ) {
-					for( bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next ) {
+					for( bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next ) {
 						if( bl->type&type &&
 							bl->x >= x0 && bl->x <= x1 &&
 							bl->y >= y0 && bl->y <= y1 &&
@@ -1093,7 +1093,7 @@ int map_foreachinmovearea(int (*func)(struct block_list*,va_list), struct block_
 					}
 				}
 				if ( type&BL_MOB ) {
-					for( bl = mapdata->block_mob[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next ) {
+					for( bl = mapdata->block_mob[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next ) {
 						if( bl->x >= x0 && bl->x <= x1 &&
 							bl->y >= y0 && bl->y <= y1 &&
 							bl_list_count < BL_LIST_MAX)
@@ -1150,11 +1150,11 @@ int map_foreachincell(int (*func)(struct block_list*,va_list), int16 m, int16 x,
 	bx = x / BLOCK_SIZE;
 
 	if( type&~BL_MOB )
-		for( bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next )
+		for( bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next )
 			if( bl->type&type && bl->x == x && bl->y == y && bl_list_count < BL_LIST_MAX )
 				bl_list[ bl_list_count++ ] = bl;
 	if( type&BL_MOB )
-		for( bl = mapdata->block_mob[ bx + by * mapdata->bxs]; bl != NULL; bl = bl->next )
+		for( bl = mapdata->block_mob[ bx + by * mapdata->bxs]; bl != nullptr; bl = bl->next )
 			if( bl->x == x && bl->y == y && bl_list_count < BL_LIST_MAX)
 				bl_list[ bl_list_count++ ] = bl;
 
@@ -1280,7 +1280,7 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int16 m,int16 x0,i
 	if ( type&~BL_MOB )
 		for ( by = my0 / BLOCK_SIZE; by <= my1 / BLOCK_SIZE; by++ ) {
 			for( bx = mx0 / BLOCK_SIZE; bx <= mx1 / BLOCK_SIZE; bx++ ) {
-				for( bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next ) {
+				for( bl = mapdata->block[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next ) {
 					if( bl->prev && bl->type&type && bl_list_count < BL_LIST_MAX ) {
 						xi = bl->x;
 						yi = bl->y;
@@ -1290,7 +1290,7 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int16 m,int16 x0,i
 						if ( k < 0 || k > len_limit ) //Since more skills use this, check for ending point as well.
 							continue;
 
-						if ( k > magnitude2 && !path_search_long(NULL, m, x0, y0, xi, yi, CELL_CHKWALL) )
+						if ( k > magnitude2 && !path_search_long(nullptr, m, x0, y0, xi, yi, CELL_CHKWALL) )
 							continue; //Targets beyond the initial ending point need the wall check.
 
 						//All these shifts are to increase the precision of the intersection point and distance considering how it's
@@ -1314,7 +1314,7 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int16 m,int16 x0,i
 	 if( type&BL_MOB )
 		for( by = my0 / BLOCK_SIZE; by <= my1 / BLOCK_SIZE; by++ ) {
 			for( bx = mx0 / BLOCK_SIZE; bx <= mx1 / BLOCK_SIZE; bx++ ) {
-				for( bl = mapdata->block_mob[ bx + by * mapdata->bxs ]; bl != NULL; bl = bl->next ) {
+				for( bl = mapdata->block_mob[ bx + by * mapdata->bxs ]; bl != nullptr; bl = bl->next ) {
 					if( bl->prev && bl_list_count < BL_LIST_MAX ) {
 						xi = bl->x;
 						yi = bl->y;
@@ -1323,7 +1323,7 @@ int map_foreachinpath(int (*func)(struct block_list*,va_list),int16 m,int16 x0,i
 						if ( k < 0 || k > len_limit )
 							continue;
 
-						if ( k > magnitude2 && !path_search_long(NULL, m, x0, y0, xi, yi, CELL_CHKWALL) )
+						if ( k > magnitude2 && !path_search_long(nullptr, m, x0, y0, xi, yi, CELL_CHKWALL) )
 							continue; //Targets beyond the initial ending point need the wall check.
 
 						k  = ( k << 4 ) / magnitude2; //k will be between 1~16 instead of 0~1
@@ -1440,7 +1440,7 @@ int map_foreachindir(int(*func)(struct block_list*, va_list), int16 m, int16 x0,
 	if (type&~BL_MOB) {
 		for (by = my0 / BLOCK_SIZE; by <= my1 / BLOCK_SIZE; by++) {
 			for (bx = mx0 / BLOCK_SIZE; bx <= mx1 / BLOCK_SIZE; bx++) {
-				for (bl = mapdata->block[bx + by * mapdata->bxs]; bl != NULL; bl = bl->next) {
+				for (bl = mapdata->block[bx + by * mapdata->bxs]; bl != nullptr; bl = bl->next) {
 					if (bl->prev && bl->type&type && bl_list_count < BL_LIST_MAX) {
 						//Check if inside search area
 						if (bl->x < mx0 || bl->x > mx1 || bl->y < my0 || bl->y > my1)
@@ -1464,7 +1464,7 @@ int map_foreachindir(int(*func)(struct block_list*, va_list), int16 m, int16 x0,
 								continue;
 						}
 						//Everything else ok, check for line of sight from source
-						if (!path_search_long(NULL, m, x0, y0, bl->x, bl->y, CELL_CHKWALL))
+						if (!path_search_long(nullptr, m, x0, y0, bl->x, bl->y, CELL_CHKWALL))
 							continue;
 						//All checks passed, add to list
 						bl_list[bl_list_count++] = bl;
@@ -1476,7 +1476,7 @@ int map_foreachindir(int(*func)(struct block_list*, va_list), int16 m, int16 x0,
 	if (type&BL_MOB) {
 		for (by = my0 / BLOCK_SIZE; by <= my1 / BLOCK_SIZE; by++) {
 			for (bx = mx0 / BLOCK_SIZE; bx <= mx1 / BLOCK_SIZE; bx++) {
-				for (bl = mapdata->block_mob[bx + by * mapdata->bxs]; bl != NULL; bl = bl->next) {
+				for (bl = mapdata->block_mob[bx + by * mapdata->bxs]; bl != nullptr; bl = bl->next) {
 					if (bl->prev && bl_list_count < BL_LIST_MAX) {
 						//Check if inside search area
 						if (bl->x < mx0 || bl->x > mx1 || bl->y < my0 || bl->y > my1)
@@ -1500,7 +1500,7 @@ int map_foreachindir(int(*func)(struct block_list*, va_list), int16 m, int16 x0,
 								continue;
 						}
 						//Everything else ok, check for line of sight from source
-						if (!path_search_long(NULL, m, x0, y0, bl->x, bl->y, CELL_CHKWALL))
+						if (!path_search_long(nullptr, m, x0, y0, bl->x, bl->y, CELL_CHKWALL))
 							continue;
 						//All checks passed, add to list
 						bl_list[bl_list_count++] = bl;
@@ -1546,13 +1546,13 @@ int map_foreachinmap(int (*func)(struct block_list*,va_list), int16 m, int type,
 
 	if( type&~BL_MOB )
 		for( b = 0; b < bsize; b++ )
-			for( bl = mapdata->block[ b ]; bl != NULL; bl = bl->next )
+			for( bl = mapdata->block[ b ]; bl != nullptr; bl = bl->next )
 				if( bl->type&type && bl_list_count < BL_LIST_MAX )
 					bl_list[ bl_list_count++ ] = bl;
 
 	if( type&BL_MOB )
 		for( b = 0; b < bsize; b++ )
-			for( bl = mapdata->block_mob[ b ]; bl != NULL; bl = bl->next )
+			for( bl = mapdata->block_mob[ b ]; bl != nullptr; bl = bl->next )
 				if( bl_list_count < BL_LIST_MAX )
 					bl_list[ bl_list_count++ ] = bl;
 
@@ -1613,7 +1613,7 @@ int map_get_new_object_id(void)
 TIMER_FUNC(map_clearflooritem_timer){
 	struct flooritem_data* fitem = (struct flooritem_data*)idb_get(id_db, id);
 
-	if (fitem == NULL || fitem->bl.type != BL_ITEM || (fitem->cleartimer != tid)) {
+	if (fitem == nullptr || fitem->bl.type != BL_ITEM || (fitem->cleartimer != tid)) {
 		ShowError("map_clearflooritem_timer : error\n");
 		return 1;
 	}
@@ -1706,7 +1706,7 @@ int map_search_freecell(struct block_list *src, int16 m, int16 *x,int16 *y, int1
 
 	if( !src && (!(flag&1) || flag&2) )
 	{
-		ShowDebug("map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2\n");
+		ShowDebug("map_search_freecell: Incorrect usage! When src is nullptr, flag has to be &1 and can't have &2\n");
 		return 0;
 	}
 
@@ -1864,7 +1864,7 @@ bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag)
  *------------------------------------------*/
 int map_addflooritem(struct item *item, int amount, int16 m, int16 x, int16 y, int first_charid, int second_charid, int third_charid, int flags, unsigned short mob_id, bool canShowEffect)
 {
-	struct flooritem_data *fitem = NULL;
+	struct flooritem_data *fitem = nullptr;
 
 	nullpo_ret(item);
 
@@ -1876,7 +1876,7 @@ int map_addflooritem(struct item *item, int amount, int16 m, int16 x, int16 y, i
 
 	CREATE(fitem, struct flooritem_data, 1);
 	fitem->bl.type=BL_ITEM;
-	fitem->bl.prev = fitem->bl.next = NULL;
+	fitem->bl.prev = fitem->bl.next = nullptr;
 	fitem->bl.m=m;
 	fitem->bl.x=x;
 	fitem->bl.y=y;
@@ -1949,7 +1949,7 @@ void map_delnickdb(int charid, const char* name)
 	struct charid2nick* p;
 	DBData data;
 
-	if (!nick_db->remove(nick_db, db_i2key(charid), &data) || (p = (struct charid2nick*)db_data2ptr(&data)) == NULL)
+	if (!nick_db->remove(nick_db, db_i2key(charid), &data) || (p = (struct charid2nick*)db_data2ptr(&data)) == nullptr)
 		return;
 
 	while( p->requests ) {
@@ -2168,12 +2168,12 @@ int map_quit(map_session_data *sd) {
  * Lookup, id to session (player,mob,npc,homon,merc..)
  *------------------------------------------*/
 map_session_data * map_id2sd(int id){
-	if (id <= 0) return NULL;
+	if (id <= 0) return nullptr;
 	return (map_session_data*)idb_get(pc_db,id);
 }
 
 struct mob_data * map_id2md(int id){
-	if (id <= 0) return NULL;
+	if (id <= 0) return nullptr;
 	return (struct mob_data*)idb_get(mobid_db,id);
 }
 
@@ -2207,7 +2207,7 @@ struct chat_data* map_id2cd(int id){
 	return BL_CAST(BL_CHAT, bl);
 }
 
-/// Returns the nick of the target charid or NULL if unknown (requests the nick to the char server).
+/// Returns the nick of the target charid or nullptr if unknown (requests the nick to the char server).
 const char* map_charid2nick(int charid)
 {
 	struct charid2nick *p;
@@ -2222,10 +2222,10 @@ const char* map_charid2nick(int charid)
 		return p->nick;// name in nick_db
 
 	chrif_searchcharid(charid);// request the name
-	return NULL;
+	return nullptr;
 }
 
-/// Returns the map_session_data of the charid or NULL if the char is not online.
+/// Returns the map_session_data of the charid or nullptr if the char is not online.
 map_session_data* map_charid2sd(int charid)
 {
 	return (map_session_data*)uidb_get(charid_db, charid);
@@ -2234,7 +2234,7 @@ map_session_data* map_charid2sd(int charid)
 /*==========================================
  * Search session data from a nick name
  * (without sensitive case if necessary)
- * return map_session_data pointer or NULL
+ * return map_session_data pointer or nullptr
  *------------------------------------------*/
 map_session_data * map_nick2sd(const char *nick, bool allow_partial)
 {
@@ -2244,13 +2244,13 @@ map_session_data * map_nick2sd(const char *nick, bool allow_partial)
 	size_t nicklen;
 	int qty = 0;
 
-	if( nick == NULL )
-		return NULL;
+	if( nick == nullptr )
+		return nullptr;
 
 	nicklen = strlen(nick);
 	iter = mapit_getallusers();
 
-	found_sd = NULL;
+	found_sd = nullptr;
 	for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
 	{
 		if( allow_partial && battle_config.partial_name_scan )
@@ -2278,13 +2278,13 @@ map_session_data * map_nick2sd(const char *nick, bool allow_partial)
 	mapit_free(iter);
 
 	if( battle_config.partial_name_scan && qty != 1 )
-		found_sd = NULL;
+		found_sd = nullptr;
 
 	return found_sd;
 }
 
 /*==========================================
- * Looksup id_db DBMap and returns BL pointer of 'id' or NULL if not found
+ * Looksup id_db DBMap and returns BL pointer of 'id' or nullptr if not found
  *------------------------------------------*/
 struct block_list * map_id2bl(int id) {
 	return (struct block_list*)idb_get(id_db,id);
@@ -2303,7 +2303,7 @@ bool map_blid_exists( int id ) {
 struct mob_data * map_getmob_boss(int16 m)
 {
 	DBIterator* iter;
-	struct mob_data *md = NULL;
+	struct mob_data *md = nullptr;
 	bool found = false;
 
 	iter = db_iterator(bossid_db);
@@ -2317,12 +2317,12 @@ struct mob_data * map_getmob_boss(int16 m)
 	}
 	dbi_destroy(iter);
 
-	return (found)? md : NULL;
+	return (found)? md : nullptr;
 }
 
 struct mob_data * map_id2boss(int id)
 {
-	if (id <= 0) return NULL;
+	if (id <= 0) return nullptr;
 	return (struct mob_data*)idb_get(bossid_db,id);
 }
 
@@ -2492,17 +2492,17 @@ void mapit_free(struct s_mapiterator* mapit)
 }
 
 /// Returns the first block_list that matches the description.
-/// Returns NULL if not found.
+/// Returns nullptr if not found.
 ///
 /// @param mapit Iterator
-/// @return first block_list or NULL
+/// @return first block_list or nullptr
 struct block_list* mapit_first(struct s_mapiterator* mapit)
 {
 	struct block_list* bl;
 
-	nullpo_retr(NULL,mapit);
+	nullpo_retr(nullptr,mapit);
 
-	for( bl = (struct block_list*)dbi_first(mapit->dbi); bl != NULL; bl = (struct block_list*)dbi_next(mapit->dbi) )
+	for( bl = (struct block_list*)dbi_first(mapit->dbi); bl != nullptr; bl = (struct block_list*)dbi_next(mapit->dbi) )
 	{
 		if( MAPIT_MATCHES(mapit,bl) )
 			break;// found match
@@ -2511,17 +2511,17 @@ struct block_list* mapit_first(struct s_mapiterator* mapit)
 }
 
 /// Returns the last block_list that matches the description.
-/// Returns NULL if not found.
+/// Returns nullptr if not found.
 ///
 /// @param mapit Iterator
-/// @return last block_list or NULL
+/// @return last block_list or nullptr
 struct block_list* mapit_last(struct s_mapiterator* mapit)
 {
 	struct block_list* bl;
 
-	nullpo_retr(NULL,mapit);
+	nullpo_retr(nullptr,mapit);
 
-	for( bl = (struct block_list*)dbi_last(mapit->dbi); bl != NULL; bl = (struct block_list*)dbi_prev(mapit->dbi) )
+	for( bl = (struct block_list*)dbi_last(mapit->dbi); bl != nullptr; bl = (struct block_list*)dbi_prev(mapit->dbi) )
 	{
 		if( MAPIT_MATCHES(mapit,bl) )
 			break;// found match
@@ -2530,20 +2530,20 @@ struct block_list* mapit_last(struct s_mapiterator* mapit)
 }
 
 /// Returns the next block_list that matches the description.
-/// Returns NULL if not found.
+/// Returns nullptr if not found.
 ///
 /// @param mapit Iterator
-/// @return next block_list or NULL
+/// @return next block_list or nullptr
 struct block_list* mapit_next(struct s_mapiterator* mapit)
 {
 	struct block_list* bl;
 
-	nullpo_retr(NULL,mapit);
+	nullpo_retr(nullptr,mapit);
 
 	for( ; ; )
 	{
 		bl = (struct block_list*)dbi_next(mapit->dbi);
-		if( bl == NULL )
+		if( bl == nullptr )
 			break;// end
 		if( MAPIT_MATCHES(mapit,bl) )
 			break;// found a match
@@ -2553,20 +2553,20 @@ struct block_list* mapit_next(struct s_mapiterator* mapit)
 }
 
 /// Returns the previous block_list that matches the description.
-/// Returns NULL if not found.
+/// Returns nullptr if not found.
 ///
 /// @param mapit Iterator
-/// @return previous block_list or NULL
+/// @return previous block_list or nullptr
 struct block_list* mapit_prev(struct s_mapiterator* mapit)
 {
 	struct block_list* bl;
 
-	nullpo_retr(NULL,mapit);
+	nullpo_retr(nullptr,mapit);
 
 	for( ; ; )
 	{
 		bl = (struct block_list*)dbi_prev(mapit->dbi);
-		if( bl == NULL )
+		if( bl == nullptr )
 			break;// end
 		if( MAPIT_MATCHES(mapit,bl) )
 			break;// found a match
@@ -2825,7 +2825,7 @@ int map_addmobtolist(unsigned short m, struct spawn_data *spawn)
 	size_t i;
 	struct map_data *mapdata = map_getmapdata(m);
 
-	ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, mapdata->moblist[i] == NULL );
+	ARR_FIND( 0, MAX_MOB_LIST_PER_MAP, i, mapdata->moblist[i] == nullptr );
 	if( i < MAX_MOB_LIST_PER_MAP )
 	{
 		mapdata->moblist[i] = spawn;
@@ -2846,7 +2846,7 @@ void map_spawnmobs(int16 m)
 		return;
 	}
 	for(i=0; i<MAX_MOB_LIST_PER_MAP; i++)
-		if(mapdata->moblist[i]!=NULL)
+		if(mapdata->moblist[i]!=nullptr)
 		{
 			k+=mapdata->moblist[i]->num;
 			npc_parse_mob2(mapdata->moblist[i]);
@@ -2974,13 +2974,13 @@ int16 map_mapname2mapid(const char* name)
  *------------------------------------------*/
 int16 map_mapindex2mapid(unsigned short mapindex)
 {
-	struct map_data *md=NULL;
+	struct map_data *md=nullptr;
 
 	if (!mapindex)
 		return -1;
 
 	md = (struct map_data*)uidb_get(map_db,(unsigned int)mapindex);
-	if(md==NULL || md->cell==NULL)
+	if(md==nullptr || md->cell==nullptr)
 		return -1;
 	return md->m;
 }
@@ -2993,7 +2993,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);
-	if(mdos==NULL || mdos->cell) //If gat isn't null, this is a local map.
+	if(mdos==nullptr || mdos->cell) //If gat isn't null, this is a local map.
 		return -1;
 	*ip=mdos->ip;
 	*port=mdos->port;
@@ -3098,7 +3098,7 @@ int map_random_dir(struct block_list *bl, int16 *x, int16 *y)
 		segment = (short)sqrt((float)(dist2 - segment*segment)); //The complement of the previously picked segment
 		yi = bl->y + segment*diry[j];
 	} while (
-		(map_getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH))
+		(map_getcell(bl->m,xi,yi,CELL_CHKNOPASS) || !path_search(nullptr,bl->m,bl->x,bl->y,xi,yi,1,CELL_CHKNOREACH))
 		&& (++i)<100 );
 
 	if (i < 100) {
@@ -3314,7 +3314,7 @@ bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable
 	if( size < 1 || !wall_name )
 		return false;
 
-	if( (iwall = (struct iwall_data *)strdb_get(iwall_db, wall_name)) != NULL )
+	if( (iwall = (struct iwall_data *)strdb_get(iwall_db, wall_name)) != nullptr )
 		return false; // Already Exists
 
 	if( map_getcell(m, x, y, CELL_CHKNOREACH) )
@@ -3377,7 +3377,7 @@ bool map_iwall_remove(const char *wall_name)
 	struct iwall_data *iwall;
 	int16 i, x1, y1;
 
-	if( (iwall = (struct iwall_data *)strdb_get(iwall_db, wall_name)) == NULL )
+	if( (iwall = (struct iwall_data *)strdb_get(iwall_db, wall_name)) == nullptr )
 		return false; // Nothing to do
 
 	for( i = 0; i < iwall->size; i++ ) {
@@ -3435,7 +3435,7 @@ int map_setipport(unsigned short mapindex, uint32 ip, uint16 port)
 int map_eraseallipport_sub(DBKey key, DBData *data, va_list va)
 {
 	struct map_data_other_server *mdos = (struct map_data_other_server *)db_data2ptr(data);
-	if(mdos->cell == NULL) {
+	if(mdos->cell == nullptr) {
 		db_remove(map_db,key);
 		aFree(mdos);
 	}
@@ -3492,7 +3492,7 @@ static char *map_init_mapcache(FILE *fp)
 	// Read file into buffer..
 	if(fread(buffer, 1, size, fp) != size) {
 		ShowError("map_init_mapcache: Could not read entire mapcache file\n");
-		return NULL;
+		return nullptr;
 	}
 
 	return buffer;
@@ -3506,7 +3506,7 @@ int map_readfromcache(struct map_data *m, char *buffer, char *decode_buffer)
 {
 	int i;
 	struct map_cache_main_header *header = (struct map_cache_main_header *)buffer;
-	struct map_cache_map_info *info = NULL;
+	struct map_cache_map_info *info = nullptr;
 	char *p = buffer + sizeof(struct map_cache_main_header);
 
 	for(i = 0; i < header->map_count; i++) {
@@ -3695,7 +3695,7 @@ int map_readgat (struct map_data* m)
 	sprintf(filename, "data\\%s.gat", m->name);
 
 	gat = (uint8 *) grfio_read(filename);
-	if (gat == NULL)
+	if (gat == nullptr)
 		return 0;
 
 	m->xs = *(int32*)(gat+6);
@@ -3814,11 +3814,11 @@ int map_readallmaps (void)
 
 		mapdata->index = idx;
 
-		if (uidb_get(map_db,(unsigned int)mapdata->index) != NULL) {
+		if (uidb_get(map_db,(unsigned int)mapdata->index) != nullptr) {
 			ShowWarning("Map %s already loaded!" CL_CLL "\n", mapdata->name);
 			if (mapdata->cell) {
 				aFree(mapdata->cell);
-				mapdata->cell = NULL;
+				mapdata->cell = nullptr;
 			}
 			map_delmapid(i);
 			maps_removed++;
@@ -3841,7 +3841,7 @@ int map_readallmaps (void)
 
 		memset(&mapdata->save, 0, sizeof(struct point));
 		mapdata->damage_adjust = {};
-		mapdata->channel = NULL;
+		mapdata->channel = nullptr;
 	}
 
 	// intialization and configuration-dependent adjustments of mapflags
@@ -3950,7 +3950,7 @@ int map_config_read(const char *cfgName)
 	FILE *fp;
 
 	fp = fopen(cfgName,"r");
-	if( fp == NULL )
+	if( fp == nullptr )
 	{
 		ShowError("Map configuration file not found at: %s\n", cfgName);
 		return 1;
@@ -3962,7 +3962,7 @@ int map_config_read(const char *cfgName)
 
 		if( line[0] == '/' && line[1] == '/' )
 			continue;
-		if( (ptr = strstr(line, "//")) != NULL )
+		if( (ptr = strstr(line, "//")) != nullptr )
 			*ptr = '\n'; //Strip comments
 		if( sscanf(line, "%31[^:]: %1023[^\t\r\n]", w1, w2) < 2 )
 			continue;
@@ -4052,7 +4052,7 @@ void map_reloadnpc_sub(const char *cfgName)
 	FILE *fp;
 
 	fp = fopen(cfgName,"r");
-	if( fp == NULL )
+	if( fp == nullptr )
 	{
 		ShowError("Map configuration file not found at: %s\n", cfgName);
 		return;
@@ -4064,7 +4064,7 @@ void map_reloadnpc_sub(const char *cfgName)
 
 		if( line[0] == '/' && line[1] == '/' )
 			continue;
-		if( (ptr = strstr(line, "//")) != NULL )
+		if( (ptr = strstr(line, "//")) != nullptr )
 			*ptr = '\n'; //Strip comments
 		if( sscanf(line, "%1023[^:]: %1023[^\t\r\n]", w1, w2) < 2 )
 			continue;
@@ -4106,7 +4106,7 @@ int inter_config_read(const char *cfgName)
 	FILE *fp;
 
 	fp=fopen(cfgName,"r");
-	if(fp==NULL){
+	if(fp==nullptr){
 		ShowError("File not found: %s\n",cfgName);
 		return 1;
 	}
@@ -4260,14 +4260,14 @@ int map_sql_close(void)
 	ShowStatus("Close Map DB Connection....\n");
 	Sql_Free(mmysql_handle);
 	Sql_Free(qsmysql_handle);
-	mmysql_handle = NULL;
-	qsmysql_handle = NULL;
+	mmysql_handle = nullptr;
+	qsmysql_handle = nullptr;
 
 	if (log_config.sql_logs)
 	{
 		ShowStatus("Close Log DB Connection....\n");
 		Sql_Free(logmysql_handle);
-		logmysql_handle = NULL;
+		logmysql_handle = nullptr;
 	}
 
 	return 0;
@@ -4326,7 +4326,7 @@ static void map_free_questinfo(struct map_data *mapdata) {
 int map_db_final(DBKey key, DBData *data, va_list ap)
 {
 	struct map_data_other_server *mdos = (struct map_data_other_server *)db_data2ptr(data);
-	if(mdos && mdos->cell == NULL)
+	if(mdos && mdos->cell == nullptr)
 		aFree(mdos);
 	return 0;
 }
@@ -4339,7 +4339,7 @@ int nick_db_final(DBKey key, DBData *data, va_list args)
 	struct charid2nick* p = (struct charid2nick*)db_data2ptr(data);
 	struct charid_request* req;
 
-	if( p == NULL )
+	if( p == nullptr )
 		return 0;
 	while( p->requests )
 	{
@@ -4491,7 +4491,7 @@ bool map_getmapflag_name( enum e_mapflag mapflag, char* output ){
 	constant = script_get_constant_str( prefix, mapflag );
 
 	// Should never happen
-	if (constant == NULL)
+	if (constant == nullptr)
 		return false;
 
 	// Begin copy after the prefix
@@ -4654,7 +4654,7 @@ bool map_setmapflag_sub(int16 m, enum e_mapflag mapflag, bool status, union u_ma
 				if (mapdata->getMapFlag(MF_PVP)) {
 					mapdata->setMapFlag(MF_PVP, false);
 					if (!battle_config.pk_mode)
-						ShowWarning("npc_parse_mapflag: Unable to set PvP and GvG%s Castle flags for the same map! Removing PvP flag from %s.\n", (mapflag == MF_GVG_CASTLE ? NULL : " TE"), mapdata->name);
+						ShowWarning("npc_parse_mapflag: Unable to set PvP and GvG%s Castle flags for the same map! Removing PvP flag from %s.\n", (mapflag == MF_GVG_CASTLE ? nullptr : " TE"), mapdata->name);
 				}
 			}
 			mapdata->setMapFlag(mapflag, status);
@@ -4917,14 +4917,14 @@ void MapServer::finalize(){
 	if(enable_grf)
 		grfio_final();
 
-	id_db->destroy(id_db, NULL);
-	pc_db->destroy(pc_db, NULL);
-	mobid_db->destroy(mobid_db, NULL);
-	bossid_db->destroy(bossid_db, NULL);
+	id_db->destroy(id_db, nullptr);
+	pc_db->destroy(pc_db, nullptr);
+	mobid_db->destroy(mobid_db, nullptr);
+	bossid_db->destroy(bossid_db, nullptr);
 	nick_db->destroy(nick_db, nick_db_final);
-	charid_db->destroy(charid_db, NULL);
-	iwall_db->destroy(iwall_db, NULL);
-	regen_db->destroy(regen_db, NULL);
+	charid_db->destroy(charid_db, nullptr);
+	iwall_db->destroy(iwall_db, nullptr);
+	regen_db->destroy(regen_db, nullptr);
 
 	map_sql_close();
 
@@ -5026,7 +5026,7 @@ void map_do_final_msg(void){
 		aFree(mdb);
 	}
 	dbi_destroy(iter);
-	map_msg_db->destroy(map_msg_db, NULL);
+	map_msg_db->destroy(map_msg_db, nullptr);
 }
 void map_msg_reload(void){
 	map_do_final_msg(); //clear data
@@ -5035,7 +5035,7 @@ void map_msg_reload(void){
 int map_msg_config_read(const char *cfgName, int lang){
 	struct msg_data *mdb;
 
-	if( (mdb = map_lang2msgdb(lang)) == NULL )
+	if( (mdb = map_lang2msgdb(lang)) == nullptr )
 		CREATE(mdb, struct msg_data, 1);
 	else
 		idb_remove(map_msg_db, lang);
@@ -5052,14 +5052,14 @@ const char* map_msg_txt(map_session_data *sd, int msg_number){
 	uint8 lang = 0; //default
 	if(sd && sd->langtype) lang = sd->langtype;
 
-	if( (mdb = map_lang2msgdb(lang)) != NULL){
+	if( (mdb = map_lang2msgdb(lang)) != nullptr){
 		const char *tmp = _msg_txt(msg_number,MAP_MAX_MSG,mdb->msg);
 		if(strcmp(tmp,"??")) //to verify result
 			return tmp;
 		ShowDebug("Message #%d not found for langtype %d.\n",msg_number,lang);
 	}
 	ShowDebug("Selected langtype %d not loaded, trying fallback...\n",lang);
-	if(lang != 0 && (mdb = map_lang2msgdb(0)) != NULL) //fallback
+	if(lang != 0 && (mdb = map_lang2msgdb(0)) != nullptr) //fallback
 		return _msg_txt(msg_number,MAP_MAX_MSG,mdb->msg);
 	return "??";
 }
@@ -5142,7 +5142,7 @@ void MapServer::handle_shutdown(){
 	map_session_data* sd;
 	struct s_mapiterator* iter = mapit_getallusers();
 	for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
-		clif_GM_kick(NULL, sd);
+		clif_GM_kick(nullptr, sd);
 	mapit_free(iter);
 	flush_fifos();
 }

+ 5 - 5
src/map/map.hpp

@@ -797,7 +797,7 @@ struct iwall_data {
 struct map_data {
 	char name[MAP_NAME_LENGTH];
 	uint16 index; // The map index used by the mapindex* functions.
-	struct mapcell* cell; // Holds the information of each map cell (NULL if the map is not on this map-server).
+	struct mapcell* cell; // Holds the information of each map cell (nullptr if the map is not on this map-server).
 	struct block_list **block;
 	struct block_list **block_mob;
 	int16 m;
@@ -856,7 +856,7 @@ private:
 struct map_data_other_server {
 	char name[MAP_NAME_LENGTH];
 	unsigned short index; //Index is the map index used by the mapindex* functions.
-	struct mapcell* cell; // If this is NULL, the map is not on this map-server
+	struct mapcell* cell; // If this is nullptr, the map is not on this map-server
 	uint32 ip;
 	uint16 port;
 };
@@ -1233,8 +1233,8 @@ enum e_mapflag map_getmapflag_by_name(char* name);
 bool map_getmapflag_name(enum e_mapflag mapflag, char* output);
 int map_getmapflag_sub(int16 m, enum e_mapflag mapflag, union u_mapflag_args *args);
 bool map_setmapflag_sub(int16 m, enum e_mapflag mapflag, bool status, union u_mapflag_args *args);
-#define map_getmapflag(m, mapflag) map_getmapflag_sub(m, mapflag, NULL)
-#define map_setmapflag(m, mapflag, status) map_setmapflag_sub(m, mapflag, status, NULL)
+#define map_getmapflag(m, mapflag) map_getmapflag_sub(m, mapflag, nullptr)
+#define map_setmapflag(m, mapflag, status) map_setmapflag_sub(m, mapflag, status, nullptr)
 
 #define CHK_ELEMENT(ele) ((ele) > ELE_NONE && (ele) < ELE_MAX) /// Check valid Element
 #define CHK_ELEMENT_LEVEL(lv) ((lv) >= 1 && (lv) <= MAX_ELE_LEVEL) /// Check valid element level
@@ -1266,7 +1266,7 @@ typedef struct s_mercenary_data   TBL_MER;
 typedef struct s_elemental_data	TBL_ELEM;
 
 #define BL_CAST(type_, bl) \
-	( ((bl) == (struct block_list*)NULL || (bl)->type != (type_)) ? (T ## type_ *)NULL : (T ## type_ *)(bl) )
+	( ((bl) == (struct block_list*)nullptr || (bl)->type != (type_)) ? (T ## type_ *)nullptr : (T ## type_ *)(bl) )
 
 #include <common/sql.hpp>
 

+ 11 - 11
src/map/mapreg.cpp

@@ -49,7 +49,7 @@ int64 mapreg_readreg(int64 uid)
 char* mapreg_readregstr(int64 uid)
 {
 	struct mapreg_save *m = (struct mapreg_save *)i64db_get(regs.vars, uid);
-	return m ? m->u.str : NULL;
+	return m ? m->u.str : nullptr;
 }
 
 /**
@@ -125,7 +125,7 @@ bool mapreg_setregstr(int64 uid, const char* str)
 	uint32 i = script_getvaridx(uid);
 	const char* name = get_str(num);
 
-	if (str == NULL || *str == 0) {
+	if (str == nullptr || *str == 0) {
 		if (i)
 			script_array_update(&regs, uid, true);
 		if (name[1] != '@') {
@@ -135,14 +135,14 @@ bool mapreg_setregstr(int64 uid, const char* str)
 				Sql_ShowDebug(mmysql_handle);
 		}
 		if ((m = static_cast<mapreg_save *>(i64db_get(regs.vars, uid)))) {
-			if (m->u.str != NULL)
+			if (m->u.str != nullptr)
 				aFree(m->u.str);
 			ers_free(mapreg_ers, m);
 		}
 		i64db_remove(regs.vars, uid);
 	} else {
 		if ((m = static_cast<mapreg_save *>(i64db_get(regs.vars, uid)))) {
-			if (m->u.str != NULL)
+			if (m->u.str != nullptr)
 				aFree(m->u.str);
 			m->u.str = aStrdup(str);
 			if (name[1] != '@') {
@@ -202,9 +202,9 @@ static void script_load_mapreg(void)
 
 	skip_insert = true;
 
-	SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &varname[0], sizeof(varname), &length, NULL);
-	SqlStmt_BindColumn(stmt, 1, SQLDT_UINT32, &index, 0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &value[0], sizeof(value), NULL, NULL);
+	SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &varname[0], sizeof(varname), &length, nullptr);
+	SqlStmt_BindColumn(stmt, 1, SQLDT_UINT32, &index, 0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 2, SQLDT_STRING, &value[0], sizeof(value), nullptr, nullptr);
 
 	while ( SQL_SUCCESS == SqlStmt_NextRow(stmt) ) {
 		int s = add_str(varname);
@@ -217,7 +217,7 @@ static void script_load_mapreg(void)
 		if( varname[length-1] == '$' ) {
 			mapreg_setregstr(uid, value);
 		} else {
-			mapreg_setreg(uid, strtoll(value,NULL,10));
+			mapreg_setreg(uid, strtoll(value,nullptr,10));
 		}
 	}
 
@@ -276,7 +276,7 @@ static TIMER_FUNC(script_autosave_mapreg){
  */
 int mapreg_destroyreg(DBKey key, DBData *data, va_list ap)
 {
-	struct mapreg_save *m = NULL;
+	struct mapreg_save *m = nullptr;
 
 	if (data->type != DB_DATA_PTR) // Sanity check
 		return 0;
@@ -306,7 +306,7 @@ void mapreg_reload(void)
 
 	if (regs.arrays) {
 		regs.arrays->destroy(regs.arrays, script_free_array_db);
-		regs.arrays = NULL;
+		regs.arrays = nullptr;
 	}
 
 	script_load_mapreg();
@@ -336,7 +336,7 @@ void mapreg_init(void)
 	mapreg_ers = ers_new(sizeof(struct mapreg_save), "mapreg.cpp:mapreg_ers", ERS_OPT_CLEAN);
 
 	skip_insert = false;
-	regs.arrays = NULL;
+	regs.arrays = nullptr;
 
 	script_load_mapreg();
 

+ 12 - 12
src/map/mercenary.cpp

@@ -83,11 +83,11 @@ bool mercenary_create(map_session_data *sd, uint16 class_, unsigned int lifetime
 * @return The Lifetime
 **/
 t_tick mercenary_get_lifetime(s_mercenary_data *md) {
-	if( md == NULL || md->contract_timer == INVALID_TIMER )
+	if( md == nullptr || md->contract_timer == INVALID_TIMER )
 		return 0;
 
 	const struct TimerData *td = get_timer(md->contract_timer);
-	return (td != NULL) ? DIFF_TICK(td->tick, gettick()) : 0;
+	return (td != nullptr) ? DIFF_TICK(td->tick, gettick()) : 0;
 }
 
 /**
@@ -96,7 +96,7 @@ t_tick mercenary_get_lifetime(s_mercenary_data *md) {
 * @return enum e_MercGuildType
 **/
 e_MercGuildType mercenary_get_guild(s_mercenary_data *md){
-	if( md == NULL || md->db == NULL )
+	if( md == nullptr || md->db == nullptr )
 		return NONE_MERC_GUILD;
 
 	uint16 class_ = md->db->class_;
@@ -119,7 +119,7 @@ e_MercGuildType mercenary_get_guild(s_mercenary_data *md){
 int mercenary_get_faith(s_mercenary_data *md) {
 	map_session_data *sd;
 
-	if( md == NULL || md->db == NULL || (sd = md->master) == NULL )
+	if( md == nullptr || md->db == nullptr || (sd = md->master) == nullptr )
 		return 0;
 
 	e_MercGuildType guild = mercenary_get_guild(md);
@@ -145,7 +145,7 @@ int mercenary_get_faith(s_mercenary_data *md) {
 void mercenary_set_faith(s_mercenary_data *md, int value) {
 	map_session_data *sd;
 
-	if( md == NULL || md->db == NULL || (sd = md->master) == NULL )
+	if( md == nullptr || md->db == nullptr || (sd = md->master) == nullptr )
 		return;
 
 	e_MercGuildType guild = mercenary_get_guild(md);
@@ -178,7 +178,7 @@ void mercenary_set_faith(s_mercenary_data *md, int value) {
 int mercenary_get_calls(s_mercenary_data *md) {
 	map_session_data *sd;
 
-	if( md == NULL || md->db == NULL || (sd = md->master) == NULL )
+	if( md == nullptr || md->db == nullptr || (sd = md->master) == nullptr )
 		return 0;
 
 	e_MercGuildType guild = mercenary_get_guild(md);
@@ -204,7 +204,7 @@ int mercenary_get_calls(s_mercenary_data *md) {
 void mercenary_set_calls(s_mercenary_data *md, int value) {
 	map_session_data *sd;
 
-	if( md == NULL || md->db == NULL || (sd = md->master) == NULL )
+	if( md == nullptr || md->db == nullptr || (sd = md->master) == nullptr )
 		return;
 
 	e_MercGuildType guild = mercenary_get_guild(md);
@@ -247,9 +247,9 @@ static TIMER_FUNC(merc_contract_end){
 	map_session_data *sd;
 	s_mercenary_data *md;
 
-	if( (sd = map_id2sd(id)) == NULL )
+	if( (sd = map_id2sd(id)) == nullptr )
 		return 1;
-	if( (md = sd->md) == NULL )
+	if( (md = sd->md) == nullptr )
 		return 1;
 
 	if( md->contract_timer != tid )
@@ -327,7 +327,7 @@ bool mercenary_recv_data(s_mercenary *merc, bool flag)
 	map_session_data *sd;
 	t_tick tick = gettick();
 
-	if( (sd = map_charid2sd(merc->char_id)) == NULL )
+	if( (sd = map_charid2sd(merc->char_id)) == nullptr )
 		return false;
 
 	std::shared_ptr<s_mercenary_db> db = mercenary_db.find(merc->class_);
@@ -378,7 +378,7 @@ bool mercenary_recv_data(s_mercenary *merc, bool flag)
 		mercenary_set_calls(md, 1);
 	sd->status.mer_id = merc->mercenary_id;
 
-	if( md && md->bl.prev == NULL && sd->bl.prev != NULL ) {
+	if( md && md->bl.prev == nullptr && sd->bl.prev != nullptr ) {
 		if(map_addblock(&md->bl))
 			return false;
 		clif_spawn(&md->bl);
@@ -396,7 +396,7 @@ bool mercenary_recv_data(s_mercenary *merc, bool flag)
 * @param sp SP amount
 **/
 void mercenary_heal(s_mercenary_data *md, int hp, int sp) {
-	if (md->master == NULL)
+	if (md->master == nullptr)
 		return;
 	if( hp )
 		clif_mercenary_updatestatus(md->master, SP_HP);

+ 58 - 58
src/map/mob.cpp

@@ -203,7 +203,7 @@ void mvptomb_create(struct mob_data *md, char *killer, time_t time)
 	nd->bl.y = md->bl.y;
 	nd->bl.type = BL_NPC;
 
-	safestrncpy(nd->name, msg_txt(NULL,656), sizeof(nd->name));
+	safestrncpy(nd->name, msg_txt(nullptr,656), sizeof(nd->name));
 
 	nd->class_ = 565;
 	nd->speed = 200;
@@ -246,7 +246,7 @@ void mvptomb_destroy(struct mob_data *md) {
 		if( !(i == mapdata->npc_num) ) {
 			mapdata->npc_num--;
 			mapdata->npc[i] = mapdata->npc[mapdata->npc_num];
-			mapdata->npc[mapdata->npc_num] = NULL;
+			mapdata->npc[mapdata->npc_num] = nullptr;
 		}
 		map_deliddb(&nd->bl);
 		aFree(nd);
@@ -277,9 +277,9 @@ static bool mobdb_searchname_sub(uint16 mob_id, const char * const str, bool ful
 			return true;
 	} else {
 		// str must be in the db value
-		if( stristr(mob->name.c_str(), str) != NULL ||
-			stristr(mob->jname.c_str(), str) != NULL ||
-			stristr(mob->sprite.c_str(), str) != NULL )
+		if( stristr(mob->name.c_str(), str) != nullptr ||
+			stristr(mob->jname.c_str(), str) != nullptr ||
+			stristr(mob->sprite.c_str(), str) != nullptr )
 			return true;
 	}
 	return false;
@@ -414,7 +414,7 @@ void mob_free_dynamic_viewdata( struct mob_data* md ){
 		aFree( md->vd );
 
 		// Remove the reference
-		md->vd = NULL;
+		md->vd = nullptr;
 
 		// Unflag it as changed
 		md->vd_changed = false;
@@ -588,7 +588,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target)
 			(sce->val2 == 3 && sce->val4 && sce->val4 != t_sd->status.guild_id)) )
 			break;
 
-		if( (pl_sd = map_id2sd(sce->val1)) == NULL || pl_sd->bl.m != md->bl.m )
+		if( (pl_sd = map_id2sd(sce->val1)) == nullptr || pl_sd->bl.m != md->bl.m )
 			break;
 
 		if( !pl_sd->state.noks )
@@ -649,7 +649,7 @@ struct mob_data *mob_once_spawn_sub(struct block_list *bl, int16 m, int16 x, int
 	struct map_data *mapdata = map_getmapdata(m);
 	// if none found, pick random position on map
 	if (x <= 0 || x >= mapdata->xs || y <= 0 || y >= mapdata->ys)
-		map_search_freecell(NULL, m, &x, &y, -1, -1, 1);
+		map_search_freecell(nullptr, m, &x, &y, -1, -1, 1);
 
 	data.x = x;
 	data.y = y;
@@ -676,7 +676,7 @@ int mob_once_spawn(map_session_data* sd, int16 m, int16 x, int16 y, const char*
 	for (count = 0; count < amount; count++)
 	{
 		int c = (mob_id >= 0) ? mob_id : mob_get_random_id(-mob_id - 1, (battle_config.random_monster_checklv) ? static_cast<e_random_monster_flags>(RMF_DB_RATE|RMF_CHECK_MOB_LV) : RMF_DB_RATE, lv);
-		md = mob_once_spawn_sub((sd) ? &sd->bl : NULL, m, x, y, mobname, c, event, size, ai);
+		md = mob_once_spawn_sub((sd) ? &sd->bl : nullptr, m, x, y, mobname, c, event, size, ai);
 
 		if (!md)
 			continue;
@@ -707,7 +707,7 @@ int mob_once_spawn(map_session_data* sd, int16 m, int16 x, int16 y, const char*
 		if (mob_id < 0 && battle_config.dead_branch_active)
 			//Behold Aegis's masterful decisions yet again...
 			//"I understand the "Aggressive" part, but the "Can Move" and "Can Attack" is just stupid" - Poki#3
-			sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE|MD_CANATTACK|MD_CANMOVE|MD_ANGRY, 0, 60000);
+			sc_start4(nullptr,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE|MD_CANATTACK|MD_CANMOVE|MD_ANGRY, 0, 60000);
 	}
 
 	return (md) ? md->bl.id : 0; // id of last spawned mob
@@ -855,7 +855,7 @@ int mob_spawn_guardian(const char* mapname, int16 x, int16 y, const char* mobnam
 		return 0;
 	}
 
-	if((x<=0 || y<=0) && !map_search_freecell(NULL, m, &x, &y, -1,-1, 1))
+	if((x<=0 || y<=0) && !map_search_freecell(nullptr, m, &x, &y, -1,-1, 1))
 	{
 		ShowWarning("mob_spawn_guardian: Couldn't locate a spawn cell for guardian class %d (index %d) at castle map %s\n",mob_id, guardian, mapname);
 		return 0;
@@ -947,7 +947,7 @@ int mob_spawn_bg(const char* mapname, int16 x, int16 y, const char* mobname, int
 	}
 
 	data.id = mob_id;
-	if( (x <= 0 || y <= 0) && !map_search_freecell(NULL, m, &x, &y, -1,-1, 1) )
+	if( (x <= 0 || y <= 0) && !map_search_freecell(nullptr, m, &x, &y, -1,-1, 1) )
 	{
 		ShowWarning("mob_spawn_bg: Couldn't locate a spawn cell for guardian class %d (bg_id %d) at map %s\n",mob_id, bg_id, mapname);
 		return 0;
@@ -991,7 +991,7 @@ int mob_can_reach(struct mob_data *md,struct block_list *bl,int range)
 {
 	nullpo_ret(md);
 	nullpo_ret(bl);
-	return unit_can_reach_bl(&md->bl, bl, range, 0, NULL, NULL);
+	return unit_can_reach_bl(&md->bl, bl, range, 0, nullptr, nullptr);
 }
 
 /*==========================================
@@ -1105,7 +1105,7 @@ int mob_spawn (struct mob_data *md)
 	t_tick tick = gettick();
 
 	md->last_thinktime = tick;
-	if (md->bl.prev != NULL)
+	if (md->bl.prev != nullptr)
 		unit_remove_map(&md->bl,CLR_RESPAWN);
 	else
 	if (md->spawn && md->mob_id != md->spawn->id)
@@ -1740,7 +1740,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, t_tick tick)
 			if (tbl && md->ud.walktimer != INVALID_TIMER && (!can_move || md->ud.walkpath.path_pos <= battle_config.mob_chase_refresh))
 				return true; //Walk at least "mob_chase_refresh" cells before dropping the target unless target is non-existent
 			mob_unlocktarget(md, tick); //Unlock target
-			tbl = NULL;
+			tbl = nullptr;
 		}
 	}
 
@@ -1770,7 +1770,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, t_tick tick)
 		if( (abl = map_id2bl(md->attacked_id)) && (!tbl || mob_can_changetarget(md, abl, mode)) )
 		{
 			int dist;
-			if( md->bl.m != abl->m || abl->prev == NULL
+			if( md->bl.m != abl->m || abl->prev == nullptr
 				|| (dist = distance_bl(&md->bl, abl)) >= MAX_MINCHASE // Attacker longer than visual area
 				|| battle_check_target(&md->bl, abl, BCT_ENEMY) <= 0 // Attacker is not enemy of mob
 				|| (battle_config.mob_ai&0x2 && !status_check_skilluse(&md->bl, abl, 0, 0)) // Cannot normal attack back to Attacker
@@ -1866,7 +1866,7 @@ static bool mob_ai_sub_hard(struct mob_data *md, t_tick tick)
 		struct flooritem_data *fitem;
 		if (md->ud.target == tbl->id && md->ud.walktimer != INVALID_TIMER)
 			return true; //Already locked.
-		if (md->lootitems == NULL)
+		if (md->lootitems == nullptr)
 		{	//Can't loot...
 			mob_unlocktarget(md, tick);
 			return true;
@@ -2025,7 +2025,7 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
 {
 	nullpo_ret(md);
 
-	if(md->bl.prev == NULL)
+	if(md->bl.prev == nullptr)
 		return 0;
 
 	// Monsters force-walked by script commands should not be searching for targets.
@@ -2037,7 +2037,7 @@ static int mob_ai_sub_lazy(struct mob_data *md, va_list args)
 	if (battle_config.mob_ai&0x20 && map_getmapdata(md->bl.m)->users>0)
 		return (int)mob_ai_sub_hard(md, tick);
 
-	if (md->bl.prev==NULL || md->status.hp == 0)
+	if (md->bl.prev==nullptr || md->status.hp == 0)
 		return 1;
 
 	if(battle_config.mob_active_time &&
@@ -2154,7 +2154,7 @@ static struct item_drop* mob_setdropitem(struct s_mob_drop *mobdrop, int qty, un
 	drop->item_data.identify = itemdb_isidentified(mobdrop->nameid);
 	mob_setdropitem_option(&drop->item_data, mobdrop);
 	drop->mob_id = mob_id;
-	drop->next = NULL;
+	drop->next = nullptr;
 	return drop;
 }
 
@@ -2173,7 +2173,7 @@ static struct item_drop* mob_setlootitem(struct s_mob_lootitem *item, unsigned s
 	 **/
 	drop->mob_id = item->mob_id;
 
-	drop->next = NULL;
+	drop->next = nullptr;
 	return drop;
 }
 
@@ -2215,8 +2215,8 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str
 	log_pick_mob(md, loot?LOG_TYPE_LOOT:LOG_TYPE_PICKDROP_MONSTER, -ditem->item_data.amount, &ditem->item_data);
 
 	sd = map_charid2sd(dlist->first_charid);
-	if( sd == NULL ) sd = map_charid2sd(dlist->second_charid);
-	if( sd == NULL ) sd = map_charid2sd(dlist->third_charid);
+	if( sd == nullptr ) sd = map_charid2sd(dlist->second_charid);
+	if( sd == nullptr ) sd = map_charid2sd(dlist->third_charid);
 	test_autoloot = sd 
 		&& (drop_rate <= sd->state.autoloot || pc_isautolooting(sd, ditem->item_data.nameid))
 		&& (flag ? ((battle_config.homunculus_autoloot ? (battle_config.hom_idle_no_share == 0 || !pc_isidle_hom(sd)) : 0) || (battle_config.mercenary_autoloot ? (battle_config.mer_idle_no_share == 0 || !pc_isidle_mer(sd)) : 0)) :
@@ -2549,8 +2549,8 @@ int mob_getdroprate(struct block_list *src, std::shared_ptr<s_mob_db> mob, int b
 int mob_dead(struct mob_data *md, struct block_list *src, int type)
 {
 	struct status_data *status;
-	map_session_data *sd = NULL, *tmpsd[DAMAGELOG_SIZE];
-	map_session_data *mvp_sd = NULL, *second_sd = NULL, *third_sd = NULL;
+	map_session_data *sd = nullptr, *tmpsd[DAMAGELOG_SIZE];
+	map_session_data *mvp_sd = nullptr, *second_sd = nullptr, *third_sd = nullptr;
 
 	struct {
 		struct party_data *p;
@@ -2591,14 +2591,14 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 	// filter out entries not eligible for exp distribution
 	memset(tmpsd,0,sizeof(tmpsd));
 	for(i = 0, count = 0, mvp_damage = 0; i < DAMAGELOG_SIZE && md->dmglog[i].id; i++) {
-		map_session_data* tsd = NULL;
+		map_session_data* tsd = nullptr;
 		if (md->dmglog[i].flag == MDLF_SELF) {
 			//Self damage counts as exp tap
 			count++;
 			continue;
 		}
 		tsd = map_charid2sd(md->dmglog[i].id);
-		if (tsd == NULL)
+		if (tsd == nullptr)
 			continue; // skip empty entries
 		if (tsd->bl.m != m)
 			continue; // skip players not on this map
@@ -2816,7 +2816,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 		dlist->first_charid = (mvp_sd ? mvp_sd->status.char_id : 0);
 		dlist->second_charid = (second_sd ? second_sd->status.char_id : 0);
 		dlist->third_charid = (third_sd ? third_sd->status.char_id : 0);
-		dlist->item = NULL;
+		dlist->item = nullptr;
 
 		for (i = 0; i < MAX_MOB_DROP_TOTAL; i++) {
 			if (md->db->dropitem[i].nameid == 0)
@@ -2843,7 +2843,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 			//A Rare Drop Global Announce by Lupus
 			if( mvp_sd && md->db->dropitem[i].rate <= battle_config.rare_drop_announce ) {
 				char message[128];
-				sprintf (message, msg_txt(NULL,541), mvp_sd->status.name, md->name, it->ename.c_str(), (float)drop_rate/100);
+				sprintf (message, msg_txt(nullptr,541), mvp_sd->status.name, md->name, it->ename.c_str(), (float)drop_rate/100);
 				//MSG: "'%s' won %s's %s (chance: %0.02f%%)"
 				intif_broadcast(message,strlen(message)+1,BC_DEFAULT);
 			}
@@ -2952,7 +2952,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 		dlist->first_charid = (mvp_sd ? mvp_sd->status.char_id : 0);
 		dlist->second_charid = (second_sd ? second_sd->status.char_id : 0);
 		dlist->third_charid = (third_sd ? third_sd->status.char_id : 0);
-		dlist->item = NULL;
+		dlist->item = nullptr;
 		for (i = 0; i < md->lootitem_count; i++)
 			mob_item_drop(md, dlist, mob_setlootitem(&md->lootitems[i], md->mob_id), 1, 10000, homkillonly || merckillonly);
 		add_timer(tick + (!battle_config.delay_battle_damage?500:0), mob_delay_item_drop, 0, (intptr_t)dlist);
@@ -3049,7 +3049,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 				//A Rare MVP Drop Global Announce by Lupus
 				if(temp<=battle_config.rare_drop_announce) {
 					char message[128];
-					sprintf (message, msg_txt(NULL,541), mvp_sd->status.name, md->name, i_data->ename.c_str(), temp/100.);
+					sprintf (message, msg_txt(nullptr,541), mvp_sd->status.name, md->name, i_data->ename.c_str(), temp/100.);
 					//MSG: "'%s' won %s's %s (chance: %0.02f%%)"
 					intif_broadcast(message,strlen(message)+1,BC_DEFAULT);
 				}
@@ -3078,7 +3078,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 
 	if (type&2 && !sd && md->mob_id == MOBID_EMPERIUM)
 		//Emperium destroyed by script. Discard mvp character. [Skotlex]
-		mvp_sd = NULL;
+		mvp_sd = nullptr;
 
 	rebirth =  ( md->sc.getSCE(SC_KAIZEL) || md->sc.getSCE(SC_ULTIMATE_S) || (md->sc.getSCE(SC_REBIRTH) && !md->state.rebirth) );
 	if( !rebirth ) { // Only trigger event on final kill
@@ -3184,7 +3184,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 
 	// MvP tomb [GreenBox]
 	if (battle_config.mvp_tomb_enabled && md->spawn->state.boss && map_getmapflag(md->bl.m, MF_NOTOMB) != 1)
-		mvptomb_create(md, mvp_sd ? mvp_sd->status.name : NULL, time(NULL));
+		mvptomb_create(md, mvp_sd ? mvp_sd->status.name : nullptr, time(nullptr));
 
 	if( !rebirth )
 		mob_setdelayspawn(md); //Set respawning.
@@ -3242,7 +3242,7 @@ int mob_guardian_guildchange(struct mob_data *md)
 	}
 
 	auto g = guild_search(md->guardian_data->castle->guild_id);
-	if (g == NULL)
+	if (g == nullptr)
 	{	//Properly remove guardian info from Castle data.
 		ShowError("mob_guardian_guildchange: New Guild (id %d) does not exists!\n", md->guardian_data->guild_id);
 		if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS)
@@ -3347,7 +3347,7 @@ int mob_class_change (struct mob_data *md, int mob_id)
 
 	nullpo_ret(md);
 
-	if( md->bl.prev == NULL )
+	if( md->bl.prev == nullptr )
 		return 0;
 
 	if (!mob_id || !mobdb_checkid(mob_id))
@@ -3400,7 +3400,7 @@ int mob_class_change (struct mob_data *md, int mob_id)
 	for(i=0;i<MAX_MOBSKILL;i++)
 		md->skilldelay[i] = c;
 
-	if (md->lootitems == NULL && status_has_mode(&md->db->status,MD_LOOTER))
+	if (md->lootitems == nullptr && status_has_mode(&md->db->status,MD_LOOTER))
 		md->lootitems = (struct s_mob_lootitem *)aCalloc(LOOTITEM_SIZE,sizeof(struct s_mob_lootitem));
 
 	//Targets should be cleared no morph
@@ -3613,7 +3613,7 @@ int mob_getfriendhprate_sub(struct block_list *bl,va_list ap)
 	if( md->bl.id == bl->id && !(battle_config.mob_ai&0x10))
 		return 0;
 
-	if ((*fr) != NULL) //A friend was already found.
+	if ((*fr) != nullptr) //A friend was already found.
 		return 0;
 
 	if (battle_check_target(&md->bl,bl,BCT_ENEMY)>0)
@@ -3627,10 +3627,10 @@ int mob_getfriendhprate_sub(struct block_list *bl,va_list ap)
 }
 static struct block_list *mob_getfriendhprate(struct mob_data *md,int64 min_rate,int64 max_rate)
 {
-	struct block_list *fr=NULL;
+	struct block_list *fr=nullptr;
 	int type = BL_MOB;
 
-	nullpo_retr(NULL, md);
+	nullpo_retr(nullptr, md);
 
 	if (md->special_state.ai) //Summoned creatures. [Skotlex]
 		type = BL_PC;
@@ -3650,7 +3650,7 @@ struct block_list *mob_getmasterhpltmaxrate(struct mob_data *md,int64 rate)
 			return bl;
 	}
 
-	return NULL;
+	return nullptr;
 }
 
 bool mob_getstatus_sub( struct mob_data& md, e_mob_skill_condition condition, sc_type type ){
@@ -3709,7 +3709,7 @@ int mob_getfriendstatus_sub( struct block_list *bl, va_list ap ){
 
 struct mob_data *mob_getfriendstatus(struct mob_data *md,int64 cond1,int64 cond2)
 {
-	struct mob_data* fr = NULL;
+	struct mob_data* fr = nullptr;
 	nullpo_ret(md);
 
 	map_foreachinallrange(mob_getfriendstatus_sub, &md->bl, 8,BL_MOB, md,cond1,cond2,&fr);
@@ -3739,9 +3739,9 @@ bool mob_chat_display_message(mob_data &md, uint16 msg_id) {
  *------------------------------------------*/
 int mobskill_use(struct mob_data *md, t_tick tick, int event, int64 damage)
 {
-	struct block_list *fbl = NULL; //Friend bl, which can either be a BL_PC or BL_MOB depending on the situation. [Skotlex]
+	struct block_list *fbl = nullptr; //Friend bl, which can either be a BL_PC or BL_MOB depending on the situation. [Skotlex]
 	struct block_list *bl;
-	struct mob_data *fmd = NULL;
+	struct mob_data *fmd = nullptr;
 	int i,j,n;
 	short skill_target;
 
@@ -3813,12 +3813,12 @@ int mobskill_use(struct mob_data *md, t_tick tick, int event, int64 damage)
 					}
 					break;
 				case MSC_FRIENDHPLTMAXRATE:	// friend HP < maxhp%
-					flag = ((fbl = mob_getfriendhprate(md, 0, ms[i]->cond2)) != NULL); break;
+					flag = ((fbl = mob_getfriendhprate(md, 0, ms[i]->cond2)) != nullptr); break;
 				case MSC_FRIENDHPINRATE	:
-					flag = ((fbl = mob_getfriendhprate(md, ms[i]->cond2, ms[i]->val[0])) != NULL); break;
+					flag = ((fbl = mob_getfriendhprate(md, ms[i]->cond2, ms[i]->val[0])) != nullptr); break;
 				case MSC_FRIENDSTATUSON:	// friend status[num] on
 				case MSC_FRIENDSTATUSOFF:	// friend status[num] off
-					flag = ((fmd = mob_getfriendstatus(md, ms[i]->cond1, ms[i]->cond2)) != NULL); break;
+					flag = ((fmd = mob_getfriendstatus(md, ms[i]->cond1, ms[i]->cond2)) != nullptr); break;
 				case MSC_SLAVELT:		// slave < num
 					flag = (mob_countslave(&md->bl) < c2 ); break;
 				case MSC_ATTACKPCGT:	// attack pc > num
@@ -3834,7 +3834,7 @@ int mobskill_use(struct mob_data *md, t_tick tick, int event, int64 damage)
 					if (flag) md->state.attacked_count = 0;	//Rude attacked count should be reset after the skill condition is met. Thanks to Komurka [Skotlex]
 					break;
 				case MSC_MASTERHPLTMAXRATE:
-					flag = ((fbl = mob_getmasterhpltmaxrate(md, ms[i]->cond2)) != NULL); break;
+					flag = ((fbl = mob_getmasterhpltmaxrate(md, ms[i]->cond2)) != nullptr); break;
 				case MSC_MASTERATTACKED:
 					flag = (md->master_id > 0 && (fbl=map_id2bl(md->master_id)) && unit_counttargeted(fbl) > 0); break;
 				case MSC_ALCHEMIST:
@@ -3978,7 +3978,7 @@ int mobskill_event(struct mob_data *md, struct block_list *src, t_tick tick, int
 {
 	int target_id, res = 0;
 
-	if(md->bl.prev == NULL || md->status.hp == 0)
+	if(md->bl.prev == nullptr || md->status.hp == 0)
 		return 0;
 
 	target_id = md->target_id;
@@ -4251,8 +4251,8 @@ int mob_clone_delete(struct mob_data *md){
 	if (mob_is_clone(mob_id)) {
 		mob_db.erase(mob_id);
 		//Clear references to the db
-		md->db = NULL;
-		md->vd = NULL;
+		md->db = nullptr;
+		md->vd = nullptr;
 		return 1;
 	}
 	return 0;
@@ -5956,11 +5956,11 @@ static bool mob_parse_row_mobskilldb( char** str, size_t columns, size_t current
 	if( j < ARRAYLENGTH(cond2) )
 		ms->cond2 = cond2[j].id;
 
-	ms->val[0] = (int)strtol(str[12],NULL,0);
-	ms->val[1] = (int)strtol(str[13],NULL,0);
-	ms->val[2] = (int)strtol(str[14],NULL,0);
-	ms->val[3] = (int)strtol(str[15],NULL,0);
-	ms->val[4] = (int)strtol(str[16],NULL,0);
+	ms->val[0] = (int)strtol(str[12],nullptr,0);
+	ms->val[1] = (int)strtol(str[13],nullptr,0);
+	ms->val[2] = (int)strtol(str[14],nullptr,0);
+	ms->val[3] = (int)strtol(str[15],nullptr,0);
+	ms->val[4] = (int)strtol(str[16],nullptr,0);
 
 	if(ms->skill_id == NPC_EMOTION && mob_id > 0 &&
 		ms->val[1] == mob->status.mode)
@@ -6049,9 +6049,9 @@ static int mob_read_sqlskilldb(void)
 			++lines;
 			for( i = 0; i < 19; ++i )
 			{
-				Sql_GetData(mmysql_handle, i, &str[i], NULL);
-				if( str[i] == NULL ) 
-					str[i] = dummy; // get rid of NULL columns
+				Sql_GetData(mmysql_handle, i, &str[i], nullptr);
+				if( str[i] == nullptr ) 
+					str[i] = dummy; // get rid of nullptr columns
 			}
 
 			if (!mob_parse_row_mobskilldb(str, 19, count))

+ 3 - 3
src/map/navi.cpp

@@ -156,7 +156,7 @@ bool navi_path_search(struct navi_walkpath_data *wpd, const struct navi_pos *fro
 	struct map_data *mapdata = map_getmapdata(from->m);
 	struct navi_walkpath_data s_wpd;
 
-	if (wpd == NULL)
+	if (wpd == nullptr)
 		wpd = &s_wpd; // use dummy output variable
 
 	if (from->m != dest->m)
@@ -195,7 +195,7 @@ bool navi_path_search(struct navi_walkpath_data *wpd, const struct navi_pos *fro
 
 	// Start node
 	i = calc_index(from->x, from->y);
-	tp[i].parent = NULL;
+	tp[i].parent = nullptr;
 	tp[i].x = from->x;
 	tp[i].y = from->y;
 	tp[i].g_cost = 0;
@@ -264,7 +264,7 @@ bool navi_path_search(struct navi_walkpath_data *wpd, const struct navi_pos *fro
 		}
 	}
 
-	for (it = current; it->parent != NULL; it = it->parent, len++);
+	for (it = current; it->parent != nullptr; it = it->parent, len++);
 	if (len > sizeof(wpd->path)) {
 		return false;
 	}

+ 93 - 93
src/map/npc.cpp

@@ -1099,11 +1099,11 @@ struct npc_data* npc_name2id(const char* name)
  * Timer to check for idle time and timeout the dialog if necessary
  **/
 TIMER_FUNC(npc_secure_timeout_timer){
-	map_session_data* sd = NULL;
+	map_session_data* sd = nullptr;
 	unsigned int timeout = NPC_SECURE_TIMEOUT_NEXT;
 	t_tick cur_tick = gettick(); //ensure we are on last tick
 
-	if ((sd = map_id2sd(id)) == NULL || !sd->npc_id || sd->state.ignoretimeout) {
+	if ((sd = map_id2sd(id)) == nullptr || !sd->npc_id || sd->state.ignoretimeout) {
 		if( sd && sd->npc_idle_timer != INVALID_TIMER ){
 			delete_timer( sd->npc_idle_timer, npc_secure_timeout_timer );
 			sd->npc_idle_timer = INVALID_TIMER;
@@ -1151,7 +1151,7 @@ int npc_event_dequeue(map_session_data* sd,bool free_script_stack)
 		}
 		if (free_script_stack&&sd->st) {
 			script_free_state(sd->st);
-			sd->st = NULL;
+			sd->st = nullptr;
 		}
 		sd->npc_id = 0;
 	}
@@ -1338,11 +1338,11 @@ TIMER_FUNC(npc_event_do_clock){
 	char buf[EVENT_NAME_LENGTH];
 	int c = 0;
 
-	timer = time(NULL);
+	timer = time(nullptr);
 	t = localtime(&timer);
 
 	if (t->tm_min != ev_tm_b.tm_min ) {
-		const char* day = NULL;
+		const char* day = nullptr;
 
 		safesnprintf(buf,EVENT_NAME_LENGTH,"%s%02d",script_config.timer_minute_event_name,t->tm_min);
 		c += npc_event_doall(buf);
@@ -1360,7 +1360,7 @@ TIMER_FUNC(npc_event_do_clock){
 			case SATURDAY:	day = script_config.timer_saturday_event_name; break;
 		}
 
-		if( day != NULL ){
+		if( day != nullptr ){
 			safesnprintf(buf,EVENT_NAME_LENGTH,"%s%02d%02d",day,t->tm_hour,t->tm_min);
 			c += npc_event_doall(buf);
 		}
@@ -1406,7 +1406,7 @@ int npc_timerevent_export(struct npc_data *nd, int i)
 		// Timer event
 		struct npc_timerevent_list *te = nd->u.scr.timer_event;
 		int j, k2 = nd->u.scr.timeramount;
-		if (te == NULL)
+		if (te == nullptr)
 			te = (struct npc_timerevent_list *)aMalloc(sizeof(struct npc_timerevent_list));
 		else
 			te = (struct npc_timerevent_list *)aRealloc( te, sizeof(struct npc_timerevent_list) * (k2+1) );
@@ -1440,9 +1440,9 @@ TIMER_FUNC(npc_timerevent){
 	struct npc_data* nd=(struct npc_data *)map_id2bl(id);
 	struct npc_timerevent_list *te;
 	struct timer_event_data *ted = (struct timer_event_data*)data;
-	map_session_data *sd=NULL;
+	map_session_data *sd=nullptr;
 
-	if( nd == NULL )
+	if( nd == nullptr )
 	{
 		ShowError("npc_timerevent: NPC not found??\n");
 		return 0;
@@ -1509,7 +1509,7 @@ int npc_timerevent_start(struct npc_data* nd, int rid)
 {
 	int j;
 	t_tick tick = gettick();
-	map_session_data *sd = NULL; //Player to whom script is attached.
+	map_session_data *sd = nullptr; //Player to whom script is attached.
 
 	nullpo_ret(nd);
 
@@ -1564,7 +1564,7 @@ int npc_timerevent_start(struct npc_data* nd, int rid)
  *------------------------------------------*/
 int npc_timerevent_stop(struct npc_data* nd)
 {
-	map_session_data *sd = NULL;
+	map_session_data *sd = nullptr;
 	int *tid;
 
 	nullpo_ret(nd);
@@ -1582,7 +1582,7 @@ int npc_timerevent_stop(struct npc_data* nd)
 	// Delete timer
 	if ( *tid != INVALID_TIMER )
 	{
-		const struct TimerData *td = NULL;
+		const struct TimerData *td = nullptr;
 
 		td = get_timer(*tid);
 		if( td && td->data )
@@ -1634,7 +1634,7 @@ void npc_timerevent_quit(map_session_data* sd)
 		if( ev && ev->nd != nd )
 		{
 			ShowWarning("npc_timerevent_quit: Unable to execute \"%s\", two NPCs have the same event name [%s]!\n",script_config.timer_quit_event_name,buf);
-			ev = NULL;
+			ev = nullptr;
 		}
 		if( ev )
 		{
@@ -1688,7 +1688,7 @@ int npc_settimerevent_tick(struct npc_data* nd, int newtimer)
 {
 	bool flag;
 	int old_rid;
-	//map_session_data *sd = NULL;
+	//map_session_data *sd = nullptr;
 
 	nullpo_ret(nd);
 
@@ -1764,7 +1764,7 @@ int npc_event(map_session_data* sd, const char* eventname, int ontouch)
 
 	nullpo_ret(sd);
 
-	if( ev == NULL || (nd = ev->nd) == NULL )
+	if( ev == nullptr || (nd = ev->nd) == nullptr )
 	{
 		if( !ontouch )
 			ShowError("npc_event: event not found [%s]\n", eventname);
@@ -2012,12 +2012,12 @@ int npc_touch_areanpc2(struct mob_data *md)
 					if( mapdata->npc[i]->bl.id == md->areanpc_id )
 						break; // Already touch this NPC
 					safesnprintf(eventname, ARRAYLENGTH(eventname), "%s::%s", mapdata->npc[i]->exname, script_config.ontouchnpc_event_name);
-					if( (ev = (struct event_data*)strdb_get(ev_db, eventname)) == NULL || ev->nd == NULL )
+					if( (ev = (struct event_data*)strdb_get(ev_db, eventname)) == nullptr || ev->nd == nullptr )
 						break; // No OnTouchNPC Event
 					md->areanpc_id = mapdata->npc[i]->bl.id;
 					id = md->bl.id; // Stores Unique ID
 					run_script(ev->nd->u.scr.script, ev->pos, md->bl.id, ev->nd->bl.id);
-					if( map_id2md(id) == NULL ) return 1; // Not Warped, but killed
+					if( map_id2md(id) == nullptr ) return 1; // Not Warped, but killed
 					break;
 			}
 
@@ -2104,15 +2104,15 @@ int npc_check_areanpc(int flag, int16 m, int16 x, int16 y, int16 range)
 
 /*==========================================
  * Chk if player not too far to access the npc.
- * Returns npc_data (success) or NULL (fail).
+ * Returns npc_data (success) or nullptr (fail).
  *------------------------------------------*/
 struct npc_data* npc_checknear(map_session_data* sd, struct block_list* bl)
 {
 	struct npc_data *nd;
 
-	nullpo_retr(NULL, sd);
-	if(bl == NULL) return NULL;
-	if(bl->type != BL_NPC) return NULL;
+	nullpo_retr(nullptr, sd);
+	if(bl == nullptr) return nullptr;
+	if(bl->type != BL_NPC) return nullptr;
 	nd = (TBL_NPC*)bl;
 
 	if(sd->state.using_fake_npc && sd->npc_id == bl->id)
@@ -2124,7 +2124,7 @@ struct npc_data* npc_checknear(map_session_data* sd, struct block_list* bl)
 	if (bl->m!=sd->bl.m ||
 	   bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 ||
 	   bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)
-		return NULL;
+		return nullptr;
 
 	return nd;
 }
@@ -2185,7 +2185,7 @@ int npc_click(map_session_data* sd, struct npc_data* nd)
 	}
 
 	if(!nd) return 1;
-	if ((nd = npc_checknear(sd,&nd->bl)) == NULL)
+	if ((nd = npc_checknear(sd,&nd->bl)) == nullptr)
 		return 1;
 	//Hidden/Disabled npc.
 	if (nd->class_ < 0 || nd->sc.option&OPTION_HIDE)
@@ -2276,7 +2276,7 @@ bool npc_scriptcont(map_session_data* sd, int id, bool closing){
 	}
 
 	if(id != fake_nd->bl.id) { // Not item script
-		if ((npc_checknear(sd, target)) == NULL) {
+		if ((npc_checknear(sd, target)) == nullptr) {
 			ShowWarning("npc_scriptcont: failed npc_checknear test.\n");
 			return true;
 		}
@@ -2356,7 +2356,7 @@ int npc_buysellsel(map_session_data* sd, int id, int type)
 
 	nullpo_retr(1, sd);
 
-	if ((nd = npc_checknear(sd,map_id2bl(id))) == NULL)
+	if ((nd = npc_checknear(sd,map_id2bl(id))) == nullptr)
 		return 1;
 
 	if (nd->subtype != NPCTYPE_SHOP) {
@@ -2425,7 +2425,7 @@ static enum e_CASHSHOP_ACK npc_cashshop_process_payment(struct npc_data *nd, int
 					struct item *it;
 					int amount = 0;
 
-					if (sd->inventory.u.items_inventory[i].nameid == 0 || sd->inventory_data[i] == NULL || !(it = &sd->inventory.u.items_inventory[i]) || it->nameid != nd->u.shop.itemshop_nameid)
+					if (sd->inventory.u.items_inventory[i].nameid == 0 || sd->inventory_data[i] == nullptr || !(it = &sd->inventory.u.items_inventory[i]) || it->nameid != nd->u.shop.itemshop_nameid)
 						continue;
 					if (!pc_can_sell_item(sd, it, nd->subtype))
 						continue;
@@ -2760,7 +2760,7 @@ static int npc_buylist_sub(map_session_data* sd, std::vector<s_npc_buy_list>& it
  */
 e_purchase_result npc_buylist( map_session_data* sd, std::vector<s_npc_buy_list>& item_list ){
 	struct npc_data* nd;
-	struct npc_item_list *shop = NULL;
+	struct npc_item_list *shop = nullptr;
 	double z;
 	int j,k,w,skill,new_;
 	uint8 market_index[MAX_INVENTORY];
@@ -2768,7 +2768,7 @@ e_purchase_result npc_buylist( map_session_data* sd, std::vector<s_npc_buy_list>
 	nullpo_retr(e_purchase_result::PURCHASE_FAIL_COUNT, sd);
 
 	nd = npc_checknear(sd,map_id2bl(sd->npc_shopid));
-	if( nd == NULL )
+	if( nd == nullptr )
 		return e_purchase_result::PURCHASE_FAIL_COUNT;
 	if( nd->subtype != NPCTYPE_SHOP && nd->subtype != NPCTYPE_MARKETSHOP )
 		return e_purchase_result::PURCHASE_FAIL_COUNT;
@@ -2905,7 +2905,7 @@ e_purchase_result npc_buylist( map_session_data* sd, std::vector<s_npc_buy_list>
 			z = z * (double)skill * (double)battle_config.shop_exp/10000.;
 			if( z < 1 )
 				z = 1;
-			pc_gainexp(sd,NULL,0,(int)z, 0);
+			pc_gainexp(sd,nullptr,0,(int)z, 0);
 		}
 	}
 
@@ -3006,7 +3006,7 @@ uint8 npc_selllist(map_session_data* sd, int list_length, PACKET_CZ_PC_SELL_ITEM
 	nullpo_retr(1, sd);
 	nullpo_retr(1, item_list);
 
-	if( ( nd = npc_checknear(sd, map_id2bl(sd->npc_shopid)) ) == NULL || nd->subtype != NPCTYPE_SHOP )
+	if( ( nd = npc_checknear(sd, map_id2bl(sd->npc_shopid)) ) == nullptr || nd->subtype != NPCTYPE_SHOP )
 	{
 		return 1;
 	}
@@ -3099,7 +3099,7 @@ uint8 npc_selllist(map_session_data* sd, int list_length, PACKET_CZ_PC_SELL_ITEM
 			z = z * (double)skill * (double)battle_config.shop_exp/10000.;
 			if( z < 1 )
 				z = 1;
-			pc_gainexp(sd, NULL, 0, (int)z, 0);
+			pc_gainexp(sd, nullptr, 0, (int)z, 0);
 		}
 	}
 
@@ -3374,7 +3374,7 @@ int npc_remove_map(struct npc_data* nd)
 	int i;
 	nullpo_retr(1, nd);
 
-	if(nd->bl.prev == NULL || nd->bl.m < 0)
+	if(nd->bl.prev == nullptr || nd->bl.m < 0)
 		return 1; //Not assigned to a map.
 
 	struct map_data *mapdata = map_getmapdata(nd->bl.m);
@@ -3403,7 +3403,7 @@ int npc_remove_map(struct npc_data* nd)
 		mapdata->npc[ mapdata->npc_num_warp ] = mapdata->npc[ mapdata->npc_num_area ];
 		mapdata->npc[ mapdata->npc_num_area ] = mapdata->npc[ mapdata->npc_num ];
 	}
-	mapdata->npc[ mapdata->npc_num ] = NULL;
+	mapdata->npc[ mapdata->npc_num ] = nullptr;
 	return 0;
 }
 
@@ -3459,7 +3459,7 @@ int npc_unload(struct npc_data* nd, bool single) {
 #endif
 
 	if( single && nd->path ) {
-		struct npc_path_data* npd = NULL;
+		struct npc_path_data* npd = nullptr;
 		if( nd->path ) {
 			npd = (struct npc_path_data*)strdb_get(npc_path_db, nd->path);
 		}
@@ -3469,8 +3469,8 @@ int npc_unload(struct npc_data* nd, bool single) {
 			aFree(nd->path);/* remove now that no other instances exist */
 
 			if (npd == npc_last_npd) {
-				npc_last_npd = NULL;
-				npc_last_path = NULL;
+				npc_last_npd = nullptr;
+				npc_last_path = nullptr;
 			}
 		}
 	}
@@ -3516,11 +3516,11 @@ int npc_unload(struct npc_data* nd, bool single) {
 		if (nd->src_id == 0) {
 			if(nd->u.scr.script) {
 				script_free_code(nd->u.scr.script);
-				nd->u.scr.script = NULL;
+				nd->u.scr.script = nullptr;
 			}
 			if (nd->u.scr.label_list) {
 				aFree(nd->u.scr.label_list);
-				nd->u.scr.label_list = NULL;
+				nd->u.scr.label_list = nullptr;
 				nd->u.scr.label_list_num = 0;
 			}
 		}
@@ -3533,7 +3533,7 @@ int npc_unload(struct npc_data* nd, bool single) {
 				ers_free(npc_sc_display_ers, nd->sc_display[i]);
 			nd->sc_display_count = 0;
 			aFree(nd->sc_display);
-			nd->sc_display = NULL;
+			nd->sc_display = nullptr;
 		}
 	}
 
@@ -3662,13 +3662,13 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta
 		safestrncpy(nd->exname, name, sizeof(nd->exname));
 	}
 
-	if( *nd->exname == '\0' || strstr(nd->exname,"::") != NULL ) {// invalid
+	if( *nd->exname == '\0' || strstr(nd->exname,"::") != nullptr ) {// invalid
 		snprintf(newname, ARRAYLENGTH(newname), "0_%d_%d_%d", nd->bl.m, nd->bl.x, nd->bl.y);
 		ShowWarning("npc_parsename: Invalid unique name in file '%s', line'%d'. Renaming '%s' to '%s'.\n", filepath, strline(buffer,start-buffer), nd->exname, newname);
 		safestrncpy(nd->exname, newname, sizeof(nd->exname));
 	}
 
-	if( (dnd=npc_name2id(nd->exname)) != NULL ) {// duplicate unique name, generate new one
+	if( (dnd=npc_name2id(nd->exname)) != nullptr ) {// duplicate unique name, generate new one
 		char this_mapname[MAP_NAME_LENGTH_EXT];
 		char other_mapname[MAP_NAME_LENGTH_EXT];
 		int i = 0;
@@ -3676,7 +3676,7 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta
 		do {
 			++i;
 			snprintf(newname, ARRAYLENGTH(newname), "%d_%d_%d_%d", i, nd->bl.m, nd->bl.x, nd->bl.y);
-		} while( npc_name2id(newname) != NULL );
+		} while( npc_name2id(newname) != nullptr );
 
 		strcpy(this_mapname, (nd->bl.m==-1?"(not on a map)":mapindex_id2name(map_getmapdata(nd->bl.m)->index)));
 		strcpy(other_mapname, (dnd->bl.m==-1?"(not on a map)":mapindex_id2name(map_getmapdata(dnd->bl.m)->index)));
@@ -3688,7 +3688,7 @@ static void npc_parsename(struct npc_data* nd, const char* name, const char* sta
 	}
 
 	if( npc_last_path != filepath ) {
-		struct npc_path_data * npd = NULL;
+		struct npc_path_data * npd = nullptr;
 
 		if( !(npd = (struct npc_path_data *)strdb_get(npc_path_db,filepath) ) ) {
 			CREATE(npd, struct npc_path_data, 1);
@@ -3799,7 +3799,7 @@ struct npc_data *npc_create_npc(int16 m, int16 x, int16 y){
  * @param to_mapindex : mapid to warp to
  * @param to_x : x coordinate to warp to
  * @param to_y : y coordinate to warp to
- * @return NULL:failed creation, npc_data* new warp
+ * @return nullptr:failed creation, npc_data* new warp
  */
 struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short from_y, short xs, short ys, unsigned short to_mapindex, short to_x, short to_y)
 {
@@ -3809,13 +3809,13 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short
 	nd = npc_create_npc(from_mapid, from_x, from_y);
 
 	safestrncpy(nd->exname, name, ARRAYLENGTH(nd->exname));
-	if (npc_name2id(nd->exname) != NULL)
+	if (npc_name2id(nd->exname) != nullptr)
 		flag = 1;
 
 	if (flag == 1)
 		snprintf(nd->exname, ARRAYLENGTH(nd->exname), "warp_%d_%d_%d", from_mapid, from_x, from_y);
 
-	for( i = 0; npc_name2id(nd->exname) != NULL; ++i )
+	for( i = 0; npc_name2id(nd->exname) != nullptr; ++i )
 		snprintf(nd->exname, ARRAYLENGTH(nd->exname), "warp%d_%d_%d_%d", i, from_mapid, from_x, from_y);
 	safestrncpy(nd->name, nd->exname, ARRAYLENGTH(nd->name));
 
@@ -3836,7 +3836,7 @@ struct npc_data* npc_add_warp(char* name, short from_mapid, short from_x, short
 	map_addnpc(from_mapid, nd);
 	npc_setcells(nd);
 	if(map_addblock(&nd->bl))
-		return NULL;
+		return nullptr;
 	status_set_viewdata(&nd->bl, nd->class_);
 	status_change_init(&nd->bl);
 	unit_dataset(&nd->bl);
@@ -3988,7 +3988,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
 	{// w1=<map name>,<x>,<y>,<facing>
 		char mapname[MAP_NAME_LENGTH_EXT];
 		if( sscanf(w1, "%15[^,],%6hd,%6hd,%4hd", mapname, &x, &y, &dir) != 4
-		||	strchr(w4, ',') == NULL )
+		||	strchr(w4, ',') == nullptr )
 		{
 			ShowError("npc_parse_shop: Invalid shop definition in file '%s', line '%d'.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
 			return strchr(start,'\n');// skip and continue
@@ -4084,7 +4084,7 @@ static const char* npc_parse_shop(char* w1, char* w2, char* w3, char* w4, const
 		int value;
 		bool skip = false;
 
-		if( p == NULL )
+		if( p == nullptr )
 			break;
 		switch(type) {
 			case NPCTYPE_MARKETSHOP:
@@ -4263,7 +4263,7 @@ int npc_convertlabel_db(DBKey key, DBData *data, va_list ap)
 		return 0;
 	}
 
-	if( *label_list == NULL )
+	if( *label_list == nullptr )
 	{
 		*label_list = (struct npc_label_list *) aCalloc (1, sizeof(struct npc_label_list));
 		*label_list_num = 0;
@@ -4284,15 +4284,15 @@ static const char* npc_skip_script(const char* start, const char* buffer, const
 	const char* p;
 	int curly_count;
 
-	if( start == NULL )
-		return NULL;// nothing to skip
+	if( start == nullptr )
+		return nullptr;// nothing to skip
 
 	// initial bracket (assumes the previous part is ok)
 	p = strchr(start,'{');
-	if( p == NULL )
+	if( p == nullptr )
 	{
 		ShowError("npc_skip_script: Missing left curly in file '%s', line'%d'.", filepath, strline(buffer,start-buffer));
-		return NULL;// can't continue
+		return nullptr;// can't continue
 	}
 
 	// skip everything
@@ -4316,19 +4316,19 @@ static const char* npc_skip_script(const char* start, const char* buffer, const
 				else if( *p == '\0' )
 				{
 					script_error(buffer, filepath, 0, "Unexpected end of string.", p);
-					return NULL;// can't continue
+					return nullptr;// can't continue
 				}
 				else if( *p == '\n' )
 				{
 					script_error(buffer, filepath, 0, "Unexpected newline at string.", p);
-					return NULL;// can't continue
+					return nullptr;// can't continue
 				}
 			}
 		}
 		else if( *p == '\0' )
 		{// end of buffer
 			ShowError("Missing %d right curlys at file '%s', line '%d'.\n", curly_count, filepath, strline(buffer,p-buffer));
-			return NULL;// can't continue
+			return nullptr;// can't continue
 		}
 	}
 
@@ -4374,26 +4374,26 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
 		if( sscanf(w1, "%15[^,],%6hd,%6hd,%4hd", mapname, &x, &y, &dir) != 4 )
 		{
 			ShowError("npc_parse_script: Invalid placement format for a script in file '%s', line '%d'. Skipping the rest of file...\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
-			return NULL;// unknown format, don't continue
+			return nullptr;// unknown format, don't continue
 		}
 		m = map_mapname2mapid(mapname);
 	}
 
 	script_start = strstr(start,",{");
 	end = strchr(start,'\n');
-	if( strstr(w4,",{") == NULL || script_start == NULL || (end != NULL && script_start > end) )
+	if( strstr(w4,",{") == nullptr || script_start == nullptr || (end != nullptr && script_start > end) )
 	{
 		ShowError("npc_parse_script: Missing left curly ',{' in file '%s', line '%d'. Skipping the rest of the file.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
-		return NULL;// can't continue
+		return nullptr;// can't continue
 	}
 	++script_start;
 
 	end = npc_skip_script(script_start, buffer, filepath);
-	if( end == NULL )
-		return NULL;// (simple) parse error, don't continue
+	if( end == nullptr )
+		return nullptr;// (simple) parse error, don't continue
 
 	script = parse_script(script_start, filepath, strline(buffer,script_start-buffer), SCRIPT_USE_LABEL_DB);
-	label_list = NULL;
+	label_list = nullptr;
 	label_list_num = 0;
 	if( script )
 	{
@@ -4434,7 +4434,7 @@ static const char* npc_parse_script(char* w1, char* w2, char* w3, char* w4, cons
 		nd->ud.dir = (uint8)dir;
 		npc_setcells(nd);
 		if(map_addblock(&nd->bl))
-			return NULL;
+			return nullptr;
 		if( nd->class_ != JT_FAKENPC )
 		{
 			status_set_viewdata(&nd->bl, nd->class_);
@@ -4519,7 +4519,7 @@ const char* npc_parse_duplicate( char* w1, char* w2, char* w3, char* w4, const c
 	safestrncpy(srcname, w2+10, length-10);
 
 	dnd = npc_name2id(srcname);
-	if( dnd == NULL) {
+	if( dnd == nullptr) {
 		ShowError("npc_parse_script: original npc not found for duplicate in file '%s', line '%d' : %s\n", filepath, strline(buffer,start-buffer), srcname);
 		return end;// next line, try to continue
 	}
@@ -4658,13 +4658,13 @@ int npc_duplicate4instance(struct npc_data *snd, int16 m) {
 		return 1;
 
 	snprintf(newname, ARRAYLENGTH(newname), "dup_%d_%d", mapdata->instance_id, snd->bl.id);
-	if( npc_name2id(newname) != NULL ) { // Name already in use
+	if( npc_name2id(newname) != nullptr ) { // Name already in use
 		ShowError("npc_duplicate4instance: the npcname (%s) is already in use while trying to duplicate npc %s in instance %d.\n", newname, snd->exname, mapdata->instance_id);
 		return 1;
 	}
 
 	if( snd->subtype == NPCTYPE_WARP ) { // Adjust destination, if instanced
-		struct npc_data *wnd = NULL; // New NPC
+		struct npc_data *wnd = nullptr; // New NPC
 		std::shared_ptr<s_instance_data> idata = util::umap_find(instances, mapdata->instance_id);
 		int dm = map_mapindex2mapid(snd->u.warp.mapindex), imap = 0;
 
@@ -4800,7 +4800,7 @@ void npc_market_delfromsql_(const char *exname, t_itemid nameid, bool clear) {
  **/
 static int npc_market_checkall_sub(DBKey key, DBData *data, va_list ap) {
 	struct s_npc_market *market = (struct s_npc_market *)db_data2ptr(data);
-	struct npc_data *nd = NULL;
+	struct npc_data *nd = nullptr;
 	uint16 i;
 
 	if (!market)
@@ -4870,7 +4870,7 @@ static int npc_market_free(DBKey key, DBData *data, va_list ap) {
 		return 0;
 	if (market->list) {
 		aFree(market->list);
-		market->list = NULL;
+		market->list = nullptr;
 	}
 	aFree(market);
 	return 1;
@@ -4907,7 +4907,7 @@ static void npc_market_fromsql(void) {
 		struct s_npc_market *market;
 		struct npc_item_list list;
 
-		Sql_GetData(mmysql_handle, 0, &data, NULL);
+		Sql_GetData(mmysql_handle, 0, &data, nullptr);
 
 		if (!(market = (struct s_npc_market *)strdb_get(NPCMarketDB,data))) {
 			CREATE(market, struct s_npc_market, 1);
@@ -4916,10 +4916,10 @@ static void npc_market_fromsql(void) {
 			strdb_put(NPCMarketDB, market->exname, market);
 		}
 
-		Sql_GetData(mmysql_handle, 1, &data, NULL); list.nameid = strtoul(data, nullptr, 10);
-		Sql_GetData(mmysql_handle, 2, &data, NULL); list.value = atoi(data);
-		Sql_GetData(mmysql_handle, 3, &data, NULL); list.qty = atoi(data);
-		Sql_GetData(mmysql_handle, 4, &data, NULL); list.flag = atoi(data);
+		Sql_GetData(mmysql_handle, 1, &data, nullptr); list.nameid = strtoul(data, nullptr, 10);
+		Sql_GetData(mmysql_handle, 2, &data, nullptr); list.value = atoi(data);
+		Sql_GetData(mmysql_handle, 3, &data, nullptr); list.qty = atoi(data);
+		Sql_GetData(mmysql_handle, 4, &data, nullptr); list.flag = atoi(data);
 
 		std::shared_ptr<item_data> id = item_db.find(list.nameid);
 
@@ -5021,7 +5021,7 @@ void npc_unsetcells(struct npc_data* nd)
 
 bool npc_movenpc(struct npc_data* nd, int16 x, int16 y)
 {
-	if (nd->bl.m < 0 || nd->bl.prev == NULL) 
+	if (nd->bl.m < 0 || nd->bl.prev == nullptr) 
 		return false;	//Not on a map.
 
 	struct map_data *mapdata = map_getmapdata(nd->bl.m);
@@ -5076,7 +5076,7 @@ int npc_do_atcmd_event(map_session_data* sd, const char* command, const char* me
 
 	nullpo_ret(sd);
 
-	if( ev == NULL || (nd = ev->nd) == NULL ) {
+	if( ev == nullptr || (nd = ev->nd) == nullptr ) {
 		ShowError("npc_event: event not found [%s]\n", eventname);
 		return 0;
 	}
@@ -5099,7 +5099,7 @@ int npc_do_atcmd_event(map_session_data* sd, const char* command, const char* me
 	}
 
 	st = script_alloc_state(ev->nd->u.scr.script, ev->pos, sd->bl.id, ev->nd->bl.id);
-	setd_sub_str( st, NULL, ".@atcmd_command$", 0, command, NULL );
+	setd_sub_str( st, nullptr, ".@atcmd_command$", 0, command, nullptr );
 
 	// split atcmd parameters based on spaces
 
@@ -5113,7 +5113,7 @@ int npc_do_atcmd_event(map_session_data* sd, const char* command, const char* me
 			temp[k] = '\0';
 			k = 0;
 			if( temp[0] != '\0' ) {
-				setd_sub_str( st, NULL, ".@atcmd_parameters$", j++, temp, NULL );
+				setd_sub_str( st, nullptr, ".@atcmd_parameters$", j++, temp, nullptr );
 			}
 		} else {
 			temp[k] = message[i];
@@ -5121,7 +5121,7 @@ int npc_do_atcmd_event(map_session_data* sd, const char* command, const char* me
 		}
 	 }
 
-	setd_sub_num( st, NULL, ".@atcmd_numparameters", 0, j, NULL );
+	setd_sub_num( st, nullptr, ".@atcmd_numparameters", 0, j, nullptr );
 	aFree(temp);
 
 	run_script_main(st);
@@ -5140,18 +5140,18 @@ static const char* npc_parse_function(char* w1, char* w2, char* w3, char* w4, co
 
 	script_start = strstr(start,"\t{");
 	end = strchr(start,'\n');
-	if (*w4 != '{' || script_start == NULL || (end != NULL && script_start > end)) {
+	if (*w4 != '{' || script_start == nullptr || (end != nullptr && script_start > end)) {
 		ShowError("npc_parse_function: Missing left curly '%%TAB%%{' in file '%s', line '%d'. Skipping the rest of the file.\n * w1=%s\n * w2=%s\n * w3=%s\n * w4=%s\n", filepath, strline(buffer,start-buffer), w1, w2, w3, w4);
-		return NULL;// can't continue
+		return nullptr;// can't continue
 	}
 	++script_start;
 
 	end = npc_skip_script(script_start,buffer,filepath);
-	if( end == NULL )
-		return NULL;// (simple) parse error, don't continue
+	if( end == nullptr )
+		return nullptr;// (simple) parse error, don't continue
 
 	script = parse_script(script_start, filepath, strline(buffer,start-buffer), SCRIPT_RETURN_EMPTY_SCRIPT);
-	if( script == NULL )// parse error, continue
+	if( script == nullptr )// parse error, continue
 		return end;
 
 	func_db = script_get_userfunc_db();
@@ -5755,7 +5755,7 @@ int npc_script_event(map_session_data* sd, enum npce_event type){
 	if (type == NPCE_MAX)
 		return 0;
 	if (!sd) {
-		ShowError("npc_script_event: NULL sd. Event Type %d\n", type);
+		ShowError("npc_script_event: nullptr sd. Event Type %d\n", type);
 		return 0;
 	}
 
@@ -5929,7 +5929,7 @@ const char *npc_get_script_event_name(int npce_index)
 		return script_config.kill_mob_event_name;
 	default:
 		ShowError("npc_get_script_event_name: npce_index is outside the array limits: %d (max: %d).\n", npce_index, NPCE_MAX);
-		return NULL;
+		return nullptr;
 	}
 }
 
@@ -5974,7 +5974,7 @@ void npc_read_event_script(void)
 }
 
 void npc_clear_pathlist(void) {
-	struct npc_path_data *npd = NULL;
+	struct npc_path_data *npd = nullptr;
 	DBIterator *path_list = db_iterator(npc_path_db);
 
 	/* free all npc_path_data filepaths */
@@ -6028,9 +6028,9 @@ int npc_reload(void) {
 			for( int16 j = 0; j < MAX_MOB_LIST_PER_MAP; j++ ){
 				struct map_data *mapdata = map_getmapdata(i);
 
-				if (mapdata->moblist[j] != NULL) {
+				if (mapdata->moblist[j] != nullptr) {
 					aFree(mapdata->moblist[j]);
-					mapdata->moblist[j] = NULL;
+					mapdata->moblist[j] = nullptr;
 				}
 				if( mapdata->mob_delete_timer != INVALID_TIMER )
 				{ // Mobs were removed anyway,so delete the timer [Inkfish]
@@ -6087,7 +6087,7 @@ int npc_reload(void) {
 //Unload all npc in the given file
 bool npc_unloadfile( const char* path ) {
 	DBIterator * iter = db_iterator(npcname_db);
-	struct npc_data* nd = NULL;
+	struct npc_data* nd = nullptr;
 	bool found = false;
 
 	for( nd = (struct npc_data*)dbi_first(iter); dbi_exists(iter); nd = (struct npc_data*)dbi_next(iter) ) {
@@ -6119,9 +6119,9 @@ void do_clear_npc(void) {
 void do_final_npc(void) {
 	npc_clear_pathlist();
 	script_event.clear();
-	ev_db->destroy(ev_db, NULL);
-	npcname_db->destroy(npcname_db, NULL);
-	npc_path_db->destroy(npc_path_db, NULL);
+	ev_db->destroy(ev_db, nullptr);
+	npcname_db->destroy(npcname_db, nullptr);
+	npc_path_db->destroy(npc_path_db, nullptr);
 #if PACKETVER >= 20131223
 	NPCMarketDB->destroy(NPCMarketDB, npc_market_free);
 #endif

+ 38 - 38
src/map/npc_chat.cpp

@@ -114,29 +114,29 @@ static struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int64 setid)
 {
 	struct pcrematch_set *pcreset;
 	struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
-	if (npcParse == NULL) 
+	if (npcParse == nullptr) 
 		nd->chatdb = npcParse = (struct npc_parse *) aCalloc(sizeof(struct npc_parse), 1);
 	
 	pcreset = npcParse->active;
 	
-	while (pcreset != NULL) {
+	while (pcreset != nullptr) {
 		if (pcreset->setid == setid)
 		break;
 		pcreset = pcreset->next;
 	}
-	if (pcreset == NULL) 
+	if (pcreset == nullptr) 
 		pcreset = npcParse->inactive;
 	
-	while (pcreset != NULL) {
+	while (pcreset != nullptr) {
 		if (pcreset->setid == setid)
 		break;
 		pcreset = pcreset->next;
 	}
 	
-	if (pcreset == NULL) {
+	if (pcreset == nullptr) {
 		pcreset = (struct pcrematch_set *) aCalloc(sizeof(struct pcrematch_set), 1);
 		pcreset->next = npcParse->inactive;
-		if (pcreset->next != NULL)
+		if (pcreset->next != nullptr)
 			pcreset->next->prev = pcreset;
 		pcreset->prev = 0;
 		npcParse->inactive = pcreset;
@@ -155,26 +155,26 @@ static void activate_pcreset(struct npc_data* nd, int64 setid)
 {
 	struct pcrematch_set *pcreset;
 	struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
-	if (npcParse == NULL) 
+	if (npcParse == nullptr) 
 		return; // Nothing to activate...
 	pcreset = npcParse->inactive;
-	while (pcreset != NULL) {
+	while (pcreset != nullptr) {
 		if (pcreset->setid == setid)
 			break;
 		pcreset = pcreset->next;
 	}
-	if (pcreset == NULL)
+	if (pcreset == nullptr)
 		return; // not in inactive list
-	if (pcreset->next != NULL)
+	if (pcreset->next != nullptr)
 		pcreset->next->prev = pcreset->prev;
-	if (pcreset->prev != NULL)
+	if (pcreset->prev != nullptr)
 		pcreset->prev->next = pcreset->next;
 	else 
 		npcParse->inactive = pcreset->next;
 	
-	pcreset->prev = NULL;
+	pcreset->prev = nullptr;
 	pcreset->next = npcParse->active;
-	if (pcreset->next != NULL)
+	if (pcreset->next != nullptr)
 		pcreset->next->prev = pcreset;
 	npcParse->active = pcreset;
 }
@@ -188,31 +188,31 @@ static void deactivate_pcreset(struct npc_data* nd, int64 setid)
 {
 	struct pcrematch_set *pcreset;
 	struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
-	if (npcParse == NULL) 
+	if (npcParse == nullptr) 
 		return; // Nothing to deactivate...
 	if (setid == -1) {
-		while(npcParse->active != NULL)
+		while(npcParse->active != nullptr)
 			deactivate_pcreset(nd, npcParse->active->setid);
 		return;
 	}
 	pcreset = npcParse->active;
-	while (pcreset != NULL) {
+	while (pcreset != nullptr) {
 		if (pcreset->setid == setid)
 			break;
 		pcreset = pcreset->next;
 	}
-	if (pcreset == NULL)
+	if (pcreset == nullptr)
 		return; // not in active list
-	if (pcreset->next != NULL)
+	if (pcreset->next != nullptr)
 		pcreset->next->prev = pcreset->prev;
-	if (pcreset->prev != NULL)
+	if (pcreset->prev != nullptr)
 		pcreset->prev->next = pcreset->next;
 	else 
 		npcParse->active = pcreset->next;
 	
-	pcreset->prev = NULL;
+	pcreset->prev = nullptr;
 	pcreset->next = npcParse->inactive;
-	if (pcreset->next != NULL)
+	if (pcreset->next != nullptr)
 		pcreset->next->prev = pcreset;
 	npcParse->inactive = pcreset;
 }
@@ -225,29 +225,29 @@ static void delete_pcreset(struct npc_data* nd, int64 setid)
 	int active = 1;
 	struct pcrematch_set *pcreset;
 	struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
-	if (npcParse == NULL) 
+	if (npcParse == nullptr) 
 		return; // Nothing to deactivate...
 	pcreset = npcParse->active;
-	while (pcreset != NULL) {
+	while (pcreset != nullptr) {
 		if (pcreset->setid == setid)
 			break;
 		pcreset = pcreset->next;
 	}
-	if (pcreset == NULL) {
+	if (pcreset == nullptr) {
 		active = 0;
 		pcreset = npcParse->inactive;
-		while (pcreset != NULL) {
+		while (pcreset != nullptr) {
 			if (pcreset->setid == setid)
 				break;
 			pcreset = pcreset->next;
 		}
 	}
-	if (pcreset == NULL) 
+	if (pcreset == nullptr) 
 		return;
 	
-	if (pcreset->next != NULL)
+	if (pcreset->next != nullptr)
 		pcreset->next->prev = pcreset->prev;
-	if (pcreset->prev != NULL)
+	if (pcreset->prev != nullptr)
 		pcreset->prev->next = pcreset->next;
 	
 	if(active)
@@ -255,8 +255,8 @@ static void delete_pcreset(struct npc_data* nd, int64 setid)
 	else
 		npcParse->inactive = pcreset->next;
 	
-	pcreset->prev = NULL;
-	pcreset->next = NULL;
+	pcreset->prev = nullptr;
+	pcreset->next = nullptr;
 	
 	while (pcreset->head) {
 		struct pcrematch_entry* n = pcreset->head->next;
@@ -282,17 +282,17 @@ static struct pcrematch_entry* create_pcrematch_entry(struct pcrematch_set* set)
 	// items defined later. as a result, we have to do some work up front.
 	
 	/*  if we are the first pattern, stick us at the end */
-	if (last == NULL) {
+	if (last == nullptr) {
 		set->head = e;
 		return e;
 	}
 	
 	/* Look for the last entry */
-	while (last->next != NULL)
+	while (last->next != nullptr)
 		last = last->next;
 	
 	last->next = e;
-	e->next = NULL;
+	e->next = nullptr;
 	
 	return e;
 }
@@ -309,7 +309,7 @@ void npc_chat_def_pattern(struct npc_data* nd, int64 setid, const char* pattern,
 	struct pcrematch_entry *e = create_pcrematch_entry(s);
 	e->pattern = aStrdup(pattern);
 	e->label = aStrdup(label);
-	e->pcre_ = pcre_compile(pattern, PCRE_CASELESS, &err, &erroff, NULL);
+	e->pcre_ = pcre_compile(pattern, PCRE_CASELESS, &err, &erroff, nullptr);
 	e->pcre_extra_ = pcre_study(e->pcre_, 0, &err);
 }
 
@@ -322,7 +322,7 @@ void npc_chat_def_pattern(struct npc_data* nd, int64 setid, const char* pattern,
 void npc_chat_finalize(struct npc_data* nd)
 {
 	struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
-	if (npcParse == NULL)
+	if (npcParse == nullptr)
 		return;
 	
 	while(npcParse->active)
@@ -350,7 +350,7 @@ int npc_chat_sub(struct block_list* bl, va_list ap)
 	struct pcrematch_entry* e;
 	
 	// Not interested in anything you might have to say...
-	if (npcParse == NULL || npcParse->active == NULL)
+	if (npcParse == nullptr || npcParse->active == nullptr)
 		return 0;
 	
 	msg = va_arg(ap,char*);
@@ -358,10 +358,10 @@ int npc_chat_sub(struct block_list* bl, va_list ap)
 	sd = va_arg(ap,map_session_data *);
 	
 	// iterate across all active sets
-	for (pcreset = npcParse->active; pcreset != NULL; pcreset = pcreset->next)
+	for (pcreset = npcParse->active; pcreset != nullptr; pcreset = pcreset->next)
 	{
 		// interate across all patterns in that set
-		for (e = pcreset->head; e != NULL; e = e->next)
+		for (e = pcreset->head; e != nullptr; e = e->next)
 		{
 			int offsets[2*10 + 10]; // 1/3 reserved for temp space requred by pcre_exec
 			

+ 38 - 38
src/map/party.cpp

@@ -58,7 +58,7 @@ int party_getmemberid(struct party_data* p, map_session_data* sd)
 {
 	int member_id;
 	nullpo_retr(-1, p);
-	if( sd == NULL )
+	if( sd == nullptr )
 		return -1;// no player
 	ARR_FIND(0, MAX_PARTY, member_id,
 		p->party.member[member_id].account_id == sd->status.account_id &&
@@ -74,9 +74,9 @@ int party_getmemberid(struct party_data* p, map_session_data* sd)
 map_session_data* party_getavailablesd(struct party_data *p)
 {
 	int i;
-	nullpo_retr(NULL, p);
-	ARR_FIND(0, MAX_PARTY, i, p->data[i].sd != NULL);
-	return( i < MAX_PARTY ) ? p->data[i].sd : NULL;
+	nullpo_retr(nullptr, p);
+	ARR_FIND(0, MAX_PARTY, i, p->data[i].sd != nullptr);
+	return( i < MAX_PARTY ) ? p->data[i].sd : nullptr;
 }
 
 /*==========================================
@@ -88,14 +88,14 @@ static TBL_PC* party_sd_check(int party_id, uint32 account_id, uint32 char_id)
 	TBL_PC* sd = map_id2sd(account_id);
 
 	if (!(sd && sd->status.char_id == char_id))
-		return NULL;
+		return nullptr;
 
 	if( sd->status.party_id == 0 )
 		sd->status.party_id = party_id;// auto-join if not in a party
 	if (sd->status.party_id != party_id)
 	{	//If player belongs to a different party, kick him out.
 		intif_party_leave(party_id,account_id,char_id,sd->status.name,PARTY_MEMBER_WITHDRAW_LEAVE);
-		return NULL;
+		return nullptr;
 	}
 
 	return sd;
@@ -107,8 +107,8 @@ static TBL_PC* party_sd_check(int party_id, uint32 account_id, uint32 char_id)
  *------------------------------------------*/
 void do_final_party(void)
 {
-	party_db->destroy(party_db,NULL);
-	party_booking_db->destroy(party_booking_db,NULL); // Party Booking [Spiria]
+	party_db->destroy(party_db,nullptr);
+	party_booking_db->destroy(party_booking_db,nullptr); // Party Booking [Spiria]
 }
 // Constructor, init vars
 void do_init_party(void)
@@ -123,7 +123,7 @@ void do_init_party(void)
 struct party_data* party_search(int party_id)
 {
 	if(!party_id)
-		return NULL;
+		return nullptr;
 	return (struct party_data*)idb_get(party_db,party_id);
 }
 
@@ -284,7 +284,7 @@ int party_recv_info(struct party* sp, uint32 char_id)
 
 	p = (struct party_data*)idb_get(party_db, sp->party_id);
 
-	if( p != NULL ) { // diff members
+	if( p != nullptr ) { // diff members
 		int i;
 
 		for( member_id = 0; member_id < MAX_PARTY; ++member_id ) {
@@ -329,7 +329,7 @@ int party_recv_info(struct party* sp, uint32 char_id)
 		member_id = removed[--removed_count];
 		sd = p->data[member_id].sd;
 
-		if( sd == NULL )
+		if( sd == nullptr )
 			continue; // not online
 
 		party_member_withdraw(sp->party_id, sd->status.account_id, sd->status.char_id, sd->status.name, PARTY_MEMBER_WITHDRAW_LEAVE);
@@ -352,7 +352,7 @@ int party_recv_info(struct party* sp, uint32 char_id)
 		member_id = added[--added_count];
 		sd = p->data[member_id].sd;
 
-		if( sd == NULL )
+		if( sd == nullptr )
 			continue;// not online
 
 		clif_name_area(&sd->bl); //Update other people's display. [Skotlex]
@@ -390,7 +390,7 @@ int party_invite(map_session_data *sd,map_session_data *tsd)
 
 	nullpo_ret(sd);
 
-	if( ( p = party_search(sd->status.party_id) ) == NULL )
+	if( ( p = party_search(sd->status.party_id) ) == nullptr )
 		return 0;
 
 	// confirm if this player is a party leader
@@ -423,7 +423,7 @@ int party_invite(map_session_data *sd,map_session_data *tsd)
 		return 0;
 	}
 
-	if( tsd == NULL) {
+	if( tsd == nullptr) {
 		clif_party_invite_reply( *sd, "", PARTY_REPLY_OFFLINE );
 		return 0;
 	}
@@ -582,7 +582,7 @@ int party_reply_invite(map_session_data *sd,int party_id,int flag)
 		sd->party_invite = 0;
 		sd->party_invite_account = 0;
 
-		if( tsd != NULL )
+		if( tsd != nullptr )
 			clif_party_invite_reply( *tsd, sd->status.name, PARTY_REPLY_REJECTED );
 	}
 
@@ -619,7 +619,7 @@ int party_member_added(int party_id,uint32 account_id,uint32 char_id, int flag)
 	struct party_data *p = party_search(party_id);
 	int i;
 
-	if(sd == NULL || sd->status.char_id != char_id || !sd->party_joining ) {
+	if(sd == nullptr || sd->status.char_id != char_id || !sd->party_joining ) {
 		if (!flag) //Char logged off before being accepted into party.
 			intif_party_leave(party_id,account_id,char_id,"",PARTY_MEMBER_WITHDRAW_LEAVE);
 		return 0;
@@ -638,7 +638,7 @@ int party_member_added(int party_id,uint32 account_id,uint32 char_id, int flag)
 	}
 
 	if( flag ) { // failed
-		if( sd2 != NULL )
+		if( sd2 != nullptr )
 			clif_party_invite_reply( *sd2, sd->status.name, PARTY_REPLY_FULL );
 		return 0;
 	}
@@ -649,7 +649,7 @@ int party_member_added(int party_id,uint32 account_id,uint32 char_id, int flag)
 	clif_party_option(p,sd,0x100);
 	clif_party_info( *p, sd );
 
-	if( sd2 != NULL )
+	if( sd2 != nullptr )
 		clif_party_invite_reply( *sd2, sd->status.name, PARTY_REPLY_ACCEPTED );
 
 	for( i = 0; i < ARRAYLENGTH(p->data); ++i ) { // hp of the other party members
@@ -677,7 +677,7 @@ int party_removemember(map_session_data* sd, uint32 account_id, char* name)
 
 	p = party_search(sd->status.party_id);
 
-	if( p == NULL )
+	if( p == nullptr )
 		return 0;
 
 	// check the requesting char's party membership
@@ -729,7 +729,7 @@ int party_leave(map_session_data *sd)
 
 	p = party_search(sd->status.party_id);
 
-	if( p == NULL )
+	if( p == nullptr )
 		return 0;
 
 	ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == sd->status.account_id && p->party.member[i].char_id == sd->status.char_id );
@@ -801,7 +801,7 @@ int party_broken(int party_id)
 
 	p = party_search(party_id);
 
-	if( p == NULL )
+	if( p == nullptr )
 		return 0;
 
 	if( p->instance_id )
@@ -867,7 +867,7 @@ int party_optionchanged(int party_id,uint32 account_id,int exp,int item,int flag
 	struct party_data *p;
 	map_session_data *sd=map_id2sd(account_id);
 
-	if( (p = party_search(party_id)) == NULL)
+	if( (p = party_search(party_id)) == nullptr)
 		return 0;
 
 	//Flag&1: Exp change denied. Flag&2: Item change denied.
@@ -900,7 +900,7 @@ int party_changeleader(map_session_data *sd, map_session_data *tsd, struct party
 			return 0;
 		}
 
-		if ((p = party_search(sd->status.party_id)) == NULL )
+		if ((p = party_search(sd->status.party_id)) == nullptr )
 			return -1;
 
 		ARR_FIND( 0, MAX_PARTY, mi, p->data[mi].sd == sd );
@@ -958,7 +958,7 @@ int party_recv_movemap( int party_id, uint32 account_id, uint32 char_id, int onl
 
 	p = party_search(party_id);
 
-	if( p == NULL )
+	if( p == nullptr )
 		return 0;
 
 	ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id );
@@ -1047,7 +1047,7 @@ int party_send_message(map_session_data *sd,const char *mes, size_t len)
 	party_recv_message(sd->status.party_id,sd->status.account_id,mes,len);
 
 	// Chat logging type 'P' / Party Chat
-	log_chat(LOG_CHAT_PARTY, sd->status.party_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, NULL, mes);
+	log_chat(LOG_CHAT_PARTY, sd->status.party_id, sd->status.char_id, sd->status.account_id, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y, nullptr, mes);
 
 	return 0;
 }
@@ -1055,7 +1055,7 @@ int party_send_message(map_session_data *sd,const char *mes, size_t len)
 int party_recv_message(int party_id,uint32 account_id,const char *mes,int len)
 {
 	struct party_data *p;
-	if( (p=party_search(party_id))==NULL)
+	if( (p=party_search(party_id))==nullptr)
 		return 0;
 	clif_party_message( *p, account_id, mes, len );
 	return 0;
@@ -1067,7 +1067,7 @@ int party_skill_check(map_session_data *sd, int party_id, uint16 skill_id, uint1
 	map_session_data *p_sd;
 	int i;
 
-	if(!party_id || (p = party_search(party_id)) == NULL)
+	if(!party_id || (p = party_search(party_id)) == nullptr)
 		return 0;
 	party_check_state(p);
 	switch(skill_id) {
@@ -1086,7 +1086,7 @@ int party_skill_check(map_session_data *sd, int party_id, uint16 skill_id, uint1
 	}
 
 	for(i = 0; i < MAX_PARTY; i++) {
-		if ((p_sd = p->data[i].sd) == NULL)
+		if ((p_sd = p->data[i].sd) == nullptr)
 			continue;
 
 		if (sd->bl.m != p_sd->bl.m)
@@ -1192,7 +1192,7 @@ void party_exp_share(struct party_data* p, struct block_list* src, t_exp base_ex
 
 	// count the number of players eligible for exp sharing
 	for (i = c = 0; i < MAX_PARTY; i++) {
-		if( (sd[c] = p->data[i].sd) == NULL || sd[c]->bl.m != src->m || pc_isdead(sd[c]) || (battle_config.idle_no_share && pc_isidle_party(sd[c])) )
+		if( (sd[c] = p->data[i].sd) == nullptr || sd[c]->bl.m != src->m || pc_isdead(sd[c]) || (battle_config.idle_no_share && pc_isidle_party(sd[c])) )
 			continue;
 		c++;
 	}
@@ -1239,7 +1239,7 @@ void party_exp_share(struct party_data* p, struct block_list* src, t_exp base_ex
 //Does party loot. first_charid holds the charid of the player who has time priority to take the item.
 int party_share_loot(struct party_data* p, map_session_data* sd, struct item* item, int first_charid)
 {
-	TBL_PC* target = NULL;
+	TBL_PC* target = nullptr;
 	int i;
 
 	if (p && p->party.item&2 && (first_charid || !(battle_config.party_share_type&1))) {
@@ -1254,7 +1254,7 @@ int party_share_loot(struct party_data* p, map_session_data* sd, struct item* it
 				if (i >= MAX_PARTY)
 					i = 0;	// reset counter to 1st person in party so it'll stop when it reaches "itemc"
 
-				if( (psd = p->data[i].sd) == NULL || sd->bl.m != psd->bl.m || pc_isdead(psd) || (battle_config.idle_no_share && pc_isidle_party(psd)) )
+				if( (psd = p->data[i].sd) == nullptr || sd->bl.m != psd->bl.m || pc_isdead(psd) || (battle_config.idle_no_share && pc_isidle_party(psd)) )
 					continue;
 
 				if (pc_additem(psd,item,item->amount,LOG_TYPE_PICKDROP_PLAYER))
@@ -1271,7 +1271,7 @@ int party_share_loot(struct party_data* p, map_session_data* sd, struct item* it
 
 			//Collect pick candidates
 			for (i = 0; i < MAX_PARTY; i++) {
-				if( (psd[count] = p->data[i].sd) == NULL || psd[count]->bl.m != sd->bl.m || pc_isdead(psd[count]) || (battle_config.idle_no_share && pc_isidle_party(psd[count])) )
+				if( (psd[count] = p->data[i].sd) == nullptr || psd[count]->bl.m != sd->bl.m || pc_isdead(psd[count]) || (battle_config.idle_no_share && pc_isidle_party(psd[count])) )
 					continue;
 
 				count++;
@@ -1364,7 +1364,7 @@ int party_foreachsamemap(int (*func)(struct block_list*,va_list),map_session_dat
 
 	nullpo_ret(sd);
 
-	if((p = party_search(sd->status.party_id)) == NULL)
+	if((p = party_search(sd->status.party_id)) == nullptr)
 		return 0;
 
 	x0 = sd->bl.x-range;
@@ -1423,7 +1423,7 @@ void party_booking_register(map_session_data *sd, short level, short mapid, shor
 
 	pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id);
 
-	if( pb_ad == NULL ) {
+	if( pb_ad == nullptr ) {
 		pb_ad = create_party_booking_data();
 		idb_put(party_booking_db, sd->status.char_id, pb_ad);
 	} else { // already registered
@@ -1432,7 +1432,7 @@ void party_booking_register(map_session_data *sd, short level, short mapid, shor
 	}
 
 	memcpy(pb_ad->charname,sd->status.name,NAME_LENGTH);
-	pb_ad->starttime = (int)time(NULL);
+	pb_ad->starttime = (int)time(nullptr);
 	pb_ad->p_detail.level = level;
 	pb_ad->p_detail.mapid = mapid;
 
@@ -1452,10 +1452,10 @@ void party_booking_update(map_session_data *sd, short* job)
 
 	pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id);
 
-	if( pb_ad == NULL )
+	if( pb_ad == nullptr )
 		return;
 
-	pb_ad->starttime = (int)time(NULL);// Update time.
+	pb_ad->starttime = (int)time(nullptr);// Update time.
 
 	for(i = 0; i < MAX_PARTY_BOOKING_JOBS; i++)
 		if(job[i] != 0xFF)
@@ -1508,7 +1508,7 @@ bool party_booking_delete(map_session_data *sd)
 {
 	struct party_booking_ad_info* pb_ad;
 
-	if((pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id)) != NULL) {
+	if((pb_ad = (struct party_booking_ad_info*)idb_get(party_booking_db, sd->status.char_id)) != nullptr) {
 		clif_PartyBookingDeleteNotify(sd, pb_ad->index);
 		idb_remove(party_booking_db,sd->status.char_id);
 	}

+ 5 - 5
src/map/path.cpp

@@ -137,7 +137,7 @@ bool path_search_long(struct shootpath_data *spd,int16 m,int16 x0,int16 y0,int16
 	struct map_data *mapdata = map_getmapdata(m);
 	struct shootpath_data s_spd;
 
-	if( spd == NULL )
+	if( spd == nullptr )
 		spd = &s_spd; // use dummy output variable
 
 	if (!mapdata->cell)
@@ -273,9 +273,9 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x
 	struct walkpath_data s_wpd;
 
 	if (flag&2)
-		return path_search_long(NULL, m, x0, y0, x1, y1, cell);
+		return path_search_long(nullptr, m, x0, y0, x1, y1, cell);
 
-	if (wpd == NULL)
+	if (wpd == nullptr)
 		wpd = &s_wpd; // use dummy output variable
 
 	if (!mapdata->cell)
@@ -343,7 +343,7 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x
 
 		// Start node
 		i = calc_index(x0, y0);
-		tp[i].parent = NULL;
+		tp[i].parent = nullptr;
 		tp[i].x      = x0;
 		tp[i].y      = y0;
 		tp[i].g_cost = 0;
@@ -411,7 +411,7 @@ bool path_search(struct walkpath_data *wpd, int16 m, int16 x0, int16 y0, int16 x
 			}
 		}
 
-		for (it = current; it->parent != NULL; it = it->parent, len++);
+		for (it = current; it->parent != nullptr; it = it->parent, len++);
 		if (len > sizeof(wpd->path))
 			return false;
 

文件差異過大導致無法顯示
+ 135 - 135
src/map/pc.cpp


+ 1 - 1
src/map/pc.hpp

@@ -1174,7 +1174,7 @@ static bool pc_cant_act( map_session_data* sd ){
 #define pc_is90overweight(sd) ( (sd)->weight * 10 >= (sd)->max_weight * 9 )
 
 static inline bool pc_hasprogress(map_session_data *sd, enum e_wip_block progress) {
-	return sd == NULL || (sd->state.workinprogress&progress) == progress;
+	return sd == nullptr || (sd->state.workinprogress&progress) == progress;
 }
 
 uint16 pc_maxparameter(map_session_data *sd, e_params param);

+ 28 - 28
src/map/pet.cpp

@@ -489,7 +489,7 @@ void pet_clear_support_bonuses(map_session_data *sd) {
 
 	if (pd->a_skill) {
 		aFree(pd->a_skill);
-		pd->a_skill = NULL;
+		pd->a_skill = nullptr;
 	}
 
 	if (pd->s_skill) {
@@ -501,7 +501,7 @@ void pet_clear_support_bonuses(map_session_data *sd) {
 		}
 
 		aFree(pd->s_skill);
-		pd->s_skill = NULL;
+		pd->s_skill = nullptr;
 	}
 
 	if (pd->recovery) {
@@ -509,7 +509,7 @@ void pet_clear_support_bonuses(map_session_data *sd) {
 			delete_timer(pd->recovery->timer, pet_recovery_timer);
 
 		aFree(pd->recovery);
-		pd->recovery = NULL;
+		pd->recovery = nullptr;
 	}
 
 	if (pd->bonus) {
@@ -517,7 +517,7 @@ void pet_clear_support_bonuses(map_session_data *sd) {
 			delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
 
 		aFree(pd->bonus);
-		pd->bonus = NULL;
+		pd->bonus = nullptr;
 	}
 
 	if (pd->loot) {
@@ -527,7 +527,7 @@ void pet_clear_support_bonuses(map_session_data *sd) {
 			aFree(pd->loot->item);
 
 		aFree(pd->loot);
-		pd->loot = NULL;
+		pd->loot = nullptr;
 	}
 }
 
@@ -715,7 +715,7 @@ int pet_attackskill(struct pet_data *pd, int target_id)
 
 		bl = map_id2bl(target_id);
 
-		if(bl == NULL || pd->bl.m != bl->m || bl->prev == NULL || status_isdead(bl) ||
+		if(bl == nullptr || pd->bl.m != bl->m || bl->prev == nullptr || status_isdead(bl) ||
 			!check_distance_bl(&pd->bl, bl, pd->db->range3))
 			return 0;
 
@@ -746,7 +746,7 @@ int pet_target_check(struct pet_data *pd,struct block_list *bl,int type)
 	Assert((pd->master == 0) || (pd->master->pd == pd));
 
 
-	if(bl == NULL || bl->type != BL_MOB || bl->prev == NULL ||
+	if(bl == nullptr || bl->type != BL_MOB || bl->prev == nullptr ||
 		pd->pet.intimate < battle_config.pet_support_min_friendly ||
 		pd->pet.hungry <= PET_HUNGRY_NONE ||
 		pd->pet.class_ == status_get_class(bl))
@@ -803,9 +803,9 @@ int pet_sc_check(map_session_data *sd, int type)
 
 	pd = sd->pd;
 
-	if( pd == NULL
+	if( pd == nullptr
 	||  (battle_config.pet_equip_required && pd->pet.equip == 0)
-	||  pd->recovery == NULL
+	||  pd->recovery == nullptr
 	||  pd->recovery->timer != INVALID_TIMER
 	||  pd->recovery->type != type )
 		return 1;
@@ -886,7 +886,7 @@ static TIMER_FUNC(pet_hungry){
  * Search pet database for given value and type.
  * @param key : value to search for
  * @param type : pet type to search for (Catch, Egg, Equip, Food)
- * @return Pet DB pointer on success, NULL on failure
+ * @return Pet DB pointer on success, nullptr on failure
  */
 std::shared_ptr<s_pet_db> pet_db_search( int key, enum e_pet_itemtype type ){
 	for( auto &pair : pet_db ){
@@ -942,7 +942,7 @@ static int pet_performance(map_session_data *sd, struct pet_data *pd)
 
 	pet_stop_walking(pd,2000<<8);
 	clif_pet_performance(pd, rnd_value(1, val));
-	pet_lootitem_drop(pd,NULL);
+	pet_lootitem_drop(pd,nullptr);
 
 	return 1;
 }
@@ -1104,7 +1104,7 @@ int pet_birth_process(map_session_data *sd, struct s_pet *pet)
 	if (save_settings&CHARSAVE_PET)
 		chrif_save(sd, CSAVE_INVENTORY); //is it REALLY Needed to save the char for hatching a pet? [Skotlex]
 
-	if(sd->bl.prev != NULL) {
+	if(sd->bl.prev != nullptr) {
 		if(map_addblock(&sd->pd->bl))
 			return 1;
 
@@ -1137,7 +1137,7 @@ int pet_recv_petdata(uint32 account_id,struct s_pet *p,int flag)
 
 	sd = map_id2sd(account_id);
 
-	if(sd == NULL)
+	if(sd == nullptr)
 		return 1;
 
 	if(flag == 1) {
@@ -1165,7 +1165,7 @@ int pet_recv_petdata(uint32 account_id,struct s_pet *p,int flag)
 	} else {
 		pet_data_init(sd,p);
 
-		if(sd->pd && sd->bl.prev != NULL) {
+		if(sd->pd && sd->bl.prev != nullptr) {
 			if(map_addblock(&sd->pd->bl))
 				return 1;
 
@@ -1246,7 +1246,7 @@ int pet_catch_process2(map_session_data* sd, int target_id)
 
 	md = (struct mob_data*)map_id2bl(target_id);
 
-	if(!md || md->bl.type != BL_MOB || md->bl.prev == NULL) { // Invalid inputs/state, abort capture.
+	if(!md || md->bl.type != BL_MOB || md->bl.prev == nullptr) { // Invalid inputs/state, abort capture.
 		clif_pet_roulette(sd,0);
 		sd->catch_target_class = PET_CATCH_FAIL;
 		sd->itemid = 0;
@@ -1350,7 +1350,7 @@ bool pet_get_egg(uint32 account_id, short pet_class, int pet_id ) {
 
 	sd = map_id2sd(account_id);
 
-	if( sd == NULL )
+	if( sd == nullptr )
 		return false;
 
 	// i = pet_search_petDB_index(sd->catch_target_class,PET_CLASS);
@@ -1397,7 +1397,7 @@ int pet_menu(map_session_data *sd,int menunum)
 {
 	nullpo_ret(sd);
 
-	if (sd->pd == NULL)
+	if (sd->pd == nullptr)
 		return 1;
 
 	//You lost the pet already.
@@ -1440,7 +1440,7 @@ int pet_change_name(map_session_data *sd,char *name)
 
 	pd = sd->pd;
 
-	if((pd == NULL) || (pd->pet.rename_flag == 1 && !battle_config.pet_rename))
+	if((pd == nullptr) || (pd->pet.rename_flag == 1 && !battle_config.pet_rename))
 		return 1;
 
 	for(i = 0; i < NAME_LENGTH && name[i]; i++) {
@@ -1718,9 +1718,9 @@ static int pet_randomwalk(struct pet_data *pd,t_tick tick)
  */
 static int pet_ai_sub_hard(struct pet_data *pd, map_session_data *sd, t_tick tick)
 {
-	struct block_list *target = NULL;
+	struct block_list *target = nullptr;
 
-	if(pd->bl.prev == NULL || sd == NULL || sd->bl.prev == NULL)
+	if(pd->bl.prev == nullptr || sd == nullptr || sd->bl.prev == nullptr)
 		return 0;
 
 	if(DIFF_TICK(tick,pd->last_thinktime) < MIN_PETTHINKTIME)
@@ -1777,7 +1777,7 @@ static int pet_ai_sub_hard(struct pet_data *pd, map_session_data *sd, t_tick tic
 
 		if (!target || pd->bl.m != target->m || status_isdead(target) ||
 			!check_distance_bl(&pd->bl, target, pd->db->range3)) {
-			target = NULL;
+			target = nullptr;
 			pet_unlocktarget(pd);
 		}
 	}
@@ -1893,8 +1893,8 @@ static int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
 	if(sd_charid && sd_charid != pd->master->status.char_id)
 		return 0;
 
-	if(unit_can_reach_bl(&pd->bl,bl, pd->db->range2, 1, NULL, NULL) &&
-		((*target) == NULL || //New target closer than previous one.
+	if(unit_can_reach_bl(&pd->bl,bl, pd->db->range2, 1, nullptr, nullptr) &&
+		((*target) == nullptr || //New target closer than previous one.
 		!check_distance_bl(&pd->bl, *target, distance_bl(&pd->bl, bl)))) {
 		(*target) = bl;
 		pd->target_id = bl->id;
@@ -1957,7 +1957,7 @@ int pet_lootitem_drop(struct pet_data *pd,map_session_data *sd)
 	dlist->first_charid = 0;
 	dlist->second_charid = 0;
 	dlist->third_charid = 0;
-	dlist->item = NULL;
+	dlist->item = nullptr;
 
 	for(i = 0; i < pd->loot->count; i++) {
 		struct item *it;
@@ -2009,7 +2009,7 @@ TIMER_FUNC(pet_skill_bonus_timer){
 	int bonus;
 	int timer = 0;
 
-	if(sd == NULL || sd->pd==NULL || sd->pd->bonus == NULL)
+	if(sd == nullptr || sd->pd==nullptr || sd->pd->bonus == nullptr)
 		return 1;
 
 	pd = sd->pd;
@@ -2055,7 +2055,7 @@ TIMER_FUNC(pet_recovery_timer){
 	map_session_data *sd = map_id2sd(id);
 	struct pet_data *pd;
 
-	if(sd == NULL || sd->pd == NULL || sd->pd->recovery == NULL)
+	if(sd == nullptr || sd->pd == nullptr || sd->pd->recovery == nullptr)
 		return 1;
 
 	pd = sd->pd;
@@ -2089,7 +2089,7 @@ TIMER_FUNC(pet_heal_timer){
 	struct pet_data *pd;
 	unsigned int rate = 100;
 
-	if(sd == NULL || sd->pd == NULL || sd->pd->s_skill == NULL)
+	if(sd == nullptr || sd->pd == nullptr || sd->pd->s_skill == nullptr)
 		return 1;
 
 	pd = sd->pd;
@@ -2132,7 +2132,7 @@ TIMER_FUNC(pet_skill_support_timer){
 	struct status_data *status;
 	short rate = 100;
 
-	if(sd == NULL || sd->pd == NULL || sd->pd->s_skill == NULL)
+	if(sd == nullptr || sd->pd == nullptr || sd->pd->s_skill == nullptr)
 		return 1;
 
 	pd = sd->pd;

+ 1 - 1
src/map/quest.cpp

@@ -701,7 +701,7 @@ int quest_delete(map_session_data *sd, int quest_id)
 
 	if (sd->num_quests == 0) {
 		aFree(sd->quest_log);
-		sd->quest_log = NULL;
+		sd->quest_log = nullptr;
 	} else
 		RECREATE(sd->quest_log, struct quest, sd->num_quests);
 

文件差異過大導致無法顯示
+ 129 - 129
src/map/script.cpp


+ 5 - 5
src/map/script.hpp

@@ -103,7 +103,7 @@
 #define reference_getindex(data) ( (uint32)(int64)((reference_getuid(data) >> 32) & 0xffffffff) )
 /// Returns the name of the reference
 #define reference_getname(data) ( str_buf + str_data[reference_getid(data)].str )
-/// Returns the linked list of uid-value pairs of the reference (can be NULL)
+/// Returns the linked list of uid-value pairs of the reference (can be nullptr)
 #define reference_getref(data) ( (data)->ref )
 /// Returns the value of the constant
 #define reference_getconstant(data) ( str_data[reference_getid(data)].val )
@@ -116,8 +116,8 @@
 /// Checks whether two references point to the same variable (or array)
 #define is_same_reference(data1, data2) \
 	(  reference_getid(data1) == reference_getid(data2) \
-	&& ( (data1->ref == data2->ref && data1->ref == NULL) \
-	  || (data1->ref != NULL && data2->ref != NULL && data1->ref->vars == data2->ref->vars \
+	&& ( (data1->ref == data2->ref && data1->ref == nullptr) \
+	  || (data1->ref != nullptr && data2->ref != nullptr && data1->ref->vars == data2->ref->vars \
 	     ) ) )
 
 #define script_getvarid(var) ( (int32)(int64)(var & 0xFFFFFFFF) )
@@ -353,7 +353,7 @@ struct script_array {
 enum script_parse_options {
 	SCRIPT_USE_LABEL_DB = 0x1,// records labels in scriptlabel_db
 	SCRIPT_IGNORE_EXTERNAL_BRACKETS = 0x2,// ignores the check for {} brackets around the script
-	SCRIPT_RETURN_EMPTY_SCRIPT = 0x4// returns the script object instead of NULL for empty scripts
+	SCRIPT_RETURN_EMPTY_SCRIPT = 0x4// returns the script object instead of nullptr for empty scripts
 };
 
 enum monsterinfo_types {
@@ -2252,7 +2252,7 @@ const char* script_get_constant_str(const char* prefix, int64 value);
 bool script_get_parameter(const char* name, int64* value);
 bool script_get_constant(const char* name, int64* value);
 void script_set_constant_(const char* name, int64 value, const char* constant_name, bool isparameter, bool deprecated);
-#define script_set_constant(name, value, isparameter, deprecated) script_set_constant_(name, value, NULL, isparameter, deprecated)
+#define script_set_constant(name, value, isparameter, deprecated) script_set_constant_(name, value, nullptr, isparameter, deprecated)
 void script_hardcoded_constants(void);
 
 void script_cleararray_pc(map_session_data* sd, const char* varname);

+ 4 - 4
src/map/searchstore.cpp

@@ -53,7 +53,7 @@ static searchstore_search_t searchstore_getsearchfunc(unsigned char type)
 		case SEARCHTYPE_BUYING_STORE: return &buyingstore_search;
 	}
 
-	return NULL;
+	return nullptr;
 }
 
 /**
@@ -68,7 +68,7 @@ static searchstore_searchall_t searchstore_getsearchallfunc(unsigned char type)
 		case SEARCHTYPE_BUYING_STORE: return &buyingstore_searchall;
 	}
 
-	return NULL;
+	return nullptr;
 }
 
 /**
@@ -153,7 +153,7 @@ void searchstore_query(map_session_data* sd, unsigned char type, unsigned int mi
 	if( !sd->searchstore.open )
 		return;
 
-	if( ( store_searchall = searchstore_getsearchallfunc(type) ) == NULL ) {
+	if( ( store_searchall = searchstore_getsearchallfunc(type) ) == nullptr ) {
 		ShowError("searchstore_query: Unknown search type %u (account_id=%d).\n", (unsigned int)type, sd->bl.id);
 		return;
 	}
@@ -316,7 +316,7 @@ void searchstore_click(map_session_data* sd, uint32 account_id, int store_id, t_
 		return;
 	}
 
-	if( ( pl_sd = map_id2sd(account_id) ) == NULL ) { // no longer online
+	if( ( pl_sd = map_id2sd(account_id) ) == nullptr ) { // no longer online
 		clif_search_store_info_failed(sd, SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE);
 		return;
 	}

文件差異過大導致無法顯示
+ 126 - 126
src/map/skill.cpp


+ 51 - 51
src/map/status.cpp

@@ -1392,7 +1392,7 @@ int64 status_charge(struct block_list* bl, int64 hp, int64 sp)
 {
 	if(!(bl->type&BL_CONSUME))
 		return (int)hp+sp; // Assume all was charged so there are no 'not enough' fails.
-	return status_damage(NULL, bl, hp, sp, 0, 3, 0);
+	return status_damage(nullptr, bl, hp, sp, 0, 3, 0);
 }
 
 /**
@@ -1714,12 +1714,12 @@ int status_heal(struct block_list *bl,int64 hhp,int64 hsp, int64 hap, int flag)
 
 	sc = status_get_sc(bl);
 	if (sc && !sc->count)
-		sc = NULL;
+		sc = nullptr;
 
 	if (hp < 0) {
 		if (hp == INT_MIN) // -INT_MIN == INT_MIN in some architectures!
 			hp++;
-		status_damage(NULL, bl, -hp, 0, 0, 1, 0);
+		status_damage(nullptr, bl, -hp, 0, 0, 1, 0);
 		hp = 0;
 	}
 
@@ -1738,7 +1738,7 @@ int status_heal(struct block_list *bl,int64 hhp,int64 hsp, int64 hap, int flag)
 	if(sp < 0) {
 		if (sp == INT_MIN)
 			sp++;
-		status_damage(NULL, bl, 0, -sp, 0, 1, 0);
+		status_damage(nullptr, bl, 0, -sp, 0, 1, 0);
 		sp = 0;
 	}
 
@@ -1928,9 +1928,9 @@ int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per
  * Checks whether the src can use the skill on the target,
  * taking into account status/option of both source/target
  * @param src:	Object using skill on target [PC|MOB|PET|HOM|MER|ELEM]
-		src MAY be NULL to indicate we shouldn't check it, this is a ground-based skill attack
+		src MAY be nullptr to indicate we shouldn't check it, this is a ground-based skill attack
  * @param target: Object being targeted by src [PC|MOB|HOM|MER|ELEM]
-		 target MAY be NULL, which checks if src can cast skill_id on the ground
+		 target MAY be nullptr, which checks if src can cast skill_id on the ground
  * @param skill_id: Skill ID being used on target
  * @param flag:	0 - Trying to use skill on target
  *		1 - Cast bar is done
@@ -2684,7 +2684,7 @@ void status_calc_misc(struct block_list *bl, struct status_data *status, int lev
 int status_calc_mob_(struct mob_data* md, uint8 opt)
 {
 	struct status_data *status;
-	struct block_list *mbl = NULL;
+	struct block_list *mbl = nullptr;
 	int flag=0;
 
 	if (opt&SCO_FIRST) { // Set basic level on respawn.
@@ -2719,7 +2719,7 @@ int status_calc_mob_(struct mob_data* md, uint8 opt)
 	if (!flag) { // No special status required.
 		if (md->base_status) {
 			aFree(md->base_status);
-			md->base_status = NULL;
+			md->base_status = nullptr;
 		}
 		if (opt&SCO_FIRST)
 			memcpy(&md->status, &md->db->status, sizeof(struct status_data));
@@ -3535,7 +3535,7 @@ bool status_calc_weight(map_session_data *sd, enum e_status_calc_weight_opt flag
 		sd->weight = 0; // Reset current weight
 
 		for(i = 0; i < MAX_INVENTORY; i++) {
-			if (!sd->inventory.u.items_inventory[i].nameid || sd->inventory_data[i] == NULL)
+			if (!sd->inventory.u.items_inventory[i].nameid || sd->inventory_data[i] == nullptr)
 				continue;
 			sd->weight += sd->inventory_data[i]->weight * sd->inventory.u.items_inventory[i].amount;
 		}
@@ -7902,7 +7902,7 @@ static unsigned short status_calc_speed(struct block_list *bl, status_change *sc
 	TBL_PC* sd = BL_CAST(BL_PC, bl);
 	int speed_rate = 100;
 
-	if (sc == NULL || (sd && sd->state.permanent_speed))
+	if (sc == nullptr || (sd && sd->state.permanent_speed))
 		return (unsigned short)cap_value(speed, MIN_WALK_SPEED, MAX_WALK_SPEED);
 
 	if (sd && pc_ismadogear(sd)) { // Mado speed is not affected by other statuses
@@ -8833,20 +8833,20 @@ void status_calc_slave_mode(struct mob_data *md, struct mob_data *mmd)
 	switch (battle_config.slaves_inherit_mode) {
 		case 1: //Always aggressive
 			if (!status_has_mode(&md->status,MD_AGGRESSIVE))
-				sc_start4(NULL, &md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 0);
+				sc_start4(nullptr, &md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 0);
 			break;
 		case 2: //Always passive
 			if (status_has_mode(&md->status,MD_AGGRESSIVE))
-				sc_start4(NULL, &md->bl, SC_MODECHANGE, 100, 1, 0, 0, MD_AGGRESSIVE, 0);
+				sc_start4(nullptr, &md->bl, SC_MODECHANGE, 100, 1, 0, 0, MD_AGGRESSIVE, 0);
 			break;
 		case 4: // Overwrite with slave mode
-			sc_start4(NULL, &md->bl, SC_MODECHANGE, 100, 1, MD_CANMOVE|MD_NORANDOMWALK|MD_CANATTACK, 0, 0, 0);
+			sc_start4(nullptr, &md->bl, SC_MODECHANGE, 100, 1, MD_CANMOVE|MD_NORANDOMWALK|MD_CANATTACK, 0, 0, 0);
 			break;
 		default: //Copy master
 			if (status_has_mode(&mmd->status,MD_AGGRESSIVE))
-				sc_start4(NULL, &md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 0);
+				sc_start4(nullptr, &md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE, 0, 0);
 			else
-				sc_start4(NULL, &md->bl, SC_MODECHANGE, 100, 1, 0, 0, MD_AGGRESSIVE, 0);
+				sc_start4(nullptr, &md->bl, SC_MODECHANGE, 100, 1, 0, 0, MD_AGGRESSIVE, 0);
 			break;
 	}
 }
@@ -8914,18 +8914,18 @@ int status_get_lv(struct block_list *bl)
 /**
  * Gets the regeneration info of the given bl
  * @param bl: Object whose regen info to get [PC|HOM|MER|ELEM]
- * @return regen data or NULL if any other bl->type than noted above
+ * @return regen data or nullptr if any other bl->type than noted above
  */
 struct regen_data *status_get_regen_data(struct block_list *bl)
 {
-	nullpo_retr(NULL, bl);
+	nullpo_retr(nullptr, bl);
 	switch (bl->type) {
 		case BL_PC:	return &((TBL_PC*)bl)->regen;
 		case BL_HOM:	return &((TBL_HOM*)bl)->regen;
 		case BL_MER:	return &((TBL_MER*)bl)->regen;
 		case BL_ELEM:	return &((TBL_ELEM*)bl)->regen;
 		default:
-			return NULL;
+			return nullptr;
 	}
 }
 
@@ -8954,11 +8954,11 @@ struct status_data *status_get_status_data(struct block_list *bl)
 /**
  * Gets the base status data of the given bl
  * @param bl: Object whose status to get [PC|MOB|PET|HOM|MER|ELEM|NPC]
- * @return base_status or NULL if any other bl->type than noted above
+ * @return base_status or nullptr if any other bl->type than noted above
  */
 struct status_data *status_get_base_status(struct block_list *bl)
 {
-	nullpo_retr(NULL, bl);
+	nullpo_retr(nullptr, bl);
 	switch (bl->type) {
 		case BL_PC:	return &((TBL_PC*)bl)->base_status;
 		case BL_MOB:	return ((TBL_MOB*)bl)->base_status ? ((TBL_MOB*)bl)->base_status : &((TBL_MOB*)bl)->db->status;
@@ -8966,9 +8966,9 @@ struct status_data *status_get_base_status(struct block_list *bl)
 		case BL_HOM:	return &((TBL_HOM*)bl)->base_status;
 		case BL_MER:	return &((TBL_MER*)bl)->base_status;
 		case BL_ELEM:	return &((TBL_ELEM*)bl)->base_status;
-		case BL_NPC:	return ((mobdb_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : NULL);
+		case BL_NPC:	return ((mobdb_checkid(((TBL_NPC*)bl)->class_) == 0) ? &((TBL_NPC*)bl)->status : nullptr);
 		default:
-			return NULL;
+			return nullptr;
 	}
 }
 
@@ -9020,7 +9020,7 @@ int status_get_party_id(struct block_list *bl)
 				struct mob_data *md=(TBL_MOB*)bl;
 				if( md->master_id > 0 ) {
 					map_session_data *msd;
-					if (md->special_state.ai && (msd = map_id2sd(md->master_id)) != NULL)
+					if (md->special_state.ai && (msd = map_id2sd(md->master_id)) != nullptr)
 						return msd->status.party_id;
 					return -md->master_id;
 				}
@@ -9067,7 +9067,7 @@ int status_get_guild_id(struct block_list *bl)
 				struct mob_data *md = (struct mob_data *)bl;
 				if (md->guardian_data)	// Guardian's guild [Skotlex]
 					return md->guardian_data->guild_id;
-				if (md->special_state.ai && (msd = map_id2sd(md->master_id)) != NULL)
+				if (md->special_state.ai && (msd = map_id2sd(md->master_id)) != nullptr)
 					return msd->status.guild_id; // Alchemist's mobs [Skotlex]
 			}
 			break;
@@ -9116,7 +9116,7 @@ int status_get_emblem_id(struct block_list *bl)
 				struct mob_data *md = (struct mob_data *)bl;
 				if (md->guardian_data)	// Guardian's guild [Skotlex]
 					return md->guardian_data->emblem_id;
-				if (md->special_state.ai && (msd = map_id2sd(md->master_id)) != NULL)
+				if (md->special_state.ai && (msd = map_id2sd(md->master_id)) != nullptr)
 					return msd->guild_emblem_id; // Alchemist's mobs [Skotlex]
 			}
 			break;
@@ -9200,7 +9200,7 @@ int status_isimmune(struct block_list *bl)
  */
 struct view_data* status_get_viewdata(struct block_list *bl)
 {
-	nullpo_retr(NULL, bl);
+	nullpo_retr(nullptr, bl);
 	switch (bl->type) {
 		case BL_PC:  return &((TBL_PC*)bl)->vd;
 		case BL_MOB: return ((TBL_MOB*)bl)->vd;
@@ -9210,7 +9210,7 @@ struct view_data* status_get_viewdata(struct block_list *bl)
 		case BL_MER: return ((TBL_MER*)bl)->vd;
 		case BL_ELEM: return ((TBL_ELEM*)bl)->vd;
 	}
-	return NULL;
+	return nullptr;
 }
 
 /**
@@ -9235,7 +9235,7 @@ void status_set_viewdata(struct block_list *bl, int class_)
 	else if (elemental_db.exists(class_))
 		vd = elemental_get_viewdata(class_);
 	else
-		vd = NULL;
+		vd = nullptr;
 
 	switch (bl->type) {
 	case BL_PC:
@@ -9395,7 +9395,7 @@ status_change *status_get_sc(struct block_list *bl)
 		case BL_MER: return &((TBL_MER*)bl)->sc;
 		case BL_ELEM: return &((TBL_ELEM*)bl)->sc;
 	}
-	return NULL;
+	return nullptr;
 }
 
 /**
@@ -9476,7 +9476,7 @@ t_tick status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_
 	map_session_data *sd;
 
 	nullpo_ret(bl);
-	if (src == NULL)
+	if (src == nullptr)
 		return tick?tick:1; // This should not happen in current implementation, but leave it anyway
 
 	// Skills (magic type) that are blocked by Golden Thief Bug card or Wand of Hermod
@@ -9498,7 +9498,7 @@ t_tick status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_
 	status_src = status_get_status_data(src);
 	sc = status_get_sc(bl);
 	if( sc && !sc->count )
-		sc = NULL;
+		sc = nullptr;
 
 #ifdef RENEWAL
 	uint16 levelAdv = (static_cast<uint16>(pow(max(0, status_get_lv(src) - status_get_lv(bl)), 2)) / 5) * 100;
@@ -9931,11 +9931,11 @@ void status_display_remove(struct block_list *bl, enum sc_type type) {
 		int cursor;
 
 		ers_free(eri, sc_display[i]);
-		sc_display[i] = NULL;
+		sc_display[i] = nullptr;
 
 		/* The all-mighty compact-o-matic */
 		for( i = 0, cursor = 0; i < sc_display_count; i++ ) {
-			if( sc_display[i] == NULL )
+			if( sc_display[i] == nullptr )
 				continue;
 
 			if( i != cursor )
@@ -9946,7 +9946,7 @@ void status_display_remove(struct block_list *bl, enum sc_type type) {
 
 		if( !(sc_display_count = cursor) ) {
 			aFree(sc_display);
-			sc_display = NULL;
+			sc_display = nullptr;
 		}
 
 		*sc_display_ptr = sc_display;
@@ -9968,7 +9968,7 @@ void status_display_remove(struct block_list *bl, enum sc_type type) {
  * @return adjusted duration based on flag values
  */
 int status_change_start(struct block_list* src, struct block_list* bl,enum sc_type type,int rate,int val1,int val2,int val3,int val4,t_tick duration,unsigned char flag, int32 delay) {
-	map_session_data *sd = NULL;
+	map_session_data *sd = nullptr;
 	status_change* sc;
 	struct status_change_entry* sce;
 	struct status_data *status;
@@ -10098,8 +10098,8 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
 			// Avoid cloaking with no wall and low skill level. [Skotlex]
 			// Due to the cloaking card, we have to check the wall versus to known
 			// skill level rather than the used one. [Skotlex]
-			// if (sd && val1 < 3 && skill_check_cloaking(bl,NULL))
-			if( sd && pc_checkskill(sd, AS_CLOAKING) < 3 && !skill_check_cloaking(bl,NULL) )
+			// if (sd && val1 < 3 && skill_check_cloaking(bl,nullptr))
+			if( sd && pc_checkskill(sd, AS_CLOAKING) < 3 && !skill_check_cloaking(bl,nullptr) )
 				return 0;
 			break;
 		case SC_MODECHANGE: {
@@ -10262,7 +10262,7 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
 				return 0;
 			break;
 		case SC_CAMOUFLAGE:
-			if( sd && pc_checkskill(sd, RA_CAMOUFLAGE) < 3 && !skill_check_camouflage(bl,NULL) )
+			if( sd && pc_checkskill(sd, RA_CAMOUFLAGE) < 3 && !skill_check_camouflage(bl,nullptr) )
 				return 0;
 			break;
 		case SC__STRIPACCESSORY:
@@ -11162,8 +11162,8 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
 			int stat,max_stat;
 			// Fetch caster information
 			struct block_list *pbl = map_id2bl(val1);
-			status_change *psc = pbl?status_get_sc(pbl):NULL;
-			struct status_change_entry *psce = psc?psc->getSCE(SC_MARIONETTE):NULL;
+			status_change *psc = pbl?status_get_sc(pbl):nullptr;
+			struct status_change_entry *psce = psc?psc->getSCE(SC_MARIONETTE):nullptr;
 			// Fetch target's stats
 			struct status_data* status2 = status_get_status_data(bl); // Battle status
 
@@ -11249,9 +11249,9 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
 			break;
 		case SC_CLOSECONFINE2:
 		{
-			struct block_list *src2 = val2?map_id2bl(val2):NULL;
-			status_change *sc2 = src2?status_get_sc(src2):NULL;
-			struct status_change_entry *sce2 = sc2?sc2->getSCE(SC_CLOSECONFINE):NULL;
+			struct block_list *src2 = val2?map_id2bl(val2):nullptr;
+			status_change *sc2 = src2?status_get_sc(src2):nullptr;
+			struct status_change_entry *sce2 = sc2?sc2->getSCE(SC_CLOSECONFINE):nullptr;
 
 			if (src2 && sc2) {
 				if (!sce2) { // Start lock on caster.
@@ -13007,7 +13007,7 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
 				struct unit_data *ud = unit_bl2ud(bl);
 
 				if( ud )
-					ud->state.running = unit_run(bl, NULL, SC_RUN);
+					ud->state.running = unit_run(bl, nullptr, SC_RUN);
 			}
 			break;
 		case SC_BOSSMAPINFO:
@@ -13272,7 +13272,7 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid)
 				int damage = status->max_hp*sce->val3/100;
 				if(status->hp < damage) // to not kill him
 					damage = status->hp-1;
-				status_damage(NULL,bl,damage,0,0,1,0);
+				status_damage(nullptr,bl,damage,0,0,1,0);
 			}
 			break;
 		case SC_RUN:
@@ -13330,7 +13330,7 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid)
 						((TBL_PC*)d_bl)->devotion[sce->val2] = 0;
 					else if( d_bl->type == BL_MER )
 						((TBL_MER*)d_bl)->devotion_flag = 0;
-					clif_devotion(d_bl, NULL);
+					clif_devotion(d_bl, nullptr);
 				}
 			}
 			break;
@@ -13442,7 +13442,7 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid)
 			if (sce->val1) { // Check for partner and end their marionette status as well
 				enum sc_type type2 = (type == SC_MARIONETTE) ? SC_MARIONETTE2 : SC_MARIONETTE;
 				struct block_list *pbl = map_id2bl(sce->val1);
-				status_change* sc2 = pbl?status_get_sc(pbl):NULL;
+				status_change* sc2 = pbl?status_get_sc(pbl):nullptr;
 
 				if (sc2 && sc2->getSCE(type2)) {
 					sc2->getSCE(type2)->val1 = 0;
@@ -13685,7 +13685,7 @@ int status_change_end(struct block_list* bl, enum sc_type type, int tid)
 			{
 				// Drop the material from target if expired
 				struct item it;
-				map_session_data *caster = NULL;
+				map_session_data *caster = nullptr;
 
 				if (sce->val3 || status_isdead(bl) || !(caster = map_id2sd(sce->val2)))
 					break;
@@ -14981,7 +14981,7 @@ int status_change_timer_sub(struct block_list* bl, va_list ap)
 			status_check_skilluse(src, bl, WZ_SIGHTBLASTER, 2))
 		{
 			if (sce) {
-				struct skill_unit *su = NULL; 
+				struct skill_unit *su = nullptr; 
 				if(bl->type == BL_SKILL)
 					su = (struct skill_unit *)bl;
 				if (skill_attack(BF_MAGIC,src,src,bl,WZ_SIGHTBLASTER,sce->val1,tick,0x1000000)
@@ -15148,7 +15148,7 @@ static int status_natural_heal(struct block_list* bl, va_list args)
 	struct status_data *status;
 	status_change *sc;
 	struct unit_data *ud;
-	struct view_data *vd = NULL;
+	struct view_data *vd = nullptr;
 	struct regen_data_sub *sregen;
 	map_session_data *sd;
 	int rate, multi = 1, flag;
@@ -15159,7 +15159,7 @@ static int status_natural_heal(struct block_list* bl, va_list args)
 	status = status_get_status_data(bl);
 	sc = status_get_sc(bl);
 	if (sc && !sc->count)
-		sc = NULL;
+		sc = nullptr;
 	sd = BL_CAST(BL_PC,bl);
 
 	flag = regen->flag;

+ 17 - 17
src/map/storage.cpp

@@ -667,26 +667,26 @@ enum e_guild_storage_log storage_guild_log_read_sub( map_session_data* sd, std::
 	struct guild_log_entry entry;
 
 	// General data
-	SqlStmt_BindColumn(stmt, 0, SQLDT_UINT,      &entry.id,               0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 1, SQLDT_STRING,    &entry.time, sizeof(entry.time), NULL, NULL);
-	SqlStmt_BindColumn(stmt, 2, SQLDT_STRING,    &entry.name, sizeof(entry.name), NULL, NULL);
-	SqlStmt_BindColumn(stmt, 3, SQLDT_SHORT,     &entry.amount,           0, NULL, NULL);
+	SqlStmt_BindColumn(stmt, 0, SQLDT_UINT,      &entry.id,               0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 1, SQLDT_STRING,    &entry.time, sizeof(entry.time), nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 2, SQLDT_STRING,    &entry.name, sizeof(entry.name), nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 3, SQLDT_SHORT,     &entry.amount,           0, nullptr, nullptr);
 
 	// Item data
-	SqlStmt_BindColumn(stmt, 4, SQLDT_UINT,      &entry.item.nameid,      0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR,      &entry.item.identify,    0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR,      &entry.item.refine,      0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 7, SQLDT_CHAR,      &entry.item.attribute,   0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 8, SQLDT_UINT,      &entry.item.expire_time, 0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 9, SQLDT_UINT,      &entry.item.bound,       0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 10, SQLDT_UINT64,   &entry.item.unique_id,   0, NULL, NULL);
-	SqlStmt_BindColumn(stmt, 11, SQLDT_INT8,     &entry.item.enchantgrade,0, NULL, NULL);
+	SqlStmt_BindColumn(stmt, 4, SQLDT_UINT,      &entry.item.nameid,      0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 5, SQLDT_CHAR,      &entry.item.identify,    0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 6, SQLDT_CHAR,      &entry.item.refine,      0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 7, SQLDT_CHAR,      &entry.item.attribute,   0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 8, SQLDT_UINT,      &entry.item.expire_time, 0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 9, SQLDT_UINT,      &entry.item.bound,       0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 10, SQLDT_UINT64,   &entry.item.unique_id,   0, nullptr, nullptr);
+	SqlStmt_BindColumn(stmt, 11, SQLDT_INT8,     &entry.item.enchantgrade,0, nullptr, nullptr);
 	for( j = 0; j < MAX_SLOTS; ++j )
-		SqlStmt_BindColumn(stmt, 12+j, SQLDT_UINT, &entry.item.card[j], 0, NULL, NULL);
+		SqlStmt_BindColumn(stmt, 12+j, SQLDT_UINT, &entry.item.card[j], 0, nullptr, nullptr);
 	for( j = 0; j < MAX_ITEM_RDM_OPT; ++j ) {
-		SqlStmt_BindColumn(stmt, 12+MAX_SLOTS+j*3, SQLDT_SHORT, &entry.item.option[j].id, 0, NULL, NULL);
-		SqlStmt_BindColumn(stmt, 12+MAX_SLOTS+j*3+1, SQLDT_SHORT, &entry.item.option[j].value, 0, NULL, NULL);
-		SqlStmt_BindColumn(stmt, 12+MAX_SLOTS+j*3+2, SQLDT_CHAR, &entry.item.option[j].param, 0, NULL, NULL);
+		SqlStmt_BindColumn(stmt, 12+MAX_SLOTS+j*3, SQLDT_SHORT, &entry.item.option[j].id, 0, nullptr, nullptr);
+		SqlStmt_BindColumn(stmt, 12+MAX_SLOTS+j*3+1, SQLDT_SHORT, &entry.item.option[j].value, 0, nullptr, nullptr);
+		SqlStmt_BindColumn(stmt, 12+MAX_SLOTS+j*3+2, SQLDT_CHAR, &entry.item.option[j].param, 0, nullptr, nullptr);
 	}
 
 	log.reserve(max);
@@ -1044,7 +1044,7 @@ void storage_guild_storagesaved(int guild_id)
 {
 	struct s_storage *stor;
 
-	if ((stor = guild2storage2(guild_id)) != NULL) {
+	if ((stor = guild2storage2(guild_id)) != nullptr) {
 		if (stor->dirty && !stor->status) // Storage has been correctly saved.
 			stor->dirty = false;
 	}

+ 6 - 6
src/map/trade.cpp

@@ -37,7 +37,7 @@ void trade_traderequest(map_session_data *sd, map_session_data *target_sd)
 		return; //Can't trade in notrade mapflag maps.
 	}
 
-	if (target_sd == NULL || sd == target_sd) {
+	if (target_sd == nullptr || sd == target_sd) {
 		clif_tradestart(sd, 1); // character does not exist
 		return;
 	}
@@ -110,7 +110,7 @@ void trade_tradeack(map_session_data *sd, int type)
 	if (sd->state.trading || !sd->trade_partner)
 		return; // Already trading or no partner set.
 
-	if ((tsd = map_id2sd(sd->trade_partner)) == NULL) {
+	if ((tsd = map_id2sd(sd->trade_partner)) == nullptr) {
 		clif_tradestart(sd, 1); // Character does not exist
 		sd->trade_partner=0;
 		return;
@@ -356,7 +356,7 @@ void trade_tradeadditem(map_session_data *sd, short index, short amount)
 	if( !sd->state.trading || sd->state.deal_locked > 0 )
 		return; // Can't add stuff.
 
-	if( (target_sd = map_id2sd(sd->trade_partner)) == NULL ) {
+	if( (target_sd = map_id2sd(sd->trade_partner)) == nullptr ) {
 		trade_tradecancel(sd);
 		return;
 	}
@@ -453,7 +453,7 @@ void trade_tradeaddzeny(map_session_data* sd, int amount)
 	if( !sd->state.trading || sd->state.deal_locked > 0 )
 		return; //Can't add stuff.
 
-	if( (target_sd = map_id2sd(sd->trade_partner)) == NULL ) {
+	if( (target_sd = map_id2sd(sd->trade_partner)) == nullptr ) {
 		trade_tradecancel(sd);
 		return;
 	}
@@ -478,7 +478,7 @@ void trade_tradeok(map_session_data *sd)
 	if(sd->state.deal_locked || !sd->state.trading)
 		return;
 
-	if ((target_sd = map_id2sd(sd->trade_partner)) == NULL) {
+	if ((target_sd = map_id2sd(sd->trade_partner)) == nullptr) {
 		trade_tradecancel(sd);
 		return;
 	}
@@ -569,7 +569,7 @@ void trade_tradecommit(map_session_data *sd)
 	if (!sd->state.trading || !sd->state.deal_locked) //Locked should be 1 (pressed ok) before you can press trade.
 		return;
 
-	if ((tsd = map_id2sd(sd->trade_partner)) == NULL) {
+	if ((tsd = map_id2sd(sd->trade_partner)) == nullptr) {
 		trade_tradecancel(sd);
 		return;
 	}

+ 66 - 66
src/map/unit.cpp

@@ -61,11 +61,11 @@ int unit_unattackable(struct block_list *bl);
  * Get the unit_data related to the bl
  * @param bl : Object to get the unit_data from
  *	valid type are : BL_PC|BL_MOB|BL_PET|BL_NPC|BL_HOM|BL_MER|BL_ELEM
- * @return unit_data of bl or NULL
+ * @return unit_data of bl or nullptr
  */
 struct unit_data* unit_bl2ud(struct block_list *bl)
 {
-	if( bl == NULL) return NULL;
+	if( bl == nullptr) return nullptr;
 	switch(bl->type){
 	case BL_PC: return &((map_session_data*)bl)->ud;
 	case BL_MOB: return &((struct mob_data*)bl)->ud;
@@ -74,7 +74,7 @@ struct unit_data* unit_bl2ud(struct block_list *bl)
 	case BL_HOM: return &((struct homun_data*)bl)->ud;
 	case BL_MER: return &((s_mercenary_data*)bl)->ud;
 	case BL_ELEM: return &((s_elemental_data*)bl)->ud;
-	default : return NULL;
+	default : return nullptr;
 	}
 }
 
@@ -162,7 +162,7 @@ int unit_walktoxy_sub(struct block_list *bl)
 /**
  * Retrieve the direct master of a bl if one exists.
  * @param bl: char to get his master [HOM|ELEM|PET|MER]
- * @return map_session_data of master or NULL
+ * @return map_session_data of master or nullptr
  */
 TBL_PC* unit_get_master(struct block_list *bl)
 {
@@ -173,13 +173,13 @@ TBL_PC* unit_get_master(struct block_list *bl)
 			case BL_PET: return (((TBL_PET *)bl)->master);
 			case BL_MER: return (((TBL_MER *)bl)->master);
 		}
-	return NULL;
+	return nullptr;
 }
 
 /**
  * Retrieve a unit's master's teleport timer
  * @param bl: char to get his master's teleport timer [HOM|ELEM|PET|MER]
- * @return timer or NULL
+ * @return timer or nullptr
  */
 int* unit_get_masterteleport_timer(struct block_list *bl)
 {
@@ -190,7 +190,7 @@ int* unit_get_masterteleport_timer(struct block_list *bl)
 			case BL_PET: return &(((TBL_PET *)bl)->masterteleport_timer);
 			case BL_MER: return &(((TBL_MER *)bl)->masterteleport_timer);
 		}
-	return NULL;
+	return nullptr;
 }
 
 /**
@@ -206,9 +206,9 @@ TIMER_FUNC(unit_teleport_timer){
 	struct block_list *bl = map_id2bl(id);
 	int *mast_tid = unit_get_masterteleport_timer(bl);
 
-	if(tid == INVALID_TIMER || mast_tid == NULL)
+	if(tid == INVALID_TIMER || mast_tid == nullptr)
 		return 0;
-	else if(*mast_tid != tid || bl == NULL)
+	else if(*mast_tid != tid || bl == nullptr)
 		return 0;
 	else {
 		TBL_PC *msd = unit_get_master(bl);
@@ -229,7 +229,7 @@ TIMER_FUNC(unit_teleport_timer){
  */
 int unit_check_start_teleport_timer(struct block_list *sbl)
 {
-	TBL_PC *msd = NULL;
+	TBL_PC *msd = nullptr;
 	int max_dist = 0;
 
 	switch(sbl->type) {
@@ -253,7 +253,7 @@ int unit_check_start_teleport_timer(struct block_list *sbl)
 	if(msd && max_dist) {
 		int *msd_tid = unit_get_masterteleport_timer(sbl);
 
-		if(msd_tid == NULL)
+		if(msd_tid == nullptr)
 			return 0;
 		if (!check_distance_bl(&msd->bl, sbl, max_dist)) {
 			if(*msd_tid == INVALID_TIMER || *msd_tid == 0)
@@ -282,7 +282,7 @@ TIMER_FUNC(unit_step_timer){
 
 	bl = map_id2bl(id);
 
-	if (!bl || bl->prev == NULL)
+	if (!bl || bl->prev == nullptr)
 		return 0;
 
 	ud = unit_bl2ud(bl);
@@ -524,7 +524,7 @@ static TIMER_FUNC(unit_walktoxy_timer)
 				npc_touchnext_areanpc(sd,false);
 			if(map_getcell(bl->m,x,y,CELL_CHKNPC)) {
 				npc_touch_area_allnpc(sd,bl->m,x,y);
-				if (bl->prev == NULL) // Script could have warped char, abort remaining of the function.
+				if (bl->prev == nullptr) // Script could have warped char, abort remaining of the function.
 					return 0;
 			} else
 				sd->areanpc.clear();
@@ -620,7 +620,7 @@ static TIMER_FUNC(unit_walktoxy_timer)
 		if( md && DIFF_TICK(tick,md->dmgtick) < 3000 ) // Not required not damaged recently
 			clif_move(ud);
 	} else if(ud->state.running) { // Keep trying to run.
-		if (!(unit_run(bl, NULL, SC_RUN) || unit_run(bl, sd, SC_WUGDASH)) )
+		if (!(unit_run(bl, nullptr, SC_RUN) || unit_run(bl, sd, SC_WUGDASH)) )
 			ud->state.running = 0;
 	} else if (!ud->stepaction && ud->target_to) {
 		// Update target trajectory.
@@ -681,7 +681,7 @@ static TIMER_FUNC(unit_walktoxy_timer)
 TIMER_FUNC(unit_delay_walktoxy_timer){
 	struct block_list *bl = map_id2bl(id);
 
-	if (!bl || bl->prev == NULL)
+	if (!bl || bl->prev == nullptr)
 		return 0;
 
 	unit_walktoxy(bl, (short)((data>>16)&0xffff), (short)(data&0xffff), 0);
@@ -700,7 +700,7 @@ TIMER_FUNC(unit_delay_walktoxy_timer){
 TIMER_FUNC(unit_delay_walktobl_timer){
 	struct block_list *bl = map_id2bl(id), *tbl = map_id2bl(data);
 
-	if(!bl || bl->prev == NULL || tbl == NULL)
+	if(!bl || bl->prev == nullptr || tbl == nullptr)
 		return 0;
 	else {
 		struct unit_data* ud = unit_bl2ud(bl);
@@ -825,7 +825,7 @@ static inline void set_mobstate(struct block_list* bl, int flag)
  */
 static TIMER_FUNC(unit_walktobl_sub){
 	struct block_list *bl = map_id2bl(id);
-	struct unit_data *ud = bl?unit_bl2ud(bl):NULL;
+	struct unit_data *ud = bl?unit_bl2ud(bl):nullptr;
 
 	if (ud && ud->walktimer == INVALID_TIMER && ud->target && ud->target == data) {
 		if (DIFF_TICK(ud->canmove_tick, tick) > 0) // Keep waiting?
@@ -1037,21 +1037,21 @@ int unit_escape(struct block_list *bl, struct block_list *target, short dist, ui
 bool unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, bool checkpath)
 {
 	short dx,dy;
-	struct unit_data        *ud = NULL;
-	map_session_data *sd = NULL;
+	struct unit_data        *ud = nullptr;
+	map_session_data *sd = nullptr;
 
 	nullpo_retr(false,bl);
 
 	sd = BL_CAST(BL_PC, bl);
 	ud = unit_bl2ud(bl);
 
-	if(ud == NULL)
+	if(ud == nullptr)
 		return false;
 
 	unit_stop_walking(bl, 1);
 	unit_stop_attack(bl);
 
-	if( checkpath && (map_getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path_search(NULL,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) )
+	if( checkpath && (map_getcell(bl->m,dst_x,dst_y,CELL_CHKNOPASS) || !path_search(nullptr,bl->m,bl->x,bl->y,dst_x,dst_y,easy,CELL_CHKNOREACH)) )
 		return false; // Unreachable
 
 	ud->to_x = dst_x;
@@ -1077,7 +1077,7 @@ bool unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, boo
 		if(map_getcell(bl->m,bl->x,bl->y,CELL_CHKNPC)) {
 			npc_touch_area_allnpc(sd, bl->m, bl->x, bl->y);
 
-			if (bl->prev == NULL) // Script could have warped char, abort remaining of the function.
+			if (bl->prev == nullptr) // Script could have warped char, abort remaining of the function.
 				return false;
 		} else
 			sd->areanpc.clear();
@@ -1087,7 +1087,7 @@ bool unit_movepos(struct block_list *bl, short dst_x, short dst_y, int easy, boo
 			int flag = 0;
 			struct block_list* pbl = &sd->pd->bl;
 
-			if( !checkpath && !path_search(NULL,pbl->m,pbl->x,pbl->y,dst_x,dst_y,0,CELL_CHKNOPASS) )
+			if( !checkpath && !path_search(nullptr,pbl->m,pbl->x,pbl->y,dst_x,dst_y,0,CELL_CHKNOPASS) )
 				flag = 1;
 			else if (!check_distance_bl(&sd->bl, pbl, AREA_SIZE)) // Too far, teleport.
 				flag = 2;
@@ -1166,7 +1166,7 @@ int unit_blown(struct block_list* bl, int dx, int dy, int count, enum e_skill_bl
 {
 	if(count) {
 		map_session_data* sd;
-		struct skill_unit* su = NULL;
+		struct skill_unit* su = nullptr;
 		int nx, ny, result;
 
 		sd = BL_CAST(BL_PC, bl);
@@ -1297,7 +1297,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
 
 	ud = unit_bl2ud(bl);
 
-	if(bl->prev==NULL || !ud)
+	if(bl->prev==nullptr || !ud)
 		return 1;
 
 	if (type == CLR_DEAD)
@@ -1323,7 +1323,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
 	}
 
 	if (x < 0 || y < 0) { // Random map position.
-		if (!map_search_freecell(NULL, m, &x, &y, -1, -1, 1)) {
+		if (!map_search_freecell(nullptr, m, &x, &y, -1, -1, 1)) {
 			ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, map[m].name, x, y);
 			return 2;
 
@@ -1331,7 +1331,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
 	} else if ( bl->type != BL_NPC && map_getcell(m,x,y,CELL_CHKNOREACH)) { // Invalid target cell
 		ShowWarning("unit_warp: Specified non-walkable target cell: %d (%s) at [%d,%d]\n", m, map[m].name, x,y);
 
-		if (!map_search_freecell(NULL, m, &x, &y, 4, 4, 1)) { // Can't find a nearby cell
+		if (!map_search_freecell(nullptr, m, &x, &y, 4, 4, 1)) { // Can't find a nearby cell
 			ShowWarning("unit_warp failed. Unit Id:%d/Type:%d, target position map %d (%s) at [%d,%d]\n", bl->id, bl->type, m, map[m].name, x, y);
 			return 2;
 		}
@@ -1383,7 +1383,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type)
 int unit_stop_walking(struct block_list *bl,int type)
 {
 	struct unit_data *ud;
-	const struct TimerData* td = NULL;
+	const struct TimerData* td = nullptr;
 	t_tick tick;
 
 	nullpo_ret(bl);
@@ -1612,8 +1612,8 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
 	struct unit_data *ud;
 	struct status_data *tstatus;
 	status_change *sc;
-	map_session_data *sd = NULL;
-	struct block_list * target = NULL;
+	map_session_data *sd = nullptr;
+	struct block_list * target = nullptr;
 	t_tick tick = gettick();
 	int combo = 0, range;
 
@@ -1625,7 +1625,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
 	sd = BL_CAST(BL_PC, src);
 	ud = unit_bl2ud(src);
 
-	if(ud == NULL)
+	if(ud == nullptr)
 		return 0;
 
 	if (ud && ud->state.blockedskill)
@@ -1634,7 +1634,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
 	sc = status_get_sc(src);
 
 	if (sc && !sc->count)
-		sc = NULL; // Unneeded
+		sc = nullptr; // Unneeded
 
 	int inf = skill_get_inf(skill_id);
 	std::shared_ptr<s_skill_db> skill = skill_db.find(skill_id);
@@ -1671,7 +1671,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
 		switch(skill_id) { // Check for skills that auto-select target
 			case MO_CHAINCOMBO:
 				if (sc && sc->getSCE(SC_BLADESTOP)) {
-					if ((target=map_id2bl(sc->getSCE(SC_BLADESTOP)->val4)) == NULL)
+					if ((target=map_id2bl(sc->getSCE(SC_BLADESTOP)->val4)) == nullptr)
 						return 0;
 				}
 				break;
@@ -1881,7 +1881,7 @@ int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill_id, ui
 	// (these are supposed to always have the same range as your attack)
 	if( src->type != BL_NPC && !ignore_range && src->id != target_id && (!combo || ud->attacktimer == INVALID_TIMER) ) {
 		if( skill_get_state(ud->skill_id) == ST_MOVE_ENABLE ) {
-			if( !unit_can_reach_bl(src, target, range + 1, 1, NULL, NULL) )
+			if( !unit_can_reach_bl(src, target, range + 1, 1, nullptr, nullptr) )
 				return 0; // Walk-path check failed.
 		} else if( src->type == BL_MER && skill_id == MA_REMOVETRAP ) {
 			if( !battle_check_range(battle_get_master(src), target, range + 1) )
@@ -2125,8 +2125,8 @@ int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_y, uint
  */
 int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, uint16 skill_id, uint16 skill_lv, int casttime, int castcancel, bool ignore_range)
 {
-	map_session_data *sd = NULL;
-	struct unit_data        *ud = NULL;
+	map_session_data *sd = nullptr;
+	struct unit_data        *ud = nullptr;
 	status_change *sc;
 	struct block_list    bl;
 	t_tick tick = gettick();
@@ -2143,7 +2143,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
 	sd = BL_CAST(BL_PC, src);
 	ud = unit_bl2ud(src);
 
-	if(ud == NULL)
+	if(ud == nullptr)
 		return 0;
 
 	if (ud && ud->state.blockedskill)
@@ -2155,7 +2155,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
 	sc = status_get_sc(src);
 
 	if (sc && !sc->count)
-		sc = NULL;
+		sc = nullptr;
 
 	if (!skill_db.find(skill_id))
 		return 0;
@@ -2173,7 +2173,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
 		return 0;
 	}
 
-	if (!status_check_skilluse(src, NULL, skill_id, 0))
+	if (!status_check_skilluse(src, nullptr, skill_id, 0))
 		return 0;
 
 	// Fail if the targetted skill is near NPC [Cydh]
@@ -2211,7 +2211,7 @@ int unit_skilluse_pos2( struct block_list *src, short skill_x, short skill_y, ui
 
 	if (!ignore_range) {
 		if( skill_get_state(ud->skill_id) == ST_MOVE_ENABLE ) {
-			if( !unit_can_reach_bl(src, &bl, range + 1, 1, NULL, NULL) )
+			if( !unit_can_reach_bl(src, &bl, range + 1, 1, nullptr, nullptr) )
 				return 0; // Walk-path check failed.
 		}else if( !battle_check_range(src, &bl, range) )
 			return 0; // Arrow-path check failed.
@@ -2425,7 +2425,7 @@ int unit_attack(struct block_list *src,int target_id,int continuous)
 	nullpo_ret(ud = unit_bl2ud(src));
 
 	target = map_id2bl(target_id);
-	if( target == NULL || status_isdead(target) ) {
+	if( target == nullptr || status_isdead(target) ) {
 		unit_unattackable(src);
 		return 1;
 	}
@@ -2523,7 +2523,7 @@ bool unit_can_reach_pos(struct block_list *bl,int x,int y, int easy)
 	if (bl->x == x && bl->y == y) // Same place
 		return true;
 
-	return path_search(NULL,bl->m,bl->x,bl->y,x,y,easy,CELL_CHKNOREACH);
+	return path_search(nullptr,bl->m,bl->x,bl->y,x,y,easy,CELL_CHKNOREACH);
 }
 
 /**
@@ -2684,11 +2684,11 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, t_tick tick)
 	struct block_list *target;
 	struct unit_data *ud;
 	struct status_data *sstatus;
-	map_session_data *sd = NULL;
-	struct mob_data *md = NULL;
+	map_session_data *sd = nullptr;
+	struct mob_data *md = nullptr;
 	int range;
 
-	if( (ud = unit_bl2ud(src)) == NULL )
+	if( (ud = unit_bl2ud(src)) == nullptr )
 		return 0;
 
 	if( ud->attacktimer != tid ) {
@@ -2701,13 +2701,13 @@ static int unit_attack_timer_sub(struct block_list* src, int tid, t_tick tick)
 	ud->attacktimer = INVALID_TIMER;
 	target = map_id2bl(ud->target);
 
-	if( src == NULL || src->prev == NULL || target==NULL || target->prev == NULL )
+	if( src == nullptr || src->prev == nullptr || target==nullptr || target->prev == nullptr )
 		return 0;
 
 	if( status_isdead(src) || status_isdead(target) ||
 			battle_check_target(src,target,BCT_ENEMY) <= 0 || !status_check_skilluse(src, target, 0, 0)
 #ifdef OFFICIAL_WALKPATH
-	   || !path_search_long(NULL, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL)
+	   || !path_search_long(nullptr, src->m, src->x, src->y, target->x, target->y, CELL_CHKWALL)
 #endif
 	   || !unit_can_attack(src, target->id) )
 		return 0; // Can't attack under these conditions
@@ -2895,7 +2895,7 @@ bool unit_can_attack(struct block_list *bl, int target_id) {
  */
 int unit_skillcastcancel(struct block_list *bl, char type)
 {
-	map_session_data *sd = NULL;
+	map_session_data *sd = nullptr;
 	struct unit_data *ud = unit_bl2ud( bl);
 	t_tick tick = gettick();
 	int ret = 0, skill_id;
@@ -3051,7 +3051,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
 
 	nullpo_ret(ud);
 
-	if(bl->prev == NULL)
+	if(bl->prev == nullptr)
 		return 0; // Already removed?
 
 	map_freeblock_lock();
@@ -3164,7 +3164,7 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file,
 			if( map[bl->m].users <= 0 || sd->state.debug_remove_map ) {
 				// This is only place where map users is decreased, if the mobs were removed
 				// too soon then this function was executed too many times [FlavioJS]
-				if( sd->debug_file == NULL || !(sd->state.debug_remove_map) ) {
+				if( sd->debug_file == nullptr || !(sd->state.debug_remove_map) ) {
 					sd->debug_file = "";
 					sd->debug_line = 0;
 					sd->debug_func = "";
@@ -3427,7 +3427,7 @@ int unit_free(struct block_list *bl, clr_type clrtype)
 
 			if( sd->st && sd->st->state != RUN ) {// free attached scripts that are waiting
 				script_free_state(sd->st);
-				sd->st = NULL;
+				sd->st = nullptr;
 				sd->npc_id = 0;
 			}
 
@@ -3457,12 +3457,12 @@ int unit_free(struct block_list *bl, clr_type clrtype)
 
 				sd->sc_display_count = 0;
 				aFree(sd->sc_display);
-				sd->sc_display = NULL;
+				sd->sc_display = nullptr;
 			}
 
-			if( sd->quest_log != NULL ) {
+			if( sd->quest_log != nullptr ) {
 				aFree(sd->quest_log);
-				sd->quest_log = NULL;
+				sd->quest_log = nullptr;
 				sd->num_quests = sd->avail_quests = 0;
 			}
 
@@ -3504,8 +3504,8 @@ int unit_free(struct block_list *bl, clr_type clrtype)
 			}
 
 			if( sd )
-				sd->pd = NULL;
-			pd->master = NULL;
+				sd->pd = nullptr;
+			pd->master = nullptr;
 
 			skill_clear_unitgroup(bl);
 			status_change_clear(bl,1);
@@ -3529,7 +3529,7 @@ int unit_free(struct block_list *bl, clr_type clrtype)
 
 			if (md->lootitems) {
 				aFree(md->lootitems);
-				md->lootitems = NULL;
+				md->lootitems = nullptr;
 			}
 
 			if( md->guardian_data ) {
@@ -3547,7 +3547,7 @@ int unit_free(struct block_list *bl, clr_type clrtype)
 
 				md->guardian_data->~guardian_data();
 				aFree(md->guardian_data);
-				md->guardian_data = NULL;
+				md->guardian_data = nullptr;
 			}
 
 			if( md->spawn ) {
@@ -3556,14 +3556,14 @@ int unit_free(struct block_list *bl, clr_type clrtype)
 				if( !md->spawn->state.dynamic ) { // Permanently remove the mob
 					if( --md->spawn->num == 0 ) { // Last freed mob is responsible for deallocating the group's spawn data.
 						aFree(md->spawn);
-						md->spawn = NULL;
+						md->spawn = nullptr;
 					}
 				}
 			}
 
 			if( md->base_status) {
 				aFree(md->base_status);
-				md->base_status = NULL;
+				md->base_status = nullptr;
 			}
 
 			skill_clear_unitgroup(bl);
@@ -3598,8 +3598,8 @@ int unit_free(struct block_list *bl, clr_type clrtype)
 			}
 
 			if( sd )
-				sd->hd = NULL;
-			hd->master = NULL;
+				sd->hd = nullptr;
+			hd->master = nullptr;
 
 			skill_clear_unitgroup(bl);
 			status_change_clear(bl,1);
@@ -3619,10 +3619,10 @@ int unit_free(struct block_list *bl, clr_type clrtype)
 			}
 
 			if( sd )
-				sd->md = NULL;
+				sd->md = nullptr;
 
 			mercenary_contract_stop(md);
-			md->master = NULL;
+			md->master = nullptr;
 
 			skill_clear_unitgroup(bl);
 			status_change_clear(bl,1);
@@ -3642,10 +3642,10 @@ int unit_free(struct block_list *bl, clr_type clrtype)
 			}
 
 			if( sd )
-				sd->ed = NULL;
+				sd->ed = nullptr;
 
 			elemental_summon_stop(ed);
-			ed->master = NULL;
+			ed->master = nullptr;
 
 			skill_clear_unitgroup(bl);
 			status_change_clear(bl,1);

+ 17 - 17
src/map/vending.cpp

@@ -82,7 +82,7 @@ void vending_vendinglistreq(map_session_data* sd, int id)
 	map_session_data* vsd;
 	nullpo_retv(sd);
 
-	if( (vsd = map_id2sd(id)) == NULL )
+	if( (vsd = map_id2sd(id)) == nullptr )
 		return;
 	if( !vsd->state.vending )
 		return; // not vending
@@ -128,7 +128,7 @@ void vending_purchasereq(map_session_data* sd, int aid, int uid, const uint8* da
 	map_session_data* vsd = map_id2sd(aid);
 
 	nullpo_retv(sd);
-	if( vsd == NULL || !vsd->state.vending || vsd->bl.id == sd->bl.id )
+	if( vsd == nullptr || !vsd->state.vending || vsd->bl.id == sd->bl.id )
 		return; // invalid shop
 
 	if( vsd->vender_id != uid ) { // shop has changed
@@ -292,7 +292,7 @@ void vending_purchasereq(map_session_data* sd, int aid, int uid, const uint8* da
  * @param data : itemlist data
  *	data := {<index>.w <amount>.w <value>.l}[count]
  * @param count : number of different items
- * @param at Autotrader info, or NULL if requetsed not from autotrade persistance
+ * @param at Autotrader info, or nullptr if requetsed not from autotrade persistance
  * @return 0 If success, 1 - Cannot open (die, not state.prevend, trading), 2 - No cart, 3 - Count issue, 4 - Cart data isn't saved yet, 5 - No valid item found
  */
 int8 vending_openvending( map_session_data& sd, const char* message, const uint8* data, int count, struct s_autotrader *at ){
@@ -493,7 +493,7 @@ bool vending_searchall(map_session_data* sd, const struct s_search_store_search*
 */
 void vending_reopen( map_session_data& sd )
 {
-	struct s_autotrader *at = NULL;
+	struct s_autotrader *at = nullptr;
 	int8 fail = -1;
 
 	// Open vending for this autotrader
@@ -583,24 +583,24 @@ void do_init_vending_autotrade(void)
 
 		if( Sql_NumRows(mmysql_handle) > 0 ) {
 			uint16 items = 0;
-			DBIterator *iter = NULL;
-			struct s_autotrader *at = NULL;
+			DBIterator *iter = nullptr;
+			struct s_autotrader *at = nullptr;
 
 			// Init each autotrader data
 			while (SQL_SUCCESS == Sql_NextRow(mmysql_handle)) {
 				size_t len;
 				char* data;
 
-				at = NULL;
+				at = nullptr;
 				CREATE(at, struct s_autotrader, 1);
-				Sql_GetData(mmysql_handle, 0, &data, NULL); at->id = atoi(data);
-				Sql_GetData(mmysql_handle, 1, &data, NULL); at->account_id = atoi(data);
-				Sql_GetData(mmysql_handle, 2, &data, NULL); at->char_id = atoi(data);
-				Sql_GetData(mmysql_handle, 3, &data, NULL); at->sex = (data[0] == 'F') ? SEX_FEMALE : SEX_MALE;
+				Sql_GetData(mmysql_handle, 0, &data, nullptr); at->id = atoi(data);
+				Sql_GetData(mmysql_handle, 1, &data, nullptr); at->account_id = atoi(data);
+				Sql_GetData(mmysql_handle, 2, &data, nullptr); at->char_id = atoi(data);
+				Sql_GetData(mmysql_handle, 3, &data, nullptr); at->sex = (data[0] == 'F') ? SEX_FEMALE : SEX_MALE;
 				Sql_GetData(mmysql_handle, 4, &data, &len); safestrncpy(at->title, data, zmin(len + 1, MESSAGE_SIZE));
-				Sql_GetData(mmysql_handle, 5, &data, NULL); at->dir = atoi(data);
-				Sql_GetData(mmysql_handle, 6, &data, NULL); at->head_dir = atoi(data);
-				Sql_GetData(mmysql_handle, 7, &data, NULL); at->sit = atoi(data);
+				Sql_GetData(mmysql_handle, 5, &data, nullptr); at->dir = atoi(data);
+				Sql_GetData(mmysql_handle, 6, &data, nullptr); at->head_dir = atoi(data);
+				Sql_GetData(mmysql_handle, 7, &data, nullptr); at->sit = atoi(data);
 				at->count = 0;
 
 				if (battle_config.feature_autotrade_direction >= 0)
@@ -653,9 +653,9 @@ void do_init_vending_autotrade(void)
 				while (SQL_SUCCESS == Sql_NextRow(mmysql_handle) && j < at->count) {
 					char *data;
 					CREATE(at->entries[j], struct s_autotrade_entry, 1);
-					Sql_GetData(mmysql_handle, 0, &data, NULL); at->entries[j]->cartinventory_id = atoi(data);
-					Sql_GetData(mmysql_handle, 1, &data, NULL); at->entries[j]->amount = atoi(data);
-					Sql_GetData(mmysql_handle, 2, &data, NULL); at->entries[j]->price = atoi(data);
+					Sql_GetData(mmysql_handle, 0, &data, nullptr); at->entries[j]->cartinventory_id = atoi(data);
+					Sql_GetData(mmysql_handle, 1, &data, nullptr); at->entries[j]->amount = atoi(data);
+					Sql_GetData(mmysql_handle, 2, &data, nullptr); at->entries[j]->price = atoi(data);
 					j++;
 				}
 				items += j;

+ 14 - 14
src/tool/csv2yaml.cpp

@@ -660,14 +660,14 @@ static bool pet_read_db( const char* file ){
 			str[k] = p;
 			p = strchr(p,',');
 
-			if( p == NULL )
+			if( p == nullptr )
 				break; // comma not found
 
 			*p = '\0';
 			++p;
 		}
 
-		if( p == NULL ) {
+		if( p == nullptr ) {
 			ShowError("read_petdb: Insufficient columns in line %d, skipping.\n", lines);
 			continue;
 		}
@@ -681,7 +681,7 @@ static bool pet_read_db( const char* file ){
 		str[20] = p;
 		p = strstr(p+1,"},");
 
-		if( p == NULL ) {
+		if( p == nullptr ) {
 			ShowError("read_petdb: Invalid format (Pet Script column) in line %d, skipping.\n", lines);
 			continue;
 		}
@@ -1272,13 +1272,13 @@ static bool skill_parse_row_castnodexdb( char* split[], size_t columns, size_t c
 static bool skill_parse_row_unitdb( char* split[], size_t columns, size_t current ){
 	s_skill_unit_csv entry = {};
 
-	entry.unit_id = (uint16)strtol(split[1], NULL, 16);
-	entry.unit_id2 = (uint16)strtol(split[2], NULL, 16);
+	entry.unit_id = (uint16)strtol(split[1], nullptr, 16);
+	entry.unit_id2 = (uint16)strtol(split[2], nullptr, 16);
 	skill_split_atoi(split[3], entry.unit_layout_type);
 	skill_split_atoi(split[4], entry.unit_range);
 	entry.unit_interval = atoi(split[5]);
 	entry.target_str = trim(split[6]);
-	entry.unit_flag_csv = strtol(split[7], NULL, 16);
+	entry.unit_flag_csv = strtol(split[7], nullptr, 16);
 
 	skill_unit.insert({ atoi(split[0]), entry });
 
@@ -1369,7 +1369,7 @@ static bool skill_parse_row_skilldb( char* split[], size_t columns, size_t curre
 		body << YAML::Key << "TargetType" << YAML::Value << name2Upper(constant);
 	}
 
-	uint64 nk_val = strtol(split[5], NULL, 0);
+	uint64 nk_val = strtol(split[5], nullptr, 0);
 
 	if (nk_val) {
 		body << YAML::Key << "DamageFlags";
@@ -2342,7 +2342,7 @@ static bool quest_read_db( char *split[], size_t columns, size_t current ){
 	title.erase(std::remove(title.begin(), title.end(), '"'), title.end()); // Strip double quotes out
 	body << YAML::Key << "Title" << YAML::Value << title;
 
-	if (strchr(split[1], ':') == NULL) {
+	if (strchr(split[1], ':') == nullptr) {
 		uint32 time = atoi(split[1]);
 
 		if (time > 0) {
@@ -2560,7 +2560,7 @@ static bool itemdb_read_stack( char* fields[], size_t columns, size_t current ){
 
 	item.amount = atoi(fields[1]);
 
-	int type = strtoul(fields[2], NULL, 10);
+	int type = strtoul(fields[2], nullptr, 10);
 
 	if (type & 1)
 		item.inventory = true;
@@ -2656,13 +2656,13 @@ static bool itemdb_read_db(const char* file) {
 		for (i = 0; i < 19; ++i) {
 			str[i] = p;
 			p = strchr(p, ',');
-			if (p == NULL)
+			if (p == nullptr)
 				break;// comma not found
 			*p = '\0';
 			++p;
 		}
 
-		if (p == NULL) {
+		if (p == nullptr) {
 			ShowError("itemdb_read_db: Insufficient columns in line %d (item with id %lu), skipping.\n", lines, strtoul(str[0], nullptr, 10));
 			continue;
 		}
@@ -2674,7 +2674,7 @@ static bool itemdb_read_db(const char* file) {
 		}
 		str[19] = p + 1;
 		p = strstr(p + 1, "},");
-		if (p == NULL) {
+		if (p == nullptr) {
 			ShowError("itemdb_read_db: Invalid format (Script column) in line %d (item with id %lu), skipping.\n", lines, strtoul(str[0], nullptr, 10));
 			continue;
 		}
@@ -2688,7 +2688,7 @@ static bool itemdb_read_db(const char* file) {
 		}
 		str[20] = p + 1;
 		p = strstr(p + 1, "},");
-		if (p == NULL) {
+		if (p == nullptr) {
 			ShowError("itemdb_read_db: Invalid format (OnEquip_Script column) in line %d (item with id %lu), skipping.\n", lines, strtoul(str[0], nullptr, 10));
 			continue;
 		}
@@ -2792,7 +2792,7 @@ static bool itemdb_read_db(const char* file) {
 		bool equippable = type == IT_UNKNOWN ? false : type == IT_ETC ? false : type == IT_CARD ? false : type == IT_PETEGG ? false : type == IT_PETARMOR ? false : type == IT_UNKNOWN2 ? false : true;
 
 		if (equippable) {
-			uint64 temp_mask = strtoull(str[11], NULL, 0);
+			uint64 temp_mask = strtoull(str[11], nullptr, 0);
 
 			if (temp_mask == 0) {
 				//body << YAML::Key << "Jobs";

+ 4 - 4
src/tool/mapcache.cpp

@@ -77,7 +77,7 @@ int read_map(char *name, struct map_data *m)
 	// Open map GAT
 	sprintf(filename,"data\\%s.gat", name);
 	gat = (unsigned char *)grfio_read(filename);
-	if (gat == NULL)
+	if (gat == nullptr)
 		return 0;
 
 	// Open map RSW
@@ -217,7 +217,7 @@ bool MapcacheTool::initialize( int argc, char* argv[] ){
 	ShowStatus("Opening map cache: %s\n", map_cache_file.c_str());
 	if(!rebuild) {
 		map_cache_fp = fopen(map_cache_file.c_str(), "rb");
-		if(map_cache_fp == NULL) {
+		if(map_cache_fp == nullptr) {
 			ShowNotice("Existing map cache not found, forcing rebuild mode\n");
 			rebuild = 1;
 		} else
@@ -227,7 +227,7 @@ bool MapcacheTool::initialize( int argc, char* argv[] ){
 		map_cache_fp = fopen(map_cache_file.c_str(), "w+b");
 	else
 		map_cache_fp = fopen(map_cache_file.c_str(), "r+b");
-	if(map_cache_fp == NULL) {
+	if(map_cache_fp == nullptr) {
 		ShowError("Failure when opening map cache file %s\n", map_cache_file.c_str());
 		return false;
 	}
@@ -241,7 +241,7 @@ bool MapcacheTool::initialize( int argc, char* argv[] ){
 
 		ShowStatus("Opening map list: %s\n", filename.c_str());
 		list = fopen(filename.c_str(), "r");
-		if (list == NULL) {
+		if (list == nullptr) {
 			ShowError("Failure when opening maps list file %s\n", filename.c_str());
 			return false;
 		}

+ 8 - 8
src/tool/yaml.hpp

@@ -311,7 +311,7 @@ uint8 skill_split_atoi2(char *str, int64 *val, const char *delim, int min_value,
 	uint8 i = 0;
 	char *p = strtok(str, delim);
 
-	while (p != NULL) {
+	while (p != nullptr) {
 		int64 n = min_value;
 
 		trim(p);
@@ -320,7 +320,7 @@ uint8 skill_split_atoi2(char *str, int64 *val, const char *delim, int min_value,
 			n = atoi(p);
 		else {
 			n = constant_lookup_int(p);
-			p = strtok(NULL, delim);
+			p = strtok(nullptr, delim);
 		}
 
 		if (n > min_value) {
@@ -329,7 +329,7 @@ uint8 skill_split_atoi2(char *str, int64 *val, const char *delim, int min_value,
 			if (i >= max)
 				break;
 		}
-		p = strtok(NULL, delim);
+		p = strtok(nullptr, delim);
 	}
 	return i;
 }
@@ -408,7 +408,7 @@ static bool parse_item_constants_txt(const char *path) {
 	FILE *fp;
 
 	fp = fopen(path, "r");
-	if (fp == NULL) {
+	if (fp == nullptr) {
 		ShowWarning("itemdb_readdb: File not found \"%s\", skipping.\n", path);
 		return false;
 	}
@@ -438,7 +438,7 @@ static bool parse_item_constants_txt(const char *path) {
 		{
 			str[i] = p;
 			p = strchr(p, ',');
-			if (p == NULL)
+			if (p == nullptr)
 				break;// comma not found
 			*p = '\0';
 			++p;
@@ -446,7 +446,7 @@ static bool parse_item_constants_txt(const char *path) {
 
 		t_itemid item_id = strtoul(str[0], nullptr, 10);
 
-		if (p == NULL)
+		if (p == nullptr)
 		{
 			ShowError("itemdb_readdb: Insufficient columns in line %d of \"%s\" (item with id %u), skipping.\n", lines, path, item_id);
 			continue;
@@ -460,7 +460,7 @@ static bool parse_item_constants_txt(const char *path) {
 		}
 		str[19] = p + 1;
 		p = strstr(p + 1, "},");
-		if (p == NULL)
+		if (p == nullptr)
 		{
 			ShowError("itemdb_readdb: Invalid format (Script column) in line %d of \"%s\" (item with id %u), skipping.\n", lines, path, item_id);
 			continue;
@@ -476,7 +476,7 @@ static bool parse_item_constants_txt(const char *path) {
 		}
 		str[20] = p + 1;
 		p = strstr(p + 1, "},");
-		if (p == NULL)
+		if (p == nullptr)
 		{
 			ShowError("itemdb_readdb: Invalid format (OnEquip_Script column) in line %d of \"%s\" (item with id %u), skipping.\n", lines, path, item_id);
 			continue;

+ 2 - 2
src/web/charconfig_controller.cpp

@@ -53,7 +53,7 @@ HANDLER_FUNC(charconfig_save) {
 
 	if (SqlStmt_NumRows(stmt) > 0) {
 		char databuf[SQL_BUFFER_SIZE];
-		if (SQL_SUCCESS != SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &databuf, sizeof(databuf), NULL, NULL)
+		if (SQL_SUCCESS != SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &databuf, sizeof(databuf), nullptr, nullptr)
 			|| SQL_SUCCESS != SqlStmt_NextRow(stmt)
 		) {
 			SqlStmt_ShowDebug(stmt);
@@ -157,7 +157,7 @@ HANDLER_FUNC(charconfig_load) {
 
 	char databuf[SQL_BUFFER_SIZE];
 
-	if (SQL_SUCCESS != SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &databuf, sizeof(databuf), NULL, NULL)
+	if (SQL_SUCCESS != SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &databuf, sizeof(databuf), nullptr, nullptr)
 		|| SQL_SUCCESS != SqlStmt_NextRow(stmt)
 	) {
 		SqlStmt_ShowDebug(stmt);

+ 1 - 1
src/web/emblem_controller.cpp

@@ -246,7 +246,7 @@ HANDLER_FUNC(emblem_upload) {
 	uint32 version = START_VERSION;
 
 	if (SqlStmt_NumRows(stmt) > 0) {
-		if (SQL_SUCCESS != SqlStmt_BindColumn(stmt, 0, SQLDT_UINT32, &version, sizeof(version), NULL, NULL)
+		if (SQL_SUCCESS != SqlStmt_BindColumn(stmt, 0, SQLDT_UINT32, &version, sizeof(version), nullptr, nullptr)
 			|| SQL_SUCCESS != SqlStmt_NextRow(stmt)
 		) {
 			SqlStmt_ShowDebug(stmt);

+ 1 - 1
src/web/merchantstore_controller.cpp

@@ -149,7 +149,7 @@ HANDLER_FUNC(merchantstore_load) {
 
 	char databuf[SQL_BUFFER_SIZE] = { 0 };
 
-	if (SQL_SUCCESS != SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &databuf, sizeof(databuf), NULL, NULL)
+	if (SQL_SUCCESS != SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &databuf, sizeof(databuf), nullptr, nullptr)
 		|| SQL_SUCCESS != SqlStmt_NextRow(stmt)
 	) {
 		SqlStmt_ShowDebug(stmt);

+ 11 - 11
src/web/partybooking_controller.cpp

@@ -79,17 +79,17 @@ bool party_booking_read( std::string& world_name, std::vector<s_party_booking_en
 	if( SQL_SUCCESS != SqlStmt_Prepare( stmt, query.c_str() )
 		|| SQL_SUCCESS != SqlStmt_BindParam( stmt, 0, SQLDT_STRING, (void*)world_name_escaped, strlen( world_name_escaped ) )
 		|| SQL_SUCCESS != SqlStmt_Execute( stmt )
-		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 0, SQLDT_UINT32, &entry.account_id, 0, NULL, NULL )
-		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 1, SQLDT_UINT32, &entry.char_id, 0, NULL, NULL )
-		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 2, SQLDT_STRING, (void*)char_name, sizeof( char_name ), NULL, NULL )
-		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 3, SQLDT_UINT16, &entry.purpose, 0, NULL, NULL )
-		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 4, SQLDT_UINT8, &entry.assist, 0, NULL, NULL )
-		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 5, SQLDT_UINT8, &entry.damagedealer, 0, NULL, NULL )
-		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 6, SQLDT_UINT8, &entry.healer, 0, NULL, NULL )
-		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 7, SQLDT_UINT8, &entry.tanker, 0, NULL, NULL )
-		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 8, SQLDT_UINT16, &entry.minimum_level, 0, NULL, NULL )
-		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 9, SQLDT_UINT16, &entry.maximum_level, 0, NULL, NULL )
-		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 10, SQLDT_STRING, (void*)comment, sizeof( comment ), NULL, NULL )
+		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 0, SQLDT_UINT32, &entry.account_id, 0, nullptr, nullptr )
+		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 1, SQLDT_UINT32, &entry.char_id, 0, nullptr, nullptr )
+		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 2, SQLDT_STRING, (void*)char_name, sizeof( char_name ), nullptr, nullptr )
+		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 3, SQLDT_UINT16, &entry.purpose, 0, nullptr, nullptr )
+		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 4, SQLDT_UINT8, &entry.assist, 0, nullptr, nullptr )
+		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 5, SQLDT_UINT8, &entry.damagedealer, 0, nullptr, nullptr )
+		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 6, SQLDT_UINT8, &entry.healer, 0, nullptr, nullptr )
+		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 7, SQLDT_UINT8, &entry.tanker, 0, nullptr, nullptr )
+		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 8, SQLDT_UINT16, &entry.minimum_level, 0, nullptr, nullptr )
+		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 9, SQLDT_UINT16, &entry.maximum_level, 0, nullptr, nullptr )
+		|| SQL_SUCCESS != SqlStmt_BindColumn( stmt, 10, SQLDT_STRING, (void*)comment, sizeof( comment ), nullptr, nullptr )
 	){
 		SqlStmt_ShowDebug( stmt );
 		SqlStmt_Free( stmt );

+ 2 - 2
src/web/userconfig_controller.cpp

@@ -51,7 +51,7 @@ HANDLER_FUNC(userconfig_save) {
 
 	if (SqlStmt_NumRows(stmt) > 0) {
 		char databuf[SQL_BUFFER_SIZE];
-		if (SQL_SUCCESS != SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &databuf, sizeof(databuf), NULL, NULL)
+		if (SQL_SUCCESS != SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &databuf, sizeof(databuf), nullptr, nullptr)
 			|| SQL_SUCCESS != SqlStmt_NextRow(stmt)
 		) {
 			SqlStmt_ShowDebug(stmt);
@@ -152,7 +152,7 @@ HANDLER_FUNC(userconfig_load) {
 
 	char databuf[SQL_BUFFER_SIZE];
 
-	if (SQL_SUCCESS != SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &databuf, sizeof(databuf), NULL, NULL)
+	if (SQL_SUCCESS != SqlStmt_BindColumn(stmt, 0, SQLDT_STRING, &databuf, sizeof(databuf), nullptr, nullptr)
 		|| SQL_SUCCESS != SqlStmt_NextRow(stmt)
 	) {
 		SqlStmt_ShowDebug(stmt);

+ 10 - 10
src/web/web.cpp

@@ -70,10 +70,10 @@ std::string web_server_db = "ragnarok";
 
 std::string default_codepage = "";
 
-Sql * login_handle = NULL;
-Sql * char_handle = NULL;
-Sql * map_handle = NULL;
-Sql * web_handle = NULL;
+Sql * login_handle = nullptr;
+Sql * char_handle = nullptr;
+Sql * map_handle = nullptr;
+Sql * web_handle = nullptr;
 
 char login_table[32] = "login";
 char guild_emblems_table[32] = "guild_emblems";
@@ -112,7 +112,7 @@ void web_do_final_msg(void){
 bool web_config_read(const char* cfgName, bool normal) {
 	char line[1024], w1[32], w2[1024];
 	FILE* fp = fopen(cfgName, "r");
-	if (fp == NULL) {
+	if (fp == nullptr) {
 		ShowError("Configuration file (%s) not found.\n", cfgName);
 		return false;
 	}
@@ -167,7 +167,7 @@ int inter_config_read(const char* cfgName)
 	FILE* fp;
 
 	fp = fopen(cfgName, "r");
-	if(fp == NULL) {
+	if(fp == nullptr) {
 		ShowError("File not found: %s\n", cfgName);
 		return 1;
 	}
@@ -348,16 +348,16 @@ int web_sql_close(void)
 {
 	ShowStatus("Close Login DB Connection....\n");
 	Sql_Free(login_handle);
-	login_handle = NULL;
+	login_handle = nullptr;
 	ShowStatus("Close Char DB Connection....\n");
 	Sql_Free(char_handle);
-	char_handle = NULL;
+	char_handle = nullptr;
 	ShowStatus("Close Map DB Connection....\n");
 	Sql_Free(map_handle);
-	map_handle = NULL;
+	map_handle = nullptr;
 	ShowStatus("Close Web DB Connection....\n");
 	Sql_Free(web_handle);
-	web_handle = NULL;
+	web_handle = nullptr;
 
 	return 0;
 }

部分文件因文件數量過多而無法顯示