Issue information

Issue ID
#5331
Status
Fixed
Severity
Low
Started
Hercules Elf Bot
Feb 14, 2012 4:26
Last Post
Hercules Elf Bot
Apr 19, 2012 18:27
Confirmation
N/A

Hercules Elf Bot - Feb 14, 2012 4:26

Originally posted by [b]Elven[/b]
Script commands -> strtolower
File path -> src/map/script.c

Found bugs in my npc scripts when i tried to use strtolower commands. Guess this problem apply to "strtoupper" too.
Not too sure with latest SVN.

Original code:
[CODE]
BUILDIN_FUNC(strtolower)
{
const char *str = script_getstr(st,2);
char *output;
int i = 0;

output = (char*)aMallocA(strlen(str) + 1);
while(str[i] != '\0') {
i = i + 1;
output[i] = TOLOWER(str[i]);
}
output[i] = '\0';
script_pushstr(st, output);
return 0;
}
[/CODE]

Could be some problem with the incrementation since the first letter display different letter, or character in game.
Can be solved using ToastofDoom code:

[CODE]
BUILDIN_FUNC(strtolower)
{
const char *str = script_getstr(st,2);
char *output;
int i = 0;

output = (char*)aMallocA(strlen(str) + 1);
while(str[i] != '\0')
output[i++] = TOLOWER(str[i]);
output[i] = '\0';
script_pushstr(st, output);
return 0;
}
[/CODE]

Hercules Elf Bot - Feb 14, 2012 14:49

Originally posted by [b]Gepard[/b]
Fixed in [rev=15580].

This post has been edited by Gepard on Feb 14, 2012 14:49