From b3c722ecf777aeeea6317755a6adfc0216b7a2bd Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 27 Dec 2015 18:17:24 +0100 Subject: Replaced some explicit casts with BL_UCAST/BL_UCCAST - Replaced the map-iterator related casts. Signed-off-by: Haru --- src/map/atcommand.c | 80 ++++++++++++++++++++++---------------------------- src/map/battleground.c | 2 +- src/map/chrif.c | 6 ++-- src/map/clif.c | 13 ++++---- src/map/guild.c | 8 ++--- src/map/instance.c | 2 +- src/map/itemdb.c | 2 +- src/map/map.c | 28 ++++++++---------- src/map/npc.c | 9 +++--- src/map/pc.c | 6 ++-- src/map/pc_groups.c | 2 +- src/map/script.c | 11 +++---- src/map/skill.c | 2 +- 13 files changed, 79 insertions(+), 92 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index c5edd9934..635a7a220 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -609,7 +609,7 @@ ACMD(jump) * various info. *------------------------------------------*/ ACMD(who) { - struct map_session_data *pl_sd = NULL; + const struct map_session_data *pl_sd = NULL; struct s_mapiterator *iter = NULL; char player_name[NAME_LENGTH] = ""; int count = 0; @@ -640,7 +640,7 @@ ACMD(who) { StrBuf->Init(&buf); iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_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 || (map_id >= 0 && pl_sd->bl.m != map_id)) @@ -709,7 +709,7 @@ ACMD(who) { *------------------------------------------*/ ACMD(whogm) { - struct map_session_data* pl_sd; + const struct map_session_data *pl_sd; struct s_mapiterator* iter; int j, count; int level; @@ -731,7 +731,7 @@ ACMD(whogm) level = pc_get_group_level(sd); iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_PC, mapit->next(iter))) { int pl_level = pc_get_group_level(pl_sd); if (!pl_level) continue; @@ -2959,7 +2959,7 @@ ACMD(doom) struct s_mapiterator* iter; iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) { if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { status_kill(&pl_sd->bl); clif->specialeffect(&pl_sd->bl,450,AREA); @@ -2982,7 +2982,7 @@ ACMD(doommap) struct s_mapiterator* iter; iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) { if (pl_sd->fd != fd && sd->bl.m == pl_sd->bl.m && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { status_kill(&pl_sd->bl); clif->specialeffect(&pl_sd->bl,450,AREA); @@ -3017,7 +3017,7 @@ ACMD(raise) struct s_mapiterator* iter; iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) if( pc_isdead(pl_sd) ) atcommand->raise_sub(pl_sd); mapit->free(iter); @@ -3036,7 +3036,7 @@ ACMD(raisemap) struct s_mapiterator* iter; iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) ) atcommand->raise_sub(pl_sd); mapit->free(iter); @@ -3085,7 +3085,7 @@ ACMD(kickall) struct s_mapiterator* iter; iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) { 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); @@ -3419,7 +3419,7 @@ ACMD(recallall) count = 0; iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) { if (sd->status.account_id != pl_sd->status.account_id && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) { if (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y) continue; // Don't waste time warping the character to the same place. @@ -3479,7 +3479,7 @@ ACMD(guildrecall) count = 0; iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) { if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.guild_id == g->guild_id) { if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)) continue; // Skip GMs greater than you... or chars already on the cell @@ -3535,7 +3535,7 @@ ACMD(partyrecall) count = 0; iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) { if (sd->status.account_id != pl_sd->status.account_id && pl_sd->status.party_id == p->party.party_id) { if (pc_get_group_level(pl_sd) > pc_get_group_level(sd) || (pl_sd->bl.m == sd->bl.m && pl_sd->bl.x == sd->bl.x && pl_sd->bl.y == sd->bl.y)) continue; // Skip GMs greater than you... or chars already on the cell @@ -3698,7 +3698,7 @@ ACMD(reloadscript) { //atcommand_broadcast( fd, sd, "@broadcast", "You will feel a bit of lag at this point !" ); iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) { if (pl_sd->npc_id || pl_sd->npc_shopid) { if (pl_sd->state.using_fake_npc) { clif->clearunit_single(pl_sd->npc_id, CLR_OUTSIGHT, pl_sd->fd); @@ -3737,7 +3737,7 @@ ACMD(reloadscript) { TODO# add the missing mapflags e.g. adjust_skill_damage to display *------------------------------------------*/ ACMD(mapinfo) { - struct map_session_data* pl_sd; + const struct map_session_data *pl_sd; struct s_mapiterator* iter; struct chat_data *cd = NULL; char direction[12]; @@ -3774,7 +3774,7 @@ ACMD(mapinfo) { // count chats (for initial message) chat_num = 0; iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_PC, mapit->next(iter))) { if( pl_sd->mapindex == m_index ) { if( pl_sd->state.vending ) vend_num++; @@ -3919,7 +3919,7 @@ ACMD(mapinfo) { case 1: clif->message(fd, msg_fd(fd,1098)); // ----- Players in Map ----- iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_PC, mapit->next(iter))) { if (pl_sd->mapindex == m_index) { safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1099), // Player '%s' (session #%d) | Location: %d,%d pl_sd->status.name, pl_sd->fd, pl_sd->bl.x, pl_sd->bl.y); @@ -3956,7 +3956,7 @@ ACMD(mapinfo) { case 3: clif->message(fd, msg_fd(fd,1113)); // ----- Chats in Map ----- iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_PC, mapit->next(iter))) { if ((cd = (struct chat_data*)map->id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd) @@ -4741,7 +4741,7 @@ ACMD(disguiseall) } iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) pc->disguise(pl_sd, mob_id); mapit->free(iter); @@ -4821,7 +4821,7 @@ ACMD(undisguiseall) { struct s_mapiterator* iter; iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) if( pl_sd->disguise != -1 ) pc->disguise(pl_sd, -1); mapit->free(iter); @@ -6057,7 +6057,8 @@ ACMD(mobsearch) char mob_name[100]; int mob_id; int number = 0; - struct s_mapiterator* it; + struct s_mapiterator *it; + const struct mob_data *md = NULL; if (!*message || sscanf(message, "%99[^\n]", mob_name) < 1) { clif->message(fd, msg_fd(fd,1218)); // Please enter a monster name (usage: @mobsearch ). @@ -6079,12 +6080,7 @@ ACMD(mobsearch) clif->message(fd, atcmd_output); it = mapit_geteachmob(); - for(;;) - { - struct mob_data *md = (struct mob_data *)mapit->next(it); - if( md == NULL ) - break;// no more mobs - + for (md = BL_UCCAST(BL_MOB, mapit->first(it)); mapit->exists(it); md = BL_UCCAST(BL_MOB, mapit->next(it))) { if( md->bl.m != sd->bl.m ) continue; if( mob_id != -1 && md->class_ != mob_id ) @@ -6242,24 +6238,22 @@ ACMD(users) char buf[CHAT_SIZE_MAX]; int users[MAX_MAPINDEX]; int users_all; - struct s_mapiterator* iter; + struct s_mapiterator *iter; + const struct map_session_data *pl_sd = NULL; memset(users, 0, sizeof(users)); users_all = 0; // count users on each map iter = mapit_getallusers(); - for(;;) - { - struct map_session_data* sd2 = (struct map_session_data*)mapit->next(iter); - if( sd2 == NULL ) - break;// no more users - - if( sd2->mapindex >= MAX_MAPINDEX ) + for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_PC, mapit->next(iter))) { + if (pl_sd->mapindex >= MAX_MAPINDEX) continue;// invalid mapindex - if( users[sd2->mapindex] < INT_MAX ) ++users[sd2->mapindex]; - if( users_all < INT_MAX ) ++users_all; + if (users[pl_sd->mapindex] < INT_MAX) + ++users[pl_sd->mapindex]; + if (users_all < INT_MAX) + ++users_all; } mapit->free(iter); @@ -6528,7 +6522,7 @@ ACMD(refreshall) struct s_mapiterator* iter; iter = mapit_getallusers(); - for (iter_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); iter_sd = (struct map_session_data *)mapit->next(iter)) + for (iter_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); iter_sd = BL_UCAST(BL_PC, mapit->next(iter))) clif->refresh(iter_sd); mapit->free(iter); return true; @@ -6736,7 +6730,8 @@ ACMD(showmobs) char mob_name[100]; int mob_id; int number = 0; - struct s_mapiterator* it; + struct s_mapiterator *it; + const struct mob_data *md = NULL; if (sscanf(message, "%99[^\n]", mob_name) < 0) { clif->message(fd, msg_fd(fd,546)); // Please enter a mob name/id (usage: @showmobs ) @@ -6773,12 +6768,7 @@ ACMD(showmobs) clif->message(fd, atcmd_output); it = mapit_geteachmob(); - for(;;) - { - struct mob_data *md = (struct mob_data *)mapit->next(it); - if( md == NULL ) - break;// no more mobs - + for (md = BL_UCCAST(BL_MOB, mapit->first(it)); mapit->next(it); md = BL_UCCAST(BL_MOB, mapit->next(it))) { if( md->bl.m != sd->bl.m ) continue; if( mob_id != -1 && md->class_ != mob_id ) @@ -7411,7 +7401,7 @@ ACMD(sizeall) size = cap_value(size,0,2); iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) { if (pl_sd->state.size != size) { if (pl_sd->state.size) { pl_sd->state.size = SZ_SMALL; diff --git a/src/map/battleground.c b/src/map/battleground.c index 5d88180d5..a273784d4 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -655,7 +655,7 @@ int bg_afk_timer(int tid, int64 tick, int id, intptr_t data) { int count = 0; iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if( !sd->bg_queue.arena || !sd->bg_id ) continue; if( DIFF_TICK(sockt->last_tick, sd->idletime) > bg->mafksec ) diff --git a/src/map/chrif.c b/src/map/chrif.c index a39859609..1f7fbe96e 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1478,8 +1478,8 @@ int send_usercount_tochar(int tid, int64 tick, int id, intptr_t data) { *------------------------------------------*/ bool send_users_tochar(void) { int users = 0, i = 0; - struct map_session_data* sd; - struct s_mapiterator* iter; + const struct map_session_data *sd; + struct s_mapiterator *iter; chrif_check(false); @@ -1489,7 +1489,7 @@ bool send_users_tochar(void) { WFIFOW(chrif->fd,0) = 0x2aff; iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCCAST(BL_PC, mapit->next(iter))) { WFIFOL(chrif->fd,6+8*i) = sd->status.account_id; WFIFOL(chrif->fd,6+8*i+4) = sd->status.char_id; i++; diff --git a/src/map/clif.c b/src/map/clif.c index b1f901386..898a97c95 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -405,7 +405,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target case ALL_CLIENT: //All player clients. iter = mapit_getallusers(); - while ((tsd = (struct map_session_data *)mapit->next(iter)) != NULL) { + while ((tsd = BL_UCAST(BL_PC, mapit->next(iter))) != NULL) { WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); WFIFOSET(tsd->fd,len); @@ -415,7 +415,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target case ALL_SAMEMAP: //All players on the same map iter = mapit_getallusers(); - while ((tsd = (struct map_session_data *)mapit->next(iter)) != NULL) { + while ((tsd = BL_UCAST(BL_PC, mapit->next(iter))) != NULL) { if (bl && bl->m == tsd->bl.m) { WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); @@ -506,7 +506,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target break; iter = mapit_getallusers(); - while ((tsd = (struct map_session_data *)mapit->next(iter)) != NULL) { + while ((tsd = BL_UCAST(BL_PC, mapit->next(iter))) != NULL) { if( tsd->partyspy == p->party.party_id ) { WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); @@ -522,7 +522,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target if (!sd || !sd->duel_group) break; //Invalid usage. iter = mapit_getallusers(); - while ((tsd = (struct map_session_data *)mapit->next(iter)) != NULL) { + while ((tsd = BL_UCAST(BL_PC, mapit->next(iter))) != NULL) { if( type == DUEL_WOS && bl->id == tsd->bl.id ) continue; if( sd->duel_group == tsd->duel_group ) { @@ -585,7 +585,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target break; iter = mapit_getallusers(); - while ((tsd = (struct map_session_data *)mapit->next(iter)) != NULL) { + while ((tsd = BL_UCAST(BL_PC, mapit->next(iter))) != NULL) { if( tsd->guildspy == g->guild_id ) { WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); @@ -1388,8 +1388,7 @@ void clif_weather(int16 m) struct map_session_data *sd=NULL; iter = mapit_getallusers(); - for( sd = (struct map_session_data*)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data*)mapit->next(iter) ) - { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if( sd->bl.m == m ) clif->weather_check(sd); } diff --git a/src/map/guild.c b/src/map/guild.c index ada731bf6..d7dcad58f 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -442,7 +442,7 @@ int guild_check_member(struct guild *g) nullpo_ret(g); iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if( sd->status.guild_id != g->guild_id ) continue; @@ -465,7 +465,7 @@ int guild_recv_noinfo(int guild_id) struct s_mapiterator* iter; iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if( sd->status.guild_id == guild_id ) sd->status.guild_id = 0; // erase guild } @@ -505,7 +505,7 @@ int guild_recv_info(struct guild *sg) { tg[i] = guild->search(sg->alliance[i].guild_id); } - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if (!sd->status.guild_id) continue; // Not interested in guildless users @@ -946,7 +946,7 @@ void guild_retrieveitembound(int char_id,int aid,int guild_id) { struct guild_storage *gstor = idb_get(gstorage->db,guild_id); if(gstor && gstor->storage_status == 1) { //Someone is in guild storage, close them struct s_mapiterator* iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if(sd->status.guild_id == guild_id && sd->state.storage_flag == STORAGE_FLAG_GUILD) { gstorage->close(sd); break; diff --git a/src/map/instance.c b/src/map/instance.c index e3f381254..e9ef602f7 100644 --- a/src/map/instance.c +++ b/src/map/instance.c @@ -724,7 +724,7 @@ void do_reload_instance(void) { } iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if(sd && map->list[sd->bl.m].instance_id >= 0) { pc->setpos(sd,instance->list[map->list[sd->bl.m].instance_id].respawn.map,instance->list[map->list[sd->bl.m].instance_id].respawn.x,instance->list[map->list[sd->bl.m].instance_id].respawn.y,CLR_TELEPORT); } diff --git a/src/map/itemdb.c b/src/map/itemdb.c index 2894463de..048efd636 100644 --- a/src/map/itemdb.c +++ b/src/map/itemdb.c @@ -2123,7 +2123,7 @@ void itemdb_reload(void) { // readjust itemdb pointer cache for each player iter = mapit_geteachpc(); - for( sd = (struct map_session_data*)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data*)mapit->next(iter) ) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { memset(sd->item_delay, 0, sizeof(sd->item_delay)); // reset item delays pc->setinventorydata(sd); if( battle_config.item_check ) diff --git a/src/map/map.c b/src/map/map.c index a40ceebd0..e3054fb30 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -1979,7 +1979,7 @@ struct map_session_data * map_nick2sd(const char *nick) iter = mapit_getallusers(); found_sd = NULL; - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if( battle_config.partial_name_scan ) {// partial name search if( strnicmp(sd->status.name, nick, nicklen) == 0 ) @@ -2033,10 +2033,8 @@ struct mob_data * map_getmob_boss(int16 m) bool found = false; iter = db_iterator(map->bossid_db); - for( md = (struct mob_data*)dbi_first(iter); dbi_exists(iter); md = (struct mob_data*)dbi_next(iter) ) - { - if( md->bl.m == m ) - { + for (md = dbi_first(iter); dbi_exists(iter); md = dbi_next(iter)) { + if (md->bl.m == m) { found = true; break; } @@ -2124,7 +2122,7 @@ void map_vforeachmob(int (*func)(struct mob_data* md, va_list args), va_list arg struct mob_data* md; iter = db_iterator(map->mobid_db); - for( md = (struct mob_data*)dbi_first(iter); dbi_exists(iter); md = (struct mob_data*)dbi_next(iter) ) { + for (md = dbi_first(iter); dbi_exists(iter); md = dbi_next(iter)) { va_list argscopy; int ret; @@ -2155,7 +2153,7 @@ void map_vforeachnpc(int (*func)(struct npc_data* nd, va_list args), va_list arg struct block_list* bl; iter = db_iterator(map->id_db); - for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) ) { + for (bl = dbi_first(iter); dbi_exists(iter); bl = dbi_next(iter)) { if( bl->type == BL_NPC ) { struct npc_data* nd = (struct npc_data*)bl; va_list argscopy; @@ -2189,7 +2187,7 @@ void map_vforeachregen(int (*func)(struct block_list* bl, va_list args), va_list struct block_list* bl; iter = db_iterator(map->regen_db); - for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) ) { + for (bl = dbi_first(iter); dbi_exists(iter); bl = dbi_next(iter)) { va_list argscopy; int ret; @@ -2220,7 +2218,7 @@ void map_vforeachiddb(int (*func)(struct block_list* bl, va_list args), va_list struct block_list* bl; iter = db_iterator(map->id_db); - for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) ) { + for (bl = dbi_first(iter); dbi_exists(iter); bl = dbi_next(iter)) { va_list argscopy; int ret; @@ -2301,7 +2299,7 @@ struct block_list* mapit_first(struct s_mapiterator* iter) { nullpo_retr(NULL,iter); - for( bl = (struct block_list*)dbi_first(iter->dbi); bl != NULL; bl = (struct block_list*)dbi_next(iter->dbi) ) { + for (bl = dbi_first(iter->dbi); bl != NULL; bl = dbi_next(iter->dbi) ) { if( MAPIT_MATCHES(iter,bl) ) break;// found match } @@ -2318,7 +2316,7 @@ struct block_list* mapit_last(struct s_mapiterator* iter) { nullpo_retr(NULL,iter); - for( bl = (struct block_list*)dbi_last(iter->dbi); bl != NULL; bl = (struct block_list*)dbi_prev(iter->dbi) ) { + for (bl = dbi_last(iter->dbi); bl != NULL; bl = dbi_prev(iter->dbi)) { if( MAPIT_MATCHES(iter,bl) ) break;// found match } @@ -2336,7 +2334,7 @@ struct block_list* mapit_next(struct s_mapiterator* iter) { nullpo_retr(NULL,iter); for( ; ; ) { - bl = (struct block_list*)dbi_next(iter->dbi); + bl = dbi_next(iter->dbi); if( bl == NULL ) break;// end if( MAPIT_MATCHES(iter,bl) ) @@ -2357,7 +2355,7 @@ struct block_list* mapit_prev(struct s_mapiterator* iter) { nullpo_retr(NULL,iter); for( ; ; ) { - bl = (struct block_list*)dbi_prev(iter->dbi); + bl = dbi_prev(iter->dbi); if( bl == NULL ) break;// end if( MAPIT_MATCHES(iter,bl) ) @@ -5380,7 +5378,7 @@ int do_final(void) { //Ladies and babies first. iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) map->quit(sd); mapit->free(iter); @@ -5524,7 +5522,7 @@ void do_shutdown(void) { struct map_session_data* sd; struct s_mapiterator* iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) clif->GM_kick(NULL, sd); mapit->free(iter); sockt->flush_fifos(); diff --git a/src/map/npc.c b/src/map/npc.c index 8dd27389f..fc4abb5fa 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1630,7 +1630,7 @@ void npc_trader_update(int master) { CREATE(master_nd->u.scr.shop,struct npc_shop_data,1); iter = db_iterator(map->id_db); - for( bl = (struct block_list*)dbi_first(iter); dbi_exists(iter); bl = (struct block_list*)dbi_next(iter) ) { + for (bl = dbi_first(iter); dbi_exists(iter); bl = dbi_next(iter)) { if( bl->type == BL_NPC ) { struct npc_data* nd = (struct npc_data*)bl; @@ -2286,7 +2286,7 @@ int npc_unload(struct npc_data* nd, bool single) aFree(nd->u.shop.shop_item); else if( nd->subtype == SCRIPT ) { struct s_mapiterator* iter; - struct block_list* bl; + struct map_session_data *sd = NULL; if( single ) { npc->ev_db->foreach(npc->ev_db,npc->unload_ev,nd->exname); //Clean up all events related @@ -2294,8 +2294,7 @@ int npc_unload(struct npc_data* nd, bool single) } iter = mapit_geteachpc(); - for( bl = (struct block_list*)mapit->first(iter); mapit->exists(iter); bl = (struct block_list*)mapit->next(iter) ) { - struct map_session_data *sd = (struct map_session_data *)bl; + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if( sd && sd->npc_timer_id != INVALID_TIMER ) { const struct TimerData *td = timer->get(sd->npc_timer_id); @@ -4662,7 +4661,7 @@ int npc_reload(void) { //Remove all npcs/mobs. [Skotlex] iter = mapit_geteachiddb(); - for( bl = (struct block_list*)mapit->first(iter); mapit->exists(iter); bl = (struct block_list*)mapit->next(iter) ) { + for (bl = mapit->first(iter); mapit->exists(iter); bl = mapit->next(iter)) { switch(bl->type) { case BL_NPC: if( bl->id != npc->fake_nd->bl.id )// don't remove fake_nd diff --git a/src/map/pc.c b/src/map/pc.c index 3c93be7df..7fc67d668 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -10259,7 +10259,7 @@ int pc_autosave(int tid, int64 tick, int id, intptr_t data) { save_flag = 1; //Noone was saved, so save first found char. iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if(sd->bl.id == last_save_id && save_flag != 1) { save_flag = 1; continue; @@ -10813,7 +10813,7 @@ void pc_read_skill_tree(void) /* lets update all players skill tree */ iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) clif->skillinfoblock(sd); mapit->free(iter); } @@ -11196,7 +11196,7 @@ int pc_global_expiration_timer(int tid, int64 tick, int id, intptr_t data) { struct map_session_data* sd; iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if( sd->expiration_time ) pc->expire_check(sd); } diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index cfb28cbd5..bd46b9616 100644 --- a/src/map/pc_groups.c +++ b/src/map/pc_groups.c @@ -508,7 +508,7 @@ void pc_groups_reload(void) { /* refresh online users permissions */ iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if (pc->set_group(sd, sd->group_id) != 0) { ShowWarning("pc_groups_reload: %s (AID:%d) has unknown group id (%d)! kicking...\n", sd->status.name, sd->status.account_id, pc_get_group_id(sd)); diff --git a/src/map/script.c b/src/map/script.c index 7fc4f6b39..800b58428 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -6104,7 +6104,7 @@ BUILDIN(warpguild) } iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCAST(BL_PC, mapit->next(iter))) { if( pl_sd->status.guild_id != gid ) continue; @@ -10530,7 +10530,8 @@ BUILDIN(getusers) { *------------------------------------------*/ BUILDIN(getusersname) { - struct map_session_data *sd, *pl_sd; + struct map_session_data *sd; + const struct map_session_data *pl_sd; int /*disp_num=1,*/ group_level = 0; struct s_mapiterator* iter; @@ -10539,7 +10540,7 @@ BUILDIN(getusersname) group_level = pc_get_group_level(sd); iter = mapit_getallusers(); - for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { + for (pl_sd = BL_UCCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); pl_sd = BL_UCCAST(BL_PC, mapit->next(iter))) { if (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc_get_group_level(pl_sd) > group_level) continue; // skip hidden sessions @@ -11884,7 +11885,7 @@ BUILDIN(pvpon) return true; iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if( sd->bl.m != m || sd->pvp_timer != INVALID_TIMER ) continue; // not applicable @@ -13605,7 +13606,7 @@ BUILDIN(recovery) struct s_mapiterator* iter; iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) { if(pc_isdead(sd)) status->revive(&sd->bl, 100, 100); else diff --git a/src/map/skill.c b/src/map/skill.c index 85de43198..b82e3864b 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -19111,7 +19111,7 @@ void skill_reload(void) chrif->skillid2idx(0); /* lets update all players skill tree : so that if any skill modes were changed they're properly updated */ iter = mapit_getallusers(); - for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) + for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) clif->skillinfoblock(sd); mapit->free(iter); -- cgit v1.2.3-60-g2f50