summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-11-25 12:12:34 -0200
committershennetsind <ind@henn.et>2013-11-25 12:12:34 -0200
commit659b0ebfe319d9f6697574f9eeff00808ec2d427 (patch)
tree3fc1da4b4497efd14564bc383285e8035d0dffa0 /src/map/atcommand.c
parent58a985ed43473f4c8d58345dca158739f2ba7195 (diff)
downloadhercules-659b0ebfe319d9f6697574f9eeff00808ec2d427.tar.gz
hercules-659b0ebfe319d9f6697574f9eeff00808ec2d427.tar.bz2
hercules-659b0ebfe319d9f6697574f9eeff00808ec2d427.tar.xz
hercules-659b0ebfe319d9f6697574f9eeff00808ec2d427.zip
Fixed txt_time (used by @time)
number of screwed up scenarios e.g. when day, hour and second are 0 but minute is not. Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 9f3d2f694..b18868b0c 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -4237,10 +4237,9 @@ ACMD(unloadnpc)
char* txt_time(unsigned int duration)
{
int days, hours, minutes, seconds;
- char temp[CHAT_SIZE_MAX];
static char temp1[CHAT_SIZE_MAX];
+ int tlen = 0;
- memset(temp, '\0', sizeof(temp));
memset(temp1, '\0', sizeof(temp1));
days = duration / (60 * 60 * 24);
@@ -4251,22 +4250,22 @@ char* txt_time(unsigned int duration)
seconds = duration - (60 * minutes);
if (days == 1)
- sprintf(temp, msg_txt(219), days); // %d day
+ tlen += sprintf(tlen + temp1, msg_txt(219), days); // %d day
else if (days > 1)
- sprintf(temp, msg_txt(220), days); // %d days
+ tlen += sprintf(tlen + temp1, msg_txt(220), days); // %d days
if (hours == 1)
- sprintf(temp1, msg_txt(221), temp, hours); // %s %d hour
+ tlen += sprintf(tlen + temp1, msg_txt(221), hours); // %d hour
else if (hours > 1)
- sprintf(temp1, msg_txt(222), temp, hours); // %s %d hours
+ tlen += sprintf(tlen + temp1, msg_txt(222), hours); // %d hours
if (minutes < 2)
- sprintf(temp, msg_txt(223), temp1, minutes); // %s %d minute
+ tlen += sprintf(tlen + temp1, msg_txt(223), minutes); // %d minute
else
- sprintf(temp, msg_txt(224), temp1, minutes); // %s %d minutes
+ tlen += sprintf(tlen + temp1, msg_txt(224), minutes); // %d minutes
if (seconds == 1)
- sprintf(temp1, msg_txt(225), temp, seconds); // %s and %d second
+ tlen += sprintf(tlen + temp1, msg_txt(225), seconds); // and %d second
else if (seconds > 1)
- sprintf(temp1, msg_txt(226), temp, seconds); // %s and %d seconds
-
+ tlen += sprintf(tlen + temp1, msg_txt(226), seconds); // and %d seconds
+
return temp1;
}