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

@@ -76,7 +76,7 @@ struct pcrematch_set {
struct pcrematch_set* prev;
struct pcrematch_set* next;
struct pcrematch_entry* head;
int setid;
int64 setid;
};
/*
@@ -110,7 +110,7 @@ void finalize_pcrematch_entry(struct pcrematch_entry* e)
/**
* Lookup (and possibly create) a new set of patterns by the set id
*/
static struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid)
static struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int64 setid)
{
struct pcrematch_set *pcreset;
struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
@@ -151,7 +151,7 @@ static struct pcrematch_set* lookup_pcreset(struct npc_data* nd, int setid)
*
* if the setid does not exist, this will silently return
*/
static void activate_pcreset(struct npc_data* nd, int setid)
static void activate_pcreset(struct npc_data* nd, int64 setid)
{
struct pcrematch_set *pcreset;
struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
@@ -184,7 +184,7 @@ static void activate_pcreset(struct npc_data* nd, int setid)
*
* if the setid does not exist, this will silently return
*/
static void deactivate_pcreset(struct npc_data* nd, int setid)
static void deactivate_pcreset(struct npc_data* nd, int64 setid)
{
struct pcrematch_set *pcreset;
struct npc_parse *npcParse = (struct npc_parse *) nd->chatdb;
@@ -220,7 +220,7 @@ static void deactivate_pcreset(struct npc_data* nd, int setid)
/**
* delete a set of patterns.
*/
static void delete_pcreset(struct npc_data* nd, int setid)
static void delete_pcreset(struct npc_data* nd, int64 setid)
{
int active = 1;
struct pcrematch_set *pcreset;
@@ -300,7 +300,7 @@ static struct pcrematch_entry* create_pcrematch_entry(struct pcrematch_set* set)
/**
* define/compile a new pattern
*/
void npc_chat_def_pattern(struct npc_data* nd, int setid, const char* pattern, const char* label)
void npc_chat_def_pattern(struct npc_data* nd, int64 setid, const char* pattern, const char* label)
{
const char *err;
int erroff;
@@ -375,7 +375,7 @@ int npc_chat_sub(struct block_list* bl, va_list ap)
char var[255], val[255];
snprintf(var, sizeof(var), "$@p%i$", i);
pcre_copy_substring(msg, offsets, r, i, val, sizeof(val));
set_var(sd, var, val);
set_var_str( sd, var, val );
}
// find the target label.. this sucks..
@@ -400,7 +400,7 @@ int npc_chat_sub(struct block_list* bl, va_list ap)
int buildin_defpattern(struct script_state* st)
{
int setid = conv_num(st,& (st->stack->stack_data[st->start+2]));
int64 setid = conv_num64(st,& (st->stack->stack_data[st->start+2]));
const char* pattern = conv_str(st,& (st->stack->stack_data[st->start+3]));
const char* label = conv_str(st,& (st->stack->stack_data[st->start+4]));
struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
@@ -412,7 +412,7 @@ int buildin_defpattern(struct script_state* st)
int buildin_activatepset(struct script_state* st)
{
int setid = conv_num(st,& (st->stack->stack_data[st->start+2]));
int64 setid = conv_num64(st,& (st->stack->stack_data[st->start+2]));
struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
activate_pcreset(nd, setid);
@@ -422,7 +422,7 @@ int buildin_activatepset(struct script_state* st)
int buildin_deactivatepset(struct script_state* st)
{
int setid = conv_num(st,& (st->stack->stack_data[st->start+2]));
int64 setid = conv_num64(st,& (st->stack->stack_data[st->start+2]));
struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
deactivate_pcreset(nd, setid);
@@ -432,7 +432,7 @@ int buildin_deactivatepset(struct script_state* st)
int buildin_deletepset(struct script_state* st)
{
int setid = conv_num(st,& (st->stack->stack_data[st->start+2]));
int64 setid = conv_num64(st,& (st->stack->stack_data[st->start+2]));
struct npc_data* nd = (struct npc_data *)map_id2bl(st->oid);
delete_pcreset(nd, setid);