From b560da5de159468ee9b28e95b939b443cdfe1108 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Fri, 3 Jul 2020 05:24:38 +0200 Subject: Prevent overflow when using gettimetick(0) --- src/map/script.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/map/script.c b/src/map/script.c index b49844320..75582d72f 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11272,7 +11272,8 @@ static BUILDIN(gettimetick) case 0: default: //type 0:(System Ticks) - script_pushint(st,(int)timer->gettick()); // TODO: change this to int64 when we'll support 64 bit script values + // Conjunction with INT_MAX is done to prevent overflow. (Script variables are signed integers.) + script_pushint(st, timer->gettick() & INT_MAX); // TODO: change this to int64 when we'll support 64 bit script values break; } return true; -- cgit v1.2.3-60-g2f50 From 45c296988f59b4030e5721c665e521378fd1e049 Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Fri, 3 Jul 2020 05:27:16 +0200 Subject: Update documentation of gettimetick(0)'s loop interval --- doc/script_commands.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index db37ef284..a48c9c78a 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -3626,7 +3626,7 @@ If the player is not found, returns -1. *gettimetick() Valid types are : - 0 - server's tick (milleseconds), unsigned int, loops every ~50 days + 0 - server's tick (milleseconds), unsigned int, loops every ~25 days 1 - time since the start of the current day in seconds 2 - UNIX epoch time (number of seconds elapsed since 1st of January 1970) -- cgit v1.2.3-60-g2f50