Browse Source

* Added an option to re-roll the /dice emotion server-side, to prevent cheats during events (bugreport:4194).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14519 54d463be-8e91-2dee-dedb-b68131a5f0ec
ai4rei 14 năm trước cách đây
mục cha
commit
c82e8e36f1
5 tập tin đã thay đổi với 16 bổ sung2 xóa
  1. 1 0
      Changelog-Trunk.txt
  2. 4 0
      conf/battle/client.conf
  3. 1 0
      src/map/battle.c
  4. 1 0
      src/map/battle.h
  5. 9 2
      src/map/clif.c

+ 1 - 0
Changelog-Trunk.txt

@@ -1,6 +1,7 @@
 Date	Added
 
 2010/11/28
+	* Added an option to re-roll the /dice emotion server-side, to prevent cheats during events (bugreport:4194). [Ai4rei]
 	* Added emotion_type enumeration for clif_emotion constants. [Ai4rei]
 	- Made clif_parse_Emotion use clif_emotion, rather than having it's code inlined.
 	* Added clr_type enumeration for vanish effect constants. [Ai4rei]

+ 4 - 0
conf/battle/client.conf

@@ -119,3 +119,7 @@ display_hallucination: yes
 // Set this to 1 if your client supports status change timers and you want to use them
 // Clients from 2009 onward support this
 display_status_timers: yes
+
+// Randomizes the dice emoticon server-side, to prevent clients from forging
+// packets for the desired number. (Note 1)
+client_reshuffle_dice: no

+ 1 - 0
src/map/battle.c

@@ -4004,6 +4004,7 @@ static const struct _battle_data {
 	{ "invincible.nodamage",                &battle_config.invincible_nodamage,             0,      0,      1,              },
 	{ "mob_slave_keep_target",              &battle_config.mob_slave_keep_target,           0,      0,      1,              },
 	{ "autospell_check_range",              &battle_config.autospell_check_range,           0,      0,      1,              },
+	{ "client_reshuffle_dice",              &battle_config.client_reshuffle_dice,           0,      0,      1,              },
 // BattleGround Settings
 	{ "bg_update_interval",                 &battle_config.bg_update_interval,              1000,   100,    INT_MAX,        },
 	{ "bg_short_attack_damage_rate",        &battle_config.bg_short_damage_rate,            80,     0,      INT_MAX,        },

+ 1 - 0
src/map/battle.h

@@ -471,6 +471,7 @@ extern struct Battle_Config
 	int invincible_nodamage;
 	int mob_slave_keep_target;
 	int autospell_check_range;	//Enable range check for autospell bonus. [L0ne_W0lf]
+	int client_reshuffle_dice;  // Reshuffle /dice
 
 	// [BattleGround Settings]
 	int bg_update_interval;

+ 9 - 2
src/map/clif.c

@@ -9063,8 +9063,10 @@ void clif_parse_ChangeDir(int fd, struct map_session_data *sd)
  *------------------------------------------*/
 void clif_parse_Emotion(int fd, struct map_session_data *sd)
 {
+	int emoticon = RFIFOB(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0]);
+
 	if (battle_config.basic_skill_check == 0 || pc_checkskill(sd, NV_BASIC) >= 2) {
-		if (RFIFOB(fd,2) == E_MUTE) {// prevent use of the mute emote [Valaris]
+		if (emoticon == E_MUTE) {// prevent use of the mute emote [Valaris]
 			clif_skill_fail(sd, 1, 0, 1);
 			return;
 		}
@@ -9076,7 +9078,12 @@ void clif_parse_Emotion(int fd, struct map_session_data *sd)
 		}
 		sd->emotionlasttime = time(NULL) + 1; // not more than 1 per second (using /commands the client can spam it)
 
-		clif_emotion(&sd->bl, RFIFOB(fd,2));
+		if(battle_config.client_reshuffle_dice && emoticon>=E_DICE1 && emoticon<=E_DICE6)
+		{// re-roll dice
+			emoticon = rand()%6+E_DICE1;
+		}
+
+		clif_emotion(&sd->bl, emoticon);
 	} else
 		clif_skill_fail(sd, 1, 0, 1);
 }