Browse Source

- Corrected autoloot so that you can specify rate with decimal precision ("@autoloot 0.01" should work)

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@7294 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex 19 năm trước cách đây
mục cha
commit
50134b5191
2 tập tin đã thay đổi với 10 bổ sung14 xóa
  1. 3 0
      Changelog-Trunk.txt
  2. 7 14
      src/map/atcommand.c

+ 3 - 0
Changelog-Trunk.txt

@@ -3,6 +3,9 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+2006/06/22
+	* Corrected autoloot so that you can specify rate with decimal precision
+	  ("@autoloot 0.01" should work) [Skotlex]
 2006/06/21
 	* [Removed]:
 	  - Redundant mob name copying. (it's already copied in mob_parse_dataset) [Lance]

+ 7 - 14
src/map/atcommand.c

@@ -7716,7 +7716,7 @@ atcommand_changeleader(
 int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* command, const char* message)
 {
 	// autoloot command with value
-	unsigned int rate;
+	int rate;
 
 	nullpo_retr(-1, sd);
 
@@ -7737,11 +7737,8 @@ int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* co
 		}
 	}
 
-	// autoloot command with value
-	//unsigned int rate; // Moved to top due to decleration error after executional block. [Zido]
-
 	// get maximum droprate limit
-	rate = atoi(message) * 100;
+	rate = (int)(atof(message) * 100);
 
 	// check for invalid value
 	if(rate > 10000)
@@ -7754,32 +7751,28 @@ int atcommand_autoloot(const int fd, struct map_session_data* sd, const char* co
 	if(rate == 0)
 	{
 		if(sd->state.autoloot == 0)
-		{
 			clif_displaymessage(fd, "Autoloot is already off.");
-			return 0;
-		} else {
+		else {
 			clif_displaymessage(fd, "Autoloot is now off.");
 			sd->state.autoloot = 0;
-			return 0;
 		}
+		return 0;
 	}
 
 	// autoloot value is 100, turn autoloot on
 	if(rate == 10000)
 	{
 		if(sd->state.autoloot == 10000)
-		{
 			clif_displaymessage(fd, "Autoloot is already on.");
-			return 0;
-		} else {
+		else {
 			clif_displaymessage(fd, "Autoloot is now on.");
 			sd->state.autoloot = 10000;
-			return 0;
 		}
+		return 0;
 	}
 
 	// autoloot value is between 0 and 100
-	snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %d percent and below.", (rate / 100));
+	snprintf(atcmd_output, sizeof atcmd_output, "Autolooting items with drop rates of %0.02f%% and below.", rate/100.);
 	clif_displaymessage(fd, atcmd_output);
 	sd->state.autoloot = rate;