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:
Lemongrass3110
2020-01-13 14:44:48 +01:00
committed by GitHub
parent 3142863a13
commit e72c7360cf
41 changed files with 948 additions and 683 deletions

View File

@@ -178,7 +178,7 @@ void chlogif_prepsend_global_accreg(void) {
}
}
void chlogif_send_global_accreg(const char *key, unsigned int index, intptr_t val, bool is_string) {
void chlogif_send_global_accreg(const char *key, unsigned int index, int64 int_value, const char* string_value, bool is_string) {
int nlen = WFIFOW(login_fd, 2);
size_t len;
@@ -197,26 +197,25 @@ void chlogif_send_global_accreg(const char *key, unsigned int index, intptr_t va
nlen += 4;
if( is_string ) {
WFIFOB(login_fd, nlen) = val ? 2 : 3;
WFIFOB(login_fd, nlen) = string_value ? 2 : 3;
nlen += 1;
if( val ) {
char *sval = (char*)val;
len = strlen(sval)+1;
if( string_value ) {
len = strlen(string_value)+1;
WFIFOB(login_fd, nlen) = (unsigned char)len; // won't be higher; the column size is 254
nlen += 1;
safestrncpy(WFIFOCP(login_fd,nlen), sval, len);
safestrncpy(WFIFOCP(login_fd,nlen), string_value, len);
nlen += len;
}
} else {
WFIFOB(login_fd, nlen) = val ? 0 : 1;
WFIFOB(login_fd, nlen) = int_value ? 0 : 1;
nlen += 1;
if( val ) {
WFIFOL(login_fd, nlen) = (int)val;
nlen += 4;
if( int_value ) {
WFIFOQ(login_fd, nlen) = int_value;
nlen += 8;
}
}