summaryrefslogtreecommitdiff
path: root/src/map/clif.c
diff options
context:
space:
mode:
authorlordttseven <lordttseven@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-03-15 10:30:42 +0000
committerlordttseven <lordttseven@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-03-15 10:30:42 +0000
commitdaeecf3bd0bdb54f43f8aedee98a7c8c68a56992 (patch)
tree4d57bf55bb3f936bf97ac92402627e90ed1bdd40 /src/map/clif.c
parent55984b91c03d25e7a6cae535043cd49815cf9e24 (diff)
downloadhercules-daeecf3bd0bdb54f43f8aedee98a7c8c68a56992.tar.gz
hercules-daeecf3bd0bdb54f43f8aedee98a7c8c68a56992.tar.bz2
hercules-daeecf3bd0bdb54f43f8aedee98a7c8c68a56992.tar.xz
hercules-daeecf3bd0bdb54f43f8aedee98a7c8c68a56992.zip
Status change packet cleanup
* fixed a couple typos * replaced duplicate function clif_status_load with a macro * normalized and documented status change table related getter abstraction * put some checks that were previously in multiple places into clif_status_change * packets are now used as they are on official servers: - ZC_MSG_STATE_CHANGE for ending statuses and starting them on non-pcs - ZC_MSG_STATE_CHANGE2 for starting *all* statuses on players - tick = 9999 for statuses of indeterminate duration - for non-pc units, a packet is only sent if it has a visual impact on the client; if you notice any missing visual effects, please report them! * fixed hidden GM characters leaking certain status packets * fixed hidden GM characters not displaying timers for newly gained statuses * fixed status end packet never being sent for non-pc, non-mercenary units * fixed SC_CLOAKING displaying a time bar on the client * fixed tick being an unsigned int, yet used as a signed int * removed hard-coded status length exceptions in clif_status_change git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15688 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/clif.c')
-rw-r--r--src/map/clif.c63
1 files changed, 18 insertions, 45 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 4b5cae43a..d3ac3b8a1 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1592,7 +1592,7 @@ void clif_move(struct unit_data *ud)
return; //This performance check is needed to keep GM-hidden objects from being notified to bots.
/**
- * Hide NPC from maya puprle card.
+ * Hide NPC from maya purple card.
**/
if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
return;
@@ -4019,7 +4019,7 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl)
return;
/**
- * Hide NPC from maya puprle card.
+ * Hide NPC from maya purple card.
**/
if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
return;
@@ -5230,69 +5230,42 @@ void clif_cooking_list(struct map_session_data *sd, int trigger)
}
}
-
-/*==========================================
- * Sends a status change packet to the object only, used for loading status changes. [Skotlex]
- *------------------------------------------*/
-int clif_status_load(struct block_list *bl,int type, int flag)
-{
- int fd;
- if (type == SI_BLANK) //It shows nothing on the client...
- return 0;
-
- if (bl->type != BL_PC)
- return 0;
-
- fd = ((struct map_session_data*)bl)->fd;
-
- WFIFOHEAD(fd,packet_len(0x196));
- WFIFOW(fd,0)=0x0196;
- WFIFOW(fd,2)=type;
- WFIFOL(fd,4)=bl->id;
- WFIFOB(fd,8)=flag; //Status start
- WFIFOSET(fd, packet_len(0x196));
- return 0;
-}
-
-
/// Notifies clients of a status change.
-/// 0196 <index>.W <id>.L <state>.B (ZC_MSG_STATE_CHANGE)
-/// 043f <index>.W <id>.L <state>.B <remain msec>.L { <val>.L }*3 (ZC_MSG_STATE_CHANGE2)
-void clif_status_change(struct block_list *bl,int type,int flag,unsigned int tick,int val1, int val2, int val3)
+/// 0196 <index>.W <id>.L <state>.B (ZC_MSG_STATE_CHANGE) [used for ending status changes and starting them on non-pc units (when needed)]
+/// 043f <index>.W <id>.L <state>.B <remain msec>.L { <val>.L }*3 (ZC_MSG_STATE_CHANGE2) [used exclusively for starting statuses on pcs]
+void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val1, int val2, int val3)
{
unsigned char buf[32];
+ struct map_session_data *sd;
if (type == SI_BLANK) //It shows nothing on the client...
return;
nullpo_retv(bl);
- if (type == SI_BLANK || type == SI_MAXIMIZEPOWER || type == SI_RIDING ||
- type == SI_FALCON || type == SI_TRICKDEAD || type == SI_BROKENARMOR ||
- type == SI_BROKENWEAPON || type == SI_WEIGHT50 || type == SI_WEIGHT90 ||
- type == SI_TENSIONRELAX || type == SI_LANDENDOW || type == SI_AUTOBERSERK ||
- type == SI_BUMP || type == SI_READYSTORM || type == SI_READYDOWN ||
- type == SI_READYTURN || type == SI_READYCOUNTER || type == SI_DODGE ||
- type == SI_DEVIL || type == SI_NIGHT || type == SI_INTRAVISION ||
- type == SI_BANDING)
- tick=0;
-
-// TODO: 0x43f PACKETVER?
- if( battle_config.display_status_timers && tick>0 )
+ sd = BL_CAST(BL_PC, bl);
+
+ if (!(status_type2relevant_bl_types(type)&bl->type)) // only send status changes that actually matter to the client
+ return;
+
+ if(flag && battle_config.display_status_timers && sd)
WBUFW(buf,0)=0x43f;
else
WBUFW(buf,0)=0x196;
WBUFW(buf,2)=type;
WBUFL(buf,4)=bl->id;
WBUFB(buf,8)=flag;
- if( battle_config.display_status_timers && tick>0 )
+ if(flag && battle_config.display_status_timers && sd)
{
- WBUFL(buf,9)=tick;
+ if (tick <= 0)
+ tick = 9999; // this is indeed what official servers do
+
+ WBUFL(buf,9) = tick;
WBUFL(buf,13) = val1;
WBUFL(buf,17) = val2;
WBUFL(buf,21) = val3;
}
- clif_send(buf,packet_len(WBUFW(buf,0)),bl,AREA);
+ clif_send(buf,packet_len(WBUFW(buf,0)),bl, (sd && sd->status.option&OPTION_INVISIBLE) ? SELF : AREA);
}