summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c803
1 files changed, 393 insertions, 410 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 9569e526d..d58e3780e 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -89,26 +89,6 @@ static inline void SETVALUE(unsigned char* buf, int i, int n)
buf[i+2] = GetByte(n, 2);
}
-// String buffer structures.
-// str_data stores string information
-static struct str_data_struct {
- enum c_op type;
- int str;
- int backpatch;
- int label;
- bool (*func)(struct script_state *st);
- int val;
- int next;
-} *str_data = NULL;
-static int str_data_size = 0; // size of the data
-static int str_num = LABEL_START; // next id to be assigned
-
-// str_buf holds the strings themselves
-static char *str_buf;
-static int str_size = 0; // size of the buffer
-static int str_pos = 0; // next position to be assigned
-
-
// Using a prime number for SCRIPT_HASH_SIZE should give better distributions
#define SCRIPT_HASH_SIZE 1021
int str_hash[SCRIPT_HASH_SIZE];
@@ -338,7 +318,7 @@ static void script_dump_stack(struct script_state* st)
break;
case C_NAME:
- ShowMessage(" \"%s\" (id=%d ref=%p subtype=%s)\n", reference_getname(data), data->u.num, data->ref, script_op2name(str_data[data->u.num].type));
+ ShowMessage(" \"%s\" (id=%d ref=%p subtype=%s)\n", reference_getname(data), data->u.num, data->ref, script_op2name(script->str_data[data->u.num].type));
break;
case C_RETINFO:
@@ -416,7 +396,7 @@ static void script_reportdata(struct script_data* data)
ShowDebug("Data: param name='%s' type=%d\n", reference_getname(data), reference_getparamtype(data));
} else {// ???
ShowDebug("Data: reference name='%s' type=%s\n", reference_getname(data), script_op2name(data->type));
- ShowDebug("Please report this!!! - str_data.type=%s\n", script_op2name(str_data[reference_getid(data)].type));
+ ShowDebug("Please report this!!! - script->str_data.type=%s\n", script_op2name(script->str_data[reference_getid(data)].type));
}
break;
case C_POS:// label
@@ -442,7 +422,7 @@ static void script_reportfunc(struct script_state* st)
data = script_getdata(st,0);
- if( !data_isreference(data) || str_data[reference_getid(data)].type != C_FUNC )
+ if( !data_isreference(data) || script->str_data[reference_getid(data)].type != C_FUNC )
{// script currently not executing a built-in function or corrupt stack
return;
}
@@ -526,14 +506,14 @@ static unsigned int calc_hash(const char* p)
/*==========================================
- * str_data manipulation functions
+ * script->str_data manipulation functions
*------------------------------------------*/
/// Looks up string using the provided id.
const char* get_str(int id)
{
- Assert( id >= LABEL_START && id < str_size );
- return str_buf+str_data[id].str;
+ Assert( id >= LABEL_START && id < script->str_size );
+ return script->str_buf+script->str_data[id].str;
}
/// Returns the uid of the string, or -1.
@@ -541,7 +521,7 @@ static int search_str(const char* p)
{
int i;
- for( i = str_hash[calc_hash(p)]; i != 0; i = str_data[i].next )
+ for( i = str_hash[calc_hash(p)]; i != 0; i = script->str_data[i].next )
if( strcasecmp(get_str(i),p) == 0 )
return i;
@@ -559,50 +539,50 @@ int add_str(const char* p)
if( str_hash[h] == 0 )
{// empty bucket, add new node here
- str_hash[h] = str_num;
+ str_hash[h] = script->str_num;
}
else
{// scan for end of list, or occurence of identical string
- for( i = str_hash[h]; ; i = str_data[i].next )
+ for( i = str_hash[h]; ; i = script->str_data[i].next )
{
if( strcasecmp(get_str(i),p) == 0 )
return i; // string already in list
- if( str_data[i].next == 0 )
+ if( script->str_data[i].next == 0 )
break; // reached the end
}
// append node to end of list
- str_data[i].next = str_num;
+ script->str_data[i].next = script->str_num;
}
// grow list if neccessary
- if( str_num >= str_data_size )
+ if( script->str_num >= script->str_data_size )
{
- str_data_size += 128;
- RECREATE(str_data,struct str_data_struct,str_data_size);
- memset(str_data + (str_data_size - 128), '\0', 128);
+ script->str_data_size += 128;
+ RECREATE(script->str_data,struct str_data_struct,script->str_data_size);
+ memset(script->str_data + (script->str_data_size - 128), '\0', 128);
}
len=(int)strlen(p);
// grow string buffer if neccessary
- while( str_pos+len+1 >= str_size )
+ while( script->str_pos+len+1 >= script->str_size )
{
- str_size += 256;
- RECREATE(str_buf,char,str_size);
- memset(str_buf + (str_size - 256), '\0', 256);
+ script->str_size += 256;
+ RECREATE(script->str_buf,char,script->str_size);
+ memset(script->str_buf + (script->str_size - 256), '\0', 256);
}
- safestrncpy(str_buf+str_pos, p, len+1);
- str_data[str_num].type = C_NOP;
- str_data[str_num].str = str_pos;
- str_data[str_num].next = 0;
- str_data[str_num].func = NULL;
- str_data[str_num].backpatch = -1;
- str_data[str_num].label = -1;
- str_pos += len+1;
+ safestrncpy(script->str_buf+script->str_pos, p, len+1);
+ script->str_data[script->str_num].type = C_NOP;
+ script->str_data[script->str_num].str = script->str_pos;
+ script->str_data[script->str_num].next = 0;
+ script->str_data[script->str_num].func = NULL;
+ script->str_data[script->str_num].backpatch = -1;
+ script->str_data[script->str_num].label = -1;
+ script->str_pos += len+1;
- return str_num++;
+ return script->str_num++;
}
@@ -646,35 +626,35 @@ static void add_scripti(int a)
add_scriptb(a|0x80);
}
-/// Appends a str_data object (label/function/variable/integer) to the script buffer.
+/// Appends a script->str_data object (label/function/variable/integer) to the script buffer.
///
-/// @param l The id of the str_data entry
+/// @param l The id of the script->str_data entry
// Maximum up to 16M
static void add_scriptl(int l)
{
- int backpatch = str_data[l].backpatch;
+ int backpatch = script->str_data[l].backpatch;
- switch(str_data[l].type){
+ switch(script->str_data[l].type){
case C_POS:
case C_USERFUNC_POS:
add_scriptc(C_POS);
- add_scriptb(str_data[l].label);
- add_scriptb(str_data[l].label>>8);
- add_scriptb(str_data[l].label>>16);
+ add_scriptb(script->str_data[l].label);
+ add_scriptb(script->str_data[l].label>>8);
+ add_scriptb(script->str_data[l].label>>16);
break;
case C_NOP:
case C_USERFUNC:
// Embedded data backpatch there is a possibility of label
add_scriptc(C_NAME);
- str_data[l].backpatch = script_pos;
+ script->str_data[l].backpatch = script_pos;
add_scriptb(backpatch);
add_scriptb(backpatch>>8);
add_scriptb(backpatch>>16);
break;
case C_INT:
- add_scripti(abs(str_data[l].val));
- if( str_data[l].val < 0 ) //Notice that this is negative, from jA (Rayce)
+ add_scripti(abs(script->str_data[l].val));
+ if( script->str_data[l].val < 0 ) //Notice that this is negative, from jA (Rayce)
add_scriptc(C_NEG);
break;
default: // assume C_NAME
@@ -693,20 +673,20 @@ void set_label(int l,int pos, const char* script_pos)
{
int i,next;
- if(str_data[l].type==C_INT || str_data[l].type==C_PARAM || str_data[l].type==C_FUNC)
+ if(script->str_data[l].type==C_INT || script->str_data[l].type==C_PARAM || script->str_data[l].type==C_FUNC)
{ //Prevent overwriting constants values, parameters and built-in functions [Skotlex]
disp_error_message("set_label: invalid label name",script_pos);
return;
}
- if(str_data[l].label!=-1){
+ if(script->str_data[l].label!=-1){
disp_error_message("set_label: dup label ",script_pos);
return;
}
- str_data[l].type=(str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS);
- str_data[l].label=pos;
- for(i=str_data[l].backpatch;i>=0 && i!=0x00ffffff;){
+ script->str_data[l].type=(script->str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS);
+ script->str_data[l].label=pos;
+ for(i=script->str_data[l].backpatch;i>=0 && i!=0x00ffffff;){
next=GETVALUE(script_buf,i);
- script_buf[i-1]=(str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS);
+ script_buf[i-1]=(script->str_data[l].type == C_USERFUNC ? C_USERFUNC_POS : C_POS);
SETVALUE(script_buf,i,pos);
i=next;
}
@@ -748,7 +728,7 @@ const char* skip_space(const char* p)
}
/// Skips a word.
-/// A word consists of undercores and/or alfanumeric characters,
+/// A word consists of undercores and/or alphanumeric characters,
/// and valid variable prefixes/postfixes.
static
const char* skip_word(const char* p)
@@ -778,7 +758,7 @@ const char* skip_word(const char* p)
return p;
}
-/// Adds a word to str_data.
+/// Adds a word to script->str_data.
/// @see skip_word
/// @see add_str
static
@@ -791,7 +771,7 @@ int add_word(const char* p)
// Check for a word
len = skip_word(p) - p;
if( len == 0 )
- disp_error_message("script:add_word: invalid word. A word consists of undercores and/or alfanumeric characters, and valid variable prefixes/postfixes.", p);
+ disp_error_message("script:add_word: invalid word. A word consists of undercores and/or alphanumeric characters, and valid variable prefixes/postfixes.", p);
// Duplicate the word
word = (char*)aMalloc(len+1);
@@ -815,21 +795,21 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom)
int func;
func = add_word(p);
- if( str_data[func].type == C_FUNC ){
+ if( script->str_data[func].type == C_FUNC ){
char argT = 0;
// buildin function
add_scriptl(func);
add_scriptc(C_ARG);
- arg = script->buildin[str_data[func].val];
+ arg = script->buildin[script->str_data[func].val];
if( !arg ) arg = &argT;
- } else if( str_data[func].type == C_USERFUNC || str_data[func].type == C_USERFUNC_POS ){
+ } else if( script->str_data[func].type == C_USERFUNC || script->str_data[func].type == C_USERFUNC_POS ){
// script defined function
add_scriptl(buildin_callsub_ref);
add_scriptc(C_ARG);
add_scriptl(func);
- arg = script->buildin[str_data[buildin_callsub_ref].val];
+ arg = script->buildin[script->str_data[buildin_callsub_ref].val];
if( *arg == 0 )
- disp_error_message("parse_callfunc: callsub has no arguments, please review it's definition",p);
+ disp_error_message("parse_callfunc: callsub has no arguments, please review its definition",p);
if( *arg != '*' )
++arg; // count func as argument
} else {
@@ -845,7 +825,7 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom)
add_scriptc(C_STR);
while( *name ) add_scriptb(*name ++);
add_scriptb(0);
- arg = script->buildin[str_data[buildin_callfunc_ref].val];
+ arg = script->buildin[script->str_data[buildin_callfunc_ref].val];
if( *arg != '*' ) ++ arg;
}
#endif
@@ -918,9 +898,9 @@ static void parse_nextline(bool first, const char* p)
}
// initialize data for new '-' label fix up scheduling
- str_data[LABEL_NEXTLINE].type = C_NOP;
- str_data[LABEL_NEXTLINE].backpatch = -1;
- str_data[LABEL_NEXTLINE].label = -1;
+ script->str_data[LABEL_NEXTLINE].type = C_NOP;
+ script->str_data[LABEL_NEXTLINE].backpatch = -1;
+ script->str_data[LABEL_NEXTLINE].label = -1;
}
/// Parse a variable assignment using the direct equals operator
@@ -1007,7 +987,7 @@ const char* parse_variable(const char* p) {
// parse the variable currently being modified
word = add_word(var);
- if( str_data[word].type == C_FUNC || str_data[word].type == C_USERFUNC || str_data[word].type == C_USERFUNC_POS )
+ if( script->str_data[word].type == C_FUNC || script->str_data[word].type == C_USERFUNC || script->str_data[word].type == C_USERFUNC_POS )
{// cannot assign a variable which exists as a function or label
disp_error_message("Cannot modify a variable which has the same name as a function or label.", p);
}
@@ -1069,7 +1049,7 @@ const char* parse_simpleexpr(const char *p)
p=skip_space(p);
if(*p==';' || *p==',')
- disp_error_message("parse_simpleexpr: unexpected expr end",p);
+ disp_error_message("parse_simpleexpr: unexpected end of expression",p);
if(*p=='('){
if( (i=syntax.curly_count-1) >= 0 && syntax.curly[i].type == TYPE_ARGLIST )
++syntax.curly[i].count;
@@ -1085,7 +1065,7 @@ const char* parse_simpleexpr(const char *p)
syntax.curly[i].flag = ARGLIST_NO_PAREN;
}
if( *p != ')' )
- disp_error_message("parse_simpleexpr: unmatch ')'",p);
+ disp_error_message("parse_simpleexpr: unmatched ')'",p);
++p;
} else if(ISDIGIT(*p) || ((*p=='-' || *p=='+') && ISDIGIT(p[1]))){
char *np;
@@ -1111,7 +1091,7 @@ const char* parse_simpleexpr(const char *p)
add_scriptb(*p++);
}
if(!*p)
- disp_error_message("parse_simpleexpr: unexpected eof @ string",p);
+ disp_error_message("parse_simpleexpr: unexpected end of file @ string",p);
add_scriptb(0);
p++; //'"'
} else {
@@ -1123,7 +1103,7 @@ const char* parse_simpleexpr(const char *p)
disp_error_message("parse_simpleexpr: unexpected character",p);
l=add_word(p);
- if( str_data[l].type == C_FUNC || str_data[l].type == C_USERFUNC || str_data[l].type == C_USERFUNC_POS)
+ if( script->str_data[l].type == C_FUNC || script->str_data[l].type == C_USERFUNC || script->str_data[l].type == C_USERFUNC_POS)
return parse_callfunc(p,1,0);
#ifdef SCRIPT_CALLFUNC_CHECK
else {
@@ -1149,7 +1129,7 @@ const char* parse_simpleexpr(const char *p)
p=parse_subexpr(p+1,-1);
p=skip_space(p);
if( *p != ']' )
- disp_error_message("parse_simpleexpr: unmatch ']'",p);
+ disp_error_message("parse_simpleexpr: unmatched ']'",p);
++p;
add_scriptc(C_FUNC);
}else
@@ -1350,8 +1330,8 @@ const char* parse_curly_close(const char* p)
}
// Syntax-related processing
-// break, case, continue, default, do, for, function,
-// if, switch, while ? will handle this internally.
+// break, case, continue, default, do, for, function,
+// if, switch, while ? will handle this internally.
const char* parse_syntax(const char* p)
{
const char *p2 = skip_word(p);
@@ -1431,14 +1411,14 @@ const char* parse_syntax(const char* p)
memcpy(label,p,v);
label[v]='\0';
if( !script_get_constant(label, &v) )
- disp_error_message("parse_syntax: 'case' label not integer",p);
+ disp_error_message("parse_syntax: 'case' label is not an integer",p);
p = skip_word(p);
} else { //Numeric value
if((*p == '-' || *p == '+') && ISDIGIT(p[1])) // pre-skip because '-' can not skip_word
p++;
p = skip_word(p);
if(np != p)
- disp_error_message("parse_syntax: 'case' label not integer",np);
+ disp_error_message("parse_syntax: 'case' label is not an integer",np);
}
p = skip_space(p);
if(*p != ':')
@@ -1646,9 +1626,9 @@ const char* parse_syntax(const char* p)
// function declaration - just register the name
int l;
l = add_word(func_name);
- if( str_data[l].type == C_NOP )// register only, if the name was not used by something else
- str_data[l].type = C_USERFUNC;
- else if( str_data[l].type == C_USERFUNC )
+ if( script->str_data[l].type == C_NOP )// register only, if the name was not used by something else
+ script->str_data[l].type = C_USERFUNC;
+ else if( script->str_data[l].type == C_USERFUNC )
; // already registered
else
disp_error_message("parse_syntax:function: function name is invalid", func_name);
@@ -1677,9 +1657,9 @@ const char* parse_syntax(const char* p)
// Set the position of the function (label)
l=add_word(func_name);
- if( str_data[l].type == C_NOP || str_data[l].type == C_USERFUNC )// register only, if the name was not used by something else
+ if( script->str_data[l].type == C_NOP || script->str_data[l].type == C_USERFUNC )// register only, if the name was not used by something else
{
- str_data[l].type = C_USERFUNC;
+ script->str_data[l].type = C_USERFUNC;
set_label(l, script_pos, p);
if( parse_options&SCRIPT_USE_LABEL_DB )
strdb_iput(scriptlabel_db, get_str(l), script_pos);
@@ -1974,11 +1954,11 @@ bool script_get_constant(const char* name, int* value)
{
int n = search_str(name);
- if( n == -1 || str_data[n].type != C_INT )
+ if( n == -1 || script->str_data[n].type != C_INT )
{// not found or not a constant
return false;
}
- value[0] = str_data[n].val;
+ value[0] = script->str_data[n].val;
return true;
}
@@ -1988,18 +1968,18 @@ void script_set_constant(const char* name, int value, bool isparameter)
{
int n = add_str(name);
- if( str_data[n].type == C_NOP )
+ if( script->str_data[n].type == C_NOP )
{// new
- str_data[n].type = isparameter ? C_PARAM : C_INT;
- str_data[n].val = value;
+ script->str_data[n].type = isparameter ? C_PARAM : C_INT;
+ script->str_data[n].val = value;
}
- else if( str_data[n].type == C_PARAM || str_data[n].type == C_INT )
+ else if( script->str_data[n].type == C_PARAM || script->str_data[n].type == C_INT )
{// existing parameter or constant
- ShowError("script_set_constant: Attempted to overwrite existing %s '%s' (old value=%d, new value=%d).\n", ( str_data[n].type == C_PARAM ) ? "parameter" : "constant", name, str_data[n].val, value);
+ ShowError("script_set_constant: Attempted to overwrite existing %s '%s' (old value=%d, new value=%d).\n", ( script->str_data[n].type == C_PARAM ) ? "parameter" : "constant", name, script->str_data[n].val, value);
}
else
{// existing name
- ShowError("script_set_constant: Invalid name for %s '%s' (already defined as %s).\n", isparameter ? "parameter" : "constant", name, script_op2name(str_data[n].type));
+ ShowError("script_set_constant: Invalid name for %s '%s' (already defined as %s).\n", isparameter ? "parameter" : "constant", name, script_op2name(script->str_data[n].type));
}
}
@@ -2126,8 +2106,8 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
script_pos = 0;
script_size = 0;
script_buf = NULL;
- for(i=LABEL_START;i<str_num;i++)
- if(str_data[i].type == C_NOP) str_data[i].type = C_NAME;
+ for(i=LABEL_START;i<script->str_num;i++)
+ if(script->str_data[i].type == C_NOP) script->str_data[i].type = C_NAME;
for(i=0; i<size; i++)
linkdb_final(&syntax.curly[i].case_label);
return NULL;
@@ -2165,14 +2145,14 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
}
// clear references of labels, variables and internal functions
- for(i=LABEL_START;i<str_num;i++){
+ for(i=LABEL_START;i<script->str_num;i++){
if(
- str_data[i].type==C_POS || str_data[i].type==C_NAME ||
- str_data[i].type==C_USERFUNC || str_data[i].type == C_USERFUNC_POS
+ script->str_data[i].type==C_POS || script->str_data[i].type==C_NAME ||
+ script->str_data[i].type==C_USERFUNC || script->str_data[i].type == C_USERFUNC_POS
){
- str_data[i].type=C_NOP;
- str_data[i].backpatch=-1;
- str_data[i].label=-1;
+ script->str_data[i].type=C_NOP;
+ script->str_data[i].backpatch=-1;
+ script->str_data[i].label=-1;
}
}
@@ -2206,20 +2186,20 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o
RECREATE(script_buf,unsigned char,script_pos);
// default unknown references to variables
- for(i=LABEL_START;i<str_num;i++){
- if(str_data[i].type==C_NOP){
+ for(i=LABEL_START;i<script->str_num;i++){
+ if(script->str_data[i].type==C_NOP){
int j,next;
- str_data[i].type=C_NAME;
- str_data[i].label=i;
- for(j=str_data[i].backpatch;j>=0 && j!=0x00ffffff;){
+ script->str_data[i].type=C_NAME;
+ script->str_data[i].label=i;
+ for(j=script->str_data[i].backpatch;j>=0 && j!=0x00ffffff;){
next=GETVALUE(script_buf,j);
SETVALUE(script_buf,j,i);
j=next;
}
}
- else if( str_data[i].type == C_USERFUNC )
+ else if( script->str_data[i].type == C_USERFUNC )
{// 'function name;' without follow-up code
- ShowError("parse_script: function '%s' declared but not defined.\n", str_buf+str_data[i].str);
+ ShowError("parse_script: function '%s' declared but not defined.\n", script->str_buf+script->str_data[i].str);
unresolved_names = true;
}
}
@@ -2315,13 +2295,13 @@ void get_val(struct script_state* st, struct script_data* data)
{// needs player attached
if( postfix == '$' )
{// string variable
- ShowWarning("script:get_val: cannot access player variable '%s', defaulting to \"\"\n", name);
+ ShowWarning("script:script->get_val: cannot access player variable '%s', defaulting to \"\"\n", name);
data->type = C_CONSTSTR;
data->u.str = "";
}
else
{// integer variable
- ShowWarning("script:get_val: cannot access player variable '%s', defaulting to 0\n", name);
+ ShowWarning("script:script->get_val: cannot access player variable '%s', defaulting to 0\n", name);
data->type = C_INT;
data->u.num = 0;
}
@@ -2335,7 +2315,7 @@ void get_val(struct script_state* st, struct script_data* data)
switch( prefix )
{
case '@':
- data->u.str = iPc->readregstr(sd, data->u.num);
+ data->u.str = pc->readregstr(sd, data->u.num);
break;
case '$':
data->u.str = mapreg_readregstr(data->u.num);
@@ -2362,7 +2342,7 @@ void get_val(struct script_state* st, struct script_data* data)
if ( st->instance_id >= 0 ) {
data->u.str = (char*)idb_get(instances[st->instance_id].vars,reference_getuid(data));
} else {
- ShowWarning("script:get_val: cannot access instance variable '%s', defaulting to \"\"\n", name);
+ ShowWarning("script:script->get_val: cannot access instance variable '%s', defaulting to \"\"\n", name);
data->u.str = NULL;
}
break;
@@ -2394,13 +2374,13 @@ void get_val(struct script_state* st, struct script_data* data)
}
else if( reference_toparam(data) )
{
- data->u.num = iPc->readparam(sd, reference_getparamtype(data));
+ data->u.num = pc->readparam(sd, reference_getparamtype(data));
}
else
switch( prefix )
{
case '@':
- data->u.num = iPc->readreg(sd, data->u.num);
+ data->u.num = pc->readreg(sd, data->u.num);
break;
case '$':
data->u.num = mapreg_readreg(data->u.num);
@@ -2427,7 +2407,7 @@ void get_val(struct script_state* st, struct script_data* data)
if( st->instance_id >= 0 )
data->u.num = (int)idb_iget(instances[st->instance_id].vars,reference_getuid(data));
else {
- ShowWarning("script:get_val: cannot access instance variable '%s', defaulting to 0\n", name);
+ ShowWarning("script:script->get_val: cannot access instance variable '%s', defaulting to 0\n", name);
data->u.num = 0;
}
break;
@@ -2441,16 +2421,13 @@ void get_val(struct script_state* st, struct script_data* data)
return;
}
-struct script_data* push_val2(struct script_stack* stack, enum c_op type, int val, struct DBMap** ref);
-
/// Retrieves the value of a reference identified by uid (variable, constant, param)
/// The value is left in the top of the stack and needs to be removed manually.
-void* get_val2(struct script_state* st, int uid, struct DBMap** ref)
-{
+void* get_val2(struct script_state* st, int uid, struct DBMap** ref) {
struct script_data* data;
- push_val2(st->stack, C_NAME, uid, ref);
+ script->push_val(st->stack, C_NAME, uid, ref);
data = script_getdatatop(st, -1);
- get_val(st, data);
+ script->get_val(st, data);
return (data->type == C_INT ? (void*)__64BPTRSIZE(data->u.num) : (void*)__64BPTRSIZE(data->u.str));
}
@@ -2467,7 +2444,7 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
const char* str = (const char*)value;
switch (prefix) {
case '@':
- return iPc->setregstr(sd, num, str);
+ return pc->setregstr(sd, num, str);
case '$':
return mapreg_setregstr(num, str);
case '#':
@@ -2497,9 +2474,9 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
else
{// integer variable
int val = (int)__64BPTRSIZE(value);
- if(str_data[num&0x00ffffff].type == C_PARAM)
+ if(script->str_data[num&0x00ffffff].type == C_PARAM)
{
- if( iPc->setparam(sd, str_data[num&0x00ffffff].val, val) == 0 )
+ if( pc->setparam(sd, script->str_data[num&0x00ffffff].val, val) == 0 )
{
if( st != NULL )
{
@@ -2514,7 +2491,7 @@ static int set_reg(struct script_state* st, TBL_PC* sd, int num, const char* nam
switch (prefix) {
case '@':
- return iPc->setreg(sd, num, val);
+ return pc->setreg(sd, num, val);
case '$':
return mapreg_setreg(num, val);
case '#':
@@ -2560,7 +2537,7 @@ const char* conv_str(struct script_state* st, struct script_data* data)
{
char* p;
- get_val(st, data);
+ script->get_val(st, data);
if( data_isstring(data) )
{// nothing to convert
}
@@ -2574,7 +2551,7 @@ const char* conv_str(struct script_state* st, struct script_data* data)
}
else if( data_isreference(data) )
{// reference -> string
- //##TODO when does this happen (check get_val) [FlavioJS]
+ //##TODO when does this happen (check script->get_val) [FlavioJS]
data->type = C_CONSTSTR;
data->u.str = reference_getname(data);
}
@@ -2594,7 +2571,7 @@ int conv_num(struct script_state* st, struct script_data* data) {
char* p;
long num;
- get_val(st, data);
+ script->get_val(st, data);
if( data_isint(data) )
{// nothing to convert
}
@@ -2649,8 +2626,7 @@ int conv_num(struct script_state* st, struct script_data* data) {
//
/// Increases the size of the stack
-void stack_expand(struct script_stack* stack)
-{
+void stack_expand(struct script_stack* stack) {
stack->sp_max += 64;
stack->stack_data = (struct script_data*)aRealloc(stack->stack_data,
stack->sp_max * sizeof(stack->stack_data[0]) );
@@ -2658,12 +2634,8 @@ void stack_expand(struct script_stack* stack)
64 * sizeof(stack->stack_data[0]) );
}
-/// Pushes a value into the stack
-#define push_val(stack,type,val) push_val2(stack, type, val, NULL)
-
/// Pushes a value into the stack (with reference)
-struct script_data* push_val2(struct script_stack* stack, enum c_op type, int val, struct DBMap** ref)
-{
+struct script_data* push_val(struct script_stack* stack, enum c_op type, int val, struct DBMap** ref) {
if( stack->sp >= stack->sp_max )
stack_expand(stack);
stack->stack_data[stack->sp].type = type;
@@ -2698,28 +2670,26 @@ struct script_data* push_retinfo(struct script_stack* stack, struct script_retin
}
/// Pushes a copy of the target position into the stack
-struct script_data* push_copy(struct script_stack* stack, int pos)
-{
- switch( stack->stack_data[pos].type )
- {
- case C_CONSTSTR:
- return push_str(stack, C_CONSTSTR, stack->stack_data[pos].u.str);
- break;
- case C_STR:
- return push_str(stack, C_STR, aStrdup(stack->stack_data[pos].u.str));
- break;
- case C_RETINFO:
- ShowFatalError("script:push_copy: can't create copies of C_RETINFO. Exiting...\n");
- exit(1);
- break;
- default:
- return push_val2(
- stack,stack->stack_data[pos].type,
- stack->stack_data[pos].u.num,
- stack->stack_data[pos].ref
- );
- break;
- }
+struct script_data* push_copy(struct script_stack* stack, int pos) {
+ switch( stack->stack_data[pos].type ) {
+ case C_CONSTSTR:
+ return script->push_str(stack, C_CONSTSTR, stack->stack_data[pos].u.str);
+ break;
+ case C_STR:
+ return script->push_str(stack, C_STR, aStrdup(stack->stack_data[pos].u.str));
+ break;
+ case C_RETINFO:
+ ShowFatalError("script:push_copy: can't create copies of C_RETINFO. Exiting...\n");
+ exit(1);
+ break;
+ default:
+ return script->push_val(
+ stack,stack->stack_data[pos].type,
+ stack->stack_data[pos].u.num,
+ stack->stack_data[pos].ref
+ );
+ break;
+ }
}
/// Removes the values in indexes [start,end[ from the stack.
@@ -2833,7 +2803,7 @@ void script_free_state(struct script_state* st)
if( st->sleep.timer != INVALID_TIMER )
iTimer->delete_timer(st->sleep.timer, run_script_timer);
script_free_vars(st->stack->var_function);
- pop_stack(st, 0, st->stack->sp);
+ script->pop_stack(st, 0, st->stack->sp);
aFree(st->stack->stack_data);
aFree(st->stack);
st->stack = NULL;
@@ -2883,7 +2853,7 @@ int pop_val(struct script_state* st)
if(st->stack->sp<=0)
return 0;
st->stack->sp--;
- get_val(st,&(st->stack->stack_data[st->stack->sp]));
+ script->get_val(st,&(st->stack->stack_data[st->stack->sp]));
if(st->stack->stack_data[st->stack->sp].type==C_INT)
return st->stack->stack_data[st->stack->sp].u.num;
return 0;
@@ -2897,7 +2867,7 @@ void op_3(struct script_state* st, int op)
int flag = 0;
data = script_getdatatop(st, -3);
- get_val(st, data);
+ script->get_val(st, data);
if( data_isstring(data) )
flag = data->u.str[0];// "" -> false
@@ -3041,8 +3011,8 @@ void op_2(struct script_state *st, int op)
st->op2ref = 0;
}
- get_val(st, left);
- get_val(st, right);
+ script->get_val(st, left);
+ script->get_val(st, right);
// automatic conversions
switch( op )
@@ -3103,7 +3073,7 @@ void op_1(struct script_state* st, int op)
int i1;
data = script_getdatatop(st, -1);
- get_val(st, data);
+ script->get_val(st, data);
if( !data_isint(data) )
{// not a number
@@ -3141,7 +3111,7 @@ static void script_check_buildin_argtype(struct script_state* st, int func)
{
char type;
int idx, invalid = 0;
- char* sf = script->buildin[str_data[func].val];
+ char* sf = script->buildin[script->str_data[func].val];
for( idx = 2; script_hasdata(st, idx); idx++ ) {
struct script_data* data = script_getdata(st, idx);
@@ -3237,7 +3207,7 @@ int run_func(struct script_state *st)
st->end = end_sp;
data = &st->stack->stack_data[st->start];
- if( data->type == C_NAME && str_data[data->u.num].type == C_FUNC )
+ if( data->type == C_NAME && script->str_data[data->u.num].type == C_FUNC )
func = data->u.num;
else
{
@@ -3253,11 +3223,11 @@ int run_func(struct script_state *st)
script_check_buildin_argtype(st, func);
}
- if(str_data[func].func){
- if (!(str_data[func].func(st))) //Report error
+ if(script->str_data[func].func){
+ if (!(script->str_data[func].func(st))) //Report error
script_reportsrc(st);
} else {
- ShowError("script:run_func: '%s' (id=%d type=%s) has no C function. please report this!!!\n", get_str(func), func, script_op2name(str_data[func].type));
+ ShowError("script:run_func: '%s' (id=%d type=%s) has no C function. please report this!!!\n", get_str(func), func, script_op2name(script->str_data[func].type));
script_reportsrc(st);
st->state = END;
}
@@ -3266,14 +3236,14 @@ int run_func(struct script_state *st)
if( st->state == RERUNLINE )
return 0;
- pop_stack(st, st->start, st->end);
+ script->pop_stack(st, st->start, st->end);
if( st->state == RETFUNC )
{// return from a user-defined function
struct script_retinfo* ri;
int olddefsp = st->stack->defsp;
int nargs;
- pop_stack(st, st->stack->defsp, st->start);// pop distractions from the stack
+ script->pop_stack(st, st->stack->defsp, st->start);// pop distractions from the stack
if( st->stack->defsp < 1 || st->stack->stack_data[st->stack->defsp-1].type != C_RETINFO )
{
ShowWarning("script:run_func: return without callfunc or callsub!\n");
@@ -3291,7 +3261,7 @@ int run_func(struct script_state *st)
st->stack->defsp = ri->defsp;
memset(ri, 0, sizeof(struct script_retinfo));
- pop_stack(st, olddefsp-nargs-1, olddefsp);// pop arguments and retinfo
+ script->pop_stack(st, olddefsp-nargs-1, olddefsp);// pop arguments and retinfo
st->state = GOTO;
}
@@ -3482,21 +3452,21 @@ void run_script_main(struct script_state *st)
if( stack->defsp > stack->sp )
ShowError("script:run_script_main: unexpected stack position (defsp=%d sp=%d). please report this!!!\n", stack->defsp, stack->sp);
else
- pop_stack(st, stack->defsp, stack->sp);// pop unused stack data. (unused return value)
+ script->pop_stack(st, stack->defsp, stack->sp);// pop unused stack data. (unused return value)
break;
case C_INT:
- push_val(stack,C_INT,get_num(st->script->script_buf,&st->pos));
+ script->push_val(stack,C_INT,get_num(st->script->script_buf,&st->pos),NULL);
break;
case C_POS:
case C_NAME:
- push_val(stack,c,GETVALUE(st->script->script_buf,st->pos));
+ script->push_val(stack,c,GETVALUE(st->script->script_buf,st->pos),NULL);
st->pos+=3;
break;
case C_ARG:
- push_val(stack,c,0);
+ script->push_val(stack,c,0,NULL);
break;
case C_STR:
- push_str(stack,C_CONSTSTR,(char*)(st->script->script_buf+st->pos));
+ script->push_str(stack,C_CONSTSTR,(char*)(st->script->script_buf+st->pos));
while(st->script->script_buf[st->pos++]);
break;
case C_FUNC:
@@ -3659,7 +3629,7 @@ int script_config_read(char *cfgName)
*/
static int db_script_free_code_sub(DBKey key, DBData *data, va_list ap)
{
- struct script_code *code = iDB->data2ptr(data);
+ struct script_code *code = DB->data2ptr(data);
if (code)
script_free_code(code);
return 0;
@@ -3706,14 +3676,14 @@ void script_cleararray_pc(struct map_session_data* sd, const char* varname, void
{
for( idx = 0; idx < SCRIPT_MAX_ARRAYSIZE; idx++ )
{
- iPc->setregstr(sd, reference_uid(key, idx), (const char*)value);
+ pc->setregstr(sd, reference_uid(key, idx), (const char*)value);
}
}
else
{
for( idx = 0; idx < SCRIPT_MAX_ARRAYSIZE; idx++ )
{
- iPc->setreg(sd, reference_uid(key, idx), (int)__64BPTRSIZE(value));
+ pc->setreg(sd, reference_uid(key, idx), (int)__64BPTRSIZE(value));
}
}
}
@@ -3741,11 +3711,11 @@ void script_setarray_pc(struct map_session_data* sd, const char* varname, uint8
if( is_string_variable(varname) )
{
- iPc->setregstr(sd, reference_uid(key, idx), (const char*)value);
+ pc->setregstr(sd, reference_uid(key, idx), (const char*)value);
}
else
{
- iPc->setreg(sd, reference_uid(key, idx), (int)__64BPTRSIZE(value));
+ pc->setreg(sd, reference_uid(key, idx), (int)__64BPTRSIZE(value));
}
if( refcache )
@@ -3774,7 +3744,7 @@ void do_final_script(void) {
memset(count, 0, sizeof(count));
fprintf(fp,"num : hash : data_name\n");
fprintf(fp,"---------------------------------------------------------------\n");
- for(i=LABEL_START; i<str_num; i++) {
+ for(i=LABEL_START; i<script->str_num; i++) {
unsigned int h = calc_hash(get_str(i));
fprintf(fp,"%04d : %4u : %s\n",i,h, get_str(i));
++count[h];
@@ -3828,10 +3798,10 @@ void do_final_script(void) {
linkdb_final(&sleep_db);
}
- if (str_data)
- aFree(str_data);
- if (str_buf)
- aFree(str_buf);
+ if (script->str_data)
+ aFree(script->str_data);
+ if (script->str_buf)
+ aFree(script->str_buf);
for( i = 0; i < atcommand->binding_count; i++ ) {
aFree(atcommand->binding[i]);
@@ -4159,7 +4129,7 @@ BUILDIN(menu)
st->state = END;
return false;
}
- iPc->setreg(sd, add_str("@menu"), menu);
+ pc->setreg(sd, add_str("@menu"), menu);
st->pos = script_getnum(st, i + 1);
st->state = GOTO;
}
@@ -4236,7 +4206,7 @@ BUILDIN(select)
if( sd->npc_menu <= 0 )
break;// entry found
}
- iPc->setreg(sd, add_str("@menu"), menu);
+ pc->setreg(sd, add_str("@menu"), menu);
script_pushint(st, menu);
st->state = RUN;
}
@@ -4307,7 +4277,7 @@ BUILDIN(prompt)
else if( sd->npc_menu == 0xff )
{// Cancel was pressed
sd->state.menu_or_input = 0;
- iPc->setreg(sd, add_str("@menu"), 0xff);
+ pc->setreg(sd, add_str("@menu"), 0xff);
script_pushint(st, 0xff);
st->state = RUN;
}
@@ -4323,7 +4293,7 @@ BUILDIN(prompt)
if( sd->npc_menu <= 0 )
break;// entry found
}
- iPc->setreg(sd, add_str("@menu"), menu);
+ pc->setreg(sd, add_str("@menu"), menu);
script_pushint(st, menu);
st->state = RUN;
}
@@ -4373,7 +4343,7 @@ BUILDIN(callfunc)
for( i = st->start+3, j = 0; i < st->end; i++, j++ )
{
- struct script_data* data = push_copy(st->stack,i);
+ struct script_data* data = script->push_copy(st->stack,i);
if( data_isreference(data) && !data->ref )
{
const char* name = reference_getname(data);
@@ -4421,7 +4391,7 @@ BUILDIN(callsub)
for( i = st->start+3, j = 0; i < st->end; i++, j++ )
{
- struct script_data* data = push_copy(st->stack,i);
+ struct script_data* data = script->push_copy(st->stack,i);
if( data_isreference(data) && !data->ref )
{
const char* name = reference_getname(data);
@@ -4471,7 +4441,7 @@ BUILDIN(getarg)
idx = script_getnum(st,2);
if( idx >= 0 && idx < ri->nargs )
- push_copy(st->stack, st->stack->defsp - 1 - ri->nargs + idx);
+ script->push_copy(st->stack, st->stack->defsp - 1 - ri->nargs + idx);
else if( script_hasdata(st,3) )
script_pushcopy(st, 3);
else
@@ -4502,7 +4472,7 @@ BUILDIN(return)
if( name[0] == '.' && name[1] == '@' )
{// scope variable
if( !data->ref || data->ref == (DBMap**)&st->stack->var_function )
- get_val(st, data);// current scope, convert to value
+ script->get_val(st, data);// current scope, convert to value
}
else if( name[0] == '.' && !data->ref )
{// script variable, link to current script
@@ -4569,11 +4539,11 @@ BUILDIN(warp)
y = script_getnum(st,4);
if(strcmp(str,"Random")==0)
- ret = iPc->randomwarp(sd,CLR_TELEPORT);
+ ret = pc->randomwarp(sd,CLR_TELEPORT);
else if(strcmp(str,"SavePoint")==0 || strcmp(str,"Save")==0)
- ret = iPc->setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
+ ret = pc->setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
else
- ret = iPc->setpos(sd,mapindex_name2id(str),x,y,CLR_OUTSIGHT);
+ ret = pc->setpos(sd,mapindex_name2id(str),x,y,CLR_OUTSIGHT);
if( ret ) {
ShowError("buildin_warp: moving player '%s' to \"%s\",%d,%d failed.\n", sd->status.name, str, x, y);
@@ -4597,7 +4567,7 @@ static int buildin_areawarp_sub(struct block_list *bl,va_list ap)
y3 = va_arg(ap,int);
if(index == 0)
- iPc->randomwarp((TBL_PC *)bl,CLR_TELEPORT);
+ pc->randomwarp((TBL_PC *)bl,CLR_TELEPORT);
else if(x3 && y3) {
int max, tx, ty, j = 0;
@@ -4612,10 +4582,10 @@ static int buildin_areawarp_sub(struct block_list *bl,va_list ap)
j++;
} while( iMap->getcell(index,tx,ty,CELL_CHKNOPASS) && j < max );
- iPc->setpos((TBL_PC *)bl,index,tx,ty,CLR_OUTSIGHT);
+ pc->setpos((TBL_PC *)bl,index,tx,ty,CLR_OUTSIGHT);
}
else
- iPc->setpos((TBL_PC *)bl,index,x2,y2,CLR_OUTSIGHT);
+ pc->setpos((TBL_PC *)bl,index,x2,y2,CLR_OUTSIGHT);
return 0;
}
BUILDIN(areawarp)
@@ -4665,7 +4635,7 @@ static int buildin_areapercentheal_sub(struct block_list *bl,va_list ap)
int hp, sp;
hp = va_arg(ap, int);
sp = va_arg(ap, int);
- iPc->percentheal((TBL_PC *)bl,hp,sp);
+ pc->percentheal((TBL_PC *)bl,hp,sp);
return 0;
}
BUILDIN(areapercentheal)
@@ -4711,12 +4681,12 @@ BUILDIN(warpchar)
return true;
if(strcmp(str, "Random") == 0)
- iPc->randomwarp(sd, CLR_TELEPORT);
+ pc->randomwarp(sd, CLR_TELEPORT);
else
if(strcmp(str, "SavePoint") == 0)
- iPc->setpos(sd, sd->status.save_point.map,sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
+ pc->setpos(sd, sd->status.save_point.map,sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
else
- iPc->setpos(sd, mapindex_name2id(str), x, y, CLR_TELEPORT);
+ pc->setpos(sd, mapindex_name2id(str), x, y, CLR_TELEPORT);
return true;
}
@@ -4742,7 +4712,7 @@ BUILDIN(warpparty)
if ( script_hasdata(st,6) )
str2 = script_getstr(st,6);
- p = iParty->search(p_id);
+ p = party->search(p_id);
if(!p)
return true;
@@ -4790,20 +4760,20 @@ BUILDIN(warpparty)
{
case 0: // Random
if(!map[pl_sd->bl.m].flag.nowarp)
- iPc->randomwarp(pl_sd,CLR_TELEPORT);
+ pc->randomwarp(pl_sd,CLR_TELEPORT);
break;
case 1: // SavePointAll
if(!map[pl_sd->bl.m].flag.noreturn)
- iPc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
+ pc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
break;
case 2: // SavePoint
if(!map[pl_sd->bl.m].flag.noreturn)
- iPc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
+ pc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
break;
case 3: // Leader
case 4: // m,x,y
if(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp)
- iPc->setpos(pl_sd,mapindex,x,y,CLR_TELEPORT);
+ pc->setpos(pl_sd,mapindex,x,y,CLR_TELEPORT);
break;
}
}
@@ -4851,19 +4821,19 @@ BUILDIN(warpguild)
{
case 0: // Random
if(!map[pl_sd->bl.m].flag.nowarp)
- iPc->randomwarp(pl_sd,CLR_TELEPORT);
+ pc->randomwarp(pl_sd,CLR_TELEPORT);
break;
case 1: // SavePointAll
if(!map[pl_sd->bl.m].flag.noreturn)
- iPc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
+ pc->setpos(pl_sd,pl_sd->status.save_point.map,pl_sd->status.save_point.x,pl_sd->status.save_point.y,CLR_TELEPORT);
break;
case 2: // SavePoint
if(!map[pl_sd->bl.m].flag.noreturn)
- iPc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
+ pc->setpos(pl_sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
break;
case 3: // m,x,y
if(!map[pl_sd->bl.m].flag.noreturn && !map[pl_sd->bl.m].flag.nowarp)
- iPc->setpos(pl_sd,mapindex_name2id(str),x,y,CLR_TELEPORT);
+ pc->setpos(pl_sd,mapindex_name2id(str),x,y,CLR_TELEPORT);
break;
}
}
@@ -4906,7 +4876,7 @@ BUILDIN(itemheal)
sd = script_rid2sd(st);
if (!sd) return true;
- iPc->itemheal(sd,sd->itemid,hp,sp);
+ pc->itemheal(sd,sd->itemid,hp,sp);
return true;
}
/*==========================================
@@ -4933,7 +4903,7 @@ BUILDIN(percentheal)
if( sd->sc.data[SC_EXTREMITYFIST2] )
sp = 0;
#endif
- iPc->percentheal(sd,hp,sp);
+ pc->percentheal(sd,hp,sp);
return true;
}
@@ -4956,7 +4926,7 @@ BUILDIN(jobchange)
if( sd == NULL )
return true;
- iPc->jobchange(sd, job, upper);
+ pc->jobchange(sd, job, upper);
}
return true;
@@ -4968,7 +4938,7 @@ BUILDIN(jobchange)
BUILDIN(jobname)
{
int class_=script_getnum(st,2);
- script_pushconststr(st, (char*)iPc->job_name(class_));
+ script_pushconststr(st, (char*)pc->job_name(class_));
return true;
}
@@ -5097,7 +5067,7 @@ BUILDIN(set)
}
// push the maximum number of array values to the stack
- push_val(st->stack, C_INT, SCRIPT_MAX_ARRAYSIZE);
+ script->push_val(st->stack, C_INT, SCRIPT_MAX_ARRAYSIZE,NULL);
// call the copy array method directly
return buildin_copyarray(st);
@@ -5129,7 +5099,7 @@ static int32 getarraysize(struct script_state* st, int32 id, int32 idx, int isst
{
for( ; idx < SCRIPT_MAX_ARRAYSIZE; ++idx )
{
- char* str = (char*)get_val2(st, reference_uid(id, idx), ref);
+ char* str = (char*)script->get_val2(st, reference_uid(id, idx), ref);
if( str && *str )
ret = idx + 1;
script_removetop(st, -1, 0);
@@ -5139,7 +5109,7 @@ static int32 getarraysize(struct script_state* st, int32 id, int32 idx, int isst
{
for( ; idx < SCRIPT_MAX_ARRAYSIZE; ++idx )
{
- int32 num = (int32)__64BPTRSIZE(get_val2(st, reference_uid(id, idx), ref));
+ int32 num = (int32)__64BPTRSIZE(script->get_val2(st, reference_uid(id, idx), ref));
if( num )
ret = idx + 1;
script_removetop(st, -1, 0);
@@ -5332,7 +5302,7 @@ BUILDIN(copyarray)
{// destination might be overlapping the source - copy in reverse order
for( i = count - 1; i >= 0; --i )
{
- v = get_val2(st, reference_uid(id2, idx2 + i), reference_getref(data2));
+ v = script->get_val2(st, reference_uid(id2, idx2 + i), reference_getref(data2));
set_reg(st, sd, reference_uid(id1, idx1 + i), name1, v, reference_getref(data1));
script_removetop(st, -1, 0);
}
@@ -5343,7 +5313,7 @@ BUILDIN(copyarray)
{
if( idx2 + i < SCRIPT_MAX_ARRAYSIZE )
{
- v = get_val2(st, reference_uid(id2, idx2 + i), reference_getref(data2));
+ v = script->get_val2(st, reference_uid(id2, idx2 + i), reference_getref(data2));
set_reg(st, sd, reference_uid(id1, idx1 + i), name1, v, reference_getref(data1));
script_removetop(st, -1, 0);
}
@@ -5445,7 +5415,7 @@ BUILDIN(deletearray)
// move rest of the elements backward
for( ; start + count < end; ++start )
{
- void* v = get_val2(st, reference_uid(id, start + count), reference_getref(data));
+ void* v = script->get_val2(st, reference_uid(id, start + count), reference_getref(data));
set_reg(st, sd, reference_uid(id, start), name, v, reference_getref(data));
script_removetop(st, -1, 0);
}
@@ -5507,7 +5477,7 @@ BUILDIN(getelementofarray)
return false;// out of range
}
- push_val2(st->stack, C_NAME, reference_uid(id, i), reference_getref(data));
+ script->push_val(st->stack, C_NAME, reference_uid(id, i), reference_getref(data));
return true;
}
@@ -5530,7 +5500,7 @@ BUILDIN(setlook)
if( sd == NULL )
return true;
- iPc->changelook(sd,type,val);
+ pc->changelook(sd,type,val);
return true;
}
@@ -5607,7 +5577,7 @@ BUILDIN(countitem)
}
data = script_getdata(st,2);
- get_val(st, data); // convert into value in case of a variable
+ script->get_val(st, data); // convert into value in case of a variable
if( data_isstring(data) )
{// item name
@@ -5654,7 +5624,7 @@ BUILDIN(countitem2)
}
data = script_getdata(st,2);
- get_val(st, data); // convert into value in case of a variable
+ script->get_val(st, data); // convert into value in case of a variable
if( data_isstring(data) )
{// item name
@@ -5719,11 +5689,11 @@ BUILDIN(checkweight)
script_pushint(st,0);
return false;
}
- slots = iPc->inventoryblank(sd); //nb of empty slot
+ slots = pc->inventoryblank(sd); //nb of empty slot
for(i=2; i<nbargs; i=i+2){
data = script_getdata(st,i);
- get_val(st, data); // convert into value in case of a variable
+ script->get_val(st, data); // convert into value in case of a variable
if( data_isstring(data) ){// item name
id = itemdb_searchname(script->conv_str(st, data));
} else {// item id
@@ -5750,7 +5720,7 @@ BUILDIN(checkweight)
return true;
}
- switch( iPc->checkadditem(sd, nameid, amount) )
+ switch( pc->checkadditem(sd, nameid, amount) )
{
case ADDITEM_EXIST:
// item is already in inventory, but there is still space for the requested amount
@@ -5833,11 +5803,11 @@ BUILDIN(checkweight2)
fail = 1;
}
- slots = iPc->inventoryblank(sd);
+ slots = pc->inventoryblank(sd);
for(i=0; i<nb_it; i++){
- nameid = (int32)__64BPTRSIZE(get_val2(st,reference_uid(id_it,idx_it+i),reference_getref(data_it)));
+ nameid = (int32)__64BPTRSIZE(script->get_val2(st,reference_uid(id_it,idx_it+i),reference_getref(data_it)));
script_removetop(st, -1, 0);
- amount = (int32)__64BPTRSIZE(get_val2(st,reference_uid(id_nb,idx_nb+i),reference_getref(data_nb)));
+ amount = (int32)__64BPTRSIZE(script->get_val2(st,reference_uid(id_nb,idx_nb+i),reference_getref(data_nb)));
script_removetop(st, -1, 0);
if(fail) continue; //cpntonie to depop rest
@@ -5856,7 +5826,7 @@ BUILDIN(checkweight2)
fail = 1;
continue;
}
- switch( iPc->checkadditem(sd, nameid, amount) ) {
+ switch( pc->checkadditem(sd, nameid, amount) ) {
case ADDITEM_EXIST:
// item is already in inventory, but there is still space for the requested amount
break;
@@ -5895,7 +5865,7 @@ BUILDIN(getitem)
struct item_data *item_data;
data=script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) )
{// "<item name>"
const char *name=script->conv_str(st,data);
@@ -5950,10 +5920,10 @@ BUILDIN(getitem)
// if not pet egg
if (!pet_create_egg(sd, nameid))
{
- if ((flag = iPc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT)))
+ if ((flag = pc->additem(sd, &it, get_count, LOG_TYPE_SCRIPT)))
{
clif->additem(sd, 0, 0, flag);
- if( iPc->candrop(sd,&it) )
+ if( pc->candrop(sd,&it) )
iMap->addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
@@ -5983,7 +5953,7 @@ BUILDIN(getitem2)
return true;
data=script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ){
const char *name=script->conv_str(st,data);
struct item_data *item_data = itemdb_searchname(name);
@@ -6048,10 +6018,10 @@ BUILDIN(getitem2)
// if not pet egg
if (!pet_create_egg(sd, nameid))
{
- if ((flag = iPc->additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT)))
+ if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT)))
{
clif->additem(sd, 0, 0, flag);
- if( iPc->candrop(sd,&item_tmp) )
+ if( pc->candrop(sd,&item_tmp) )
iMap->addflooritem(&item_tmp,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
@@ -6074,7 +6044,7 @@ BUILDIN(rentitem)
int nameid = 0, flag;
data = script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( (sd = script_rid2sd(st)) == NULL )
return true;
@@ -6111,7 +6081,7 @@ BUILDIN(rentitem)
it.identify = 1;
it.expire_time = (unsigned int)(time(NULL) + seconds);
- if( (flag = iPc->additem(sd, &it, 1, LOG_TYPE_SCRIPT)) )
+ if( (flag = pc->additem(sd, &it, 1, LOG_TYPE_SCRIPT)) )
{
clif->additem(sd, 0, 0, flag);
return false;
@@ -6141,7 +6111,7 @@ BUILDIN(getnameditem)
}
data=script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ){
const char *name=script->conv_str(st,data);
struct item_data *item_data = itemdb_searchname(name);
@@ -6161,7 +6131,7 @@ BUILDIN(getnameditem)
}
data=script_getdata(st,3);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ) //Char Name
tsd=iMap->nick2sd(script->conv_str(st,data));
else //Char Id was given
@@ -6180,7 +6150,7 @@ BUILDIN(getnameditem)
item_tmp.card[0]=CARD0_CREATE; //we don't use 255! because for example SIGNED WEAPON shouldn't get TOP10 BS Fame bonus [Lupus]
item_tmp.card[2]=tsd->status.char_id;
item_tmp.card[3]=tsd->status.char_id >> 16;
- if(iPc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT)) {
+ if(pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT)) {
script_pushint(st,0);
return true; //Failed to add item, we will not drop if they don't fit
}
@@ -6215,7 +6185,7 @@ BUILDIN(makeitem)
struct item_data *item_data;
data=script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ){
const char *name=script->conv_str(st,data);
if( (item_data = itemdb_searchname(name)) )
@@ -6272,7 +6242,7 @@ static void buildin_delitem_delete(struct map_session_data* sd, int idx, int* am
{// delete associated pet
intif_delete_petdata(MakeDWord(inv->card[1], inv->card[2]));
}
- iPc->delitem(sd, idx, delamount, 0, 0, LOG_TYPE_SCRIPT);
+ pc->delitem(sd, idx, delamount, 0, 0, LOG_TYPE_SCRIPT);
}
amount[0]-= delamount;
@@ -6427,7 +6397,7 @@ BUILDIN(delitem)
}
data = script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) )
{
const char* item_name = script->conv_str(st,data);
@@ -6496,7 +6466,7 @@ BUILDIN(delitem2)
}
data = script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) )
{
const char* item_name = script->conv_str(st,data);
@@ -6566,7 +6536,7 @@ BUILDIN(disableitemuse)
/*==========================================
* return the basic stats of sd
- * chk iPc->readparam for available type
+ * chk pc->readparam for available type
*------------------------------------------*/
BUILDIN(readparam)
{
@@ -6584,7 +6554,7 @@ BUILDIN(readparam)
return true;
}
- script_pushint(st,iPc->readparam(sd,type));
+ script_pushint(st,pc->readparam(sd,type));
return true;
}
@@ -6670,7 +6640,7 @@ BUILDIN(getpartyname)
party_id = script_getnum(st,2);
- if( ( p = iParty->search(party_id) ) != NULL )
+ if( ( p = party->search(party_id) ) != NULL )
{
script_pushstrcopy(st,p->party.name);
}
@@ -6694,7 +6664,7 @@ BUILDIN(getpartymember)
struct party_data *p;
int i,j=0,type=0;
- p=iParty->search(script_getnum(st,2));
+ p=party->search(script_getnum(st,2));
if( script_hasdata(st,3) )
type=script_getnum(st,3);
@@ -6734,7 +6704,7 @@ BUILDIN(getpartyleader)
if( script_hasdata(st,3) )
type=script_getnum(st,3);
- p=iParty->search(party_id);
+ p=party->search(party_id);
if (p) //Search leader
for(i = 0; i < MAX_PARTY && !p->party.member[i].leader; i++);
@@ -6847,7 +6817,7 @@ BUILDIN(strcharinfo)
script_pushstrcopy(st,sd->status.name);
break;
case 1:
- if( ( p = iParty->search(sd->status.party_id) ) != NULL ) {
+ if( ( p = party->search(sd->status.party_id) ) != NULL ) {
script_pushstrcopy(st,p->party.name);
} else {
script_pushconststr(st,"");
@@ -6951,7 +6921,7 @@ BUILDIN(getequipid)
}
// get inventory position of item
- i = iPc->checkequip(sd,equip[num]);
+ i = pc->checkequip(sd,equip[num]);
if( i < 0 )
{
script_pushint(st,-1);
@@ -6989,7 +6959,7 @@ BUILDIN(getequipname)
}
// get inventory position of item
- i = iPc->checkequip(sd,equip[num]);
+ i = pc->checkequip(sd,equip[num]);
if( i < 0 )
{
script_pushconststr(st,"");
@@ -7108,7 +7078,7 @@ BUILDIN(getequipisequiped)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=iPc->checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0)
script_pushint(st,1);
@@ -7135,7 +7105,7 @@ BUILDIN(getequipisenableref)
return true;
if( num > 0 && num <= ARRAYLENGTH(equip) )
- i = iPc->checkequip(sd,equip[num-1]);
+ i = pc->checkequip(sd,equip[num-1]);
if( i >= 0 && sd->inventory_data[i] && !sd->inventory_data[i]->flag.no_refine && !sd->status.inventory[i].expire_time )
script_pushint(st,1);
else
@@ -7161,7 +7131,7 @@ BUILDIN(getequipisidentify)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=iPc->checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0)
script_pushint(st,sd->status.inventory[i].identify);
else
@@ -7187,7 +7157,7 @@ BUILDIN(getequiprefinerycnt)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=iPc->checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0)
script_pushint(st,sd->status.inventory[i].refine);
else
@@ -7214,7 +7184,7 @@ BUILDIN(getequipweaponlv)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=iPc->checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0 && sd->inventory_data[i])
script_pushint(st,sd->inventory_data[i]->wlv);
else
@@ -7240,7 +7210,7 @@ BUILDIN(getequippercentrefinery)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=iPc->checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0 && sd->status.inventory[i].nameid && sd->status.inventory[i].refine < MAX_REFINE)
script_pushint(st,status_get_refine_chance(itemdb_wlv(sd->status.inventory[i].nameid), (int)sd->status.inventory[i].refine));
else
@@ -7263,7 +7233,7 @@ BUILDIN(successrefitem)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=iPc->checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0) {
ep=sd->status.inventory[i].equip;
@@ -7271,7 +7241,7 @@ BUILDIN(successrefitem)
logs->pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i],sd->inventory_data[i]);
sd->status.inventory[i].refine++;
- iPc->unequipitem(sd,i,2); // status calc will happen in iPc->equipitem() below
+ pc->unequipitem(sd,i,2); // status calc will happen in pc->equipitem() below
clif->refine(sd->fd,0,i,sd->status.inventory[i].refine);
clif->delitem(sd,i,1,3);
@@ -7280,7 +7250,7 @@ BUILDIN(successrefitem)
logs->pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i],sd->inventory_data[i]);
clif->additem(sd,i,1,0);
- iPc->equipitem(sd,i,ep);
+ pc->equipitem(sd,i,ep);
clif->misceffect(&sd->bl,3);
if(sd->status.inventory[i].refine == 10 &&
sd->status.inventory[i].card[0] == CARD0_FORGE &&
@@ -7288,13 +7258,13 @@ BUILDIN(successrefitem)
){ // Fame point system [DracoRPG]
switch (sd->inventory_data[i]->wlv){
case 1:
- iPc->addfame(sd,1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point
+ pc->addfame(sd,1); // Success to refine to +10 a lv1 weapon you forged = +1 fame point
break;
case 2:
- iPc->addfame(sd,25); // Success to refine to +10 a lv2 weapon you forged = +25 fame point
+ pc->addfame(sd,25); // Success to refine to +10 a lv2 weapon you forged = +25 fame point
break;
case 3:
- iPc->addfame(sd,1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point
+ pc->addfame(sd,1000); // Success to refine to +10 a lv3 weapon you forged = +1000 fame point
break;
}
}
@@ -7317,13 +7287,13 @@ BUILDIN(failedrefitem)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=iPc->checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0) {
sd->status.inventory[i].refine = 0;
- iPc->unequipitem(sd,i,3); //recalculate bonus
+ pc->unequipitem(sd,i,3); //recalculate bonus
clif->refine(sd->fd,1,i,sd->status.inventory[i].refine); //notify client of failure
- iPc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ pc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
clif->misceffect(&sd->bl,2); // display failure effect
}
@@ -7345,7 +7315,7 @@ BUILDIN(downrefitem)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i = iPc->checkequip(sd,equip[num-1]);
+ i = pc->checkequip(sd,equip[num-1]);
if(i >= 0) {
ep = sd->status.inventory[i].equip;
@@ -7353,7 +7323,7 @@ BUILDIN(downrefitem)
logs->pick_pc(sd, LOG_TYPE_SCRIPT, -1, &sd->status.inventory[i],sd->inventory_data[i]);
sd->status.inventory[i].refine++;
- iPc->unequipitem(sd,i,2); // status calc will happen in iPc->equipitem() below
+ pc->unequipitem(sd,i,2); // status calc will happen in pc->equipitem() below
clif->refine(sd->fd,2,i,sd->status.inventory[i].refine = sd->status.inventory[i].refine - 2);
clif->delitem(sd,i,1,3);
@@ -7362,7 +7332,7 @@ BUILDIN(downrefitem)
logs->pick_pc(sd, LOG_TYPE_SCRIPT, 1, &sd->status.inventory[i],sd->inventory_data[i]);
clif->additem(sd,i,1,0);
- iPc->equipitem(sd,i,ep);
+ pc->equipitem(sd,i,ep);
clif->misceffect(&sd->bl,2);
}
@@ -7383,10 +7353,10 @@ BUILDIN(delequip)
return true;
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=iPc->checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0) {
- iPc->unequipitem(sd,i,3); //recalculate bonus
- iPc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ pc->unequipitem(sd,i,3); //recalculate bonus
+ pc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
}
return true;
@@ -7405,7 +7375,7 @@ BUILDIN(statusup)
if( sd == NULL )
return true;
- iPc->statusup(sd,type);
+ pc->statusup(sd,type);
return true;
}
@@ -7423,7 +7393,7 @@ BUILDIN(statusup2)
if( sd == NULL )
return true;
- iPc->statusup2(sd,type,val);
+ pc->statusup2(sd,type,val);
return true;
}
@@ -7477,16 +7447,16 @@ BUILDIN(bonus)
switch( script_lastdata(st)-2 ) {
case 1:
- iPc->bonus(sd, type, val1);
+ pc->bonus(sd, type, val1);
break;
case 2:
val2 = script_getnum(st,4);
- iPc->bonus2(sd, type, val1, val2);
+ pc->bonus2(sd, type, val1, val2);
break;
case 3:
val2 = script_getnum(st,4);
val3 = script_getnum(st,5);
- iPc->bonus3(sd, type, val1, val2, val3);
+ pc->bonus3(sd, type, val1, val2, val3);
break;
case 4:
if( type == SP_AUTOSPELL_ONSKILL && script_isstring(st,4) )
@@ -7496,7 +7466,7 @@ BUILDIN(bonus)
val3 = script_getnum(st,5);
val4 = script_getnum(st,6);
- iPc->bonus4(sd, type, val1, val2, val3, val4);
+ pc->bonus4(sd, type, val1, val2, val3, val4);
break;
case 5:
if( type == SP_AUTOSPELL_ONSKILL && script_isstring(st,4) )
@@ -7507,7 +7477,7 @@ BUILDIN(bonus)
val3 = script_getnum(st,5);
val4 = script_getnum(st,6);
val5 = script_getnum(st,7);
- iPc->bonus5(sd, type, val1, val2, val3, val4, val5);
+ pc->bonus5(sd, type, val1, val2, val3, val4, val5);
break;
default:
ShowDebug("buildin_bonus: unexpected number of arguments (%d)\n", (script_lastdata(st) - 1));
@@ -7543,7 +7513,7 @@ BUILDIN(autobonus)
if( script_hasdata(st,6) )
other_script = script_getstr(st,6);
- if( iPc->addautobonus(sd->autobonus,ARRAYLENGTH(sd->autobonus),
+ if( pc->addautobonus(sd->autobonus,ARRAYLENGTH(sd->autobonus),
bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,false) )
{
script_add_autobonus(bonus_script);
@@ -7580,7 +7550,7 @@ BUILDIN(autobonus2)
if( script_hasdata(st,6) )
other_script = script_getstr(st,6);
- if( iPc->addautobonus(sd->autobonus2,ARRAYLENGTH(sd->autobonus2),
+ if( pc->addautobonus(sd->autobonus2,ARRAYLENGTH(sd->autobonus2),
bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,false) )
{
script_add_autobonus(bonus_script);
@@ -7615,7 +7585,7 @@ BUILDIN(autobonus3)
if( script_hasdata(st,6) )
other_script = script_getstr(st,6);
- if( iPc->addautobonus(sd->autobonus3,ARRAYLENGTH(sd->autobonus3),
+ if( pc->addautobonus(sd->autobonus3,ARRAYLENGTH(sd->autobonus3),
bonus_script,rate,dur,atk_type,other_script,sd->status.inventory[current_equip_item_index].equip,true) )
{
script_add_autobonus(bonus_script);
@@ -7651,7 +7621,7 @@ BUILDIN(skill)
level = script_getnum(st,3);
if( script_hasdata(st,4) )
flag = script_getnum(st,4);
- iPc->skill(sd, id, level, flag);
+ pc->skill(sd, id, level, flag);
return true;
}
@@ -7680,7 +7650,7 @@ BUILDIN(addtoskill)
level = script_getnum(st,3);
if( script_hasdata(st,4) )
flag = script_getnum(st,4);
- iPc->skill(sd, id, level, flag);
+ pc->skill(sd, id, level, flag);
return true;
}
@@ -7722,7 +7692,7 @@ BUILDIN(getskilllv)
return true;// no player attached, report source
id = ( script_isstring(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
- script_pushint(st, iPc->checkskill(sd,id));
+ script_pushint(st, pc->checkskill(sd,id));
return true;
}
@@ -7770,7 +7740,7 @@ BUILDIN(getgmlevel)
if( sd == NULL )
return true;// no player attached, report source
- script_pushint(st, iPc->get_group_level(sd));
+ script_pushint(st, pc->get_group_level(sd));
return true;
}
@@ -7891,9 +7861,9 @@ BUILDIN(setoption)
if( flag ){// Add option
if( option&OPTION_WEDDING && !battle_config.wedding_modifydisplay )
option &= ~OPTION_WEDDING;// Do not show the wedding sprites
- iPc->setoption(sd, sd->sc.option|option);
+ pc->setoption(sd, sd->sc.option|option);
} else// Remove option
- iPc->setoption(sd, sd->sc.option&~option);
+ pc->setoption(sd, sd->sc.option&~option);
return true;
}
@@ -7941,7 +7911,7 @@ BUILDIN(setcart)
if( script_hasdata(st,2) )
type = script_getnum(st,2);
- iPc->setcart(sd, type);
+ pc->setcart(sd, type);
return true;
}
@@ -7984,7 +7954,7 @@ BUILDIN(setfalcon)
if( script_hasdata(st,2) )
flag = script_getnum(st,2);
- iPc->setfalcon(sd, flag);
+ pc->setfalcon(sd, flag);
return true;
}
@@ -8026,7 +7996,7 @@ BUILDIN(setriding)
if( script_hasdata(st,2) )
flag = script_getnum(st,2);
- iPc->setriding(sd, flag);
+ pc->setriding(sd, flag);
return true;
}
@@ -8087,7 +8057,7 @@ BUILDIN(setmadogear)
if( script_hasdata(st,2) )
flag = script_getnum(st,2);
- iPc->setmadogear(sd, flag);
+ pc->setmadogear(sd, flag);
return true;
}
@@ -8113,7 +8083,7 @@ BUILDIN(savepoint)
y = script_getnum(st,4);
map = mapindex_name2id(str);
if( map )
- iPc->setsavepoint(sd, map, x, y);
+ pc->setsavepoint(sd, map, x, y);
return true;
}
@@ -8360,7 +8330,7 @@ BUILDIN(getexp)
base = (int) cap_value(base * bonus, 0, INT_MAX);
job = (int) cap_value(job * bonus, 0, INT_MAX);
- iPc->gainexp(sd, NULL, base, job, true);
+ pc->gainexp(sd, NULL, base, job, true);
return true;
}
@@ -8789,7 +8759,7 @@ BUILDIN(addtimer)
if( sd == NULL )
return true;
- iPc->addeventtimer(sd,tick,event);
+ pc->addeventtimer(sd,tick,event);
return true;
}
/*==========================================
@@ -8805,7 +8775,7 @@ BUILDIN(deltimer)
return true;
check_event(st, event);
- iPc->deleventtimer(sd,event);
+ pc->deleventtimer(sd,event);
return true;
}
/*==========================================
@@ -8823,7 +8793,7 @@ BUILDIN(addtimercount)
return true;
check_event(st, event);
- iPc->addeventtimercount(sd,event,tick);
+ pc->addeventtimercount(sd,event,tick);
return true;
}
@@ -8843,7 +8813,7 @@ BUILDIN(initnpctimer)
{ //Check if argument is numeric (flag) or string (npc name)
struct script_data *data;
data = script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ) //NPC name
nd = npc_name2id(script->conv_str(st, data));
else if( data_isint(data) ) //Flag
@@ -8891,7 +8861,7 @@ BUILDIN(startnpctimer)
{ //Check if argument is numeric (flag) or string (npc name)
struct script_data *data;
data = script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ) //NPC name
nd = npc_name2id(script->conv_str(st, data));
else if( data_isint(data) ) //Flag
@@ -8937,7 +8907,7 @@ BUILDIN(stopnpctimer)
{ //Check if argument is numeric (flag) or string (npc name)
struct script_data *data;
data = script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ) //NPC name
nd = npc_name2id(script->conv_str(st, data));
else if( data_isint(data) ) //Flag
@@ -9170,7 +9140,7 @@ BUILDIN(itemeffect) {
nullpo_retr( 1, ( nd = (TBL_NPC *)iMap->id2bl( sd->npc_id ) ) );
data = script_getdata( st, 2 );
- get_val( st, data );
+ script->get_val( st, data );
if( data_isstring( data ) ){
const char *name = script->conv_str( st, data );
@@ -9292,11 +9262,11 @@ BUILDIN(getusersname)
sd = script_rid2sd(st);
if (!sd) return true;
- group_level = iPc->get_group_level(sd);
+ group_level = pc->get_group_level(sd);
iter = mapit_getallusers();
for( pl_sd = (TBL_PC*)mapit->first(iter); mapit->exists(iter); pl_sd = (TBL_PC*)mapit->next(iter) )
{
- if (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && iPc->get_group_level(pl_sd) > group_level)
+ if (pc_has_permission(pl_sd, PC_PERM_HIDE_SESSION) && pc->get_group_level(pl_sd) > group_level)
continue; // skip hidden sessions
/* Temporary fix for bugreport:1023.
@@ -9406,7 +9376,7 @@ BUILDIN(getareadropitem)
y1=script_getnum(st,6);
data=script_getdata(st,7);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ){
const char *name=script->conv_str(st,data);
struct item_data *item_data = itemdb_searchname(name);
@@ -9833,7 +9803,7 @@ BUILDIN(eaclass)
}
class_ = sd->status.class_;
}
- script_pushint(st,iPc->jobid2mapid(class_));
+ script_pushint(st,pc->jobid2mapid(class_));
return true;
}
@@ -9850,7 +9820,7 @@ BUILDIN(roclass)
else
sex = 1; //Just use male when not found.
}
- script_pushint(st,iPc->mapid2jobid(class_, sex));
+ script_pushint(st,pc->mapid2jobid(class_, sex));
return true;
}
@@ -9891,7 +9861,7 @@ BUILDIN(resetlvl)
if( sd == NULL )
return true;
- iPc->resetlvl(sd,type);
+ pc->resetlvl(sd,type);
return true;
}
/*==========================================
@@ -9901,7 +9871,7 @@ BUILDIN(resetstatus)
{
TBL_PC *sd;
sd=script_rid2sd(st);
- iPc->resetstate(sd);
+ pc->resetstate(sd);
return true;
}
@@ -9912,7 +9882,7 @@ BUILDIN(resetskill)
{
TBL_PC *sd;
sd=script_rid2sd(st);
- iPc->resetskill(sd,1);
+ pc->resetskill(sd,1);
return true;
}
@@ -9923,7 +9893,7 @@ BUILDIN(skillpointcount)
{
TBL_PC *sd;
sd=script_rid2sd(st);
- script_pushint(st,sd->status.skill_point + iPc->resetskill(sd,2));
+ script_pushint(st,sd->status.skill_point + pc->resetskill(sd,2));
return true;
}
@@ -9974,10 +9944,10 @@ BUILDIN(changesex)
TBL_PC *sd = NULL;
sd = script_rid2sd(st);
- iPc->resetskill(sd,4);
+ pc->resetskill(sd,4);
// to avoid any problem with equipment and invalid sex, equipment is unequiped.
for( i=0; i<EQI_MAX; i++ )
- if( sd->equip_index[i] >= 0 ) iPc->unequipitem(sd, sd->equip_index[i], 3);
+ if( sd->equip_index[i] >= 0 ) pc->unequipitem(sd, sd->equip_index[i], 3);
chrif_changesex(sd);
return true;
}
@@ -10202,17 +10172,17 @@ BUILDIN(warpwaitingpc)
{// no zeny to cover set fee
break;
}
- iPc->payzeny(sd, cd->zeny, LOG_TYPE_NPC, NULL);
+ pc->payzeny(sd, cd->zeny, LOG_TYPE_NPC, NULL);
}
mapreg_setreg(reference_uid(add_str("$@warpwaitingpc"), i), sd->bl.id);
if( strcmp(map_name,"Random") == 0 )
- iPc->randomwarp(sd,CLR_TELEPORT);
+ pc->randomwarp(sd,CLR_TELEPORT);
else if( strcmp(map_name,"SavePoint") == 0 )
- iPc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
+ pc->setpos(sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, CLR_TELEPORT);
else
- iPc->setpos(sd, mapindex_name2id(map_name), x, y, CLR_OUTSIGHT);
+ pc->setpos(sd, mapindex_name2id(map_name), x, y, CLR_OUTSIGHT);
}
mapreg_setreg(add_str("$@warpwaitingpcnum"), i);
return true;
@@ -10268,7 +10238,7 @@ BUILDIN(isloggedin)
if (script_hasdata(st,3) && sd &&
sd->status.char_id != script_getnum(st,3))
sd = NULL;
- push_val(st->stack,C_INT,sd!=NULL);
+ script->push_val(st->stack,C_INT,sd!=NULL,NULL);
return true;
}
@@ -10368,7 +10338,7 @@ BUILDIN(getmapflag)
static int script_mapflag_pvp_sub(struct block_list *bl,va_list ap) {
TBL_PC* sd = (TBL_PC*)bl;
if (sd->pvp_timer == INVALID_TIMER) {
- sd->pvp_timer = iTimer->add_timer(iTimer->gettick() + 200, iPc->calc_pvprank_timer, sd->bl.id, 0);
+ sd->pvp_timer = iTimer->add_timer(iTimer->gettick() + 200, pc->calc_pvprank_timer, sd->bl.id, 0);
sd->pvp_rank = 0;
sd->pvp_lastusers = 0;
sd->pvp_point = 5;
@@ -10392,7 +10362,7 @@ BUILDIN(setmapflag)
if(script_hasdata(st,4)){
data = script_getdata(st,4);
- get_val(st, data);
+ script->get_val(st, data);
if( data_isstring(data) )
@@ -10599,7 +10569,7 @@ BUILDIN(pvpon)
if( sd->bl.m != m || sd->pvp_timer != INVALID_TIMER )
continue; // not applicable
- sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+200,iPc->calc_pvprank_timer,sd->bl.id,0);
+ sd->pvp_timer = iTimer->add_timer(iTimer->gettick()+200,pc->calc_pvprank_timer,sd->bl.id,0);
sd->pvp_rank = 0;
sd->pvp_lastusers = 0;
sd->pvp_point = 5;
@@ -10616,7 +10586,7 @@ static int buildin_pvpoff_sub(struct block_list *bl,va_list ap)
TBL_PC* sd = (TBL_PC*)bl;
clif->pvpset(sd, 0, 0, 2);
if (sd->pvp_timer != INVALID_TIMER) {
- iTimer->delete_timer(sd->pvp_timer, iPc->calc_pvprank_timer);
+ iTimer->delete_timer(sd->pvp_timer, pc->calc_pvprank_timer);
sd->pvp_timer = INVALID_TIMER;
}
return 0;
@@ -10735,7 +10705,7 @@ static int buildin_maprespawnguildid_sub_pc(struct map_session_data* sd, va_list
(sd->status.guild_id != g_id && flag&2) || //Warp out outsiders
(sd->status.guild_id == 0) // Warp out players not in guild [Valaris]
)
- iPc->setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
+ pc->setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT);
return 1;
}
@@ -10936,8 +10906,8 @@ BUILDIN(requestguildinfo)
}
/// Returns the number of cards that have been compounded onto the specified equipped item.
-/// getequipcardcnt(<equipment slot>);
-BUILDIN(getequipcardcnt)
+/// getequpcardcnt(<equipment slot>);
+BUILDIN(getequpcardcnt)
{
int i=-1,j,num;
TBL_PC *sd;
@@ -10946,7 +10916,7 @@ BUILDIN(getequipcardcnt)
num=script_getnum(st,2);
sd=script_rid2sd(st);
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=iPc->checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if (i < 0 || !sd->inventory_data[i]) {
script_pushint(st,0);
@@ -10978,7 +10948,7 @@ BUILDIN(successremovecards) {
int num = script_getnum(st,2);
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=iPc->checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if (i < 0 || !sd->inventory_data[i]) {
return true;
@@ -10996,7 +10966,7 @@ BUILDIN(successremovecards) {
item_tmp.nameid = sd->status.inventory[i].card[c];
item_tmp.identify = 1;
- if((flag=iPc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ // get back the cart in inventory
+ if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ // get back the cart in inventory
clif->additem(sd,0,0,flag);
iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
@@ -11017,8 +10987,8 @@ BUILDIN(successremovecards) {
for (j = sd->inventory_data[i]->slot; j < MAX_SLOTS; j++)
item_tmp.card[j]=sd->status.inventory[i].card[j];
- iPc->delitem(sd,i,1,0,3,LOG_TYPE_SCRIPT);
- if((flag=iPc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ //chk if can be spawn in inventory otherwise put on floor
+ pc->delitem(sd,i,1,0,3,LOG_TYPE_SCRIPT);
+ if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){ //chk if can be spawn in inventory otherwise put on floor
clif->additem(sd,0,0,flag);
iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
@@ -11042,7 +11012,7 @@ BUILDIN(failedremovecards) {
int typefail = script_getnum(st,3);
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=iPc->checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if (i < 0 || !sd->inventory_data[i])
return true;
@@ -11063,7 +11033,7 @@ BUILDIN(failedremovecards) {
item_tmp.nameid = sd->status.inventory[i].card[c];
item_tmp.identify = 1;
- if((flag=iPc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){
+ if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){
clif->additem(sd,0,0,flag);
iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
@@ -11073,7 +11043,7 @@ BUILDIN(failedremovecards) {
if(cardflag == 1) {
if(typefail == 0 || typefail == 2){ // destroy the item
- iPc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ pc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
}
if(typefail == 1){ // destroy the card
int flag;
@@ -11090,9 +11060,9 @@ BUILDIN(failedremovecards) {
for (j = sd->inventory_data[i]->slot; j < MAX_SLOTS; j++)
item_tmp.card[j]=sd->status.inventory[i].card[j];
- iPc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
+ pc->delitem(sd,i,1,0,2,LOG_TYPE_SCRIPT);
- if((flag=iPc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){
+ if((flag=pc->additem(sd,&item_tmp,1,LOG_TYPE_SCRIPT))){
clif->additem(sd,0,0,flag);
iMap->addflooritem(&item_tmp,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
@@ -11138,17 +11108,17 @@ BUILDIN(mapwarp) // Added by RoVeRT
for( i=0; i < g->max_member; i++)
{
if(g->member[i].sd && g->member[i].sd->bl.m==m){
- iPc->setpos(g->member[i].sd,index,x,y,CLR_TELEPORT);
+ pc->setpos(g->member[i].sd,index,x,y,CLR_TELEPORT);
}
}
}
break;
case 2:
- p = iParty->search(check_ID);
+ p = party->search(check_ID);
if(p){
for(i=0;i<MAX_PARTY; i++){
if(p->data[i].sd && p->data[i].sd->bl.m == m){
- iPc->setpos(p->data[i].sd,index,x,y,CLR_TELEPORT);
+ pc->setpos(p->data[i].sd,index,x,y,CLR_TELEPORT);
}
}
}
@@ -11211,7 +11181,7 @@ BUILDIN(marriage)
TBL_PC *sd=script_rid2sd(st);
TBL_PC *p_sd=iMap->nick2sd(partner);
- if(sd==NULL || p_sd==NULL || iPc->marriage(sd,p_sd) < 0){
+ if(sd==NULL || p_sd==NULL || pc->marriage(sd,p_sd) < 0){
script_pushint(st,0);
return true;
}
@@ -11233,7 +11203,7 @@ BUILDIN(wedding_effect)
BUILDIN(divorce)
{
TBL_PC *sd=script_rid2sd(st);
- if(sd==NULL || iPc->divorce(sd) < 0){
+ if(sd==NULL || pc->divorce(sd) < 0){
script_pushint(st,0);
return true;
}
@@ -11245,7 +11215,7 @@ BUILDIN(ispartneron)
{
TBL_PC *sd=script_rid2sd(st);
- if(sd==NULL || !iPc->ismarried(sd) ||
+ if(sd==NULL || !pc->ismarried(sd) ||
iMap->charid2sd(sd->status.partner_id) == NULL) {
script_pushint(st,0);
return true;
@@ -11311,7 +11281,7 @@ BUILDIN(warppartner)
TBL_PC *sd=script_rid2sd(st);
TBL_PC *p_sd=NULL;
- if(sd==NULL || !iPc->ismarried(sd) ||
+ if(sd==NULL || !pc->ismarried(sd) ||
(p_sd=iMap->charid2sd(sd->status.partner_id)) == NULL) {
script_pushint(st,0);
return true;
@@ -11323,7 +11293,7 @@ BUILDIN(warppartner)
mapindex = mapindex_name2id(str);
if (mapindex) {
- iPc->setpos(p_sd,mapindex,x,y,CLR_OUTSIGHT);
+ pc->setpos(p_sd,mapindex,x,y,CLR_OUTSIGHT);
script_pushint(st,1);
} else
script_pushint(st,0);
@@ -11387,7 +11357,7 @@ BUILDIN(guardian)
has_index = true;
} else if( script_hasdata(st,7) ){
data=script_getdata(st,7);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) )
{// "<event label>"
evt=script_getstr(st,7);
@@ -11490,7 +11460,7 @@ BUILDIN(getitemname)
struct script_data *data;
data=script_getdata(st,2);
- get_val(st,data);
+ script->get_val(st,data);
if( data_isstring(data) ){
const char *name=script->conv_str(st,data);
@@ -11618,7 +11588,7 @@ BUILDIN(setiteminfo)
/*==========================================
* Returns value from equipped item slot n [Lupus]
- getequipcardid(num,slot)
+ getequpcardid(num,slot)
where
num = eqip position slot
slot = 0,1,2,3 (Card Slot N)
@@ -11637,7 +11607,7 @@ BUILDIN(getequipcardid)
slot=script_getnum(st,3);
sd=script_rid2sd(st);
if (num > 0 && num <= ARRAYLENGTH(equip))
- i=iPc->checkequip(sd,equip[num-1]);
+ i=pc->checkequip(sd,equip[num-1]);
if(i >= 0 && slot>=0 && slot<4)
script_pushint(st,sd->status.inventory[i].card[slot]);
else
@@ -11735,22 +11705,22 @@ BUILDIN(getinventorylist)
if(!sd) return true;
for(i=0;i<MAX_INVENTORY;i++){
if(sd->status.inventory[i].nameid > 0 && sd->status.inventory[i].amount > 0){
- iPc->setreg(sd,reference_uid(add_str("@inventorylist_id"), j),sd->status.inventory[i].nameid);
- iPc->setreg(sd,reference_uid(add_str("@inventorylist_amount"), j),sd->status.inventory[i].amount);
- iPc->setreg(sd,reference_uid(add_str("@inventorylist_equip"), j),sd->status.inventory[i].equip);
- iPc->setreg(sd,reference_uid(add_str("@inventorylist_refine"), j),sd->status.inventory[i].refine);
- iPc->setreg(sd,reference_uid(add_str("@inventorylist_identify"), j),sd->status.inventory[i].identify);
- iPc->setreg(sd,reference_uid(add_str("@inventorylist_attribute"), j),sd->status.inventory[i].attribute);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_id"), j),sd->status.inventory[i].nameid);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_amount"), j),sd->status.inventory[i].amount);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_equip"), j),sd->status.inventory[i].equip);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_refine"), j),sd->status.inventory[i].refine);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_identify"), j),sd->status.inventory[i].identify);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_attribute"), j),sd->status.inventory[i].attribute);
for (k = 0; k < MAX_SLOTS; k++)
{
sprintf(card_var, "@inventorylist_card%d",k+1);
- iPc->setreg(sd,reference_uid(add_str(card_var), j),sd->status.inventory[i].card[k]);
+ pc->setreg(sd,reference_uid(add_str(card_var), j),sd->status.inventory[i].card[k]);
}
- iPc->setreg(sd,reference_uid(add_str("@inventorylist_expire"), j),sd->status.inventory[i].expire_time);
+ pc->setreg(sd,reference_uid(add_str("@inventorylist_expire"), j),sd->status.inventory[i].expire_time);
j++;
}
}
- iPc->setreg(sd,add_str("@inventorylist_count"),j);
+ pc->setreg(sd,add_str("@inventorylist_count"),j);
return true;
}
@@ -11761,13 +11731,13 @@ BUILDIN(getskilllist)
if(!sd) return true;
for(i=0;i<MAX_SKILL;i++){
if(sd->status.skill[i].id > 0 && sd->status.skill[i].lv > 0){
- iPc->setreg(sd,reference_uid(add_str("@skilllist_id"), j),sd->status.skill[i].id);
- iPc->setreg(sd,reference_uid(add_str("@skilllist_lv"), j),sd->status.skill[i].lv);
- iPc->setreg(sd,reference_uid(add_str("@skilllist_flag"), j),sd->status.skill[i].flag);
+ pc->setreg(sd,reference_uid(add_str("@skilllist_id"), j),sd->status.skill[i].id);
+ pc->setreg(sd,reference_uid(add_str("@skilllist_lv"), j),sd->status.skill[i].lv);
+ pc->setreg(sd,reference_uid(add_str("@skilllist_flag"), j),sd->status.skill[i].flag);
j++;
}
}
- iPc->setreg(sd,add_str("@skilllist_count"),j);
+ pc->setreg(sd,add_str("@skilllist_count"),j);
return true;
}
@@ -11778,7 +11748,7 @@ BUILDIN(clearitem)
if(sd==NULL) return true;
for (i=0; i<MAX_INVENTORY; i++) {
if (sd->status.inventory[i].amount) {
- iPc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_SCRIPT);
+ pc->delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_SCRIPT);
}
}
return true;
@@ -11796,7 +11766,7 @@ BUILDIN(disguise)
id = script_getnum(st,2);
if (mobdb_checkid(id) || npcdb_checkid(id)) {
- iPc->disguise(sd, id);
+ pc->disguise(sd, id);
script_pushint(st,id);
} else
script_pushint(st,0);
@@ -11813,7 +11783,7 @@ BUILDIN(undisguise)
if (sd == NULL) return true;
if (sd->disguise != -1) {
- iPc->disguise(sd, -1);
+ pc->disguise(sd, -1);
script_pushint(st,0);
} else {
script_pushint(st,1);
@@ -12257,7 +12227,7 @@ BUILDIN(nude)
if( sd->equip_index[ i ] >= 0 ) {
if( !calcflag )
calcflag = 1;
- iPc->unequipitem( sd , sd->equip_index[ i ] , 2);
+ pc->unequipitem( sd , sd->equip_index[ i ] , 2);
}
}
@@ -13116,12 +13086,12 @@ BUILDIN(getrefine)
*-------------------------------------------------------*/
BUILDIN(night)
{
- if (iMap->night_flag != 1) iPc->map_night_timer(iPc->night_timer_tid, 0, 0, 1);
+ if (iMap->night_flag != 1) pc->map_night_timer(pc->night_timer_tid, 0, 0, 1);
return true;
}
BUILDIN(day)
{
- if (iMap->night_flag != 0) iPc->map_day_timer(iPc->day_timer_tid, 0, 0, 1);
+ if (iMap->night_flag != 0) pc->map_day_timer(pc->day_timer_tid, 0, 0, 1);
return true;
}
@@ -13138,9 +13108,9 @@ BUILDIN(unequip)
sd = script_rid2sd(st);
if( sd != NULL && num >= 1 && num <= ARRAYLENGTH(equip) )
{
- i = iPc->checkequip(sd,equip[num-1]);
+ i = pc->checkequip(sd,equip[num-1]);
if (i >= 0)
- iPc->unequipitem(sd,i,1|2);
+ pc->unequipitem(sd,i,1|2);
}
return true;
}
@@ -13161,7 +13131,7 @@ BUILDIN(equip)
}
ARR_FIND( 0, MAX_INVENTORY, i, sd->status.inventory[i].nameid == nameid );
if( i < MAX_INVENTORY )
- iPc->equipitem(sd,i,item_data->equip);
+ pc->equipitem(sd,i,item_data->equip);
return true;
}
@@ -13550,7 +13520,7 @@ BUILDIN(implode)
sprintf(output,"%s","NULL");
} else {
for(i = 0; i <= array_size; ++i) {
- temp = (char*) get_val2(st, reference_uid(id, i), reference_getref(data));
+ temp = (char*) script->get_val2(st, reference_uid(id, i), reference_getref(data));
len += strlen(temp);
script_removetop(st, -1, 0);
}
@@ -13565,7 +13535,7 @@ BUILDIN(implode)
//build output
for(i = 0; i < array_size; ++i) {
- temp = (char*) get_val2(st, reference_uid(id, i), reference_getref(data));
+ temp = (char*) script->get_val2(st, reference_uid(id, i), reference_getref(data));
len = strlen(temp);
memcpy(&output[k], temp, len);
k += len;
@@ -13575,7 +13545,7 @@ BUILDIN(implode)
}
script_removetop(st, -1, 0);
}
- temp = (char*) get_val2(st, reference_uid(id, array_size), reference_getref(data));
+ temp = (char*) script->get_val2(st, reference_uid(id, array_size), reference_getref(data));
len = strlen(temp);
memcpy(&output[k], temp, len);
k += len;
@@ -14030,14 +14000,14 @@ BUILDIN(setnpcdisplay)
if( script_hasdata(st,5) )
size = script_getnum(st,5);
- get_val(st, data);
+ script->get_val(st, data);
if( data_isstring(data) )
newname = script->conv_str(st,data);
else if( data_isint(data) )
class_ = script->conv_num(st,data);
else
{
- ShowError("script:setnpcdisplay: expected a string or number\n");
+ ShowError("script:setnpcdisplay: expected string or number\n");
script_reportdata(data);
return false;
}
@@ -14295,7 +14265,7 @@ BUILDIN(getd)
elem = 0;
// Push the 'pointer' so it's more flexible [Lance]
- push_val(st->stack, C_NAME, reference_uid(add_str(varname), elem));
+ script->push_val(st->stack, C_NAME, reference_uid(add_str(varname), elem),NULL);
return true;
}
@@ -14835,7 +14805,7 @@ BUILDIN(pcfollow)
sd = script_rid2sd(st);
if(sd)
- iPc->follow(sd, targetid);
+ pc->follow(sd, targetid);
return true;
}
@@ -14854,7 +14824,7 @@ BUILDIN(pcstopfollow)
sd = script_rid2sd(st);
if(sd)
- iPc->stop_following(sd);
+ pc->stop_following(sd);
return true;
}
@@ -14961,7 +14931,7 @@ BUILDIN(unitattack)
}
data = script_getdata(st, 3);
- get_val(st, data);
+ script->get_val(st, data);
if( data_isstring(data) )
{
TBL_PC* sd = iMap->nick2sd(script->conv_str(st, data));
@@ -15264,7 +15234,7 @@ BUILDIN(getvariableofnpc)
return false;
}
- push_val2(st->stack, C_NAME, reference_getuid(data), &nd->u.scr.script->script_vars );
+ script->push_val(st->stack, C_NAME, reference_getuid(data), &nd->u.scr.script->script_vars );
return true;
}
@@ -15728,7 +15698,7 @@ BUILDIN(waitingroom2bg_single)
if( bg_team_join(bg_id, sd) )
{
- iPc->setpos(sd, mapindex, x, y, CLR_TELEPORT);
+ pc->setpos(sd, mapindex, x, y, CLR_TELEPORT);
script_pushint(st,1);
}
else
@@ -16133,7 +16103,7 @@ BUILDIN(has_instance) {
if( i != sd->instances )
instance_id = sd->instance[i];
}
- if( instance_id == -1 && sd->status.party_id && (p = iParty->search(sd->status.party_id)) && p->instances ) {
+ if( instance_id == -1 && sd->status.party_id && (p = party->search(sd->status.party_id)) && p->instances ) {
for( i = 0; i < p->instances; i++ ) {
ARR_FIND(0, instances[p->instance[i]].num_map, j, map[instances[p->instance[i]].map[j]].instance_src_map == m);
if( j != instances[p->instance[i]].num_map )
@@ -16167,7 +16137,7 @@ static int buildin_instance_warpall_sub(struct block_list *bl,va_list ap) {
int x = va_arg(ap,int);
int y = va_arg(ap,int);
- iPc->setpos(sd,mapindex,x,y,CLR_TELEPORT);
+ pc->setpos(sd,mapindex,x,y,CLR_TELEPORT);
return 0;
}
@@ -16230,7 +16200,7 @@ BUILDIN(instance_check_party) {
party_id = script_getnum(st,2);
else return true;
- if( !(p = iParty->search(party_id)) ){
+ if( !(p = party->search(party_id)) ){
script_pushint(st, 0); // Returns false if party does not exist.
return true;
}
@@ -16524,10 +16494,10 @@ BUILDIN(setdragon) {
if( (sd = script_rid2sd(st)) == NULL )
return true;
- if( !iPc->checkskill(sd,RK_DRAGONTRAINING) || (sd->class_&MAPID_THIRDMASK) != MAPID_RUNE_KNIGHT )
+ if( !pc->checkskill(sd,RK_DRAGONTRAINING) || (sd->class_&MAPID_THIRDMASK) != MAPID_RUNE_KNIGHT )
script_pushint(st,0);//Doesn't have the skill or it's not a Rune Knight
else if ( pc_isridingdragon(sd) ) {//Is mounted; release
- iPc->setoption(sd, sd->sc.option&~OPTION_DRAGON);
+ pc->setoption(sd, sd->sc.option&~OPTION_DRAGON);
script_pushint(st,1);
} else {//Not mounted; Mount now.
unsigned int option = OPTION_DRAGON1;
@@ -16542,7 +16512,7 @@ BUILDIN(setdragon) {
option = OPTION_DRAGON1;
}
}
- iPc->setoption(sd, sd->sc.option|option);
+ pc->setoption(sd, sd->sc.option|option);
script_pushint(st,1);
}
return true;
@@ -16921,9 +16891,9 @@ BUILDIN(getrandgroupitem) {
for (i = 0; i < qty; i += get_count) {
// if not pet egg
if (!pet_create_egg(sd, nameid)) {
- if ((flag = iPc->additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT))) {
+ if ((flag = pc->additem(sd, &item_tmp, get_count, LOG_TYPE_SCRIPT))) {
clif->additem(sd, 0, 0, flag);
- if( iPc->candrop(sd,&item_tmp) )
+ if( pc->candrop(sd,&item_tmp) )
iMap->addflooritem(&item_tmp,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
}
}
@@ -17332,9 +17302,9 @@ BUILDIN(qiclear) {
bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st)) {
int n = add_str(name), i = 0;
- if( str_data[n].type == C_FUNC ) {
- str_data[n].func = func;
- i = str_data[n].val;
+ if( script->str_data[n].type == C_FUNC ) {
+ script->str_data[n].func = func;
+ i = script->str_data[n].val;
if( args ) {
int slen = strlen(args);
if( script->buildin[i] ) {
@@ -17350,9 +17320,9 @@ bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st)
} else {
i = script->buildin_count;
- str_data[n].type = C_FUNC;
- str_data[n].val = i;
- str_data[n].func = func;
+ script->str_data[n].type = C_FUNC;
+ script->str_data[n].val = i;
+ script->str_data[n].func = func;
RECREATE(script->buildin, char *, ++script->buildin_count);
@@ -17563,7 +17533,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(getcastledata,"si"),
BUILDIN_DEF(setcastledata,"sii"),
BUILDIN_DEF(requestguildinfo,"i?"),
- BUILDIN_DEF(getequipcardcnt,"i"),
+ BUILDIN_DEF(getequpcardcnt,"i"),
BUILDIN_DEF(successremovecards,"i"),
BUILDIN_DEF(failedremovecards,"ii"),
BUILDIN_DEF(marriage,"s"),
@@ -17864,12 +17834,12 @@ void script_parse_builtin(void) {
else if (!strcmp(BUILDIN[i].name, "callfunc")) buildin_callfunc_ref = n;
else if (!strcmp(BUILDIN[i].name, "getelementofarray") ) buildin_getelementofarray_ref = n;
- if( str_data[n].func && str_data[n].func != BUILDIN[i].func )
+ if( script->str_data[n].func && script->str_data[n].func != BUILDIN[i].func )
continue;/* something replaced it, skip. */
- str_data[n].type = C_FUNC;
- str_data[n].val = offset;
- str_data[n].func = BUILDIN[i].func;
+ script->str_data[n].type = C_FUNC;
+ script->str_data[n].val = offset;
+ script->str_data[n].func = BUILDIN[i].func;
/* we only store the arguments, its the only thing used out of this */
if( slen ) {
@@ -17895,6 +17865,13 @@ void script_defaults(void) {
script->buildin_count = 0;
script->buildin = NULL;
+ script->str_data = NULL;
+ script->str_data_size = 0;
+ script->str_num = LABEL_START;
+ script->str_buf = NULL;
+ script->str_size = 0;
+ script->str_pos = 0;
+
script->init = do_init_script;
script->final = do_final_script;
@@ -17903,6 +17880,12 @@ void script_defaults(void) {
script->conv_num = conv_num;
script->conv_str = conv_str;
script->rid2sd = script_rid2sd;
+ script->push_val = push_val;
+ script->get_val = get_val;
+ script->get_val2 = get_val2;
+ script->push_str = push_str;
+ script->push_copy = push_copy;
+ script->pop_stack = pop_stack;
script->queue = script_hqueue_get;
script->queue_add = script_hqueue_add;