From f0fb58027eaaab3572aac3c89227aeab05423819 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Thu, 23 Oct 2008 00:08:26 +0000 Subject: Commit Mantis tasks 486 and 460 --- src/char/char.c | 27 ++++++++++++------ src/common/timer.h | 4 +-- src/map/chrif.c | 8 +----- src/map/clif.c | 84 ++++++++++++++++++++++++++++++++++++++++++------------ src/map/clif.h | 2 ++ src/map/map.h | 17 ++++++++++- src/map/pc.c | 68 ++++++++++++++++++++++--------------------- 7 files changed, 140 insertions(+), 70 deletions(-) (limited to 'src') diff --git a/src/char/char.c b/src/char/char.c index aa4d554..a92a7c3 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -1247,6 +1247,19 @@ int count_users(void) { return users; } +//---------------------------------------- +// [Fate] Find inventory item based on equipment mask, return view. ID must match view ID (!). +//---------------------------------------- +static int +find_equip_view(struct mmo_charstatus *p, unsigned int equipmask) +{ + int i; + for (i = 0; i < MAX_INVENTORY; i++) + if (p->inventory[i].amount + && p->inventory[i].equip & equipmask) + return p->inventory[i].nameid; + return 0; +} //---------------------------------------- // Function to send characters to a player @@ -1286,8 +1299,10 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) { WFIFOL(fd,j+12) = p->job_exp; WFIFOL(fd,j+16) = p->job_level; - WFIFOL(fd,j+20) = 0; - WFIFOL(fd,j+24) = 0; + WFIFOW(fd,j+20) = find_equip_view(p, 0x0040); // 9: shoes + WFIFOW(fd,j+22) = find_equip_view(p, 0x0004); // 10: gloves + WFIFOW(fd,j+24) = find_equip_view(p, 0x0008); // 11: cape + WFIFOW(fd,j+26) = find_equip_view(p, 0x0010); // 12: misc1 WFIFOL(fd,j+28) = p->option; WFIFOL(fd,j+32) = p->karma; @@ -1310,7 +1325,8 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) { WFIFOW(fd,j+66) = p->head_top; WFIFOW(fd,j+68) = p->head_mid; WFIFOW(fd,j+70) = p->hair_color; - WFIFOW(fd,j+72) = p->clothes_color; + WFIFOW(fd,j+72) = find_equip_view(p, 0x0080); // 13: misc2 +// WFIFOW(fd,j+72) = p->clothes_color; memcpy(WFIFOP(fd,j+74), p->name, 24); @@ -1353,11 +1369,6 @@ int char_divorce(struct mmo_charstatus *cs) { if (char_dat[i].char_id == cs->partner_id && char_dat[i].partner_id == cs->char_id) { cs->partner_id = 0; char_dat[i].partner_id = 0; - for(j = 0; j < MAX_INVENTORY; j++) - if (char_dat[i].inventory[j].nameid == WEDDING_RING_M || char_dat[i].inventory[j].nameid == WEDDING_RING_F) - memset(&char_dat[i].inventory[j], 0, sizeof(char_dat[i].inventory[0])); - if (cs->inventory[j].nameid == WEDDING_RING_M || cs->inventory[j].nameid == WEDDING_RING_F) - memset(&cs->inventory[j], 0, sizeof(cs->inventory[0])); return 0; } } diff --git a/src/common/timer.h b/src/common/timer.h index a96f011..f6fc5c8 100644 --- a/src/common/timer.h +++ b/src/common/timer.h @@ -28,8 +28,8 @@ struct TimerData { unsigned int gettick_nocache(void); unsigned int gettick(void); -int add_timer(unsigned int delay,int (*)(int index /* for deletion */,unsigned int orig_delay,int id, int data),int id, int data); -int add_timer_interval(unsigned int,int (*)(int,unsigned int,int,int),int,int,int interval); +int add_timer(unsigned int,int (*)(int,unsigned int,int,int),int,int); +int add_timer_interval(unsigned int,int (*)(int,unsigned int,int,int),int,int,int); int delete_timer(int,int (*)(int,unsigned int,int,int)); int addtick_timer(int tid,unsigned int tick); diff --git a/src/map/chrif.c b/src/map/chrif.c index dc401b6..ceeac26 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -689,13 +689,7 @@ int chrif_divorce(int char_id, int partner_id) nullpo_retr(0, sd = map_nick2sd(map_charid2nick(partner_id))); if (sd->status.partner_id == char_id) { int i; - //離婚(相方は既にキャラが消えている筈なので) sd->status.partner_id = 0; - - //相方の結婚指輪を剥奪 - for(i = 0; i < MAX_INVENTORY; i++) - if (sd->status.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F) - pc_delitem(sd, i, 1, 0); } return 0; @@ -717,7 +711,7 @@ int chrif_accountdeletion(int fd) if (acc > 0) { if (sd != NULL) { sd->login_id1++; // change identify, because if player come back in char within the 5 seconds, he can change its characters - clif_displaymessage(sd->fd, "Your account has been deleted (disconnexion)..."); + clif_displaymessage(sd->fd, "Your account has been deleted (disconnection)..."); clif_setwaitclose(sd->fd); // forced to disconnect for the change } } else { diff --git a/src/map/clif.c b/src/map/clif.c index ad750d4..4feaa15 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -1209,6 +1209,23 @@ static int clif_set0192(int fd, int m, int x, int y, int type) { return 0; } +/* These indices are derived from equip_pos in pc.c and some guesswork */ +static int equip_points[LOOK_LAST + 1] = { + -1, /* 0: base */ + -1, /* 1: hair */ + 9, /* 2: weapon */ + 4, /* 3: head botom -- leg armour */ + 6, /* 4: head top -- hat */ + 5, /* 5: head mid -- torso armour */ + -1, /* 6: hair colour */ + -1, /* 6: clothes colour */ + 8, /* 6: shield */ + 2, /* 9: shoes */ + 3, /* gloves */ + 1, /* cape */ + 7, /* misc1 */ + 0, /* misc2 */}; + /*========================================== * *------------------------------------------ @@ -1286,6 +1303,8 @@ int clif_spawnpc(struct map_session_data *sd) { if (map[sd->bl.m].flag.rain) clif_specialeffect(&sd->bl, 161, 1); + clif_changelook_accessories(&sd->bl, NULL); + return 0; } @@ -1316,6 +1335,7 @@ int clif_spawnnpc(struct npc_data *nd) len = clif_npc0078(nd,buf); clif_send(buf,len,&nd->bl,AREA); + return 0; } @@ -2563,8 +2583,13 @@ int clif_changestatus(struct block_list *bl,int type,int val) */ int clif_changelook(struct block_list *bl,int type,int val) { + clif_changelook_towards(bl, type, val, NULL); +} - unsigned char buf[32]; +int clif_changelook_towards(struct block_list *bl,int type,int val, struct map_session_data *dstsd) +{ + unsigned char rbuf[32]; + unsigned char *buf = dstsd ? WFIFOP(dstsd->fd, 0) : rbuf; // pick target buffer or general-purpose one struct map_session_data *sd = NULL; nullpo_retr(0, bl); @@ -2582,18 +2607,24 @@ int clif_changelook(struct block_list *bl,int type,int val) WBUFL(buf,2)=bl->id; WBUFB(buf,6)=type; WBUFB(buf,7)=val; - clif_send(buf,packet_len_table[0xc3],bl,AREA); + + if (dstsd) + WFIFOSET(dstsd->fd, packet_len_table[0xc3]); + else + clif_send(buf,packet_len_table[0xc3],bl,AREA); #else - if(sd && (type == LOOK_WEAPON || type == LOOK_SHIELD || type == LOOK_SHOES)) { + if(sd && (type == LOOK_WEAPON || type == LOOK_SHIELD || type >= LOOK_SHOES)) { WBUFW(buf,0)=0x1d7; WBUFL(buf,2)=bl->id; - if(type == LOOK_SHOES) { - WBUFB(buf,6)=9; - if(sd->equip_index[2] >= 0 && sd->inventory_data[sd->equip_index[2]]) { - if(sd->inventory_data[sd->equip_index[2]]->view_id > 0) - WBUFW(buf,7)=sd->inventory_data[sd->equip_index[2]]->view_id; + if(type >= LOOK_SHOES) { + int equip_point = equip_points[type]; + + WBUFB(buf,6) = type; + if(sd->equip_index[equip_point] >= 0 && sd->inventory_data[sd->equip_index[2]]) { + if(sd->inventory_data[sd->equip_index[equip_point]]->view_id > 0) + WBUFW(buf,7)=sd->inventory_data[sd->equip_index[equip_point]]->view_id; else - WBUFW(buf,7)=sd->status.inventory[sd->equip_index[2]].nameid; + WBUFW(buf,7)=sd->status.inventory[sd->equip_index[equip_point]].nameid; } else WBUFW(buf,7)=0; WBUFW(buf,9)=0; @@ -2620,22 +2651,21 @@ int clif_changelook(struct block_list *bl,int type,int val) } else WBUFW(buf,9)=0; } - clif_send(buf,packet_len_table[0x1d7],bl,AREA); + if (dstsd) + WFIFOSET(dstsd->fd, packet_len_table[0x1d7]); + else + clif_send(buf, packet_len_table[0x1d7], bl, AREA); } - else if(sd && (type == LOOK_BASE) && (val > 255)) - { + else { WBUFW(buf,0)=0x1d7; WBUFL(buf,2)=bl->id; WBUFB(buf,6)=type; WBUFW(buf,7)=val; WBUFW(buf,9)=0; - clif_send(buf,packet_len_table[0x1d7],bl,AREA); - } else { - WBUFW(buf,0)=0xc3; - WBUFL(buf,2)=bl->id; - WBUFB(buf,6)=type; - WBUFB(buf,7)=val; - clif_send(buf,packet_len_table[0xc3],bl,AREA); + if (dstsd) + WFIFOSET(dstsd->fd, packet_len_table[0x1d7]); + else + clif_send(buf, packet_len_table[0x1d7], bl, AREA); } #endif return 0; @@ -3514,6 +3544,17 @@ int clif_storageclose(struct map_session_data *sd) return 0; } +void +clif_changelook_accessories(struct block_list *bl, struct map_session_data *dest) +{ + int i; + + for (i = LOOK_SHOES; i <= LOOK_LAST; i++) + clif_changelook_towards(bl, i, 0, dest); +} + + + // // callback系 ? // @@ -3555,6 +3596,8 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds if(sd->status.manner < 0) clif_changestatus(&sd->bl,SP_MANNER,sd->status.manner); + clif_changelook_accessories(sd, dstsd); + clif_changelook_accessories(dstsd, sd); } /*========================================== @@ -3640,6 +3683,7 @@ int clif_fixpcpos(struct map_session_data *sd) len = clif_set0078(sd,buf); clif_send(buf,len,&sd->bl,AREA); } + clif_changelook_accessories(sd, NULL); return 0; } @@ -7221,6 +7265,8 @@ void clif_parse_LoadEndAck(int fd,struct map_session_data *sd) skill_status_change_start(&sd->bl,SC_BROKNARMOR,0,0,0,0,0,0); } + clif_changelook_accessories(sd, NULL); + 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,0,sd); } diff --git a/src/map/clif.h b/src/map/clif.h index d04d821..a6f8a3c 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -65,6 +65,8 @@ int clif_changestatus(struct block_list*,int,int); //area int clif_damage(struct block_list *,struct block_list *,unsigned int,int,int,int,int,int,int); // area #define clif_takeitem(src,dst) clif_damage(src,dst,0,0,0,0,0,1,0) int clif_changelook(struct block_list *,int,int); // area +int clif_changelook_towards(struct block_list *,int,int, struct map_session_data *dst); // area or target +void clif_changelook_accessories(struct block_list *bl, struct map_session_data *dst); // area or target; list gloves, boots etc. int clif_arrowequip(struct map_session_data *sd,int val); //self int clif_arrow_fail(struct map_session_data *sd,int type); //self int clif_arrow_create_list(struct map_session_data *sd); //self diff --git a/src/map/map.h b/src/map/map.h index 28d6758..ea240f2 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -610,9 +610,24 @@ enum { }; enum { - LOOK_BASE,LOOK_HAIR,LOOK_WEAPON,LOOK_HEAD_BOTTOM,LOOK_HEAD_TOP,LOOK_HEAD_MID,LOOK_HAIR_COLOR,LOOK_CLOTHES_COLOR,LOOK_SHIELD,LOOK_SHOES + LOOK_BASE, + LOOK_HAIR, + LOOK_WEAPON, + LOOK_HEAD_BOTTOM, + LOOK_HEAD_TOP, + LOOK_HEAD_MID, + LOOK_HAIR_COLOR, + LOOK_CLOTHES_COLOR, + LOOK_SHIELD, + LOOK_SHOES, /* 9 */ + LOOK_GLOVES, + LOOK_CAPE, + LOOK_MISC1, + LOOK_MISC2 }; +#define LOOK_LAST LOOK_MISC2 + struct chat_data { struct block_list bl; diff --git a/src/map/pc.c b/src/map/pc.c index fe8dab4..8bb2ee8 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -5759,12 +5759,14 @@ int pc_equiplookall(struct map_session_data *sd) clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); #else clif_changelook(&sd->bl,LOOK_WEAPON,0); - clif_changelook(&sd->bl,LOOK_SHOES,0); +// clif_changelook(&sd->bl,LOOK_SHOES,0); #endif clif_changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); clif_changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); clif_changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); + clif_changelook_accessories(&sd->bl, NULL); + return 0; } @@ -6307,9 +6309,25 @@ int pc_cleareventtimer(struct map_session_data *sd) * アイテムを装備する *------------------------------------------ */ +static int +pc_signal_advanced_equipment_change(struct map_session_data *sd,int n) +{ + if(sd->status.inventory[n].equip & 0x0040) + clif_changelook(&sd->bl,LOOK_SHOES,0); + if(sd->status.inventory[n].equip & 0x0004) + clif_changelook(&sd->bl, LOOK_GLOVES, 0); + if(sd->status.inventory[n].equip & 0x0008) + clif_changelook(&sd->bl, LOOK_CAPE, 0); + if(sd->status.inventory[n].equip & 0x0010) + clif_changelook(&sd->bl, LOOK_MISC1, 0); + if(sd->status.inventory[n].equip & 0x0080) + clif_changelook(&sd->bl, LOOK_MISC2, 0); +} + + int pc_equipitem(struct map_session_data *sd,int n,int pos) { - int i,nameid, arrow; + int i,nameid, arrow, view; struct item_data *id; //転生や養子の場合の元の職業を算出する @@ -6380,11 +6398,15 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos) } sd->status.inventory[n].equip=pos; + if(sd->inventory_data[n]) { + view = sd->inventory_data[n]->look; + if (view == 0) view = sd->inventory_data[n]->nameid; + } else { + view = 0; + } + if(sd->status.inventory[n].equip & 0x0002) { - if(sd->inventory_data[n]) - sd->weapontype1 = sd->inventory_data[n]->look; - else - sd->weapontype1 = 0; + sd->weapontype1 = view; pc_calcweapontype(sd); pc_set_weapon_look(sd); } @@ -6393,12 +6415,10 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos) if(sd->inventory_data[n]->type == 4) { sd->status.shield = 0; if(sd->status.inventory[n].equip == 0x0020) - sd->weapontype2 = sd->inventory_data[n]->look; - else - sd->weapontype2 = 0; + sd->weapontype2 = view; } else if(sd->inventory_data[n]->type == 5) { - sd->status.shield = sd->inventory_data[n]->look; + sd->status.shield = view; sd->weapontype2 = 0; } } @@ -6408,28 +6428,18 @@ int pc_equipitem(struct map_session_data *sd,int n,int pos) clif_changelook(&sd->bl,LOOK_SHIELD,sd->status.shield); } if(sd->status.inventory[n].equip & 0x0001) { - if(sd->inventory_data[n]) - sd->status.head_bottom = sd->inventory_data[n]->look; - else - sd->status.head_bottom = 0; + sd->status.head_bottom = view; clif_changelook(&sd->bl,LOOK_HEAD_BOTTOM,sd->status.head_bottom); } if(sd->status.inventory[n].equip & 0x0100) { - if(sd->inventory_data[n]) - sd->status.head_top = sd->inventory_data[n]->look; - else - sd->status.head_top = 0; + sd->status.head_top = view; clif_changelook(&sd->bl,LOOK_HEAD_TOP,sd->status.head_top); } if(sd->status.inventory[n].equip & 0x0200) { - if(sd->inventory_data[n]) - sd->status.head_mid = sd->inventory_data[n]->look; - else - sd->status.head_mid = 0; + sd->status.head_mid = view; clif_changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); } - if(sd->status.inventory[n].equip & 0x0040) - clif_changelook(&sd->bl,LOOK_SHOES,0); + pc_signal_advanced_equipment_change(sd, n); pc_checkallowskill(sd); // 装備品でスキルか解除されるかチェック if (itemdb_look(sd->status.inventory[n].nameid) == 11 && arrow){ // Added by RoVeRT @@ -6501,8 +6511,7 @@ int pc_unequipitem(struct map_session_data *sd,int n,int type) sd->status.head_mid = 0; clif_changelook(&sd->bl,LOOK_HEAD_MID,sd->status.head_mid); } - if(sd->status.inventory[n].equip & 0x0040) - clif_changelook(&sd->bl,LOOK_SHOES,0); + pc_signal_advanced_equipment_change(sd, n); if(sd->sc_data[SC_BROKNWEAPON].timer != -1 && sd->status.inventory[n].equip & 0x0002 && sd->status.inventory[i].broken==1) @@ -6733,19 +6742,12 @@ int pc_divorce(struct map_session_data *sd) return -1; if( (p_sd=map_nick2sd(map_charid2nick(sd->status.partner_id))) !=NULL){ - int i; if(p_sd->status.partner_id != sd->status.char_id || sd->status.partner_id != p_sd->status.char_id){ printf("pc_divorce: Illegal partner_id sd=%d p_sd=%d\n",sd->status.partner_id,p_sd->status.partner_id); return -1; } sd->status.partner_id=0; p_sd->status.partner_id=0; - for(i=0;istatus.inventory[i].nameid == WEDDING_RING_M || sd->status.inventory[i].nameid == WEDDING_RING_F) - pc_delitem(sd,i,1,0); - for(i=0;istatus.inventory[i].nameid == WEDDING_RING_M || p_sd->status.inventory[i].nameid == WEDDING_RING_F) - pc_delitem(p_sd,i,1,0); }else{ printf("pc_divorce: p_sd nullpo\n"); -- cgit v1.2.3-60-g2f50