From 77e8fe5ff4dfcfb999904a610e66fb959f650658 Mon Sep 17 00:00:00 2001 From: skotlex Date: Thu, 22 Jun 2006 14:14:41 +0000 Subject: - Corrected autoloot so that you can specify rate with decimal precision ("@autoloot 0.01" should work) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@7294 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/atcommand.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'src/map/atcommand.c') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 13e2ccee5..943676876 100644 --- a/src/map/atcommand.c +++ b/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; -- cgit v1.2.3-60-g2f50