Skip to content

Instantly share code, notes, and snippets.

@cydh
Created August 15, 2016 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cydh/0be6023091862428f8460f13849ea93e to your computer and use it in GitHub Desktop.
Save cydh/0be6023091862428f8460f13849ea93e to your computer and use it in GitHub Desktop.
* Cleaned up `clif_status_change`. * Removed `BL_SCEFFECT` and `StatusRelevantBLTypes` array.
diff --git a/src/map/clif.c b/src/map/clif.c
index 9387c3f..ccf134f 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -5820,10 +5820,17 @@ void clif_cooking_list(struct map_session_data *sd, int trigger, uint16 skill_id
/// 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]
/// 0983 <index>.W <id>.L <state>.B <total msec>.L <remain msec>.L { <val>.L }*3 (ZC_MSG_STATE_CHANGE3) (PACKETVER >= 20120618)
-void clif_status_change_sub(struct block_list *bl,int type,int flag,int tick,int val1, int val2, int val3, enum send_target target_type)
+/// @param bl Show/send packet to clients around this object
+/// @param id ID of object that having this effect
+/// @param type Status icon see enum si_type
+/// @param flag 1:Active, 0:Deactive
+/// @param tick Duration in ms
+/// @param val1
+/// @param val2
+/// @param val3
+void clif_status_change_sub(struct block_list *bl, int id, int type, int flag, int tick, int val1, int val2, int val3, enum send_target target_type)
{
unsigned char buf[32];
- struct map_session_data *sd;
if (type == SI_BLANK) //It shows nothing on the client...
return;
@@ -5833,36 +5840,32 @@ void clif_status_change_sub(struct block_list *bl,int type,int flag,int tick,int
nullpo_retv(bl);
- 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 PACKETVER >= 20120618
- if(flag && battle_config.display_status_timers && sd)
- WBUFW(buf,0)=0x983;
+ if (flag && battle_config.display_status_timers)
+ WBUFW(buf,0) = 0x983;
else
#elif PACKETVER >= 20090121
- if(flag && battle_config.display_status_timers && sd)
- WBUFW(buf,0)=0x43f;
+ if (flag && battle_config.display_status_timers)
+ WBUFW(buf,0) = 0x43f;
else
#endif
- WBUFW(buf,0)=0x196;
- WBUFW(buf,2)=type;
- WBUFL(buf,4)=bl->id;
- WBUFB(buf,8)=flag;
+ WBUFW(buf,0) = 0x196;
+ WBUFW(buf,2) = type;
+ WBUFL(buf,4) = id;
+ WBUFB(buf,8) = flag;
#if PACKETVER >= 20120618
- if(flag && battle_config.display_status_timers && sd) {
+ if (flag && battle_config.display_status_timers) {
if (tick <= 0)
tick = 9999; // this is indeed what official servers do
- WBUFL(buf,9)=tick;/* at this stage remain and total are the same value I believe */
- WBUFL(buf,13)=tick;
+ WBUFL(buf,9) = tick;/* at this stage remain and total are the same value I believe */
+ WBUFL(buf,13) = tick;
WBUFL(buf,17) = val1;
WBUFL(buf,21) = val2;
WBUFL(buf,25) = val3;
}
#elif PACKETVER >= 20090121
- if(flag && battle_config.display_status_timers && sd) {
+ if (flag && battle_config.display_status_timers) {
if (tick <= 0)
tick = 9999; // this is indeed what official servers do
@@ -5872,11 +5875,20 @@ void clif_status_change_sub(struct block_list *bl,int type,int flag,int tick,int
WBUFL(buf,21) = val3;
}
#endif
- clif_send(buf,packet_len(WBUFW(buf,0)),bl, target_type);
+ clif_send(buf, packet_len(WBUFW(buf,0)), bl, target_type);
}
-void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val1, int val2, int val3) {
- struct map_session_data *sd;
+/* Sends status effect to clients/players around the bl
+ * @param bl Object that has the effect
+ * @param type Status icon see enum si_type
+ * @param flag 1:Active, 0:Deactive
+ * @param tick Duration in ms
+ * @param val1
+ * @param val2
+ * @param val3
+ */
+void clif_status_change(struct block_list *bl, int type, int flag, int tick, int val1, int val2, int val3) {
+ struct map_session_data *sd = NULL;
if (type == SI_BLANK) //It shows nothing on the client...
return;
@@ -5888,10 +5900,7 @@ void clif_status_change(struct block_list *bl,int type,int flag,int tick,int val
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;
-
- clif_status_change_sub(bl,type, flag, tick, val1, val2, val3, (sd && sd->status.option&OPTION_INVISIBLE) ? SELF : AREA);
+ clif_status_change_sub(bl, bl->id, type, flag, tick, val1, val2, val3, ((sd ? (sd->status.option&OPTION_INVISIBLE ? SELF : AREA) : AREA_WOS)));
}
/**
@@ -5923,10 +5932,7 @@ void clif_efst_status_change_sub(struct map_session_data *sd, struct block_list
#if PACKETVER > 20120418
clif_efst_status_change((target == SELF) ? &sd->bl : bl, bl->id, target, StatusIconChangeTable[type], tick, tsd->sc_display[i]->val1, tsd->sc_display[i]->val2, tsd->sc_display[i]->val3);
#else
- /** !CHECKME: Corrected packet for this client for clif_efst_status_change.
- * The packet sent by clif_status_change_sub only works only the char with the effect sends the effect detail.
- **/
- clif_status_change_sub(&tsd->bl, StatusIconChangeTable[type], 1, tick, tsd->sc_display[i]->val1, tsd->sc_display[i]->val2, tsd->sc_display[i]->val3, (target == SELF) ? AREA_WOS : AREA);
+ clif_status_change_sub(&sd->bl, bl->id, StatusIconChangeTable[type], 1, tick, tsd->sc_display[i]->val1, tsd->sc_display[i]->val2, tsd->sc_display[i]->val3, target);
#endif
}
}
diff --git a/src/map/status.c b/src/map/status.c
index 3a4d154..4dbd060 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -139,24 +139,9 @@ unsigned int status_sc2scb_flag(sc_type sc)
return StatusChangeFlagTable[sc];
}
-/**
- * Returns the bl types which require a status change packet to be sent for a given client status identifier.
- * @param type The client-side status identifier to look up (see enum si_type)
- * @return The bl types relevant to the type (see enum bl_type)
- */
-int status_type2relevant_bl_types(int type)
-{
- if( type < 0 || type >= SI_MAX ) {
- ShowError("status_type2relevant_bl_types: Unsupported type %d\n", type);
- return SI_BLANK;
- }
-
- return StatusRelevantBLTypes[type];
-}
-
#define add_sc(skill,sc) set_sc(skill,sc,SI_BLANK,SCB_NONE)
// Indicates that the status displays a visual effect for the affected unit, and should be sent to the client for all supported units
-#define set_sc_with_vfx(skill, sc, icon, flag) set_sc((skill), (sc), (icon), (flag)); if((icon) < SI_MAX) StatusRelevantBLTypes[(icon)] |= BL_SCEFFECT
+#define set_sc_with_vfx(skill, sc, icon, flag) set_sc((skill), (sc), (icon), (flag));
static void set_sc(uint16 skill_id, sc_type sc, int icon, unsigned int flag)
{
@@ -186,8 +171,6 @@ static void set_sc_with_vfx_noskill(sc_type sc, int icon, unsigned flag) {
StatusIconChangeTable[sc] = icon;
StatusChangeFlagTable[sc] |= flag;
}
- if (icon > SI_BLANK && icon < SI_MAX)
- StatusRelevantBLTypes[icon] |= BL_SCEFFECT;
}
void initChangeTables(void)
@@ -200,9 +183,6 @@ void initChangeTables(void)
for (i = 0; i < MAX_SKILL; i++)
SkillStatusChangeTable[i] = SC_NONE;
- for (i = 0; i < SI_MAX; i++)
- StatusRelevantBLTypes[i] = BL_PC;
-
memset(StatusSkillChangeTable, 0, sizeof(StatusSkillChangeTable));
memset(StatusChangeFlagTable, 0, sizeof(StatusChangeFlagTable));
memset(StatusChangeStateTable, 0, sizeof(StatusChangeStateTable));
diff --git a/src/map/status.h b/src/map/status.h
index 923c677..3e0518d 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -1972,8 +1972,6 @@ enum e_status_bonus {
#define BL_CONSUME (BL_PC|BL_HOM|BL_MER|BL_ELEM)
///Define to determine who has regen
#define BL_REGEN (BL_PC|BL_HOM|BL_MER|BL_ELEM)
-///Define to determine who will receive a clif_status_change packet for effects that require one to display correctly
-#define BL_SCEFFECT (BL_PC|BL_HOM|BL_MER|BL_MOB|BL_ELEM)
/** Basic damage info of a weapon
* Required because players have two of these, one in status_data
@@ -1992,7 +1990,6 @@ sc_type SkillStatusChangeTable[MAX_SKILL]; /// skill -> status
int StatusIconChangeTable[SC_MAX]; /// status -> "icon" (icon is a bit of a misnomer, since there exist values with no icon associated)
unsigned int StatusChangeFlagTable[SC_MAX]; /// status -> flags
int StatusSkillChangeTable[SC_MAX]; /// status -> skill
-int StatusRelevantBLTypes[SI_MAX]; /// "icon" -> enum bl_type (for clif->status_change to identify for which bl types to send packets)
unsigned int StatusChangeStateTable[SC_MAX]; /// status -> flags
bool StatusDisplayType[SC_MAX];
@@ -2121,7 +2118,6 @@ struct status_change {
sc_type status_skill2sc(int skill);
int status_sc2skill(sc_type sc);
unsigned int status_sc2scb_flag(sc_type sc);
-int status_type2relevant_bl_types(int type);
int StatusIconChangeTable[SC_MAX]; /// status -> "icon" (icon is a bit of a misnomer, since there exist values with no icon associated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment