Replaced NULL with nullptr (#8298)

This commit is contained in:
Lemongrass3110
2024-05-03 19:38:13 +02:00
committed by GitHub
parent 30928a04e1
commit b48948822a
100 changed files with 3217 additions and 3217 deletions

View File

@@ -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))