Browse Source

Fixed showdigit's start values (#1807)

Fixed #1769
Lemongrass3110 8 years ago
parent
commit
1b634c8f42
2 changed files with 22 additions and 9 deletions
  1. 2 4
      doc/script_commands.txt
  2. 20 5
      src/map/script.c

+ 2 - 4
doc/script_commands.txt

@@ -8136,11 +8136,9 @@ of the "clock" and can be one of the following values:
     1 - Incremental counter (1 tick/second).
     2 - Decremental counter (1 tick/second). Does not stop at zero,
         but overflows.
-    3 - Decremental counter (1 tick/second). Two digits only, stops
+    3 - Decremental counter (2 ticks/second). Two digits only, stops
         at zero.
 
-For type 1 and 2 the start value is set by using negative number of
-the one intended to set (ex. -10 starts the counter at 10 seconds).
 Except for type 3 the value is interpreted as seconds and formatted
 as time in days, hours, minutes and seconds. Note, that the official
 script command does not have the optional parameter.
@@ -8148,7 +8146,7 @@ script command does not have the optional parameter.
     // displays 23:59:59 for 5 seconds
     showdigit 86399;
 
-    // counter that starts at 60 and runs for 60 seconds
+    // counter that starts at 60 and runs for 30 seconds
     showdigit 60,3;
 
 ---------------------------------------

+ 20 - 5
src/map/script.c

@@ -19729,15 +19729,30 @@ BUILDIN_FUNC(showdigit)
 
 	value = script_getnum(st,2);
 
-	if( script_hasdata(st,3) )
-	{
+	if( script_hasdata(st,3) ){
 		type = script_getnum(st,3);
+	}
 
-		if( type > 3 )
-		{
+	switch( type ){
+		case 0:
+			break;
+		case 1:
+		case 2:
+			// Use absolute value and then the negative value of it as starting value
+			// This is what gravity's client does for these counters
+			value = -abs(value);
+			break;
+		case 3:
+			value = abs(value);
+			if( value > 99 ){
+				ShowWarning("buildin_showdigit: type 3 can display 2 digits at max. Capping value %d to 99...\n", value);
+				script_reportsrc(st);
+				value = 99;
+			}
+			break;
+		default:
 			ShowError("buildin_showdigit: Invalid type %u.\n", type);
 			return SCRIPT_CMD_FAILURE;
-		}
 	}
 
 	clif_showdigit(sd, (unsigned char)type, value);