Jump to content
  • 0
Sign in to follow this  
Vanquiser

Hansip 1.3 Anti Spam Compiling Error

Question

Can anyone fix this ??
 

 
skill.c: In function ‘hs_skill_delay_check’:
skill.c:15475: warning: suggest parentheses around assignment used as truth value
skill.c:15484: warning: suggest parentheses around assignment used as truth value
skill.c:15497: warning: suggest parentheses around assignment used as truth value
skill.c: In function ‘hs_flood_delay_check’:
skill.c:15566: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘int64’

im using Rathena Latest Revision ..

And the diff File...

Quote

 

// Hansip Protection 1.3 [Kichi]

 
diff --git a/src/map/battle.c b/src/map/battle.c
index d09cadb..f7e28dd 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -7842,6 +7842,10 @@ bool battle_check_range(struct block_list *src, struct block_list *bl, int range
{ "fame_pharmacy_5",                    &battle_config.fame_pharmacy_5,                 3,      0,      INT_MAX,        },
{ "fame_pharmacy_7",                    &battle_config.fame_pharmacy_7,                 10,     0,      INT_MAX,        },
{ "fame_pharmacy_10",                   &battle_config.fame_pharmacy_10,                50,     0,      INT_MAX,        },
+ { "hansip_protection",  &battle_config.hansip_protection, 1,     0,      1,              },
+ { "hansip_min_delay",                   &battle_config.hansip_min_delay,               100, 0,      INT_MAX,        },
+ { "hansip_spam_count",                  &battle_config.hansip_spam_count, 5, 3,      100, },
+ { "hansip_spam_punish",                  &battle_config.hansip_spam_punish, 1, 0,      1, },
 };
 #ifndef STATS_OPT_OUT
 /**
diff --git a/src/map/battle.h b/src/map/battle.h
index 4015529..d6eca81 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -543,6 +543,14 @@ extern struct Battle_Config
int taekwon_ranker_min_lv;
int revive_onwarp;
 
+ // Hansip [Kichi]
+ int status_min_duration;
+ int hansip_protection; //Make sure nodelay grf user still follow the rules [Kichi]
+ int hansip_min_delay;
+ int hansip_flood_protection;
+ int hansip_spam_count;
+ int hansip_spam_punish;
+
// Fame points
int fame_taekwon_mission;
int fame_refine_lv1;
diff --git a/src/map/clif.c b/src/map/clif.c
index 6ebbab3..621557d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -11307,6 +11307,11 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd)
return;
}
 
+ // Hansip Protection [Kichi]
+ if (battle_config.hansip_protection)
+ if (hs_flood_delay_check(sd,skill_id))
+ set_eof(fd);
+
// Whether skill fails or not is irrelevant, the char ain't idle. [skotlex]
sd->idletime = last_tick;
 
@@ -11406,6 +11411,9 @@ static void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, uin
clif_parse_UseSkillToPos_mercenary(sd->md, sd, tick, skill_id, skill_lv, x, y, skillmoreinfo);
return;
}
+ // Hansip Protection [Kichi]
+ if (battle_config.hansip_protection)
+ hs_flood_delay_check(sd,skill_id);
 
//Whether skill fails or not is irrelevant, the char ain't idle. [skotlex]
sd->idletime = last_tick;
diff --git a/src/map/pc.h b/src/map/pc.h
index bc70287..a24ecf2 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -228,6 +228,8 @@ struct map_session_data {
unsigned int banking : 1; //1 when we using the banking system 0 when closed
unsigned int hpmeter_visible : 1;
unsigned disable_atcommand_on_npc : 1; //Prevent to use atcommand while talking with NPC [Kichi]
+ unsigned hs_skill_check_double : 1; // Hansip - To check double cast [Kichi]
+ unsigned hs_skill_check_flood : 1; // Hansip - To check flood cast [Kichi]
} state;
struct {
unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
@@ -302,6 +304,15 @@ struct map_session_data {
unsigned int cansendmail_tick; // [Mail System Flood Protection]
unsigned int ks_floodprotect_tick; // [Kill Steal Protection]
 
+ // Hansip Protection [Kichi]
+ unsigned int canskill_tick2;
+ int64 last_skill;
+ unsigned int tem_tick_skill1; // Save temporer
+ unsigned int tem_tick_skill2;
+ unsigned int tem_tick_skill3;
+ unsigned int castskill_tick;
+ int spam_count;
+
struct s_item_delay {
unsigned short nameid;
unsigned int tick;
diff --git a/src/map/skill.c b/src/map/skill.c
index bda7e70..0be9d32 100755
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -15124,13 +15124,21 @@ struct skill_condition skill_get_requirement(struct map_session_data* sd, uint16
 int skill_castfix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
int time = skill_get_cast(skill_id, skill_lv);
 
+ struct map_session_data *sd;
+
nullpo_ret(bl);
+
 #ifndef RENEWAL_CAST
{
struct map_session_data *sd;
 
sd = BL_CAST(BL_PC, bl);
 
+ // Hansip Protection [Kichi]
+ // Skill Spam Check
+ if(sd && battle_config.hansip_protection)
+ hs_skill_delay_check(sd,skill_id,skill_lv,0);
+
// calculate base cast time (reduced by dex)
if( !(skill_get_castnodex(skill_id, skill_lv)&1) ) {
int scale = battle_config.castrate_dex_scale - status_get_dex(bl);
@@ -15158,6 +15166,9 @@ int skill_castfix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
 
}
 #endif
+
+ sd = BL_CAST(BL_PC, bl);
+
// config cast time multiplier
if (battle_config.cast_rate != 100)
time = time * battle_config.cast_rate / 100;
@@ -15165,6 +15176,9 @@ int skill_castfix (struct block_list *bl, uint16 skill_id, uint16 skill_lv) {
time = max(time, 0);
 
//ShowInfo("Castime castfix = %dn",time);
+ // Hansip Protection [Kichi]
+ if(sd && battle_config.hansip_protection)
+ hs_skill_delay_check(sd,skill_id,skill_lv,0);
return time;
 }
 
@@ -15413,9 +15427,132 @@ int skill_delayfix (struct block_list *bl, uint16 skill_id, uint16 skill_lv)
time = max(time, battle_config.min_skill_delay_limit);
 
//ShowInfo("Delay delayfix = %dn",time);
+ // Hansip Protection [Kichi]
+ if(battle_config.hansip_protection)
+ if (sd->state.hs_skill_check_double){
+ time = hs_skill_delay_penalty(skill_id);
+ sd->state.hs_skill_check_double = 0 ;
+ }
return time;
 }
 
+/*==========================================
+* Hansip Skill delay check [Kichi]
+* it will player who recast same skill below X ms
+* official ragnarok let you recast a same skill if the player has enough aspd to do
+*------------------------------------------*/
+int hs_skill_delay_check (struct map_session_data *sd, uint16 skill_id, uint16 skill_lv,uint16 flag) {
+ switch (skill_id) {
+ case AS_SONICBLOW:
+ case GC_CROSSIMPACT:
+ case CG_ARROWVULCAN:
+ if (sd->last_skill = skill_id){
+ if(( DIFF_TICK(sd->canskill_tick2, gettick()) > 0 ))
+ sd->state.hs_skill_check_double = 1 ;
+ else
+ sd->canskill_tick2 = gettick() + 1500;
+ }
+ break;
+ case RK_DRAGONBREATH:
+ case RK_DRAGONBREATH_WATER:
+ if (sd->last_skill = skill_id){
+ if(( DIFF_TICK(sd->canskill_tick2, gettick()) > 0 ))
+ sd->state.hs_skill_check_double = 1 ;
+ else
+ sd->canskill_tick2 = gettick() + 1000;
+ }
+ break;
+ case AC_DOUBLE:
+ case SM_BASH:
+ case KN_BOWLINGBASH:
+ case NJ_KOUENKA:
+ case NJ_HYOUSENSOU:
+ case WZ_JUPITEL:
+ if (sd->last_skill = skill_id)
+ sd->state.hs_skill_check_double = 1 ;
+ break;
+ default:
+ break;
+ }
+ sd->last_skill = skill_id;
+ return 1;
+}
+
+/*==========================================
+* Hansip Skill delay penalty [Kichi]
+* It will check if the player has been cast 2 times
+* As the official client rules, you only able to do cast 2 times and 
+* you should wait till the act end.
+*------------------------------------------*/
+int hs_skill_delay_penalty(uint16 skill_id) {
+ int time = 0;
+ switch (skill_id) {
+ case AS_SONICBLOW:
+ case GC_CROSSIMPACT:
+ case CG_ARROWVULCAN:
+ time = 2000;
+ break;
+ case RK_DRAGONBREATH:
+ case RK_DRAGONBREATH_WATER:
+ time = 1200;
+ break;
+ case AC_DOUBLE:
+ case SM_BASH:
+ case NJ_KOUENKA:
+ case NJ_HYOUSENSOU:
+ case WZ_JUPITEL:
+ time = 350;
+ break;
+ case KN_BOWLINGBASH:
+ time = 490;
+ break;
+ default:
+ time = battle_config.hansip_min_delay;
+ break;
+ }
+ return time;
+ }
+
+int hs_flood_delay_check (struct map_session_data *sd, uint16 skill_id) {
+ int64 sum;
+ char message_to_gm[200];
+ if (!sd)
+ return 0;
+
+ if (sd->last_skill && sd->last_skill == skill_id){
+
+ if (sd->tem_tick_skill2)
+ sd->tem_tick_skill3 = sd->tem_tick_skill2;
+
+ if (sd->tem_tick_skill1)
+ sd->tem_tick_skill2 = sd->tem_tick_skill1;
+ if (sd->castskill_tick)
+ sd->tem_tick_skill1 = gettick()- sd->castskill_tick;//; DIFF_TICK(sd->castskill_tick, gettick());
+
+ sum = (sd->tem_tick_skill3 + sd->tem_tick_skill2 + sd->tem_tick_skill1) / 3;
+
+ if (sum >= sd->tem_tick_skill3 - 20 && sum <= sd->tem_tick_skill3 + 20)
+ sd->spam_count = sd->spam_count + 1;
+ else
+ sd->spam_count = 0;
+
+ if (sd->spam_count > 3){
+ sprintf(message_to_gm, "[Hansip] : Spam Detected!  '%s' probably use third party. Constantly flood %d times, tick %d", sd->status.name,  sd->spam_count, sum);
+ intif_wis_message_to_gm(wisp_server_name, PC_PERM_RECEIVE_HACK_INFO, message_to_gm);
+ }
+ if (sd->spam_count >= battle_config.hansip_spam_count && battle_config.hansip_spam_punish)
+ return 1;
+ sd->castskill_tick = gettick();
+ }else{
+ sd->tem_tick_skill1 = 0;
+ sd->tem_tick_skill2 = 0;
+ sd->tem_tick_skill3 = 0;
+ sd->spam_count = 0;
+ }
+ sd->last_skill = skill_id;
+
+ return 0;
+}
 /*=========================================
  *
  *-----------------------------------------*/
diff --git a/src/map/skill.h b/src/map/skill.h
index df411f4..bc22c16 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -389,6 +389,11 @@ int skill_vfcastfix( struct block_list *bl, double time, uint16 skill_id, uint16
 #endif
 int skill_delayfix( struct block_list *bl, uint16 skill_id, uint16 skill_lv);
 
+// Hansip Protection [Kichi]
+int hs_skill_delay_check( struct map_session_data *sd, uint16 skill_id, uint16 skill_lv,uint16 flag);
+int hs_skill_delay_penalty( uint16 skill_id);
+int hs_flood_delay_check (struct map_session_data *sd, uint16 skill_id);
+
 // Skill conditions check and remove [inkfish]
 bool skill_check_condition_castbegin(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv);
 bool skill_check_condition_castend(struct map_session_data *sd, uint16 skill_id, uint16 skill_lv);

 

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.