summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-06-11 22:14:50 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-06-11 22:14:50 +0000
commitf24a3d43c43fc28c292cd7af10defae894aedc6d (patch)
tree3bdc85ce1e475a38440d155567587ee2ba59cfc0 /src/map/clif.c
parent15d0d129834b212fa00285afa412cbb38f97ca6b (diff)
downloadhercules-f24a3d43c43fc28c292cd7af10defae894aedc6d.tar.gz
hercules-f24a3d43c43fc28c292cd7af10defae894aedc6d.tar.bz2
hercules-f24a3d43c43fc28c292cd7af10defae894aedc6d.tar.xz
hercules-f24a3d43c43fc28c292cd7af10defae894aedc6d.zip
- Fixed pet equip not displaying correctly at all (closes topic:153753)
- Removed old fixpos packet (the 'new' one is way smaller) - Fixed some major logical typos in the code, cleaned up many places git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@10746 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c289
1 files changed, 113 insertions, 176 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index d28f9fdf3..7cb9fc096 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -600,21 +600,22 @@ int clif_charselectok(int id)
}
/*==========================================
- *
+ * Makes an item appear on the ground
+ * 009e <ID>.l <name ID>.w <identify flag>.B <X>.w <Y>.w <subX>.B <subY>.B <amount>.w
*------------------------------------------*/
-static int clif_set009e(struct flooritem_data *fitem,unsigned char *buf)
+int clif_dropflooritem(struct flooritem_data* fitem)
{
+ uint8 buf[17];
int view;
nullpo_retr(0, fitem);
- //009e <ID>.l <name ID>.w <identify flag>.B <X>.w <Y>.w <subX>.B <subY>.B <amount>.w
+ if (fitem->item_data.nameid <= 0)
+ return 0;
+
WBUFW(buf, 0) = 0x9e;
WBUFL(buf, 2) = fitem->bl.id;
- if ((view = itemdb_viewid(fitem->item_data.nameid)) > 0)
- WBUFW(buf, 6) = view;
- else
- WBUFW(buf, 6) = fitem->item_data.nameid;
+ WBUFW(buf, 6) = ((view = itemdb_viewid(fitem->item_data.nameid)) > 0) ? view : fitem->item_data.nameid;
WBUFB(buf, 8) = fitem->item_data.identify;
WBUFW(buf, 9) = fitem->bl.x;
WBUFW(buf,11) = fitem->bl.y;
@@ -622,21 +623,6 @@ static int clif_set009e(struct flooritem_data *fitem,unsigned char *buf)
WBUFB(buf,14) = fitem->suby;
WBUFW(buf,15) = fitem->item_data.amount;
- return packet_len(0x9e);
-}
-
-/*==========================================
- *
- *------------------------------------------*/
-int clif_dropflooritem(struct flooritem_data *fitem)
-{
- unsigned char buf[64];
-
- nullpo_retr(0, fitem);
-
- if (fitem->item_data.nameid <= 0)
- return 0;
- clif_set009e(fitem, buf);
clif_send(buf, packet_len(0x9e), &fitem->bl, AREA);
return 0;
@@ -770,53 +756,29 @@ void clif_get_weapon_view(TBL_PC* sd, unsigned short *rhand, unsigned short *lha
#endif
}
-static void clif_get_guild_data(struct block_list *bl, long *guild_id, short *emblem_id)
-{
- //TODO: There has to be a way to clean this up.
- switch (bl->type) {
- case BL_PC:
- *guild_id = ((TBL_PC*)bl)->status.guild_id;
- *emblem_id = ((TBL_PC*)bl)->guild_emblem_id;
- break;
- case BL_MOB:
- if (((TBL_MOB*)bl)->guardian_data) {
- *guild_id =((TBL_MOB*)bl)->guardian_data->guild_id;
- *emblem_id =((TBL_MOB*)bl)->guardian_data->emblem_id;
- }
- break;
- case BL_NPC:
- if (bl->subtype == SCRIPT && ((TBL_NPC*)bl)->u.scr.guild_id > 0) {
- struct guild *g = guild_search(((TBL_NPC*)bl)->u.scr.guild_id);
- if (g) {
- *guild_id =g->guild_id;
- *emblem_id =g->emblem_id;
- }
- }
- break;
- default:
- *guild_id = status_get_guild_id(bl);
- }
- return;
-}
/*==========================================
*
*------------------------------------------*/
-static int clif_set0078(struct block_list *bl, struct view_data *vd, unsigned char *buf)
+static int clif_set0078(struct block_list* bl, unsigned char* buf)
{
- struct status_change *sc;
- struct map_session_data *sd;
- long guild_id=0;
- unsigned short emblem_id=0, lv;
- unsigned short dir;
+ struct status_change* sc;
+ struct view_data* vd;
+ int guild_id, emblem_id, dir, lv;
nullpo_retr(0, bl);
- BL_CAST(BL_PC, bl, sd);
sc = status_get_sc(bl);
+ vd = status_get_viewdata(bl);
- clif_get_guild_data(bl, &guild_id, &emblem_id);
+ guild_id = status_get_guild_id(bl);
+ emblem_id = status_get_emblem_id(bl);
dir = unit_getdir(bl);
lv = status_get_lv(bl);
- if(pcdb_checkid(vd->class_)) {
+
+ if(pcdb_checkid(vd->class_))
+ {
+ struct map_session_data* sd;
+ BL_CAST(BL_PC, bl, sd);
+
#if PACKETVER > 6
memset(buf,0,packet_len(0x22a));
@@ -955,9 +917,9 @@ static int clif_set0078(struct block_list *bl, struct view_data *vd, unsigned ch
//44B: Karma
//45B: Sex
WBUFPOS(buf,46,bl->x,bl->y,dir);
- WBUFB(buf,49)=5;
- WBUFB(buf,50)=5;
- //51BL Sit/Stand
+ //WBUFB(buf,49)=5;
+ //WBUFB(buf,50)=5;
+ //51B: Sit/Stand
WBUFW(buf,52)=clif_setlevel(lv);
return packet_len(0x78);
}
@@ -968,18 +930,20 @@ static int clif_set0078(struct block_list *bl, struct view_data *vd, unsigned ch
static int clif_set007b(struct block_list *bl, struct view_data *vd, struct unit_data *ud, unsigned char *buf)
{
struct status_change *sc;
- struct map_session_data *sd;
- long guild_id=0;
- unsigned short emblem_id=0, lv;
+ int guild_id, emblem_id, lv;
nullpo_retr(0, bl);
- BL_CAST(BL_PC, bl, sd);
sc = status_get_sc(bl);
- clif_get_guild_data(bl, &guild_id, &emblem_id);
+ guild_id = status_get_guild_id(bl);
+ emblem_id = status_get_emblem_id(bl);
lv = status_get_lv(bl);
- if(pcdb_checkid(vd->class_)) {
+ if(pcdb_checkid(vd->class_))
+ {
+ struct map_session_data* sd;
+ BL_CAST(BL_PC, bl, sd);
+
#if PACKETVER > 6
memset(buf,0,packet_len(0x22c));
@@ -1291,6 +1255,7 @@ int clif_spawn(struct block_list *bl)
{
unsigned char buf[128];
struct view_data *vd;
+
nullpo_retr(0, bl);
vd = status_get_viewdata(bl);
if (!vd || vd->class_ == INVISIBLE_CLASS)
@@ -1298,8 +1263,9 @@ int clif_spawn(struct block_list *bl)
if (pcdb_checkid(vd->class_))
{ //Player spawn packet.
- clif_set0078(bl, vd, buf);
- switch(WBUFW(buf,0)) {
+ clif_set0078(bl, buf);
+ switch(WBUFW(buf,0))
+ {
case 0x78: //Convert to 0x79
WBUFW(buf, 0) = 0x79;
WBUFW(buf,51) = WBUFW(buf,52); //Lv is placed on offset 52
@@ -1337,9 +1303,7 @@ int clif_spawn(struct block_list *bl)
WBUFW(buf,10)=sc->opt2;
WBUFW(buf,12)=sc->option;
}
- WBUFW(buf,14)=vd->hair_style; //Required for pets.
WBUFW(buf,20)=vd->class_;
- WBUFW(buf,24)=vd->head_bottom; //Pet armor
WBUFPOS(buf,36,bl->x,bl->y,unit_getdir(bl));
clif_send(buf,packet_len(0x7c),bl,AREA_WOS);
@@ -1374,6 +1338,13 @@ int clif_spawn(struct block_list *bl)
clif_specialeffect(&md->bl,421,AREA);
}
break;
+ case BL_PET:
+ {
+ unsigned char buf[64];
+ int len = clif_set0078(bl, buf);
+ clif_send(buf, len, bl, AREA_WOS);
+ }
+ break;
}
return 0;
}
@@ -2644,6 +2615,7 @@ int clif_updatestatus(struct map_session_data *sd,int type)
return 0;
}
+
int clif_changestatus(struct block_list *bl,int type,int val)
{
unsigned char buf[12];
@@ -2654,7 +2626,6 @@ int clif_changestatus(struct block_list *bl,int type,int val)
if(bl->type == BL_PC)
sd = (struct map_session_data *)bl;
-//printf("clif_changestatus id:%d type:%d val:%d\n",bl->id,type,val);
if(sd){
WBUFW(buf,0)=0x1ab;
WBUFL(buf,2)=bl->id;
@@ -3693,7 +3664,7 @@ void clif_getareachar_pc(struct map_session_data* sd,struct map_session_data* ds
*/
}
-void clif_getareachar_char(struct map_session_data* sd,struct block_list *bl)
+void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl)
{
struct unit_data *ud;
struct view_data *vd;
@@ -3724,7 +3695,7 @@ void clif_getareachar_char(struct map_session_data* sd,struct block_list *bl)
#else
WFIFOHEAD(fd,packet_len(0x78));
#endif
- len = clif_set0078(bl,vd,WFIFOP(fd,0));
+ len = clif_set0078(bl,WFIFOP(fd,0));
WFIFOSET(fd,len);
}
@@ -3732,7 +3703,7 @@ void clif_getareachar_char(struct map_session_data* sd,struct block_list *bl)
clif_refreshlook(&sd->bl,bl->id,LOOK_CLOTHES_COLOR,vd->cloth_color,SELF);
switch (bl->type)
- {
+ { // FIXME: 'AREA' causes unneccessary spam since this should be 1:1 communication
case BL_PC:
{
TBL_PC* tsd = (TBL_PC*)bl;
@@ -3758,39 +3729,16 @@ void clif_getareachar_char(struct map_session_data* sd,struct block_list *bl)
clif_specialeffect(bl,421,AREA);
}
break;
+ case BL_PET:
+ {
+ unsigned char buf[64];
+ int len = clif_set0078(bl, buf);
+ clif_send(buf, len, &sd->bl, SELF);
+ }
+ break;
}
}
-/*==========================================
- * Older fix pos packet.
- *------------------------------------------*/
-int clif_fixpos2(struct block_list* bl)
-{
- struct unit_data *ud;
- struct view_data *vd;
- unsigned char buf[256];
- int len;
-
- nullpo_retr(0, bl);
- ud = unit_bl2ud(bl);
- vd = status_get_viewdata(bl);
- if (!vd || vd->class_ == INVISIBLE_CLASS)
- return 0;
-
- if(ud && ud->walktimer != -1)
- len = clif_set007b(bl,vd,ud,buf);
- else
- len = clif_set0078(bl,vd,buf);
-
- if (disguised(bl)) {
- clif_send(buf,len,bl,AREA_WOS);
- clif_setdisguise((TBL_PC*)bl, buf, len, 0);
- clif_setdisguise((TBL_PC*)bl, buf, len, 1);
- } else
- clif_send(buf,len,bl,AREA);
- return 0;
-}
-
//Modifies the type of damage according to status changes [Skotlex]
#define clif_calc_delay(type,delay) (type==1||type==4||type==0x0a)?type:(delay==0?9:type)
@@ -4056,7 +4004,7 @@ int clif_01ac(struct block_list *bl)
default:
if(&sd->bl == bl)
break;
- clif_getareachar_char(sd,bl);
+ clif_getareachar_unit(sd,bl);
break;
}
return 0;
@@ -4134,13 +4082,13 @@ int clif_insight(struct block_list *bl,va_list ap)
clif_getareachar_skillunit(tsd,(TBL_SKILL*)bl);
break;
default:
- clif_getareachar_char(tsd,bl);
+ clif_getareachar_unit(tsd,bl);
break;
}
}
if (sd && sd->fd)
{ //Tell sd that tbl walked into his view
- clif_getareachar_char(sd,tbl);
+ clif_getareachar_unit(sd,tbl);
}
return 0;
}
@@ -4187,7 +4135,7 @@ int clif_skillinfo(struct map_session_data *sd,int skillid,int type,int range)
int clif_skillinfoblock(struct map_session_data *sd)
{
int fd;
- int i,c,len=4,id;
+ int i,c,len,id;
nullpo_retr(0, sd);
@@ -4195,21 +4143,23 @@ int clif_skillinfoblock(struct map_session_data *sd)
if (!fd) return 0;
WFIFOHEAD(fd, MAX_SKILL * 37 + 4);
- WFIFOW(fd,0)=0x10f;
- for ( i = c = 0; i < MAX_SKILL; i++){
- if( (id=sd->status.skill[i].id)!=0 ){
- WFIFOW(fd,len ) = id;
+ WFIFOW(fd,0) = 0x10f;
+ for ( i = 0, c = 0, len = 4; i < MAX_SKILL; i++)
+ {
+ if( (id = sd->status.skill[i].id) != 0 )
+ {
+ WFIFOW(fd,len) = id;
WFIFOW(fd,len+2) = skill_get_inf(id);
WFIFOW(fd,len+4) = 0;
WFIFOW(fd,len+6) = sd->status.skill[i].lv;
WFIFOW(fd,len+8) = skill_get_sp(id,sd->status.skill[i].lv);
WFIFOW(fd,len+10)= skill_get_range2(&sd->bl, id,sd->status.skill[i].lv);
strncpy((char*)WFIFOP(fd,len+12), skill_get_name(id), NAME_LENGTH);
- if(sd->status.skill[i].flag ==0)
- WFIFOB(fd,len+36)= (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class_))? 1:0;
+ if(sd->status.skill[i].flag == 0)
+ WFIFOB(fd,len+36) = (sd->status.skill[i].lv < skill_tree_get_max(id, sd->status.class_))? 1:0;
else
WFIFOB(fd,len+36) = 0;
- len+=37;
+ len += 37;
c++;
}
}
@@ -6051,7 +6001,7 @@ int clif_catch_process(struct map_session_data *sd)
return 0;
}
-int clif_pet_rulet(struct map_session_data *sd,int data)
+int clif_pet_roulette(struct map_session_data *sd,int data)
{
int fd;
@@ -6102,24 +6052,48 @@ int clif_sendegg(struct map_session_data *sd)
return 0;
}
-int clif_send_petdata(struct map_session_data *sd,int type,int param)
+/*==========================================
+ * Sends a specific pet data update.
+ * type = 0 -> param = 0 (initial data)
+ * type = 1 -> param = intimacy value
+ * type = 2 -> param = hungry value
+ * type = 3 -> param = accessory id
+ * type = 4 -> param = performance number (1-3:normal, 4:special)
+ * type = 5 -> param = hairstyle number
+ *------------------------------------------*/
+int clif_send_petdata(struct map_session_data* sd, int type, int param)
{
int fd;
nullpo_retr(0, sd);
nullpo_retr(0, sd->pd);
- fd=sd->fd;
+ fd = sd->fd;
WFIFOHEAD(fd,packet_len(0x1a4));
- WFIFOW(fd,0)=0x1a4;
- WFIFOB(fd,2)=type;
- WFIFOL(fd,3)=sd->pd->bl.id;
- WFIFOL(fd,7)=param;
+ WFIFOW(fd,0) = 0x1a4;
+ WFIFOB(fd,2) = type;
+ WFIFOL(fd,3) = sd->pd->bl.id;
+ WFIFOL(fd,7) = param;
WFIFOSET(fd,packet_len(0x1a4));
return 0;
}
+int clif_send_petdata_area(struct pet_data* pd, int type, int param)
+{
+ uint8 buf[16];
+
+ nullpo_retr(0, pd);
+
+ WBUFW(buf,0) = 0x1a4;
+ WBUFB(buf,2) = type;
+ WBUFL(buf,3) = pd->bl.id;
+ WBUFL(buf,7) = param;
+ clif_send(buf, packet_len(0x1a4), &pd->bl, AREA);
+
+ return 0;
+}
+
int clif_send_petstatus(struct map_session_data *sd)
{
int fd;
@@ -6171,41 +6145,6 @@ int clif_pet_emotion(struct pet_data *pd,int param)
return 0;
}
-int clif_pet_performance(struct block_list *bl,int param)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, bl);
-
- memset(buf,0,packet_len(0x1a4));
-
- WBUFW(buf,0)=0x1a4;
- WBUFB(buf,2)=4;
- WBUFL(buf,3)=bl->id;
- WBUFL(buf,7)=param;
-
- clif_send(buf,packet_len(0x1a4),bl,AREA);
-
- return 0;
-}
-
-int clif_pet_equip(struct pet_data *pd)
-{
- unsigned char buf[16];
-
- nullpo_retr(0, pd);
-
- memset(buf,0,packet_len(0x1a4));
-
- WBUFW(buf,0)=0x1a4;
- WBUFB(buf,2)=3;
- WBUFL(buf,3)=pd->bl.id;
- WBUFL(buf,7)=pd->vd.shield;
- clif_send(buf,packet_len(0x1a4),&pd->bl,AREA);
-
- return 0;
-}
-
int clif_pet_food(struct map_session_data *sd,int foodid,int fail)
{
int fd;
@@ -6554,16 +6493,14 @@ int clif_guild_send_onlineinfo(struct map_session_data *sd)
*------------------------------------------*/
int clif_guild_masterormember(struct map_session_data *sd)
{
- int type=0x57,fd;
+ int fd;
nullpo_retr(0, sd);
fd=sd->fd;
- if(sd->state.gmaster_flag)
- type=0xd7;
WFIFOHEAD(fd,packet_len(0x14e));
- WFIFOW(fd,0)=0x14e;
- WFIFOL(fd,2)=type;
+ WFIFOW(fd,0) = 0x14e;
+ WFIFOL(fd,2) = (sd->state.gmaster_flag) ? 0xd7 : 0x57;
WFIFOSET(fd,packet_len(0x14e));
return 0;
}
@@ -6572,7 +6509,7 @@ int clif_guild_masterormember(struct map_session_data *sd)
*------------------------------------------*/
int clif_guild_basicinfo(struct map_session_data *sd)
{
- int fd,i,t=0;
+ int fd,i,t;
struct guild *g;
struct guild_castle *gc=NULL;
@@ -6599,15 +6536,13 @@ int clif_guild_basicinfo(struct map_session_data *sd)
memcpy(WFIFOP(fd,46),g->name, NAME_LENGTH);
memcpy(WFIFOP(fd,70),g->master, NAME_LENGTH);
- for(i=0;i<MAX_GUILDCASTLE;i++){
- gc=guild_castle_search(i);
- if(!gc) continue;
- if(g->guild_id == gc->guild_id) t++;
+ for(i = 0, t = 0; i < MAX_GUILDCASTLE; i++)
+ {
+ gc = guild_castle_search(i);
+ if(gc && g->guild_id == gc->guild_id)
+ t++;
}
- if (t>=0 && t<=MAX_GUILDCASTLE) //(0=None, 1..24 = N of Casles) [Lupus]
- strncpy((char*)WFIFOP(fd,94),msg_txt(300+t),20);
- else
- strncpy((char*)WFIFOP(fd,94),msg_txt(299),20);
+ strncpy((char*)WFIFOP(fd,94),msg_txt(300+t),20); // "'N' castles"
WFIFOSET(fd,packet_len(WFIFOW(fd,0)));
return 0;
@@ -6838,8 +6773,10 @@ int clif_guild_skillinfo(struct map_session_data *sd)
WFIFOSET(fd,WFIFOW(fd,2));
return 0;
}
+
/*==========================================
- * ギルド告知送信
+ * Sends guild notice to client
+ * R 016f <str1z>.60B <str2z>.120B
*------------------------------------------*/
int clif_guild_notice(struct map_session_data *sd,struct guild *g)
{
@@ -7455,7 +7392,7 @@ int clif_soundeffectall(struct block_list *bl, const char *name, int type, int c
}
// displaying special effects (npcs, weather, etc) [Valaris]
-int clif_specialeffect(struct block_list *bl, int type, int flag)
+int clif_specialeffect(struct block_list* bl, int type, enum send_target target)
{
unsigned char buf[24];
@@ -7467,7 +7404,7 @@ int clif_specialeffect(struct block_list *bl, int type, int flag)
WBUFL(buf,2) = bl->id;
WBUFL(buf,6) = type;
- clif_send(buf, packet_len(0x1f3), bl, flag);
+ clif_send(buf, packet_len(0x1f3), bl, target);
if (disguised(bl)) {
WBUFL(buf,2) = -bl->id;