diff options
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r-- | src/map/atcommand.c | 80 |
1 files changed, 35 insertions, 45 deletions
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 <monster name>). @@ -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 <mob name/id>) @@ -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; |