Fixed showdigit's start values (#1807)

Fixed #1769
This commit is contained in:
Lemongrass3110 2016-12-20 01:37:40 +01:00 committed by GitHub
parent 8492f6c35e
commit 1b634c8f42
2 changed files with 22 additions and 9 deletions

View File

@ -8136,11 +8136,9 @@ of the "clock" and can be one of the following values:
1 - Incremental counter (1 tick/second). 1 - Incremental counter (1 tick/second).
2 - Decremental counter (1 tick/second). Does not stop at zero, 2 - Decremental counter (1 tick/second). Does not stop at zero,
but overflows. but overflows.
3 - Decremental counter (1 tick/second). Two digits only, stops 3 - Decremental counter (2 ticks/second). Two digits only, stops
at zero. 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 Except for type 3 the value is interpreted as seconds and formatted
as time in days, hours, minutes and seconds. Note, that the official as time in days, hours, minutes and seconds. Note, that the official
script command does not have the optional parameter. 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 // displays 23:59:59 for 5 seconds
showdigit 86399; 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; showdigit 60,3;
--------------------------------------- ---------------------------------------

View File

@ -19729,15 +19729,30 @@ BUILDIN_FUNC(showdigit)
value = script_getnum(st,2); value = script_getnum(st,2);
if( script_hasdata(st,3) ) if( script_hasdata(st,3) ){
{
type = script_getnum(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); ShowError("buildin_showdigit: Invalid type %u.\n", type);
return SCRIPT_CMD_FAILURE; return SCRIPT_CMD_FAILURE;
}
} }
clif_showdigit(sd, (unsigned char)type, value); clif_showdigit(sd, (unsigned char)type, value);