diff options
Diffstat (limited to 'src/map/clif.c')
-rw-r--r-- | src/map/clif.c | 806 |
1 files changed, 481 insertions, 325 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 0c5143ffd..39ffdd23d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -226,7 +226,6 @@ uint32 clif_refresh_ip(void) { } return 0; } - #if PACKETVER >= 20071106 static inline unsigned char clif_bl_type(struct block_list *bl) { switch (bl->type) { @@ -362,11 +361,11 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target clif->send (buf, len, bl, SELF); case AREA_WOC: case AREA_WOS: - map_foreachinarea(clif->send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE, + iMap->foreachinarea(clif->send_sub, bl->m, bl->x-AREA_SIZE, bl->y-AREA_SIZE, bl->x+AREA_SIZE, bl->y+AREA_SIZE, BL_PC, buf, len, bl, type); break; case AREA_CHAT_WOC: - map_foreachinarea(clif->send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5), + iMap->foreachinarea(clif->send_sub, bl->m, bl->x-(AREA_SIZE-5), bl->y-(AREA_SIZE-5), bl->x+(AREA_SIZE-5), bl->y+(AREA_SIZE-5), BL_PC, buf, len, bl, AREA_WOC); break; @@ -375,7 +374,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target { struct chat_data *cd; if (sd) { - cd = (struct chat_data*)map_id2bl(sd->chatID); + cd = (struct chat_data*)iMap->id2bl(sd->chatID); } else if (bl->type == BL_CHAT) { cd = (struct chat_data*)bl; } else break; @@ -404,7 +403,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target case PARTY_SAMEMAP: case PARTY_SAMEMAP_WOS: if (sd && sd->status.party_id) - p = party_search(sd->status.party_id); + p = iParty->search(sd->status.party_id); if (p) { for(i=0;i<MAX_PARTY;i++){ @@ -427,7 +426,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target memcpy(WFIFOP(fd,0), buf, len); WFIFOSET(fd,len); } - if (!enable_spy) //Skip unnecessary parsing. [Skotlex] + if (!iMap->enable_spy) //Skip unnecessary parsing. [Skotlex] break; iter = mapit_getallusers(); @@ -504,7 +503,7 @@ int clif_send(const void* buf, int len, struct block_list* bl, enum send_target WFIFOSET(fd,len); } } - if (!enable_spy) //Skip unnecessary parsing. [Skotlex] + if (!iMap->enable_spy) //Skip unnecessary parsing. [Skotlex] break; iter = mapit_getallusers(); @@ -562,7 +561,7 @@ void clif_authok(struct map_session_data *sd) struct packet_authok p; p.PacketType = authokType; - p.startTime = gettick(); + p.startTime = iTimer->gettick(); WBUFPOS(&p.PosDir[0],0,sd->bl.x,sd->bl.y,sd->ud.dir); /* do the stupid client math */ p.xSize = p.ySize = 5; /* not-used */ @@ -646,7 +645,7 @@ void clif_charselectok(int id, uint8 ok) struct map_session_data* sd; int fd; - if ((sd = map_id2sd(id)) == NULL || !sd->fd) + if ((sd = iMap->id2sd(id)) == NULL || !sd->fd) return; fd = sd->fd; @@ -764,7 +763,7 @@ void clif_clearunit_delayed(struct block_list* bl, clr_type type, unsigned int t { struct block_list *tbl = ers_alloc(clif->delay_clearunit_ers, struct block_list); memcpy (tbl, bl, sizeof (struct block_list)); - add_timer(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl); + iTimer->add_timer(tick, clif->clearunit_delayed_sub, (int)type, (intptr_t)tbl); } void clif_get_weapon_view(struct map_session_data* sd, unsigned short *rhand, unsigned short *lhand) @@ -850,7 +849,7 @@ void clif_set_unit_idle(struct block_list* bl, struct map_session_data *tsd, enu p.speed = status_get_speed(bl); p.bodyState = (sc) ? sc->opt1 : 0; p.healthState = (sc) ? sc->opt2 : 0; - p.effectState = (sc) ? sc->option : 0; + p.effectState = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0; p.job = vd->class_; p.head = vd->hair_style; p.weapon = vd->weapon; @@ -1092,7 +1091,7 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.speed = status_get_speed(bl); p.bodyState = (sc) ? sc->opt1 : 0; p.healthState = (sc) ? sc->opt2 : 0; - p.effectState = (sc) ? sc->option : 0; + p.effectState = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0; p.job = vd->class_; p.head = vd->hair_style; p.weapon = vd->weapon; @@ -1136,9 +1135,9 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.isBoss = 0; } #endif - clif->send(&p,sizeof(p),bl,target); - if( disguised(bl) ) { + if( sd->status.class_ != sd->disguise ) + clif->send(&p,sizeof(p),bl,target); #if PACKETVER >= 20071106 p.objecttype = pcdb_checkid(status_get_viewdata(bl)->class_) ? 0x0 : 0x5; //PC_TYPE : NPC_MOB_TYPE p.GID = -bl->id; @@ -1146,7 +1145,8 @@ void clif_spawn_unit(struct block_list* bl, enum send_target target) { p.GID = -bl->id; #endif clif->send(&p,sizeof(p),bl,SELF); - } + } else + clif->send(&p,sizeof(p),bl,target); } @@ -1171,12 +1171,12 @@ void clif_set_unit_walking(struct block_list* bl, struct map_session_data *tsd, p.speed = status_get_speed(bl); p.bodyState = (sc) ? sc->opt1 : 0; p.healthState = (sc) ? sc->opt2 : 0; - p.effectState = (sc) ? sc->option : 0; + p.effectState = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0; p.job = vd->class_; p.head = vd->hair_style; p.weapon = vd->weapon; p.accessory = vd->head_bottom; - p.moveStartTime = gettick(); + p.moveStartTime = iTimer->gettick(); #if PACKETVER < 7 p.shield = vd->shield; #endif @@ -1332,7 +1332,7 @@ int clif_spawn(struct block_list *bl) /** * Hide NPC from maya purple card. **/ - if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE)) + if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->option&OPTION_INVISIBLE)) return 0; clif->spawn_unit(bl,AREA_WOS); @@ -1554,7 +1554,7 @@ void clif_walkok(struct map_session_data *sd) WFIFOHEAD(fd, packet_len(0x87)); WFIFOW(fd,0)=0x87; - WFIFOL(fd,2)=gettick(); + WFIFOL(fd,2)=iTimer->gettick(); WFIFOPOS2(fd,6,sd->bl.x,sd->bl.y,sd->ud.to_x,sd->ud.to_y,8,8); WFIFOSET(fd,packet_len(0x87)); } @@ -1611,7 +1611,7 @@ void clif_move(struct unit_data *ud) /** * Hide NPC from maya purple card. **/ - if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE)) + if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->option&OPTION_INVISIBLE)) return; if (ud->state.speed_changed) { @@ -1625,10 +1625,9 @@ void clif_move(struct unit_data *ud) WBUFW(buf,0)=0x86; WBUFL(buf,2)=bl->id; WBUFPOS2(buf,6,bl->x,bl->y,ud->to_x,ud->to_y,8,8); - WBUFL(buf,12)=gettick(); + WBUFL(buf,12)=iTimer->gettick(); clif->send(buf, packet_len(0x86), bl, AREA_WOS); - if (disguised(bl)) - { + if (disguised(bl)) { WBUFL(buf,2)=-bl->id; clif->send(buf, packet_len(0x86), bl, SELF); } @@ -1636,14 +1635,14 @@ void clif_move(struct unit_data *ud) /*========================================== - * Delays the map_quit of a player after they are disconnected. [Skotlex] + * Delays the iMap->quit of a player after they are disconnected. [Skotlex] *------------------------------------------*/ int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data *sd = NULL; //Remove player from map server - if ((sd = map_id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player. - map_quit(sd); + if ((sd = iMap->id2sd(id)) != NULL && sd->fd == 0) //Should be a disconnected player. + iMap->quit(sd); return 0; } @@ -1652,28 +1651,27 @@ int clif_delayquit(int tid, unsigned int tick, int id, intptr_t data) { *------------------------------------------*/ void clif_quitsave(int fd,struct map_session_data *sd) { if (!battle_config.prevent_logout || - DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) - map_quit(sd); + DIFF_TICK(iTimer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) + iMap->quit(sd); else if (sd->fd) { //Disassociate session from player (session is deleted after this function was called) //And set a timer to make him quit later. session[sd->fd]->session_data = NULL; sd->fd = 0; - add_timer(gettick() + 10000, clif->delayquit, sd->bl.id, 0); + iTimer->add_timer(iTimer->gettick() + 10000, clif->delayquit, sd->bl.id, 0); } } /// Notifies the client of a position change to coordinates on given map (ZC_NPCACK_MAPMOVE). /// 0091 <map name>.16B <x>.W <y>.W -void clif_changemap(struct map_session_data *sd, short map, int x, int y) -{ +void clif_changemap(struct map_session_data *sd, short m, int x, int y) { int fd; nullpo_retv(sd); fd = sd->fd; WFIFOHEAD(fd,packet_len(0x91)); WFIFOW(fd,0) = 0x91; - mapindex_getmapname_ext(mapindex_id2name(map), (char*)WFIFOP(fd,2)); + mapindex_getmapname_ext(map[m].cName ? map[m].cName : map[m].name, (char*)WFIFOP(fd,2)); WFIFOW(fd,18) = x; WFIFOW(fd,20) = y; WFIFOSET(fd,packet_len(0x91)); @@ -1682,8 +1680,7 @@ void clif_changemap(struct map_session_data *sd, short map, int x, int y) /// Notifies the client of a position change to coordinates on given map, which is on another map-server (ZC_NPCACK_SERVERMOVE). /// 0092 <map name>.16B <x>.W <y>.W <ip>.L <port>.W -void clif_changemapserver(struct map_session_data* sd, unsigned short map_index, int x, int y, uint32 ip, uint16 port) -{ +void clif_changemapserver(struct map_session_data* sd, unsigned short map_index, int x, int y, uint32 ip, uint16 port) { int fd; nullpo_retv(sd); fd = sd->fd; @@ -1766,7 +1763,7 @@ void clif_buylist(struct map_session_data *sd, struct npc_data *nd) if( id == NULL ) continue; WFIFOL(fd, 4+c*11) = val; - WFIFOL(fd, 8+c*11) = pc_modifybuyvalue(sd,val); + WFIFOL(fd, 8+c*11) = iPc->modifybuyvalue(sd,val); WFIFOB(fd,12+c*11) = itemtype(id->type); WFIFOW(fd,13+c*11) = ( id->view_id > 0 ) ? id->view_id : id->nameid; c++; @@ -1809,7 +1806,7 @@ void clif_selllist(struct map_session_data *sd) { if( sd->status.inventory[i].nameid > 0 && sd->inventory_data[i] ) { - if( !itemdb_cansell(&sd->status.inventory[i], pc_get_group_level(sd)) ) + if( !itemdb_cansell(&sd->status.inventory[i], iPc->get_group_level(sd)) ) continue; if( sd->status.inventory[i].expire_time ) @@ -1820,7 +1817,7 @@ void clif_selllist(struct map_session_data *sd) continue; WFIFOW(fd,4+c*10)=i+2; WFIFOL(fd,6+c*10)=val; - WFIFOL(fd,10+c*10)=pc_modifysellvalue(sd,val); + WFIFOL(fd,10+c*10)=iPc->modifysellvalue(sd,val); c++; } } @@ -1837,11 +1834,12 @@ void clif_selllist(struct map_session_data *sd) /// - set npcid of dialog window (0 by default) /// - if set to clear on next mes, clear contents /// - append this text -void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) -{ +void clif_scriptmes(struct map_session_data *sd, int npcid, const char *mes) { int fd = sd->fd; int slen = strlen(mes) + 9; + sd->state.dialog = 1; + WFIFOHEAD(fd, slen); WFIFOW(fd,0)=0xb4; WFIFOW(fd,2)=slen; @@ -1954,7 +1952,7 @@ void clif_scriptmenu(struct map_session_data* sd, int npcid, const char* mes) int slen = strlen(mes) + 9; struct block_list *bl = NULL; - if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m || + if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) clif->sendfakenpc(sd, npcid); @@ -1986,7 +1984,7 @@ void clif_scriptinput(struct map_session_data *sd, int npcid) nullpo_retv(sd); - if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m || + if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) clif->sendfakenpc(sd, npcid); @@ -2017,7 +2015,7 @@ void clif_scriptinputstr(struct map_session_data *sd, int npcid) nullpo_retv(sd); - if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = map_id2bl(npcid)) && (bl->m!=sd->bl.m || + if (!sd->state.using_fake_npc && (npcid == fake_nd->bl.id || ((bl = iMap->id2bl(npcid)) && (bl->m!=sd->bl.m || bl->x<sd->bl.x-AREA_SIZE-1 || bl->x>sd->bl.x+AREA_SIZE+1 || bl->y<sd->bl.y-AREA_SIZE-1 || bl->y>sd->bl.y+AREA_SIZE+1)))) clif->sendfakenpc(sd, npcid); @@ -2235,7 +2233,7 @@ void clif_additem(struct map_session_data *sd, int n, int amount, int fail) { p.IsDamaged = sd->status.inventory[n].attribute; p.refiningLevel =sd->status.inventory[n].refine; clif->addcards2(&p.slot.card[0], &sd->status.inventory[n]); - p.location = pc_equippoint(sd,n); + p.location = iPc->equippoint(sd,n); p.type = itemtype(sd->inventory_data[n]->type); #if PACKETVER >= 20061218 p.HireExpireDate = sd->status.inventory[n].expire_time; @@ -2355,7 +2353,7 @@ void clif_inventorylist(struct map_session_data *sd) { if( !itemdb_isstackable2(sd->inventory_data[i]) ) { //Non-stackable (Equippable) WBUFW(bufe,ne*se+4)=i+2; - clif->item_sub(bufe, ne*se+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i)); + clif->item_sub(bufe, ne*se+6, &sd->status.inventory[i], sd->inventory_data[i], iPc->equippoint(sd,i)); clif->addcards(WBUFP(bufe, ne*se+16), &sd->status.inventory[i]); #if PACKETVER >= 20071002 WBUFL(bufe,ne*se+24)=sd->status.inventory[i].expire_time; @@ -2445,7 +2443,7 @@ void clif_equiplist(struct map_session_data *sd) continue; //Equippable WBUFW(buf,n*cmd+4)=i+2; - clif->item_sub(buf, n*cmd+6, &sd->status.inventory[i], sd->inventory_data[i], pc_equippoint(sd,i)); + clif->item_sub(buf, n*cmd+6, &sd->status.inventory[i], sd->inventory_data[i], iPc->equippoint(sd,i)); clif->addcards(WBUFP(buf, n*cmd+16), &sd->status.inventory[i]); #if PACKETVER >= 20071002 WBUFL(buf,n*cmd+24)=sd->status.inventory[i].expire_time; @@ -2747,6 +2745,9 @@ void read_channels_config(void) { } else { unsigned char d = 0, dlen = strlen(irc_server); char server[40]; + + memset(server, '\0', sizeof(server)); + for(d = 0; d < dlen; d++) { if(irc_server[d] == ':') { memcpy(server, irc_server, d); @@ -2762,7 +2763,7 @@ void read_channels_config(void) { ShowWarning("channels.conf : irc channel enabled but irc_channel_network wasn't found, disabling irc channel...\n"); } if( config_setting_lookup_string(settings, "irc_channel_channel", &irc_channel) ) - safestrncpy(hChSys.irc_channel, irc_channel, 20); + safestrncpy(hChSys.irc_channel, irc_channel, 50); else { hChSys.irc = false; ShowWarning("channels.conf : irc channel enabled but irc_channel_channel wasn't found, disabling irc channel...\n"); @@ -2771,7 +2772,7 @@ void read_channels_config(void) { if( strcmpi(irc_nick,"Hercules_chSysBot") == 0 ) { sprintf(hChSys.irc_nick, "Hercules_chSysBot%d",rand()%777); } else - safestrncpy(hChSys.irc_nick, irc_nick, 30); + safestrncpy(hChSys.irc_nick, irc_nick, 40); } else { hChSys.irc = false; ShowWarning("channels.conf : irc channel enabled but irc_channel_nick wasn't found, disabling irc channel...\n"); @@ -2949,7 +2950,7 @@ int clif_hpmeter_sub(struct block_list *bl, va_list ap) { *------------------------------------------*/ int clif_hpmeter(struct map_session_data *sd) { nullpo_ret(sd); - map_foreachinarea(clif->hpmeter_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd); + iMap->foreachinarea(clif->hpmeter_sub, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_PC, sd); return 0; } @@ -2979,9 +2980,9 @@ void clif_updatestatus(struct map_session_data *sd,int type) switch(type){ // 00b0 case SP_WEIGHT: - pc_updateweightstatus(sd); + iPc->updateweightstatus(sd); WFIFOHEAD(fd,14); - WFIFOW(fd,0)=0xb0; //Need to re-set as pc_updateweightstatus can alter the buffer. [Skotlex] + WFIFOW(fd,0)=0xb0; //Need to re-set as iPc->updateweightstatus can alter the buffer. [Skotlex] WFIFOW(fd,2)=type; WFIFOL(fd,4)=sd->weight; break; @@ -3091,11 +3092,11 @@ void clif_updatestatus(struct map_session_data *sd,int type) break; case SP_NEXTBASEEXP: WFIFOW(fd,0)=0xb1; - WFIFOL(fd,4)=pc_nextbaseexp(sd); + WFIFOL(fd,4)=iPc->nextbaseexp(sd); break; case SP_NEXTJOBEXP: WFIFOW(fd,0)=0xb1; - WFIFOL(fd,4)=pc_nextjobexp(sd); + WFIFOL(fd,4)=iPc->nextjobexp(sd); break; /** @@ -3108,7 +3109,7 @@ void clif_updatestatus(struct map_session_data *sd,int type) case SP_UDEX: case SP_ULUK: WFIFOW(fd,0)=0xbe; - WFIFOB(fd,4)=pc_need_status_point(sd,type-SP_USTR+SP_STR,1); + WFIFOB(fd,4)=iPc->need_status_point(sd,type-SP_USTR+SP_STR,1); len=5; break; @@ -3405,17 +3406,17 @@ void clif_initialstatus(struct map_session_data *sd) { WBUFW(buf,0)=0xbd; WBUFW(buf,2)=min(sd->status.status_point, INT16_MAX); WBUFB(buf,4)=min(sd->status.str, UINT8_MAX); - WBUFB(buf,5)=pc_need_status_point(sd,SP_STR,1); + WBUFB(buf,5)=iPc->need_status_point(sd,SP_STR,1); WBUFB(buf,6)=min(sd->status.agi, UINT8_MAX); - WBUFB(buf,7)=pc_need_status_point(sd,SP_AGI,1); + WBUFB(buf,7)=iPc->need_status_point(sd,SP_AGI,1); WBUFB(buf,8)=min(sd->status.vit, UINT8_MAX); - WBUFB(buf,9)=pc_need_status_point(sd,SP_VIT,1); + WBUFB(buf,9)=iPc->need_status_point(sd,SP_VIT,1); WBUFB(buf,10)=min(sd->status.int_, UINT8_MAX); - WBUFB(buf,11)=pc_need_status_point(sd,SP_INT,1); + WBUFB(buf,11)=iPc->need_status_point(sd,SP_INT,1); WBUFB(buf,12)=min(sd->status.dex, UINT8_MAX); - WBUFB(buf,13)=pc_need_status_point(sd,SP_DEX,1); + WBUFB(buf,13)=iPc->need_status_point(sd,SP_DEX,1); WBUFB(buf,14)=min(sd->status.luk, UINT8_MAX); - WBUFB(buf,15)=pc_need_status_point(sd,SP_LUK,1); + WBUFB(buf,15)=iPc->need_status_point(sd,SP_LUK,1); WBUFW(buf,16) = pc_leftside_atk(sd); WBUFW(buf,18) = pc_rightside_atk(sd); @@ -3507,7 +3508,7 @@ void clif_arrow_create_list(struct map_session_data *sd) for (i = 0, c = 0; i < MAX_SKILL_ARROW_DB; i++) { if (skill_arrow_db[i].nameid > 0 && - (j = pc_search_inventory(sd, skill_arrow_db[i].nameid)) >= 0 && + (j = iPc->search_inventory(sd, skill_arrow_db[i].nameid)) >= 0 && !sd->status.inventory[j].equip && sd->status.inventory[j].identify) { if ((j = itemdb_viewid(skill_arrow_db[i].nameid)) > 0) @@ -3638,16 +3639,17 @@ void clif_changeoption(struct block_list* bl) struct map_session_data* sd; nullpo_retv(bl); - sc = status_get_sc(bl); - if (!sc) return; //How can an option change if there's no sc? + + if ( !(sc = status_get_sc(bl)) && bl->type != BL_NPC ) return; //How can an option change if there's no sc? + sd = BL_CAST(BL_PC, bl); #if PACKETVER >= 7 WBUFW(buf,0) = 0x229; WBUFL(buf,2) = bl->id; - WBUFW(buf,6) = sc->opt1; - WBUFW(buf,8) = sc->opt2; - WBUFL(buf,10) = sc->option; + WBUFW(buf,6) = (sc) ? sc->opt1 : 0; + WBUFW(buf,8) = (sc) ? sc->opt2 : 0; + WBUFL(buf,10) = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0; WBUFB(buf,14) = (sd)? sd->status.karma : 0; if(disguised(bl)) { clif->send(buf,packet_len(0x229),bl,AREA_WOS); @@ -3661,9 +3663,9 @@ void clif_changeoption(struct block_list* bl) #else WBUFW(buf,0) = 0x119; WBUFL(buf,2) = bl->id; - WBUFW(buf,6) = sc->opt1; - WBUFW(buf,8) = sc->opt2; - WBUFW(buf,10) = sc->option; + WBUFW(buf,6) = (sc) ? sc->opt1 : 0; + WBUFW(buf,8) = (sc) ? sc->opt2 : 0; + WBUFL(buf,10) = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0; WBUFB(buf,12) = (sd)? sd->status.karma : 0; if(disguised(bl)) { clif->send(buf,packet_len(0x119),bl,AREA_WOS); @@ -3680,19 +3682,17 @@ void clif_changeoption(struct block_list* bl) /// Displays status change effects on NPCs/monsters (ZC_NPC_SHOWEFST_UPDATE). /// 028a <id>.L <effect state>.L <level>.L <showEFST>.L -void clif_changeoption2(struct block_list* bl) -{ +void clif_changeoption2(struct block_list* bl) { unsigned char buf[20]; struct status_change *sc; - sc = status_get_sc(bl); - if (!sc) return; //How can an option change if there's no sc? + if ( !(sc = status_get_sc(bl)) && bl->type != BL_NPC ) return; //How can an option change if there's no sc? WBUFW(buf,0) = 0x28a; WBUFL(buf,2) = bl->id; - WBUFL(buf,6) = sc->option; + WBUFL(buf,6) = (sc) ? sc->option : bl->type == BL_NPC ? ((TBL_NPC*)bl)->option : 0; WBUFL(buf,10) = clif_setlevel(bl); - WBUFL(buf,14) = sc->opt3; + WBUFL(buf,14) = (sc) ? sc->opt3 : 0; if(disguised(bl)) { clif->send(buf,packet_len(0x28a),bl,AREA_WOS); WBUFL(buf,2) = -bl->id; @@ -3748,7 +3748,7 @@ void clif_useitemack(struct map_session_data *sd,int index,int amount,bool ok) } void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data *sd, char *msg) { - if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), gettick()) > 0 && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { + if( channel->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + ( channel->msg_delay * 1000 ), iTimer->gettick()) > 0 && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN) ) { clif->colormes(sd->fd,COLOR_RED,msg_txt(1455)); return; } else { @@ -3758,7 +3758,7 @@ void clif_hercules_chsys_send(struct hChSysCh *channel, struct map_session_data if( channel->type == hChSys_IRC ) ircbot->relay(sd->status.name,msg); if( channel->msg_delay != 0 ) - sd->hchsysch_tick = gettick(); + sd->hchsysch_tick = iTimer->gettick(); } } @@ -4011,7 +4011,7 @@ void clif_traderequest(struct map_session_data* sd, const char* name) safestrncpy((char*)WFIFOP(fd,2), name, NAME_LENGTH); WFIFOSET(fd,packet_len(0xe5)); #else - struct map_session_data* tsd = map_id2sd(sd->trade_partner); + struct map_session_data* tsd = iMap->id2sd(sd->trade_partner); if( !tsd ) return; WFIFOHEAD(fd,packet_len(0x1f4)); @@ -4037,7 +4037,7 @@ void clif_traderequest(struct map_session_data* sd, const char* name) void clif_tradestart(struct map_session_data* sd, uint8 type) { int fd = sd->fd; - struct map_session_data* tsd = map_id2sd(sd->trade_partner); + struct map_session_data* tsd = iMap->id2sd(sd->trade_partner); if( PACKETVER < 6 || !tsd ) { WFIFOHEAD(fd,packet_len(0xe7)); WFIFOW(fd,0) = 0xe7; @@ -4299,7 +4299,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds if( dstsd->chatID ) { struct chat_data *cd = NULL; - if( (cd = (struct chat_data*)map_id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd) + if( (cd = (struct chat_data*)iMap->id2bl(dstsd->chatID)) && cd->usersd[0]==dstsd) clif->dispchat(cd,sd->fd); } else if( dstsd->state.vending ) clif->showvendingboard(&dstsd->bl,dstsd->message,sd->fd); @@ -4328,7 +4328,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds ARR_FIND( 0, 5, i, dstsd->devotion[i] > 0 ); if( i < 5 ) clif->devotion(&dstsd->bl, sd); // display link (dstsd - crusader) to sd - if( dstsd->sc.data[SC_DEVOTION] && (d_bl = map_id2bl(dstsd->sc.data[SC_DEVOTION]->val1)) != NULL ) + if( dstsd->sc.data[SC_DEVOTION] && (d_bl = iMap->id2bl(dstsd->sc.data[SC_DEVOTION]->val1)) != NULL ) clif->devotion(d_bl, sd); } @@ -4343,7 +4343,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { /** * Hide NPC from maya purple card. **/ - if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE)) + if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->option&OPTION_INVISIBLE)) return; if ( ( ud = unit_bl2ud(bl) ) && ud->walktimer != INVALID_TIMER ) @@ -4376,7 +4376,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl) { { TBL_NPC* nd = (TBL_NPC*)bl; if( nd->chat_id ) - clif->dispchat((struct chat_data*)map_id2bl(nd->chat_id),sd->fd); + clif->dispchat((struct chat_data*)iMap->id2bl(nd->chat_id),sd->fd); if( nd->size == SZ_BIG ) clif->specialeffect_single(bl,423,sd->fd); else if( nd->size == SZ_MEDIUM ) @@ -4600,16 +4600,13 @@ void clif_changemapcell(int fd, int16 m, int x, int y, int type, enum send_targe WBUFW(buf,2) = x; WBUFW(buf,4) = y; WBUFW(buf,6) = type; - mapindex_getmapname_ext(map[m].name,(char*)WBUFP(buf,8)); + mapindex_getmapname_ext(map[m].cName ? map[m].cName : map[m].name,(char*)WBUFP(buf,8)); - if( fd ) - { + if( fd ) { WFIFOHEAD(fd,packet_len(0x192)); memcpy(WFIFOP(fd,0), buf, packet_len(0x192)); WFIFOSET(fd,packet_len(0x192)); - } - else - { + } else { struct block_list dummy_bl; dummy_bl.type = BL_NUL; dummy_bl.x = x; @@ -4782,7 +4779,7 @@ int clif_outsight(struct block_list *bl,va_list ap) clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); if(sd->chatID){ struct chat_data *cd; - cd=(struct chat_data*)map_id2bl(sd->chatID); + cd=(struct chat_data*)iMap->id2bl(sd->chatID); if(cd->usersd[0]==sd) clif->dispchat(cd,tsd->fd); } @@ -4798,7 +4795,7 @@ int clif_outsight(struct block_list *bl,va_list ap) clif->clearchar_skillunit((struct skill_unit *)bl,tsd->fd); break; case BL_NPC: - if( !(((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE) ) + if( !(((TBL_NPC*)bl)->option&OPTION_INVISIBLE) ) clif->clearunit_single(bl->id,CLR_OUTSIGHT,tsd->fd); break; default: @@ -4809,7 +4806,7 @@ int clif_outsight(struct block_list *bl,va_list ap) } if (sd && sd->fd) { //sd is watching tbl go out of view. if (((vd=status_get_viewdata(tbl)) && vd->class_ != INVISIBLE_CLASS) && - !(tbl->type == BL_NPC && (((TBL_NPC*)tbl)->sc.option&OPTION_INVISIBLE))) + !(tbl->type == BL_NPC && (((TBL_NPC*)tbl)->option&OPTION_INVISIBLE))) clif->clearunit_single(tbl->id,CLR_OUTSIGHT,sd->fd); } return 0; @@ -5935,7 +5932,7 @@ void clif_wis_message(int fd, const char* nick, const char* mes, int mes_len) WFIFOW(fd,2) = mes_len + NAME_LENGTH + 8; safestrncpy((char*)WFIFOP(fd,4), nick, NAME_LENGTH); WFIFOL(fd,28) = 0; // isAdmin; if nonzero, also displays text above char - // TODO: WFIFOL(fd,28) = pc_get_group_level(ssd); + // TODO: WFIFOL(fd,28) = iPc->get_group_level(ssd); safestrncpy((char*)WFIFOP(fd,32), mes, mes_len); WFIFOSET(fd,WFIFOW(fd,2)); #endif @@ -6170,14 +6167,14 @@ void clif_item_refine_list(struct map_session_data *sd) nullpo_retv(sd); - skill_lv = pc_checkskill(sd,WS_WEAPONREFINE); + skill_lv = iPc->checkskill(sd,WS_WEAPONREFINE); fd=sd->fd; refine_item[0] = -1; - refine_item[1] = pc_search_inventory(sd,1010); - refine_item[2] = pc_search_inventory(sd,1011); - refine_item[3] = refine_item[4] = pc_search_inventory(sd,984); + refine_item[1] = iPc->search_inventory(sd,1010); + refine_item[2] = iPc->search_inventory(sd,1011); + refine_item[3] = refine_item[4] = iPc->search_inventory(sd,984); WFIFOHEAD(fd, MAX_INVENTORY * 13 + 4); WFIFOW(fd,0)=0x221; @@ -6369,7 +6366,7 @@ void clif_vendinglist(struct map_session_data* sd, unsigned int id, struct s_ven nullpo_retv(sd); nullpo_retv(vending); - nullpo_retv(vsd=map_id2sd(id)); + nullpo_retv(vsd=iMap->id2sd(id)); fd = sd->fd; count = vsd->vend_num; @@ -6528,7 +6525,7 @@ void clif_party_member_info(struct party_data *p, struct map_session_data *sd) WBUFB(buf,14) = (p->party.member[i].online)?0:1; memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH); memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH); - mapindex_getmapname_ext(map[sd->bl.m].name, (char*)WBUFP(buf,63)); + mapindex_getmapname_ext(map[sd->bl.m].cName ? map[sd->bl.m].cName : map[sd->bl.m].name, (char*)WBUFP(buf,63)); WBUFB(buf,79) = (p->party.item&1)?1:0; WBUFB(buf,80) = (p->party.item&2)?1:0; clif->send(buf,packet_len(0x1e9),&sd->bl,PARTY); @@ -6613,7 +6610,7 @@ void clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd) fd=tsd->fd; - if( (p=party_search(sd->status.party_id))==NULL ) + if( (p=iParty->search(sd->status.party_id))==NULL ) return; WFIFOHEAD(fd,packet_len(cmd)); @@ -7089,31 +7086,31 @@ void clif_autospell(struct map_session_data *sd,uint16 skill_lv) WFIFOHEAD(fd,packet_len(0x1cd)); WFIFOW(fd, 0)=0x1cd; - if(skill_lv>0 && pc_checkskill(sd,MG_NAPALMBEAT)>0) + if(skill_lv>0 && iPc->checkskill(sd,MG_NAPALMBEAT)>0) WFIFOL(fd,2)= MG_NAPALMBEAT; else WFIFOL(fd,2)= 0x00000000; - if(skill_lv>1 && pc_checkskill(sd,MG_COLDBOLT)>0) + if(skill_lv>1 && iPc->checkskill(sd,MG_COLDBOLT)>0) WFIFOL(fd,6)= MG_COLDBOLT; else WFIFOL(fd,6)= 0x00000000; - if(skill_lv>1 && pc_checkskill(sd,MG_FIREBOLT)>0) + if(skill_lv>1 && iPc->checkskill(sd,MG_FIREBOLT)>0) WFIFOL(fd,10)= MG_FIREBOLT; else WFIFOL(fd,10)= 0x00000000; - if(skill_lv>1 && pc_checkskill(sd,MG_LIGHTNINGBOLT)>0) + if(skill_lv>1 && iPc->checkskill(sd,MG_LIGHTNINGBOLT)>0) WFIFOL(fd,14)= MG_LIGHTNINGBOLT; else WFIFOL(fd,14)= 0x00000000; - if(skill_lv>4 && pc_checkskill(sd,MG_SOULSTRIKE)>0) + if(skill_lv>4 && iPc->checkskill(sd,MG_SOULSTRIKE)>0) WFIFOL(fd,18)= MG_SOULSTRIKE; else WFIFOL(fd,18)= 0x00000000; - if(skill_lv>7 && pc_checkskill(sd,MG_FIREBALL)>0) + if(skill_lv>7 && iPc->checkskill(sd,MG_FIREBALL)>0) WFIFOL(fd,22)= MG_FIREBALL; else WFIFOL(fd,22)= 0x00000000; - if(skill_lv>9 && pc_checkskill(sd,MG_FROSTDIVER)>0) + if(skill_lv>9 && iPc->checkskill(sd,MG_FROSTDIVER)>0) WFIFOL(fd,26)= MG_FROSTDIVER; else WFIFOL(fd,26)= 0x00000000; @@ -7152,7 +7149,7 @@ void clif_devotion(struct block_list *src, struct map_session_data *tsd) for( i = 0; i < 5; i++ ) WBUFL(buf,6+4*i) = sd->devotion[i]; - WBUFW(buf,26) = skill->get_range2(src, CR_DEVOTION, pc_checkskill(sd, CR_DEVOTION)); + WBUFW(buf,26) = skill->get_range2(src, CR_DEVOTION, iPc->checkskill(sd, CR_DEVOTION)); } if( tsd ) @@ -8086,7 +8083,7 @@ void clif_callpartner(struct map_session_data *sd) if( sd->status.partner_id ) { const char *p; - if( ( p = map_charid2nick(sd->status.partner_id) ) != NULL ) + if( ( p = iMap->charid2nick(sd->status.partner_id) ) != NULL ) { memcpy(WBUFP(buf,2), p, NAME_LENGTH); } @@ -8209,7 +8206,7 @@ void clif_GM_kick(struct map_session_data *sd,struct map_session_data *tsd) if( fd > 0 ) clif->authfail_fd(fd, 15); else - map_quit(tsd); + iMap->quit(tsd); if( sd ) clif->GM_kickack(sd,tsd->status.account_id); @@ -8484,7 +8481,7 @@ void clif_refresh(struct map_session_data *sd) int i; nullpo_retv(sd); - clif->changemap(sd,sd->mapindex,sd->bl.x,sd->bl.y); + clif->changemap(sd,sd->bl.m,sd->bl.x,sd->bl.y); clif->inventorylist(sd); if(pc_iscarton(sd)) { clif->cartlist(sd); @@ -8514,7 +8511,7 @@ void clif_refresh(struct map_session_data *sd) } if( sd->ed ) clif->elemental_info(sd); - map_foreachinrange(clif->getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd); + iMap->foreachinrange(clif->getareachar,&sd->bl,AREA_SIZE,BL_ALL,sd); clif->weather_check(sd); if( sd->chatID ) chat_leavechat(sd,0); @@ -8534,8 +8531,8 @@ void clif_refresh(struct map_session_data *sd) if( disguised(&sd->bl) ) {/* refresh-da */ short disguise = sd->disguise; - pc_disguise(sd, -1); - pc_disguise(sd, disguise); + iPc->disguise(sd, -1); + iPc->disguise(sd, disguise); } } @@ -8574,7 +8571,7 @@ void clif_charnameack (int fd, struct block_list *bl) memcpy(WBUFP(buf,6), ssd->status.name, NAME_LENGTH); if( ssd->status.party_id ) { - p = party_search(ssd->status.party_id); + p = iParty->search(ssd->status.party_id); } if( ssd->status.guild_id ) { if( ( g = ssd->guild ) != NULL ) { @@ -8698,10 +8695,10 @@ void clif_charnameupdate (struct map_session_data *ssd) if (!battle_config.display_party_name) { if (ssd->status.party_id > 0 && ssd->status.guild_id > 0 && (g = ssd->guild) != NULL) - p = party_search(ssd->status.party_id); + p = iParty->search(ssd->status.party_id); }else{ if (ssd->status.party_id > 0) - p = party_search(ssd->status.party_id); + p = iParty->search(ssd->status.party_id); } if( ssd->status.guild_id > 0 && (g = ssd->guild) != NULL ) @@ -8887,7 +8884,7 @@ void clif_feel_info(struct map_session_data* sd, unsigned char feel_level, unsig void clif_hate_info(struct map_session_data *sd, unsigned char hate_level,int class_, unsigned char type) { if( pcdb_checkid(class_) ) { - clif->starskill(sd, job_name(class_), class_, hate_level, type ? 10 : 11); + clif->starskill(sd, iPc->job_name(class_), class_, hate_level, type ? 10 : 11); } else if( mobdb_checkid(class_) ) { clif->starskill(sd, mob_db(class_)->jname, class_, hate_level, type ? 10 : 11); } else { @@ -9002,7 +8999,7 @@ void clif_viewequip_ack(struct map_session_data* sd, struct map_session_data* ts // Inventory position WBUFW(buf, n*s+43) = i + 2; // Add refine, identify flag, element, etc. - clif->item_sub(WBUFP(buf,0), n*s+45, &tsd->status.inventory[i], tsd->inventory_data[i], pc_equippoint(tsd, i)); + clif->item_sub(WBUFP(buf,0), n*s+45, &tsd->status.inventory[i], tsd->inventory_data[i], iPc->equippoint(tsd, i)); // Add cards clif->addcards(WBUFP(buf, n*s+55), &tsd->status.inventory[i]); // Expiration date stuff, if all of those are set to 0 then the client doesn't show anything related (6 bytes) @@ -9251,7 +9248,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) { } //Check for double login. - bl = map_id2bl(account_id); + bl = iMap->id2bl(account_id); if(bl && bl->type != BL_PC) { ShowError("clif_parse_WantToConnection: a non-player object already has id %d, please increase the starting account number\n", account_id); WFIFOHEAD(fd,packet_len(0x6a)); @@ -9274,7 +9271,7 @@ void clif_parse_WantToConnection(int fd, struct map_session_data* sd) { sd->fd = fd; session[fd]->session_data = sd; - pc_setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd); + iPc->setnewpc(sd, account_id, char_id, login_id1, client_tick, sex, fd); #if PACKETVER < 20070521 WFIFOHEAD(fd,4); @@ -9320,18 +9317,19 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) return; if (!sd->state.active) { //Character loading is not complete yet! - //Let pc_reg_received reinvoke this when ready. + //Let iPc->reg_received reinvoke this when ready. sd->state.connect_new = 0; return; } if (sd->state.rewarp) { //Rewarp player. sd->state.rewarp = 0; - clif->changemap(sd, sd->mapindex, sd->bl.x, sd->bl.y); + clif->changemap(sd, sd->bl.m, sd->bl.x, sd->bl.y); return; } sd->state.warping = 0; + sd->state.dialog = 0;/* reset when warping, client dialog will go missing */ // look #if PACKETVER < 4 @@ -9344,8 +9342,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) if(sd->vd.cloth_color) clif->refreshlook(&sd->bl,sd->bl.id,LOOK_CLOTHES_COLOR,sd->vd.cloth_color,SELF); // item - clif->inventorylist(sd); // inventory list first, otherwise deleted items in pc_checkitem show up as 'unknown item' - pc_checkitem(sd); + clif->inventorylist(sd); // inventory list first, otherwise deleted items in iPc->checkitem show up as 'unknown item' + iPc->checkitem(sd); // cart if(pc_iscarton(sd)) { @@ -9363,30 +9361,30 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) guild->send_memberinfoshort(sd,1); if(battle_config.pc_invincible_time > 0) { - pc_setinvincibletimer(sd,battle_config.pc_invincible_time); + iPc->setinvincibletimer(sd,battle_config.pc_invincible_time); } if( map[sd->bl.m].users++ == 0 && battle_config.dynamic_mobs ) - map_spawnmobs(sd->bl.m); + iMap->spawnmobs(sd->bl.m); if( !(sd->sc.option&OPTION_INVISIBLE) ) { // increment the number of pvp players on the map map[sd->bl.m].users_pvp++; } - if( map[sd->bl.m].instance_id ) { - instance[map[sd->bl.m].instance_id].users++; - instance_check_idle(map[sd->bl.m].instance_id); + if( map[sd->bl.m].instance_id >= 0 ) { + instances[map[sd->bl.m].instance_id].users++; + instance->check_idle(map[sd->bl.m].instance_id); } sd->state.debug_remove_map = 0; // temporary state to track double remove_map's [FlavioJS] // reset the callshop flag if the player changes map sd->state.callshop = 0; - map_addblock(&sd->bl); + iMap->addblock(&sd->bl); clif->spawn(&sd->bl); // Party // (needs to go after clif_spawn() to show hp bars correctly) if(sd->status.party_id) { - party_send_movemap(sd); + iParty->send_movemap(sd); clif->party_hp(sd); // Show hp after displacement [LuzZza] } @@ -9395,7 +9393,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) if(map[sd->bl.m].flag.pvp && !(sd->sc.option&OPTION_INVISIBLE)) { if(!battle_config.pk_mode) { // remove pvp stuff for pk_mode [Valaris] if (!map[sd->bl.m].flag.pvp_nocalcrank) - sd->pvp_timer = add_timer(gettick()+200, pc_calc_pvprank_timer, sd->bl.id, 0); + sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+200, iPc->calc_pvprank_timer, sd->bl.id, 0); sd->pvp_rank = 0; sd->pvp_lastusers = 0; sd->pvp_point = 5; @@ -9415,7 +9413,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) clif->map_property(sd, MAPPROPERTY_AGITZONE); // info about nearby objects // must use foreachinarea (CIRCULAR_AREA interferes with foreachinrange) - map_foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd); + iMap->foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd); // pet if( sd->pd ) { @@ -9423,7 +9421,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) clif->message(sd->fd, msg_txt(666)); pet_menu(sd, 3); //Option 3 is return to egg. } else { - map_addblock(&sd->pd->bl); + iMap->addblock(&sd->pd->bl); clif->spawn(&sd->pd->bl); clif->send_petdata(sd,sd->pd,0,0); clif->send_petstatus(sd); @@ -9433,7 +9431,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) //homunculus [blackhole89] if( homun_alive(sd->hd) ) { - map_addblock(&sd->hd->bl); + iMap->addblock(&sd->hd->bl); clif->spawn(&sd->hd->bl); clif->send_homdata(sd,SP_ACK,0); clif->hominfo(sd,sd->hd,1); @@ -9442,11 +9440,11 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) if( battle_config.hom_setting&0x8 ) status_calc_bl(&sd->hd->bl, SCB_SPEED); //Homunc mimic their master's speed on each map change if( !(battle_config.hom_setting&0x2) ) - skill->unit_move(&sd->hd->bl,gettick(),1); // apply land skills immediately + skill->unit_move(&sd->hd->bl,iTimer->gettick(),1); // apply land skills immediately } if( sd->md ) { - map_addblock(&sd->md->bl); + iMap->addblock(&sd->md->bl); clif->spawn(&sd->md->bl); clif->mercenary_info(sd); clif->mercenary_skillblock(sd); @@ -9454,7 +9452,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) } if( sd->ed ) { - map_addblock(&sd->ed->bl); + iMap->addblock(&sd->ed->bl); clif->spawn(&sd->ed->bl); clif->elemental_info(sd); clif->elemental_updatestatus(sd,SP_HP); @@ -9486,7 +9484,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) sc_start(&sd->bl,SC_NOCHAT,100,0,0); //Auron reported that This skill only triggers when you logon on the map o.O [Skotlex] - if ((lv = pc_checkskill(sd,SG_KNOWLEDGE)) > 0) { + if ((lv = iPc->checkskill(sd,SG_KNOWLEDGE)) > 0) { if(sd->bl.m == sd->feel_map[0].m || sd->bl.m == sd->feel_map[1].m || sd->bl.m == sd->feel_map[2].m) @@ -9499,13 +9497,13 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) if(homun_alive(sd->hd)) homun->init_timers(sd->hd); - if (night_flag && map[sd->bl.m].flag.nightenabled) { + if (iMap->night_flag && map[sd->bl.m].flag.nightenabled) { sd->state.night = 1; clif->status_change(&sd->bl, SI_NIGHT, 1, 0, 0, 0, 0); } // Notify everyone that this char logged in [Skotlex]. - map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); + iMap->map_foreachpc(clif->friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 1); //Login Event npc_script_event(sd, NPCE_LOGIN); @@ -9536,7 +9534,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) (map_flag_gvg(sd->state.pmap) || map_flag_gvg(sd->bl.m) || map[sd->state.pmap].flag.battleground || map[sd->bl.m].flag.battleground) ) status_calc_bl(&sd->bl, SCB_FLEE); //Refresh flee penalty - if( night_flag && map[sd->bl.m].flag.nightenabled ) { //Display night. + if( iMap->night_flag && map[sd->bl.m].flag.nightenabled ) { //Display night. if( !sd->state.night ) { sd->state.night = 1; clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_NIGHT); @@ -9558,7 +9556,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) clif->broadcast(&sd->bl, output, strlen(output) + 1, 0x10, SELF); } - map_iwall_get(sd); // Updates Walls Info on this Map to Client + iMap->iwall_get(sd); // Updates Walls Info on this Map to Client status_calc_pc(sd, false);/* some conditions are map-dependent so we must recalculate */ sd->state.changemap = false; @@ -9587,7 +9585,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) if(map[sd->bl.m].flag.loadevent) // Lance npc_script_event(sd, NPCE_LOADMAP); - if (pc_checkskill(sd, SG_DEVIL) && !pc_nextjobexp(sd)) //blindness [Komurka] + if (iPc->checkskill(sd, SG_DEVIL) && !iPc->nextjobexp(sd)) //blindness [Komurka] clif->sc_end(&sd->bl, sd->bl.id, SELF, SI_DEVIL); if (sd->sc.opt2) //Client loses these on warp. @@ -9596,7 +9594,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) clif->weather_check(sd); // For automatic triggering of NPCs after map loading (so you don't need to walk 1 step first) - if (map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC)) + if (iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNPC)) npc_touch_areanpc(sd,sd->bl.m,sd->bl.x,sd->bl.y); else sd->areanpc_id = 0; @@ -9615,7 +9613,7 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) // Trigger skill effects if you appear standing on them if(!battle_config.pc_invincible_time) - skill->unit_move(&sd->bl,gettick(),1); + skill->unit_move(&sd->bl,iTimer->gettick(),1); } @@ -9639,7 +9637,7 @@ void clif_parse_TickSend(int fd, struct map_session_data *sd) { sd->client_tick = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - clif->notify_time(sd, gettick()); + clif->notify_time(sd, iTimer->gettick()); } @@ -9719,7 +9717,7 @@ void clif_parse_progressbar(int fd, struct map_session_data * sd) { int npc_id = sd->progressbar.npc_id; - if( gettick() < sd->progressbar.timeout && sd->st ) + if( iTimer->gettick() < sd->progressbar.timeout && sd->st ) sd->st->state = END; sd->progressbar.npc_id = sd->progressbar.timeout = 0; @@ -9750,7 +9748,7 @@ void clif_parse_WalkToXY(int fd, struct map_session_data *sd) if(sd->sc.data[SC_RUN] || sd->sc.data[SC_WUGDASH]) return; - pc_delinvincibletimer(sd); + iPc->delinvincibletimer(sd); RFIFOPOS(fd, packet_db[RFIFOW(fd,0)].pos[0], &x, &y, NULL); @@ -9786,7 +9784,7 @@ void clif_parse_QuitGame(int fd, struct map_session_data *sd) { /* Rovert's prevent logout option fixed [Valaris] */ if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] && - (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) + (!battle_config.prevent_logout || DIFF_TICK(iTimer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) { set_eof(fd); clif->disconnect_ack(sd, 0); @@ -9809,7 +9807,7 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) if( id < 0 && -id == sd->bl.id ) // for disguises [Valaris] id = sd->bl.id; - bl = map_id2bl(id); + bl = iMap->id2bl(id); if( bl == NULL ) return; // Lagged clients could request names of already gone mobs/players. [Skotlex] @@ -9821,13 +9819,13 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) sc = status_get_sc(bl); if (sc && sc->option&OPTION_INVISIBLE && !disguised(bl) && bl->type != BL_NPC && //Skip hidden NPCs which can be seen using Maya Purple - pc_get_group_level(sd) < battle_config.hack_info_GM_level + iPc->get_group_level(sd) < battle_config.hack_info_GM_level ) { char gm_msg[256]; sprintf(gm_msg, "Hack on NameRequest: character '%s' (account: %d) requested the name of an invisible target (id: %d).\n", sd->status.name, sd->status.account_id, id); ShowWarning(gm_msg); // information is sent to all online GMs - intif_wis_message_to_gm(wisp_server_name, battle_config.hack_info_GM_level, gm_msg); + intif_wis_message_to_gm(iMap->wisp_server_name, battle_config.hack_info_GM_level, gm_msg); return; } */ @@ -9836,10 +9834,11 @@ void clif_parse_GetCharNameRequest(int fd, struct map_session_data *sd) } int clif_undisguise_timer(int tid, unsigned int tick, int id, intptr_t data) { struct map_session_data * sd; - if( (sd = map_id2sd(id)) && sd->fontcolor && sd->disguise == sd->status.class_ ) { - pc_disguise(sd,-1); + if( (sd = iMap->id2sd(id)) ) { + sd->fontcolor_tid = INVALID_TIMER; + if( sd->fontcolor && sd->disguise == sd->status.class_ ) + iPc->disguise(sd,-1); } - sd->fontcolor_tid = INVALID_TIMER; return 0; } @@ -9867,9 +9866,9 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) return; if( battle_config.min_chat_delay ) { //[Skotlex] - if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0) + if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) return; - sd->cantalk_tick = gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; } if( sd->gcbind ) { @@ -9880,14 +9879,16 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) unsigned char mylen = 1; if( sd->disguise == -1 ) { - pc_disguise(sd,sd->status.class_); + sd->fontcolor_tid = iTimer->add_timer(iTimer->gettick()+5000, clif->undisguise_timer, sd->bl.id, 0); + iPc->disguise(sd,sd->status.class_); if( pc_isdead(sd) ) clif_clearunit_single(-sd->bl.id, CLR_DEAD, sd->fd); - sd->fontcolor_tid = add_timer(gettick()+5000, clif->undisguise_timer, sd->bl.id, 0); + if( unit_is_walking(&sd->bl) ) + clif->move(&sd->ud); } else if ( sd->disguise == sd->status.class_ && sd->fontcolor_tid != INVALID_TIMER ) { const struct TimerData *timer; - if( (timer = get_timer(sd->fontcolor_tid)) ) { - settick_timer(sd->fontcolor_tid, timer->tick+5000); + if( (timer = iTimer->get_timer(sd->fontcolor_tid)) ) { + iTimer->settick_timer(sd->fontcolor_tid, timer->tick+5000); } } @@ -9937,7 +9938,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) WFIFOSET(fd, WFIFOW(fd,2)); #ifdef PCRE_SUPPORT // trigger listening npcs - map_foreachinrange(npc_chat_sub, &sd->bl, AREA_SIZE, BL_NPC, text, textlen, &sd->bl); + iMap->foreachinrange(npc_chat_sub, &sd->bl, AREA_SIZE, BL_NPC, text, textlen, &sd->bl); #endif // Chat logging type 'O' / Global Chat @@ -10018,7 +10019,7 @@ void clif_parse_Emotion(int fd, struct map_session_data *sd) { int emoticon = RFIFOB(fd,packet_db[RFIFOW(fd,0)].pos[0]); - if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 2) { + if (battle_config.basic_skill_check == 0 || iPc->checkskill(sd, NV_BASIC) >= 2) { if (emoticon == E_MUTE) {// prevent use of the mute emote [Valaris] clif->skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 1); return; @@ -10058,7 +10059,7 @@ void clif_user_count(struct map_session_data* sd, int count) { /// 00c1 void clif_parse_HowManyConnections(int fd, struct map_session_data *sd) { - clif->user_count(sd, map_getusers()); + clif->user_count(sd, iMap->getusers()); } @@ -10097,19 +10098,19 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, if( sd->sc.data[SC_BASILICA] || sd->sc.data[SC__SHADOWFORM] ) return; - if (!battle_config.sdelay_attack_enable && pc_checkskill(sd, SA_FREECAST) <= 0) { + if (!battle_config.sdelay_attack_enable && iPc->checkskill(sd, SA_FREECAST) <= 0) { if (DIFF_TICK(tick, sd->ud.canact_tick) < 0) { clif->skill_fail(sd, 1, USESKILL_FAIL_SKILLINTERVAL, 0); return; } } - pc_delinvincibletimer(sd); + iPc->delinvincibletimer(sd); sd->idletime = last_tick; unit_attack(&sd->bl, target_id, action_type != 0); break; case 0x02: // sitdown - if (battle_config.basic_skill_check && pc_checkskill(sd, NV_BASIC) < 3) { + if (battle_config.basic_skill_check && iPc->checkskill(sd, NV_BASIC) < 3) { clif->skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 2); break; } @@ -10139,7 +10140,7 @@ void clif_parse_ActionRequest_sub(struct map_session_data *sd, int action_type, clif->standing(&sd->bl); return; } - pc_setstand(sd); + iPc->setstand(sd); skill->sit(sd,0); clif->standing(&sd->bl); break; @@ -10274,7 +10275,7 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) clif->pActionRequest_sub(sd, RFIFOB(fd,packet_db[RFIFOW(fd,0)].pos[1]), RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]), - gettick() + iTimer->gettick() ); } @@ -10287,12 +10288,12 @@ void clif_parse_ActionRequest(int fd, struct map_session_data *sd) void clif_parse_Restart(int fd, struct map_session_data *sd) { switch(RFIFOB(fd,2)) { case 0x00: - pc_respawn(sd,CLR_RESPAWN); + iPc->respawn(sd,CLR_RESPAWN); break; case 0x01: /* Rovert's Prevent logout option - Fixed [Valaris] */ if( !sd->sc.data[SC_CLOAKING] && !sd->sc.data[SC_HIDING] && !sd->sc.data[SC_CHASEWALK] && !sd->sc.data[SC_CLOAKINGEXCEED] && - (!battle_config.prevent_logout || DIFF_TICK(gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) + (!battle_config.prevent_logout || DIFF_TICK(iTimer->gettick(), sd->canlog_tick) > battle_config.prevent_logout) ) { //Send to char-server for character selection. chrif_charselectreq(sd, session[fd]->client_addr); } else { @@ -10324,10 +10325,10 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) return; if (battle_config.min_chat_delay) { //[Skotlex] - if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0) { + if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) { return; } - sd->cantalk_tick = gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; } // Chat logging type 'W' / Whisper @@ -10416,7 +10417,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) } // searching destination character - dstsd = map_nick2sd(target); + dstsd = iMap->nick2sd(target); if (dstsd == NULL || strcmp(dstsd->status.name, target) != 0) { // player is not on this map-server @@ -10430,7 +10431,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) // if player ignores everyone if (dstsd->state.ignoreAll) { - if (dstsd->sc.option & OPTION_INVISIBLE && pc_get_group_level(sd) < pc_get_group_level(dstsd)) + if (dstsd->sc.option & OPTION_INVISIBLE && iPc->get_group_level(sd) < iPc->get_group_level(dstsd)) clif->wis_end(fd, 1); // 1: target character is not loged in else clif->wis_end(fd, 3); // 3: everyone ignored by target @@ -10441,7 +10442,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) if( dstsd->state.autotrade == 1 ) { char output[256]; sprintf(output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name); - clif->wis_message(fd, wisp_server_name, output, strlen(output) + 1); + clif->wis_message(fd, iMap->wisp_server_name, output, strlen(output) + 1); return; } @@ -10487,7 +10488,7 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd) map_object_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - fitem = (struct flooritem_data*)map_id2bl(map_object_id); + fitem = (struct flooritem_data*)iMap->id2bl(map_object_id); do { if (pc_isdead(sd)) { @@ -10511,7 +10512,7 @@ void clif_parse_TakeItem(int fd, struct map_session_data *sd) if (pc_cant_act(sd)) break; - if (!pc_takeitem(sd, fitem)) + if (!iPc->takeitem(sd, fitem)) break; return; @@ -10544,7 +10545,7 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd) )) break; - if (!pc_dropitem(sd, item_index, item_amount)) + if (!iPc->dropitem(sd, item_index, item_amount)) break; return; @@ -10577,7 +10578,7 @@ void clif_parse_UseItem(int fd, struct map_session_data *sd) if(n <0 || n >= MAX_INVENTORY) return; - if (!pc_useitem(sd,n)) + if (!iPc->useitem(sd,n)) clif->useitemack(sd,n,0,false); //Send an empty ack packet or the client gets stuck. } @@ -10619,9 +10620,9 @@ void clif_parse_EquipItem(int fd,struct map_session_data *sd) //Client doesn't send the position for ammo. if(sd->inventory_data[index]->type == IT_AMMO) - pc_equipitem(sd,index,EQP_AMMO); + iPc->equipitem(sd,index,EQP_AMMO); else - pc_equipitem(sd,index,RFIFOW(fd,4)); + iPc->equipitem(sd,index,RFIFOW(fd,4)); } void clif_hercules_chsys_delete(struct hChSysCh *channel) { @@ -10734,7 +10735,7 @@ void clif_parse_UnequipItem(int fd,struct map_session_data *sd) index = RFIFOW(fd,2)-2; - pc_unequipitem(sd,index,1); + iPc->unequipitem(sd,index,1); } @@ -10754,12 +10755,12 @@ void clif_parse_NpcClicked(int fd,struct map_session_data *sd) if ( pc_cant_act2(sd) ) return; - bl = map_id2bl(RFIFOL(fd,2)); + bl = iMap->id2bl(RFIFOL(fd,2)); if (!bl) return; switch (bl->type) { case BL_MOB: case BL_PC: - clif->pActionRequest_sub(sd, 0x07, bl->id, gettick()); + clif->pActionRequest_sub(sd, 0x07, bl->id, iTimer->gettick()); break; case BL_NPC: if( bl->m != -1 )// the user can't click floating npcs directly (hack attempt) @@ -10871,7 +10872,7 @@ void clif_parse_CreateChatRoom(int fd, struct map_session_data* sd) if (sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM) return; - if(battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 4) { + if(battle_config.basic_skill_check && iPc->checkskill(sd,NV_BASIC) < 4) { clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,3); return; } @@ -10978,7 +10979,7 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd) { struct map_session_data *t_sd; - t_sd = map_id2sd(RFIFOL(fd,2)); + t_sd = iMap->id2sd(RFIFOL(fd,2)); if(!sd->chatID && pc_cant_act(sd)) return; //You can trade while in a chatroom. @@ -10989,7 +10990,7 @@ void clif_parse_TradeRequest(int fd,struct map_session_data *sd) return; } - if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 1) { + if( battle_config.basic_skill_check && iPc->checkskill(sd,NV_BASIC) < 1) { clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,0); return; } @@ -11063,7 +11064,7 @@ void clif_parse_PutItemToCart(int fd,struct map_session_data *sd) return; if (!pc_iscarton(sd)) return; - pc_putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4)); + iPc->putitemtocart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4)); } @@ -11073,7 +11074,7 @@ void clif_parse_GetItemFromCart(int fd,struct map_session_data *sd) { if (!pc_iscarton(sd)) return; - pc_getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4)); + iPc->getitemfromcart(sd,RFIFOW(fd,2)-2,RFIFOL(fd,4)); } @@ -11085,11 +11086,11 @@ void clif_parse_RemoveOption(int fd,struct map_session_data *sd) * Attempts to remove these options when this function is called (will remove all available) **/ #ifdef NEW_CARTS - pc_setoption(sd,sd->sc.option&~(OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR)); + iPc->setoption(sd,sd->sc.option&~(OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR)); if( sd->sc.data[SC_PUSH_CART] ) - pc_setcart(sd,0); + iPc->setcart(sd,0); #else - pc_setoption(sd,sd->sc.option&~(OPTION_CART|OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR)); + iPc->setoption(sd,sd->sc.option&~(OPTION_CART|OPTION_RIDING|OPTION_FALCON|OPTION_DRAGON|OPTION_MADOGEAR)); #endif } @@ -11100,7 +11101,7 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd) {// TODO: State tracking? int type; - if( sd && pc_checkskill(sd, MC_CHANGECART) < 1 ) + if( sd && iPc->checkskill(sd, MC_CHANGECART) < 1 ) return; type = (int)RFIFOW(fd,2); @@ -11121,7 +11122,7 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd) (type == 2 && sd->status.base_level > 40) || (type == 1)) #endif - pc_setcart(sd,type); + iPc->setcart(sd,type); } @@ -11134,7 +11135,7 @@ void clif_parse_ChangeCart(int fd,struct map_session_data *sd) /// the like void clif_parse_StatusUp(int fd,struct map_session_data *sd) { - pc_statusup(sd,RFIFOW(fd,2)); + iPc->statusup(sd,RFIFOW(fd,2)); } @@ -11142,7 +11143,7 @@ void clif_parse_StatusUp(int fd,struct map_session_data *sd) /// 0112 <skill id>.W void clif_parse_SkillUp(int fd,struct map_session_data *sd) { - pc_skillup(sd,RFIFOW(fd,2)); + iPc->skillup(sd,RFIFOW(fd,2)); } void clif_parse_UseSkillToId_homun(struct homun_data *hd, struct map_session_data *sd, unsigned int tick, uint16 skill_id, uint16 skill_lv, int target_id) @@ -11242,7 +11243,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) { uint16 skill_id, skill_lv; int tmp, target_id; - unsigned int tick = gettick(); + unsigned int tick = iTimer->gettick(); skill_lv = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[0]); skill_id = RFIFOW(fd,packet_db[RFIFOW(fd,0)].pos[1]); @@ -11313,7 +11314,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) if( skill_lv != sd->skillitemlv ) skill_lv = sd->skillitemlv; if( !(tmp&INF_SELF_SKILL) ) - pc_delinvincibletimer(sd); // Target skills thru items cancel invincibility. [Inkfish] + iPc->delinvincibletimer(sd); // Target skills thru items cancel invincibility. [Inkfish] unit_skilluse_id(&sd->bl, target_id, skill_id, skill_lv); return; } @@ -11326,12 +11327,12 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) else skill_lv = 0; } else { - tmp = pc_checkskill(sd, skill_id); + tmp = iPc->checkskill(sd, skill_id); if( skill_lv > tmp ) skill_lv = tmp; } - pc_delinvincibletimer(sd); + iPc->delinvincibletimer(sd); if( skill_lv ) unit_skilluse_id(&sd->bl, target_id, skill_id, skill_lv); @@ -11342,7 +11343,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) *------------------------------------------*/ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 skill_lv, uint16 skill_id, short x, short y, int skillmoreinfo) { - unsigned int tick = gettick(); + unsigned int tick = iTimer->gettick(); if( !(skill->get_inf(skill_id)&INF_GROUND_SKILL) ) return; //Using a target skill on the ground? WRONG. @@ -11394,7 +11395,7 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski return; //Can't use skills while a menu is open. } - pc_delinvincibletimer(sd); + iPc->delinvincibletimer(sd); if( sd->skillitem == skill_id ) { if( skill_lv != sd->skillitemlv ) @@ -11403,7 +11404,7 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uint16 ski } else { int lv; sd->skillitem = sd->skillitemlv = 0; - if( (lv = pc_checkskill(sd, skill_id)) > 0 ) { + if( (lv = iPc->checkskill(sd, skill_id)) > 0 ) { if( skill_lv > lv ) skill_lv = lv; unit_skilluse_pos(&sd->bl, x, y, skill_id,skill_lv); @@ -11470,7 +11471,7 @@ void clif_parse_UseSkillMap(int fd, struct map_session_data* sd) return; } - pc_delinvincibletimer(sd); + iPc->delinvincibletimer(sd); skill->castend_map(sd,skill_id,map_name); } @@ -11480,7 +11481,7 @@ void clif_parse_UseSkillMap(int fd, struct map_session_data* sd) void clif_parse_RequestMemo(int fd,struct map_session_data *sd) { if (!pc_isdead(sd)) - pc_memo(sd,-1); + iPc->memo(sd,-1); } @@ -11590,7 +11591,7 @@ void clif_parse_NpcSelectMenu(int fd,struct map_session_data *sd) #ifdef SECURE_NPCTIMEOUT if( sd->npc_idle_timer != INVALID_TIMER ) { #endif - TBL_NPC* nd = map_id2nd(npc_id); + TBL_NPC* nd = iMap->id2nd(npc_id); ShowWarning("Invalid menu selection on npc %d:'%s' - got %d, valid range is [%d..%d] (player AID:%d, CID:%d, name:'%s')!\n", npc_id, (nd)?nd->name:"invalid npc id", select, 1, sd->npc_menu, sd->bl.id, sd->status.char_id, sd->status.name); clif->GM_kick(NULL,sd); #ifdef SECURE_NPCTIMEOUT @@ -11728,7 +11729,7 @@ void clif_parse_InsertCard(int fd,struct map_session_data *sd) { if (sd->state.trading != 0) return; - pc_insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2); + iPc->insert_card(sd,RFIFOW(fd,2)-2,RFIFOW(fd,4)-2); } @@ -11741,7 +11742,7 @@ void clif_parse_SolveCharName(int fd, struct map_session_data *sd) int charid; charid = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - map_reqnickdb(sd, charid); + iMap->reqnickdb(sd, charid); } @@ -11932,12 +11933,12 @@ void clif_parse_CreateParty(int fd, struct map_session_data *sd) clif->message(fd, msg_txt(227)); return; } - if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 7 ) { + if( battle_config.basic_skill_check && iPc->checkskill(sd,NV_BASIC) < 7 ) { clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,4); return; } - party_create(sd,name,0,0); + iParty->create(sd,name,0,0); } void clif_parse_CreateParty2(int fd, struct map_session_data *sd) @@ -11951,12 +11952,12 @@ void clif_parse_CreateParty2(int fd, struct map_session_data *sd) clif->message(fd, msg_txt(227)); return; } - if( battle_config.basic_skill_check && pc_checkskill(sd,NV_BASIC) < 7 ) { + if( battle_config.basic_skill_check && iPc->checkskill(sd,NV_BASIC) < 7 ) { clif->skill_fail(sd,1,USESKILL_FAIL_LEVEL,4); return; } - party_create(sd,name,item1,item2); + iParty->create(sd,name,item1,item2); } @@ -11972,14 +11973,14 @@ void clif_parse_PartyInvite(int fd, struct map_session_data *sd) return; } - t_sd = map_id2sd(RFIFOL(fd,2)); + t_sd = iMap->id2sd(RFIFOL(fd,2)); if(t_sd && t_sd->state.noask) {// @noask [LuzZza] clif->noask_sub(sd, t_sd, 1); return; } - party_invite(sd, t_sd); + iParty->invite(sd, t_sd); } void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) @@ -11993,14 +11994,14 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) return; } - t_sd = map_nick2sd(name); + t_sd = iMap->nick2sd(name); if(t_sd && t_sd->state.noask) { // @noask [LuzZza] clif->noask_sub(sd, t_sd, 1); return; } - party_invite(sd, t_sd); + iParty->invite(sd, t_sd); } @@ -12012,12 +12013,12 @@ void clif_parse_PartyInvite2(int fd, struct map_session_data *sd) /// 1 = accept void clif_parse_ReplyPartyInvite(int fd,struct map_session_data *sd) { - party_reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6)); + iParty->reply_invite(sd,RFIFOL(fd,2),RFIFOL(fd,6)); } void clif_parse_ReplyPartyInvite2(int fd,struct map_session_data *sd) { - party_reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6)); + iParty->reply_invite(sd,RFIFOL(fd,2),RFIFOB(fd,6)); } @@ -12029,7 +12030,7 @@ void clif_parse_LeaveParty(int fd, struct map_session_data *sd) clif->message(fd, msg_txt(227)); return; } - party_leave(sd); + iParty->leave(sd); } @@ -12041,7 +12042,7 @@ void clif_parse_RemovePartyMember(int fd, struct map_session_data *sd) clif->message(fd, msg_txt(227)); return; } - party_removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6)); + iParty->removemember(sd,RFIFOL(fd,2),(char*)RFIFOP(fd,6)); } @@ -12056,7 +12057,7 @@ void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) if( !sd->status.party_id ) return; - p = party_search(sd->status.party_id); + p = iParty->search(sd->status.party_id); if( p == NULL ) return; @@ -12069,9 +12070,9 @@ void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) #if PACKETVER < 20090603 //Client can't change the item-field - party_changeoption(sd, RFIFOL(fd,2), p->party.item); + iParty->changeoption(sd, RFIFOL(fd,2), p->party.item); #else - party_changeoption(sd, RFIFOL(fd,2), ((RFIFOB(fd,6)?1:0)|(RFIFOB(fd,7)?2:0))); + iParty->changeoption(sd, RFIFOL(fd,2), ((RFIFOB(fd,6)?1:0)|(RFIFOB(fd,7)?2:0))); #endif } @@ -12098,12 +12099,12 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd) if( battle_config.min_chat_delay ) { //[Skotlex] - if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0) + if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) return; - sd->cantalk_tick = gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; } - party_send_message(sd, text, textlen); + iParty->send_message(sd, text, textlen); } @@ -12111,7 +12112,7 @@ void clif_parse_PartyMessage(int fd, struct map_session_data* sd) /// 07da <account id>.L void clif_parse_PartyChangeLeader(int fd, struct map_session_data* sd) { - party_changeleader(sd, map_id2sd(RFIFOL(fd,2))); + iParty->changeleader(sd, iMap->id2sd(RFIFOL(fd,2))); } @@ -12130,7 +12131,7 @@ void clif_parse_PartyBookingRegisterReq(int fd, struct map_session_data* sd) for(i=0; i<PARTY_BOOKING_JOBS; i++) job[i] = RFIFOB(fd,6+i*2); - party_booking_register(sd, level, mapid, job); + iParty->booking_register(sd, level, mapid, job); } @@ -12161,7 +12162,7 @@ void clif_parse_PartyBookingSearchReq(int fd, struct map_session_data* sd) unsigned long lastindex = RFIFOL(fd,8); short resultcount = RFIFOW(fd,12); - party_booking_search(sd, level, mapid, job, lastindex, resultcount); + iParty->booking_search(sd, level, mapid, job, lastindex, resultcount); } @@ -12198,7 +12199,7 @@ void clif_PartyBookingSearchAck(int fd, struct party_booking_ad_info** results, /// 0806 void clif_parse_PartyBookingDeleteReq(int fd, struct map_session_data* sd) { - if(party_booking_delete(sd)) + if(iParty->booking_delete(sd)) clif->PartyBookingDeleteAck(sd, 0); } @@ -12231,7 +12232,7 @@ void clif_parse_PartyBookingUpdateReq(int fd, struct map_session_data* sd) for(i=0; i<PARTY_BOOKING_JOBS; i++) job[i] = RFIFOW(fd,2+i*2); - party_booking_update(sd, job); + iParty->booking_update(sd, job); } @@ -12359,7 +12360,7 @@ void clif_parse_OpenVending(int fd, struct map_session_data* sd) clif->message (sd->fd, msg_txt(276)); // "You can't open a shop on this map" return; } - if( map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) ) { + if( iMap->getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) ) { clif->message (sd->fd, msg_txt(204)); // "You can't open a shop on this cell." return; } @@ -12557,7 +12558,7 @@ clif_sub_guild_invite(int fd, struct map_session_data *sd, struct map_session_da /// 0168 <account id>.L <inviter account id>.L <inviter char id>.L void clif_parse_GuildInvite(int fd,struct map_session_data *sd) { - struct map_session_data *t_sd = map_id2sd(RFIFOL(fd,2)); + struct map_session_data *t_sd = iMap->id2sd(RFIFOL(fd,2)); if (clif_sub_guild_invite(fd, sd, t_sd)) return; @@ -12567,7 +12568,7 @@ void clif_parse_GuildInvite(int fd,struct map_session_data *sd) /// 0916 <char name>.24B void clif_parse_GuildInvite2(int fd, struct map_session_data *sd) { - struct map_session_data *t_sd = map_nick2sd((char *)RFIFOP(fd, 2)); + struct map_session_data *t_sd = iMap->nick2sd((char *)RFIFOP(fd, 2)); if (clif_sub_guild_invite(fd, sd, t_sd)) return; @@ -12635,9 +12636,9 @@ void clif_parse_GuildMessage(int fd, struct map_session_data* sd) if( battle_config.min_chat_delay ) { //[Skotlex] - if (DIFF_TICK(sd->cantalk_tick, gettick()) > 0) + if (DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0) return; - sd->cantalk_tick = gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; } if( sd->bg_id ) @@ -12661,7 +12662,7 @@ void clif_parse_GuildRequestAlliance(int fd, struct map_session_data *sd) return; } - t_sd = map_id2sd(RFIFOL(fd,2)); + t_sd = iMap->id2sd(RFIFOL(fd,2)); // @noask [LuzZza] if(t_sd && t_sd->state.noask) { @@ -12716,7 +12717,7 @@ void clif_parse_GuildOpposition(int fd, struct map_session_data *sd) return; } - t_sd = map_id2sd(RFIFOL(fd,2)); + t_sd = iMap->id2sd(RFIFOL(fd,2)); // @noask [LuzZza] if(t_sd && t_sd->state.noask) { @@ -12831,7 +12832,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) int tid; tid = RFIFOL(fd,2); - target = map_id2bl(tid); + target = iMap->id2bl(tid); if (!target) { clif->GM_kickack(sd, 0); return; @@ -12852,7 +12853,7 @@ void clif_parse_GMKick(int fd, struct map_session_data *sd) case BL_MOB: { char command[100]; - if( !pc_can_use_command(sd, "@killmonster")) { + if( !iPc->can_use_command(sd, "@killmonster")) { clif->GM_kickack(sd, 0); return; } @@ -12915,7 +12916,7 @@ void clif_parse_GMRemove2(int fd, struct map_session_data* sd) struct map_session_data* pl_sd; account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - if( (pl_sd = map_id2sd(account_id)) != NULL ) { + if( (pl_sd = iMap->id2sd(account_id)) != NULL ) { char command[NAME_LENGTH+8]; sprintf(command, "%cjumpto %s", atcommand->at_symbol, pl_sd->status.name); atcommand->parse(fd, sd, command, 1); @@ -12952,7 +12953,7 @@ void clif_parse_GMRecall2(int fd, struct map_session_data* sd) struct map_session_data* pl_sd; account_id = RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]); - if( (pl_sd = map_id2sd(account_id)) != NULL ) { + if( (pl_sd = iMap->id2sd(account_id)) != NULL ) { char command[NAME_LENGTH+8]; sprintf(command, "%crecall %s", atcommand->at_symbol, pl_sd->status.name); atcommand->parse(fd, sd, command, 1); @@ -13023,10 +13024,10 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) //If type is 2 and the ids don't match, this is a crafted hacked packet! //Disabled because clients keep self-muting when you give players public @ commands... [Skotlex] - if (type == 2 /* && (pc_get_group_level(sd) > 0 || sd->bl.id != id)*/) + if (type == 2 /* && (iPc->get_group_level(sd) > 0 || sd->bl.id != id)*/) return; - dstsd = map_id2sd(id); + dstsd = iMap->id2sd(id); if( dstsd == NULL ) return; @@ -13090,7 +13091,7 @@ void clif_parse_GMChangeMapType(int fd, struct map_session_data *sd) y = RFIFOW(fd,4); type = RFIFOW(fd,6); - map_setgatcell(sd->bl.m,x,y,type); + iMap->setgatcell(sd->bl.m,x,y,type); clif->changemapcell(0,sd->bl.m,x,y,type,ALL_SAMEMAP); //FIXME: once players leave the map, the client 'forgets' this information. } @@ -13113,7 +13114,7 @@ void clif_parse_PMIgnore(int fd, struct map_session_data* sd) type = RFIFOB(fd,26); if( type == 0 ) { // Add name to ignore list (block) - if (strcmp(wisp_server_name, nick) == 0) { + if (strcmp(iMap->wisp_server_name, nick) == 0) { clif->wisexin(sd, type, 1); // fail return; } @@ -13240,8 +13241,8 @@ void clif_parse_NoviceDoriDori(int fd, struct map_session_data *sd) void clif_parse_NoviceExplosionSpirits(int fd, struct map_session_data *sd) { if( ( sd->class_&MAPID_UPPERMASK ) == MAPID_SUPER_NOVICE ) { - unsigned int next = pc_nextbaseexp(sd); - if( next == 0 ) next = pc_thisbaseexp(sd); + unsigned int next = iPc->nextbaseexp(sd); + if( next == 0 ) next = iPc->thisbaseexp(sd); if( next ) { int percent = (int)( ( (float)sd->status.base_exp/(float)next )*1000. ); @@ -13314,7 +13315,7 @@ void clif_friendslist_send(struct map_session_data *sd) } for (n = 0; n < i; n++) { //Sending the online players - if (map_charid2sd(sd->status.friends[n].char_id)) + if (iMap->charid2sd(sd->status.friends[n].char_id)) clif->friendslist_toggle(sd, sd->status.friends[n].account_id, sd->status.friends[n].char_id, 1); } } @@ -13366,7 +13367,7 @@ void clif_parse_FriendsListAdd(int fd, struct map_session_data *sd) struct map_session_data *f_sd; int i; - f_sd = map_nick2sd((char*)RFIFOP(fd,2)); + f_sd = iMap->nick2sd((char*)RFIFOP(fd,2)); // ensure that the request player's friend list is not full ARR_FIND(0, MAX_FRIENDS, i, sd->status.friends[i].char_id == 0); @@ -13431,7 +13432,7 @@ void clif_parse_FriendsListReply(int fd, struct map_session_data *sd) return; } - f_sd = map_id2sd(account_id); //The account id is the same as the bl.id of players. + f_sd = iMap->id2sd(account_id); //The account id is the same as the bl.id of players. if (f_sd == NULL) return; @@ -13496,7 +13497,7 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) } //remove from friend's list first - if( (f_sd = map_id2sd(account_id)) && f_sd->status.char_id == char_id) { + if( (f_sd = iMap->id2sd(account_id)) && f_sd->status.char_id == char_id) { for (i = 0; i < MAX_FRIENDS && (f_sd->status.friends[i].char_id != sd->status.char_id || f_sd->status.friends[i].account_id != sd->status.account_id); i++); @@ -13577,7 +13578,7 @@ void clif_blacksmith(struct map_session_data* sd) for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) { if (smith_fame_list[i].id > 0) { if (strcmp(smith_fame_list[i].name, "-") == 0 && - (name = map_charid2nick(smith_fame_list[i].id)) != NULL) + (name = iMap->charid2nick(smith_fame_list[i].id)) != NULL) { strncpy((char *)(WFIFOP(fd, 2 + 24 * i)), name, NAME_LENGTH); } else @@ -13629,7 +13630,7 @@ void clif_alchemist(struct map_session_data* sd) { for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) { if (chemist_fame_list[i].id > 0) { if (strcmp(chemist_fame_list[i].name, "-") == 0 && - (name = map_charid2nick(chemist_fame_list[i].id)) != NULL) + (name = iMap->charid2nick(chemist_fame_list[i].id)) != NULL) { memcpy(WFIFOP(fd, 2 + 24 * i), name, NAME_LENGTH); } else @@ -13681,7 +13682,7 @@ void clif_taekwon(struct map_session_data* sd) { for (i = 0; i < 10 && i < MAX_FAME_LIST; i++) { if (taekwon_fame_list[i].id > 0) { if (strcmp(taekwon_fame_list[i].name, "-") == 0 && - (name = map_charid2nick(taekwon_fame_list[i].id)) != NULL) + (name = iMap->charid2nick(taekwon_fame_list[i].id)) != NULL) { memcpy(WFIFOP(fd, 2 + 24 * i), name, NAME_LENGTH); } else @@ -13881,7 +13882,7 @@ void clif_parse_HomMenu(int fd, struct map_session_data *sd) { //[orn] /// 0292 void clif_parse_AutoRevive(int fd, struct map_session_data *sd) { - int item_position = pc_search_inventory(sd, ITEMID_TOKEN_OF_SIEGFRIED); + int item_position = iPc->search_inventory(sd, ITEMID_TOKEN_OF_SIEGFRIED); if (item_position < 0) return; @@ -13893,7 +13894,7 @@ void clif_parse_AutoRevive(int fd, struct map_session_data *sd) return; clif->skill_nodamage(&sd->bl,&sd->bl,ALL_RESURRECTION,4,1); - pc_delitem(sd, item_position, 1, 0, 1, LOG_TYPE_CONSUME); + iPc->delitem(sd, item_position, 1, 0, 1, LOG_TYPE_CONSUME); } @@ -13908,17 +13909,17 @@ void clif_check(int fd, struct map_session_data* pl_sd) { WFIFOHEAD(fd,packet_len(0x214)); WFIFOW(fd, 0) = 0x214; WFIFOB(fd, 2) = min(pl_sd->status.str, UINT8_MAX); - WFIFOB(fd, 3) = pc_need_status_point(pl_sd, SP_STR, 1); + WFIFOB(fd, 3) = iPc->need_status_point(pl_sd, SP_STR, 1); WFIFOB(fd, 4) = min(pl_sd->status.agi, UINT8_MAX); - WFIFOB(fd, 5) = pc_need_status_point(pl_sd, SP_AGI, 1); + WFIFOB(fd, 5) = iPc->need_status_point(pl_sd, SP_AGI, 1); WFIFOB(fd, 6) = min(pl_sd->status.vit, UINT8_MAX); - WFIFOB(fd, 7) = pc_need_status_point(pl_sd, SP_VIT, 1); + WFIFOB(fd, 7) = iPc->need_status_point(pl_sd, SP_VIT, 1); WFIFOB(fd, 8) = min(pl_sd->status.int_, UINT8_MAX); - WFIFOB(fd, 9) = pc_need_status_point(pl_sd, SP_INT, 1); + WFIFOB(fd, 9) = iPc->need_status_point(pl_sd, SP_INT, 1); WFIFOB(fd,10) = min(pl_sd->status.dex, UINT8_MAX); - WFIFOB(fd,11) = pc_need_status_point(pl_sd, SP_DEX, 1); + WFIFOB(fd,11) = iPc->need_status_point(pl_sd, SP_DEX, 1); WFIFOB(fd,12) = min(pl_sd->status.luk, UINT8_MAX); - WFIFOB(fd,13) = pc_need_status_point(pl_sd, SP_LUK, 1); + WFIFOB(fd,13) = iPc->need_status_point(pl_sd, SP_LUK, 1); WFIFOW(fd,14) = pl_sd->battle_status.batk+pl_sd->battle_status.rhw.atk+pl_sd->battle_status.lhw.atk; WFIFOW(fd,16) = pl_sd->battle_status.rhw.atk2+pl_sd->battle_status.lhw.atk2; WFIFOW(fd,18) = pl_sd->battle_status.matk_max; @@ -13950,7 +13951,7 @@ void clif_parse_Check(int fd, struct map_session_data *sd) safestrncpy(charname, (const char*)RFIFOP(fd,packet_db[RFIFOW(fd,0)].pos[0]), sizeof(charname)); - if( ( pl_sd = map_nick2sd(charname) ) == NULL || pc_get_group_level(sd) < pc_get_group_level(pl_sd) ) { + if( ( pl_sd = iMap->nick2sd(charname) ) == NULL || iPc->get_group_level(sd) < iPc->get_group_level(pl_sd) ) { return; } @@ -14232,9 +14233,9 @@ void clif_parse_Mail_getattach(int fd, struct map_session_data *sd) if ((data = itemdb_exists(sd->mail.inbox.msg[i].item.nameid)) == NULL) return; - switch( pc_checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) ) { + switch( iPc->checkadditem(sd, data->nameid, sd->mail.inbox.msg[i].item.amount) ) { case ADDITEM_NEW: - fail = ( pc_inventoryblank(sd) == 0 ); + fail = ( iPc->inventoryblank(sd) == 0 ); break; case ADDITEM_OVERAMOUNT: fail = true; @@ -14360,7 +14361,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) return; } - if( DIFF_TICK(sd->cansendmail_tick, gettick()) > 0 ) { + if( DIFF_TICK(sd->cansendmail_tick, iTimer->gettick()) > 0 ) { clif->message(sd->fd,msg_txt(675)); //"Cannot send mails too fast!!." clif->mail_send(fd, true); // fail return; @@ -14398,7 +14399,7 @@ void clif_parse_Mail_send(int fd, struct map_session_data *sd) if( !intif_Mail_send(sd->status.account_id, &msg) ) mail_deliveryfail(sd, &msg); - sd->cansendmail_tick = gettick() + 1000; // 1 Second flood Protection + sd->cansendmail_tick = iTimer->gettick() + 1000; // 1 Second flood Protection } @@ -14526,9 +14527,9 @@ void clif_parse_Auction_setitem(int fd, struct map_session_data *sd) return; } - if( !pc_can_give_items(sd) || sd->status.inventory[idx].expire_time || + if( !iPc->can_give_items(sd) || sd->status.inventory[idx].expire_time || !sd->status.inventory[idx].identify || - !itemdb_canauction(&sd->status.inventory[idx],pc_get_group_level(sd)) ) { // Quest Item or something else + !itemdb_canauction(&sd->status.inventory[idx],iPc->get_group_level(sd)) ) { // Quest Item or something else clif->auction_setitem(sd->fd, idx, true); return; } @@ -14645,10 +14646,10 @@ void clif_parse_Auction_register(int fd, struct map_session_data *sd) { int zeny = auction.hours*battle_config.auction_feeperhour; - pc_delitem(sd, sd->auction.index, sd->auction.amount, 1, 6, LOG_TYPE_AUCTION); + iPc->delitem(sd, sd->auction.index, sd->auction.amount, 1, 6, LOG_TYPE_AUCTION); sd->auction.amount = 0; - pc_payzeny(sd, zeny, LOG_TYPE_AUCTION, NULL); + iPc->payzeny(sd, zeny, LOG_TYPE_AUCTION, NULL); } } @@ -14680,7 +14681,7 @@ void clif_parse_Auction_bid(int fd, struct map_session_data *sd) unsigned int auction_id = RFIFOL(fd,2); int bid = RFIFOL(fd,6); - if( !pc_can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish] + if( !iPc->can_give_items(sd) ) { //They aren't supposed to give zeny [Inkfish] clif->message(sd->fd, msg_txt(246)); return; } @@ -14692,7 +14693,7 @@ void clif_parse_Auction_bid(int fd, struct map_session_data *sd) else if ( CheckForCharServer() ) // char server is down (bugreport:1138) clif->auction_message(fd, 0); // You have failed to bid into the auction else { - pc_payzeny(sd, bid, LOG_TYPE_AUCTION, NULL); + iPc->payzeny(sd, bid, LOG_TYPE_AUCTION, NULL); intif_Auction_bid(sd->status.char_id, sd->status.name, auction_id, bid); } } @@ -14877,9 +14878,9 @@ void clif_Adopt_request(struct map_session_data *sd, struct map_session_data *sr /// 01f9 <account id>.L void clif_parse_Adopt_request(int fd, struct map_session_data *sd) { - struct map_session_data *tsd = map_id2sd(RFIFOL(fd,2)), *p_sd = map_charid2sd(sd->status.partner_id); + struct map_session_data *tsd = iMap->id2sd(RFIFOL(fd,2)), *p_sd = iMap->charid2sd(sd->status.partner_id); - if( pc_can_Adopt(sd, p_sd, tsd) ) { + if( iPc->can_Adopt(sd, p_sd, tsd) ) { tsd->adopt_invite = sd->status.account_id; clif->adopt_request(tsd, sd, p_sd->status.account_id); } @@ -14896,8 +14897,8 @@ void clif_parse_Adopt_reply(int fd, struct map_session_data *sd) int p1_id = RFIFOL(fd,2); int p2_id = RFIFOL(fd,6); int result = RFIFOL(fd,10); - struct map_session_data* p1_sd = map_id2sd(p1_id); - struct map_session_data* p2_sd = map_id2sd(p2_id); + struct map_session_data* p1_sd = iMap->id2sd(p1_id); + struct map_session_data* p2_sd = iMap->id2sd(p2_id); int pid = sd->adopt_invite; sd->adopt_invite = 0; @@ -14911,7 +14912,7 @@ void clif_parse_Adopt_reply(int fd, struct map_session_data *sd) if( result == 0 ) return; // Rejected - pc_adoption(p1_sd, p2_sd, sd); + iPc->adoption(p1_sd, p2_sd, sd); } @@ -14937,11 +14938,11 @@ void clif_bossmapinfo(int fd, struct mob_data *md, short flag) } else WFIFOB(fd,2) = 2; // First Time } else if (md->spawn_timer != INVALID_TIMER) { // Boss is Dead - const struct TimerData * timer_data = get_timer(md->spawn_timer); + const struct TimerData * timer_data = iTimer->get_timer(md->spawn_timer); unsigned int seconds; int hours, minutes; - seconds = DIFF_TICK(timer_data->tick, gettick()) / 1000 + 60; + seconds = DIFF_TICK(timer_data->tick, iTimer->gettick()) / 1000 + 60; hours = seconds / (60 * 60); seconds = seconds - (60 * 60 * hours); minutes = seconds / 60; @@ -14962,7 +14963,7 @@ void clif_bossmapinfo(int fd, struct mob_data *md, short flag) void clif_parse_ViewPlayerEquip(int fd, struct map_session_data* sd) { int charid = RFIFOL(fd, 2); - struct map_session_data* tsd = map_id2sd(charid); + struct map_session_data* tsd = iMap->id2sd(charid); if (!tsd) return; @@ -15487,9 +15488,9 @@ void clif_parse_BattleChat(int fd, struct map_session_data* sd) return; if( battle_config.min_chat_delay ) { - if( DIFF_TICK(sd->cantalk_tick, gettick()) > 0 ) + if( DIFF_TICK(sd->cantalk_tick, iTimer->gettick()) > 0 ) return; - sd->cantalk_tick = gettick() + battle_config.min_chat_delay; + sd->cantalk_tick = iTimer->gettick() + battle_config.min_chat_delay; } bg_send_message(sd, text, textlen); @@ -15571,48 +15572,61 @@ void clif_font(struct map_session_data *sd) /*========================================== * Instancing Window *------------------------------------------*/ -int clif_instance(int instance_id, int type, int flag) -{ - struct map_session_data *sd; - struct party_data *p; +int clif_instance(int instance_id, int type, int flag) { + struct map_session_data *sd = NULL; unsigned char buf[255]; + enum send_target target = PARTY; + + switch( instances[instance_id].owner_type ) { + case IOT_NONE: + return 0; + case IOT_GUILD: + target = GUILD; + sd = guild->getavailablesd(guild->search(instances[instance_id].owner_id)); + break; + case IOT_PARTY: + /* default is already PARTY */ + sd = iParty->getavailablesd(iParty->search(instances[instance_id].owner_id)); + break; + case IOT_CHAR: + target = SELF; + sd = iMap->id2sd(instances[instance_id].owner_id); + break; + } - if( (p = party_search(instance[instance_id].party_id)) == NULL || (sd = party_getavailablesd(p)) == NULL ) + if( !sd ) return 0; - + switch( type ) { case 1: // S 0x2cb <Instance name>.61B <Standby Position>.W // Required to start the instancing information window on Client // This window re-appear each "refresh" of client automatically until type 4 is send to client. WBUFW(buf,0) = 0x02CB; - memcpy(WBUFP(buf,2),instance[instance_id].name,INSTANCE_NAME_LENGTH); + memcpy(WBUFP(buf,2),instances[instance_id].name,INSTANCE_NAME_LENGTH); WBUFW(buf,63) = flag; - clif->send(buf,packet_len(0x02CB),&sd->bl,PARTY); + clif->send(buf,packet_len(0x02CB),&sd->bl,target); break; case 2: // S 0x2cc <Standby Position>.W // To announce Instancing queue creation if no maps available WBUFW(buf,0) = 0x02CC; WBUFW(buf,2) = flag; - clif->send(buf,packet_len(0x02CC),&sd->bl,PARTY); + clif->send(buf,packet_len(0x02CC),&sd->bl,target); break; case 3: case 4: // S 0x2cd <Instance Name>.61B <Instance Remaining Time>.L <Instance Noplayers close time>.L WBUFW(buf,0) = 0x02CD; - memcpy(WBUFP(buf,2),instance[instance_id].name,61); - if( type == 3 ) - { - WBUFL(buf,63) = (uint32)instance[instance_id].progress_timeout; + memcpy(WBUFP(buf,2),instances[instance_id].name,61); + if( type == 3 ) { + WBUFL(buf,63) = instances[instance_id].progress_timeout; WBUFL(buf,67) = 0; - } - else - { + } else { WBUFL(buf,63) = 0; - WBUFL(buf,67) = (uint32)instance[instance_id].idle_timeout; + WBUFL(buf,67) = instances[instance_id].idle_timeout; } - clif->send(buf,packet_len(0x02CD),&sd->bl,PARTY); + clif->send(buf,packet_len(0x02CD),&sd->bl,target); break; case 5: // S 0x2ce <Message ID>.L @@ -15624,7 +15638,7 @@ int clif_instance(int instance_id, int type, int flag) WBUFW(buf,0) = 0x02CE; WBUFL(buf,2) = flag; //WBUFL(buf,6) = EnterLimitDate; - clif->send(buf,packet_len(0x02CE),&sd->bl,PARTY); + clif->send(buf,packet_len(0x02CE),&sd->bl,target); break; } return 0; @@ -15632,24 +15646,24 @@ int clif_instance(int instance_id, int type, int flag) void clif_instance_join(int fd, int instance_id) { - if( instance[instance_id].idle_timer != INVALID_TIMER ) { + if( instances[instance_id].idle_timer != INVALID_TIMER ) { WFIFOHEAD(fd,packet_len(0x02CD)); WFIFOW(fd,0) = 0x02CD; - memcpy(WFIFOP(fd,2),instance[instance_id].name,61); + memcpy(WFIFOP(fd,2),instances[instance_id].name,61); WFIFOL(fd,63) = 0; - WFIFOL(fd,67) = (uint32)instance[instance_id].idle_timeout; + WFIFOL(fd,67) = instances[instance_id].idle_timeout; WFIFOSET(fd,packet_len(0x02CD)); - } else if( instance[instance_id].progress_timer != INVALID_TIMER ) { + } else if( instances[instance_id].progress_timer != INVALID_TIMER ) { WFIFOHEAD(fd,packet_len(0x02CD)); WFIFOW(fd,0) = 0x02CD; - memcpy(WFIFOP(fd,2),instance[instance_id].name,61); - WFIFOL(fd,63) = (uint32)instance[instance_id].progress_timeout;; + memcpy(WFIFOP(fd,2),instances[instance_id].name,61); + WFIFOL(fd,63) = instances[instance_id].progress_timeout; WFIFOL(fd,67) = 0; WFIFOSET(fd,packet_len(0x02CD)); } else { WFIFOHEAD(fd,packet_len(0x02CB)); WFIFOW(fd,0) = 0x02CB; - memcpy(WFIFOP(fd,2),instance[instance_id].name,61); + memcpy(WFIFOP(fd,2),instances[instance_id].name,61); WFIFOW(fd,63) = 0; WFIFOSET(fd,packet_len(0x02CB)); } @@ -16822,14 +16836,14 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) { if (!itemdb_isstackable2(data)) get_count = 1; - pc_paycash(sd, clif->cs.data[tab][j]->price * qty, kafra_pay);// [Ryuuzaki] + iPc->paycash(sd, clif->cs.data[tab][j]->price * qty, kafra_pay);// [Ryuuzaki] for (k = 0; k < qty; k += get_count) { if (!pet_create_egg(sd, data->nameid)) { memset(&item_tmp, 0, sizeof(item_tmp)); item_tmp.nameid = data->nameid; item_tmp.identify = 1; - switch (pc_additem(sd, &item_tmp, get_count, LOG_TYPE_NPC)) { + switch (iPc->additem(sd, &item_tmp, get_count, LOG_TYPE_NPC)) { case 0: result = CSBR_SUCCESS; break; @@ -16851,7 +16865,7 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) { } if( result != CSBR_SUCCESS ) - pc_getcash(sd, clif->cs.data[tab][j]->price * get_count,0); + iPc->getcash(sd, clif->cs.data[tab][j]->price * get_count,0); } } } @@ -16947,6 +16961,133 @@ void clif_status_change_end(struct block_list *bl, int tid, enum send_target tar clif->send(&p,sizeof(p), bl, target); } +void clif_bgqueue_ack(struct map_session_data *sd, enum BATTLEGROUNDS_QUEUE_ACK response, unsigned char arena_id) { + + switch (response) { + case BGQA_FAIL_COOLDOWN: + case BGQA_FAIL_DESERTER: + case BGQA_FAIL_TEAM_COUNT: + break; + default: { + struct packet_bgqueue_ack p; + + p.PacketType = bgqueue_ackType; + p.type = response; + safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name)); + + clif->send(&p,sizeof(p), &sd->bl, SELF); + } + break; + } +} + + +void clif_bgqueue_notice_delete(struct map_session_data *sd, enum BATTLEGROUNDS_QUEUE_NOTICE_DELETED response, unsigned char arena_id) { + struct packet_bgqueue_notice_delete p; + + p.PacketType = bgqueue_notice_deleteType; + p.type = response; + safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name)); + + clif->send(&p,sizeof(p), &sd->bl, SELF); +} + +void clif_parse_bgqueue_register(int fd, struct map_session_data *sd) { + struct packet_bgqueue_register *p = P2PTR(fd, bgqueue_registerType); + struct bg_arena *arena = NULL; + + if( !bg->queue_on ) return; /* temp, until feature is complete */ + + if( !(arena = bg->name2arena(p->bg_name)) ) { + clif->bgqueue_ack(sd,BGQA_FAIL_BGNAME_INVALID,0); + return; + } + + switch( (enum bg_queue_types)p->type ) { + case BGQT_INDIVIDUAL: + case BGQT_PARTY: + case BGQT_GUILD: + break; + default: + clif->bgqueue_ack(sd,BGQA_FAIL_TYPE_INVALID, arena->id); + return; + } + + bg->queue_add(sd, arena, (enum bg_queue_types)p->type); +} + +void clif_bgqueue_update_info(struct map_session_data *sd, unsigned char arena_id, int position) { + struct packet_bgqueue_update_info p; + + p.PacketType = bgqueue_updateinfoType; + safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name)); + p.position = position; + + sd->bg_queue.client_has_bg_data = true; // Client creates bg data when this packet arrives + + clif->send(&p,sizeof(p), &sd->bl, SELF); +} + +void clif_parse_bgqueue_checkstate(int fd, struct map_session_data *sd) { + //struct packet_bgqueue_checkstate *p = P2PTR(fd, bgqueue_checkstateType); /* TODO: bgqueue_notice_delete should use this p->bg_name */ + if( !bg->queue_on ) return; /* temp, until feature is complete */ + if ( sd->bg_queue.arena && sd->bg_queue.type ) { + sd->bg_queue.client_has_bg_data = true; + clif->bgqueue_update_info(sd,sd->bg_queue.arena->id,bg->id2pos(sd->bg_queue.arena->queue_id,sd->status.account_id)); + } else + clif->bgqueue_notice_delete(sd, BGQND_FAIL_NOT_QUEUING,0);/* TODO: wrong response, should respond with p->bg_name not id 0 */ +} + +void clif_parse_bgqueue_revoke_req(int fd, struct map_session_data *sd) { + //struct packet_bgqueue_revoke_req *p = P2PTR(fd, bgqueue_revokereqType); + return; + //bg->queue_leave(sd, p->bg_name); +} + +void clif_parse_bgqueue_battlebegin_ack(int fd, struct map_session_data *sd) { + //struct packet_bgqueue_battlebegin_ack *p = P2PTR(fd, bgqueue_checkstateType); + return; + //if ( p->result == 1 ) + // bg->queue_pc_ready(sd); + //else + // bg->queue_leave(sd, p->bg_name); +} + +void clif_bgqueue_joined(struct map_session_data *sd, int pos) { + struct packet_bgqueue_notify_entry p; + + p.PacketType = bgqueue_notify_entryType; + safestrncpy(p.name,sd->status.name,sizeof(p.name)); + p.position = pos; + + clif->send(&p,sizeof(p), &sd->bl, BG_QUEUE); +} + +void clif_bgqueue_pcleft(struct map_session_data *sd) { + /* no idea */ + return; +} + +// Sends BG ready req to all with same bg arena/type as sd +void clif_bgqueue_battlebegins(struct map_session_data *sd, unsigned char arena_id, enum send_target target) { + struct packet_bgqueue_battlebegins p; + + p.PacketType = bgqueue_battlebegins; + safestrncpy(p.bg_name, bg->arena[arena_id]->name, sizeof(p.bg_name)); + safestrncpy(p.game_name, bg->arena[arena_id]->name, sizeof(p.game_name)); + + clif->send(&p,sizeof(p), &sd->bl, target); +} + +void clif_scriptclear(struct map_session_data *sd, int npcid) { + struct packet_script_clear p; + + p.PacketType = script_clearType; + p.NpcID = npcid; + + clif->send(&p,sizeof(p), &sd->bl, SELF); +} + /*========================================== * Main client packet processing function *------------------------------------------*/ @@ -16977,7 +17118,7 @@ int clif_parse(int fd) { } else { //Unusual logout (during log on/off/map-changer procedure) ShowInfo("Player AID:%d/CID:%d logged off.\n", sd->status.account_id, sd->status.char_id); - map_quit(sd); + iMap->quit(sd); } } else { ShowInfo("Closed connection from '"CL_WHITE"%s"CL_RESET"'.\n", ip2str(session[fd]->client_addr, NULL)); @@ -17122,6 +17263,7 @@ void clif_bc_ready(void) { int do_init_clif(void) { const char* colors[COLOR_MAX] = { "0xFF0000", "0x00ff00", "0xffffff" }; int i; + /** * Setup Color Table (saves unnecessary load of strtoul on every call) **/ @@ -17138,8 +17280,8 @@ int do_init_clif(void) { exit(EXIT_FAILURE); } - add_timer_func_list(clif->clearunit_delayed_sub, "clif_clearunit_delayed_sub"); - add_timer_func_list(clif->delayquit, "clif_delayquit"); + iTimer->add_timer_func_list(clif->clearunit_delayed_sub, "clif_clearunit_delayed_sub"); + iTimer->add_timer_func_list(clif->delayquit, "clif_delayquit"); clif->delay_clearunit_ers = ers_new(sizeof(struct block_list),"clif.c::delay_clearunit_ers",ERS_OPT_CLEAR); @@ -17277,6 +17419,7 @@ void clif_defaults(void) { clif->scriptinputstr = clif_scriptinputstr; clif->cutin = clif_cutin; clif->sendfakenpc = clif_sendfakenpc; + clif->scriptclear = clif_scriptclear; /* client-user-interface-related */ clif->viewpoint = clif_viewpoint; clif->damage = clif_damage; @@ -17611,13 +17754,7 @@ void clif_defaults(void) { /* elemental-related */ clif->elemental_info = clif_elemental_info; clif->elemental_updatestatus = clif_elemental_updatestatus; - /* misc-handling */ - clif->adopt_reply = clif_Adopt_reply; - clif->adopt_request = clif_Adopt_request; - clif->readbook = clif_readbook; - clif->notify_time = clif_notify_time; - clif->user_count = clif_user_count; - clif->noask_sub = clif_noask_sub; + /* Hercules Channel System */ clif->chsys_create = clif_hercules_chsys_create; clif->chsys_msg = clif_hercules_chsys_msg; clif->chsys_msg2 = clif_hercules_chsys_msg2; @@ -17630,6 +17767,20 @@ void clif_defaults(void) { clif->chsys_quitg = clif_hercules_chsys_quitg; clif->chsys_gjoin = clif_hercules_chsys_gjoin; clif->chsys_gleave = clif_hercules_chsys_gleave; + /* bgqueue */ + clif->bgqueue_ack = clif_bgqueue_ack; + clif->bgqueue_notice_delete = clif_bgqueue_notice_delete; + clif->bgqueue_update_info = clif_bgqueue_update_info; + clif->bgqueue_joined = clif_bgqueue_joined; + clif->bgqueue_pcleft = clif_bgqueue_pcleft; + clif->bgqueue_battlebegins = clif_bgqueue_battlebegins; + /* misc-handling */ + clif->adopt_reply = clif_Adopt_reply; + clif->adopt_request = clif_Adopt_request; + clif->readbook = clif_readbook; + clif->notify_time = clif_notify_time; + clif->user_count = clif_user_count; + clif->noask_sub = clif_noask_sub; clif->cashshop_load = clif_cashshop_db; clif->bc_ready = clif_bc_ready; clif->undisguise_timer = clif_undisguise_timer; @@ -17835,6 +17986,11 @@ void clif_defaults(void) { clif->pCashShopReqTab = clif_parse_CashShopReqTab; clif->pCashShopSchedule = clif_parse_CashShopSchedule; clif->pCashShopBuy = clif_parse_CashShopBuy; + /* BGQueue */ + clif->pBGQueueRegister = clif_parse_bgqueue_register; + clif->pBGQueueCheckState = clif_parse_bgqueue_checkstate; + clif->pBGQueueRevokeReq = clif_parse_bgqueue_revoke_req; + clif->pBGQueueBattleBeginAck = clif_parse_bgqueue_battlebegin_ack; /* */ clif->pPartyTick = clif_parse_PartyTick; clif->pGuildInvite2 = clif_parse_GuildInvite2; |