Added int64 support to the script engine (#4522)
Added support for signed 64 bit integer value computation into the script engine. This is required because newer official features require support for bigger numbers inside the scripts. This also cleans up a lot of messy code and fixes a few issues like script stack corruptions. Thanks to @aleos89 and everyone who supported me with this.
This commit is contained in:
@@ -21098,16 +21098,20 @@ uint8 skill_split_atoi2(char *str, int *val, const char *delim, int min_value, u
|
||||
char *p = strtok(str, delim);
|
||||
|
||||
while (p != NULL) {
|
||||
int64 n_tmp;
|
||||
int n = min_value;
|
||||
|
||||
trim(p);
|
||||
|
||||
if (ISDIGIT(p[0])) // If using numeric
|
||||
n = atoi(p);
|
||||
else if (!script_get_constant(p, &n)) { // If using constant value
|
||||
ShowError("skill_split_atoi2: Invalid value: '%s'\n", p);
|
||||
p = strtok(NULL, delim);
|
||||
continue;
|
||||
else {
|
||||
if (!script_get_constant(p, &n_tmp)) { // If using constant value
|
||||
ShowError("skill_split_atoi2: Invalid value: '%s'\n", p);
|
||||
p = strtok(NULL, delim);
|
||||
continue;
|
||||
}
|
||||
n = static_cast<int>(n_tmp);
|
||||
}
|
||||
|
||||
if (n > min_value) {
|
||||
@@ -21799,6 +21803,7 @@ static bool skill_parse_row_changematerialdb(char* split[], int columns, int cur
|
||||
*/
|
||||
static bool skill_parse_row_skilldamage(char* split[], int columns, int current)
|
||||
{
|
||||
int64 caster_tmp;
|
||||
uint16 id = 0;
|
||||
int caster;
|
||||
|
||||
@@ -21815,10 +21820,11 @@ static bool skill_parse_row_skilldamage(char* split[], int columns, int current)
|
||||
if (ISDIGIT(split[1][0]))
|
||||
caster = atoi(split[1]);
|
||||
else { // Try to parse caster as constant
|
||||
if (!script_get_constant(split[1], &caster)) {
|
||||
if (!script_get_constant(split[1], &caster_tmp)) {
|
||||
ShowError("skill_parse_row_skilldamage: Invalid caster constant given for skill %d. Skipping.", id);
|
||||
return false;
|
||||
}
|
||||
caster = static_cast<int>(caster_tmp);
|
||||
}
|
||||
skill_db[id]->damage.caster |= caster;
|
||||
skill_db[id]->damage.map |= atoi(split[2]);
|
||||
|
||||
Reference in New Issue
Block a user