@packetfilter

AnnieRuru

~~Cute~Cute~Scripter~~
Messages
1,677
Points
0
Location
your next door ~
Discord
AnnieRuru#1609
Github
AnnieRuru
Emulator
Client Version
2019-05-30aRagexeRE
No more Work in Progress, Please report if there are any bug

Download: 1.0a [Complete]

plugin



What is `@packetfilter` ?

`@packetfilter` is a custom mod originate from eamod

https://github.com/zephyrus-cr/eamod/blob/master/Servers/rAthena/conf/groups.conf#L418-L422

-Activates a mode to ignore some packets on WoE, comming from other users

-This reduce the bandwith a little bit on WoE, reducing LAG.

-C = Ignore jokes and global chat messages from others.

-I = Ignores Item usage from others.

packetfilter: true
it can actually reduce lag on your live server during woe depends on how many players activate it

it totally depends on the player's side, community effort that every player should together turn on the `@packetfilter` to reduce massive lag during woe

this modification is actually very famous and there are members willingly to pay for it

https://rathena.org/board/topic/121200-packetfilter-battleinfo/

https://rathena.org/board/topic/123203-battleinfo-packetfilter/

https://rathena.org/board/topic/111797-packetfilter-zepyhrus-ramod/

https://rathena.org/board/topic/79995-buy-noactnodelay-partybuff-src-as-it-was-on-pro-ro-or-packetfilter/



this `@packetfilter` is unlike the one you are having, or that is circulating on rathena forum

this one has been written entirely from scratch and added some other flags that the original don't

for example,

`@packetfilter COHM EOHM`

allow block normal chat and emotion from non-related players, pets, homunculus and monsters
but this doesn't block normal chat from party/guild members

a full list of flags are

  •   C = ignore normal Chat, including Dancer's scream, Bard's frost joke, and pet's talk (pet start to talk when intimacy > 900)
  •   E = ignore emotion, including monster and pet emotion (but NOT pet performance)
  •   I = ignore Item use effect
  •   A = ignore normal Attack animation (based on receiving side), your own attack animation are always shown
  •   B = Buffing skill animations (based on receiving side), your own casting animation are always shown
  •   S = Status effect
  •   T = offensive single Target skill/spell animations (based on receiving side), your own casting animation are always shown
  •   G = Ground based skills (eg:storm gust), your own casting animation are always shown
  •   M = Music dance/songs from Bard/Dancer
  •   D = Direction. Recommend filter on Party/Guild type and not enemies. Highly Recommend for supportive type Class.
after the Main type, also support additional flags

  •   S = Self
  •   P = Party
  •   G = Guild
  •   B = Battleground
  •   C = Clan
  •   O = Other players, none of the above
  •   H = Homunculus/pets/elementals/mercenary and player's @summon
  •   M = Monsters




Why This plugin doesn't block Kaite or Energy Coat ?

2 reasons

No.1 - currently there is a bug with plugin,

struct packet_spawn_unit *p = (struct packet_spawn_unit*)RBUFP(buf, 0);


this line will throw error on Linux

so no choice, maybe I'll make a bug report

this bug also has been reported on Dastgir's `@noview`





No.2 - just set p->virtue = 0; isn't really blocking the packet

this goes against the very principle of this plugin, which is NOT send certain packet to the client

OPT3 (including OPT3_KAITE | OPT3_ENERGYCOAT | OPT3_SOULLINK) is part of the idle_unitType, unit_walkingType and spawn_unitType function

and blocking those 3 packet entirely is stupid

in case you don't understand, look under clif_set_unit_walking and clif_set_unit_idle function inside src\map\clif.c file

p.GUID = g_id;
p.GEmblemVer = status->get_emblem_id(bl);
p.honor = (sd) ? sd->status.manner : 0;
// p.virtue = (sc) ? sc->opt3 : 0; <-- change this line
p.virtue = 0;
p.isPKModeON = (sd && sd->status.karma) ? 1 : 0;
p.sex = vd->sex;






Note: about [D]irection type packet

try add a ShowDebug inside clif->send

src/map/clif.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/src/map/clif.c b/src/map/clif.c
index ab3c4422a..9e245f335 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -450,6 +450,7 @@ static bool clif_send(const void *buf, int len, struct block_list *bl, enum send
return true;
}

+ShowDebug("source:%s buf:0x%x send_target:%d\n", (sd != NULL)? sd->status.name : "NULL", RBUFW(buf, 0), type);
switch(type) {
case ALL_CLIENT: //All player clients.
iter = mapit_getallusers();


you will find 0x9c is being send repeatedly on every attack and every skill cast , getting attack etc

this direction update packet isn't just send by Shift-click, but also including all the actions above

this packet is very spam-able and I think can be safely block on party/guild/clan/bg flags

for supportive class, I also think can block all of them since supportive class doesn't need information from enemies

0.1 - plugin

- proof of concept

0.2 - plugin

- add sub-type flags (Self/Party/Guild/Bg/Other/Homun/Mob)

- add emotion filter

- fix compiler warning that doesn't display on visual studio

0.3 - plugin

- add missing FILTER_CLAN flag

- implement block_item type 'I' flag

- fix FILTER_OTHER not working properly when the player doesn't have a party or guild

- fix [C]hat type shouldn't able to filter self, since the client always shows you are talking anyway

- and attempt to fix the above stupid error that doesn't show on Visual Studio

0.4 - plugin

- if its not BL_PC|BL_PET|BL_HOM|BL_MER|BL_ELEM|BL_MOB immediately jump out of function for faster processing

- fix sd->status.clan_id

- implement block attack [A] and buff [B ] flag

- don't need to use snprintf needlessly when print out the flags

- just unset the flag if the SELF flag isn't supported

0.5 - plugin

- fix linux compile warning `type` not being use

- change useItemAckType into 0x1c8 ... hopefully no more nullpo ?

- allow blocking casting animation, save more bandwidth

- implement [T], [G], [D] type respectively

1.0 - plugin

- introduce type [D], direction packet, and existing Dance/songs move to type `[M]usic`

- no longer use nested IF-ELSE, use switch statement on the packet header for faster read speed

- fix [I.]tem type throw nullpo error on 2018 client

- add Caution as a warning that certain packet filter wont work correctly

 
Last edited by a moderator:
I've never seen this kinda of modification and i think its very neat one to maybe put as a forced settings via mapflag.

Maybe the ability to only see the damage you deal and recieve, the packet would still be sent anyway because I think it's bounded to "receive damage" animaiton effect, but might reduce image cluster when maps are crowded. Maybe if passing it as 0 would reduce memory? noidea

Not sure what else could we block from been area sent ^^

Gratz on the project

 

 
I've never seen this kinda of modification and i think its very neat one to maybe put as a forced settings via mapflag.

Maybe the ability to only see the damage you deal and recieve, the packet would still be sent anyway because I think it's bounded to "receive damage" animaiton effect, but might reduce image cluster when maps are crowded. Maybe if passing it as 0 would reduce memory? noidea
mf_gvg mapflag and mf_gvg_castle mapflag with `@agitstart` on will disallow showing the damage packet already ? I think they sent as 1 damage or something

https://github.com/HerculesWS/Hercules/blob/1354b01c7a24e9ffd9ea570cbaec668721fc2a6c/conf/map/battle/client.conf#L55-L58

// When set to true, the damage field in packets sent from woe maps will be set
// to -1, making it impossible for GMs, Bots and Hexed clients to know the
// actual damage caused by attacks. (Note 1)
hide_woe_damage: true
search hide_woe_damage in clif.c, the packet indeed altered to become if (skill is multiple hit)? number of hits : 0;

if( battle_config.hide_woe_damage && map_flag_gvg2(src->m) ) {
p.damage = damage?div:0;
p.leftDamage = damage2?div:0;
} else {
p.damage = damage;
p.leftDamage = damage2;
}




and yes, this modification is indeed REMOVE certain packet send to reduce server bandwidth

this can only stays as plugin, and could never get into our emulator, despite how popular it is

 
@AnnieRuru

I knew about the woe hiding the damage, but I was wondering if hiding everyones damage but yours would reduce bandwidth and memory.

Example:

If tou have 20 player hiting a worldboss for 123456789(damages are high nowadays)

That wouldbe 20 x 12356789 packets sent with that value per player...

If it shows only your (self) damage there would be 1 x 123456789 damage packet and 19 x -1 for the damage animation.

(Hope its clear)

Do you think It would improve performance?

 
actually normal hit a monster send multiple packets

let's put a ShowDebug on clif->send function

src/map/clif.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/map/clif.c b/src/map/clif.c
index 54c9869c3..38ac2ea1e 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -449,7 +449,7 @@ static bool clif_send(const void *buf, int len, struct block_list *bl, enum send
else if (type == AREA_WOS || type == BG_WOS || type == BG_AREA_WOS)
return true;
}
-
+ShowDebug("source:%s buf:%d send_target:%d\n", (sd != NULL)? sd->status.name : "NULL", RBUFW(buf, 0), type);
switch(type) {
case ALL_CLIENT: //All player clients.
iter = mapit_getallusers();


`@monster poporing` and hit it once, and here is what I get

[Debug]: source:NULL buf:2248 send_target:2
[Debug]: source:AnnieRuru buf:156 send_target:2
[Debug]: source:NULL buf:2557 send_target:2
[Debug]: source:AnnieRuru buf:2248 send_target:2
[Debug]: source:NULL buf:156 send_target:2
[Debug]: source:AnnieRuru buf:2248 send_target:2
[Debug]: source:NULL buf:156 send_target:2
[Debug]: source:AnnieRuru buf:2248 send_target:2


analyze the packet

2248 hex 0x8C8 is ZC_NOTIFY_ACT2 came from clif_damage function

/// Sends a 'damage' packet (src performs action on dst)
/// 008a <src ID>.L <dst ID>.L <server tick>.L <src speed>.L <dst speed>.L <damage>.W <div>.W <type>.B <damage2>.W (ZC_NOTIFY_ACT)
/// 02e1 <src ID>.L <dst ID>.L <server tick>.L <src speed>.L <dst speed>.L <damage>.L <div>.W <type>.B <damage2>.L (ZC_NOTIFY_ACT2)
/// 08c8 <src ID>.L <dst ID>.L <server tick>.L <src speed>.L <dst speed>.L <damage>.L <IsSPDamage>.B <div>.W <type>.B <damage2>.L (ZC_NOTIFY_ACT2)
/// type: @see enum battle_dmg_type
/// for BDT_NORMAL: [ damage: total damage, div: amount of hits, damage2: assassin dual-wield damage ]
static int clif_damage(struct block_list *src, struct block_list *dst, int sdelay, int ddelay, int64 in_damage, short div, enum battle_dmg_type type, int64 in_damage2)


156 hex 0x9c is ZC_CHANGE_DIRECTION came from clif_changed_dir function

/// Updates body and head direction of an object (ZC_CHANGE_DIRECTION).
/// 009c <id>.L <head dir>.W <dir>.B
/// head dir:
/// 0 = straight
/// 1 = turned CW
/// 2 = turned CCW
/// dir: @see enum unit_dir
static void clif_changed_dir(struct block_list *bl, enum send_target target)


2557 hex 0x9fd is unit_walkingType (src\map\packet_struct.h) ... couldn't find where this came from ... I rather don't touch this at the moment

this means, whenever I attack something, it sends an attack animation and also updates the client to face the attacking source enemy

so if we block ZC_CHANGE_DIRECTION for the monster, this will cause rogue's backstab to not function properly

Do you think It would improve performance?
the answer is YES, block ZC_NOTIFY_ACT2

here's the plugin `@filterattack`

https://github.com/AnnieRuru/Release/blob/master/plugins/packetfilter/filterattack.c

after tested it, `@filterattack 63` looks like everyone is standing still facing each other (remember ZC_CHANGE_DIRECTION packet is still sent)

 
the answer is YES, block ZC_NOTIFY_ACT2

here's the plugin `@filterattack`

https://github.com/AnnieRuru/Release/blob/master/plugins/packetfilter/filterattack.c

after tested it, `@filterattack 63` looks like everyone is standing still facing each other (remember ZC_CHANGE_DIRECTION packet is still sent)
Nice analysis for my random question xD. Thanks for all the informations ^^.

I think you can reverse the development process and see where the "playable" treshold stands at.
For example blocking all the packet and then enabling back, while doing some kinda of perfomance test to see the hit on memory.
You would probably need to setup a test environment, eg, 1,4,8,20 players in the area.

But that's a lot of work xD And afterall the project already stants on a very awesome state so congratz again.

 
0.2 - plugin

- add sub-type flags (Self/Party/Guild/Bg/Other/Homun/Mob)

- add emotion filter

- fix compiler warning that doesn't display on visual studio

actually there are a lot of people interested in this topic...

@xJhay

let me just copy paste from a PM



the reason I started this topic because I received the `@packetfilter` for rathena use, and asked me to convert into plugin

and upon reading it I found its very inconvenient and thus I want to rewrite it

that version I receive is block based on skill ID

but my plan is to block based on flags, not every skill ID entry

if block by skill type listed in skill_db,conf will make the plugin future proof

SkillType: { (bool, defaults to "Passive")
Passive: true/false (boolean, defaults to false)
Enemy: true/false (boolean, defaults to false)
Place: true/false (boolean, defaults to false)
Self: true/false (boolean, defaults to false)
Friend: true/false (boolean, defaults to false)
Trap: true/false (boolean, defaults to false)
}
SkillInfo: { (bool, defaults to "None")
Quest: true/false (boolean, defaults to false)
NPC: true/false (boolean, defaults to false)
Wedding: true/false (boolean, defaults to false)
Spirit: true/false (boolean, defaults to false)
Guild: true/false (boolean, defaults to false)
Song: true/false (boolean, defaults to false)
Ensemble: true/false (boolean, defaults to false)




PS: just like card seller A-Z, before I made that script every member posted on the board manually insert each card ID into each npc,
until I made that SQL version which rip from SQL database, that old script still works today, make it future proof



another thing to note about that version is because it block base on skill ID only, it doesn't make use of the flag of each packet

on the battlefield, or I mean during woe, there are a lot of packets being sent even if its unnecessary information

for example, your guild and another guild A attacking defending guild B,

and your guild and guild A are not on good terms and rushing to destroy the emperium

my point is, guild A attacking guild B are unnecessary in my opinion, and I don't need those packet informations

but I still need to know my party/guild are under attack

/// 02e1 <src ID>.L <dst ID>.L <server tick>.L <src speed>.L <dst speed>.L <damage>.L <div>.W <type>.B <damage2>.L (ZC_NOTIFY_ACT2)


and I can use <src ID> and <dst ID> and check are they the same guild ? then send packet

is <dst ID> my guild mates ? then send packet

the rest are not important

that version simply block by skill ID and from my understanding, I wouldn't know who is actually healing me when enable `@packetfilter`

there are some healer who are good in healing others and some just standing there acting like a doll waiting to get hit

my idea is make additional field so only filter out unneeded information

when playing as crusader, my job is to defend my party, and I want all information packets send that are threatening my party

when playing as assassin, I don't have to take care of guild member, I only want to assassinate the healer or dd who are actively killing the most of my guildmates etc

yeah, make it highly configurable



anyway read the additional information I already made this part a reality,

but so far only chat and emotions are implement, skills has to do ... maybe tomorrow ...

 
Hi mam, once again error won't show up in windows compiler but showing in another compiler.

Here it is, already tried the 0.2:

image.png

 
PLEASE GIVE ME YOUR COMPILER

I want my visual studio 2019 also display error like yours

btw I'm guessing that's CentOS, this happened before on my OnPCUseSkillEvent

0.3 - plugin

- add missing FILTER_CLAN flag

- implement block_item type 'I' flag

- fix FILTER_OTHER not working properly when the player doesn't have a party or guild

- fix [C]hat type shouldn't able to filter self, since the client always shows you are talking anyway

- and attempt to fix the above stupid error that doesn't show on Visual Studio

 
@AnnieRuru i not sure is this can works, but you can try use clang in visual studio. it probably will show more errors.

or use WSL or WSL2 with linux kernel and tools inside.

 
@AnnieRuru i not sure is this can works, but you can try use clang in visual studio. it probably will show more errors.

or use WSL or WSL2 with linux kernel and tools inside. 
https://devblogs.microsoft.com/cppblog/clang-llvm-support-in-visual-studio/

and maybe this one ?
https://devblogs.microsoft.com/dotnet/debug-your-net-core-apps-in-wsl-2-with-visual-studio/

visual_studio_with_clang.png


... maybe next time ...



0.4 - plugin

- if its not BL_PC|BL_PET|BL_HOM|BL_MER|BL_ELEM|BL_MOB immediately jump out of function for faster processing

- fix sd->status.clan_id

- implement block attack [A] and buff [B ] flag

- don't need to use snprintf needlessly when print out the flags

- just unset the flag if the SELF flag isn't supported

no kaute/kaipe pls :(
Kaite.png


Kaite is indeed very interesting

I'm 100% sure I've block the casting animation for Kaahi Kaizel Kaupe ... and of course Kaite

but I think what you guys want is the effect of the Kaite to turn off ?

that should be another kind of source edit plugin

EDIT: wait, let me put ShowDebug on it again .... editing ....

it send 2 types of packet, 0x9cb and 0x983

0x9cb is clif_skill_nodamage

0x983 is clif_status_change_sub

means has to read p.index to know the the skill ID ....

EDIT2: 0x229 ... WOW don't block this packet

if the player is hiding/cloaking, enable this packetfilter will show her !!

needs to be cautious about this packet...

EDIT3: I think I figure it out, it is OPT3, means just set OPT3 into 0 will do

 
Last edited by a moderator:
PLEASE GIVE ME YOUR COMPILER

I want my visual studio 2019 also display error like yours

btw I'm guessing that's CentOS, this happened before on my OnPCUseSkillEvent

0.3 - plugin

- add missing FILTER_CLAN flag

- implement block_item type 'I' flag

- fix FILTER_OTHER not working properly when the player doesn't have a party or guild

- fix [C]hat type shouldn't able to filter self, since the client always shows you are talking anyway

- and attempt to fix the above stupid error that doesn't show on Visual Studio
Tried the latest Ms. @AnnieRuru and getting error on @packetfilter IOHM

image.png

 
https://devblogs.microsoft.com/cppblog/clang-llvm-support-in-visual-studio/

and maybe this one ?
https://devblogs.microsoft.com/dotnet/debug-your-net-core-apps-in-wsl-2-with-visual-studio/



... maybe next time ...



0.4 - plugin

- if its not BL_PC|BL_PET|BL_HOM|BL_MER|BL_ELEM|BL_MOB immediately jump out of function for faster processing

- fix sd->status.clan_id

- implement block attack [A] and buff [B ] flag

- don't need to use snprintf needlessly when print out the flags

- just unset the flag if the SELF flag isn't supported



Kaite is indeed very interesting

I'm 100% sure I've block the casting animation for Kaahi Kaizel Kaupe ... and of course Kaite

but I think what you guys want is the effect of the Kaite to turn off ?

that should be another kind of source edit plugin

EDIT: wait, let me put ShowDebug on it again .... editing ....

it send 2 types of packet, 0x9cb and 0x983

0x9cb is clif_skill_nodamage

0x983 is clif_status_change_sub

means has to read p.index to know the the skill ID ....

EDIT2: 0x229 ... WOW don't block this packet

if the player is hiding/cloaking, enable this packetfilter will show her !!

needs to be cautious about this packet...

EDIT3: I think I figure it out, it is OPT3, means just set OPT3 into 0 will do
thank you for your dedication and for helping us, Annie. 

 
0.5 - plugin

- fix linux compile warning `type` not being use

- change useItemAckType into 0x1c8 ... hopefully no more nullpo ?

- allow blocking casting animation, save more bandwidth

- implement [T], [G], [D] type respectively

also, I split the original Land Protector and bard/dancer song out

Land Protector is under [G] type, Apple of Idun is under [D] type

Basilica is under [B.] type

type [S.] still has some bug, if being cast directly in front of the player, it doesn't block correctly

.. very close to finish

@Kuroyama, try again

 
Last edited by a moderator:
0.5 - plugin

- fix linux compile warning `type` not being use

- change useItemAckType into 0x1c8 ... hopefully no more nullpo ?

- allow blocking casting animation, save more bandwidth

- implement [T], [G], [D] type respectively

also, I split the original Land Protector and bard/dancer song out

Land Protector is under [G] type, Apple of Idun is under [D] type

Basilica is under [B.] type

type [S.] still has some bug, if being cast directly in front of the player, it doesn't block correctly

.. very close to finish

@Kuroyama, try again
I did try it now Ms. @AnnieRuru. Here's the new error:

On windows compiler:

image.png

On CentOS/Linux:

image.png

image.png

image.png

image.png

 
Back
Top