diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/map/atcommand.c | 54 | ||||
-rw-r--r-- | src/map/battle.c | 133 | ||||
-rw-r--r-- | src/map/battleground.c | 4 | ||||
-rw-r--r-- | src/map/chrif.c | 12 | ||||
-rw-r--r-- | src/map/chrif.h | 6 | ||||
-rw-r--r-- | src/map/clif.c | 120 | ||||
-rw-r--r-- | src/map/guild.c | 20 | ||||
-rw-r--r-- | src/map/guild.h | 6 | ||||
-rw-r--r-- | src/map/homunculus.c | 2 | ||||
-rw-r--r-- | src/map/instance.c | 2 | ||||
-rw-r--r-- | src/map/intif.c | 10 | ||||
-rw-r--r-- | src/map/map.c | 30 | ||||
-rw-r--r-- | src/map/mob.c | 14 | ||||
-rw-r--r-- | src/map/npc.c | 7 | ||||
-rw-r--r-- | src/map/party.c | 18 | ||||
-rw-r--r-- | src/map/party.h | 5 | ||||
-rw-r--r-- | src/map/pc.c | 21 | ||||
-rw-r--r-- | src/map/pc_groups.c | 2 | ||||
-rw-r--r-- | src/map/quest.c | 18 | ||||
-rw-r--r-- | src/map/quest.h | 19 | ||||
-rw-r--r-- | src/map/script.c | 879 | ||||
-rw-r--r-- | src/map/script.h | 10 | ||||
-rw-r--r-- | src/map/skill.c | 65 | ||||
-rw-r--r-- | src/map/status.c | 295 | ||||
-rw-r--r-- | src/map/status.h | 12 | ||||
-rw-r--r-- | src/map/unit.c | 14 |
26 files changed, 863 insertions, 915 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index ffd09caeb..b508c9adb 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -640,7 +640,7 @@ ACMD(who) { StrBuf->Init(&buf); iter = mapit_getallusers(); - for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)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)) @@ -731,7 +731,7 @@ ACMD(whogm) level = pc_get_group_level(sd); iter = mapit_getallusers(); - for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { int pl_level = pc_get_group_level(pl_sd); if (!pl_level) continue; @@ -1563,7 +1563,7 @@ int atcommand_stopattack(struct block_list *bl,va_list ap) *------------------------------------------*/ int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) { - TBL_PC* sd = (TBL_PC*)bl; + struct map_session_data *sd = (struct map_session_data *)bl; nullpo_ret(bl); clif->pvpset(sd, 0, 0, 2); if (sd->pvp_timer != INVALID_TIMER) { @@ -1598,7 +1598,7 @@ ACMD(pvpoff) *------------------------------------------*/ int atcommand_pvpon_sub(struct block_list *bl,va_list ap) { - TBL_PC* sd = (TBL_PC*)bl; + struct map_session_data *sd = (struct map_session_data *)bl; nullpo_ret(bl); if (sd->pvp_timer == INVALID_TIMER) { sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); @@ -2959,10 +2959,8 @@ ACMD(doom) struct s_mapiterator* iter; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) - { - if (pl_sd->fd != fd && pc_get_group_level(sd) >= pc_get_group_level(pl_sd)) - { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)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); clif->message(pl_sd->fd, msg_fd(fd,61)); // The holy messenger has given judgment. @@ -2984,10 +2982,8 @@ ACMD(doommap) struct s_mapiterator* iter; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_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)) - { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)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); clif->message(pl_sd->fd, msg_fd(fd,61)); // The holy messenger has given judgment. @@ -3021,7 +3017,7 @@ ACMD(raise) struct s_mapiterator* iter; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) if( pc_isdead(pl_sd) ) atcommand->raise_sub(pl_sd); mapit->free(iter); @@ -3040,7 +3036,7 @@ ACMD(raisemap) struct s_mapiterator* iter; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) if (sd->bl.m == pl_sd->bl.m && pc_isdead(pl_sd) ) atcommand->raise_sub(pl_sd); mapit->free(iter); @@ -3089,8 +3085,7 @@ ACMD(kickall) struct s_mapiterator* iter; iter = mapit_getallusers(); - for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) - { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)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); @@ -3424,7 +3419,7 @@ ACMD(recallall) count = 0; iter = mapit_getallusers(); - for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)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. @@ -3484,8 +3479,7 @@ ACMD(guildrecall) count = 0; iter = mapit_getallusers(); - for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) - { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)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 @@ -3541,7 +3535,7 @@ ACMD(partyrecall) count = 0; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)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 @@ -3704,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 = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)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); @@ -3780,7 +3774,7 @@ ACMD(mapinfo) { // count chats (for initial message) chat_num = 0; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { if( pl_sd->mapindex == m_index ) { if( pl_sd->state.vending ) vend_num++; @@ -3925,8 +3919,7 @@ ACMD(mapinfo) { case 1: clif->message(fd, msg_fd(fd,1098)); // ----- Players in Map ----- iter = mapit_getallusers(); - for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) - { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)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); @@ -3963,8 +3956,7 @@ ACMD(mapinfo) { case 3: clif->message(fd, msg_fd(fd,1113)); // ----- Chats in Map ----- iter = mapit_getallusers(); - for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) - { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { if ((cd = (struct chat_data*)map->id2bl(pl_sd->chatID)) != NULL && pl_sd->mapindex == m_index && cd->usersd[0] == pl_sd) @@ -4749,7 +4741,7 @@ ACMD(disguiseall) } iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) pc->disguise(pl_sd, mob_id); mapit->free(iter); @@ -4829,7 +4821,7 @@ ACMD(undisguiseall) { struct s_mapiterator* iter; iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) if( pl_sd->disguise != -1 ) pc->disguise(pl_sd, -1); mapit->free(iter); @@ -6536,7 +6528,7 @@ ACMD(refreshall) struct s_mapiterator* iter; iter = mapit_getallusers(); - for (iter_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); iter_sd = (TBL_PC*)mapit->next(iter)) + for (iter_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); iter_sd = (struct map_session_data *)mapit->next(iter)) clif->refresh(iter_sd); mapit->free(iter); return true; @@ -7419,7 +7411,7 @@ ACMD(sizeall) size = cap_value(size,0,2); iter = mapit_getallusers(); - for (pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter)) { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { if (pl_sd->state.size != size) { if (pl_sd->state.size) { pl_sd->state.size = SZ_SMALL; @@ -9822,7 +9814,7 @@ bool atcommand_exec(const int fd, struct map_session_data *sd, const char *messa //Reconstructed message char atcmd_msg[CHAT_SIZE_MAX]; - TBL_PC * ssd = NULL; //sd for target + struct map_session_data *ssd = NULL; //sd for target AtCommandInfo * info; nullpo_retr(false, sd); diff --git a/src/map/battle.c b/src/map/battle.c index 201cd6a00..1eec1f14a 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -234,9 +234,13 @@ int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) { struct block_list* target = map->id2bl(dat->target_id); if( !target || status->isdead(target) ) {/* nothing we can do */ - if( dat->src_type == BL_PC && (src = map->id2bl(dat->src_id)) != NULL && --((TBL_PC*)src)->delayed_damage == 0 && ((TBL_PC*)src)->state.hold_recalc ) { - ((TBL_PC*)src)->state.hold_recalc = 0; - status_calc_pc(((TBL_PC*)src),SCO_FORCE); + if (dat->src_type == BL_PC + && (src = map->id2bl(dat->src_id)) != NULL + && --((struct map_session_data *)src)->delayed_damage == 0 + && ((struct map_session_data *)src)->state.hold_recalc + ) { + ((struct map_session_data *)src)->state.hold_recalc = 0; + status_calc_pc((struct map_session_data *)src, SCO_FORCE); } ers_free(battle->delay_damage_ers, dat); return 0; @@ -249,7 +253,7 @@ int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) { battle_config.fix_warp_hit_delay_abuse ? (dat->skill_id == MO_EXTREMITYFIST || target->m != src->m || check_distance_bl(src, target, dat->distance)) : - ((target->type != BL_PC || ((TBL_PC*)target)->invincible_timer == INVALID_TIMER) + ((target->type != BL_PC || ((struct map_session_data *)target)->invincible_timer == INVALID_TIMER) && (dat->skill_id == MO_EXTREMITYFIST || (target->m == src->m && check_distance_bl(src, target, dat->distance)))) )) { map->freeblock_lock(); @@ -268,9 +272,13 @@ int battle_delay_damage_sub(int tid, int64 tick, int id, intptr_t data) { map->freeblock_unlock(); } - if( src && src->type == BL_PC && --((TBL_PC*)src)->delayed_damage == 0 && ((TBL_PC*)src)->state.hold_recalc ) { - ((TBL_PC*)src)->state.hold_recalc = 0; - status_calc_pc(((TBL_PC*)src),SCO_FORCE); + if (src != NULL + && src->type == BL_PC + && --((struct map_session_data *)src)->delayed_damage == 0 + && ((struct map_session_data*)src)->state.hold_recalc + ) { + ((struct map_session_data *)src)->state.hold_recalc = 0; + status_calc_pc((struct map_session_data *)src, SCO_FORCE); } } ers_free(battle->delay_damage_ers, dat); @@ -318,7 +326,7 @@ int battle_delay_damage(int64 tick, int amotion, struct block_list *src, struct amotion = 1000; //Aegis places a damage-delay cap of 1 sec to non player attacks. [Skotlex] if( src->type == BL_PC ) { - ((TBL_PC*)src)->delayed_damage++; + ((struct map_session_data *)src)->delayed_damage++; } timer->add(tick+amotion, battle->delay_damage_sub, 0, (intptr_t)dat); @@ -532,11 +540,11 @@ int64 battle_calc_base_damage(struct block_list *src, struct block_list *bl, uin s_ele = st->rhw.ele; s_ele_ = st->lhw.ele; if ( src->type == BL_PC ) { - if ( ((TBL_PC*)src)->charm_type != CHARM_TYPE_NONE && ((TBL_PC*)src)->charm_count >= MAX_SPIRITCHARM ) { - s_ele = s_ele_ = ((TBL_PC*)src)->charm_type; + if (((struct map_session_data *)src)->charm_type != CHARM_TYPE_NONE && ((struct map_session_data *)src)->charm_count >= MAX_SPIRITCHARM) { + s_ele = s_ele_ = ((struct map_session_data*)src)->charm_type; } - if ( flag & 2 && ((TBL_PC*)src)->bonus.arrow_ele ) - s_ele = ((TBL_PC*)src)->bonus.arrow_ele; + if (flag&2 && ((struct map_session_data *)src)->bonus.arrow_ele) + s_ele = ((struct map_session_data *)src)->bonus.arrow_ele; } } if (src->type == BL_PC) { @@ -2863,7 +2871,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam struct block_list *d_bl = map->id2bl(sce_d->val1); if (d_bl && check_distance_bl(bl, d_bl, sce_d->val3) && ((d_bl->type == BL_MER && ((TBL_MER*)d_bl)->master && ((TBL_MER*)d_bl)->master->bl.id == bl->id) - || (d_bl->type == BL_PC && ((TBL_PC*)d_bl)->devotion[sce_d->val2] == bl->id)) + || (d_bl->type == BL_PC && ((struct map_session_data *)d_bl)->devotion[sce_d->val2] == bl->id)) ) { // if player is target of devotion, show guard effect on the devotion caster rather than the target clif->skill_nodamage(d_bl, d_bl, CR_AUTOGUARD, sce->val1, 1); @@ -3123,7 +3131,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if( (sce = sc->data[SC_STONEHARDSKIN]) && flag&(BF_SHORT|BF_WEAPON) && damage > 0 ) { sce->val2 -= (int)cap_value(damage,INT_MIN,INT_MAX); if( src->type == BL_PC ) { - TBL_PC *ssd = BL_CAST(BL_PC, src); + struct map_session_data *ssd = BL_CAST(BL_PC, src); if (ssd && ssd->status.weapon != W_BOW) skill->break_equip(src, EQP_WEAPON, 3000, BCT_SELF); } else @@ -3302,8 +3310,8 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam if (!skill_id || (element = skill->get_ele(skill_id, skill_lv)) == -1) { // Take weapon's element struct status_data *sstatus = NULL; - if (src->type == BL_PC && ((TBL_PC*)src)->bonus.arrow_ele) { - element = ((TBL_PC*)src)->bonus.arrow_ele; + if (src->type == BL_PC && ((struct map_session_data *)src)->bonus.arrow_ele) { + element = ((struct map_session_data *)src)->bonus.arrow_ele; } else if ((sstatus = status->get_status_data(src)) != NULL) { element = sstatus->rhw.ele; } @@ -3371,7 +3379,7 @@ int64 battle_calc_gvg_damage(struct block_list *src,struct block_list *bl,int64 } } if(src->type != BL_MOB) { - struct guild *g = src->type == BL_PC ? ((TBL_PC *)src)->guild : guild->search(status->get_guild_id(src)); + struct guild *g = src->type == BL_PC ? ((struct map_session_data *)src)->guild : guild->search(status->get_guild_id(src)); if (class_ == MOBID_EMPELIUM && (!g || guild->checkskill(g,GD_APPROVAL) <= 0)) return 0; @@ -3420,7 +3428,8 @@ int battle_calc_drain(int64 damage, int rate, int per) { /*========================================== * Consumes ammo for the given skill. *------------------------------------------*/ -void battle_consume_ammo(TBL_PC*sd, int skill_id, int lv) { +void battle_consume_ammo(struct map_session_data *sd, int skill_id, int lv) +{ int qty=1; nullpo_retv(sd); @@ -3499,7 +3508,7 @@ struct Damage battle_calc_magic_attack(struct block_list *src,struct block_list short s_ele = 0; unsigned int skillratio = 100; //Skill dmg modifiers. - TBL_PC *sd; + struct map_session_data *sd = NULL; struct status_change *sc; struct Damage ad; struct status_data *sstatus = status->get_status_data(src); @@ -5596,14 +5605,11 @@ struct Damage battle_calc_weapon_attack(struct block_list *src,struct block_list } } //Reject Sword bugreport:4493 by Daegaladh - if(wd.damage && tsc && tsc->data[SC_SWORDREJECT] && - (src->type!=BL_PC || ( - ((TBL_PC *)src)->weapontype1 == W_DAGGER || - ((TBL_PC *)src)->weapontype1 == W_1HSWORD || - ((TBL_PC *)src)->status.weapon == W_2HSWORD - )) && - rnd()%100 < tsc->data[SC_SWORDREJECT]->val2 - ) { + if (wd.damage != 0 + && tsc != NULL && tsc->data[SC_SWORDREJECT] != NULL + && (sd == NULL || sd->weapontype1 == W_DAGGER || sd->weapontype1 == W_1HSWORD || sd->status.weapon == W_2HSWORD) + && rnd()%100 < tsc->data[SC_SWORDREJECT]->val2 + ) { ATK_RATER(50); status_fix_damage(target,src,wd.damage,clif->damage(target,src,0,0,wd.damage,0,BDT_NORMAL,0)); clif->skill_nodamage(target,target,ST_REJECTSWORD,tsc->data[SC_SWORDREJECT]->val1,1); @@ -5893,7 +5899,7 @@ void battle_reflect_damage(struct block_list *target, struct block_list *src, st #undef NORMALIZE_RDAMAGE } -void battle_drain(TBL_PC *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int boss) +void battle_drain(struct map_session_data *sd, struct block_list *tbl, int64 rdamage, int64 ldamage, int race, int boss) { struct weapon_data *wd; int type, thp = 0, tsp = 0, rhp = 0, rsp = 0, hp, sp, i; @@ -5970,13 +5976,13 @@ int battle_damage_area(struct block_list *bl, va_list ap) { nullpo_ret(src); map->freeblock_lock(); if( src->type == BL_PC ) - battle->drain((TBL_PC*)src, bl, damage, damage, status_get_race(bl), is_boss(bl)); + battle->drain((struct map_session_data *)src, bl, damage, damage, status_get_race(bl), is_boss(bl)); if( amotion ) battle->delay_damage(tick, amotion,src,bl,0,CR_REFLECTSHIELD,0,damage,ATK_DEF,0,true); else status_fix_damage(src,bl,damage,0); clif->damage(bl,bl,amotion,dmotion,damage,1,BDT_ENDURE,0); - if( !(src->type == BL_PC && ((TBL_PC*)src)->state.autocast) ) + if (!(src->type == BL_PC && ((struct map_session_data *)src)->state.autocast)) skill->additional_effect(src, bl, CR_REFLECTSHIELD, 1, BF_WEAPON|BF_SHORT|BF_NORMAL,ATK_DEF,tick); map->freeblock_unlock(); } @@ -6190,19 +6196,20 @@ enum damage_lv battle_weapon_attack(struct block_list* src, struct block_list* t struct status_change_entry *sce = tsc->data[SC_DEVOTION]; struct block_list *d_bl = map->id2bl(sce->val1); - if( d_bl && ( - (d_bl->type == BL_MER && ((TBL_MER*)d_bl)->master && ((TBL_MER*)d_bl)->master->bl.id == target->id) || - (d_bl->type == BL_PC && ((TBL_PC*)d_bl)->devotion[sce->val2] == target->id) - ) && check_distance_bl(target, d_bl, sce->val3) ) - { + if (d_bl != NULL + && ((d_bl->type == BL_MER && ((TBL_MER *)d_bl)->master && ((TBL_MER *)d_bl)->master->bl.id == target->id) + || (d_bl->type == BL_PC && ((struct map_session_data *)d_bl)->devotion[sce->val2] == target->id) + ) + && check_distance_bl(target, d_bl, sce->val3) + ) { clif->damage(d_bl, d_bl, 0, 0, damage, 0, BDT_NORMAL, 0); status_fix_damage(NULL, d_bl, damage, 0); - } - else + } else { status_change_end(target, SC_DEVOTION, INVALID_TIMER); + } } else if( tsc->data[SC_CIRCLE_OF_FIRE_OPTION] && (wd.flag&BF_SHORT) && target->type == BL_PC ) { - struct elemental_data *ed = ((TBL_PC*)target)->ed; - if( ed ) { + struct elemental_data *ed = ((struct map_session_data *)target)->ed; + if (ed != NULL) { clif->skill_damage(&ed->bl, target, tick, status_get_amotion(src), 0, -30000, 1, EL_CIRCLE_OF_FIRE, tsc->data[SC_CIRCLE_OF_FIRE_OPTION]->val1, BDT_SKILL); skill->attack(BF_MAGIC,&ed->bl,&ed->bl,src,EL_CIRCLE_OF_FIRE,tsc->data[SC_CIRCLE_OF_FIRE_OPTION]->val1,tick,wd.flag); } @@ -6438,11 +6445,11 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if ( s_bl->type == BL_PC ) { switch( t_bl->type ) { case BL_MOB: // Source => PC, Target => MOB - if (pc_has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVM) ) + if (pc_has_permission((struct map_session_data *)s_bl, PC_PERM_DISABLE_PVM) ) return 0; break; case BL_PC: - if (pc_has_permission((TBL_PC*)s_bl, PC_PERM_DISABLE_PVP)) + if (pc_has_permission((struct map_session_data *)s_bl, PC_PERM_DISABLE_PVP)) return 0; break; default:/* anything else goes */ @@ -6451,25 +6458,26 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f } switch( target->type ) { // Checks on actual target - case BL_PC: { - struct status_change* sc = status->get_sc(src); - if( ((TBL_PC*)target)->invincible_timer != INVALID_TIMER ) { - switch( battle->get_current_skill(src) ) { - /* TODO a proper distinction should be established bugreport:8397 */ - case PR_SANCTUARY: - case PR_MAGNIFICAT: - break; - default: - return -1; - } - } - if ( pc_isinvisible((TBL_PC*)target) ) - return -1; //Cannot be targeted yet. - if( sc && sc->count ) { - if( sc->data[SC_SIREN] && sc->data[SC_SIREN]->val2 == target->id ) + case BL_PC: + { + struct status_change *sc = status->get_sc(src); + if (((struct map_session_data *)target)->invincible_timer != INVALID_TIMER) { + switch( battle->get_current_skill(src) ) { + /* TODO a proper distinction should be established bugreport:8397 */ + case PR_SANCTUARY: + case PR_MAGNIFICAT: + break; + default: return -1; } } + if (pc_isinvisible((struct map_session_data *)target)) + return -1; //Cannot be targeted yet. + if (sc && sc->count) { + if (sc->data[SC_SIREN] && sc->data[SC_SIREN]->val2 == target->id) + return -1; + } + } break; case BL_MOB: { @@ -6565,7 +6573,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if( sd->state.monster_ignore && flag&BCT_ENEMY ) return 0; // Global immunity only to Attacks - if( sd->status.karma && s_bl->type == BL_PC && ((TBL_PC*)s_bl)->status.karma ) + if (sd->status.karma && s_bl->type == BL_PC && ((struct map_session_data *)s_bl)->status.karma) state |= BCT_ENEMY; // Characters with bad karma may fight amongst them if( sd->state.killable ) { state |= BCT_ENEMY; // Everything can kill it @@ -6629,7 +6637,7 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f } else if( sd->duel_group && !((!battle_config.duel_allow_pvp && map->list[m].flag.pvp) || (!battle_config.duel_allow_gvg && map_flag_gvg(m))) ) { - if( t_bl->type == BL_PC && (sd->duel_group == ((TBL_PC*)t_bl)->duel_group) ) + if (t_bl->type == BL_PC && (sd->duel_group == ((struct map_session_data *)t_bl)->duel_group)) return (BCT_ENEMY&flag)?1:-1; // Duel targets can ONLY be your enemy, nothing else. else if (src->type != BL_SKILL || (flag&BCT_ALL) != BCT_ALL) return 0; @@ -6720,9 +6728,10 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f if( state&BCT_ENEMY && map->list[m].flag.battleground && sbg_id && sbg_id == tbg_id ) state &= ~BCT_ENEMY; - if( state&BCT_ENEMY && battle_config.pk_mode && !map_flag_gvg(m) && s_bl->type == BL_PC && t_bl->type == BL_PC ) - { // Prevent novice engagement on pk_mode (feature by Valaris) - TBL_PC *sd = (TBL_PC*)s_bl, *sd2 = (TBL_PC*)t_bl; + if (state&BCT_ENEMY && battle_config.pk_mode && !map_flag_gvg(m) && s_bl->type == BL_PC && t_bl->type == BL_PC) { + // Prevent novice engagement on pk_mode (feature by Valaris) + struct map_session_data *sd = (struct map_session_data *)s_bl; + struct map_session_data *sd2 = (struct map_session_data *)t_bl; if ( (sd->class_&MAPID_UPPERMASK) == MAPID_NOVICE || (sd2->class_&MAPID_UPPERMASK) == MAPID_NOVICE || diff --git a/src/map/battleground.c b/src/map/battleground.c index b2d6f0faf..05db70604 100644 --- a/src/map/battleground.c +++ b/src/map/battleground.c @@ -220,7 +220,7 @@ int bg_team_get_id(struct block_list *bl) { nullpo_ret(bl); switch( bl->type ) { case BL_PC: - return ((TBL_PC*)bl)->bg_id; + return ((struct map_session_data *)bl)->bg_id; case BL_PET: if( ((TBL_PET*)bl)->msd ) return ((TBL_PET*)bl)->msd->bg_id; @@ -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 = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)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 e9227db73..a39859609 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -163,7 +163,8 @@ bool chrif_auth_delete(int account_id, int char_id, enum sd_state state) { } //Moves the sd character to the auth_db structure. -bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) { +bool chrif_sd_to_auth(struct map_session_data *sd, enum sd_state state) +{ struct auth_node *node; nullpo_retr(false, sd); @@ -191,7 +192,7 @@ bool chrif_sd_to_auth(TBL_PC* sd, enum sd_state state) { return true; } -bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) +bool chrif_auth_logout(struct map_session_data *sd, enum sd_state state) { nullpo_retr(false, sd); if(sd->fd && state == ST_LOGOUT) { //Disassociate player, and free it after saving ack returns. [Skotlex] @@ -204,7 +205,8 @@ bool chrif_auth_logout(TBL_PC* sd, enum sd_state state) return chrif->sd_to_auth(sd, state); } -bool chrif_auth_finished(TBL_PC* sd) { +bool chrif_auth_finished(struct map_session_data *sd) +{ struct auth_node *node; nullpo_retr(false, sd); @@ -593,7 +595,7 @@ void chrif_authok(int fd) { struct mmo_charstatus* charstatus; struct auth_node *node; bool changing_mapservers; - TBL_PC* sd; + struct map_session_data *sd = NULL; //Check if both servers agree on the struct's size if( RFIFOW(fd,2) - 25 != sizeof(struct mmo_charstatus) ) { @@ -1487,7 +1489,7 @@ bool send_users_tochar(void) { WFIFOW(chrif->fd,0) = 0x2aff; iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)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/chrif.h b/src/map/chrif.h index d57d4d42c..6a5ec36b6 100644 --- a/src/map/chrif.h +++ b/src/map/chrif.h @@ -21,9 +21,9 @@ #ifndef MAP_CHRIF_H #define MAP_CHRIF_H -#include "map/map.h" //TBL_PC #include "common/hercules.h" #include "common/db.h" +#include "common/mmo.h" struct eri; struct map_session_data; @@ -129,9 +129,9 @@ struct chrif_interface { bool (*flush) (void); void (*skillid2idx) (int fd); - bool (*sd_to_auth) (TBL_PC* sd, enum sd_state state); + bool (*sd_to_auth) (struct map_session_data *sd, enum sd_state state); int (*check_connect_char_server) (int tid, int64 tick, int id, intptr_t data); - bool (*auth_logout) (TBL_PC* sd, enum sd_state state); + bool (*auth_logout) (struct map_session_data *sd, enum sd_state state); void (*save_ack) (int fd); int (*reconnect) (DBKey key, DBData *data, va_list ap); int (*auth_db_cleanup_sub) (DBKey key, DBData *data, va_list ap); diff --git a/src/map/clif.c b/src/map/clif.c index 053017a4a..8928b447c 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -190,8 +190,9 @@ static inline void RFIFOPOS2(int fd, unsigned short pos, short* x0, short* y0, s #endif // 0 //To identify disguised characters. -static inline bool disguised(struct block_list* bl) { - return (bool)( bl->type == BL_PC && ((TBL_PC*)bl)->disguise != -1 ); +static inline bool disguised(struct block_list* bl) +{ + return (bool)(bl->type == BL_PC && ((struct map_session_data *)bl)->disguise != -1); } //Guarantees that the given string does not exceeds the allowed size, as well as making sure it's null terminated. [Skotlex] @@ -404,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 = (TBL_PC*)mapit->next(iter)) != NULL ) { + while ((tsd = (struct map_session_data *)mapit->next(iter)) != NULL) { WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); WFIFOSET(tsd->fd,len); @@ -414,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 = (TBL_PC*)mapit->next(iter)) != NULL) { + while ((tsd = (struct map_session_data *)mapit->next(iter)) != NULL) { if (bl && bl->m == tsd->bl.m) { WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); @@ -505,7 +506,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target break; iter = mapit_getallusers(); - while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) { + while ((tsd = (struct map_session_data *)mapit->next(iter)) != NULL) { if( tsd->partyspy == p->party.party_id ) { WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); @@ -521,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 = (TBL_PC*)mapit->next(iter)) != NULL ) { + while ((tsd = (struct map_session_data *)mapit->next(iter)) != NULL) { if( type == DUEL_WOS && bl->id == tsd->bl.id ) continue; if( sd->duel_group == tsd->duel_group ) { @@ -584,7 +585,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target break; iter = mapit_getallusers(); - while( (tsd = (TBL_PC*)mapit->next(iter)) != NULL ) { + while ((tsd = (struct map_session_data *)mapit->next(iter)) != NULL) { if( tsd->guildspy == g->guild_id ) { WFIFOHEAD(tsd->fd, len); memcpy(WFIFOP(tsd->fd,0), buf, len); @@ -1422,25 +1423,25 @@ bool clif_spawn(struct block_list *bl) switch (bl->type) { case BL_PC: - { - TBL_PC *sd = ((TBL_PC*)bl); - int i; - if (sd->spiritball > 0) - clif->spiritball(&sd->bl); - if(sd->state.size==SZ_BIG) // tiny/big players [Valaris] - clif->specialeffect(bl,423,AREA); - else if(sd->state.size==SZ_MEDIUM) - clif->specialeffect(bl,421,AREA); - if( sd->bg_id && map->list[sd->bl.m].flag.battleground ) - clif->sendbgemblem_area(sd); - for( i = 0; i < sd->sc_display_count; i++ ) { - clif->sc_load(&sd->bl, sd->bl.id,AREA,status->dbs->IconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3); - } - if (sd->charm_type != CHARM_TYPE_NONE && sd->charm_count > 0) - clif->spiritcharm(sd); - if (sd->status.robe) - clif->refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA); + { + struct map_session_data *sd = ((struct map_session_data *)bl); + int i; + if (sd->spiritball > 0) + clif->spiritball(&sd->bl); + if (sd->state.size == SZ_BIG) // tiny/big players [Valaris] + clif->specialeffect(bl,423,AREA); + else if (sd->state.size == SZ_MEDIUM) + clif->specialeffect(bl,421,AREA); + if (sd->bg_id != 0 && map->list[sd->bl.m].flag.battleground) + clif->sendbgemblem_area(sd); + for (i = 0; i < sd->sc_display_count; i++) { + clif->sc_load(&sd->bl, sd->bl.id,AREA,status->dbs->IconChangeTable[sd->sc_display[i]->type],sd->sc_display[i]->val1,sd->sc_display[i]->val2,sd->sc_display[i]->val3); } + if (sd->charm_type != CHARM_TYPE_NONE && sd->charm_count > 0) + clif->spiritcharm(sd); + if (sd->status.robe) + clif->refreshlook(bl,bl->id,LOOK_ROBE,sd->status.robe,AREA); + } break; case BL_MOB: { @@ -1688,14 +1689,14 @@ void clif_move2(struct block_list *bl, struct view_data *vd, struct unit_data *u switch(bl->type) { case BL_PC: - { - TBL_PC *sd = ((TBL_PC*)bl); - //clif_movepc(sd); - if(sd->state.size==SZ_BIG) // tiny/big players [Valaris] - clif->specialeffect(&sd->bl,423,AREA); - else if(sd->state.size==SZ_MEDIUM) - clif->specialeffect(&sd->bl,421,AREA); - } + { + struct map_session_data *sd = ((struct map_session_data *)bl); + //clif_movepc(sd); + if(sd->state.size==SZ_BIG) // tiny/big players [Valaris] + clif->specialeffect(&sd->bl,423,AREA); + else if(sd->state.size==SZ_MEDIUM) + clif->specialeffect(&sd->bl,421,AREA); + } break; case BL_MOB: { @@ -2774,7 +2775,7 @@ int clif_hpmeter_sub(struct block_list *bl, va_list ap) { #endif sd = va_arg(ap, struct map_session_data *); - tsd = (TBL_PC *)bl; + tsd = (struct map_session_data *)bl; nullpo_ret(sd); nullpo_ret(tsd); @@ -4182,18 +4183,18 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { switch (bl->type) { case BL_PC: - { - TBL_PC* tsd = (TBL_PC*)bl; - clif->getareachar_pc(sd, tsd); - if(tsd->state.size==SZ_BIG) // tiny/big players [Valaris] - clif->specialeffect_single(bl,423,sd->fd); - else if(tsd->state.size==SZ_MEDIUM) - clif->specialeffect_single(bl,421,sd->fd); - if( tsd->bg_id && map->list[tsd->bl.m].flag.battleground ) - clif->sendbgemblem_single(sd->fd,tsd); - if ( tsd->status.robe ) - clif->refreshlook(&sd->bl,bl->id,LOOK_ROBE,tsd->status.robe,SELF); - } + { + struct map_session_data *tsd = (struct map_session_data *)bl; + clif->getareachar_pc(sd, tsd); + if (tsd->state.size == SZ_BIG) // tiny/big players [Valaris] + clif->specialeffect_single(bl,423,sd->fd); + else if (tsd->state.size == SZ_MEDIUM) + clif->specialeffect_single(bl,421,sd->fd); + if (tsd->bg_id != 0 && map->list[tsd->bl.m].flag.battleground) + clif->sendbgemblem_single(sd->fd,tsd); + if (tsd->status.robe) + clif->refreshlook(&sd->bl,bl->id,LOOK_ROBE,tsd->status.robe,SELF); + } break; case BL_MER: // Devotion Effects if( ((TBL_MER*)bl)->devotion_flag ) @@ -4523,7 +4524,7 @@ void clif_getareachar_skillunit(struct block_list *bl, struct skill_unit *su, en clif->send(&p,sizeof(p),bl,target); if(su->group->skill_id == WZ_ICEWALL) - clif->changemapcell(bl->type == BL_PC ? ((TBL_PC*)bl)->fd : 0,su->bl.m,su->bl.x,su->bl.y,5,SELF); + clif->changemapcell(bl->type == BL_PC ? ((struct map_session_data *)bl)->fd : 0, su->bl.m, su->bl.x, su->bl.y, 5, SELF); } /*========================================== @@ -4603,7 +4604,7 @@ int clif_outsight(struct block_list *bl,va_list ap) { struct block_list *tbl; struct view_data *vd; - TBL_PC *sd, *tsd; + struct map_session_data *sd, *tsd; tbl=va_arg(ap,struct block_list*); if(bl == tbl) return 0; // bl can be null pointer? and after if BL_PC, sd will be null pointer too @@ -4660,7 +4661,7 @@ int clif_outsight(struct block_list *bl,va_list ap) int clif_insight(struct block_list *bl,va_list ap) { struct block_list *tbl; - TBL_PC *sd, *tsd; + struct map_session_data *sd, *tsd; tbl=va_arg(ap,struct block_list*); if (bl == tbl) return 0; @@ -5669,11 +5670,12 @@ void clif_resurrection(struct block_list *bl,int type) clif->send(buf,packet_len(0x148),bl, type == 1 ? AREA : AREA_WOS); if (disguised(bl)) { - if( ((TBL_PC*)bl)->fontcolor ) { + if (((struct map_session_data *)bl)->fontcolor) { WBUFL(buf,2)=-bl->id; clif->send(buf,packet_len(0x148),bl, SELF); - } else + } else { clif->spawn(bl); + } } } @@ -7013,7 +7015,7 @@ void clif_devotion(struct block_list *src, struct map_session_data *tsd) *------------------------------------------*/ void clif_spiritball(struct block_list *bl) { unsigned char buf[16]; - TBL_PC *sd = BL_CAST(BL_PC,bl); + struct map_session_data *sd = BL_CAST(BL_PC,bl); TBL_HOM *hd = BL_CAST(BL_HOM,bl); nullpo_retv(bl); @@ -8468,9 +8470,9 @@ void clif_charnameack (int fd, struct block_list *bl) } // if no recipient specified just update nearby clients - if (fd == 0) + if (fd == 0) { clif->send(buf, packet_len(cmd), bl, AREA); - else { + } else { WFIFOHEAD(fd, packet_len(cmd)); memcpy(WFIFOP(fd, 0), buf, packet_len(cmd)); WFIFOSET(fd, packet_len(cmd)); @@ -9087,7 +9089,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) { return; } - CREATE(sd, TBL_PC, 1); + CREATE(sd, struct map_session_data, 1); sd->fd = fd; sd->cryptKey = (( ((( clif->cryptKey[0] * clif->cryptKey[1] ) + clif->cryptKey[2]) & 0xFFFFFFFF) @@ -9890,7 +9892,7 @@ void clif_changed_dir(struct block_list *bl, enum send_target target) nullpo_retv(bl); WBUFW(buf,0) = 0x9c; WBUFL(buf,2) = bl->id; - WBUFW(buf,6) = bl->type==BL_PC?((TBL_PC*)bl)->head_dir:0; + WBUFW(buf,6) = bl->type == BL_PC ? ((struct map_session_data *)bl)->head_dir : 0; WBUFB(buf,8) = unit->getdir(bl); clif->send(buf, packet_len(0x9c), bl, target); @@ -17604,7 +17606,7 @@ void clif_status_change_end(struct block_list *bl, int tid, enum send_target tar nullpo_retv(bl); - if( bl->type == BL_PC && !((TBL_PC*)bl)->state.active ) + if (bl->type == BL_PC && !((struct map_session_data *)bl)->state.active) return; p.PacketType = status_change_endType; @@ -18638,7 +18640,7 @@ unsigned short clif_parse_cmd_optional( int fd, struct map_session_data *sd ) { *------------------------------------------*/ int clif_parse(int fd) { int cmd, packet_len; - TBL_PC* sd; + struct map_session_data *sd; int pnum; //TODO apply delays or disconnect based on packet throughput [FlavioJS] @@ -18648,7 +18650,7 @@ int clif_parse(int fd) { unsigned short (*parse_cmd_func)(int fd, struct map_session_data *sd); // begin main client packet processing loop - sd = (TBL_PC *)sockt->session[fd]->session_data; + sd = (struct map_session_data *)sockt->session[fd]->session_data; if (sockt->session[fd]->flag.eof) { if (sd) { diff --git a/src/map/guild.c b/src/map/guild.c index 10511067a..0dd4c876b 100644 --- a/src/map/guild.c +++ b/src/map/guild.c @@ -57,8 +57,9 @@ struct guild_interface *guild; /*========================================== * Retrieves and validates the sd pointer for this guild member [Skotlex] *------------------------------------------*/ -TBL_PC* guild_sd_check(int guild_id, int account_id, int char_id) { - TBL_PC* sd = map->id2sd(account_id); +struct map_session_data *guild_sd_check(int guild_id, int account_id, int char_id) +{ + struct map_session_data *sd = map->id2sd(account_id); if (!(sd && sd->status.char_id == char_id)) return NULL; @@ -441,8 +442,7 @@ int guild_check_member(struct guild *g) nullpo_ret(g); iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) - { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)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 = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)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 = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { if (!sd->status.guild_id) continue; // Not interested in guildless users @@ -939,14 +939,14 @@ int guild_member_withdraw(int guild_id, int account_id, int char_id, int flag, c void guild_retrieveitembound(int char_id,int aid,int guild_id) { #ifdef GP_BOUND_ITEMS - TBL_PC *sd = map->charid2sd(char_id); - if(sd){ //Character is online + struct map_session_data *sd = map->charid2sd(char_id); + if (sd != NULL) { //Character is online pc->bound_clear(sd,IBT_GUILD); } else { //Character is offline, ask char server to do the job 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 = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { if(sd->status.guild_id == guild_id && sd->state.storage_flag == STORAGE_FLAG_GUILD) { gstorage->close(sd); break; @@ -1328,7 +1328,7 @@ int guild_getexp(struct map_session_data *sd,int exp) /*==================================================== * Ask to increase guildskill skill_id *---------------------------------------------------*/ -int guild_skillup(TBL_PC* sd, uint16 skill_id) +int guild_skillup(struct map_session_data *sd, uint16 skill_id) { struct guild* g; int idx = skill_id - GD_SKILLBASE; diff --git a/src/map/guild.h b/src/map/guild.h index 4b6e860d8..10749f8ad 100644 --- a/src/map/guild.h +++ b/src/map/guild.h @@ -21,11 +21,13 @@ #ifndef MAP_GUILD_H #define MAP_GUILD_H -#include "map/map.h" // EVENT_NAME_LENGTH, TBL_PC +#include "map/map.h" // EVENT_NAME_LENGTH #include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" +struct map_session_data; + /** * Defines **/ @@ -161,7 +163,7 @@ struct guild_interface { void (*retrieveitembound) (int char_id,int aid,int guild_id); /* */ int (*payexp_timer) (int tid, int64 tick, int id, intptr_t data); - TBL_PC* (*sd_check) (int guild_id, int account_id, int char_id); + struct map_session_data *(*sd_check) (int guild_id, int account_id, int char_id); bool (*read_guildskill_tree_db) (char* split[], int columns, int current); bool (*read_castledb) (char* str[], int columns, int current); int (*payexp_timer_sub) (DBKey key, DBData *data, va_list ap); diff --git a/src/map/homunculus.c b/src/map/homunculus.c index d81eeb2da..8ba8ba93b 100644 --- a/src/map/homunculus.c +++ b/src/map/homunculus.c @@ -580,7 +580,7 @@ void homunculus_healed (struct homun_data *hd) { void homunculus_save(struct homun_data *hd) { // copy data that must be saved in homunculus struct ( hp / sp ) - TBL_PC * sd; + struct map_session_data *sd = NULL; //Do not check for max_hp/max_sp caps as current could be higher to max due //to status changes/skills (they will be capped as needed upon stat //calculation on login) diff --git a/src/map/instance.c b/src/map/instance.c index ff6f8bdab..e3f381254 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 = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)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/intif.c b/src/map/intif.c index 016b4f7d3..ed5078088 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1496,7 +1496,8 @@ QUESTLOG SYSTEM FUNCTIONS * * @param sd Character's data */ -void intif_request_questlog(TBL_PC *sd) { +void intif_request_questlog(struct map_session_data *sd) +{ nullpo_retv(sd); WFIFOHEAD(inter_fd,6); WFIFOW(inter_fd,0) = 0x3060; @@ -1513,7 +1514,7 @@ void intif_request_questlog(TBL_PC *sd) { */ void intif_parse_QuestLog(int fd) { int char_id = RFIFOL(fd, 4), num_received = (RFIFOW(fd, 2)-8)/sizeof(struct quest); - TBL_PC *sd = map->charid2sd(char_id); + struct map_session_data *sd = map->charid2sd(char_id); if (!sd) // User not online anymore return; @@ -1568,7 +1569,7 @@ void intif_parse_QuestLog(int fd) { */ void intif_parse_QuestSave(int fd) { int cid = RFIFOL(fd, 2); - TBL_PC *sd = map->id2sd(cid); + struct map_session_data *sd = map->id2sd(cid); if( !RFIFOB(fd, 6) ) ShowError("intif_parse_QuestSave: Failed to save quest(s) for character %d!\n", cid); @@ -1582,7 +1583,8 @@ void intif_parse_QuestSave(int fd) { * @param sd Character's data * @return 0 in case of success, nonzero otherwise */ -int intif_quest_save(TBL_PC *sd) { +int intif_quest_save(struct map_session_data *sd) +{ int len = sizeof(struct quest)*sd->num_quests + 8; if(intif->CheckForCharServer()) diff --git a/src/map/map.c b/src/map/map.c index dcbc3f6f5..dd6996af2 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -350,12 +350,13 @@ int map_moveblock(struct block_list *bl, int x1, int y1, int64 tick) { skill->unit_move(bl,tick,3); - if( bl->type == BL_PC && ((TBL_PC*)bl)->shadowform_id ) {//Shadow Form Target Moving + if (bl->type == BL_PC && ((struct map_session_data *)bl)->shadowform_id != 0) { + //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(((struct map_session_data *)bl)->shadowform_id)) == NULL || !check_distance_bl(bl,d_bl,10)) { if( d_bl ) status_change_end(d_bl,SC__SHADOWFORM,INVALID_TIMER); - ((TBL_PC*)bl)->shadowform_id = 0; + ((struct map_session_data *)bl)->shadowform_id = 0; } } @@ -391,7 +392,7 @@ int map_moveblock(struct block_list *bl, int x1, int y1, int64 tick) { } } /* Guild Aura Moving */ - if( bl->type == BL_PC && ((TBL_PC*)bl)->state.gmaster_flag ) { + if (bl->type == BL_PC && ((struct map_session_data *)bl)->state.gmaster_flag) { if (sc->data[SC_LEADERSHIP]) skill->unit_move_unit_group(skill->id2group(sc->data[SC_LEADERSHIP]->val4), bl->m, x1-x0, y1-y0); if (sc->data[SC_GLORYWOUNDS]) @@ -1738,9 +1739,8 @@ void map_addiddb(struct block_list *bl) { nullpo_retv(bl); - if( bl->type == BL_PC ) - { - TBL_PC* sd = (TBL_PC*)bl; + if (bl->type == BL_PC) { + struct map_session_data *sd = (struct map_session_data *)bl; idb_put(map->pc_db,sd->bl.id,sd); idb_put(map->charid_db,sd->status.char_id,sd); } @@ -1766,14 +1766,11 @@ void map_deliddb(struct block_list *bl) { nullpo_retv(bl); - if( bl->type == BL_PC ) - { - TBL_PC* sd = (TBL_PC*)bl; + if (bl->type == BL_PC) { + struct map_session_data *sd = (struct map_session_data *)bl; idb_remove(map->pc_db,sd->bl.id); idb_remove(map->charid_db,sd->status.char_id); - } - else if( bl->type == BL_MOB ) - { + } else if (bl->type == BL_MOB) { idb_remove(map->mobid_db,bl->id); idb_remove(map->bossid_db,bl->id); } @@ -1982,8 +1979,7 @@ struct map_session_data * map_nick2sd(const char *nick) iter = mapit_getallusers(); found_sd = NULL; - for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) - { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { if( battle_config.partial_name_scan ) {// partial name search if( strnicmp(sd->status.name, nick, nicklen) == 0 ) @@ -5384,7 +5380,7 @@ int do_final(void) { //Ladies and babies first. iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) map->quit(sd); mapit->free(iter); @@ -5528,7 +5524,7 @@ void do_shutdown(void) { struct 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) ) + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) clif->GM_kick(NULL, sd); mapit->free(iter); sockt->flush_fifos(); diff --git a/src/map/mob.c b/src/map/mob.c index 16b5417b9..76fc44c87 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1073,8 +1073,8 @@ int mob_ai_sub_hard_activesearch(struct block_list *bl,va_list ap) switch (bl->type) { case BL_PC: - if (((TBL_PC*)bl)->state.gangsterparadise && - !(status_get_mode(&md->bl)&MD_BOSS)) + if (((struct map_session_data *)bl)->state.gangsterparadise + && !(status_get_mode(&md->bl)&MD_BOSS)) return 0; //Gangster paradise protection. default: if (battle_config.hom_setting&0x4 && @@ -1444,9 +1444,9 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) { if (!tbl || tbl->m != md->bl.m || (md->ud.attacktimer == INVALID_TIMER && !status->check_skilluse(&md->bl, tbl, 0, 0)) || (md->ud.walktimer != INVALID_TIMER && !(battle_config.mob_ai&0x1) && !check_distance_bl(&md->bl, tbl, md->min_chase)) - || ( tbl->type == BL_PC - && ((((TBL_PC*)tbl)->state.gangsterparadise && !(mode&MD_BOSS)) - || ((TBL_PC*)tbl)->invincible_timer != INVALID_TIMER) + || (tbl->type == BL_PC + && ((((struct map_session_data *)tbl)->state.gangsterparadise && !(mode&MD_BOSS)) + || ((struct map_session_data *)tbl)->invincible_timer != INVALID_TIMER) ) ) { //No valid target @@ -1847,7 +1847,7 @@ int mob_delay_item_drop(int tid, int64 tick, int id, intptr_t data) { *------------------------------------------*/ void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, struct item_drop *ditem, int loot, int drop_rate, unsigned short flag) { - TBL_PC* sd; + struct map_session_data *sd = NULL; //Logs items, dropped by mobs [Lupus] logs->pick_mob(md, loot?LOG_TYPE_LOOT:LOG_TYPE_PICKDROP_MONSTER, -ditem->item_data.amount, &ditem->item_data, NULL); @@ -1945,7 +1945,7 @@ void mob_log_damage(struct mob_data *md, struct block_list *src, int damage) { case BL_PC: { - struct map_session_data *sd = (TBL_PC*)src; + struct map_session_data *sd = (struct map_session_data *)src; char_id = sd->status.char_id; if( damage ) md->attacked_id = src->id; diff --git a/src/map/npc.c b/src/map/npc.c index a7d4cdab0..c4ed896a9 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -212,9 +212,8 @@ int npc_enable_sub(struct block_list *bl, va_list ap) nullpo_ret(bl); nullpo_ret(nd=va_arg(ap,struct npc_data *)); - if(bl->type == BL_PC) - { - TBL_PC *sd = (TBL_PC*)bl; + if (bl->type == BL_PC) { + struct map_session_data *sd = (struct map_session_data *)bl; if (nd->option&OPTION_INVISIBLE) return 1; @@ -2296,7 +2295,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 = ((TBL_PC*)bl); + struct map_session_data *sd = (struct map_session_data *)bl; if( sd && sd->npc_timer_id != INVALID_TIMER ) { const struct TimerData *td = timer->get(sd->npc_timer_id); diff --git a/src/map/party.c b/src/map/party.c index 1b5989f41..a1f315c54 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -96,8 +96,9 @@ struct map_session_data* party_getavailablesd(struct party_data *p) /*========================================== * Retrieves and validates the sd pointer for this party member [Skotlex] *------------------------------------------*/ -TBL_PC* party_sd_check(int party_id, int account_id, int char_id) { - TBL_PC* sd = map->id2sd(account_id); +struct map_session_data *party_sd_check(int party_id, int account_id, int char_id) +{ + struct map_session_data *sd = map->id2sd(account_id); if (!(sd && sd->status.char_id == char_id)) return NULL; @@ -973,16 +974,16 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b //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, struct map_session_data* sd, struct item* item_data, int first_charid) { - TBL_PC* target = NULL; + struct map_session_data *target = NULL; int i; if (p && p->party.item&2 && (first_charid || !(battle_config.party_share_type&1))) { //item distribution to party members. if (battle_config.party_share_type&2) { //Round Robin - TBL_PC* psd; i = p->itemc; do { + struct map_session_data *psd; i++; if (i >= MAX_PARTY) i = 0; // reset counter to 1st person in party so it'll stop when it reaches "itemc" @@ -1000,7 +1001,7 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i } while (i != p->itemc); } else { //Random pick - TBL_PC* psd[MAX_PARTY]; + struct map_session_data *psd[MAX_PARTY]; int count = 0; //Collect pick candidates for (i = 0; i < MAX_PARTY; i++) { @@ -1048,7 +1049,7 @@ int party_send_dot_remove(struct map_session_data *sd) // party_foreachsamemap(party->sub_count, sd, 0, &c); int party_sub_count(struct block_list *bl, va_list ap) { - struct map_session_data *sd = (TBL_PC *)bl; + struct map_session_data *sd = (struct map_session_data *)bl; if (sd->state.autotrade) return 0; @@ -1109,8 +1110,9 @@ int party_vforeachsamemap(int (*func)(struct block_list*,va_list), struct map_se } // Special check for Minstrel's and Wanderer's chorus skills. -int party_sub_count_chorus(struct block_list *bl, va_list ap) { - struct map_session_data *sd = (TBL_PC *)bl; +int party_sub_count_chorus(struct block_list *bl, va_list ap) +{ + struct map_session_data *sd = (struct map_session_data *)bl; if (sd->state.autotrade) return 0; diff --git a/src/map/party.h b/src/map/party.h index eb3442b92..828916b88 100644 --- a/src/map/party.h +++ b/src/map/party.h @@ -21,7 +21,6 @@ #ifndef MAP_PARTY_H #define MAP_PARTY_H -#include "map/map.h" // TBL_PC #include "common/hercules.h" #include "common/db.h" #include "common/mmo.h" // struct party @@ -31,7 +30,9 @@ #define PARTY_BOOKING_JOBS 6 #define PARTY_BOOKING_RESULTS 10 +struct block_list; struct hplugin_data_store; +struct map_session_data; struct party_member_data { struct map_session_data *sd; @@ -141,7 +142,7 @@ struct party_interface { int (*foreachsamemap) (int (*func)(struct block_list *,va_list),struct map_session_data *sd,int range,...); int (*send_xy_timer) (int tid, int64 tick, int id, intptr_t data); void (*fill_member) (struct party_member* member, struct map_session_data* sd, unsigned int leader); - TBL_PC* (*sd_check) (int party_id, int account_id, int char_id); + struct map_session_data *(*sd_check) (int party_id, int account_id, int char_id); void (*check_state) (struct party_data *p); struct party_booking_ad_info* (*create_booking_data) (void); int (*db_final) (DBKey key, DBData *data, va_list ap); diff --git a/src/map/pc.c b/src/map/pc.c index b6b6787e9..880acd654 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -3976,7 +3976,7 @@ int pc_bonus5(struct map_session_data *sd,int type,int type2,int type3,int type4 * Grants a player a given skill. * Flag values: @see enum pc_skill_flag *------------------------------------------*/ -int pc_skill(TBL_PC* sd, int id, int level, int flag) +int pc_skill(struct map_session_data *sd, int id, int level, int flag) { uint16 index = 0; nullpo_ret(sd); @@ -8778,7 +8778,7 @@ int pc_setcart(struct map_session_data *sd,int type) { * @param sd Target player. * @param flag New state. **/ -void pc_setfalcon(TBL_PC* sd, bool flag) +void pc_setfalcon(struct map_session_data *sd, bool flag) { if (flag) { if (pc->checkskill(sd,HT_FALCON) > 0) // add falcon if he have the skill @@ -8796,7 +8796,7 @@ void pc_setfalcon(TBL_PC* sd, bool flag) * @param sd Target player. * @param flag New state. **/ -void pc_setridingpeco(TBL_PC* sd, bool flag) +void pc_setridingpeco(struct map_session_data *sd, bool flag) { if (flag) { if (pc->checkskill(sd, KN_RIDING)) @@ -8832,7 +8832,7 @@ void pc_setmadogear(struct map_session_data *sd, bool flag) * @param sd Target player. * @param type New state. This must be a valid OPTION_DRAGON* or 0. **/ -void pc_setridingdragon(TBL_PC* sd, unsigned int type) +void pc_setridingdragon(struct map_session_data *sd, unsigned int type) { if (type&OPTION_DRAGON) { // Ensure only one dragon is set at a time. @@ -8864,7 +8864,7 @@ void pc_setridingdragon(TBL_PC* sd, unsigned int type) * @param sd Target player. * @param flag New state. **/ -void pc_setridingwug(TBL_PC* sd, bool flag) +void pc_setridingwug(struct map_session_data *sd, bool flag) { if (flag) { if (pc->checkskill(sd, RA_WUGRIDER) > 0) @@ -10259,8 +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 = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) - { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { if(sd->bl.id == last_save_id && save_flag != 1) { save_flag = 1; continue; @@ -10814,7 +10813,7 @@ void pc_read_skill_tree(void) /* lets update all players skill tree */ iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) clif->skillinfoblock(sd); mapit->free(iter); } @@ -11197,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 = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { if( sd->expiration_time ) pc->expire_check(sd); } @@ -11243,7 +11242,7 @@ void pc_autotrade_load(void) SQL->GetData(map->mysql_handle, 2, &data, NULL); sex = atoi(data); SQL->GetData(map->mysql_handle, 3, &data, NULL); safestrncpy(title, data, sizeof(title)); - CREATE(sd, TBL_PC, 1); + CREATE(sd, struct map_session_data, 1); pc->setnewpc(sd, account_id, char_id, 0, 0, sex, 0); @@ -11389,7 +11388,7 @@ void pc_autotrade_prepare(struct map_session_data *sd) { map->quit(sd); chrif->auth_delete(account_id, char_id, ST_LOGOUT); - CREATE(sd, TBL_PC, 1); + CREATE(sd, struct map_session_data, 1); pc->setnewpc(sd, account_id, char_id, 0, 0, sex, 0); diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c index 675a8b62e..cfb28cbd5 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 = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter)) { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)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/quest.c b/src/map/quest.c index 9a6200138..bec358187 100644 --- a/src/map/quest.c +++ b/src/map/quest.c @@ -75,7 +75,7 @@ struct quest_db *quest_db(int quest_id) { * @param sd Player's data * @return 0 in case of success, nonzero otherwise (i.e. the player has no quests) */ -int quest_pc_login(TBL_PC *sd) +int quest_pc_login(struct map_session_data *sd) { #if PACKETVER < 20141022 int i; @@ -106,7 +106,8 @@ int quest_pc_login(TBL_PC *sd) * @param quest_id ID of the quest to add. * @return 0 in case of success, nonzero otherwise */ -int quest_add(TBL_PC *sd, int quest_id) { +int quest_add(struct map_session_data *sd, int quest_id) +{ int n; struct quest_db *qi = quest->db(quest_id); @@ -157,7 +158,8 @@ int quest_add(TBL_PC *sd, int quest_id) { * @param qid2 New quest to add * @return 0 in case of success, nonzero otherwise */ -int quest_change(TBL_PC *sd, int qid1, int qid2) { +int quest_change(struct map_session_data *sd, int qid1, int qid2) +{ int i; struct quest_db *qi = quest->db(qid2); @@ -207,7 +209,8 @@ int quest_change(TBL_PC *sd, int qid1, int qid2) { * @param quest_id ID of the quest to remove * @return 0 in case of success, nonzero otherwise */ -int quest_delete(TBL_PC *sd, int quest_id) { +int quest_delete(struct map_session_data *sd, int quest_id) +{ int i; //Search for quest @@ -276,7 +279,7 @@ int quest_update_objective_sub(struct block_list *bl, va_list ap) { * @param sd Character's data * @param mob_id Monster ID */ -void quest_update_objective(TBL_PC *sd, int mob_id) +void quest_update_objective(struct map_session_data *sd, int mob_id) { int i,j; @@ -331,7 +334,8 @@ void quest_update_objective(TBL_PC *sd, int mob_id) * @param qs New quest state * @return 0 in case of success, nonzero otherwise */ -int quest_update_status(TBL_PC *sd, int quest_id, enum quest_state qs) { +int quest_update_status(struct map_session_data *sd, int quest_id, enum quest_state qs) +{ int i; ARR_FIND(0, sd->avail_quests, i, sd->quest_log[i].quest_id == quest_id); @@ -380,7 +384,7 @@ int quest_update_status(TBL_PC *sd, int quest_id, enum quest_state qs) { * 1 if the quest's timeout has expired * 0 otherwise */ -int quest_check(TBL_PC *sd, int quest_id, enum quest_check_type type) +int quest_check(struct map_session_data *sd, int quest_id, enum quest_check_type type) { int i; diff --git a/src/map/quest.h b/src/map/quest.h index 567f0692a..8e2cb4e23 100644 --- a/src/map/quest.h +++ b/src/map/quest.h @@ -21,9 +21,12 @@ #ifndef MAP_QUEST_H #define MAP_QUEST_H -#include "map/map.h" // TBL_PC #include "common/hercules.h" #include "common/conf.h" +#include "common/mmo.h" // enum quest_state + +struct block_list; +struct map_session_data; #define MAX_QUEST_DB (60355+1) // Highest quest ID + 1 @@ -64,14 +67,14 @@ struct quest_interface { void (*reload) (void); /* */ struct quest_db *(*db) (int quest_id); - int (*pc_login) (TBL_PC *sd); - int (*add) (TBL_PC *sd, int quest_id); - int (*change) (TBL_PC *sd, int qid1, int qid2); - int (*delete) (TBL_PC *sd, int quest_id); + int (*pc_login) (struct map_session_data *sd); + int (*add) (struct map_session_data *sd, int quest_id); + int (*change) (struct map_session_data *sd, int qid1, int qid2); + int (*delete) (struct map_session_data *sd, int quest_id); int (*update_objective_sub) (struct block_list *bl, va_list ap); - void (*update_objective) (TBL_PC *sd, int mob_id); - int (*update_status) (TBL_PC *sd, int quest_id, enum quest_state qs); - int (*check) (TBL_PC *sd, int quest_id, enum quest_check_type type); + void (*update_objective) (struct map_session_data *sd, int mob_id); + int (*update_status) (struct map_session_data *sd, int quest_id, enum quest_state qs); + int (*check) (struct map_session_data *sd, int quest_id, enum quest_check_type type); void (*clear) (void); int (*read_db) (void); struct quest_db *(*read_db_sub) (config_setting_t *cs, int n, const char *source); diff --git a/src/map/script.c b/src/map/script.c index 1e19cb85b..28ad217df 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2633,8 +2633,9 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o /// Returns the player attached to this script, identified by the rid. /// If there is no player attached, the script is terminated. -TBL_PC *script_rid2sd(struct script_state *st) { - TBL_PC *sd; +struct map_session_data *script_rid2sd(struct script_state *st) +{ + struct map_session_data *sd; if( !( sd = map->id2sd(st->rid) ) ) { ShowError("script_rid2sd: fatal error ! player not attached!\n"); script->reportfunc(st); @@ -2644,8 +2645,9 @@ TBL_PC *script_rid2sd(struct script_state *st) { return sd; } -TBL_PC *script_id2sd(struct script_state *st, int account_id) { - TBL_PC *sd; +struct map_session_data *script_id2sd(struct script_state *st, int account_id) +{ + struct map_session_data *sd; if ((sd = map->id2sd(account_id)) == NULL) { ShowWarning("script_id2sd: Player with account ID '%d' not found!\n", account_id); script->reportfunc(st); @@ -2654,8 +2656,9 @@ TBL_PC *script_id2sd(struct script_state *st, int account_id) { return sd; } -TBL_PC *script_charid2sd(struct script_state *st, int char_id) { - TBL_PC *sd; +struct map_session_data *script_charid2sd(struct script_state *st, int char_id) +{ + struct map_session_data *sd; if ((sd = map->charid2sd(char_id)) == NULL) { ShowWarning("script_charid2sd: Player with char ID '%d' not found!\n", char_id); script->reportfunc(st); @@ -2664,8 +2667,9 @@ TBL_PC *script_charid2sd(struct script_state *st, int char_id) { return sd; } -TBL_PC *script_nick2sd(struct script_state *st, const char *name) { - TBL_PC *sd; +struct map_session_data *script_nick2sd(struct script_state *st, const char *name) +{ + struct map_session_data *sd; if ((sd = map->nick2sd(name)) == NULL) { ShowWarning("script_nick2sd: Player name '%s' not found!\n", name); script->reportfunc(st); @@ -2717,7 +2721,7 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) { const char* name; char prefix; char postfix; - TBL_PC* sd = NULL; + struct map_session_data *sd = NULL; if( !data_isreference(data) ) return data;// not a variable/constant @@ -3146,7 +3150,8 @@ void set_reg_instance_num(struct script_state* st, int64 num, const char* name, * * TODO: return values are screwed up, have been for some time (reaad: years), e.g. some functions return 1 failure and success. *------------------------------------------*/ -int set_reg(struct script_state* st, TBL_PC* sd, int64 num, const char* name, const void* value, struct reg_db *ref) { +int set_reg(struct script_state *st, struct map_session_data *sd, int64 num, const char *name, const void *value, struct reg_db *ref) +{ char prefix = name[0]; if (strlen(name) > SCRIPT_VARNAME_LENGTH) { @@ -3231,11 +3236,13 @@ int set_reg(struct script_state* st, TBL_PC* sd, int64 num, const char* name, co } } -int set_var(TBL_PC* sd, char* name, void* val) { +int set_var(struct map_session_data *sd, char *name, void *val) +{ return script->set_reg(NULL, sd, reference_uid(script->add_str(name),0), name, val, NULL); } -void setd_sub(struct script_state *st, TBL_PC *sd, const char *varname, int elem, void *value, struct reg_db *ref) { +void setd_sub(struct script_state *st, struct map_session_data *sd, const char *varname, int elem, void *value, struct reg_db *ref) +{ script->set_reg(st, sd, reference_uid(script->add_str(varname),elem), varname, value, ref); } @@ -4156,7 +4163,7 @@ void script_stop_instances(struct script_code *code) { int run_script_timer(int tid, int64 tick, int id, intptr_t data) { struct script_state *st = idb_get(script->st_db,(int)data); if( st ) { - TBL_PC *sd = map->id2sd(st->rid); + struct map_session_data *sd = map->id2sd(st->rid); if((sd && sd->status.char_id != id) || (st->rid && !sd)) { //Character mismatch. Cancel execution. st->rid = 0; @@ -4241,7 +4248,7 @@ void script_attach_state(struct script_state* st) { void run_script_main(struct script_state *st) { int cmdcount = script->config.check_cmdcount; int gotocount = script->config.check_gotocount; - TBL_PC *sd; + struct map_session_data *sd; struct script_stack *stack = st->stack; struct npc_data *nd; @@ -5158,8 +5165,9 @@ const char *script_getfuncname(struct script_state *st) { /// If a dialog doesn't exist yet, one is created. /// /// mes "<message>"; -BUILDIN(mes) { - TBL_PC* sd = script->rid2sd(st); +BUILDIN(mes) +{ + struct map_session_data *sd = script->rid2sd(st); if( sd == NULL ) return true; @@ -5183,10 +5191,8 @@ BUILDIN(mes) { /// next; BUILDIN(next) { - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; #ifdef SECURE_NPCTIMEOUT sd->npc_idle_type = NPCT_WAIT; @@ -5200,11 +5206,10 @@ BUILDIN(next) /// The dialog is closed when the button is pressed. /// /// close; -BUILDIN(close) { - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) +BUILDIN(close) +{ + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; st->state = sd->state.dialog == 1 ? CLOSE : END; @@ -5216,11 +5221,10 @@ BUILDIN(close) { /// The dialog is closed and the script continues when the button is pressed. /// /// close2; -BUILDIN(close2) { - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) +BUILDIN(close2) +{ + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; if( sd->state.dialog == 1 ) @@ -5290,10 +5294,8 @@ BUILDIN(menu) { int i; const char* text; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; #ifdef SECURE_NPCTIMEOUT @@ -5414,10 +5416,8 @@ BUILDIN(select) { int i; const char* text; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; #ifdef SECURE_NPCTIMEOUT @@ -5491,10 +5491,8 @@ BUILDIN(prompt) { int i; const char *text; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; #ifdef SECURE_NPCTIMEOUT @@ -5821,10 +5819,8 @@ BUILDIN(warp) int x,y; int warp_clean = 1; const char* str; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; str = script_getstr(st,2); @@ -5864,9 +5860,9 @@ int buildin_areawarp_sub(struct block_list *bl,va_list ap) x3 = va_arg(ap,int); y3 = va_arg(ap,int); - if(index == 0) - pc->randomwarp((TBL_PC *)bl,CLR_TELEPORT); - else if(x3 && y3) { + if (index == 0) { + pc->randomwarp((struct map_session_data *)bl, CLR_TELEPORT); + } else if (x3 != 0 && y3 != 0) { int max, tx, ty, j = 0; // choose a suitable max number of attempts @@ -5880,10 +5876,10 @@ int buildin_areawarp_sub(struct block_list *bl,va_list ap) j++; } while (map->getcell(index, bl, tx, ty, CELL_CHKNOPASS) && j < max); - pc->setpos((TBL_PC *)bl,index,tx,ty,CLR_OUTSIGHT); + pc->setpos((struct map_session_data *)bl, index, tx, ty, CLR_OUTSIGHT); + } else { + pc->setpos((struct map_session_data *)bl,index,x2,y2,CLR_OUTSIGHT); } - else - pc->setpos((TBL_PC *)bl,index,x2,y2,CLR_OUTSIGHT); return 0; } BUILDIN(areawarp) @@ -5933,7 +5929,7 @@ int buildin_areapercentheal_sub(struct block_list *bl,va_list ap) int hp, sp; hp = va_arg(ap, int); sp = va_arg(ap, int); - pc->percentheal((TBL_PC *)bl,hp,sp); + pc->percentheal((struct map_session_data *)bl, hp, sp); return 0; } BUILDIN(areapercentheal) { @@ -5965,7 +5961,7 @@ BUILDIN(areapercentheal) { BUILDIN(warpchar) { int x,y,a; const char *str; - TBL_PC *sd; + struct map_session_data *sd; str=script_getstr(st,2); x=script_getnum(st,3); @@ -5993,8 +5989,8 @@ BUILDIN(warpchar) { *------------------------------------------*/ BUILDIN(warpparty) { - TBL_PC *sd = NULL; - TBL_PC *pl_sd; + struct map_session_data *sd = NULL; + struct map_session_data *pl_sd; struct party_data* p; int type; int map_index; @@ -6082,8 +6078,8 @@ BUILDIN(warpparty) *------------------------------------------*/ BUILDIN(warpguild) { - TBL_PC *sd = NULL; - TBL_PC *pl_sd; + struct map_session_data *sd = NULL; + struct map_session_data *pl_sd; struct guild* g; struct s_mapiterator* iter; int type; @@ -6108,8 +6104,7 @@ BUILDIN(warpguild) } iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) - { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)mapit->next(iter)) { if( pl_sd->status.guild_id != gid ) continue; @@ -6140,12 +6135,12 @@ BUILDIN(warpguild) /*========================================== * Force Heal a player (hp and sp) *------------------------------------------*/ -BUILDIN(heal) { - TBL_PC *sd; +BUILDIN(heal) +{ int hp,sp; - - sd = script->rid2sd(st); - if (!sd) return true; + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) + return true; hp=script_getnum(st,2); sp=script_getnum(st,3); @@ -6157,7 +6152,7 @@ BUILDIN(heal) { *------------------------------------------*/ BUILDIN(itemheal) { - TBL_PC *sd; + struct map_session_data *sd; int hp,sp; hp=script_getnum(st,2); @@ -6180,7 +6175,7 @@ BUILDIN(itemheal) BUILDIN(percentheal) { int hp,sp; - TBL_PC* sd; + struct map_session_data *sd; hp=script_getnum(st,2); sp=script_getnum(st,3); @@ -6213,12 +6208,9 @@ BUILDIN(jobchange) if( script_hasdata(st,3) ) upper=script_getnum(st,3); - if (pc->db_checkid(job)) - { - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + if (pc->db_checkid(job)) { + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; pc->jobchange(sd, job, upper); @@ -6246,15 +6238,13 @@ BUILDIN(jobname) /// input(<var>{,<min>{,<max>}}) -> <int> BUILDIN(input) { - TBL_PC* sd; struct script_data* data; int64 uid; const char* name; int min; int max; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; data = script_getdata(st,2); @@ -6308,8 +6298,9 @@ BUILDIN(copyarray); /// The value is converted to the type of the variable. /// /// set(<variable>,<value>) -> <variable> -BUILDIN(__setr) { - TBL_PC* sd = NULL; +BUILDIN(__setr) +{ + struct map_session_data *sd = NULL; struct script_data* data; //struct script_data* datavalue; int64 num; @@ -6402,7 +6393,7 @@ BUILDIN(setarray) uint32 end; int32 id; int32 i; - TBL_PC* sd = NULL; + struct map_session_data *sd = NULL; data = script_getdata(st, 2); if( !data_isreference(data) || reference_toconstant(data) ) @@ -6453,7 +6444,7 @@ BUILDIN(cleararray) uint32 end; int32 id; void* v; - TBL_PC* sd = NULL; + struct map_session_data *sd = NULL; data = script_getdata(st, 2); if( !data_isreference(data) ) @@ -6506,7 +6497,7 @@ BUILDIN(copyarray) void* v; int32 i; uint32 count; - TBL_PC* sd = NULL; + struct map_session_data *sd = NULL; data1 = script_getdata(st, 2); data2 = script_getdata(st, 3); @@ -6608,7 +6599,7 @@ BUILDIN(deletearray) const char* name; unsigned int start, end, i; int id; - TBL_PC *sd = NULL; + struct map_session_data *sd = NULL; struct script_array *sa = NULL; struct reg_db *src = NULL; void *value; @@ -6757,7 +6748,7 @@ BUILDIN(getelementofarray) BUILDIN(setlook) { int type,val; - TBL_PC* sd; + struct map_session_data *sd; type=script_getnum(st,2); val=script_getnum(st,3); @@ -6774,7 +6765,7 @@ BUILDIN(setlook) BUILDIN(changelook) { // As setlook but only client side int type,val; - TBL_PC* sd; + struct map_session_data *sd; type=script_getnum(st,2); val=script_getnum(st,3); @@ -6793,10 +6784,8 @@ BUILDIN(changelook) *------------------------------------------*/ BUILDIN(cutin) { - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; clif->cutin(sd,script_getstr(st,2),script_getnum(st,3)); @@ -6809,7 +6798,7 @@ BUILDIN(cutin) BUILDIN(viewpoint) { int type,x,y,id,color; - TBL_PC* sd; + struct map_session_data *sd; type=script_getnum(st,2); x=script_getnum(st,3); @@ -6834,8 +6823,8 @@ BUILDIN(countitem) { int count = 0; struct item_data* id = NULL; - TBL_PC* sd = script->rid2sd(st); - if( !sd ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; if( script_isstringtype(st, 2) ) { @@ -6872,8 +6861,8 @@ BUILDIN(countitem2) { int i; struct item_data* id = NULL; - TBL_PC* sd = script->rid2sd(st); - if( !sd ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; if( script_isstringtype(st, 2) ) { @@ -7017,8 +7006,7 @@ BUILDIN(checkweight2) int32 idx_it, idx_nb; int nb_it, nb_nb; //array size - TBL_PC *sd = script->rid2sd(st); - + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -7110,7 +7098,7 @@ BUILDIN(checkweight2) BUILDIN(getitem) { int nameid,amount,get_count,i,flag = 0, offset = 0; struct item it; - TBL_PC *sd; + struct map_session_data *sd; struct item_data *item_data; if( script_isstringtype(st, 2) ) { @@ -7196,7 +7184,7 @@ BUILDIN(getitem2) { int nameid,amount,flag = 0, offset = 0; int iden,ref,attr,c1,c2,c3,c4, bound = 0; - TBL_PC *sd; + struct map_session_data *sd; if( !strcmp(script->getfuncname(st),"getitembound2") ) { bound = script_getnum(st,11); @@ -7353,7 +7341,7 @@ BUILDIN(rentitem) { BUILDIN(getnameditem) { int nameid; struct item item_tmp; - TBL_PC *sd, *tsd; + struct map_session_data *sd, *tsd; sd = script->rid2sd(st); if (sd == NULL) // Player not attached! @@ -7466,9 +7454,9 @@ BUILDIN(makeitem) y = script_getnum(st,6); if(strcmp(mapname,"this")==0) { - TBL_PC *sd; - sd = script->rid2sd(st); - if (!sd) return true; //Failed... + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) + return true; //Failed... m=sd->bl.m; } else m=map->mapname2mapid(mapname); @@ -7621,8 +7609,9 @@ bool buildin_delitem_search(struct map_session_data* sd, struct item* it, bool e /// /// delitem <item id>,<amount>{,<account id>} /// delitem "<item name>",<amount>{,<account id>} -BUILDIN(delitem) { - TBL_PC *sd; +BUILDIN(delitem) +{ + struct map_session_data *sd; struct item it; if (script_hasdata(st,4)) { @@ -7677,8 +7666,9 @@ BUILDIN(delitem) { /// /// delitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>} /// delitem2 "<Item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>} -BUILDIN(delitem2) { - TBL_PC *sd; +BUILDIN(delitem2) +{ + struct map_session_data *sd; struct item it; if (script_hasdata(st,11)) { @@ -7741,18 +7731,16 @@ BUILDIN(delitem2) { *------------------------------------------*/ BUILDIN(enableitemuse) { - TBL_PC *sd; - sd=script->rid2sd(st); - if (sd) + struct map_session_data *sd = script->rid2sd(st); + if (sd != NULL) st->npc_item_flag = sd->npc_item_flag = 1; return true; } BUILDIN(disableitemuse) { - TBL_PC *sd; - sd=script->rid2sd(st); - if (sd) + struct map_session_data *sd = script->rid2sd(st); + if (sd != NULL) st->npc_item_flag = sd->npc_item_flag = 0; return true; } @@ -7763,7 +7751,7 @@ BUILDIN(disableitemuse) *------------------------------------------*/ BUILDIN(readparam) { int type; - TBL_PC *sd; + struct map_session_data *sd; type=script_getnum(st,2); if (script_hasdata(st,3)) @@ -7792,7 +7780,7 @@ BUILDIN(readparam) { *------------------------------------------*/ BUILDIN(getcharid) { int num; - TBL_PC *sd; + struct map_session_data *sd; num = script_getnum(st,2); if( script_hasdata(st,3) ) @@ -8066,13 +8054,11 @@ BUILDIN(getguildmember) *------------------------------------------*/ BUILDIN(strcharinfo) { - TBL_PC *sd; int num; struct guild* g; struct party_data* p; - - sd=script->rid2sd(st); - if (!sd) //Avoid crashing.... + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) //Avoid crashing.... return true; num=script_getnum(st,2); @@ -8166,7 +8152,7 @@ BUILDIN(strnpcinfo) { BUILDIN(charid2rid) { int cid = script_getnum(st, 2); - TBL_PC *sd = map->charid2sd(cid); + struct map_session_data *sd = map->charid2sd(cid); if (sd == NULL) { script_pushint(st, 0); @@ -8183,11 +8169,9 @@ BUILDIN(charid2rid) BUILDIN(getequipid) { int i, num; - TBL_PC* sd; struct item_data* item; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; num = script_getnum(st,2) - 1; @@ -8221,11 +8205,9 @@ BUILDIN(getequipid) BUILDIN(getequipname) { int i, num; - TBL_PC* sd; struct item_data* item; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; num = script_getnum(st,2) - 1; @@ -8258,10 +8240,8 @@ BUILDIN(getequipname) BUILDIN(getbrokenid) { int i,num,id=0,brokencounter=0; - TBL_PC *sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; num=script_getnum(st,2); @@ -8286,10 +8266,7 @@ BUILDIN(getbrokenid) BUILDIN(getbrokencount) { int i, counter = 0; - TBL_PC *sd; - - sd = script->rid2sd(st); - + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -8310,10 +8287,8 @@ BUILDIN(repair) { int i,num; int repaircounter=0; - TBL_PC *sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; num=script_getnum(st,2); @@ -8339,10 +8314,8 @@ BUILDIN(repair) BUILDIN(repairall) { int i, repaircounter = 0; - TBL_PC *sd; - - sd = script->rid2sd(st); - if(sd == NULL) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; for(i = 0; i < MAX_INVENTORY; i++) @@ -8370,7 +8343,7 @@ BUILDIN(repairall) BUILDIN(getequipisequiped) { int i = -1,num; - TBL_PC *sd; + struct map_session_data *sd; num = script_getnum(st,2); sd = script->rid2sd(st); @@ -8397,7 +8370,7 @@ BUILDIN(getequipisequiped) BUILDIN(getequipisenableref) { int i = -1,num; - TBL_PC *sd; + struct map_session_data *sd; num = script_getnum(st,2); sd = script->rid2sd(st); @@ -8423,7 +8396,7 @@ BUILDIN(getequipisenableref) BUILDIN(getequipisidentify) { int i = -1,num; - TBL_PC *sd; + struct map_session_data *sd; num = script_getnum(st,2); sd = script->rid2sd(st); @@ -8449,7 +8422,7 @@ BUILDIN(getequipisidentify) BUILDIN(getequiprefinerycnt) { int i = -1,num; - TBL_PC *sd; + struct map_session_data *sd; num = script_getnum(st,2); sd = script->rid2sd(st); @@ -8476,7 +8449,7 @@ BUILDIN(getequiprefinerycnt) BUILDIN(getequipweaponlv) { int i = -1,num; - TBL_PC *sd; + struct map_session_data *sd; num = script_getnum(st,2); sd = script->rid2sd(st); @@ -8501,7 +8474,7 @@ BUILDIN(getequipweaponlv) *------------------------------------------*/ BUILDIN(getequippercentrefinery) { int i = -1,num; - TBL_PC *sd; + struct map_session_data *sd; num = script_getnum(st,2); sd = script->rid2sd(st); @@ -8524,7 +8497,7 @@ BUILDIN(getequippercentrefinery) { BUILDIN(successrefitem) { int i = -1 , num, up = 1; - TBL_PC *sd; + struct map_session_data *sd; num = script_getnum(st,2); sd = script->rid2sd(st); @@ -8585,7 +8558,7 @@ BUILDIN(successrefitem) BUILDIN(failedrefitem) { int i=-1,num; - TBL_PC *sd; + struct map_session_data *sd; num = script_getnum(st,2); sd = script->rid2sd(st); @@ -8613,7 +8586,7 @@ BUILDIN(failedrefitem) BUILDIN(downrefitem) { int i = -1, num, down = 1; - TBL_PC *sd; + struct map_session_data *sd; sd = script->rid2sd(st); if (sd == NULL) @@ -8654,7 +8627,7 @@ BUILDIN(downrefitem) BUILDIN(delequip) { int i=-1,num; - TBL_PC *sd; + struct map_session_data *sd; num = script_getnum(st,2); sd = script->rid2sd(st); @@ -8681,7 +8654,7 @@ BUILDIN(delequip) *------------------------------------------*/ BUILDIN(statusup) { int type; - TBL_PC *sd; + struct map_session_data *sd; type=script_getnum(st,2); sd = script->rid2sd(st); @@ -8698,7 +8671,7 @@ BUILDIN(statusup) { BUILDIN(statusup2) { int type,val; - TBL_PC *sd; + struct map_session_data *sd; type=script_getnum(st,2); val=script_getnum(st,3); @@ -8725,10 +8698,8 @@ BUILDIN(bonus) { int val3 = 0; int val4 = 0; int val5 = 0; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; // no player attached type = script_getnum(st,2); @@ -8806,11 +8777,9 @@ BUILDIN(autobonus) { unsigned int dur; short rate; short atk_type = 0; - TBL_PC* sd; const char *bonus_script, *other_script = NULL; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; // no player attached if( sd->state.autobonus&sd->status.inventory[status->current_equip_item_index].equip ) @@ -8842,11 +8811,9 @@ BUILDIN(autobonus2) { unsigned int dur; short rate; short atk_type = 0; - TBL_PC* sd; const char *bonus_script, *other_script = NULL; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; // no player attached if( sd->state.autobonus&sd->status.inventory[status->current_equip_item_index].equip ) @@ -8877,11 +8844,9 @@ BUILDIN(autobonus2) { BUILDIN(autobonus3) { unsigned int dur; short rate,atk_type; - TBL_PC* sd; const char *bonus_script, *other_script = NULL; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; // no player attached if( sd->state.autobonus&sd->status.inventory[status->current_equip_item_index].equip ) @@ -8922,10 +8887,8 @@ BUILDIN(skill) { int id; int level; int flag = SKILL_GRANT_TEMPORARY; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true;// no player attached, report source id = ( script_isstringtype(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) ); @@ -8950,10 +8913,8 @@ BUILDIN(addtoskill) { int id; int level; int flag = SKILL_GRANT_TEMPSTACK; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true;// no player attached, report source id = ( script_isstringtype(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) ); @@ -8973,11 +8934,9 @@ BUILDIN(guildskill) { int skill_id, id, max_points; int level; - TBL_PC* sd; struct guild *gd; struct guild_skill gd_skill; - - sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; // no player attached, report source @@ -9007,12 +8966,11 @@ BUILDIN(guildskill) { /// /// getskilllv(<skill id>) -> <level> /// getskilllv("<skill name>") -> <level> -BUILDIN(getskilllv) { +BUILDIN(getskilllv) +{ int id; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true;// no player attached, report source id = ( script_isstringtype(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) ); @@ -9057,10 +9015,8 @@ BUILDIN(basicskillcheck) /// getgmlevel() -> <level> BUILDIN(getgmlevel) { - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true;// no player attached, report source script_pushint(st, pc_get_group_level(sd)); @@ -9097,9 +9053,7 @@ BUILDIN(setgroupid) { /// getgroupid() -> <int> BUILDIN(getgroupid) { - TBL_PC* sd; - - sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; // no player attached, report source script_pushint(st, pc_get_group_id(sd)); @@ -9133,10 +9087,8 @@ BUILDIN(end) { BUILDIN(checkoption) { int option; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true;// no player attached, report source option = script_getnum(st,2); @@ -9154,10 +9106,8 @@ BUILDIN(checkoption) BUILDIN(checkoption1) { int opt1; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true;// no player attached, report source opt1 = script_getnum(st,2); @@ -9175,10 +9125,8 @@ BUILDIN(checkoption1) BUILDIN(checkoption2) { int opt2; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true;// no player attached, report source opt2 = script_getnum(st,2); @@ -9201,10 +9149,8 @@ BUILDIN(setoption) { int option; int flag = 1; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true;// no player attached, report source option = script_getnum(st,2); @@ -9234,10 +9180,8 @@ BUILDIN(setoption) /// @author Valaris BUILDIN(checkcart) { - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true;// no player attached, report source if( pc_iscarton(sd) ) @@ -9262,10 +9206,8 @@ BUILDIN(checkcart) BUILDIN(setcart) { int type = 1; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true;// no player attached, report source if( script_hasdata(st,2) ) @@ -9282,9 +9224,7 @@ BUILDIN(setcart) /// @author Valaris BUILDIN(checkfalcon) { - TBL_PC* sd; - - sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true;// no player attached, report source @@ -9304,9 +9244,7 @@ BUILDIN(checkfalcon) BUILDIN(setfalcon) { bool flag = true; - TBL_PC* sd; - - sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true;// no player attached, report source @@ -9342,9 +9280,7 @@ enum setmount_type { */ BUILDIN(checkmount) { - TBL_PC* sd; - - sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; // no player attached, report source @@ -9388,9 +9324,7 @@ BUILDIN(checkmount) BUILDIN(setmount) { int flag = SETMOUNT_TYPE_AUTODETECT; - TBL_PC* sd; - - sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true;// no player attached, report source @@ -9454,10 +9388,8 @@ BUILDIN(setmount) /// BUILDIN(checkwug) { - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true;// no player attached, report source if( pc_iswug(sd) || pc_isridingwug(sd) ) @@ -9477,9 +9409,7 @@ BUILDIN(savepoint) { int y; short mapid; const char* str; - TBL_PC* sd; - - sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; // no player attached, report source @@ -9595,23 +9525,21 @@ BUILDIN(gettimestr) /*========================================== * Open player storage *------------------------------------------*/ -BUILDIN(openstorage) { - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) +BUILDIN(openstorage) +{ + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; storage->open(sd); return true; } -BUILDIN(guildopenstorage) { - TBL_PC* sd; +BUILDIN(guildopenstorage) +{ int ret; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; ret = gstorage->open(sd); @@ -9624,13 +9552,12 @@ BUILDIN(guildopenstorage) { *------------------------------------------*/ /// itemskill <skill id>,<level>{,flag /// itemskill "<skill name>",<level>{,flag -BUILDIN(itemskill) { +BUILDIN(itemskill) +{ int id; int lv; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL || sd->ud.skilltimer != INVALID_TIMER ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL || sd->ud.skilltimer != INVALID_TIMER) return true; id = ( script_isstringtype(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) ); @@ -9653,10 +9580,8 @@ BUILDIN(itemskill) { BUILDIN(produce) { int trigger; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; trigger=script_getnum(st,2); @@ -9669,10 +9594,8 @@ BUILDIN(produce) BUILDIN(cooking) { int trigger; - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; trigger=script_getnum(st,2); @@ -9684,7 +9607,7 @@ BUILDIN(cooking) *------------------------------------------*/ BUILDIN(makepet) { - TBL_PC* sd; + struct map_session_data *sd; int id,pet_id; id=script_getnum(st,2); @@ -9711,12 +9634,10 @@ BUILDIN(makepet) *------------------------------------------*/ BUILDIN(getexp) { - TBL_PC* sd; int base=0,job=0; double bonus; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; base=script_getnum(st,2); @@ -9739,11 +9660,9 @@ BUILDIN(getexp) *------------------------------------------*/ BUILDIN(guildgetexp) { - TBL_PC* sd; int exp; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; exp = script_getnum(st,2); @@ -9758,8 +9677,9 @@ BUILDIN(guildgetexp) /*========================================== * Changes the guild master of a guild [Skotlex] *------------------------------------------*/ -BUILDIN(guildchangegm) { - TBL_PC *sd; +BUILDIN(guildchangegm) +{ + struct map_session_data *sd; int guild_id; const char *name; @@ -10058,7 +9978,7 @@ BUILDIN(killmonsterall) { * clone map, x, y, event, char_id, master_id, mode, flag, duration *------------------------------------------*/ BUILDIN(clone) { - TBL_PC *sd, *msd=NULL; + struct map_session_data *sd, *msd = NULL; int char_id,master_id=0,x,y, mode = 0, flag = 0, m; unsigned int duration = 0; const char *mapname, *event; @@ -10139,7 +10059,7 @@ BUILDIN(addtimer) { int tick = script_getnum(st,2); const char* event = script_getstr(st, 3); - TBL_PC* sd; + struct map_session_data *sd; script->check_event(st, event); sd = script->rid2sd(st); @@ -10157,7 +10077,7 @@ BUILDIN(addtimer) BUILDIN(deltimer) { const char *event; - TBL_PC* sd; + struct map_session_data *sd; event=script_getstr(st, 2); sd = script->rid2sd(st); @@ -10174,7 +10094,7 @@ BUILDIN(addtimercount) { const char *event; int tick; - TBL_PC* sd; + struct map_session_data *sd; event=script_getstr(st, 2); tick=script_getnum(st,3); @@ -10218,10 +10138,9 @@ BUILDIN(initnpctimer) if( !nd ) return true; - if( flag ) //Attach - { - TBL_PC* sd = script->rid2sd(st); - if( sd == NULL ) + if (flag) { //Attach + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; nd->u.scr.rid = sd->bl.id; } @@ -10262,10 +10181,9 @@ BUILDIN(startnpctimer) if( !nd ) return true; - if( flag ) //Attach - { - TBL_PC* sd = script->rid2sd(st); - if( sd == NULL ) + if (flag) { //Attach + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; nd->u.scr.rid = sd->bl.id; } @@ -10311,9 +10229,10 @@ BUILDIN(stopnpctimer) { } /*========================================== *------------------------------------------*/ -BUILDIN(getnpctimer) { +BUILDIN(getnpctimer) +{ struct npc_data *nd; - TBL_PC *sd; + struct map_session_data *sd; int type = script_getnum(st,2); int val = 0; @@ -10374,8 +10293,9 @@ BUILDIN(setnpctimer) /*========================================== * attaches the player rid to the timer [Celest] *------------------------------------------*/ -BUILDIN(attachnpctimer) { - TBL_PC *sd; +BUILDIN(attachnpctimer) +{ + struct map_session_data *sd; struct npc_data *nd = (struct npc_data *)map->id2bl(st->oid); if( !nd || nd->bl.type != BL_NPC ) @@ -10496,10 +10416,8 @@ int buildin_announce_sub(struct block_list *bl, va_list ap) * itemeffect "<item name>"; */ BUILDIN(itemeffect) { TBL_NPC *nd; - TBL_PC *sd; struct item_data *item_data; - - sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -10611,7 +10529,7 @@ BUILDIN(getusers) { *------------------------------------------*/ BUILDIN(getusersname) { - TBL_PC *sd, *pl_sd; + struct map_session_data *sd, *pl_sd; int /*disp_num=1,*/ group_level = 0; struct s_mapiterator* iter; @@ -10620,8 +10538,7 @@ BUILDIN(getusersname) group_level = pc_get_group_level(sd); iter = mapit_getallusers(); - for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) ) - { + for (pl_sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); pl_sd = (struct map_session_data *)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 @@ -10700,7 +10617,7 @@ BUILDIN(getareausers) } idx = 3; } else { - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) { script_pushint(st, -1); return true; @@ -11029,7 +10946,7 @@ BUILDIN(debugmes) BUILDIN(catchpet) { int pet_id; - TBL_PC *sd; + struct map_session_data *sd; pet_id= script_getnum(st,2); sd=script->rid2sd(st); @@ -11045,10 +10962,8 @@ BUILDIN(catchpet) *------------------------------------------*/ BUILDIN(homunculus_evolution) { - TBL_PC *sd; - - sd=script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; if(homun_alive(sd->hd)) { @@ -11067,11 +10982,9 @@ BUILDIN(homunculus_evolution) *------------------------------------------*/ BUILDIN(homunculus_mutate) { - TBL_PC *sd; bool success = false; - - sd = script->rid2sd(st); - if( sd == NULL || sd->hd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL || sd->hd == NULL) return true; if (sd->hd->homunculus.vaporize == HOM_ST_MORPH) { @@ -11110,11 +11023,9 @@ BUILDIN(homunculus_mutate) *------------------------------------------*/ BUILDIN(homunculus_morphembryo) { - TBL_PC *sd; bool success = false; - - sd = script->rid2sd(st); - if( sd == NULL || sd->hd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL || sd->hd == NULL) return true; if (homun_alive(sd->hd)) { @@ -11153,10 +11064,10 @@ BUILDIN(homunculus_morphembryo) * 1 = Homunculus is vaporized (rest) * 2 = Homunculus is in morph state *------------------------------------------*/ -BUILDIN(homunculus_checkcall) { - TBL_PC *sd = script->rid2sd(st); - - if( sd == NULL || !sd->hd ) +BUILDIN(homunculus_checkcall) +{ + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL || sd->hd == NULL) script_pushint(st, -1); else script_pushint(st, sd->hd->homunculus.vaporize); @@ -11165,11 +11076,10 @@ BUILDIN(homunculus_checkcall) { } // [Zephyrus] -BUILDIN(homunculus_shuffle) { - TBL_PC *sd; - - sd=script->rid2sd(st); - if( sd == NULL ) +BUILDIN(homunculus_shuffle) +{ + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; if(homun_alive(sd->hd)) @@ -11182,12 +11092,11 @@ BUILDIN(homunculus_shuffle) { BUILDIN(eaclass) { int class_; - if( script_hasdata(st,2) ) + if (script_hasdata(st,2)) { class_ = script_getnum(st,2); - else { - TBL_PC *sd; - sd=script->rid2sd(st); - if( !sd ) + } else { + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; class_ = sd->status.class_; } @@ -11199,10 +11108,10 @@ BUILDIN(roclass) { int class_ =script_getnum(st,2); int sex; - if( script_hasdata(st,3) ) + if (script_hasdata(st,3)) { sex = script_getnum(st,3); - else { - TBL_PC *sd; + } else { + struct map_session_data *sd; if (st->rid && (sd=script->rid2sd(st)) != NULL) sex = sd->status.sex; else @@ -11217,9 +11126,8 @@ BUILDIN(roclass) *------------------------------------------*/ BUILDIN(birthpet) { - TBL_PC *sd; - sd=script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; if( sd->status.pet_id ) @@ -11241,12 +11149,9 @@ BUILDIN(birthpet) *------------------------------------------*/ BUILDIN(resetlvl) { - TBL_PC *sd; - int type=script_getnum(st,2); - - sd=script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; pc->resetlvl(sd,type); @@ -11257,7 +11162,7 @@ BUILDIN(resetlvl) *------------------------------------------*/ BUILDIN(resetstatus) { - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; pc->resetstate(sd); @@ -11269,7 +11174,7 @@ BUILDIN(resetstatus) *------------------------------------------*/ BUILDIN(resetskill) { - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; pc->resetskill(sd, PCRESETSKILL_RESYNC); @@ -11281,7 +11186,7 @@ BUILDIN(resetskill) *------------------------------------------*/ BUILDIN(skillpointcount) { - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; script_pushint(st,sd->status.skill_point + pc->resetskill(sd, PCRESETSKILL_RECOUNT)); @@ -11291,8 +11196,9 @@ BUILDIN(skillpointcount) /*========================================== * *------------------------------------------*/ -BUILDIN(changebase) { - TBL_PC *sd=NULL; +BUILDIN(changebase) +{ + struct map_session_data *sd = NULL; int vclass; if (script_hasdata(st,3)) @@ -11318,10 +11224,10 @@ BUILDIN(changebase) { return true; } -static TBL_PC *prepareChangeSex(struct script_state* st) +static struct map_session_data *prepareChangeSex(struct script_state *st) { int i; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return NULL; @@ -11338,7 +11244,7 @@ static TBL_PC *prepareChangeSex(struct script_state* st) *------------------------------------------*/ BUILDIN(changesex) { - TBL_PC *sd = prepareChangeSex(st); + struct map_session_data *sd = prepareChangeSex(st); if (sd == NULL) return true; chrif->changesex(sd, true); @@ -11350,7 +11256,7 @@ BUILDIN(changesex) *------------------------------------------*/ BUILDIN(changecharsex) { - TBL_PC *sd = prepareChangeSex(st); + struct map_session_data *sd = prepareChangeSex(st); if (sd == NULL) return true; chrif->changesex(sd, false); @@ -11568,7 +11474,7 @@ BUILDIN(warpwaitingpc) n = script_getnum(st,5); for (i = 0; i < n && cd->users > 0; i++) { - TBL_PC* sd = cd->usersd[0]; + struct map_session_data *sd = cd->usersd[0]; if (strcmp(map_name,"SavePoint") == 0 && map->list[sd->bl.m].flag.noteleport) { // can't teleport on this map @@ -11638,10 +11544,11 @@ BUILDIN(detachrid) /*========================================== * Chk if account connected, (and charid from account if specified) *------------------------------------------*/ -BUILDIN(isloggedin) { - TBL_PC* sd = map->id2sd(script_getnum(st,2)); - if (script_hasdata(st,3) && sd && - sd->status.char_id != script_getnum(st,3)) +BUILDIN(isloggedin) +{ + struct map_session_data *sd = map->id2sd(script_getnum(st,2)); + if (script_hasdata(st,3) && sd != NULL + && sd->status.char_id != script_getnum(st,3)) sd = NULL; script->push_val(st->stack,C_INT,sd!=NULL,NULL); return true; @@ -11741,8 +11648,9 @@ BUILDIN(getmapflag) return true; } /* pvp timer handling */ -int script_mapflag_pvp_sub(struct block_list *bl,va_list ap) { - TBL_PC* sd = (TBL_PC*)bl; +int script_mapflag_pvp_sub(struct block_list *bl, va_list ap) +{ + struct map_session_data *sd = (struct map_session_data *)bl; if (sd->pvp_timer == INVALID_TIMER) { sd->pvp_timer = timer->add(timer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0); sd->pvp_rank = 0; @@ -11945,10 +11853,11 @@ BUILDIN(removemapflag) { return true; } -BUILDIN(pvpon) { +BUILDIN(pvpon) +{ int16 m; const char *str; - TBL_PC* sd = NULL; + struct map_session_data *sd = NULL; struct s_mapiterator* iter; struct block_list bl; @@ -11973,8 +11882,7 @@ BUILDIN(pvpon) { return true; iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) - { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { if( sd->bl.m != m || sd->pvp_timer != INVALID_TIMER ) continue; // not applicable @@ -11990,9 +11898,9 @@ BUILDIN(pvpon) { return true; } -int buildin_pvpoff_sub(struct block_list *bl,va_list ap) +int buildin_pvpoff_sub(struct block_list *bl, va_list ap) { - TBL_PC* sd = (TBL_PC*)bl; + struct map_session_data *sd = (struct map_session_data *)bl; clif->pvpset(sd, 0, 0, 2); if (sd->pvp_timer != INVALID_TIMER) { timer->delete(sd->pvp_timer, pc->calc_pvprank_timer); @@ -12084,7 +11992,7 @@ BUILDIN(emotion) { player=script_getnum(st,3); if (player != 0) { - TBL_PC *sd = NULL; + struct map_session_data *sd = NULL; if (script_hasdata(st,4)) sd = script->nick2sd(st, script_getstr(st,4)); else @@ -12310,7 +12218,7 @@ BUILDIN(requestguildinfo) BUILDIN(getequipcardcnt) { int i=-1,j,num; - TBL_PC *sd; + struct map_session_data *sd; int count; num=script_getnum(st,2); @@ -12349,7 +12257,7 @@ BUILDIN(successremovecards) { int i=-1,c,cardflag=0; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); int num = script_getnum(st,2); if (sd == NULL) @@ -12420,7 +12328,7 @@ BUILDIN(failedremovecards) { int i=-1,c,cardflag=0; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); int num = script_getnum(st,2); int typefail = script_getnum(st,3); @@ -12594,8 +12502,8 @@ BUILDIN(mobcount) { BUILDIN(marriage) { const char *partner=script_getstr(st,2); - TBL_PC *sd=script->rid2sd(st); - TBL_PC *p_sd = script->nick2sd(st, partner); + struct map_session_data *sd = script->rid2sd(st); + struct map_session_data *p_sd = script->nick2sd(st, partner); if (sd == NULL || p_sd == NULL || pc->marriage(sd,p_sd) < 0) { script_pushint(st,0); @@ -12604,8 +12512,9 @@ BUILDIN(marriage) { script_pushint(st,1); return true; } -BUILDIN(wedding_effect) { - TBL_PC *sd = script->rid2sd(st); +BUILDIN(wedding_effect) +{ + struct map_session_data *sd = script->rid2sd(st); struct block_list *bl; if (sd == NULL) @@ -12617,8 +12526,8 @@ BUILDIN(wedding_effect) { } BUILDIN(divorce) { - TBL_PC *sd=script->rid2sd(st); - if(sd==NULL || pc->divorce(sd) < 0) { + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL || pc->divorce(sd) < 0) { script_pushint(st,0); return true; } @@ -12627,7 +12536,7 @@ BUILDIN(divorce) } BUILDIN(ispartneron) { - TBL_PC *sd=script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd==NULL || !pc->ismarried(sd) || map->charid2sd(sd->status.partner_id) == NULL) { @@ -12641,7 +12550,7 @@ BUILDIN(ispartneron) { BUILDIN(getpartnerid) { - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -12651,7 +12560,7 @@ BUILDIN(getpartnerid) BUILDIN(getchildid) { - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -12661,7 +12570,7 @@ BUILDIN(getchildid) BUILDIN(getmotherid) { - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -12670,8 +12579,8 @@ BUILDIN(getmotherid) } BUILDIN(getfatherid) { - TBL_PC *sd=script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; script_pushint(st,sd->status.father); @@ -12683,8 +12592,8 @@ BUILDIN(warppartner) int x,y; unsigned short map_index; const char *str; - TBL_PC *sd=script->rid2sd(st); - TBL_PC *p_sd=NULL; + struct map_session_data *sd = script->rid2sd(st); + struct map_session_data *p_sd = NULL; if (sd == NULL || !pc->ismarried(sd) || (p_sd = script->charid2sd(st, sd->status.partner_id)) == NULL) { @@ -12992,7 +12901,7 @@ BUILDIN(setiteminfo) BUILDIN(getequipcardid) { int i=-1,num,slot; - TBL_PC *sd; + struct map_session_data *sd; num=script_getnum(st,2); slot=script_getnum(st,3); @@ -13018,9 +12927,9 @@ BUILDIN(petskillbonus) { struct pet_data *pd; - TBL_PC *sd=script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if (sd == NULL || sd->pd == NULL) return true; pd=sd->pd; @@ -13055,9 +12964,9 @@ BUILDIN(petloot) { int max; struct pet_data *pd; - TBL_PC *sd=script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if (sd == NULL || sd->pd == NULL) return true; max=script_getnum(st,2); @@ -13091,8 +13000,9 @@ BUILDIN(petloot) * @inventorylist_card(0..3), @inventorylist_expire * @inventorylist_count = scalar *------------------------------------------*/ -BUILDIN(getinventorylist){ - TBL_PC *sd=script->rid2sd(st); +BUILDIN(getinventorylist) +{ + struct map_session_data *sd = script->rid2sd(st); char card_var[NAME_LENGTH]; int i,j=0,k; @@ -13123,8 +13033,9 @@ BUILDIN(getinventorylist){ return true; } -BUILDIN(getcartinventorylist){ - TBL_PC *sd=script->rid2sd(st); +BUILDIN(getcartinventorylist) +{ + struct map_session_data *sd = script->rid2sd(st); char card_var[26]; int i,j=0,k; @@ -13153,9 +13064,10 @@ BUILDIN(getcartinventorylist){ BUILDIN(getskilllist) { - TBL_PC *sd=script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); int i,j=0; - if(!sd) return true; + if (sd == NULL) + return true; for(i=0;i<MAX_SKILL;i++) { if(sd->status.skill[i].id > 0 && sd->status.skill[i].lv > 0) { pc->setreg(sd,reference_uid(script->add_str("@skilllist_id"), j),sd->status.skill[i].id); @@ -13170,9 +13082,10 @@ BUILDIN(getskilllist) BUILDIN(clearitem) { - TBL_PC *sd=script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); int i; - if(sd==NULL) return true; + if (sd == NULL) + return true; for (i=0; i<MAX_INVENTORY; i++) { if (sd->status.inventory[i].amount) { pc->delitem(sd, i, sd->status.inventory[i].amount, 0, DELITEM_NORMAL, LOG_TYPE_SCRIPT); @@ -13187,8 +13100,9 @@ BUILDIN(clearitem) BUILDIN(disguise) { int id; - TBL_PC* sd = script->rid2sd(st); - if (sd == NULL) return true; + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) + return true; id = script_getnum(st,2); @@ -13206,8 +13120,9 @@ BUILDIN(disguise) *------------------------------------------*/ BUILDIN(undisguise) { - TBL_PC* sd = script->rid2sd(st); - if (sd == NULL) return true; + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) + return true; if (sd->disguise != -1) { pc->disguise(sd, -1); @@ -13247,8 +13162,8 @@ BUILDIN(misceffect) if (bl) clif->specialeffect(bl,type,AREA); } else { - TBL_PC *sd=script->rid2sd(st); - if(sd) + struct map_session_data *sd = script->rid2sd(st); + if (sd != NULL) clif->specialeffect(&sd->bl,type,AREA); } return true; @@ -13333,12 +13248,11 @@ BUILDIN(playbgmall) { *------------------------------------------*/ BUILDIN(soundeffect) { - TBL_PC* sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); const char* name = script_getstr(st,2); int type = script_getnum(st,3); - if(sd) - { + if (sd != NULL) { clif->soundeffect(sd,&sd->bl,name,type); } return true; @@ -13349,7 +13263,7 @@ int soundeffect_sub(struct block_list* bl,va_list ap) char* name = va_arg(ap,char*); int type = va_arg(ap,int); - clif->soundeffect((TBL_PC *)bl, bl, name, type); + clif->soundeffect((struct map_session_data *)bl, bl, name, type); return true; } @@ -13412,9 +13326,9 @@ BUILDIN(soundeffectall) { BUILDIN(petrecovery) { struct pet_data *pd; - TBL_PC *sd=script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if (sd == NULL || sd->pd == NULL) return true; pd=sd->pd; @@ -13438,9 +13352,10 @@ BUILDIN(petrecovery) *------------------------------------------*/ /// petskillattack <skill id>,<level>,<div>,<rate>,<bonusrate> /// petskillattack "<skill name>",<level>,<div>,<rate>,<bonusrate> -BUILDIN(petskillattack) { +BUILDIN(petskillattack) +{ struct pet_data *pd; - TBL_PC *sd=script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd==NULL || sd->pd==NULL) return true; @@ -13463,11 +13378,12 @@ BUILDIN(petskillattack) { *------------------------------------------*/ /// petskillsupport <skill id>,<level>,<delay>,<hp>,<sp> /// petskillsupport "<skill name>",<level>,<delay>,<hp>,<sp> -BUILDIN(petskillsupport) { +BUILDIN(petskillsupport) +{ struct pet_data *pd; - TBL_PC *sd=script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); - if(sd==NULL || sd->pd==NULL) + if (sd == NULL || sd->pd == NULL) return true; pd=sd->pd; @@ -13501,8 +13417,9 @@ BUILDIN(petskillsupport) { *------------------------------------------*/ /// skilleffect <skill id>,<level> /// skilleffect "<skill name>",<level> -BUILDIN(skilleffect) { - TBL_PC *sd; +BUILDIN(skilleffect) +{ + struct map_session_data *sd; uint16 skill_id=( script_isstringtype(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) ); uint16 skill_lv=script_getnum(st,3); @@ -13562,8 +13479,8 @@ BUILDIN(specialeffect) { else { if (target == SELF) { - TBL_PC *sd=script->rid2sd(st); - if (sd) + struct map_session_data *sd = script->rid2sd(st); + if (sd != NULL) clif->specialeffect_single(bl,type,sd->fd); } else { clif->specialeffect(bl, type, target); @@ -13574,7 +13491,7 @@ BUILDIN(specialeffect) { } BUILDIN(specialeffect2) { - TBL_PC *sd; + struct map_session_data *sd; int type = script_getnum(st,2); enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA; @@ -13594,10 +13511,10 @@ BUILDIN(specialeffect2) { *------------------------------------------*/ BUILDIN(nude) { - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); int i, calcflag = 0; - if( sd == NULL ) + if (sd == NULL) return true; for( i = 0 ; i < EQI_MAX; i++ ) { @@ -13617,8 +13534,9 @@ BUILDIN(nude) /*========================================== * gmcommand [MouseJstr] *------------------------------------------*/ -BUILDIN(atcommand) { - TBL_PC *sd, *dummy_sd = NULL; +BUILDIN(atcommand) +{ + struct map_session_data *sd, *dummy_sd = NULL; int fd; const char* cmd; bool ret = true; @@ -13660,7 +13578,7 @@ BUILDIN(atcommand) { */ BUILDIN(dispbottom) { - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); const char *message = script_getstr(st,2); if (sd == NULL) @@ -13682,12 +13600,11 @@ BUILDIN(dispbottom) *------------------------------------------*/ BUILDIN(recovery) { - TBL_PC* sd; + struct map_session_data *sd; struct s_mapiterator* iter; iter = mapit_getallusers(); - for( sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) - { + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) { if(pc_isdead(sd)) status->revive(&sd->bl, 100, 100); else @@ -13704,11 +13621,11 @@ BUILDIN(recovery) *------------------------------------------*/ BUILDIN(getpetinfo) { - TBL_PC *sd=script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); TBL_PET *pd; int type=script_getnum(st,2); - if(!sd || !sd->pd) { + if (sd == NULL || sd->pd == NULL) { if (type == 2) script_pushconststr(st,"null"); else @@ -13738,10 +13655,10 @@ BUILDIN(getpetinfo) *------------------------------------------*/ BUILDIN(gethominfo) { - TBL_PC *sd=script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); int type = script_getnum(st,2); - if(!sd || !sd->hd) { + if (sd == NULL || sd->hd == NULL) { if (type == 2) script_pushconststr(st,"null"); else @@ -13820,7 +13737,7 @@ BUILDIN(getmercinfo) BUILDIN(checkequipedcard) { int n,i,c=0; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -13890,7 +13807,7 @@ BUILDIN(movenpc) { BUILDIN(message) { const char *message; - TBL_PC *sd = NULL; + struct map_session_data *sd = NULL; if (script_isstringtype(st,2)) sd = script->nick2sd(st, script_getstr(st,2)); @@ -14093,7 +14010,7 @@ BUILDIN(getnpcclass) BUILDIN(getlook) { int type,val = -1; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -14122,7 +14039,7 @@ BUILDIN(getlook) BUILDIN(getsavepoint) { int type; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -14165,7 +14082,7 @@ BUILDIN(getsavepoint) BUILDIN(getmapxy) { struct block_list *bl = NULL; - TBL_PC *sd=NULL; + struct map_session_data *sd = NULL; int64 num; const char *name; @@ -14364,7 +14281,7 @@ BUILDIN(getmapxy) BUILDIN(logmes) { const char *str; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -14378,12 +14295,11 @@ BUILDIN(summon) { int class_, timeout=0; const char *str,*event=""; - TBL_PC *sd; struct mob_data *md; int64 tick = timer->gettick(); - - sd=script->rid2sd(st); - if (!sd) return true; + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) + return true; str = script_getstr(st,2); class_ = script_getnum(st,3); @@ -14426,7 +14342,7 @@ BUILDIN(isequippedcnt) { int i, j, k, id = 1; int ret = 0; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -14478,7 +14394,7 @@ BUILDIN(isequipped) int ret = -1; //Original hash to reverse it when full check fails. unsigned int setitem_hash = 0, setitem_hash2 = 0; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -14556,7 +14472,7 @@ BUILDIN(cardscnt) int i, k, id = 1; int ret = 0; int index; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -14595,7 +14511,7 @@ BUILDIN(cardscnt) *-------------------------------------------------------*/ BUILDIN(getrefine) { - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -14622,7 +14538,7 @@ BUILDIN(day) { BUILDIN(unequip) { size_t num; - TBL_PC *sd; + struct map_session_data *sd; num = script_getnum(st,2); sd = script->rid2sd(st); @@ -14637,11 +14553,9 @@ BUILDIN(unequip) BUILDIN(equip) { int nameid=0,i; - TBL_PC *sd; struct item_data *item_data; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return false; nameid=script_getnum(st,2); @@ -14688,7 +14602,7 @@ BUILDIN(equip2) { int i,nameid,ref,attr,c0,c1,c2,c3; struct item_data *item_data; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) { script_pushint(st,0); @@ -14982,7 +14896,7 @@ BUILDIN(explode) char *temp = NULL; const char *name; - TBL_PC* sd = NULL; + struct map_session_data *sd = NULL; if (!data_isreference(data)) { ShowError("script:explode: not a variable\n"); @@ -15041,7 +14955,7 @@ BUILDIN(implode) const char *name; uint32 array_size, id; - TBL_PC* sd = NULL; + struct map_session_data *sd = NULL; char *output; @@ -15810,7 +15724,7 @@ BUILDIN(swap) BUILDIN(setd) { - TBL_PC *sd=NULL; + struct map_session_data *sd = NULL; char varname[100]; const char *buffer; int elem; @@ -15841,7 +15755,7 @@ BUILDIN(setd) int buildin_query_sql_sub(struct script_state* st, Sql* handle) { int i, j; - TBL_PC* sd = NULL; + struct map_session_data *sd = NULL; const char* query; struct script_data* data; const char* name; @@ -15968,11 +15882,10 @@ BUILDIN(getd) { // Pet stat [Lance] BUILDIN(petstat) { - TBL_PC *sd = NULL; struct pet_data *pd; int flag = script_getnum(st,2); - sd = script->rid2sd(st); - if(!sd || !sd->status.pet_id || !sd->pd) { + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL || sd->status.pet_id == 0 || sd->pd == NULL) { if(flag == 2) script_pushconststr(st, ""); else @@ -15998,7 +15911,7 @@ BUILDIN(callshop) struct npc_data *nd; const char *shopname; int flag = 0; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -16353,7 +16266,7 @@ BUILDIN(getmonsterinfo) BUILDIN(checkvending) // check vending [Nab4] { - TBL_PC *sd = NULL; + struct map_session_data *sd = NULL; if (script_hasdata(st,2)) sd = script->nick2sd(st, script_getstr(st,2)); @@ -16370,7 +16283,7 @@ BUILDIN(checkvending) // check vending [Nab4] // check chatting [Marka] BUILDIN(checkchatting) { - TBL_PC *sd = NULL; + struct map_session_data *sd = NULL; if (script_hasdata(st,2)) sd = script->nick2sd(st, script_getstr(st,2)); @@ -16386,7 +16299,7 @@ BUILDIN(checkchatting) { } BUILDIN(checkidle) { - TBL_PC *sd = NULL; + struct map_session_data *sd = NULL; if (script_hasdata(st, 2)) sd = script->nick2sd(st, script_getstr(st, 2)); @@ -16412,11 +16325,11 @@ BUILDIN(searchitem) int32 start; int32 id; int32 i; - TBL_PC* sd = NULL; + struct map_session_data *sd = NULL; - if ((items[0] = itemdb->exists(atoi(itemname)))) + if ((items[0] = itemdb->exists(atoi(itemname)))) { count = 1; - else { + } else { count = itemdb->search_name_array(items, ARRAYLENGTH(items), itemname, 0); if (count > MAX_SEARCH) count = MAX_SEARCH; } @@ -16470,7 +16383,7 @@ BUILDIN(rid2name) { if((bl = map->id2bl(rid))) { switch(bl->type) { case BL_MOB: script_pushstrcopy(st,((TBL_MOB*)bl)->name); break; - case BL_PC: script_pushstrcopy(st,((TBL_PC*)bl)->status.name); break; + case BL_PC: script_pushstrcopy(st, ((struct map_session_data *)bl)->status.name); break; case BL_NPC: script_pushstrcopy(st,((TBL_NPC*)bl)->exname); break; case BL_PET: script_pushstrcopy(st,((TBL_PET*)bl)->pet.name); break; case BL_HOM: script_pushstrcopy(st,((TBL_HOM*)bl)->homunculus.name); break; @@ -16489,7 +16402,7 @@ BUILDIN(rid2name) { BUILDIN(pcblockmove) { int id, flag; - TBL_PC *sd = NULL; + struct map_session_data *sd = NULL; id = script_getnum(st,2); flag = script_getnum(st,3); @@ -16505,9 +16418,10 @@ BUILDIN(pcblockmove) { return true; } -BUILDIN(pcfollow) { +BUILDIN(pcfollow) +{ int id, targetid; - TBL_PC *sd = NULL; + struct map_session_data *sd = NULL; id = script_getnum(st,2); targetid = script_getnum(st,3); @@ -16526,7 +16440,7 @@ BUILDIN(pcfollow) { BUILDIN(pcstopfollow) { int id; - TBL_PC *sd = NULL; + struct map_session_data *sd = NULL; id = script_getnum(st,2); @@ -16669,7 +16583,7 @@ BUILDIN(unitattack) { } if (script_isstringtype(st, 3)) { - TBL_PC* sd = script->nick2sd(st, script_getstr(st, 3)); + struct map_session_data *sd = script->nick2sd(st, script_getstr(st, 3)); if (sd != NULL) target_bl = &sd->bl; } else { @@ -16689,7 +16603,7 @@ BUILDIN(unitattack) { switch( unit_bl->type ) { case BL_PC: - clif->pActionRequest_sub(((TBL_PC *)unit_bl), actiontype > 0 ? 0x07 : 0x00, target_bl->id, timer->gettick()); + clif->pActionRequest_sub((struct map_session_data *)unit_bl, actiontype > 0 ? 0x07 : 0x00, target_bl->id, timer->gettick()); script_pushint(st, 1); return true; case BL_MOB: @@ -16908,7 +16822,7 @@ BUILDIN(awake) { for( tst = dbi_first(iter); dbi_exists(iter); tst = dbi_next(iter) ) { if( tst->oid == nd->bl.id ) { - TBL_PC* sd = map->id2sd(tst->rid); + struct map_session_data *sd = map->id2sd(tst->rid); if( tst->sleep.timer == INVALID_TIMER ) {// already awake ??? continue; @@ -17023,10 +16937,8 @@ BUILDIN(warpportal) { BUILDIN(openmail) { - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; mail->openmail(sd); @@ -17036,10 +16948,8 @@ BUILDIN(openmail) BUILDIN(openauction) { - TBL_PC* sd; - - sd = script->rid2sd(st); - if( sd == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; clif->auction_openwindow(sd); @@ -17478,8 +17388,9 @@ BUILDIN(questprogress) return true; } -BUILDIN(showevent) { - TBL_PC *sd = script->rid2sd(st); +BUILDIN(showevent) +{ + struct map_session_data *sd = script->rid2sd(st); struct npc_data *nd = map->id2nd(st->oid); int icon, color = 0; @@ -18036,8 +17947,9 @@ BUILDIN(has_instance) { script_pushconststr(st, map->list[m].name); return true; } -int buildin_instance_warpall_sub(struct block_list *bl,va_list ap) { - struct map_session_data *sd = ((TBL_PC*)bl); +int buildin_instance_warpall_sub(struct block_list *bl,va_list ap) +{ + struct map_session_data *sd = (struct map_session_data*)bl; int map_index = va_arg(ap,int); int x = va_arg(ap,int); int y = va_arg(ap,int); @@ -18420,9 +18332,10 @@ BUILDIN(showdigit) /** * Rune Knight **/ -BUILDIN(makerune) { - TBL_PC* sd; - if( (sd = script->rid2sd(st)) == NULL ) +BUILDIN(makerune) +{ + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; clif->skill_produce_mix_list(sd,RK_RUNEMASTERY,24); sd->itemid = script_getnum(st,2); @@ -18434,8 +18347,8 @@ BUILDIN(makerune) { **/ BUILDIN(hascashmount) { - TBL_PC* sd; - if( (sd = script->rid2sd(st)) == NULL ) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; if( sd->sc.data[SC_ALL_RIDING] ) script_pushint(st,1); @@ -18453,8 +18366,8 @@ BUILDIN(hascashmount) **/ BUILDIN(setcashmount) { - TBL_PC* sd; - if ((sd = script->rid2sd(st)) == NULL) + struct map_session_data *sd = script->rid2sd(st); + if (sd == NULL) return true; if (pc_hasmount(sd)) { clif->msgtable(sd, MSG_REINS_CANT_USE_MOUNTED); @@ -18715,7 +18628,7 @@ BUILDIN(unbindatcmd) { } BUILDIN(useatcmd) { - TBL_PC *sd, *dummy_sd = NULL; + struct map_session_data *sd, *dummy_sd = NULL; int fd; const char* cmd; @@ -19584,7 +19497,7 @@ BUILDIN(bg_join_team) { BUILDIN(countbound) { int i, type, j=0, k=0; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -19620,7 +19533,7 @@ BUILDIN(checkbound) { int i, nameid = script_getnum(st,2); int bound_type = 0; - TBL_PC *sd = script->rid2sd(st); + struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; diff --git a/src/map/script.h b/src/map/script.h index b3e16b1b4..5f71662c6 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -647,10 +647,10 @@ struct script_interface { bool (*addScript) (char *name, char *args, bool (*func)(struct script_state *st), bool isDeprecated); int (*conv_num) (struct script_state *st,struct script_data *data); const char* (*conv_str) (struct script_state *st,struct script_data *data); - TBL_PC *(*rid2sd) (struct script_state *st); - TBL_PC *(*id2sd) (struct script_state *st, int account_id); - TBL_PC *(*charid2sd) (struct script_state *st, int char_id); - TBL_PC *(*nick2sd) (struct script_state *st, const char *name); + struct map_session_data *(*rid2sd) (struct script_state *st); + struct map_session_data *(*id2sd) (struct script_state *st, int account_id); + struct map_session_data *(*charid2sd) (struct script_state *st, int char_id); + struct map_session_data *(*nick2sd) (struct script_state *st, const char *name); void (*detach_rid) (struct script_state* st); struct script_data* (*push_val)(struct script_stack* stack, enum c_op type, int64 val, struct reg_db *ref); struct script_data *(*get_val) (struct script_state* st, struct script_data* data); @@ -728,7 +728,7 @@ struct script_interface { void (*read_constdb) (void); const char* (*print_line) (StringBuf *buf, const char *p, const char *mark, int line); void (*errorwarning_sub) (StringBuf *buf, const char *src, const char *file, int start_line, const char *error_msg, const char *error_pos); - int (*set_reg) (struct script_state *st, TBL_PC *sd, int64 num, const char *name, const void *value, struct reg_db *ref); + int (*set_reg) (struct script_state *st, struct map_session_data *sd, int64 num, const char *name, const void *value, struct reg_db *ref); void (*set_reg_ref_str) (struct script_state* st, struct reg_db *n, int64 num, const char* name, const char *str); void (*set_reg_scope_str) (struct script_state* st, struct reg_db *n, int64 num, const char* name, const char *str); void (*set_reg_npc_str) (struct script_state* st, struct reg_db *n, int64 num, const char* name, const char *str); diff --git a/src/map/skill.c b/src/map/skill.c index 5462340db..39f8ace34 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -288,8 +288,8 @@ int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { case RA_ARROWSTORM: case RA_AIMEDBOLT: case RA_WUGBITE: - if( bl->type == BL_PC ) - range += pc->checkskill((TBL_PC*)bl, AC_VULTURE); + if (bl->type == BL_PC) + range += pc->checkskill((struct map_session_data *)bl, AC_VULTURE); else range += 10; //Assume level 10? break; @@ -300,13 +300,13 @@ int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { case GS_SPREADATTACK: case GS_GROUNDDRIFT: if (bl->type == BL_PC) - range += pc->checkskill((TBL_PC*)bl, GS_SNAKEEYE); + range += pc->checkskill((struct map_session_data *)bl, GS_SNAKEEYE); else range += 10; //Assume level 10? break; case NJ_KIRIKAGE: if (bl->type == BL_PC) - range = skill->get_range(NJ_SHADOWJUMP,pc->checkskill((TBL_PC*)bl,NJ_SHADOWJUMP)); + range = skill->get_range(NJ_SHADOWJUMP, pc->checkskill((struct map_session_data *)bl, NJ_SHADOWJUMP)); break; /** * Warlock @@ -323,9 +323,9 @@ int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { case WL_TETRAVORTEX: case WL_EARTHSTRAIN: case WL_RELEASE: - if( bl->type == BL_PC ) - range += pc->checkskill((TBL_PC*)bl, WL_RADIUS); - break; + if (bl->type == BL_PC) + range += pc->checkskill((struct map_session_data *)bl, WL_RADIUS); + break; /** * Ranger Bonus **/ @@ -336,8 +336,8 @@ int skill_get_range2 (struct block_list *bl, uint16 skill_id, uint16 skill_lv) { case RA_CLUSTERBOMB: case RA_FIRINGTRAP: case RA_ICEBOUNDTRAP: - if( bl->type == BL_PC ) - range += (1 + pc->checkskill((TBL_PC*)bl, RA_RESEARCHTRAP))/2; + if (bl->type == BL_PC) + range += (1 + pc->checkskill((struct map_session_data *)bl, RA_RESEARCHTRAP))/2; } if( !range && bl->type != BL_PC ) @@ -1957,8 +1957,7 @@ int skill_break_equip (struct block_list *bl, unsigned short where, int rate, in const enum sc_type scdef[4] = {SC_PROTECTWEAPON, SC_PROTECTARMOR, SC_PROTECTSHIELD, SC_PROTECTHELM}; struct status_change *sc = status->get_sc(bl); int i; - TBL_PC *sd; - sd = BL_CAST(BL_PC, bl); + struct map_session_data *sd = BL_CAST(BL_PC, bl); if (sc && !sc->count) sc = NULL; @@ -2771,11 +2770,12 @@ int skill_attack(int attack_type, struct block_list* src, struct block_list *dsr struct status_change_entry *sce = sc->data[SC_DEVOTION]; struct block_list *d_bl = map->id2bl(sce->val1); - if( d_bl && ( - (d_bl->type == BL_MER && ((TBL_MER*)d_bl)->master && ((TBL_MER*)d_bl)->master->bl.id == bl->id) || - (d_bl->type == BL_PC && ((TBL_PC*)d_bl)->devotion[sce->val2] == bl->id) - ) && check_distance_bl(bl, d_bl, sce->val3) ) - { + if (d_bl != NULL + && ((d_bl->type == BL_MER && ((TBL_MER *)d_bl)->master && ((TBL_MER *)d_bl)->master->bl.id == bl->id) + || (d_bl->type == BL_PC && ((struct map_session_data *)d_bl)->devotion[sce->val2] == bl->id) + ) + && check_distance_bl(bl, d_bl, sce->val3) + ) { if(!rmdamage){ clif->damage(d_bl,d_bl, 0, 0, damage, 0, BDT_NORMAL, 0); status_fix_damage(NULL,d_bl, damage, 0); @@ -3325,7 +3325,7 @@ int skill_timerskill(int tid, int64 tick, int id, intptr_t data) { case SR_WINDMILL: if( target->type == BL_PC ) { struct map_session_data *tsd = NULL; - if( (tsd = ((TBL_PC*)target)) && !pc_issit(tsd) ) { + if ((tsd = (struct map_session_data *)target) != NULL && !pc_issit(tsd)) { pc_setsit(tsd); skill->sit(tsd,1); clif->sitting(&tsd->bl); @@ -3348,7 +3348,7 @@ int skill_timerskill(int tid, int64 tick, int id, intptr_t data) { if( distance_xy(src->x, src->y, target->x, target->y) >= 3 ) break; - skill->castend_damage_id(src, target, skl->skill_id, pc->checkskill(((TBL_PC*)src), skl->skill_id), tick, 0); + skill->castend_damage_id(src, target, skl->skill_id, pc->checkskill((struct map_session_data *)src, skl->skill_id), tick, 0); } break; case SC_ESCAPE: @@ -3360,7 +3360,7 @@ int skill_timerskill(int tid, int64 tick, int id, intptr_t data) { break; case RK_HUNDREDSPEAR: if(src->type == BL_PC) { - int skill_lv = pc->checkskill((TBL_PC *)src, KN_SPEARBOOMERANG); + int skill_lv = pc->checkskill((struct map_session_data *)src, KN_SPEARBOOMERANG); if(skill_lv > 0) skill->attack(BF_WEAPON, src, src, target, KN_SPEARBOOMERANG, skill_lv, tick, skl->flag); } else @@ -11827,7 +11827,7 @@ void skill_unit_onplace_unknown(struct skill_unit *src, struct block_list *bl, i int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int64 tick) { struct skill_unit_group *sg; struct block_list *ss; - TBL_PC* tsd; + struct map_session_data *tsd; struct status_data *tstatus, *bst; struct status_change *tsc, *ssc; struct skill_unit_group_tickset *ts; @@ -12416,7 +12416,7 @@ int skill_unit_onplace_timer(struct skill_unit *src, struct block_list *bl, int6 break; case UNT_DEMONIC_FIRE: { - TBL_PC* sd = BL_CAST(BL_PC, ss); + struct map_session_data *sd = BL_CAST(BL_PC, ss); switch( sg->val2 ) { case 1: case 2: @@ -15574,7 +15574,7 @@ int skill_greed (struct block_list *bl, va_list ap) { nullpo_ret(src = va_arg(ap, struct block_list *)); if(src->type == BL_PC && bl->type==BL_ITEM ) - pc->takeitem(((TBL_PC*)src), ((TBL_ITEM*)bl)); + pc->takeitem((struct map_session_data *)src, (struct flooritem_data *)bl); return 0; } @@ -15918,8 +15918,9 @@ bool skill_can_cloak(struct map_session_data *sd) { * Verifies if an user can still be cloaked (AS_CLOAKING) * Is called via map->foreachinrange when any kind of wall disapears **/ -int skill_check_cloaking_end(struct block_list *bl, va_list ap) { - TBL_PC *sd = BL_CAST(BL_PC, bl); +int skill_check_cloaking_end(struct block_list *bl, va_list ap) +{ + struct map_session_data *sd = BL_CAST(BL_PC, bl); if (sd && sd->sc.data[SC_CLOAKING] && !skill->can_cloak(sd)) status_change_end(bl, SC_CLOAKING, INVALID_TIMER); @@ -15972,7 +15973,7 @@ bool skill_check_shadowform(struct block_list *bl, int64 damage, int hit) if( src && (status->isdead(src) || !battle->check_target(bl,src,BCT_ENEMY)) ){ if( src->type == BL_PC ) - ((TBL_PC*)src)->shadowform_id = 0; + ((struct map_session_data *)src)->shadowform_id = 0; status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER); return false; } @@ -15983,7 +15984,7 @@ bool skill_check_shadowform(struct block_list *bl, int64 damage, int hit) if( sc->data[SC__SHADOWFORM] && (--sc->data[SC__SHADOWFORM]->val3) <= 0 ) { status_change_end(bl, SC__SHADOWFORM, INVALID_TIMER); if( src->type == BL_PC ) - ((TBL_PC*)src)->shadowform_id = 0; + ((struct map_session_data *)src)->shadowform_id = 0; } return true; } @@ -16224,7 +16225,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin return 0; } - if( src->type == BL_PC && !status->isdead(src) && ((TBL_PC*)src)->state.warping && !((TBL_PC*)src)->state.changemap ) { + if (src->type == BL_PC && !status->isdead(src) && ((struct map_session_data *)src)->state.warping && !((struct map_session_data *)src)->state.changemap) { switch( group->skill_id ) { case BA_DISSONANCE: case BA_POEMBRAGI: @@ -16236,7 +16237,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin case DC_DONTFORGETME: case DC_FORTUNEKISS: case DC_SERVICEFORYOU: - skill->usave_add(((TBL_PC*)src), group->skill_id, group->skill_lv); + skill->usave_add((struct map_session_data *)src, group->skill_id, group->skill_lv); break; } } @@ -16302,7 +16303,7 @@ int skill_delunitgroup(struct skill_unit_group *group, const char* file, int lin } if (src->type==BL_PC && group->state.ammo_consume) - battle->consume_ammo((TBL_PC*)src, group->skill_id, group->skill_lv); + battle->consume_ammo((struct map_session_data *)src, group->skill_id, group->skill_lv); group->alive_count=0; @@ -17608,8 +17609,8 @@ void skill_toggle_magicpower(struct block_list *bl, uint16 skill_id) { status_calc_bl(bl, status->sc2scb_flag(SC_MAGICPOWER)); #ifndef RENEWAL if(bl->type == BL_PC){// update current display. - clif->updatestatus(((TBL_PC *)bl),SP_MATK1); - clif->updatestatus(((TBL_PC *)bl),SP_MATK2); + clif->updatestatus((struct map_session_data *)bl, SP_MATK1); + clif->updatestatus((struct map_session_data *)bl, SP_MATK2); } #endif } @@ -19106,7 +19107,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 = (TBL_PC*)mapit->first(iter); mapit->exists(iter); sd = (TBL_PC*)mapit->next(iter) ) + for (sd = (struct map_session_data *)mapit->first(iter); mapit->exists(iter); sd = (struct map_session_data *)mapit->next(iter)) clif->skillinfoblock(sd); mapit->free(iter); diff --git a/src/map/status.c b/src/map/status.c index e96b881dd..4bbeed290 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1351,8 +1351,12 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, if (src && (sce = sc->data[SC_DEVOTION]) != NULL) { struct block_list *d_bl = map->id2bl(sce->val1); - if(d_bl &&((d_bl->type == BL_MER && ((TBL_MER *)d_bl)->master && ((TBL_MER *)d_bl)->master->bl.id == target->id) - || (d_bl->type == BL_PC && ((TBL_PC *)d_bl)->devotion[sce->val2] == target->id)) && check_distance_bl(target, d_bl, sce->val3)) { + if (d_bl != NULL + && ((d_bl->type == BL_MER && ((TBL_MER *)d_bl)->master && ((TBL_MER *)d_bl)->master->bl.id == target->id) + || (d_bl->type == BL_PC && ((struct map_session_data *)d_bl)->devotion[sce->val2] == target->id) + ) + && check_distance_bl(target, d_bl, sce->val3) + ) { clif->damage(d_bl, d_bl, 0, 0, hp, 0, BDT_NORMAL, 0); status_fix_damage(NULL, d_bl, hp, 0); return 0; @@ -1412,14 +1416,15 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, } switch (target->type) { - case BL_PC: pc->damage((TBL_PC*)target,src,hp,sp); break; + case BL_PC: pc->damage((struct map_session_data *)target, src, hp, sp); break; case BL_MOB: mob->damage((TBL_MOB*)target, src, hp); break; case BL_HOM: homun->damaged((TBL_HOM*)target); break; case BL_MER: mercenary->heal((TBL_MER*)target,hp,sp); break; case BL_ELEM: elemental->heal((TBL_ELEM*)target,hp,sp); break; } - if( src && target->type == BL_PC && (((TBL_PC*)target)->disguise) > 0 ) {// stop walking when attacked in disguise to prevent walk-delay bug + if (src != NULL && target->type == BL_PC && ((struct map_session_data *)target)->disguise > 0) { + // stop walking when attacked in disguise to prevent walk-delay bug unit->stop_walking(target, STOPWALKING_FLAG_FIXPOS); } @@ -1437,7 +1442,7 @@ int status_damage(struct block_list *src,struct block_list *target,int64 in_hp, //&2: Also remove object from map. //&4: Also delete object from memory. switch (target->type) { - case BL_PC: flag = pc->dead((TBL_PC*)target,src); break; + case BL_PC: flag = pc->dead((struct map_session_data *)target, src); break; case BL_MOB: flag = mob->dead((TBL_MOB*)target, src, (flag&4) ? 3 : 0); break; case BL_HOM: flag = homun->dead((TBL_HOM*)target); break; case BL_MER: flag = mercenary->dead((TBL_MER*)target); break; @@ -1577,7 +1582,7 @@ int status_heal(struct block_list *bl,int64 in_hp,int64 in_sp, int flag) { // send hp update to client switch(bl->type) { - case BL_PC: pc->heal((TBL_PC*)bl,hp,sp,(flag&2) ? 1 : 0); break; + case BL_PC: pc->heal((struct map_session_data *)bl,hp,sp,(flag&2) ? 1 : 0); break; case BL_MOB: mob->heal((TBL_MOB*)bl,hp); break; case BL_HOM: homun->healed((TBL_HOM*)bl); break; case BL_MER: mercenary->heal((TBL_MER*)bl,hp,sp); break; @@ -1674,7 +1679,7 @@ int status_revive(struct block_list *bl, unsigned char per_hp, unsigned char per clif->resurrection(bl, 1); switch (bl->type) { - case BL_PC: pc->revive((TBL_PC*)bl, hp, sp); break; + case BL_PC: pc->revive((struct map_session_data *)bl, hp, sp); break; case BL_MOB: mob->revive((TBL_MOB*)bl, hp); break; case BL_HOM: homun->revive((TBL_HOM*)bl, hp, sp); break; } @@ -1709,7 +1714,7 @@ int status_fixed_revive(struct block_list *bl, unsigned int per_hp, unsigned int if (bl->prev) //Animation only if character is already on a map. clif->resurrection(bl, 1); switch (bl->type) { - case BL_PC: pc->revive((TBL_PC*)bl, hp, sp); break; + case BL_PC: pc->revive((struct map_session_data *)bl, hp, sp); break; case BL_MOB: mob->revive((TBL_MOB*)bl, hp); break; case BL_HOM: homun->revive((TBL_HOM*)bl, hp, sp); break; } @@ -1750,13 +1755,14 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin if( skill_id ) { - if( src && !(src->type == BL_PC && ((TBL_PC*)src)->skillitem)) { // Items that cast skills using 'itemskill' will not be handled by map_zone_db. + if (src != NULL && !(src->type == BL_PC && ((struct map_session_data *)src)->skillitem)) { + // Items that cast skills using 'itemskill' will not be handled by map_zone_db. int i; for(i = 0; i < map->list[src->m].zone->disabled_skills_count; i++) { if( skill_id == map->list[src->m].zone->disabled_skills[i]->nameid && (map->list[src->m].zone->disabled_skills[i]->type&src->type) ) { if (src->type == BL_PC) { - clif->msgtable((TBL_PC*)src, MSG_SKILL_CANT_USE_AREA); // This skill cannot be used within this area + clif->msgtable((struct map_session_data *)src, MSG_SKILL_CANT_USE_AREA); // This skill cannot be used within this area } else if (src->type == BL_MOB && map->list[src->m].zone->disabled_skills[i]->subtype != MZS_NONE) { if( st->mode&MD_BOSS ) { /* is boss */ if( !( map->list[src->m].zone->disabled_skills[i]->subtype&MZS_BOSS ) ) @@ -1786,9 +1792,10 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin break; case AL_TELEPORT: //Should fail when used on top of Land Protector [Skotlex] - if (src && map->getcell(src->m, src, src->x, src->y, CELL_CHKLANDPROTECTOR) - && !(st->mode&MD_BOSS) - && (src->type != BL_PC || ((TBL_PC*)src)->skillitem != skill_id)) + if (src != NULL + && map->getcell(src->m, src, src->x, src->y, CELL_CHKLANDPROTECTOR) + && !(st->mode&MD_BOSS) + && (src->type != BL_PC || ((struct map_session_data *)src)->skillitem != skill_id)) return 0; break; default: @@ -1838,9 +1845,9 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin } if (sc->data[SC_DANCING] && flag!=2) { - if( src->type == BL_PC && skill_id >= WA_SWING_DANCE && skill_id <= WM_UNLIMITED_HUMMING_VOICE ) - { // Lvl 5 Lesson or higher allow you use 3rd job skills while dancing.v - if( pc->checkskill((TBL_PC*)src,WM_LESSON) < 5 ) + if (src->type == BL_PC && skill_id >= WA_SWING_DANCE && skill_id <= WM_UNLIMITED_HUMMING_VOICE) { + // Lvl 5 Lesson or higher allow you use 3rd job skills while dancing.v + if (pc->checkskill((struct map_session_data *)src, WM_LESSON) < 5) return 0; } else if(sc->data[SC_LONGING]) { //Allow everything except dancing/re-dancing. [Skotlex] if (skill_id == BD_ENCORE || @@ -1862,8 +1869,8 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin return 0; //Can't amp out of Wand of Hermode :/ [Skotlex] } - if (skill_id && //Do not block item-casted skills. - (src->type != BL_PC || ((TBL_PC*)src)->skillitem != skill_id) + if (skill_id != 0 //Do not block item-casted skills. + && (src->type != BL_PC || ((struct map_session_data *)src)->skillitem != skill_id) ) { //Skills blocked through status changes... if (!flag && ( //Blocked only from using the skill (stuff like autospell may still go through @@ -1963,23 +1970,26 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin hide_flag &= ~OPTION_HIDE; switch( target->type ) { - case BL_PC: { - struct map_session_data *sd = (TBL_PC*) target; - bool is_boss = (st->mode&MD_BOSS); - bool is_detect = ((st->mode&MD_DETECTOR)?true:false);//god-knows-why gcc doesn't shut up until this happens - if (pc_isinvisible(sd)) + case BL_PC: + { + struct map_session_data *sd = (struct map_session_data *)target; + bool is_boss = (st->mode&MD_BOSS); + bool is_detect = ((st->mode&MD_DETECTOR)?true:false);//god-knows-why gcc doesn't shut up until this happens + if (pc_isinvisible(sd)) + return 0; + if (tsc != NULL) { + if (tsc->option&hide_flag + && !is_boss + && ((sd->special_state.perfect_hiding || !is_detect) + || (tsc->data[SC_CLOAKINGEXCEED] != NULL && is_detect) + )) + return 0; + if (tsc->data[SC_CAMOUFLAGE] && !(is_boss || is_detect) && (!skill_id || (flag == 0 && src && src->type != BL_PC))) + return 0; + if (tsc->data[SC_STEALTHFIELD] && !is_boss) return 0; - if( tsc ) { - if (tsc->option&hide_flag && !is_boss && - ((sd->special_state.perfect_hiding || !is_detect) || - (tsc->data[SC_CLOAKINGEXCEED] && is_detect))) - return 0; - if( tsc->data[SC_CAMOUFLAGE] && !(is_boss || is_detect) && (!skill_id || (flag == 0 && src && src->type != BL_PC)) ) - return 0; - if( tsc->data[SC_STEALTHFIELD] && !is_boss ) - return 0; - } } + } break; case BL_ITEM: //Allow targeting of items to pick'em up (or in the case of mobs, to loot them). @@ -3492,10 +3502,17 @@ void status_calc_regen_rate(struct block_list *bl, struct regen_data *regen, str ) regen->flag = 0; //No regen - if ( sc->data[SC_DANCING] || sc->data[SC_OBLIVIONCURSE] || sc->data[SC_MAXIMIZEPOWER] || sc->data[SC_REBOUND] - || ( bl->type == BL_PC && (((TBL_PC*)bl)->class_&MAPID_UPPERMASK) == MAPID_MONK - && (sc->data[SC_EXTREMITYFIST] || (sc->data[SC_EXPLOSIONSPIRITS] && (!sc->data[SC_SOULLINK] || sc->data[SC_SOULLINK]->val2 != SL_MONK))) + if (sc->data[SC_DANCING] != NULL + || sc->data[SC_OBLIVIONCURSE] != NULL + || sc->data[SC_MAXIMIZEPOWER] != NULL + || sc->data[SC_REBOUND] != NULL + || (bl->type == BL_PC && (((struct map_session_data *)bl)->class_&MAPID_UPPERMASK) == MAPID_MONK + && (sc->data[SC_EXTREMITYFIST] != NULL + || (sc->data[SC_EXPLOSIONSPIRITS] != NULL + && (sc->data[SC_SOULLINK] == NULL || sc->data[SC_SOULLINK]->val2 != SL_MONK) ) + ) + ) ) { regen->flag &=~RGN_SP; //No natural SP regen } @@ -3548,7 +3565,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { const struct status_data *bst = status->get_base_status(bl); struct status_data *st = status->get_status_data(bl); struct status_change *sc = status->get_sc(bl); - TBL_PC *sd = BL_CAST(BL_PC,bl); + struct map_session_data *sd = BL_CAST(BL_PC,bl); int temp; if (!bst || !st) @@ -3754,7 +3771,7 @@ void status_calc_bl_main(struct block_list *bl, /*enum scb_flag*/int flag) { else st->cri = status->calc_critical(bl, sc, bst->cri + 3*(st->luk - bst->luk), true); } - if (battle_config.show_katar_crit_bonus && bl->type == BL_PC && ((TBL_PC*)bl)->status.weapon == W_KATAR) + if (battle_config.show_katar_crit_bonus && bl->type == BL_PC && ((struct map_session_data *)bl)->status.weapon == W_KATAR) st->cri <<= 1; if(flag&SCB_FLEE2 && bst->flee2) { @@ -3922,11 +3939,11 @@ void status_calc_bl_(struct block_list *bl, enum scb_flag flag, enum e_status_ca struct status_data bst; // previous battle status struct status_data *st; // pointer to current battle status - if( bl->type == BL_PC && ((TBL_PC*)bl)->delayed_damage != 0 ) { - if( opt&SCO_FORCE ) - ((TBL_PC*)bl)->state.hold_recalc = 0;/* clear and move on */ - else { - ((TBL_PC*)bl)->state.hold_recalc = 1;/* flag and stop */ + if (bl->type == BL_PC && ((struct map_session_data *)bl)->delayed_damage != 0) { + if (opt&SCO_FORCE) { + ((struct map_session_data *)bl)->state.hold_recalc = 0;/* clear and move on */ + } else { + ((struct map_session_data *)bl)->state.hold_recalc = 1;/* flag and stop */ return; } } @@ -3964,7 +3981,7 @@ void status_calc_bl_(struct block_list *bl, enum scb_flag flag, enum e_status_ca // compare against new values and send client updates if( bl->type == BL_PC ) { - TBL_PC* sd = BL_CAST(BL_PC, bl); + struct map_session_data *sd = BL_CAST(BL_PC, bl); if(bst.str != st->str) clif->updatestatus(sd,SP_STR); if(bst.agi != st->agi) @@ -4125,8 +4142,13 @@ int status_check_visibility(struct block_list *src, struct block_list *target) { case BL_PC: if ( tsc->data[SC_CLOAKINGEXCEED] && !(st->mode&MD_BOSS) ) return 0; - if ( (tsc->option&(OPTION_HIDE | OPTION_CLOAK | OPTION_CHASEWALK) || tsc->data[SC_STEALTHFIELD] || tsc->data[SC__INVISIBILITY] || tsc->data[SC_CAMOUFLAGE]) && !(st->mode&MD_BOSS) && - (((TBL_PC*)target)->special_state.perfect_hiding || !(st->mode&MD_DETECTOR)) ) + if ((tsc->option&(OPTION_HIDE | OPTION_CLOAK | OPTION_CHASEWALK) + || tsc->data[SC_STEALTHFIELD] != NULL + || tsc->data[SC__INVISIBILITY] != NULL + || tsc->data[SC_CAMOUFLAGE] != NULL + ) + && !(st->mode&MD_BOSS) + && (((struct map_session_data *)target)->special_state.perfect_hiding || !(st->mode&MD_DETECTOR))) return 0; break; default: @@ -4193,7 +4215,7 @@ unsigned short status_base_atk(const struct block_list *bl, const struct status_ return 0; if ( bl->type == BL_PC ) - switch ( ((TBL_PC*)bl)->status.weapon ) { + switch (((struct map_session_data *)bl)->status.weapon) { case W_BOW: case W_MUSICAL: case W_WHIP: @@ -4229,7 +4251,7 @@ unsigned short status_base_atk(const struct block_list *bl, const struct status_ #endif if ( bl->type == BL_PC ) #ifdef RENEWAL - str = (int)(dstr + (float)dex / 5 + (float)st->luk / 3 + (float)((TBL_PC*)bl)->status.base_level / 4); + str = (int)(dstr + (float)dex / 5 + (float)st->luk / 3 + (float)((struct map_session_data *)bl)->status.base_level / 4); else if ( bl->type == BL_MOB || bl->type == BL_MER ) str = dstr + ((TBL_MOB*)bl)->level; #else @@ -4833,10 +4855,10 @@ unsigned short status_calc_watk(struct block_list *bl, struct status_change *sc, #ifndef RENEWAL if(sc->data[SC_NIBELUNGEN]) { - if (bl->type != BL_PC) + if (bl->type != BL_PC) { watk += sc->data[SC_NIBELUNGEN]->val2; - else { - TBL_PC *sd = (TBL_PC*)bl; + } else { + struct map_session_data *sd = (struct map_session_data *)bl; int index = sd->equip_index[sd->state.lr_flag?EQI_HAND_L:EQI_HAND_R]; if(index >= 0 && sd->inventory_data[index] && sd->inventory_data[index]->wlv == 4) watk += sc->data[SC_NIBELUNGEN]->val2; @@ -5469,7 +5491,7 @@ signed short status_calc_mdef2(struct block_list *bl, struct status_change *sc, unsigned short status_calc_speed(struct block_list *bl, struct status_change *sc, int speed) { - TBL_PC* sd = BL_CAST(BL_PC, bl); + struct map_session_data *sd = BL_CAST(BL_PC, bl); int speed_rate; if( sc == NULL || ( sd && sd->state.permanent_speed ) ) @@ -5701,8 +5723,7 @@ short status_calc_aspd(struct block_list *bl, struct status_change *sc, short fl if (bl->type!=BL_PC) bonus = sc->data[SC_ASSNCROS]->val2; else { - switch (((TBL_PC*)bl)->status.weapon) - { + switch (((struct map_session_data *)bl)->status.weapon) { case W_BOW: case W_REVOLVER: case W_RIFLE: @@ -5802,7 +5823,7 @@ short status_calc_fix_aspd(struct block_list *bl, struct status_change *sc, int || sc->data[SC_WILD_STORM_OPTION])) aspd -= 50; // +5 ASPD if (sc->data[SC_FIGHTINGSPIRIT] && sc->data[SC_FIGHTINGSPIRIT]->val2) - aspd -= (bl->type==BL_PC?pc->checkskill((TBL_PC *)bl, RK_RUNEMASTERY):10) / 10 * 40; + aspd -= (bl->type == BL_PC ? pc->checkskill((struct map_session_data *)bl, RK_RUNEMASTERY) : 10) / 10 * 40; if (sc->data[SC_MTF_ASPD]) aspd -= sc->data[SC_MTF_ASPD]->val1; @@ -5857,14 +5878,11 @@ short status_calc_aspd_rate(struct block_list *bl, struct status_change *sc, int max < sc->data[SC_HLIF_FLEET]->val2) max = sc->data[SC_HLIF_FLEET]->val2; - if(sc->data[SC_ASSNCROS] && - max < sc->data[SC_ASSNCROS]->val2) - { - if (bl->type!=BL_PC) + if (sc->data[SC_ASSNCROS] && max < sc->data[SC_ASSNCROS]->val2) { + if (bl->type!=BL_PC) { max = sc->data[SC_ASSNCROS]->val2; - else - switch(((TBL_PC*)bl)->status.weapon) - { + } else { + switch (((struct map_session_data *)bl)->status.weapon) { case W_BOW: case W_REVOLVER: case W_RIFLE: @@ -5874,6 +5892,7 @@ short status_calc_aspd_rate(struct block_list *bl, struct status_change *sc, int break; default: max = sc->data[SC_ASSNCROS]->val2; + } } } @@ -6186,7 +6205,7 @@ unsigned short status_calc_mode(struct block_list *bl, struct status_change *sc, const char* status_get_name(struct block_list *bl) { nullpo_ret(bl); switch (bl->type) { - case BL_PC: return ((TBL_PC *)bl)->fakename[0] != '\0' ? ((TBL_PC*)bl)->fakename : ((TBL_PC*)bl)->status.name; + case BL_PC: return ((struct map_session_data *)bl)->fakename[0] != '\0' ? ((struct map_session_data *)bl)->fakename : ((struct map_session_data *)bl)->status.name; case BL_MOB: return ((TBL_MOB*)bl)->name; case BL_PET: return ((TBL_PET*)bl)->pet.name; case BL_HOM: return ((TBL_HOM*)bl)->homunculus.name; @@ -6204,7 +6223,7 @@ const char* status_get_name(struct block_list *bl) { int status_get_class(struct block_list *bl) { nullpo_ret(bl); switch( bl->type ) { - case BL_PC: return ((TBL_PC*)bl)->status.class_; + case BL_PC: return ((struct map_session_data *)bl)->status.class_; case BL_MOB: return ((TBL_MOB*)bl)->vd->class_; //Class used on all code should be the view class of the mob. case BL_PET: return ((TBL_PET*)bl)->pet.class_; case BL_HOM: return ((TBL_HOM*)bl)->homunculus.class_; @@ -6223,7 +6242,7 @@ int status_get_class(struct block_list *bl) { int status_get_lv(struct block_list *bl) { nullpo_ret(bl); switch (bl->type) { - case BL_PC: return ((TBL_PC*)bl)->status.base_level; + case BL_PC: return ((struct map_session_data *)bl)->status.base_level; case BL_MOB: return ((TBL_MOB*)bl)->level; case BL_PET: return ((TBL_PET*)bl)->pet.level; case BL_HOM: return ((TBL_HOM*)bl)->homunculus.level; @@ -6238,7 +6257,7 @@ struct regen_data *status_get_regen_data(struct block_list *bl) { nullpo_retr(NULL, bl); switch (bl->type) { - case BL_PC: return &((TBL_PC*)bl)->regen; + case BL_PC: return &((struct map_session_data *)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; @@ -6252,7 +6271,7 @@ struct status_data *status_get_status_data(struct block_list *bl) nullpo_retr(&status->dummy, bl); switch (bl->type) { - case BL_PC: return &((TBL_PC*)bl)->battle_status; + case BL_PC: return &((struct map_session_data *)bl)->battle_status; case BL_MOB: return &((TBL_MOB*)bl)->status; case BL_PET: return &((TBL_PET*)bl)->status; case BL_HOM: return &((TBL_HOM*)bl)->battle_status; @@ -6268,7 +6287,7 @@ struct status_data *status_get_base_status(struct block_list *bl) { nullpo_retr(NULL, bl); switch (bl->type) { - case BL_PC: return &((TBL_PC*)bl)->base_status; + case BL_PC: return &((struct map_session_data *)bl)->base_status; case BL_MOB: return ((TBL_MOB*)bl)->base_status ? ((TBL_MOB*)bl)->base_status : &((TBL_MOB*)bl)->db->status; case BL_PET: return &((TBL_PET*)bl)->db->status; case BL_HOM: return &((TBL_HOM*)bl)->base_status; @@ -6300,7 +6319,7 @@ int status_get_party_id(struct block_list *bl) { nullpo_ret(bl); switch (bl->type) { case BL_PC: - return ((TBL_PC*)bl)->status.party_id; + return ((struct map_session_data *)bl)->status.party_id; case BL_PET: if (((TBL_PET*)bl)->msd) return ((TBL_PET*)bl)->msd->status.party_id; @@ -6339,7 +6358,7 @@ int status_get_guild_id(struct block_list *bl) { nullpo_ret(bl); switch (bl->type) { case BL_PC: - return ((TBL_PC*)bl)->status.guild_id; + return ((struct map_session_data *)bl)->status.guild_id; case BL_PET: if (((TBL_PET*)bl)->msd) return ((TBL_PET*)bl)->msd->status.guild_id; @@ -6384,7 +6403,7 @@ int status_get_emblem_id(struct block_list *bl) { nullpo_ret(bl); switch (bl->type) { case BL_PC: - return ((TBL_PC*)bl)->guild_emblem_id; + return ((struct map_session_data *)bl)->guild_emblem_id; case BL_PET: if (((TBL_PET*)bl)->msd) return ((TBL_PET*)bl)->msd->guild_emblem_id; @@ -6450,9 +6469,8 @@ int status_isimmune(struct block_list *bl) { if (sc && sc->data[SC_HERMODE]) return 100; - if (bl->type == BL_PC && - ((TBL_PC*)bl)->special_state.no_magic_damage >= battle_config.gtb_sc_immunity) - return ((TBL_PC*)bl)->special_state.no_magic_damage; + if (bl->type == BL_PC && ((struct map_session_data *)bl)->special_state.no_magic_damage >= battle_config.gtb_sc_immunity) + return ((struct map_session_data *)bl)->special_state.no_magic_damage; return 0; } @@ -6460,7 +6478,7 @@ struct view_data* status_get_viewdata(struct block_list *bl) { nullpo_retr(NULL, bl); switch (bl->type) { - case BL_PC: return &((TBL_PC*)bl)->vd; + case BL_PC: return &((struct map_session_data *)bl)->vd; case BL_MOB: return ((TBL_MOB*)bl)->vd; case BL_PET: return &((TBL_PET*)bl)->vd; case BL_NPC: return ((TBL_NPC*)bl)->vd; @@ -6490,66 +6508,69 @@ void status_set_viewdata(struct block_list *bl, int class_) switch (bl->type) { case BL_PC: - { - TBL_PC* sd = (TBL_PC*)bl; - if (pc->db_checkid(class_)) { - if (pc_isridingpeco(sd)) { - switch (class_) { - //Adapt class to a Mounted one. - case JOB_KNIGHT: - class_ = JOB_KNIGHT2; - break; - case JOB_CRUSADER: - class_ = JOB_CRUSADER2; - break; - case JOB_LORD_KNIGHT: - class_ = JOB_LORD_KNIGHT2; - break; - case JOB_PALADIN: - class_ = JOB_PALADIN2; - break; - case JOB_BABY_KNIGHT: - class_ = JOB_BABY_KNIGHT2; - break; - case JOB_BABY_CRUSADER: - class_ = JOB_BABY_CRUSADER2; - break; - } - } - sd->vd.class_ = class_; - clif->get_weapon_view(sd, &sd->vd.weapon, &sd->vd.shield); - sd->vd.head_top = sd->status.head_top; - sd->vd.head_mid = sd->status.head_mid; - sd->vd.head_bottom = sd->status.head_bottom; - sd->vd.hair_style = cap_value(sd->status.hair,0,battle_config.max_hair_style); - sd->vd.hair_color = cap_value(sd->status.hair_color,0,battle_config.max_hair_color); - sd->vd.cloth_color = cap_value(sd->status.clothes_color,0,battle_config.max_cloth_color); - sd->vd.robe = sd->status.robe; - sd->vd.body_style = sd->status.body; - sd->vd.sex = sd->status.sex; - - if ( sd->vd.cloth_color ) { - if( sd->sc.option&OPTION_WEDDING && battle_config.wedding_ignorepalette ) - sd->vd.cloth_color = 0; - if( sd->sc.option&OPTION_XMAS && battle_config.xmas_ignorepalette ) - sd->vd.cloth_color = 0; - if( sd->sc.option&OPTION_SUMMER && battle_config.summer_ignorepalette ) - sd->vd.cloth_color = 0; - if( sd->sc.option&OPTION_HANBOK && battle_config.hanbok_ignorepalette ) - sd->vd.cloth_color = 0; - if( sd->sc.option&OPTION_OKTOBERFEST /* TODO: config? */ ) - sd->vd.cloth_color = 0; + { + struct map_session_data *sd = (struct map_session_data *)bl; + if (pc->db_checkid(class_)) { + if (pc_isridingpeco(sd)) { + switch (class_) { + //Adapt class to a Mounted one. + case JOB_KNIGHT: + class_ = JOB_KNIGHT2; + break; + case JOB_CRUSADER: + class_ = JOB_CRUSADER2; + break; + case JOB_LORD_KNIGHT: + class_ = JOB_LORD_KNIGHT2; + break; + case JOB_PALADIN: + class_ = JOB_PALADIN2; + break; + case JOB_BABY_KNIGHT: + class_ = JOB_BABY_KNIGHT2; + break; + case JOB_BABY_CRUSADER: + class_ = JOB_BABY_CRUSADER2; + break; } - if ( sd->vd.body_style && ( - sd->sc.option&OPTION_WEDDING || sd->sc.option&OPTION_XMAS || - sd->sc.option&OPTION_SUMMER || sd->sc.option&OPTION_HANBOK || - sd->sc.option&OPTION_OKTOBERFEST)) - sd->vd.body_style = 0; - } else if (vd) - memcpy(&sd->vd, vd, sizeof(struct view_data)); - else - ShowError("status_set_viewdata (PC): No view data for class %d\n", class_); + } + sd->vd.class_ = class_; + clif->get_weapon_view(sd, &sd->vd.weapon, &sd->vd.shield); + sd->vd.head_top = sd->status.head_top; + sd->vd.head_mid = sd->status.head_mid; + sd->vd.head_bottom = sd->status.head_bottom; + sd->vd.hair_style = cap_value(sd->status.hair,0,battle_config.max_hair_style); + sd->vd.hair_color = cap_value(sd->status.hair_color,0,battle_config.max_hair_color); + sd->vd.cloth_color = cap_value(sd->status.clothes_color,0,battle_config.max_cloth_color); + sd->vd.robe = sd->status.robe; + sd->vd.body_style = sd->status.body; + sd->vd.sex = sd->status.sex; + + if (sd->vd.cloth_color) { + if (sd->sc.option&OPTION_WEDDING && battle_config.wedding_ignorepalette) + sd->vd.cloth_color = 0; + if (sd->sc.option&OPTION_XMAS && battle_config.xmas_ignorepalette) + sd->vd.cloth_color = 0; + if (sd->sc.option&OPTION_SUMMER && battle_config.summer_ignorepalette) + sd->vd.cloth_color = 0; + if (sd->sc.option&OPTION_HANBOK && battle_config.hanbok_ignorepalette) + sd->vd.cloth_color = 0; + if (sd->sc.option&OPTION_OKTOBERFEST /* TODO: config? */) + sd->vd.cloth_color = 0; + } + if (sd->vd.body_style + && (sd->sc.option&OPTION_WEDDING + || sd->sc.option&OPTION_XMAS + || sd->sc.option&OPTION_SUMMER + || sd->sc.option&OPTION_HANBOK + || sd->sc.option&OPTION_OKTOBERFEST)) + sd->vd.body_style = 0; + } else if (vd != NULL) { + memcpy(&sd->vd, vd, sizeof(struct view_data)); + } else { + ShowError("status_set_viewdata (PC): No view data for class %d\n", class_); } + } break; case BL_MOB: { @@ -6620,7 +6641,7 @@ void status_set_viewdata(struct block_list *bl, int class_) struct status_change *status_get_sc(struct block_list *bl) { if( bl ) { switch (bl->type) { - case BL_PC: return &((TBL_PC*)bl)->sc; + case BL_PC: return &((struct map_session_data *)bl)->sc; case BL_MOB: return &((TBL_MOB*)bl)->sc; case BL_NPC: return NULL; case BL_HOM: return &((TBL_HOM*)bl)->sc; @@ -6876,13 +6897,13 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ sc_def = (st->vit + st->luk)*20; break; case SC_SIREN: - tick_def2 = (status->get_lv(bl) * 100) + ((bl->type == BL_PC)?((TBL_PC*)bl)->status.job_level : 0); + tick_def2 = status->get_lv(bl) * 100 + (bl->type == BL_PC ? ((struct map_session_data *)bl)->status.job_level : 0); break; case SC_NEEDLE_OF_PARALYZE: tick_def2 = (st->vit + st->luk) * 50; break; case SC_NETHERWORLD: - tick_def2 = 1000 * (((bl->type == BL_PC) ? ((TBL_PC*)bl)->status.job_level : 0) / 10 + status->get_lv(bl) / 50); + tick_def2 = 1000 * ((bl->type == BL_PC ? ((struct map_session_data *)bl)->status.job_level : 0) / 10 + status->get_lv(bl) / 50); break; default: //Effect that cannot be reduced? Likely a buff. @@ -10218,7 +10239,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const struct block_list *d_bl = map->id2bl(sce->val1); if( d_bl ) { if( d_bl->type == BL_PC ) - ((TBL_PC*)d_bl)->devotion[sce->val2] = 0; + ((struct map_session_data*)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); diff --git a/src/map/status.h b/src/map/status.h index 55df4cdab..180c36c72 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -2123,12 +2123,12 @@ struct status_change { #define status_get_size(bl) (status->get_status_data(bl)->size) #define status_get_mode(bl) (status->get_status_data(bl)->mode) -#define status_get_homstr(bl) (st->str + ((TBL_HOM*)bl)->homunculus.str_value) -#define status_get_homagi(bl) (st->agi + ((TBL_HOM*)bl)->homunculus.agi_value) -#define status_get_homvit(bl) (st->vit + ((TBL_HOM*)bl)->homunculus.vit_value) -#define status_get_homint(bl) (st->int_ + ((TBL_HOM*)bl)->homunculus.int_value) -#define status_get_homdex(bl) (st->dex + ((TBL_HOM*)bl)->homunculus.dex_value) -#define status_get_homluk(bl) (st->luk + ((TBL_HOM*)bl)->homunculus.luk_value) +#define status_get_homstr(bl) (st->str + ((struct homun_data *)bl)->homunculus.str_value) +#define status_get_homagi(bl) (st->agi + ((struct homun_data *)bl)->homunculus.agi_value) +#define status_get_homvit(bl) (st->vit + ((struct homun_data *)bl)->homunculus.vit_value) +#define status_get_homint(bl) (st->int_ + ((struct homun_data *)bl)->homunculus.int_value) +#define status_get_homdex(bl) (st->dex + ((struct homun_data *)bl)->homunculus.dex_value) +#define status_get_homluk(bl) (st->luk + ((struct homun_data *)bl)->homunculus.luk_value) //Short version, receives rate in 1->100 range, and does not uses a flag setting. #define sc_start(src, bl, type, rate, val1, tick) (status->change_start((src),(bl),(type),100*(rate),(val1),0,0,0,(tick),SCFLAG_NONE)) diff --git a/src/map/unit.c b/src/map/unit.c index 4c5254373..a9933d8b9 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -148,8 +148,8 @@ int unit_walktoxy_sub(struct block_list *bl) ud->state.change_walk_target=0; if (bl->type == BL_PC) { - ((TBL_PC *)bl)->head_dir = 0; - clif->walkok((TBL_PC*)bl); + ((struct map_session_data *)bl)->head_dir = 0; + clif->walkok((struct map_session_data *)bl); } clif->move(ud); @@ -813,7 +813,7 @@ int unit_setdir(struct block_list *bl,unsigned char dir) if (!ud) return 0; ud->dir = dir; if (bl->type == BL_PC) - ((TBL_PC *)bl)->head_dir = 0; + ((struct map_session_data *)bl)->head_dir = 0; clif->changed_dir(bl, AREA); return 0; } @@ -947,7 +947,7 @@ int unit_warp(struct block_list *bl,short m,short x,short y,clr_type type) } if (bl->type == BL_PC) //Use pc_setpos - return pc->setpos((TBL_PC*)bl, map_id2index(m), x, y, type); + return pc->setpos((struct map_session_data *)bl, map_id2index(m), x, y, type); if (!unit->remove_map(bl, type, ALC_MARK)) return 3; @@ -1137,7 +1137,7 @@ int unit_can_move(struct block_list *bl) { int unit_resume_running(int tid, int64 tick, int id, intptr_t data) { struct unit_data *ud = (struct unit_data *)data; - TBL_PC * sd = map->id2sd(id); + struct map_session_data *sd = map->id2sd(id); if(sd && pc_isridingwug(sd)) clif->skill_nodamage(ud->bl,ud->bl,RA_WUGDASH,ud->skill_lv, @@ -1873,7 +1873,7 @@ int unit_attack(struct block_list *src,int target_id,int continuous) { } if( src->type == BL_PC ) { - TBL_PC* sd = (TBL_PC*)src; + struct map_session_data *sd = (struct map_session_data *)src; if( target->type == BL_NPC ) { // monster npcs [Valaris] npc->click(sd,(TBL_NPC*)target); // submitted by leinsirk10 [Celest] return 0; @@ -2311,7 +2311,7 @@ int unit_changeviewsize(struct block_list *bl,short size) size=(size<0)?-1:(size>0)?1:0; if(bl->type == BL_PC) { - ((TBL_PC*)bl)->state.size=size; + ((struct map_session_data *)bl)->state.size = size; } else if(bl->type == BL_MOB) { ((TBL_MOB*)bl)->special_state.size=size; } else |