diff options
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 2105 |
1 files changed, 1291 insertions, 814 deletions
diff --git a/src/map/script.c b/src/map/script.c index 88d8095e5..e38aae562 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -57,6 +57,7 @@ #include "map/status.h" #include "map/storage.h" #include "map/unit.h" +#include "map/achievement.h" #include "common/cbasetypes.h" #include "common/conf.h" #include "common/db.h" @@ -83,7 +84,7 @@ #include <sys/time.h> #endif -struct script_interface script_s; +static struct script_interface script_s; struct script_interface *script; static inline int GETVALUE(const struct script_buf *buf, int i) __attribute__((nonnull (1))); @@ -103,7 +104,8 @@ static inline void SETVALUE(struct script_buf *buf, int i, int n) VECTOR_INDEX(*buf, i+2) = GetByte(n, 2); } -const char* script_op2name(int op) { +const char *script_op2name(int op) +{ #define RETURN_OP_NAME(type) case type: return #type switch( op ) { RETURN_OP_NAME(C_NOP); @@ -162,7 +164,7 @@ const char* script_op2name(int op) { } #ifdef SCRIPT_DEBUG_DUMP_STACK -static void script_dump_stack(struct script_state* st) +static void script_dump_stack(struct script_state *st) { int i; nullpo_retv(st); @@ -205,7 +207,8 @@ static void script_dump_stack(struct script_state* st) #endif /// Reports on the console the src of a script error. -void script_reportsrc(struct script_state *st) { +static void script_reportsrc(struct script_state *st) +{ struct block_list* bl; nullpo_retv(st); @@ -236,7 +239,7 @@ void script_reportsrc(struct script_state *st) { } /// Reports on the console information about the script data. -void script_reportdata(struct script_data* data) +static void script_reportdata(struct script_data *data) { if( data == NULL ) return; @@ -278,7 +281,7 @@ void script_reportdata(struct script_data* data) } /// Reports on the console information about the current built-in function. -void script_reportfunc(struct script_state* st) +static void script_reportfunc(struct script_state *st) { int params, id; struct script_data* data; @@ -313,8 +316,9 @@ void script_reportfunc(struct script_state* st) /*========================================== * Output error message *------------------------------------------*/ -static void disp_error_message2(const char *mes,const char *pos,int report) __attribute__((nonnull (1))) analyzer_noreturn; -static void disp_error_message2(const char *mes,const char *pos,int report) { +static void disp_error_message2(const char *mes, const char *pos, int report) __attribute__((nonnull (1))) analyzer_noreturn; +static void disp_error_message2(const char *mes, const char *pos, int report) +{ script->error_msg = aStrdup(mes); script->error_pos = pos; script->error_report = report; @@ -322,12 +326,13 @@ static void disp_error_message2(const char *mes,const char *pos,int report) { } #define disp_error_message(mes,pos) (disp_error_message2((mes),(pos),1)) -void disp_warning_message(const char *mes, const char *pos) { +static void disp_warning_message(const char *mes, const char *pos) +{ script->warning(script->parser_current_src,script->parser_current_file,script->parser_current_line,mes,pos); } /// Checks event parameter validity -void check_event(struct script_state *st, const char *evt) +static void check_event(struct script_state *st, const char *evt) { if( evt && evt[0] && !stristr(evt, "::On") ) { @@ -339,7 +344,8 @@ void check_event(struct script_state *st, const char *evt) /*========================================== * Hashes the input string *------------------------------------------*/ -unsigned int calc_hash(const char* p) { +static unsigned int calc_hash(const char *p) +{ unsigned int h; nullpo_ret(p); @@ -374,7 +380,8 @@ unsigned int calc_hash(const char* p) { /*========================================== * Hashes the input string in a case insensitive way *------------------------------------------*/ -unsigned int calc_hash_ci(const char* p) { +static unsigned int calc_hash_ci(const char *p) +{ unsigned int h = 0; #ifdef ENABLE_CASE_CHECK @@ -413,14 +420,14 @@ unsigned int calc_hash_ci(const char* p) { *------------------------------------------*/ /// Looks up string using the provided id. -const char* script_get_str(int id) +static const char *script_get_str(int id) { Assert_retr(NULL, id >= LABEL_START && id < script->str_size); return script->str_buf+script->str_data[id].str; } /// Returns the uid of the string, or -1. -int script_search_str(const char* p) +static int script_search_str(const char *p) { int i; @@ -433,7 +440,7 @@ int script_search_str(const char* p) return -1; } -void script_casecheck_clear_sub(struct casecheck_data *ccd) +static void script_casecheck_clear_sub(struct casecheck_data *ccd) { #ifdef ENABLE_CASE_CHECK nullpo_retv(ccd); @@ -453,15 +460,17 @@ void script_casecheck_clear_sub(struct casecheck_data *ccd) #endif // ENABLE_CASE_CHECK } -void script_global_casecheck_clear(void) { +static void script_global_casecheck_clear(void) +{ script_casecheck_clear_sub(&script->global_casecheck); } -void script_local_casecheck_clear(void) { +static void script_local_casecheck_clear(void) +{ script_casecheck_clear_sub(&script->local_casecheck); } -const char *script_casecheck_add_str_sub(struct casecheck_data *ccd, const char *p) +static const char *script_casecheck_add_str_sub(struct casecheck_data *ccd, const char *p) { #ifdef ENABLE_CASE_CHECK int len; @@ -518,17 +527,19 @@ const char *script_casecheck_add_str_sub(struct casecheck_data *ccd, const char return NULL; } -const char *script_global_casecheck_add_str(const char *p) { +static const char *script_global_casecheck_add_str(const char *p) +{ return script_casecheck_add_str_sub(&script->global_casecheck, p); } -const char *script_local_casecheck_add_str(const char *p) { +static const char *script_local_casecheck_add_str(const char *p) +{ return script_casecheck_add_str_sub(&script->local_casecheck, p); } /// Stores a copy of the string and returns its id. /// If an identical string is already present, returns its id instead. -int script_add_str(const char* p) +static int script_add_str(const char *p) { int len, h = script->calc_hash(p); #ifdef ENABLE_CASE_CHECK @@ -607,7 +618,7 @@ int script_add_str(const char* p) * * @param a The byte to append. */ -void add_scriptb(int a) +static void add_scriptb(int a) { VECTOR_ENSURE(script->buf, 1, SCRIPT_BLOCK_SIZE); VECTOR_PUSH(script->buf, (uint8)a); @@ -622,7 +633,7 @@ void add_scriptb(int a) * * @param a The value to append. */ -void add_scriptc(int a) +static void add_scriptc(int a) { while( a >= 0x40 ) { @@ -642,7 +653,7 @@ void add_scriptc(int a) * * @param a The value to append. */ -void add_scripti(int a) +static void add_scripti(int a) { while( a >= 0x40 ) { @@ -657,7 +668,7 @@ void add_scripti(int a) * * @param l The id of the script->str_data entry (Maximum up to 16M) */ -void add_scriptl(int l) +static void add_scriptl(int l) { int backpatch = script->str_data[l].backpatch; @@ -695,7 +706,7 @@ void add_scriptl(int l) /*========================================== * Resolve the label *------------------------------------------*/ -void set_label(int l,int pos, const char* script_pos) +static void set_label(int l, int pos, const char *script_pos) { int i; @@ -719,7 +730,7 @@ void set_label(int l,int pos, const char* script_pos) } /// Skips spaces and/or comments. -const char* script_skip_space(const char* p) +static const char *script_skip_space(const char *p) { if( p == NULL ) return NULL; @@ -758,7 +769,7 @@ const char* script_skip_space(const char* p) /// Skips a word. /// A word consists of undercores and/or alphanumeric characters, /// and valid variable prefixes/postfixes. -const char* skip_word(const char* p) +static const char *skip_word(const char *p) { nullpo_retr(NULL, p); // prefix @@ -787,7 +798,8 @@ const char* skip_word(const char* p) /// Adds a word to script->str_data. /// @see skip_word /// @see script->add_str -int add_word(const char* p) { +static int add_word(const char *p) +{ size_t len; int i; @@ -813,8 +825,7 @@ int add_word(const char* p) { /// Parses a function call. /// The argument list can have parenthesis or not. /// The number of arguments is checked. -static -const char* parse_callfunc(const char* p, int require_paren, int is_custom) +static const char *parse_callfunc(const char *p, int require_paren, int is_custom) { const char *p2; char *arg = NULL; @@ -945,7 +956,7 @@ const char* parse_callfunc(const char* p, int require_paren, int is_custom) /// Processes end of logical script line. /// @param first When true, only fix up scheduling data is initialized /// @param p Script position for error reporting in set_label -void parse_nextline(bool first, const char* p) +static void parse_nextline(bool first, const char *p) { if( !first ) { @@ -963,7 +974,7 @@ void parse_nextline(bool first, const char* p) * Pushes a variable into stack, processing its array index if needed. * @see parse_variable */ -void parse_variable_sub_push(int word, const char *p2) +static void parse_variable_sub_push(int word, const char *p2) { if( p2 ) { const char* p3 = NULL; @@ -994,7 +1005,7 @@ void parse_variable_sub_push(int word, const char *p2) /// Parse a variable assignment using the direct equals operator /// @param p script position where the function should run from /// @return NULL if not a variable assignment, the new position otherwise -const char* parse_variable(const char* p) +static const char *parse_variable(const char *p) { int word; c_op type = C_NOP; @@ -1150,7 +1161,8 @@ const char* parse_variable(const char* p) * @param p Pointer to the string to check * @return Whether the string is a number literal */ -bool is_number(const char *p) { +static bool is_number(const char *p) +{ const char *np; if (!p) return false; @@ -1181,7 +1193,7 @@ bool is_number(const char *p) { * @param str The string to insert. * @return the string position in the script string list. */ -int script_string_dup(char *str) +static int script_string_dup(char *str) { int len; int pos = script->string_list_pos; @@ -1203,7 +1215,7 @@ int script_string_dup(char *str) /*========================================== * Analysis section *------------------------------------------*/ -const char *parse_simpleexpr(const char *p) +static const char *parse_simpleexpr(const char *p) { p=script->skip_space(p); @@ -1221,7 +1233,7 @@ const char *parse_simpleexpr(const char *p) } } -const char *parse_simpleexpr_paren(const char *p) +static const char *parse_simpleexpr_paren(const char *p) { int i = script->syntax.curly_count - 1; nullpo_retr(NULL, p); @@ -1248,7 +1260,7 @@ const char *parse_simpleexpr_paren(const char *p) return p + 1; } -const char *parse_simpleexpr_number(const char *p) +static const char *parse_simpleexpr_number(const char *p) { char *np = NULL; long long lli; @@ -1270,7 +1282,7 @@ const char *parse_simpleexpr_number(const char *p) return np; } -const char *parse_simpleexpr_string(const char *p) +static const char *parse_simpleexpr_string(const char *p) { const char *start_point = p; @@ -1311,7 +1323,7 @@ const char *parse_simpleexpr_string(const char *p) return p; } -const char *parse_simpleexpr_name(const char *p) +static const char *parse_simpleexpr_name(const char *p) { int l; const char *pv = NULL; @@ -1361,7 +1373,7 @@ const char *parse_simpleexpr_name(const char *p) return p; } -void script_add_translatable_string(const struct script_string_buf *string, const char *start_point) +static void script_add_translatable_string(const struct script_string_buf *string, const char *start_point) { struct string_translation *st = NULL; @@ -1401,7 +1413,7 @@ void script_add_translatable_string(const struct script_string_buf *string, cons /*========================================== * Analysis of the expression *------------------------------------------*/ -const char* script_parse_subexpr(const char* p,int limit) +static const char *script_parse_subexpr(const char *p, int limit) { int op,opl,len; @@ -1428,8 +1440,8 @@ const char* script_parse_subexpr(const char* p,int limit) p=script->skip_space(p); while(( (op=C_OP3, opl=0, len=1,*p=='?') // ?: - || (op=C_ADD, opl=9, len=1,*p=='+') // + - || (op=C_SUB, opl=9, len=1,*p=='-') // - + || (op=C_ADD, opl=9, len=1,*p=='+' && p[1]!='+') // + + || (op=C_SUB, opl=9, len=1,*p=='-' && p[1]!='-') // - || (op=C_POW, opl=11,len=2,*p=='*' && p[1]=='*') // ** || (op=C_MUL, opl=10,len=1,*p=='*') // * || (op=C_DIV, opl=10,len=1,*p=='/') // / @@ -1470,7 +1482,7 @@ const char* script_parse_subexpr(const char* p,int limit) /*========================================== * Evaluation of the expression *------------------------------------------*/ -const char* parse_expr(const char *p) +static const char *parse_expr(const char *p) { nullpo_retr(NULL, p); switch(*p) { @@ -1485,7 +1497,7 @@ const char* parse_expr(const char *p) /*========================================== * Analysis of the line *------------------------------------------*/ -const char* parse_line(const char* p) +static const char *parse_line(const char *p) { const char* p2; @@ -1548,7 +1560,7 @@ const char* parse_line(const char* p) } // { ... } Closing process -const char* parse_curly_close(const char* p) +static const char *parse_curly_close(const char *p) { nullpo_retr(NULL, p); if(script->syntax.curly_count <= 0) { @@ -1607,7 +1619,7 @@ 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. -const char* parse_syntax(const char* p) +static const char *parse_syntax(const char *p) { const char *p2 = script->skip_word(p); @@ -2037,7 +2049,8 @@ const char* parse_syntax(const char* p) return NULL; } -const char* parse_syntax_close(const char *p) { +static const char *parse_syntax_close(const char *p) +{ // If (...) for (...) hoge (); as to make sure closed closed once again int flag; @@ -2051,7 +2064,7 @@ const char* parse_syntax_close(const char *p) { // Close judgment if, for, while, of do // flag == 1 : closed // flag == 0 : not closed -const char* parse_syntax_close_sub(const char* p,int* flag) +static const char *parse_syntax_close_sub(const char *p, int *flag) { char label[256]; int pos = script->syntax.curly_count - 1; @@ -2224,7 +2237,7 @@ const char* parse_syntax_close_sub(const char* p,int* flag) } /// Retrieves the value of a constant. -bool script_get_constant(const char* name, int* value) +static bool script_get_constant(const char *name, int *value) { int n = script->search_str(name); @@ -2242,11 +2255,11 @@ bool script_get_constant(const char* name, int* value) } /// Creates new constant or parameter with given value. -void script_set_constant(const char *name, int value, bool is_parameter, bool is_deprecated) +static void script_set_constant(const char *name, int value, bool is_parameter, bool is_deprecated) { int n = script->add_str(name); - if( script->str_data[n].type == C_NOP ) {// new + if (script->str_data[n].type == C_NOP) { script->str_data[n].type = is_parameter ? C_PARAM : C_INT; script->str_data[n].val = value; script->str_data[n].deprecated = is_deprecated ? 1 : 0; @@ -2257,7 +2270,7 @@ void script_set_constant(const char *name, int value, bool is_parameter, bool is } } /* adds data to a existent constant in the database, inserted normally via parse */ -void script_set_constant2(const char *name, int value, bool is_parameter, bool is_deprecated) +static void script_set_constant2(const char *name, int value, bool is_parameter, bool is_deprecated) { int n = script->add_str(name); @@ -2290,7 +2303,7 @@ void script_set_constant2(const char *name, int value, bool is_parameter, bool i /** * Loads the constants database from constants.conf */ -void read_constdb(void) +static void read_constdb(bool reload) { struct config_t constants_conf; char filepath[256]; @@ -2309,7 +2322,6 @@ void read_constdb(void) } while ((t = libconfig->setting_get_elem(cdb, i++))) { - bool is_parameter = false; bool is_deprecated = false; int value = 0; const char *name = config_setting_name(t); @@ -2340,10 +2352,6 @@ void read_constdb(void) continue; } value = i32; - if (libconfig->setting_lookup_bool(t, "Parameter", &i32)) { - if (i32 != 0) - is_parameter = true; - } if (libconfig->setting_lookup_bool(t, "Deprecated", &i32)) { if (i32 != 0) is_deprecated = true; @@ -2351,9 +2359,13 @@ void read_constdb(void) } else { value = libconfig->setting_get_int(t); } - if (is_parameter) - ShowWarning("read_constdb: Defining parameters in the constants configuration is deprecated and will no longer be possible in a future version. Parameters should be defined in source. (parameter = '%s')\n", name); - script->set_constant(name, value, is_parameter, is_deprecated); + + if (reload) { + int n = script->add_str(name); + script->str_data[n].type = C_NOP; // ensures it will be overwritten + } + + script->set_constant(name, value, false, is_deprecated); } script->constdb_comment(NULL); libconfig->destroy(&constants_conf); @@ -2366,12 +2378,12 @@ void read_constdb(void) * * @param comment The comment to set (NULL to unset) */ -void script_constdb_comment(const char *comment) +static void script_constdb_comment(const char *comment) { (void)comment; } -void script_load_parameters(void) +static void script_load_parameters(void) { int i = 0; struct { @@ -2426,7 +2438,7 @@ void script_load_parameters(void) /*========================================== * Display emplacement line of script *------------------------------------------*/ -const char* script_print_line(StringBuf* buf, const char* p, const char* mark, int line) +static const char *script_print_line(StringBuf *buf, const char *p, const char *mark, int line) { int i, mark_pos = 0, tabstop = TAB_SIZE; if( p == NULL || !p[0] ) return NULL; @@ -2465,7 +2477,8 @@ const char* script_print_line(StringBuf* buf, const char* p, const char* mark, i #undef update_tabstop #define CONTEXTLINES 3 -void script_errorwarning_sub(StringBuf *buf, const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos) { +static void script_errorwarning_sub(StringBuf *buf, const char *src, const char *file, int start_line, const char *error_msg, const char *error_pos) +{ // Find the line where the error occurred int j; int line = start_line; @@ -2501,7 +2514,8 @@ void script_errorwarning_sub(StringBuf *buf, const char* src, const char* file, } #undef CONTEXTLINES -void script_error(const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos) { +static void script_error(const char *src, const char *file, int start_line, const char *error_msg, const char *error_pos) +{ StringBuf buf; StrBuf->Init(&buf); @@ -2513,7 +2527,8 @@ void script_error(const char* src, const char* file, int start_line, const char* StrBuf->Destroy(&buf); } -void script_warning(const char* src, const char* file, int start_line, const char* error_msg, const char* error_pos) { +static void script_warning(const char *src, const char *file, int start_line, const char *error_msg, const char *error_pos) +{ StringBuf buf; StrBuf->Init(&buf); @@ -2527,7 +2542,8 @@ void script_warning(const char* src, const char* file, int start_line, const cha /*========================================== * Analysis of the script *------------------------------------------*/ -struct script_code* parse_script(const char *src,const char *file,int line,int options, int *retval) { +static struct script_code *parse_script(const char *src, const char *file, int line, int options, int *retval) +{ const char *p,*tmpp; int i; struct script_code* code = NULL; @@ -2741,7 +2757,7 @@ struct script_code* parse_script(const char *src,const char *file,int line,int o /// Returns the player attached to this script, identified by the rid. /// If there is no player attached, the script is terminated. -struct map_session_data *script_rid2sd(struct script_state *st) +static struct map_session_data *script_rid2sd(struct script_state *st) { struct map_session_data *sd; nullpo_retr(NULL, st); @@ -2754,7 +2770,7 @@ struct map_session_data *script_rid2sd(struct script_state *st) return sd; } -struct map_session_data *script_id2sd(struct script_state *st, int account_id) +static struct map_session_data *script_id2sd(struct script_state *st, int account_id) { struct map_session_data *sd; if ((sd = map->id2sd(account_id)) == NULL) { @@ -2765,7 +2781,7 @@ struct map_session_data *script_id2sd(struct script_state *st, int account_id) return sd; } -struct map_session_data *script_charid2sd(struct script_state *st, int char_id) +static struct map_session_data *script_charid2sd(struct script_state *st, int char_id) { struct map_session_data *sd; if ((sd = map->charid2sd(char_id)) == NULL) { @@ -2776,7 +2792,7 @@ struct map_session_data *script_charid2sd(struct script_state *st, int char_id) return sd; } -struct map_session_data *script_nick2sd(struct script_state *st, const char *name) +static struct map_session_data *script_nick2sd(struct script_state *st, const char *name) { struct map_session_data *sd; if ((sd = map->nick2sd(name)) == NULL) { @@ -2787,14 +2803,16 @@ struct map_session_data *script_nick2sd(struct script_state *st, const char *nam return sd; } -char *get_val_npcscope_str(struct script_state* st, struct reg_db *n, struct script_data* data) { +static char *get_val_npcscope_str(struct script_state *st, struct reg_db *n, struct script_data *data) +{ if (n) return (char*)i64db_get(n->vars, reference_getuid(data)); else return NULL; } -char *get_val_pc_ref_str(struct script_state *st, struct reg_db *n, struct script_data *data) { +static char *get_val_pc_ref_str(struct script_state *st, struct reg_db *n, struct script_data *data) +{ struct script_reg_str *p = NULL; nullpo_retr(NULL, n); @@ -2802,7 +2820,8 @@ char *get_val_pc_ref_str(struct script_state *st, struct reg_db *n, struct scrip return p ? p->value : NULL; } -char *get_val_instance_str(struct script_state* st, const char* name, struct script_data* data) { +static char *get_val_instance_str(struct script_state *st, const char *name, struct script_data *data) +{ nullpo_retr(NULL, st); if (st->instance_id >= 0) { return (char*)i64db_get(instance->list[st->instance_id].regs.vars, reference_getuid(data)); @@ -2812,14 +2831,16 @@ char *get_val_instance_str(struct script_state* st, const char* name, struct scr } } -int get_val_npcscope_num(struct script_state* st, struct reg_db *n, struct script_data* data) { +static int get_val_npcscope_num(struct script_state *st, struct reg_db *n, struct script_data *data) +{ if (n) return (int)i64db_iget(n->vars, reference_getuid(data)); else return 0; } -int get_val_pc_ref_num(struct script_state *st, struct reg_db *n, struct script_data *data) { +static int get_val_pc_ref_num(struct script_state *st, struct reg_db *n, struct script_data *data) +{ struct script_reg_num *p = NULL; nullpo_retr(0, n); @@ -2827,7 +2848,8 @@ int get_val_pc_ref_num(struct script_state *st, struct reg_db *n, struct script_ return p ? p->value : 0; } -int get_val_instance_num(struct script_state* st, const char* name, struct script_data* data) { +static int get_val_instance_num(struct script_state *st, const char *name, struct script_data *data) +{ if (st->instance_id >= 0) return (int)i64db_iget(instance->list[st->instance_id].regs.vars, reference_getuid(data)); else { @@ -2843,7 +2865,8 @@ int get_val_instance_num(struct script_state* st, const char* name, struct scrip * @param data[in,out] variable/constant. * @return pointer to data, for convenience. */ -struct script_data *get_val(struct script_state* st, struct script_data* data) { +static struct script_data *get_val(struct script_state *st, struct script_data *data) +{ const char* name; char prefix; char postfix; @@ -3000,7 +3023,7 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) { * @param ref[in] the container to look up the reference into. * @return the retrieved value of the reference. */ -const void *get_val2(struct script_state *st, int64 uid, struct reg_db *ref) +static const void *get_val2(struct script_state *st, int64 uid, struct reg_db *ref) { struct script_data* data; nullpo_retr(NULL, st); @@ -3016,7 +3039,8 @@ const void *get_val2(struct script_state *st, int64 uid, struct reg_db *ref) * Because, currently, array members with key 0 are indifferenciable from normal variables, we should ensure its actually in * Will be gone as soon as undefined var feature is implemented **/ -void script_array_ensure_zero(struct script_state *st, struct map_session_data *sd, int64 uid, struct reg_db *ref) { +static void script_array_ensure_zero(struct script_state *st, struct map_session_data *sd, int64 uid, struct reg_db *ref) +{ const char *name = script->get_str(script_getvarid(uid)); struct reg_db *src = NULL; bool insert = false; @@ -3063,7 +3087,8 @@ void script_array_ensure_zero(struct script_state *st, struct map_session_data * /** * Returns array size by ID **/ -unsigned int script_array_size(struct script_state *st, struct map_session_data *sd, const char *name, struct reg_db *ref) { +static unsigned int script_array_size(struct script_state *st, struct map_session_data *sd, const char *name, struct reg_db *ref) +{ struct script_array *sa = NULL; struct reg_db *src = script->array_src(st, sd, name, ref); @@ -3075,7 +3100,8 @@ unsigned int script_array_size(struct script_state *st, struct map_session_data /** * Returns array's highest key (for that awful getarraysize implementation that doesn't really gets the array size) **/ -unsigned int script_array_highest_key(struct script_state *st, struct map_session_data *sd, const char *name, struct reg_db *ref) { +static unsigned int script_array_highest_key(struct script_state *st, struct map_session_data *sd, const char *name, struct reg_db *ref) +{ struct script_array *sa = NULL; struct reg_db *src = script->array_src(st, sd, name, ref); @@ -3096,7 +3122,7 @@ unsigned int script_array_highest_key(struct script_state *st, struct map_sessio } return 0; } -int script_free_array_db(union DBKey key, struct DBData *data, va_list ap) +static int script_free_array_db(union DBKey key, struct DBData *data, va_list ap) { struct script_array *sa = DB->data2ptr(data); aFree(sa->members); @@ -3106,7 +3132,8 @@ int script_free_array_db(union DBKey key, struct DBData *data, va_list ap) /** * Clears script_array and removes it from script->array_db **/ -void script_array_delete(struct reg_db *src, struct script_array *sa) { +static void script_array_delete(struct reg_db *src, struct script_array *sa) +{ nullpo_retv(src); nullpo_retv(sa); aFree(sa->members); @@ -3118,7 +3145,8 @@ void script_array_delete(struct reg_db *src, struct script_array *sa) { * * @param idx the index of the member in script_array struct list, not of the actual array member **/ -void script_array_remove_member(struct reg_db *src, struct script_array *sa, unsigned int idx) { +static void script_array_remove_member(struct reg_db *src, struct script_array *sa, unsigned int idx) +{ unsigned int i, cursor; nullpo_retv(sa); @@ -3145,7 +3173,8 @@ void script_array_remove_member(struct reg_db *src, struct script_array *sa, uns * * @param idx the index of the array member being inserted **/ -void script_array_add_member(struct script_array *sa, unsigned int idx) { +static void script_array_add_member(struct script_array *sa, unsigned int idx) +{ nullpo_retv(sa); RECREATE(sa->members, unsigned int, ++sa->size); sa->members[sa->size - 1] = idx; @@ -3154,7 +3183,8 @@ void script_array_add_member(struct script_array *sa, unsigned int idx) { * Obtains the source of the array database for this type and scenario * Initializes such database when not yet initialized. **/ -struct reg_db *script_array_src(struct script_state *st, struct map_session_data *sd, const char *name, struct reg_db *ref) { +static struct reg_db *script_array_src(struct script_state *st, struct map_session_data *sd, const char *name, struct reg_db *ref) +{ struct reg_db *src = NULL; nullpo_retr(NULL, name); @@ -3205,7 +3235,8 @@ struct reg_db *script_array_src(struct script_state *st, struct map_session_data * @param num[in] Variable ID * @param empty[in] Whether the modified member is empty (needs to be removed) **/ -void script_array_update(struct reg_db *src, int64 num, bool empty) { +static void script_array_update(struct reg_db *src, int64 num, bool empty) +{ struct script_array *sa = NULL; int id = script_getvarid(num); unsigned int index = script_getvaridx(num); @@ -3246,7 +3277,7 @@ void script_array_update(struct reg_db *src, int64 num, bool empty) { } } -void set_reg_npcscope_str(struct script_state* st, struct reg_db *n, int64 num, const char* name, const char *str) +static void set_reg_npcscope_str(struct script_state *st, struct reg_db *n, int64 num, const char *name, const char *str) { if (n) { @@ -3263,7 +3294,7 @@ void set_reg_npcscope_str(struct script_state* st, struct reg_db *n, int64 num, } } -void set_reg_pc_ref_str(struct script_state *st, struct reg_db *n, int64 num, const char *name, const char *str) +static void set_reg_pc_ref_str(struct script_state *st, struct reg_db *n, int64 num, const char *name, const char *str) { struct script_reg_str *p = NULL; unsigned int index = script_getvaridx(num); @@ -3312,7 +3343,7 @@ void set_reg_pc_ref_str(struct script_state *st, struct reg_db *n, int64 num, co } } -void set_reg_pc_ref_num(struct script_state *st, struct reg_db *n, int64 num, const char *name, int val) +static void set_reg_pc_ref_num(struct script_state *st, struct reg_db *n, int64 num, const char *name, int val) { struct script_reg_num *p = NULL; unsigned int index = script_getvaridx(num); @@ -3356,7 +3387,7 @@ void set_reg_pc_ref_num(struct script_state *st, struct reg_db *n, int64 num, co } } -void set_reg_npcscope_num(struct script_state* st, struct reg_db *n, int64 num, const char* name, int val) +static void set_reg_npcscope_num(struct script_state *st, struct reg_db *n, int64 num, const char *name, int val) { if (n) { if (val != 0) { @@ -3371,7 +3402,7 @@ void set_reg_npcscope_num(struct script_state* st, struct reg_db *n, int64 num, } } -void set_reg_instance_str(struct script_state* st, int64 num, const char* name, const char *str) +static void set_reg_instance_str(struct script_state *st, int64 num, const char *name, const char *str) { nullpo_retv(st); if (st->instance_id >= 0) { @@ -3390,7 +3421,7 @@ void set_reg_instance_str(struct script_state* st, int64 num, const char* name, } } -void set_reg_instance_num(struct script_state* st, int64 num, const char* name, int val) +static void set_reg_instance_num(struct script_state *st, int64 num, const char *name, int val) { nullpo_retv(st); if (st->instance_id >= 0) { @@ -3423,7 +3454,7 @@ void set_reg_instance_num(struct script_state* st, int64 num, const char* name, * * TODO: return values are screwed up, have been for some time (reaad: years), e.g. some functions return 1 failure and success. *------------------------------------------*/ -int set_reg(struct script_state *st, struct map_session_data *sd, int64 num, const char *name, const void *value, struct reg_db *ref) +static int set_reg(struct script_state *st, struct map_session_data *sd, int64 num, const char *name, const void *value, struct reg_db *ref) { char prefix; nullpo_ret(name); @@ -3546,18 +3577,18 @@ int set_reg(struct script_state *st, struct map_session_data *sd, int64 num, con } } -int set_var(struct map_session_data *sd, char *name, void *val) +static int set_var(struct map_session_data *sd, char *name, void *val) { return script->set_reg(NULL, sd, reference_uid(script->add_str(name),0), name, val, NULL); } -void setd_sub(struct script_state *st, struct map_session_data *sd, const char *varname, int elem, const void *value, struct reg_db *ref) +static void setd_sub(struct script_state *st, struct map_session_data *sd, const char *varname, int elem, const void *value, struct reg_db *ref) { script->set_reg(st, sd, reference_uid(script->add_str(varname),elem), varname, value, ref); } /// Converts the data to a string -const char *conv_str(struct script_state *st, struct script_data* data) +static const char *conv_str(struct script_state *st, struct script_data *data) { script->get_val(st, data); if (data_isstring(data)) { @@ -3591,7 +3622,7 @@ const char *conv_str(struct script_state *st, struct script_data* data) } /// Converts the data to an int -int conv_num(struct script_state *st, struct script_data *data) +static int conv_num(struct script_state *st, struct script_data *data) { long num; @@ -3649,7 +3680,8 @@ int conv_num(struct script_state *st, struct script_data *data) // /// Increases the size of the stack -void stack_expand(struct script_stack* stack) { +static void stack_expand(struct script_stack *stack) +{ nullpo_retv(stack); stack->sp_max += 64; stack->stack_data = (struct script_data*)aRealloc(stack->stack_data, @@ -3659,7 +3691,8 @@ void stack_expand(struct script_stack* stack) { } /// Pushes a value into the stack (with reference) -struct script_data* push_val(struct script_stack* stack, enum c_op type, int64 val, struct reg_db *ref) { +static struct script_data *push_val(struct script_stack *stack, enum c_op type, int64 val, struct reg_db *ref) +{ nullpo_retr(NULL, stack); if( stack->sp >= stack->sp_max ) script->stack_expand(stack); @@ -3671,7 +3704,7 @@ struct script_data* push_val(struct script_stack* stack, enum c_op type, int64 v } /// Pushes a string into the stack -struct script_data *push_str(struct script_stack *stack, char *str) +static struct script_data *push_str(struct script_stack *stack, char *str) { nullpo_retr(NULL, stack); if( stack->sp >= stack->sp_max ) @@ -3684,7 +3717,7 @@ struct script_data *push_str(struct script_stack *stack, char *str) } /// Pushes a constant string into the stack -struct script_data *push_conststr(struct script_stack *stack, const char *str) +static struct script_data *push_conststr(struct script_stack *stack, const char *str) { nullpo_retr(NULL, stack); if( stack->sp >= stack->sp_max ) @@ -3697,7 +3730,8 @@ struct script_data *push_conststr(struct script_stack *stack, const char *str) } /// Pushes a retinfo into the stack -struct script_data* push_retinfo(struct script_stack* stack, struct script_retinfo* ri, struct reg_db *ref) { +static struct script_data *push_retinfo(struct script_stack *stack, struct script_retinfo *ri, struct reg_db *ref) +{ nullpo_retr(NULL, stack); if( stack->sp >= stack->sp_max ) script->stack_expand(stack); @@ -3709,7 +3743,8 @@ 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) { +static struct script_data *push_copy(struct script_stack *stack, int pos) +{ nullpo_retr(NULL, stack); switch( stack->stack_data[pos].type ) { case C_CONSTSTR: @@ -3734,7 +3769,8 @@ struct script_data* push_copy(struct script_stack* stack, int pos) { /// Removes the values in indexes [start,end[ from the stack. /// Adjusts all stack pointers. -void pop_stack(struct script_state* st, int start, int end) { +static void pop_stack(struct script_state *st, int start, int end) +{ struct script_stack* stack; struct script_data* data; int i; @@ -3806,7 +3842,7 @@ void pop_stack(struct script_state* st, int start, int end) { /*========================================== * Release script dependent variable, dependent variable of function *------------------------------------------*/ -void script_free_vars(struct DBMap *var_storage) +static void script_free_vars(struct DBMap *var_storage) { if( var_storage ) { // destroy the storage construct containing the variables @@ -3814,7 +3850,7 @@ void script_free_vars(struct DBMap *var_storage) } } -void script_free_code(struct script_code* code) +static void script_free_code(struct script_code *code) { nullpo_retv(code); @@ -3834,7 +3870,8 @@ void script_free_code(struct script_code* code) /// @param rid Who is running the script (attached player) /// @param oid Where the code is being run (npc 'object') /// @return Script state -struct script_state* script_alloc_state(struct script_code* rootscript, int pos, int rid, int oid) { +static struct script_state *script_alloc_state(struct script_code *rootscript, int pos, int rid, int oid) +{ struct script_state* st; st = ers_alloc(script->st_ers, struct script_state); @@ -3876,7 +3913,8 @@ struct script_state* script_alloc_state(struct script_code* rootscript, int pos, /// Frees a script state. /// /// @param st Script state -void script_free_state(struct script_state* st) { +static void script_free_state(struct script_state *st) +{ nullpo_retv(st); if( idb_exists(script->st_db,st->id) ) { struct map_session_data *sd = st->rid ? map->id2sd(st->rid) : NULL; @@ -3938,7 +3976,8 @@ void script_free_state(struct script_state* st) { * @param st[in] Script state. * @param ref[in] Reference to be added. */ -void script_add_pending_ref(struct script_state *st, struct reg_db *ref) { +static void script_add_pending_ref(struct script_state *st, struct reg_db *ref) +{ nullpo_retv(st); RECREATE(st->pending_refs, struct reg_db*, ++st->pending_ref_count); st->pending_refs[st->pending_ref_count-1] = ref; @@ -3950,7 +3989,7 @@ void script_add_pending_ref(struct script_state *st, struct reg_db *ref) { /*========================================== * Read command *------------------------------------------*/ -c_op get_com(const struct script_buf *scriptbuf, int *pos) +static c_op get_com(const struct script_buf *scriptbuf, int *pos) { int i = 0, j = 0; @@ -3967,7 +4006,7 @@ c_op get_com(const struct script_buf *scriptbuf, int *pos) /*========================================== * Income figures *------------------------------------------*/ -int get_num(const struct script_buf *scriptbuf, int *pos) +static int get_num(const struct script_buf *scriptbuf, int *pos) { int i,j; i=0; j=0; @@ -3980,7 +4019,7 @@ int get_num(const struct script_buf *scriptbuf, int *pos) /// Ternary operators /// test ? if_true : if_false -void op_3(struct script_state* st, int op) +static void op_3(struct script_state *st, int op) { struct script_data* data; int flag = 0; @@ -4017,7 +4056,7 @@ void op_3(struct script_state* st, int op) /// s1 RE_EQ s2 -> i /// s1 RE_NE s2 -> i /// s1 ADD s2 -> s -void op_2str(struct script_state* st, int op, const char* s1, const char* s2) +static void op_2str(struct script_state *st, int op, const char *s1, const char *s2) { int a = 0; @@ -4114,7 +4153,7 @@ void op_2str(struct script_state* st, int op, const char* s1, const char* s2) /// Binary number operators /// i OP i -> i -void op_2num(struct script_state* st, int op, int i1, int i2) +static void op_2num(struct script_state *st, int op, int i1, int i2) { int ret; int64 ret64; @@ -4174,7 +4213,7 @@ void op_2num(struct script_state* st, int op, int i1, int i2) } /// Binary operators -void op_2(struct script_state *st, int op) +static void op_2(struct script_state *st, int op) { struct script_data* left, leftref; struct script_data* right; @@ -4248,7 +4287,7 @@ void op_2(struct script_state *st, int op) /// NEG i -> i /// NOT i -> i /// LNOT i -> i -void op_1(struct script_state* st, int op) +static void op_1(struct script_state *st, int op) { struct script_data* data; int i1; @@ -4286,7 +4325,7 @@ void op_1(struct script_state* st, int op) /// /// @param st Script state whose stack arguments should be inspected. /// @param func Built-in function for which the arguments are intended. -bool script_check_buildin_argtype(struct script_state* st, int func) +static bool script_check_buildin_argtype(struct script_state *st, int func) { int idx, invalid = 0; char* sf; @@ -4372,7 +4411,7 @@ bool script_check_buildin_argtype(struct script_state* st, int func) /// Executes a buildin command. /// Stack: C_NAME(<command>) C_ARG <arg0> <arg1> ... <argN> -int run_func(struct script_state *st) +static int run_func(struct script_state *st) { struct script_data* data; int i,start_sp,end_sp,func; @@ -4465,7 +4504,8 @@ int run_func(struct script_state *st) /*========================================== * script execution *------------------------------------------*/ -void run_script(struct script_code *rootscript, int pos, int rid, int oid) { +static void run_script(struct script_code *rootscript, int pos, int rid, int oid) +{ struct script_state *st; if( rootscript == NULL || pos < 0 ) @@ -4479,7 +4519,7 @@ void run_script(struct script_code *rootscript, int pos, int rid, int oid) { script->run_main(st); } -void script_stop_instances(struct script_code *code) +static void script_stop_instances(struct script_code *code) { struct DBIterator *iter; struct script_state* st; @@ -4501,7 +4541,8 @@ void script_stop_instances(struct script_code *code) /*========================================== * Timer function for sleep *------------------------------------------*/ -int run_script_timer(int tid, int64 tick, int id, intptr_t data) { +static int run_script_timer(int tid, int64 tick, int id, intptr_t data) +{ struct script_state *st = idb_get(script->st_db,(int)data); if( st ) { struct map_session_data *sd = map->id2sd(st->rid); @@ -4522,7 +4563,8 @@ int run_script_timer(int tid, int64 tick, int id, intptr_t data) { /// /// @param st Script state to detach. /// @param dequeue_event Whether to schedule any queued events, when there was no previous script. -void script_detach_state(struct script_state* st, bool dequeue_event) { +static void script_detach_state(struct script_state *st, bool dequeue_event) +{ struct map_session_data* sd; nullpo_retv(st); @@ -4556,7 +4598,8 @@ void script_detach_state(struct script_state* st, bool dequeue_event) { /// Attaches script state to possibly attached character and backups it's previous script, if any. /// /// @param st Script state to attach. -void script_attach_state(struct script_state* st) { +static void script_attach_state(struct script_state *st) +{ struct map_session_data* sd; nullpo_retv(st); @@ -4588,7 +4631,8 @@ void script_attach_state(struct script_state* st) { /*========================================== * The main part of the script execution *------------------------------------------*/ -void run_script_main(struct script_state *st) { +static void run_script_main(struct script_state *st) +{ int cmdcount = script->config.check_cmdcount; int gotocount = script->config.check_gotocount; struct map_session_data *sd; @@ -4778,7 +4822,7 @@ void run_script_main(struct script_state *st) { * * @retval false in case of error. */ -bool script_config_read(const char *filename, bool imported) +static bool script_config_read(const char *filename, bool imported) { struct config_t config; struct config_setting_t * setting = NULL; @@ -4825,7 +4869,7 @@ bool script_config_read(const char *filename, bool imported) /** * @see DBApply */ -int db_script_free_code_sub(union DBKey key, struct DBData *data, va_list ap) +static int db_script_free_code_sub(union DBKey key, struct DBData *data, va_list ap) { struct script_code *code = DB->data2ptr(data); if (code) @@ -4833,7 +4877,7 @@ int db_script_free_code_sub(union DBKey key, struct DBData *data, va_list ap) return 0; } -void script_run_autobonus(const char *autobonus, int id, int pos) +static void script_run_autobonus(const char *autobonus, int id, int pos) { struct script_code *scriptroot = (struct script_code *)strdb_get(script->autobonus_db, autobonus); @@ -4843,7 +4887,7 @@ void script_run_autobonus(const char *autobonus, int id, int pos) } } -void script_add_autobonus(const char *autobonus) +static void script_add_autobonus(const char *autobonus) { if( strdb_get(script->autobonus_db, autobonus) == NULL ) { struct script_code *scriptroot = script->parse(autobonus, "autobonus", 0, 0, NULL); @@ -4854,7 +4898,8 @@ void script_add_autobonus(const char *autobonus) } /// resets a temporary character array variable to given value -void script_cleararray_pc(struct map_session_data* sd, const char* varname, void* value) { +static void script_cleararray_pc(struct map_session_data *sd, const char *varname, void *value) +{ struct script_array *sa = NULL; struct reg_db *src = NULL; unsigned int i, *list = NULL, size = 0; @@ -4881,10 +4926,11 @@ void script_cleararray_pc(struct map_session_data* sd, const char* varname, void /// sets a temporary character array variable element idx to given value /// @param refcache Pointer to an int variable, which keeps a copy of the reference to varname and must be initialized to 0. Can be NULL if only one element is set. -void script_setarray_pc(struct map_session_data* sd, const char* varname, uint32 idx, void* value, int* refcache) { +static void script_setarray_pc(struct map_session_data *sd, const char *varname, uint32 idx, void *value, int *refcache) +{ int key; - if( idx >= SCRIPT_MAX_ARRAYSIZE ) { + if (idx > SCRIPT_MAX_ARRAYSIZE) { ShowError("script_setarray_pc: Variable '%s' has invalid index '%u' (char_id=%d).\n", varname, idx, sd->status.char_id); return; } @@ -4901,7 +4947,7 @@ void script_setarray_pc(struct map_session_data* sd, const char* varname, uint32 /** * Clears persistent variables from memory **/ -int script_reg_destroy(union DBKey key, struct DBData *data, va_list ap) +static int script_reg_destroy(union DBKey key, struct DBData *data, va_list ap) { struct script_reg_state *src; @@ -4926,7 +4972,8 @@ int script_reg_destroy(union DBKey key, struct DBData *data, va_list ap) /** * Clears a single persistent variable **/ -void script_reg_destroy_single(struct map_session_data *sd, int64 reg, struct script_reg_state *data) { +static void script_reg_destroy_single(struct map_session_data *sd, int64 reg, struct script_reg_state *data) +{ nullpo_retv(sd); nullpo_retv(data); i64db_remove(sd->regs.vars, reg); @@ -4942,21 +4989,23 @@ void script_reg_destroy_single(struct map_session_data *sd, int64 reg, struct sc ers_free(pc->num_reg_ers,(struct script_reg_num*)data); } } -unsigned int *script_array_cpy_list(struct script_array *sa) { +static unsigned int *script_array_cpy_list(struct script_array *sa) +{ nullpo_retr(NULL, sa); if( sa->size > script->generic_ui_array_size ) script->generic_ui_array_expand(sa->size); memcpy(script->generic_ui_array, sa->members, sizeof(unsigned int)*sa->size); return script->generic_ui_array; } -void script_generic_ui_array_expand (unsigned int plus) { +static void script_generic_ui_array_expand(unsigned int plus) +{ script->generic_ui_array_size += plus + 100; RECREATE(script->generic_ui_array, unsigned int, script->generic_ui_array_size); } /*========================================== * Destructor *------------------------------------------*/ -void do_final_script(void) +static void do_final_script(void) { int i; struct DBIterator *iter; @@ -5091,7 +5140,8 @@ void do_final_script(void) /** * **/ -uint8 script_add_language(const char *name) { +static uint8 script_add_language(const char *name) +{ uint8 lang_id = script->max_lang_id; nullpo_ret(name); @@ -5103,7 +5153,8 @@ uint8 script_add_language(const char *name) { /** * Goes thru db/translations.conf file **/ -void script_load_translations(void) { +static void script_load_translations(void) +{ struct config_t translations_conf; const char *config_filename = "db/translations.conf"; // FIXME hardcoded name struct config_setting_t *translations = NULL; @@ -5187,7 +5238,7 @@ void script_load_translations(void) { * @param file The filename. * @return The corresponding translation name. */ -const char *script_get_translation_file_name(const char *file) +static const char *script_get_translation_file_name(const char *file) { const char *basename = NULL, *last_dot = NULL; @@ -5231,7 +5282,7 @@ const char *script_get_translation_file_name(const char *file) * @return success state * @retval true if a new string was added. */ -bool script_load_translation_addstring(const char *file, uint8 lang_id, const char *msgctxt, const struct script_string_buf *msgid, const struct script_string_buf *msgstr) +static bool script_load_translation_addstring(const char *file, uint8 lang_id, const char *msgctxt, const struct script_string_buf *msgid, const struct script_string_buf *msgstr) { nullpo_retr(false, file); nullpo_retr(false, msgctxt); @@ -5299,7 +5350,7 @@ bool script_load_translation_addstring(const char *file, uint8 lang_id, const ch * @param lang_id The language identifier. * @return The amount of strings loaded. */ -int script_load_translation(const char *file, uint8 lang_id) +static int script_load_translation(const char *file, uint8 lang_id) { int translations = 0; char line[1024]; @@ -5439,7 +5490,8 @@ int script_load_translation(const char *file, uint8 lang_id) /** * **/ -void script_clear_translations(bool reload) { +static void script_clear_translations(bool reload) +{ uint32 i; if( script->string_list ) @@ -5473,7 +5525,7 @@ void script_clear_translations(bool reload) { /** * **/ -int script_translation_db_destroyer(union DBKey key, struct DBData *data, va_list ap) +static int script_translation_db_destroyer(union DBKey key, struct DBData *data, va_list ap) { struct DBMap *string_db = DB->data2ptr(data); @@ -5494,7 +5546,7 @@ int script_translation_db_destroyer(union DBKey key, struct DBData *data, va_lis /** * **/ -void script_parser_clean_leftovers(void) +static void script_parser_clean_leftovers(void) { VECTOR_CLEAR(script->buf); @@ -5509,7 +5561,8 @@ void script_parser_clean_leftovers(void) /** * Performs cleanup after all parsing is processed **/ -int script_parse_cleanup_timer(int tid, int64 tick, int id, intptr_t data) { +static int script_parse_cleanup_timer(int tid, int64 tick, int id, intptr_t data) +{ script->parser_clean_leftovers(); script->parse_cleanup_timer_id = INVALID_TIMER; @@ -5520,7 +5573,8 @@ int script_parse_cleanup_timer(int tid, int64 tick, int id, intptr_t data) { /*========================================== * Initialization *------------------------------------------*/ -void do_init_script(bool minimal) { +static void do_init_script(bool minimal) +{ script->parse_cleanup_timer_id = INVALID_TIMER; VECTOR_INIT(script->parse_simpleexpr_strbuf); @@ -5539,7 +5593,7 @@ void do_init_script(bool minimal) { VECTOR_INIT(script->hqi); script->parse_builtin(); - script->read_constdb(); + script->read_constdb(false); script->load_parameters(); script->hardcoded_constants(); @@ -5550,7 +5604,7 @@ void do_init_script(bool minimal) { script->load_translations(); } -int script_reload(void) +static int script_reload(void) { int i; struct DBIterator *iter; @@ -5591,18 +5645,18 @@ int script_reload(void) script->parse_cleanup_timer_id = INVALID_TIMER; } - mapreg->reload(); - + script->read_constdb(true); itemdb->name_constants(); - clan->set_constants(); + mapreg->reload(); sysinfo->vcsrevision_reload(); return 0; } /* returns name of current function being run, from within the stack [Ind/Hercules] */ -const char *script_getfuncname(struct script_state *st) { +static const char *script_getfuncname(struct script_state *st) +{ struct script_data *data; nullpo_retr(NULL, st); @@ -5626,7 +5680,7 @@ const char *script_getfuncname(struct script_state *st) { * already initialized) * @retval false if an error occurs. */ -bool script_sprintf_helper(struct script_state *st, int start, struct StringBuf *out) +static bool script_sprintf_helper(struct script_state *st, int start, struct StringBuf *out) { const char *format = NULL; const char *p = NULL, *np = NULL; @@ -5851,7 +5905,7 @@ bool script_sprintf_helper(struct script_state *st, int start, struct StringBuf /// If a dialog doesn't exist yet, one is created. /// /// mes "<message>"; -BUILDIN(mes) +static BUILDIN(mes) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -5872,7 +5926,7 @@ BUILDIN(mes) * mes "<message>"; * @endcode */ -BUILDIN(mesf) +static BUILDIN(mesf) { struct map_session_data *sd = script->rid2sd(st); struct StringBuf buf; @@ -5897,7 +5951,7 @@ BUILDIN(mesf) /// The dialog text is cleared and the script continues when the button is pressed. /// /// next; -BUILDIN(next) +static BUILDIN(next) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -5914,7 +5968,7 @@ BUILDIN(next) /// The dialog is closed when the button is pressed. /// /// close; -BUILDIN(close) +static BUILDIN(close) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -5929,7 +5983,7 @@ BUILDIN(close) /// The dialog is closed and the script continues when the button is pressed. /// /// close2; -BUILDIN(close2) +static BUILDIN(close2) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -5949,7 +6003,7 @@ BUILDIN(close2) /// Counts the number of valid and total number of options in 'str' /// If max_count > 0 the counting stops when that valid option is reached /// total is incremented for each option (NULL is supported) -int menu_countoptions(const char* str, int max_count, int* total) +static int menu_countoptions(const char *str, int max_count, int *total) { int count = 0; int bogus_total; @@ -5999,7 +6053,7 @@ int menu_countoptions(const char* str, int max_count, int* total) /// NOTE: the client closes the npc dialog when cancel is pressed /// /// menu "<option_text>",<target_label>{,"<option_text>",<target_label>,...}; -BUILDIN(menu) +static BUILDIN(menu) { int i; const char* text; @@ -6121,7 +6175,7 @@ BUILDIN(menu) /// select(<option_text>{,<option_text>,...}) -> <selected_option> /// /// @see menu -BUILDIN(select) +static BUILDIN(select) { int i; const char* text; @@ -6196,7 +6250,7 @@ BUILDIN(select) /// prompt(<option_text>{,<option_text>,...}) -> <selected_option> /// /// @see menu -BUILDIN(prompt) +static BUILDIN(prompt) { int i; const char *text; @@ -6278,7 +6332,7 @@ BUILDIN(prompt) /// Jumps to the target script label. /// /// goto <label>; -BUILDIN(goto) +static BUILDIN(goto) { if( !data_islabel(script_getdata(st,2)) ) { @@ -6296,7 +6350,7 @@ BUILDIN(goto) /*========================================== * user-defined function call *------------------------------------------*/ -BUILDIN(callfunc) +static BUILDIN(callfunc) { int i, j; struct script_retinfo* ri; @@ -6356,7 +6410,7 @@ BUILDIN(callfunc) /*========================================== * subroutine call *------------------------------------------*/ -BUILDIN(callsub) +static BUILDIN(callsub) { int i,j; struct script_retinfo* ri; @@ -6409,7 +6463,7 @@ BUILDIN(callsub) /// If the argument doesn't exist /// /// getarg(<index>{,<default_value>}) -> <value> -BUILDIN(getarg) +static BUILDIN(getarg) { struct script_retinfo* ri; int idx; @@ -6443,7 +6497,8 @@ BUILDIN(getarg) /// /// return; /// return <value>; -BUILDIN(return) { +static BUILDIN(return) +{ st->state = RETFUNC; if( st->stack->defsp < 1 || st->stack->stack_data[st->stack->defsp-1].type != C_RETINFO ) { @@ -6493,7 +6548,7 @@ BUILDIN(return) { /// If <min> is greater than <max>, their numbers are switched. /// rand(<range>) -> <int> /// rand(<min>,<max>) -> <int> -BUILDIN(rand) +static BUILDIN(rand) { int range; int min; @@ -6522,7 +6577,7 @@ BUILDIN(rand) /*========================================== * Warp sd to str,x,y or Random or SavePoint/Save *------------------------------------------*/ -BUILDIN(warp) +static BUILDIN(warp) { int ret; int x,y; @@ -6558,7 +6613,7 @@ BUILDIN(warp) /*========================================== * Warp a specified area *------------------------------------------*/ -int buildin_areawarp_sub(struct block_list *bl, va_list ap) +static int buildin_areawarp_sub(struct block_list *bl, va_list ap) { int x2,y2,x3,y3; unsigned int index; @@ -6599,7 +6654,7 @@ int buildin_areawarp_sub(struct block_list *bl, va_list ap) } return 0; } -BUILDIN(areawarp) +static BUILDIN(areawarp) { int16 m, x0,y0,x1,y1, x2,y2,x3=0,y3=0; unsigned int index; @@ -6641,7 +6696,7 @@ BUILDIN(areawarp) /*========================================== * areapercentheal <map>,<x1>,<y1>,<x2>,<y2>,<hp>,<sp> *------------------------------------------*/ -int buildin_areapercentheal_sub(struct block_list *bl, va_list ap) +static int buildin_areapercentheal_sub(struct block_list *bl, va_list ap) { int hp = va_arg(ap, int); int sp = va_arg(ap, int); @@ -6655,7 +6710,8 @@ int buildin_areapercentheal_sub(struct block_list *bl, va_list ap) return 0; } -BUILDIN(areapercentheal) { +static BUILDIN(areapercentheal) +{ int hp,sp,m; const char *mapname; int x0,y0,x1,y1; @@ -6681,7 +6737,8 @@ BUILDIN(areapercentheal) { * another player npc-session. * Using: warpchar "mapname",x,y,Char_ID; *------------------------------------------*/ -BUILDIN(warpchar) { +static BUILDIN(warpchar) +{ int x,y,a; const char *str; struct map_session_data *sd; @@ -6711,7 +6768,7 @@ BUILDIN(warpchar) { * If 'from_mapname' is specified, only the party members on that map will be warped * If 'include_leader' option is set to false, the leader will be warped too. *------------------------------------------*/ -BUILDIN(warpparty) +static BUILDIN(warpparty) { struct map_session_data *sd = NULL; struct map_session_data *pl_sd; @@ -6806,7 +6863,7 @@ BUILDIN(warpparty) * Warpguild - [Fredzilla] * Syntax: warpguild "mapname",x,y,Guild_ID,{"from_mapname"}; *------------------------------------------*/ -BUILDIN(warpguild) +static BUILDIN(warpguild) { struct map_session_data *sd = NULL; struct guild* g; @@ -6871,7 +6928,7 @@ BUILDIN(warpguild) /*========================================== * Force Heal a player (hp and sp) *------------------------------------------*/ -BUILDIN(heal) +static BUILDIN(heal) { int hp,sp; struct map_session_data *sd = script->rid2sd(st); @@ -6886,7 +6943,7 @@ BUILDIN(heal) /*========================================== * Heal a player by item (get vit bonus etc) *------------------------------------------*/ -BUILDIN(itemheal) +static BUILDIN(itemheal) { struct map_session_data *sd; int hp,sp; @@ -6909,7 +6966,7 @@ BUILDIN(itemheal) /*========================================== * *------------------------------------------*/ -BUILDIN(percentheal) +static BUILDIN(percentheal) { int hp,sp; struct map_session_data *sd; @@ -6940,7 +6997,7 @@ BUILDIN(percentheal) /*========================================== * *------------------------------------------*/ -BUILDIN(jobchange) +static BUILDIN(jobchange) { int class, upper=-1; @@ -6962,7 +7019,7 @@ BUILDIN(jobchange) /*========================================== * *------------------------------------------*/ -BUILDIN(jobname) +static BUILDIN(jobname) { int class = script_getnum(st,2); script_pushconststr(st, pc->job_name(class)); @@ -6976,7 +7033,7 @@ BUILDIN(jobname) /// shorter than 'min' and 0 otherwise. /// /// input(<var>{,<min>{,<max>}}) -> <int> -BUILDIN(input) +static BUILDIN(input) { struct script_data* data; int64 uid; @@ -7029,13 +7086,13 @@ BUILDIN(input) } // declare the copyarray method here for future reference -BUILDIN(copyarray); +static BUILDIN(copyarray); /// Sets the value of a variable. /// The value is converted to the type of the variable. /// /// set(<variable>,<value>) -> <variable> -BUILDIN(__setr) +static BUILDIN(__setr) { struct map_session_data *sd = NULL; struct script_data* data; @@ -7123,7 +7180,7 @@ BUILDIN(__setr) /// ex: setarray arr[1],1,2,3; /// /// setarray <array variable>,<value1>{,<value2>...}; -BUILDIN(setarray) +static BUILDIN(setarray) { struct script_data* data; const char* name; @@ -7173,7 +7230,7 @@ BUILDIN(setarray) /// ex: cleararray arr[0],0,1; /// /// cleararray <array variable>,<value>,<count>; -BUILDIN(cleararray) +static BUILDIN(cleararray) { struct script_data* data; const char* name; @@ -7221,7 +7278,7 @@ BUILDIN(cleararray) /// ex: copyarray arr[0],arr[2],2; /// /// copyarray <destination array variable>,<source array variable>,<count>; -BUILDIN(copyarray) +static BUILDIN(copyarray) { struct script_data* data1; struct script_data* data2; @@ -7308,7 +7365,7 @@ BUILDIN(copyarray) /// ex: getarraysize(arr[3]) /// /// getarraysize(<array variable>) -> <int> -BUILDIN(getarraysize) +static BUILDIN(getarraysize) { struct script_data* data; @@ -7325,12 +7382,12 @@ BUILDIN(getarraysize) script_pushint(st, script->array_highest_key(st,st->rid ? script->rid2sd(st) : NULL,reference_getname(data),reference_getref(data))); return true; } -int script_array_index_cmp(const void *a, const void *b) +static int script_array_index_cmp(const void *a, const void *b) { return (*(const unsigned int *)a - *(const unsigned int *)b); // FIXME: Is the unsigned difference really intended here? } -BUILDIN(getarrayindex) +static BUILDIN(getarrayindex) { struct script_data *data = script_getdata(st, 2); @@ -7351,7 +7408,7 @@ BUILDIN(getarrayindex) /// /// deletearray <array variable>; /// deletearray <array variable>,<count>; -BUILDIN(deletearray) +static BUILDIN(deletearray) { struct script_data* data; const char* name; @@ -7465,7 +7522,7 @@ BUILDIN(deletearray) /// Equivalent to var[index]. /// /// getelementofarray(<array variable>,<index>) -> <variable reference> -BUILDIN(getelementofarray) +static BUILDIN(getelementofarray) { struct script_data* data; int32 id; @@ -7484,7 +7541,7 @@ BUILDIN(getelementofarray) id = reference_getid(data); i = script_getnum(st, 3); - if (i < 0 || i >= SCRIPT_MAX_ARRAYSIZE) { + if (i < 0 || i > SCRIPT_MAX_ARRAYSIZE) { ShowWarning("script:getelementofarray: index out of range (%"PRId64")\n", i); script->reportdata(data); script_pushnil(st); @@ -7503,7 +7560,7 @@ BUILDIN(getelementofarray) /*========================================== * *------------------------------------------*/ -BUILDIN(setlook) +static BUILDIN(setlook) { int type,val; struct map_session_data *sd; @@ -7520,7 +7577,7 @@ BUILDIN(setlook) return true; } -BUILDIN(changelook) +static BUILDIN(changelook) { // As setlook but only client side int type,val; struct map_session_data *sd; @@ -7540,7 +7597,7 @@ BUILDIN(changelook) /*========================================== * *------------------------------------------*/ -BUILDIN(cutin) +static BUILDIN(cutin) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -7553,7 +7610,7 @@ BUILDIN(cutin) /*========================================== * *------------------------------------------*/ -BUILDIN(viewpoint) +static BUILDIN(viewpoint) { int type,x,y,id,color; struct map_session_data *sd; @@ -7576,7 +7633,8 @@ BUILDIN(viewpoint) /*========================================== * *------------------------------------------*/ -BUILDIN(countitem) { +static BUILDIN(countitem) +{ int nameid, i; int count = 0; struct item_data* id = NULL; @@ -7613,7 +7671,8 @@ BUILDIN(countitem) { * countitem2(nameID,Identified,Refine,Attribute,Card0,Card1,Card2,Card3) [Lupus] * returns number of items that meet the conditions *------------------------------------------*/ -BUILDIN(countitem2) { +static BUILDIN(countitem2) +{ int nameid, iden, ref, attr, c1, c2, c3, c4; int count = 0; int i; @@ -7641,10 +7700,10 @@ BUILDIN(countitem2) { iden = script_getnum(st,3); ref = script_getnum(st,4); attr = script_getnum(st,5); - c1 = (short)script_getnum(st,6); - c2 = (short)script_getnum(st,7); - c3 = (short)script_getnum(st,8); - c4 = (short)script_getnum(st,9); + c1 = script_getnum(st,6); + c2 = script_getnum(st,7); + c3 = script_getnum(st,8); + c4 = script_getnum(st,9); for(i = 0; i < MAX_INVENTORY; i++) if (sd->status.inventory[i].nameid > 0 && sd->inventory_data[i] != NULL && @@ -7667,7 +7726,7 @@ BUILDIN(countitem2) { * 0 : fail * 1 : success (npc side only) *------------------------------------------*/ -BUILDIN(checkweight) +static BUILDIN(checkweight) { int slots, amount2=0; unsigned int weight=0, i, nbargs; @@ -7749,7 +7808,7 @@ BUILDIN(checkweight) return true; } -BUILDIN(checkweight2) +static BUILDIN(checkweight2) { //variable sub checkweight int i=0, amount2=0, slots=0, weight=0; @@ -7853,7 +7912,8 @@ BUILDIN(checkweight2) * getitembound <item id>,<amount>,<type>{,<account ID>}; * getitembound "<item id>",<amount>,<type>{,<account ID>}; *------------------------------------------*/ -BUILDIN(getitem) { +static BUILDIN(getitem) +{ int nameid,amount,get_count,i,flag = 0, offset = 0; struct item it; struct map_session_data *sd; @@ -7938,7 +7998,7 @@ BUILDIN(getitem) { /*========================================== * *------------------------------------------*/ -BUILDIN(getitem2) +static BUILDIN(getitem2) { int nameid,amount,flag = 0, offset = 0; int iden,ref,attr,c1,c2,c3,c4, bound = 0; @@ -7976,10 +8036,10 @@ BUILDIN(getitem2) iden=script_getnum(st,4); ref=script_getnum(st,5); attr=script_getnum(st,6); - c1=(short)script_getnum(st,7); - c2=(short)script_getnum(st,8); - c3=(short)script_getnum(st,9); - c4=(short)script_getnum(st,10); + c1 = script_getnum(st,7); + c2 = script_getnum(st,8); + c3 = script_getnum(st,9); + c4 = script_getnum(st,10); if (bound && (itemdb_type(nameid) == IT_PETEGG || itemdb_type(nameid) == IT_PETARMOR)) { ShowError("script_getitembound2: can't bind a pet egg/armor! Type=%d\n",bound); @@ -8018,10 +8078,10 @@ BUILDIN(getitem2) item_tmp.refine=ref; item_tmp.attribute=attr; item_tmp.bound=(unsigned char)bound; - item_tmp.card[0]=(short)c1; - item_tmp.card[1]=(short)c2; - item_tmp.card[2]=(short)c3; - item_tmp.card[3]=(short)c4; + item_tmp.card[0] = c1; + item_tmp.card[1] = c2; + item_tmp.card[2] = c3; + item_tmp.card[3] = c4; //Check if it's stackable. if (!itemdb->isstackable(nameid)) @@ -8048,7 +8108,8 @@ BUILDIN(getitem2) * rentitem <item id>,<seconds> * rentitem "<item name>",<seconds> *------------------------------------------*/ -BUILDIN(rentitem) { +static BUILDIN(rentitem) +{ struct map_session_data *sd; struct item it; int seconds; @@ -8096,7 +8157,8 @@ BUILDIN(rentitem) { * Returned Qty is always 1, only works on equip-able * equipment *------------------------------------------*/ -BUILDIN(getnameditem) { +static BUILDIN(getnameditem) +{ int nameid; struct item item_tmp; struct map_session_data *sd, *tsd; @@ -8155,7 +8217,8 @@ BUILDIN(getnameditem) { * gets a random item ID from an item group [Skotlex] * groupranditem group_num *------------------------------------------*/ -BUILDIN(grouprandomitem) { +static BUILDIN(grouprandomitem) +{ struct item_data *data; int nameid; @@ -8185,7 +8248,7 @@ BUILDIN(grouprandomitem) { /*========================================== * *------------------------------------------*/ -BUILDIN(makeitem) +static BUILDIN(makeitem) { int nameid,amount; int x,y,m; @@ -8234,9 +8297,9 @@ BUILDIN(makeitem) } /*========================================== -* makeitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,{"<map name>",<X>,<Y>,<range>}; -*------------------------------------------*/ -BUILDIN(makeitem2) + * makeitem2 <item id>, <amount>, <identify>, <refine>, <attribute>, <card1>, <card2>, <card3>, <card4>, {"<map name>", <X>, <Y>, <range>}; + *------------------------------------------*/ +static BUILDIN(makeitem2) { struct map_session_data *sd = NULL; struct item_data *i_data; @@ -8307,10 +8370,10 @@ BUILDIN(makeitem2) item_tmp.identify = script_getnum(st, 4); item_tmp.refine = cap_value(script_getnum(st, 5), 0, MAX_REFINE); item_tmp.attribute = script_getnum(st, 6); - item_tmp.card[0] = (short)script_getnum(st, 7); - item_tmp.card[1] = (short)script_getnum(st, 8); - item_tmp.card[2] = (short)script_getnum(st, 9); - item_tmp.card[3] = (short)script_getnum(st, 10); + item_tmp.card[0] = script_getnum(st, 7); + item_tmp.card[1] = script_getnum(st, 8); + item_tmp.card[2] = script_getnum(st, 9); + item_tmp.card[3] = script_getnum(st, 10); map->addflooritem(NULL, &item_tmp, amount, m, x, y, 0, 0, 0, 0, false); @@ -8320,7 +8383,7 @@ BUILDIN(makeitem2) /// Counts / deletes the current item given by idx. /// Used by buildin_delitem_search /// Relies on all input data being already fully valid. -void buildin_delitem_delete(struct map_session_data* sd, int idx, int* amount, bool delete_items) +static void buildin_delitem_delete(struct map_session_data *sd, int idx, int *amount, bool delete_items) { int delamount; struct item* inv; @@ -8348,7 +8411,7 @@ void buildin_delitem_delete(struct map_session_data* sd, int idx, int* amount, b /// Relies on all input data being already fully valid. /// @param exact_match will also match item attributes and cards, not just name id /// @return true when all items could be deleted, false when there were not enough items to delete -bool buildin_delitem_search(struct map_session_data* sd, struct item* it, bool exact_match) +static bool buildin_delitem_search(struct map_session_data *sd, struct item *it, bool exact_match) { bool delete_items = false; int i, amount; @@ -8457,7 +8520,7 @@ bool buildin_delitem_search(struct map_session_data* sd, struct item* it, bool e /// /// delitem <item id>,<amount>{,<account id>} /// delitem "<item name>",<amount>{,<account id>} -BUILDIN(delitem) +static BUILDIN(delitem) { struct map_session_data *sd; struct item it; @@ -8514,7 +8577,7 @@ BUILDIN(delitem) /// /// delitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>} /// delitem2 "<Item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>} -BUILDIN(delitem2) +static BUILDIN(delitem2) { struct map_session_data *sd; struct item it; @@ -8555,10 +8618,10 @@ BUILDIN(delitem2) it.identify=script_getnum(st,4); it.refine=script_getnum(st,5); it.attribute=script_getnum(st,6); - it.card[0]=(short)script_getnum(st,7); - it.card[1]=(short)script_getnum(st,8); - it.card[2]=(short)script_getnum(st,9); - it.card[3]=(short)script_getnum(st,10); + it.card[0] = script_getnum(st, 7); + it.card[1] = script_getnum(st, 8); + it.card[2] = script_getnum(st, 9); + it.card[3] = script_getnum(st, 10); if( it.amount <= 0 ) return true;// nothing to do @@ -8577,7 +8640,7 @@ BUILDIN(delitem2) /*========================================== * Enables/Disables use of items while in an NPC [Skotlex] *------------------------------------------*/ -BUILDIN(enableitemuse) +static BUILDIN(enableitemuse) { struct map_session_data *sd = script->rid2sd(st); if (sd != NULL) @@ -8585,7 +8648,7 @@ BUILDIN(enableitemuse) return true; } -BUILDIN(disableitemuse) +static BUILDIN(disableitemuse) { struct map_session_data *sd = script->rid2sd(st); if (sd != NULL) @@ -8597,7 +8660,8 @@ BUILDIN(disableitemuse) * return the basic stats of sd * chk pc->readparam for available type *------------------------------------------*/ -BUILDIN(readparam) { +static BUILDIN(readparam) +{ int type; struct map_session_data *sd; struct script_data *data = script_getdata(st, 2); @@ -8609,7 +8673,11 @@ BUILDIN(readparam) { } if (script_hasdata(st, 3)) { - sd = script->nick2sd(st, script_getstr(st, 3)); + if (script_isstringtype(st, 3)) { + sd = script->nick2sd(st, script_getstr(st, 3)); + } else { + sd = script->id2sd(st, script_getnum(st, 3)); + } } else { sd = script->rid2sd(st); } @@ -8623,6 +8691,43 @@ BUILDIN(readparam) { return true; } +static BUILDIN(setparam) +{ + int type; + struct map_session_data *sd; + struct script_data *data = script_getdata(st, 2); + int val = script_getnum(st, 3); + + if (data_isreference(data) && reference_toparam(data)) { + type = reference_getparamtype(data); + } else { + type = script->conv_num(st, data); + } + + if (script_hasdata(st, 4)) { + if (script_isstringtype(st, 4)) { + sd = script->nick2sd(st, script_getstr(st, 4)); + } else { + sd = script->id2sd(st, script_getnum(st, 4)); + } + } else { + sd = script->rid2sd(st); + } + + if (sd == NULL) { + script_pushint(st, 0); + return true; + } + + if (pc->setparam(sd, type, val) == 0) { + script_pushint(st, 0); + return false; + } + + script_pushint(st, 1); + return true; +} + /*========================================== * Return charid identification * return by @num : @@ -8633,7 +8738,8 @@ BUILDIN(readparam) { * 4 : bg_id * 5 : clan_id *------------------------------------------*/ -BUILDIN(getcharid) { +static BUILDIN(getcharid) +{ int num = script_getnum(st, 2); struct map_session_data *sd; @@ -8677,7 +8783,7 @@ BUILDIN(getcharid) { /*========================================== * returns the GID of an NPC *------------------------------------------*/ -BUILDIN(getnpcid) +static BUILDIN(getnpcid) { int num = script_getnum(st,2); struct npc_data* nd = NULL; @@ -8709,7 +8815,7 @@ BUILDIN(getnpcid) * Return the name of the party_id * null if not found *------------------------------------------*/ -BUILDIN(getpartyname) +static BUILDIN(getpartyname) { int party_id; struct party_data* p; @@ -8735,7 +8841,7 @@ BUILDIN(getpartyname) * 1 : char_id des membres * 2 : account_id des membres *------------------------------------------*/ -BUILDIN(getpartymember) +static BUILDIN(getpartymember) { struct party_data *p; int j=0,type=0; @@ -8772,7 +8878,7 @@ BUILDIN(getpartymember) * Retrieves party leader. if flag is specified, * return some of the leader data. Otherwise, return name. *------------------------------------------*/ -BUILDIN(getpartyleader) +static BUILDIN(getpartyleader) { int party_id, type = 0, i=0; struct party_data *p; @@ -8809,7 +8915,7 @@ BUILDIN(getpartyleader) * Return the name of the @guild_id * null if not found *------------------------------------------*/ -BUILDIN(getguildname) +static BUILDIN(getguildname) { int guild_id; struct guild* g; @@ -8831,7 +8937,7 @@ BUILDIN(getguildname) * Return the name of the guild master of @guild_id * null if not found *------------------------------------------*/ -BUILDIN(getguildmaster) +static BUILDIN(getguildmaster) { int guild_id; struct guild* g; @@ -8849,7 +8955,7 @@ BUILDIN(getguildmaster) return true; } -BUILDIN(getguildmasterid) +static BUILDIN(getguildmasterid) { int guild_id; struct guild* g; @@ -8876,7 +8982,7 @@ BUILDIN(getguildmasterid) * 1 : character ID * 2 : account ID *------------------------------------------*/ -BUILDIN(getguildmember) +static BUILDIN(getguildmember) { struct guild *g = NULL; int j = 0; @@ -8920,7 +9026,7 @@ BUILDIN(getguildmember) * 4 : clan_name or "" * - : "" *------------------------------------------*/ -BUILDIN(strcharinfo) +static BUILDIN(strcharinfo) { struct clan *c; struct guild* g; @@ -8986,7 +9092,7 @@ BUILDIN(strcharinfo) * 3 : ::str * 4 : map name *------------------------------------------*/ -BUILDIN(strnpcinfo) +static BUILDIN(strnpcinfo) { char *buf,*name=NULL; struct npc_data *nd; @@ -9043,7 +9149,7 @@ BUILDIN(strnpcinfo) /** * charid2rid: Returns the RID associated to the given character ID */ -BUILDIN(charid2rid) +static BUILDIN(charid2rid) { int cid = script_getnum(st, 2); struct map_session_data *sd = map->charid2sd(cid); @@ -9060,7 +9166,7 @@ BUILDIN(charid2rid) /*========================================== * GetEquipID(Pos); Pos: 1-SCRIPT_EQUIP_TABLE_SIZE *------------------------------------------*/ -BUILDIN(getequipid) +static BUILDIN(getequipid) { int i, num; struct item_data* item; @@ -9096,7 +9202,7 @@ BUILDIN(getequipid) * Get the equipement name at pos * return item jname or "" *------------------------------------------*/ -BUILDIN(getequipname) +static BUILDIN(getequipname) { int i, num; struct item_data* item; @@ -9131,7 +9237,7 @@ BUILDIN(getequipname) /*========================================== * getbrokenid [Valaris] *------------------------------------------*/ -BUILDIN(getbrokenid) +static BUILDIN(getbrokenid) { int i,num,id=0,brokencounter=0; struct map_session_data *sd = script->rid2sd(st); @@ -9140,6 +9246,8 @@ BUILDIN(getbrokenid) num=script_getnum(st,2); for(i=0; i<MAX_INVENTORY; i++) { + if (sd->status.inventory[i].card[0] == CARD0_PET) + continue; if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { brokencounter++; if(num==brokencounter) { @@ -9157,7 +9265,7 @@ BUILDIN(getbrokenid) /*========================================== * getbrokencount *------------------------------------------*/ -BUILDIN(getbrokencount) +static BUILDIN(getbrokencount) { int i, counter = 0; struct map_session_data *sd = script->rid2sd(st); @@ -9165,6 +9273,8 @@ BUILDIN(getbrokencount) return true; for (i = 0; i < MAX_INVENTORY; i++) { + if (sd->status.inventory[i].card[0] == CARD0_PET) + continue; if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) counter++; } @@ -9177,7 +9287,7 @@ BUILDIN(getbrokencount) /*========================================== * repair [Valaris] *------------------------------------------*/ -BUILDIN(repair) +static BUILDIN(repair) { int i,num; int repaircounter=0; @@ -9187,6 +9297,8 @@ BUILDIN(repair) num=script_getnum(st,2); for(i=0; i<MAX_INVENTORY; i++) { + if (sd->status.inventory[i].card[0] == CARD0_PET) + continue; if ((sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { repaircounter++; if(num==repaircounter) { @@ -9206,7 +9318,7 @@ BUILDIN(repair) /*========================================== * repairall *------------------------------------------*/ -BUILDIN(repairall) +static BUILDIN(repairall) { int i, repaircounter = 0; struct map_session_data *sd = script->rid2sd(st); @@ -9215,6 +9327,8 @@ BUILDIN(repairall) for(i = 0; i < MAX_INVENTORY; i++) { + if (sd->status.inventory[i].card[0] == CARD0_PET) + continue; if (sd->status.inventory[i].nameid && (sd->status.inventory[i].attribute & ATTR_BROKEN) != 0) { sd->status.inventory[i].attribute |= ATTR_BROKEN; @@ -9236,7 +9350,7 @@ BUILDIN(repairall) /*========================================== * Chk if player have something equiped at pos *------------------------------------------*/ -BUILDIN(getequipisequiped) +static BUILDIN(getequipisequiped) { int i = -1,num; struct map_session_data *sd; @@ -9263,7 +9377,7 @@ BUILDIN(getequipisequiped) * 1 : true * 0 : false *------------------------------------------*/ -BUILDIN(getequipisenableref) +static BUILDIN(getequipisenableref) { int i = -1,num; struct map_session_data *sd; @@ -9290,7 +9404,7 @@ BUILDIN(getequipisenableref) * @param equipment_index as the inventory index of the equipment. * @return 1 on enabled 0 on disabled. */ -BUILDIN(getequipisenableopt) +static BUILDIN(getequipisenableopt) { int i = -1, index = script_getnum(st, 2); struct map_session_data *sd = script->rid2sd(st); @@ -9318,7 +9432,7 @@ BUILDIN(getequipisenableopt) * 1 : true * 0 : false *------------------------------------------*/ -BUILDIN(getequipisidentify) +static BUILDIN(getequipisidentify) { int i = -1,num; struct map_session_data *sd; @@ -9344,7 +9458,7 @@ BUILDIN(getequipisidentify) * x : refine amount * 0 : false (not refined) *------------------------------------------*/ -BUILDIN(getequiprefinerycnt) +static BUILDIN(getequiprefinerycnt) { int i = -1,num; struct map_session_data *sd; @@ -9371,7 +9485,7 @@ BUILDIN(getequiprefinerycnt) * x : weapon level * 0 : false *------------------------------------------*/ -BUILDIN(getequipweaponlv) +static BUILDIN(getequipweaponlv) { int i = -1,num; struct map_session_data *sd; @@ -9397,7 +9511,8 @@ BUILDIN(getequipweaponlv) * x : refine chance * 0 : false (max refine level or unequip..) *------------------------------------------*/ -BUILDIN(getequippercentrefinery) { +static BUILDIN(getequippercentrefinery) +{ int i = -1, num; struct map_session_data *sd; int type = 0; @@ -9431,7 +9546,7 @@ BUILDIN(getequippercentrefinery) { /*========================================== * Refine +1 item at pos and log and display refine *------------------------------------------*/ -BUILDIN(successrefitem) +static BUILDIN(successrefitem) { int i = -1 , num, up = 1; struct map_session_data *sd; @@ -9468,6 +9583,11 @@ BUILDIN(successrefitem) clif->additem(sd,i,1,0); pc->equipitem(sd,i,ep); clif->misceffect(&sd->bl,3); + + achievement->validate_refine(sd, i, true); // Achievements [Smokexyz/Hercules] + + /* The following check is exclusive to characters (possibly only whitesmiths) + * that create equipments and refine them to level 10. */ if(sd->status.inventory[i].refine == 10 && sd->status.inventory[i].card[0] == CARD0_FORGE && sd->status.char_id == (int)MakeDWord(sd->status.inventory[i].card[2],sd->status.inventory[i].card[3]) @@ -9492,7 +9612,7 @@ BUILDIN(successrefitem) /*========================================== * Show a failed Refine +1 attempt *------------------------------------------*/ -BUILDIN(failedrefitem) +static BUILDIN(failedrefitem) { int i=-1,num; struct map_session_data *sd; @@ -9505,6 +9625,9 @@ BUILDIN(failedrefitem) if (num > 0 && num <= ARRAYLENGTH(script->equip)) i=pc->checkequip(sd,script->equip[num-1]); if(i >= 0) { + // Call before changing refine to 0. + achievement->validate_refine(sd, i, false); + sd->status.inventory[i].refine = 0; pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); //recalculate bonus clif->refine(sd->fd,1,i,sd->status.inventory[i].refine); //notify client of failure @@ -9520,7 +9643,7 @@ BUILDIN(failedrefitem) /*========================================== * Downgrades an Equipment Part by -1 . [Masao] *------------------------------------------*/ -BUILDIN(downrefitem) +static BUILDIN(downrefitem) { int i = -1, num, down = 1; struct map_session_data *sd; @@ -9552,6 +9675,9 @@ BUILDIN(downrefitem) clif->additem(sd,i,1,0); pc->equipitem(sd,i,ep); + + achievement->validate_refine(sd, i, false); // Achievements [Smokexyz/Hercules] + clif->misceffect(&sd->bl,2); } @@ -9561,7 +9687,7 @@ BUILDIN(downrefitem) /*========================================== * Delete the item equipped at pos. *------------------------------------------*/ -BUILDIN(delequip) +static BUILDIN(delequip) { int i=-1,num; struct map_session_data *sd; @@ -9589,7 +9715,8 @@ BUILDIN(delequip) /*========================================== * *------------------------------------------*/ -BUILDIN(statusup) { +static BUILDIN(statusup) +{ int type; struct map_session_data *sd; @@ -9605,7 +9732,7 @@ BUILDIN(statusup) { /*========================================== * *------------------------------------------*/ -BUILDIN(statusup2) +static BUILDIN(statusup2) { int type,val; struct map_session_data *sd; @@ -9628,7 +9755,8 @@ BUILDIN(statusup2) /// bonus3 <bonus type>,<val1>,<val2>,<val3>; /// bonus4 <bonus type>,<val1>,<val2>,<val3>,<val4>; /// bonus5 <bonus type>,<val1>,<val2>,<val3>,<val4>,<val5>; -BUILDIN(bonus) { +static BUILDIN(bonus) +{ int type; int val1; int val2 = 0; @@ -9710,7 +9838,7 @@ BUILDIN(bonus) { return true; } -BUILDIN(autobonus) +static BUILDIN(autobonus) { unsigned int dur; short rate; @@ -9745,7 +9873,7 @@ BUILDIN(autobonus) return true; } -BUILDIN(autobonus2) +static BUILDIN(autobonus2) { unsigned int dur; short rate; @@ -9780,7 +9908,7 @@ BUILDIN(autobonus2) return true; } -BUILDIN(autobonus3) +static BUILDIN(autobonus3) { unsigned int dur; short rate,atk_type; @@ -9823,7 +9951,8 @@ BUILDIN(autobonus3) /// skill <skill id>,<level> /// skill "<skill name>",<level>,<flag> /// skill "<skill name>",<level> -BUILDIN(skill) { +static BUILDIN(skill) +{ int id; int level; int flag = SKILL_GRANT_TEMPORARY; @@ -9849,7 +9978,8 @@ BUILDIN(skill) { /// addtoskill "<skill name>",<amount> /// /// @see skill -BUILDIN(addtoskill) { +static BUILDIN(addtoskill) +{ int id; int level; int flag = SKILL_GRANT_TEMPSTACK; @@ -9870,7 +10000,8 @@ BUILDIN(addtoskill) { /// /// guildskill <skill id>,<amount>; /// guildskill "<skill name>",<amount>; -BUILDIN(guildskill) { +static BUILDIN(guildskill) +{ int skill_id, id, max_points; int level; @@ -9909,7 +10040,7 @@ BUILDIN(guildskill) { /// /// getskilllv(<skill id>) -> <level> /// getskilllv("<skill name>") -> <level> -BUILDIN(getskilllv) +static BUILDIN(getskilllv) { int id; struct map_session_data *sd = script->rid2sd(st); @@ -9926,7 +10057,8 @@ BUILDIN(getskilllv) /// /// getgdskilllv(<guild id>,<skill id>) -> <level> /// getgdskilllv(<guild id>,"<skill name>") -> <level> -BUILDIN(getgdskilllv) { +static BUILDIN(getgdskilllv) +{ int guild_id; uint16 skill_id; struct guild* g; @@ -9947,7 +10079,7 @@ BUILDIN(getgdskilllv) { /// before allowing the basic actions. /// /// basicskillcheck() -> <bool> -BUILDIN(basicskillcheck) +static BUILDIN(basicskillcheck) { script_pushint(st, battle_config.basic_skill_check); return true; @@ -9956,7 +10088,7 @@ BUILDIN(basicskillcheck) /// Returns the GM level of the player. /// /// getgmlevel() -> <level> -BUILDIN(getgmlevel) +static BUILDIN(getgmlevel) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -9970,7 +10102,8 @@ BUILDIN(getgmlevel) /// set the group ID of the player. /// setgroupid(<new group id>{,"<character name>"|<account id>}) /// return 1 on success, 0 if failed. -BUILDIN(setgroupid) { +static BUILDIN(setgroupid) +{ struct map_session_data* sd = NULL; int new_group = script_getnum(st, 2); @@ -9994,7 +10127,8 @@ BUILDIN(setgroupid) { /// Returns the group ID of the player. /// /// getgroupid({<account id>}) -> <int> -BUILDIN(getgroupid) { +static BUILDIN(getgroupid) +{ struct map_session_data *sd = NULL; if (script_hasdata(st, 2)) { @@ -10015,7 +10149,8 @@ BUILDIN(getgroupid) { /// Terminates the execution of this script instance. /// /// end -BUILDIN(end) { +static BUILDIN(end) +{ st->state = END; /* are we stopping inside a function? */ @@ -10035,7 +10170,7 @@ BUILDIN(end) { /// Checks if the player has that effect state (option). /// /// checkoption(<option>) -> <bool> -BUILDIN(checkoption) +static BUILDIN(checkoption) { int option; struct map_session_data *sd; @@ -10060,7 +10195,7 @@ BUILDIN(checkoption) /// Checks if the player is in that body state (opt1). /// /// checkoption1(<opt1>) -> <bool> -BUILDIN(checkoption1) +static BUILDIN(checkoption1) { int opt1; struct map_session_data *sd; @@ -10085,7 +10220,7 @@ BUILDIN(checkoption1) /// Checks if the player has that health state (opt2). /// /// checkoption2(<opt2>) -> <bool> -BUILDIN(checkoption2) +static BUILDIN(checkoption2) { int opt2; struct map_session_data *sd; @@ -10114,7 +10249,7 @@ BUILDIN(checkoption2) /// /// setoption <option>,<flag>; /// setoption <option>; -BUILDIN(setoption) +static BUILDIN(setoption) { int option; int flag = 1; @@ -10153,7 +10288,7 @@ BUILDIN(setoption) /// checkcart() -> <bool> /// /// @author Valaris -BUILDIN(checkcart) +static BUILDIN(checkcart) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -10178,7 +10313,7 @@ BUILDIN(checkcart) /// /// setcart <type>; /// setcart; -BUILDIN(setcart) +static BUILDIN(setcart) { int type = 1; struct map_session_data *sd = script->rid2sd(st); @@ -10197,7 +10332,7 @@ BUILDIN(setcart) /// checkfalcon() -> <bool> /// /// @author Valaris -BUILDIN(checkfalcon) +static BUILDIN(checkfalcon) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -10216,7 +10351,7 @@ BUILDIN(checkfalcon) /// /// setfalcon <flag>; /// setfalcon; -BUILDIN(setfalcon) +static BUILDIN(setfalcon) { bool flag = true; struct map_session_data *sd = script->rid2sd(st); @@ -10253,7 +10388,7 @@ enum setmount_type { * The exact returned values are the same used as flag in setmount, except for * dragons, where SETMOUNT_TYPE_DRAGON is returned, regardless of color. */ -BUILDIN(checkmount) +static BUILDIN(checkmount) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -10296,7 +10431,7 @@ BUILDIN(checkmount) * auto-detected. As a result of this, there is no need to specify a flag at * all, unless it is a dragon color other than green. */ -BUILDIN(setmount) +static BUILDIN(setmount) { int flag = SETMOUNT_TYPE_AUTODETECT; struct map_session_data *sd = script->rid2sd(st); @@ -10361,7 +10496,7 @@ BUILDIN(setmount) /// /// checkwug() -> <bool> /// -BUILDIN(checkwug) +static BUILDIN(checkwug) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -10379,7 +10514,8 @@ BUILDIN(checkwug) /// /// save "<map name>",<x>,<y> /// savepoint "<map name>",<x>,<y> -BUILDIN(savepoint) { +static BUILDIN(savepoint) +{ int x; int y; short mapid; @@ -10401,7 +10537,9 @@ BUILDIN(savepoint) { /*========================================== * GetTimeTick(0: System Tick, 1: Time Second Tick) *------------------------------------------*/ -BUILDIN(gettimetick) { /* Asgard Version */ +/* Asgard Version */ +static BUILDIN(gettimetick) +{ int type; time_t clock; struct tm *t; @@ -10434,7 +10572,9 @@ BUILDIN(gettimetick) { /* Asgard Version */ * 4: WeekDay 5: MonthDay 6: Month * 7: Year *------------------------------------------*/ -BUILDIN(gettime) { /* Asgard Version */ +/* Asgard Version */ +static BUILDIN(gettime) +{ int type; time_t clock; struct tm *t; @@ -10479,7 +10619,7 @@ BUILDIN(gettime) { /* Asgard Version */ /*========================================== * GetTimeStr("TimeFMT", Length); *------------------------------------------*/ -BUILDIN(gettimestr) +static BUILDIN(gettimestr) { char *tmpstr; const char *fmtstr; @@ -10500,7 +10640,7 @@ BUILDIN(gettimestr) /*========================================== * Open player storage *------------------------------------------*/ -BUILDIN(openstorage) +static BUILDIN(openstorage) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -10518,7 +10658,7 @@ BUILDIN(openstorage) return true; } -BUILDIN(guildopenstorage) +static BUILDIN(guildopenstorage) { int ret; struct map_session_data *sd = script->rid2sd(st); @@ -10535,7 +10675,7 @@ BUILDIN(guildopenstorage) *------------------------------------------*/ /// itemskill <skill id>,<level>{,flag /// itemskill "<skill name>",<level>{,flag -BUILDIN(itemskill) +static BUILDIN(itemskill) { int id; int lv; @@ -10560,7 +10700,7 @@ BUILDIN(itemskill) /*========================================== * Attempt to create an item *------------------------------------------*/ -BUILDIN(produce) +static BUILDIN(produce) { int trigger; struct map_session_data *sd = script->rid2sd(st); @@ -10574,7 +10714,7 @@ BUILDIN(produce) /*========================================== * *------------------------------------------*/ -BUILDIN(cooking) +static BUILDIN(cooking) { int trigger; struct map_session_data *sd = script->rid2sd(st); @@ -10588,7 +10728,7 @@ BUILDIN(cooking) /*========================================== * Create a pet *------------------------------------------*/ -BUILDIN(makepet) +static BUILDIN(makepet) { struct map_session_data *sd; int id,pet_id; @@ -10606,7 +10746,7 @@ BUILDIN(makepet) sd->catch_target_class = pet->db[pet_id].class_; intif->create_pet(sd->status.account_id, sd->status.char_id, (short)pet->db[pet_id].class_, (short)mob->db(pet->db[pet_id].class_)->lv, - (short)pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate, + pet->db[pet_id].EggID, 0, (short)pet->db[pet_id].intimate, 100, 0, 1, pet->db[pet_id].jname); } @@ -10615,7 +10755,7 @@ BUILDIN(makepet) /*========================================== * Give player exp base,job * quest_exp_rate/100 *------------------------------------------*/ -BUILDIN(getexp) +static BUILDIN(getexp) { int base=0,job=0; struct map_session_data *sd = script->rid2sd(st); @@ -10639,7 +10779,7 @@ BUILDIN(getexp) /*========================================== * Gain guild exp [Celest] *------------------------------------------*/ -BUILDIN(guildgetexp) +static BUILDIN(guildgetexp) { int exp; struct map_session_data *sd = script->rid2sd(st); @@ -10658,7 +10798,7 @@ BUILDIN(guildgetexp) /*========================================== * Changes the guild master of a guild [Skotlex] *------------------------------------------*/ -BUILDIN(guildchangegm) +static BUILDIN(guildchangegm) { struct map_session_data *sd; int guild_id; @@ -10684,7 +10824,7 @@ BUILDIN(guildchangegm) * @amount : nb to spawn * @event : event to attach to mob *------------------------------------------*/ -BUILDIN(monster) +static BUILDIN(monster) { const char *mapn = script_getstr(st,2); int x = script_getnum(st,3); @@ -10756,7 +10896,7 @@ BUILDIN(monster) /*========================================== * Request List of Monster Drops *------------------------------------------*/ -BUILDIN(getmobdrops) +static BUILDIN(getmobdrops) { int class_ = script_getnum(st,2); int i, j = 0; @@ -10791,7 +10931,8 @@ BUILDIN(getmobdrops) /*========================================== * Same as monster but randomize location in x0,x1,y0,y1 area *------------------------------------------*/ -BUILDIN(areamonster) { +static BUILDIN(areamonster) +{ const char *mapn = script_getstr(st,2); int x0 = script_getnum(st,3); int y0 = script_getnum(st,4); @@ -10854,7 +10995,7 @@ BUILDIN(areamonster) { /*========================================== * KillMonster subcheck, verify if mob to kill ain't got an even to handle, could be force kill by allflag *------------------------------------------*/ -int buildin_killmonster_sub_strip(struct block_list *bl, va_list ap) +static int buildin_killmonster_sub_strip(struct block_list *bl, va_list ap) { //same fix but with killmonster instead - stripping events from mobs. struct mob_data *md = NULL; @@ -10877,7 +11018,7 @@ int buildin_killmonster_sub_strip(struct block_list *bl, va_list ap) md->state.npc_killmonster = 0; return 0; } -int buildin_killmonster_sub(struct block_list *bl, va_list ap) +static int buildin_killmonster_sub(struct block_list *bl, va_list ap) { struct mob_data *md = NULL; char *event = va_arg(ap,char *); @@ -10896,7 +11037,8 @@ int buildin_killmonster_sub(struct block_list *bl, va_list ap) } return 0; } -BUILDIN(killmonster) { +static BUILDIN(killmonster) +{ const char *mapname,*event; int16 m,allflag=0; mapname=script_getstr(st,2); @@ -10925,7 +11067,7 @@ BUILDIN(killmonster) { return true; } -int buildin_killmonsterall_sub_strip(struct block_list *bl,va_list ap) +static int buildin_killmonsterall_sub_strip(struct block_list *bl, va_list ap) { //Strips the event from the mob if it's killed the old method. struct mob_data *md; @@ -10937,12 +11079,13 @@ int buildin_killmonsterall_sub_strip(struct block_list *bl,va_list ap) status_kill(bl); return 0; } -int buildin_killmonsterall_sub(struct block_list *bl,va_list ap) +static int buildin_killmonsterall_sub(struct block_list *bl, va_list ap) { status_kill(bl); return 0; } -BUILDIN(killmonsterall) { +static BUILDIN(killmonsterall) +{ const char *mapname; int16 m; mapname=script_getstr(st,2); @@ -10968,7 +11111,8 @@ BUILDIN(killmonsterall) { * Creates a clone of a player. * clone map, x, y, event, char_id, master_id, mode, flag, duration *------------------------------------------*/ -BUILDIN(clone) { +static BUILDIN(clone) +{ struct map_session_data *sd, *msd = NULL; int char_id, master_id = 0, x, y, flag = 0, m; uint32 mode = 0; @@ -11016,7 +11160,7 @@ BUILDIN(clone) { } /*========================================== *------------------------------------------*/ -BUILDIN(doevent) +static BUILDIN(doevent) { const char* event = script_getstr(st,2); struct map_session_data* sd; @@ -11032,7 +11176,7 @@ BUILDIN(doevent) } /*========================================== *------------------------------------------*/ -BUILDIN(donpcevent) +static BUILDIN(donpcevent) { const char* event = script_getstr(st,2); script->check_event(st, event); @@ -11047,7 +11191,7 @@ BUILDIN(donpcevent) /*========================================== *------------------------------------------*/ -BUILDIN(addtimer) +static BUILDIN(addtimer) { int tick = script_getnum(st, 2); const char* event = script_getstr(st, 3); @@ -11076,7 +11220,7 @@ BUILDIN(addtimer) } /*========================================== *------------------------------------------*/ -BUILDIN(deltimer) +static BUILDIN(deltimer) { const char *event; struct map_session_data *sd; @@ -11097,7 +11241,7 @@ BUILDIN(deltimer) } /*========================================== *------------------------------------------*/ -BUILDIN(addtimercount) +static BUILDIN(addtimercount) { const char *event; int tick; @@ -11125,7 +11269,7 @@ enum gettimer_mode { GETTIMER_TICK_LAST = 2, }; -BUILDIN(gettimer) +static BUILDIN(gettimer) { struct map_session_data *sd; const struct TimerData *td; @@ -11213,7 +11357,7 @@ BUILDIN(gettimer) return true; } -int buildin_getunits_sub(struct block_list *bl, va_list ap) +static int buildin_getunits_sub(struct block_list *bl, va_list ap) { struct script_state *st = va_arg(ap, struct script_state *); struct map_session_data *sd = va_arg(ap, struct map_session_data *); @@ -11256,7 +11400,7 @@ static int buildin_getunits_sub_npc(struct npc_data *nd, va_list ap) return buildin_getunits_sub(&nd->bl, ap); } -BUILDIN(getunits) +static BUILDIN(getunits) { const char *name; int32 id; @@ -11352,7 +11496,7 @@ BUILDIN(getunits) /*========================================== *------------------------------------------*/ -BUILDIN(initnpctimer) +static BUILDIN(initnpctimer) { struct npc_data *nd; int flag = 0; @@ -11397,7 +11541,7 @@ BUILDIN(initnpctimer) } /*========================================== *------------------------------------------*/ -BUILDIN(startnpctimer) +static BUILDIN(startnpctimer) { struct npc_data *nd; int flag = 0; @@ -11440,7 +11584,8 @@ BUILDIN(startnpctimer) } /*========================================== *------------------------------------------*/ -BUILDIN(stopnpctimer) { +static BUILDIN(stopnpctimer) +{ struct npc_data *nd; int flag = 0; @@ -11478,7 +11623,7 @@ BUILDIN(stopnpctimer) { } /*========================================== *------------------------------------------*/ -BUILDIN(getnpctimer) +static BUILDIN(getnpctimer) { struct npc_data *nd; struct map_session_data *sd; @@ -11516,7 +11661,7 @@ BUILDIN(getnpctimer) } /*========================================== *------------------------------------------*/ -BUILDIN(setnpctimer) +static BUILDIN(setnpctimer) { int tick; struct npc_data *nd; @@ -11541,7 +11686,7 @@ BUILDIN(setnpctimer) /*========================================== * attaches the player rid to the timer [Celest] *------------------------------------------*/ -BUILDIN(attachnpctimer) +static BUILDIN(attachnpctimer) { struct map_session_data *sd; struct npc_data *nd = map->id2nd(st->oid); @@ -11570,7 +11715,8 @@ BUILDIN(attachnpctimer) /*========================================== * detaches a player rid from the timer [Celest] *------------------------------------------*/ -BUILDIN(detachnpctimer) { +static BUILDIN(detachnpctimer) +{ struct npc_data *nd; if( script_hasdata(st,2) ) @@ -11594,7 +11740,8 @@ BUILDIN(detachnpctimer) { * it checks if there is a player attached to the current script. [Skotlex] * If no, returns 0, if yes, returns the account_id of the attached player. *------------------------------------------*/ -BUILDIN(playerattached) { +static BUILDIN(playerattached) +{ if(st->rid == 0 || map->id2sd(st->rid) == NULL) script_pushint(st,0); else @@ -11604,7 +11751,7 @@ BUILDIN(playerattached) { /*========================================== *------------------------------------------*/ -BUILDIN(announce) +static BUILDIN(announce) { const char *mes = script_getstr(st,2); int flag = script_getnum(st,3); @@ -11652,7 +11799,7 @@ BUILDIN(announce) } /*========================================== *------------------------------------------*/ -int buildin_announce_sub(struct block_list *bl, va_list ap) +static int buildin_announce_sub(struct block_list *bl, va_list ap) { const char *mes = va_arg(ap, const char *); int len = va_arg(ap, int); @@ -11671,7 +11818,7 @@ int buildin_announce_sub(struct block_list *bl, va_list ap) /* Runs item effect on attached character. * itemeffect <item id>; * itemeffect "<item name>"; */ -BUILDIN(itemeffect) +static BUILDIN(itemeffect) { struct npc_data *nd; struct item_data *item_data; @@ -11704,7 +11851,7 @@ BUILDIN(itemeffect) return true; } -BUILDIN(mapannounce) +static BUILDIN(mapannounce) { const char *mapname = script_getstr(st,2); const char *mes = script_getstr(st,3); @@ -11727,7 +11874,7 @@ BUILDIN(mapannounce) } /*========================================== *------------------------------------------*/ -BUILDIN(areaannounce) +static BUILDIN(areaannounce) { const char *mapname = script_getstr(st,2); int x0 = script_getnum(st,3); @@ -11755,7 +11902,8 @@ BUILDIN(areaannounce) /*========================================== *------------------------------------------*/ -BUILDIN(getusers) { +static BUILDIN(getusers) +{ int flag, val = 0; struct map_session_data* sd; struct block_list* bl = NULL; @@ -11791,7 +11939,7 @@ BUILDIN(getusers) { /*========================================== * Works like @WHO - displays all online users names in window *------------------------------------------*/ -BUILDIN(getusersname) +static BUILDIN(getusersname) { struct map_session_data *sd; const struct map_session_data *pl_sd; @@ -11820,7 +11968,7 @@ BUILDIN(getusersname) /*========================================== * getmapguildusers("mapname",guild ID) Returns the number guild members present on a map [Reddozen] *------------------------------------------*/ -BUILDIN(getmapguildusers) +static BUILDIN(getmapguildusers) { const char *str; int16 m; @@ -11848,7 +11996,8 @@ BUILDIN(getmapguildusers) } /*========================================== *------------------------------------------*/ -BUILDIN(getmapusers) { +static BUILDIN(getmapusers) +{ const char *str; int16 m; str=script_getstr(st,2); @@ -11861,7 +12010,7 @@ BUILDIN(getmapusers) { } /*========================================== *------------------------------------------*/ -int buildin_getareausers_sub(struct block_list *bl,va_list ap) +static int buildin_getareausers_sub(struct block_list *bl, va_list ap) { int *users=va_arg(ap,int *); nullpo_ret(users); @@ -11869,7 +12018,7 @@ int buildin_getareausers_sub(struct block_list *bl,va_list ap) return 0; } -BUILDIN(getareausers) +static BUILDIN(getareausers) { int16 m = -1, x0, y0, x1, y1; int users = 0; @@ -11929,7 +12078,7 @@ BUILDIN(getareausers) /*========================================== *------------------------------------------*/ -int buildin_getareadropitem_sub(struct block_list *bl, va_list ap) +static int buildin_getareadropitem_sub(struct block_list *bl, va_list ap) { int item = va_arg(ap, int); int *amount = va_arg(ap, int *); @@ -11945,7 +12094,8 @@ int buildin_getareadropitem_sub(struct block_list *bl, va_list ap) return 0; } -BUILDIN(getareadropitem) { +static BUILDIN(getareadropitem) +{ const char *str; int16 m,x0,y0,x1,y1; int item,amount=0; @@ -11977,7 +12127,7 @@ BUILDIN(getareadropitem) { } /*========================================== *------------------------------------------*/ -BUILDIN(enablenpc) +static BUILDIN(enablenpc) { const char *str; str=script_getstr(st,2); @@ -11986,7 +12136,7 @@ BUILDIN(enablenpc) } /*========================================== *------------------------------------------*/ -BUILDIN(disablenpc) +static BUILDIN(disablenpc) { const char *str; str=script_getstr(st,2); @@ -11996,7 +12146,7 @@ BUILDIN(disablenpc) /*========================================== *------------------------------------------*/ -BUILDIN(hideoffnpc) +static BUILDIN(hideoffnpc) { const char *str; str=script_getstr(st,2); @@ -12005,7 +12155,7 @@ BUILDIN(hideoffnpc) } /*========================================== *------------------------------------------*/ -BUILDIN(hideonnpc) +static BUILDIN(hideonnpc) { const char *str; str=script_getstr(st,2); @@ -12020,7 +12170,7 @@ BUILDIN(hideonnpc) * sc_start4 <effect_id>,<duration>,<val1>,<val2>,<val3>,<val4>{,<rate,<flag>,{<unit_id>}}; * <flag>: @see enum scstart_flag */ -BUILDIN(sc_start) +static BUILDIN(sc_start) { struct npc_data *nd = map->id2nd(st->oid); struct block_list* bl; @@ -12088,7 +12238,8 @@ BUILDIN(sc_start) /// Ends one or all status effects on the target unit or on the attached player. /// /// sc_end <effect_id>{,<unit_id>}; -BUILDIN(sc_end) { +static BUILDIN(sc_end) +{ struct block_list* bl; int type; @@ -12135,7 +12286,8 @@ BUILDIN(sc_end) { /*========================================== * @FIXME atm will return reduced tick, 0 immune, 1 no tick *------------------------------------------*/ -BUILDIN(getscrate) { +static BUILDIN(getscrate) +{ struct block_list *bl; int type,rate; @@ -12156,7 +12308,7 @@ BUILDIN(getscrate) { /*========================================== * getstatus <type>{, <info>}; *------------------------------------------*/ -BUILDIN(getstatus) +static BUILDIN(getstatus) { int id, type; struct map_session_data* sd = script->rid2sd(st); @@ -12207,7 +12359,7 @@ BUILDIN(getstatus) /*========================================== * *------------------------------------------*/ -BUILDIN(debugmes) +static BUILDIN(debugmes) { const char *str; str=script_getstr(st,2); @@ -12217,7 +12369,7 @@ BUILDIN(debugmes) /*========================================== *------------------------------------------*/ -BUILDIN(catchpet) +static BUILDIN(catchpet) { int pet_id; struct map_session_data *sd; @@ -12234,7 +12386,7 @@ BUILDIN(catchpet) /*========================================== * [orn] *------------------------------------------*/ -BUILDIN(homunculus_evolution) +static BUILDIN(homunculus_evolution) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -12254,7 +12406,7 @@ BUILDIN(homunculus_evolution) * Checks for vaporized morph state * and deletes ITEMID_STRANGE_EMBRYO. *------------------------------------------*/ -BUILDIN(homunculus_mutate) +static BUILDIN(homunculus_mutate) { bool success = false; struct map_session_data *sd = script->rid2sd(st); @@ -12295,7 +12447,7 @@ BUILDIN(homunculus_mutate) * Puts homunculus into morph state * and gives ITEMID_STRANGE_EMBRYO. *------------------------------------------*/ -BUILDIN(homunculus_morphembryo) +static BUILDIN(homunculus_morphembryo) { bool success = false; struct map_session_data *sd = script->rid2sd(st); @@ -12338,7 +12490,7 @@ BUILDIN(homunculus_morphembryo) * 1 = Homunculus is vaporized (rest) * 2 = Homunculus is in morph state *------------------------------------------*/ -BUILDIN(homunculus_checkcall) +static BUILDIN(homunculus_checkcall) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL || sd->hd == NULL) @@ -12350,7 +12502,7 @@ BUILDIN(homunculus_checkcall) } // [Zephyrus] -BUILDIN(homunculus_shuffle) +static BUILDIN(homunculus_shuffle) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -12363,7 +12515,7 @@ BUILDIN(homunculus_shuffle) } //These two functions bring the eA MAPID_* class functionality to scripts. -BUILDIN(eaclass) +static BUILDIN(eaclass) { int class; if (script_hasdata(st,2)) { @@ -12378,7 +12530,7 @@ BUILDIN(eaclass) return true; } -BUILDIN(roclass) +static BUILDIN(roclass) { int job = script_getnum(st,2); int sex; @@ -12398,7 +12550,7 @@ BUILDIN(roclass) /*========================================== * Tells client to open a hatching window, used for pet incubator *------------------------------------------*/ -BUILDIN(birthpet) +static BUILDIN(birthpet) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -12421,7 +12573,7 @@ BUILDIN(birthpet) * 3 : don't reset skill, blvl=1 * 4 : jlvl=0 *------------------------------------------*/ -BUILDIN(resetlvl) +static BUILDIN(resetlvl) { int type=script_getnum(st,2); struct map_session_data *sd = script->rid2sd(st); @@ -12434,7 +12586,7 @@ BUILDIN(resetlvl) /*========================================== * Reset a player status point *------------------------------------------*/ -BUILDIN(resetstatus) +static BUILDIN(resetstatus) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -12446,7 +12598,7 @@ BUILDIN(resetstatus) /*========================================== * script command resetskill *------------------------------------------*/ -BUILDIN(resetskill) +static BUILDIN(resetskill) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -12458,7 +12610,7 @@ BUILDIN(resetskill) /*========================================== * Counts total amount of skill points. *------------------------------------------*/ -BUILDIN(skillpointcount) +static BUILDIN(skillpointcount) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -12470,7 +12622,7 @@ BUILDIN(skillpointcount) /*========================================== * *------------------------------------------*/ -BUILDIN(changebase) +static BUILDIN(changebase) { struct map_session_data *sd = NULL; int vclass; @@ -12516,7 +12668,7 @@ static struct map_session_data *prepareChangeSex(struct script_state *st) /*========================================== * Unequip all item and request for a changesex to char-serv *------------------------------------------*/ -BUILDIN(changesex) +static BUILDIN(changesex) { struct map_session_data *sd = prepareChangeSex(st); if (sd == NULL) @@ -12528,7 +12680,7 @@ BUILDIN(changesex) /*========================================== * Unequip all items and change character sex [4144] *------------------------------------------*/ -BUILDIN(changecharsex) +static BUILDIN(changecharsex) { struct map_session_data *sd = prepareChangeSex(st); if (sd == NULL) @@ -12540,7 +12692,7 @@ BUILDIN(changecharsex) /*========================================== * Works like 'announce' but outputs in the common chat window *------------------------------------------*/ -BUILDIN(globalmes) +static BUILDIN(globalmes) { const char *name=NULL,*mes; @@ -12568,7 +12720,7 @@ BUILDIN(globalmes) /// Creates a waiting room (chat room) for this npc. /// /// waitingroom "<title>",<limit>{,"<event>"{,<trigger>{,<zeny>{,<minlvl>{,<maxlvl>}}}}}; -BUILDIN(waitingroom) +static BUILDIN(waitingroom) { struct npc_data* nd; const char* title = script_getstr(st, 2); @@ -12592,7 +12744,8 @@ BUILDIN(waitingroom) /// /// delwaitingroom "<npc_name>"; /// delwaitingroom; -BUILDIN(delwaitingroom) { +static BUILDIN(delwaitingroom) +{ struct npc_data* nd; if( script_hasdata(st,2) ) nd = npc->name2id(script_getstr(st, 2)); @@ -12607,7 +12760,8 @@ BUILDIN(delwaitingroom) { /// /// kickwaitingroomall "<npc_name>"; /// kickwaitingroomall; -BUILDIN(waitingroomkickall) { +static BUILDIN(waitingroomkickall) +{ struct npc_data* nd; struct chat_data* cd; @@ -12625,7 +12779,8 @@ BUILDIN(waitingroomkickall) { /// /// enablewaitingroomevent "<npc_name>"; /// enablewaitingroomevent; -BUILDIN(enablewaitingroomevent) { +static BUILDIN(enablewaitingroomevent) +{ struct npc_data* nd; struct chat_data* cd; @@ -12643,7 +12798,8 @@ BUILDIN(enablewaitingroomevent) { /// /// disablewaitingroomevent "<npc_name>"; /// disablewaitingroomevent; -BUILDIN(disablewaitingroomevent) { +static BUILDIN(disablewaitingroomevent) +{ struct npc_data *nd; struct chat_data *cd; @@ -12675,7 +12831,7 @@ BUILDIN(disablewaitingroomevent) { /// /// getwaitingroomstate(<type>,"<npc_name>") -> <info> /// getwaitingroomstate(<type>) -> <info> -BUILDIN(getwaitingroomstate) +static BUILDIN(getwaitingroomstate) { const struct npc_data *nd; const struct chat_data *cd; @@ -12731,7 +12887,7 @@ BUILDIN(getwaitingroomstate) /// /// warpwaitingpc "<map name>",<x>,<y>,<number of players>; /// warpwaitingpc "<map name>",<x>,<y>; -BUILDIN(warpwaitingpc) +static BUILDIN(warpwaitingpc) { int x, y, i, n; const char* map_name; @@ -12788,7 +12944,8 @@ BUILDIN(warpwaitingpc) /// Detaches a character from a script. /// /// @param st Script state to detach the character from. -void script_detach_rid(struct script_state* st) { +static void script_detach_rid(struct script_state *st) +{ if(st->rid) { script->detach_state(st, false); st->rid = 0; @@ -12798,7 +12955,8 @@ void script_detach_rid(struct script_state* st) { /*========================================== * Attach sd char id to script and detach current one if any *------------------------------------------*/ -BUILDIN(attachrid) { +static BUILDIN(attachrid) +{ int rid = script_getnum(st,2); if (map->id2sd(rid) != NULL) { @@ -12814,7 +12972,7 @@ BUILDIN(attachrid) { /*========================================== * Detach script to rid *------------------------------------------*/ -BUILDIN(detachrid) +static BUILDIN(detachrid) { script->detach_rid(st); return true; @@ -12822,7 +12980,7 @@ BUILDIN(detachrid) /*========================================== * Chk if account connected, (and charid from account if specified) *------------------------------------------*/ -BUILDIN(isloggedin) +static BUILDIN(isloggedin) { struct map_session_data *sd = map->id2sd(script_getnum(st,2)); if (script_hasdata(st,3) && sd != NULL @@ -12835,7 +12993,8 @@ BUILDIN(isloggedin) /*========================================== * *------------------------------------------*/ -BUILDIN(setmapflagnosave) { +static BUILDIN(setmapflagnosave) +{ int16 m,x,y; unsigned short map_index; const char *str,*str2; @@ -12865,7 +13024,7 @@ enum mapinfo_info { MAPINFO_ZONE }; -BUILDIN(getmapinfo) +static BUILDIN(getmapinfo) { enum mapinfo_info mode = script_getnum(st, 2); int16 m = -1; @@ -12927,7 +13086,7 @@ BUILDIN(getmapinfo) return true; } -BUILDIN(getmapflag) +static BUILDIN(getmapflag) { int16 m,i; const char *str; @@ -12999,7 +13158,7 @@ BUILDIN(getmapflag) return true; } /* pvp timer handling */ -int script_mapflag_pvp_sub(struct block_list *bl, va_list ap) +static int script_mapflag_pvp_sub(struct block_list *bl, va_list ap) { struct map_session_data *sd = NULL; @@ -13021,7 +13180,8 @@ int script_mapflag_pvp_sub(struct block_list *bl, va_list ap) return 0; } -BUILDIN(setmapflag) { +static BUILDIN(setmapflag) +{ int16 m,i; const char *str, *val2 = NULL; int val=0; @@ -13127,7 +13287,8 @@ BUILDIN(setmapflag) { return true; } -BUILDIN(removemapflag) { +static BUILDIN(removemapflag) +{ int16 m,i; const char *str; @@ -13215,7 +13376,7 @@ BUILDIN(removemapflag) { return true; } -BUILDIN(pvpon) +static BUILDIN(pvpon) { int16 m; const char *str; @@ -13261,7 +13422,7 @@ BUILDIN(pvpon) return true; } -int buildin_pvpoff_sub(struct block_list *bl, va_list ap) +static int buildin_pvpoff_sub(struct block_list *bl, va_list ap) { struct map_session_data *sd = NULL; @@ -13277,7 +13438,8 @@ int buildin_pvpoff_sub(struct block_list *bl, va_list ap) return 0; } -BUILDIN(pvpoff) { +static BUILDIN(pvpoff) +{ int16 m; const char *str; struct block_list bl; @@ -13301,7 +13463,8 @@ BUILDIN(pvpoff) { return true; } -BUILDIN(gvgon) { +static BUILDIN(gvgon) +{ int16 m; const char *str; @@ -13325,7 +13488,8 @@ BUILDIN(gvgon) { return true; } -BUILDIN(gvgoff) { +static BUILDIN(gvgoff) +{ int16 m; const char *str; @@ -13348,7 +13512,8 @@ BUILDIN(gvgoff) { * emotion emotion#, <target: 0 - NPC, 1 - PC>, <NPC/PC name> *------------------------------------------*/ //Optional second parameter added by [Skotlex] -BUILDIN(emotion) { +static BUILDIN(emotion) +{ int type; int player=0; @@ -13377,7 +13542,7 @@ BUILDIN(emotion) { return true; } -int buildin_maprespawnguildid_sub_pc(struct map_session_data* sd, va_list ap) +static int buildin_maprespawnguildid_sub_pc(struct map_session_data *sd, va_list ap) { int16 m=va_arg(ap,int); int g_id=va_arg(ap,int); @@ -13394,7 +13559,7 @@ int buildin_maprespawnguildid_sub_pc(struct map_session_data* sd, va_list ap) return 1; } -int buildin_maprespawnguildid_sub_mob(struct block_list *bl, va_list ap) +static int buildin_maprespawnguildid_sub_mob(struct block_list *bl, va_list ap) { struct mob_data *md = NULL; @@ -13408,7 +13573,8 @@ int buildin_maprespawnguildid_sub_mob(struct block_list *bl, va_list ap) return 0; } -BUILDIN(maprespawnguildid) { +static BUILDIN(maprespawnguildid) +{ const char *mapname=script_getstr(st,2); int g_id=script_getnum(st,3); int flag=script_getnum(st,4); @@ -13425,28 +13591,32 @@ BUILDIN(maprespawnguildid) { return true; } -BUILDIN(agitstart) { +static BUILDIN(agitstart) +{ if(map->agit_flag==1) return true; // Agit already Start. map->agit_flag=1; guild->agit_start(); return true; } -BUILDIN(agitend) { +static BUILDIN(agitend) +{ if(map->agit_flag==0) return true; // Agit already End. map->agit_flag=0; guild->agit_end(); return true; } -BUILDIN(agitstart2) { +static BUILDIN(agitstart2) +{ if(map->agit2_flag==1) return true; // Agit2 already Start. map->agit2_flag=1; guild->agit2_start(); return true; } -BUILDIN(agitend2) { +static BUILDIN(agitend2) +{ if(map->agit2_flag==0) return true; // Agit2 already End. map->agit2_flag=0; guild->agit2_end(); @@ -13456,7 +13626,8 @@ BUILDIN(agitend2) { /*========================================== * Returns whether woe is on or off. *------------------------------------------*/ -BUILDIN(agitcheck) { +static BUILDIN(agitcheck) +{ script_pushint(st,map->agit_flag); return true; } @@ -13464,7 +13635,8 @@ BUILDIN(agitcheck) { /*========================================== * Returns whether woese is on or off. *------------------------------------------*/ -BUILDIN(agitcheck2) { +static BUILDIN(agitcheck2) +{ script_pushint(st,map->agit2_flag); return true; } @@ -13472,7 +13644,7 @@ BUILDIN(agitcheck2) { /// Sets the guild_id of this npc. /// /// flagemblem <guild_id>; -BUILDIN(flagemblem) +static BUILDIN(flagemblem) { struct npc_data *nd; int g_id = script_getnum(st,2); @@ -13497,7 +13669,7 @@ BUILDIN(flagemblem) return true; } -BUILDIN(getcastlename) +static BUILDIN(getcastlename) { const char* mapname = mapindex->getmapname(script_getstr(st,2),NULL); struct guild_castle* gc = guild->mapname2gc(mapname); @@ -13506,7 +13678,7 @@ BUILDIN(getcastlename) return true; } -BUILDIN(getcastledata) +static BUILDIN(getcastledata) { const char *mapname = mapindex->getmapname(script_getstr(st,2),NULL); int index = script_getnum(st,3); @@ -13549,7 +13721,7 @@ BUILDIN(getcastledata) return true; } -BUILDIN(setcastledata) +static BUILDIN(setcastledata) { const char *mapname = mapindex->getmapname(script_getstr(st,2),NULL); int index = script_getnum(st,3); @@ -13572,7 +13744,7 @@ BUILDIN(setcastledata) /* ===================================================================== * ---------------------------------------------------------------------*/ -BUILDIN(requestguildinfo) +static BUILDIN(requestguildinfo) { int guild_id=script_getnum(st,2); const char *event=NULL; @@ -13589,7 +13761,7 @@ BUILDIN(requestguildinfo) /// Returns the number of cards that have been compounded onto the specified equipped item. /// getequipcardcnt(<equipment slot>); -BUILDIN(getequipcardcnt) +static BUILDIN(getequipcardcnt) { int i=-1,j,num; struct map_session_data *sd; @@ -13627,7 +13799,7 @@ BUILDIN(getequipcardcnt) /// Removes all cards from the item found in the specified equipment slot of the invoking character, /// and give them to the character. If any cards were removed in this manner, it will also show a success effect. /// successremovecards(<slot>); -BUILDIN(successremovecards) +static BUILDIN(successremovecards) { int i = -1, c, cardflag = 0; @@ -13681,7 +13853,7 @@ BUILDIN(successremovecards) /// <type>=1 : will keep the item, but destroy the cards. /// <type>=2 : will keep the cards, but destroy the item. /// <type>=3 : will just display the failure effect. -BUILDIN(failedremovecards) +static BUILDIN(failedremovecards) { int i = -1, c, cardflag = 0; int num = script_getnum(st, 2); @@ -13745,7 +13917,8 @@ BUILDIN(failedremovecards) * improved by [Lance] * ================================================================*/ // Added by RoVeRT -BUILDIN(mapwarp) { +static BUILDIN(mapwarp) +{ int x,y,m,check_val=0,check_ID=0,i=0; struct guild *g = NULL; struct party_data *p = NULL; @@ -13798,7 +13971,7 @@ BUILDIN(mapwarp) { } // Added by RoVeRT -int buildin_mobcount_sub(struct block_list *bl, va_list ap) +static int buildin_mobcount_sub(struct block_list *bl, va_list ap) { char *event = va_arg(ap,char *); const struct mob_data *md = NULL; @@ -13813,7 +13986,8 @@ int buildin_mobcount_sub(struct block_list *bl, va_list ap) } // Added by RoVeRT -BUILDIN(mobcount) { +static BUILDIN(mobcount) +{ const char *mapname,*event; int16 m; mapname=script_getstr(st,2); @@ -13846,7 +14020,8 @@ BUILDIN(mobcount) { return true; } -BUILDIN(marriage) { +static BUILDIN(marriage) +{ const char *partner=script_getstr(st,2); struct map_session_data *sd = script->rid2sd(st); struct map_session_data *p_sd = script->nick2sd(st, partner); @@ -13858,7 +14033,7 @@ BUILDIN(marriage) { script_pushint(st,1); return true; } -BUILDIN(wedding_effect) +static BUILDIN(wedding_effect) { struct map_session_data *sd = script->rid2sd(st); struct block_list *bl; @@ -13870,7 +14045,7 @@ BUILDIN(wedding_effect) clif->wedding_effect(bl); return true; } -BUILDIN(divorce) +static BUILDIN(divorce) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL || pc->divorce(sd) < 0) { @@ -13881,7 +14056,8 @@ BUILDIN(divorce) return true; } -BUILDIN(ispartneron) { +static BUILDIN(ispartneron) +{ struct map_session_data *sd = script->rid2sd(st); if (sd==NULL || !pc->ismarried(sd) @@ -13894,7 +14070,7 @@ BUILDIN(ispartneron) { return true; } -BUILDIN(getpartnerid) +static BUILDIN(getpartnerid) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -13904,7 +14080,7 @@ BUILDIN(getpartnerid) return true; } -BUILDIN(getchildid) +static BUILDIN(getchildid) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -13914,7 +14090,7 @@ BUILDIN(getchildid) return true; } -BUILDIN(getmotherid) +static BUILDIN(getmotherid) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -13924,7 +14100,8 @@ BUILDIN(getmotherid) return true; } -BUILDIN(getfatherid) { +static BUILDIN(getfatherid) +{ struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) return true; @@ -13933,7 +14110,7 @@ BUILDIN(getfatherid) { return true; } -BUILDIN(warppartner) +static BUILDIN(warppartner) { int x,y; unsigned short map_index; @@ -13963,7 +14140,7 @@ BUILDIN(warppartner) /*================================================ * Script for Displaying MOB Information [Valaris] *------------------------------------------------*/ -BUILDIN(strmobinfo) +static BUILDIN(strmobinfo) { int num=script_getnum(st,2); @@ -13997,7 +14174,8 @@ BUILDIN(strmobinfo) * Summon guardians [Valaris] * guardian("<map name>",<x>,<y>,"<name to show>",<mob id>{,"<event label>"}{,<guardian index>}) -> <id> *------------------------------------------*/ -BUILDIN(guardian) { +static BUILDIN(guardian) +{ int class_ = 0, x = 0, y = 0, guardian = 0; const char *str, *mapname, *evt=""; bool has_index = false; @@ -14038,7 +14216,8 @@ BUILDIN(guardian) { /*========================================== * Invisible Walls [Zephyrus] *------------------------------------------*/ -BUILDIN(setwall) { +static BUILDIN(setwall) +{ const char *mapname, *name; int x, y, m, size, dir; bool shootable; @@ -14058,7 +14237,7 @@ BUILDIN(setwall) { return true; } -BUILDIN(delwall) +static BUILDIN(delwall) { const char *name = script_getstr(st,2); @@ -14077,7 +14256,8 @@ BUILDIN(delwall) /// 1 - maximum hp /// 2 - current hp /// -BUILDIN(guardianinfo) { +static BUILDIN(guardianinfo) +{ const char* mapname = mapindex->getmapname(script_getstr(st,2),NULL); int id = script_getnum(st,3); int type = script_getnum(st,4); @@ -14109,7 +14289,8 @@ BUILDIN(guardianinfo) { /*========================================== * Get the item name by item_id or null *------------------------------------------*/ -BUILDIN(getitemname) { +static BUILDIN(getitemname) +{ int item_id=0; struct item_data *i_data; char *item_name; @@ -14137,7 +14318,7 @@ BUILDIN(getitemname) { /*========================================== * Returns number of slots an item has. [Skotlex] *------------------------------------------*/ -BUILDIN(getitemslots) +static BUILDIN(getitemslots) { int item_id; struct item_data *i_data; @@ -14159,7 +14340,7 @@ BUILDIN(getitemslots) * Returns some values of an item [Lupus] * Price, Weight, etc... *------------------------------------------*/ -BUILDIN(getiteminfo) +static BUILDIN(getiteminfo) { int item_id = script_getnum(st, 2); int n = script_getnum(st, 3); @@ -14241,7 +14422,7 @@ BUILDIN(getiteminfo) * IT_OPT_VALUE Amount of the bonus to be added. * @return value of the type or -1. */ -BUILDIN(getequippedoptioninfo) +static BUILDIN(getequippedoptioninfo) { int val = 0, type = script_getnum(st, 2); struct map_session_data *sd = NULL; @@ -14279,7 +14460,7 @@ BUILDIN(getequippedoptioninfo) * @param type IT_OPT_INDEX or IT_OPT_VALUE. * @return (int) value or -1 on failure. */ -BUILDIN(getequipoption) +static BUILDIN(getequipoption) { int val = 0, equip_index = script_getnum(st, 2); int slot = script_getnum(st, 3); @@ -14343,7 +14524,7 @@ BUILDIN(getequipoption) * For IT_OPT_VALUE, the value of the script bonus. * @return 0 on failure, 1 on success. */ -BUILDIN(setequipoption) +static BUILDIN(setequipoption) { int equip_index = script_getnum(st, 2); int slot = script_getnum(st, 3); @@ -14352,7 +14533,7 @@ BUILDIN(setequipoption) int i = -1; struct map_session_data *sd = script->rid2sd(st); - struct item_option *ito = NULL; + struct itemdb_option *ito = NULL; if (sd == NULL) { script_pushint(st, 0); @@ -14423,7 +14604,7 @@ BUILDIN(setequipoption) * Set some values of an item [Lupus] * Price, Weight, etc... *------------------------------------------*/ -BUILDIN(setiteminfo) +static BUILDIN(setiteminfo) { // TODO: Validate data in a similar way as during database load int item_id = script_getnum(st, 2); @@ -14509,7 +14690,7 @@ BUILDIN(setiteminfo) * Useful for such quests as "Sign this refined item with players name" etc * Hat[0] +4 -> Player's Hat[0] +4 *------------------------------------------*/ -BUILDIN(getequipcardid) +static BUILDIN(getequipcardid) { int i=-1,num,slot; struct map_session_data *sd; @@ -14534,7 +14715,7 @@ BUILDIN(getequipcardid) /*========================================== * petskillbonus [Valaris] //Rewritten by [Skotlex] *------------------------------------------*/ -BUILDIN(petskillbonus) +static BUILDIN(petskillbonus) { struct pet_data *pd; @@ -14571,7 +14752,7 @@ BUILDIN(petskillbonus) /*========================================== * pet looting [Valaris] //Rewritten by [Skotlex] *------------------------------------------*/ -BUILDIN(petloot) +static BUILDIN(petloot) { int max; struct pet_data *pd; @@ -14611,7 +14792,7 @@ BUILDIN(petloot) * @inventorylist_card(0..3), @inventorylist_expire * @inventorylist_count = scalar *------------------------------------------*/ -BUILDIN(getinventorylist) +static BUILDIN(getinventorylist) { struct map_session_data *sd = script->rid2sd(st); char card_var[SCRIPT_VARNAME_LENGTH]; @@ -14652,7 +14833,7 @@ BUILDIN(getinventorylist) return true; } -BUILDIN(getcartinventorylist) +static BUILDIN(getcartinventorylist) { struct map_session_data *sd = script->rid2sd(st); char card_var[SCRIPT_VARNAME_LENGTH]; @@ -14689,7 +14870,7 @@ BUILDIN(getcartinventorylist) return true; } -BUILDIN(getskilllist) +static BUILDIN(getskilllist) { struct map_session_data *sd = script->rid2sd(st); int i,j=0; @@ -14707,7 +14888,7 @@ BUILDIN(getskilllist) return true; } -BUILDIN(clearitem) +static BUILDIN(clearitem) { struct map_session_data *sd = script->rid2sd(st); int i; @@ -14724,7 +14905,7 @@ BUILDIN(clearitem) /*========================================== * Disguise Player (returns Mob/NPC ID if success, 0 on fail) *------------------------------------------*/ -BUILDIN(disguise) +static BUILDIN(disguise) { int id; struct map_session_data *sd = script->rid2sd(st); @@ -14745,7 +14926,7 @@ BUILDIN(disguise) /*========================================== * Undisguise Player (returns 1 if success, 0 on fail) *------------------------------------------*/ -BUILDIN(undisguise) +static BUILDIN(undisguise) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -14764,7 +14945,7 @@ BUILDIN(undisguise) * Transform a bl to another class, * @type unused *------------------------------------------*/ -BUILDIN(classchange) +static BUILDIN(classchange) { int class, type, target; struct block_list *bl = map->id2bl(st->oid); @@ -14790,7 +14971,7 @@ BUILDIN(classchange) /*========================================== * Display an effect *------------------------------------------*/ -BUILDIN(misceffect) +static BUILDIN(misceffect) { int type; @@ -14809,7 +14990,7 @@ BUILDIN(misceffect) /*========================================== * Play a BGM on a single client [Rikter/Yommy] *------------------------------------------*/ -BUILDIN(playbgm) +static BUILDIN(playbgm) { struct map_session_data* sd = script->rid2sd(st); @@ -14822,7 +15003,7 @@ BUILDIN(playbgm) return true; } -int playbgm_sub(struct block_list* bl,va_list ap) +static int playbgm_sub(struct block_list *bl, va_list ap) { const char* name = va_arg(ap,const char*); @@ -14831,7 +15012,7 @@ int playbgm_sub(struct block_list* bl,va_list ap) return 0; } -int playbgm_foreachpc_sub(struct map_session_data* sd, va_list args) +static int playbgm_foreachpc_sub(struct map_session_data *sd, va_list args) { const char* name = va_arg(args, const char*); @@ -14843,7 +15024,8 @@ int playbgm_foreachpc_sub(struct map_session_data* sd, va_list args) /*========================================== * Play a BGM on multiple client [Rikter/Yommy] *------------------------------------------*/ -BUILDIN(playbgmall) { +static BUILDIN(playbgmall) +{ const char* name; name = script_getstr(st,2); @@ -14885,7 +15067,7 @@ BUILDIN(playbgmall) { /*========================================== * Play a .wav sound for sd *------------------------------------------*/ -BUILDIN(soundeffect) +static BUILDIN(soundeffect) { struct map_session_data *sd = script->rid2sd(st); const char* name = script_getstr(st,2); @@ -14897,7 +15079,7 @@ BUILDIN(soundeffect) return true; } -int soundeffect_sub(struct block_list *bl, va_list ap) +static int soundeffect_sub(struct block_list *bl, va_list ap) { struct map_session_data *sd = NULL; char *name = va_arg(ap, char *); @@ -14916,7 +15098,8 @@ int soundeffect_sub(struct block_list *bl, va_list ap) * Play a sound effect (.wav) on multiple clients * soundeffectall "<filepath>",<type>{,"<map name>"}{,<x0>,<y0>,<x1>,<y1>}; *------------------------------------------*/ -BUILDIN(soundeffectall) { +static BUILDIN(soundeffectall) +{ struct block_list* bl; const char* name; int type; @@ -14967,7 +15150,7 @@ BUILDIN(soundeffectall) { /*========================================== * pet status recovery [Valaris] / Rewritten by [Skotlex] *------------------------------------------*/ -BUILDIN(petrecovery) +static BUILDIN(petrecovery) { struct pet_data *pd; struct map_session_data *sd = script->rid2sd(st); @@ -14996,7 +15179,7 @@ BUILDIN(petrecovery) *------------------------------------------*/ /// petskillattack <skill id>,<level>,<div>,<rate>,<bonusrate> /// petskillattack "<skill name>",<level>,<div>,<rate>,<bonusrate> -BUILDIN(petskillattack) +static BUILDIN(petskillattack) { struct pet_data *pd; struct map_session_data *sd = script->rid2sd(st); @@ -15022,7 +15205,7 @@ BUILDIN(petskillattack) *------------------------------------------*/ /// petskillsupport <skill id>,<level>,<delay>,<hp>,<sp> /// petskillsupport "<skill name>",<level>,<delay>,<hp>,<sp> -BUILDIN(petskillsupport) +static BUILDIN(petskillsupport) { struct pet_data *pd; struct map_session_data *sd = script->rid2sd(st); @@ -15061,7 +15244,7 @@ BUILDIN(petskillsupport) *------------------------------------------*/ /// skilleffect <skill id>,<level> /// skilleffect "<skill name>",<level> -BUILDIN(skilleffect) +static BUILDIN(skilleffect) { struct map_session_data *sd; @@ -15089,7 +15272,8 @@ BUILDIN(skilleffect) *------------------------------------------*/ /// npcskilleffect <skill id>,<level>,<x>,<y> /// npcskilleffect "<skill name>",<level>,<x>,<y> -BUILDIN(npcskilleffect) { +static BUILDIN(npcskilleffect) +{ struct block_list *bl= map->id2bl(st->oid); uint16 skill_id=( script_isstringtype(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) ); @@ -15106,7 +15290,8 @@ BUILDIN(npcskilleffect) { /*========================================== * Special effects [Valaris] *------------------------------------------*/ -BUILDIN(specialeffect) { +static BUILDIN(specialeffect) +{ struct block_list *bl = NULL; int type = script_getnum(st, 2); enum send_target target = AREA; @@ -15149,7 +15334,8 @@ BUILDIN(specialeffect) { return true; } -BUILDIN(specialeffect2) { +static BUILDIN(specialeffect2) +{ struct map_session_data *sd; int type = script_getnum(st,2); enum send_target target = script_hasdata(st,3) ? (send_target)script_getnum(st,3) : AREA; @@ -15168,7 +15354,7 @@ BUILDIN(specialeffect2) { /*========================================== * Nude [Valaris] *------------------------------------------*/ -BUILDIN(nude) +static BUILDIN(nude) { struct map_session_data *sd = script->rid2sd(st); int i, calcflag = 0; @@ -15193,7 +15379,7 @@ BUILDIN(nude) /*========================================== * gmcommand [MouseJstr] *------------------------------------------*/ -BUILDIN(atcommand) +static BUILDIN(atcommand) { struct map_session_data *sd, *dummy_sd = NULL; int fd; @@ -15235,7 +15421,7 @@ BUILDIN(atcommand) * dispbottom "<message>"{,<color>}; * @endcode */ -BUILDIN(dispbottom) +static BUILDIN(dispbottom) { struct map_session_data *sd = script->rid2sd(st); const char *message = script_getstr(st,2); @@ -15257,7 +15443,7 @@ BUILDIN(dispbottom) * All The Players Full Recovery * (HP/SP full restore and resurrect if need) *------------------------------------------*/ -int buildin_recovery_sub(struct map_session_data *sd) +static int buildin_recovery_sub(struct map_session_data *sd) { nullpo_retr(0, sd); @@ -15270,17 +15456,17 @@ int buildin_recovery_sub(struct map_session_data *sd) return 0; } -int buildin_recovery_pc_sub(struct map_session_data *sd, va_list ap) +static int buildin_recovery_pc_sub(struct map_session_data *sd, va_list ap) { return script->buildin_recovery_sub(sd); } -int buildin_recovery_bl_sub(struct block_list *bl, va_list ap) +static int buildin_recovery_bl_sub(struct block_list *bl, va_list ap) { return script->buildin_recovery_sub(BL_CAST(BL_PC, bl)); } -BUILDIN(recovery) +static BUILDIN(recovery) { if (script_hasdata(st, 2)) { if (script_isstringtype(st, 2)) { @@ -15318,7 +15504,7 @@ BUILDIN(recovery) * n -> 0:pet_id 1:pet_class 2:pet_name * 3:friendly 4:hungry, 5: rename flag. *------------------------------------------*/ -BUILDIN(getpetinfo) +static BUILDIN(getpetinfo) { struct map_session_data *sd = script->rid2sd(st); struct pet_data *pd; @@ -15352,7 +15538,7 @@ BUILDIN(getpetinfo) * 3:friendly 4:hungry, 5: rename flag. * 6: level *------------------------------------------*/ -BUILDIN(gethominfo) +static BUILDIN(gethominfo) { struct map_session_data *sd = script->rid2sd(st); int type = script_getnum(st,2); @@ -15382,7 +15568,7 @@ BUILDIN(gethominfo) /// Retrieves information about character's mercenary /// getmercinfo <type>[,<char id>]; -BUILDIN(getmercinfo) +static BUILDIN(getmercinfo) { int type; struct map_session_data* sd; @@ -15433,7 +15619,7 @@ BUILDIN(getmercinfo) * selected card or not. * checkequipedcard(4001); *------------------------------------------*/ -BUILDIN(checkequipedcard) +static BUILDIN(checkequipedcard) { int n,i,c=0; struct map_session_data *sd = script->rid2sd(st); @@ -15460,7 +15646,7 @@ BUILDIN(checkequipedcard) return true; } -BUILDIN(__jump_zero) +static BUILDIN(__jump_zero) { int sel; sel=script_getnum(st,2); @@ -15482,7 +15668,7 @@ BUILDIN(__jump_zero) /*========================================== * movenpc [MouseJstr] *------------------------------------------*/ -BUILDIN(movenpc) +static BUILDIN(movenpc) { struct npc_data *nd = NULL; const char *npc_name; @@ -15504,7 +15690,7 @@ BUILDIN(movenpc) /*========================================== * message [MouseJstr] *------------------------------------------*/ -BUILDIN(message) +static BUILDIN(message) { const char *message; struct map_session_data *sd = NULL; @@ -15525,12 +15711,13 @@ BUILDIN(message) /*========================================== * npctalk (sends message to surrounding area) - * usage: npctalk "<message>"{,"<npc name>"}; + * usage: npctalk("<message>"{, "<npc name>"{, <show_name>}}); *------------------------------------------*/ -BUILDIN(npctalk) +static BUILDIN(npctalk) { struct npc_data* nd; const char *str = script_getstr(st,2); + bool show_name = true; if (script_hasdata(st, 3)) { nd = npc->name2id(script_getstr(st, 3)); @@ -15538,19 +15725,28 @@ BUILDIN(npctalk) nd = map->id2nd(st->oid); } + if (script_hasdata(st, 4)) { + show_name = (script_getnum(st, 4) != 0) ? true : false; + } + if (nd != NULL) { char name[NAME_LENGTH], message[256]; safestrncpy(name, nd->name, sizeof(name)); strtok(name, "#"); // discard extra name identifier if present - safesnprintf(message, sizeof(message), "%s : %s", name, str); - clif->disp_overhead(&nd->bl, message); + if (show_name) { + safesnprintf(message, sizeof(message), "%s : %s", name, str); + } else { + safesnprintf(message, sizeof(message), "%s", str); + } + clif->disp_overhead(&nd->bl, message, AREA_CHAT_WOC, NULL); } return true; } // change npc walkspeed [Valaris] -BUILDIN(npcspeed) { +static BUILDIN(npcspeed) +{ struct npc_data* nd; int speed; @@ -15566,7 +15762,7 @@ BUILDIN(npcspeed) { return true; } // make an npc walk to a position [Valaris] -BUILDIN(npcwalkto) +static BUILDIN(npcwalkto) { struct npc_data *nd = map->id2nd(st->oid); int x=0,y=0; @@ -15587,7 +15783,7 @@ BUILDIN(npcwalkto) return true; } // stop an npc's movement [Valaris] -BUILDIN(npcstop) +static BUILDIN(npcstop) { struct npc_data *nd = map->id2nd(st->oid); @@ -15600,7 +15796,7 @@ BUILDIN(npcstop) } // set click npc distance [4144] -BUILDIN(setnpcdistance) +static BUILDIN(setnpcdistance) { struct npc_data *nd = map->id2nd(st->oid); if (nd == NULL) @@ -15612,7 +15808,7 @@ BUILDIN(setnpcdistance) } // return current npc direction [4144] -BUILDIN(getnpcdir) +static BUILDIN(getnpcdir) { const struct npc_data *nd = NULL; @@ -15638,7 +15834,7 @@ BUILDIN(getnpcdir) } // set npc direction [4144] -BUILDIN(setnpcdir) +static BUILDIN(setnpcdir) { int newdir; struct npc_data *nd = NULL; @@ -15672,7 +15868,7 @@ BUILDIN(setnpcdir) } // return npc class [4144] -BUILDIN(getnpcclass) +static BUILDIN(getnpcclass) { const struct npc_data *nd = NULL; @@ -15700,7 +15896,7 @@ BUILDIN(getnpcclass) /*========================================== * getlook char info. getlook(arg) *------------------------------------------*/ -BUILDIN(getlook) +static BUILDIN(getlook) { int type,val = -1; struct map_session_data *sd = script->rid2sd(st); @@ -15729,7 +15925,7 @@ BUILDIN(getlook) /*========================================== * get char save point. argument: 0- map name, 1- x, 2- y *------------------------------------------*/ -BUILDIN(getsavepoint) +static BUILDIN(getsavepoint) { int type; struct map_session_data *sd = script->rid2sd(st); @@ -15772,7 +15968,7 @@ BUILDIN(getsavepoint) * 0 - success * -1 - some error, MapName$,MapX,MapY contains unknown value. *------------------------------------------*/ -BUILDIN(getmapxy) +static BUILDIN(getmapxy) { struct block_list *bl = NULL; struct map_session_data *sd = NULL; @@ -15976,7 +16172,7 @@ enum logmes_type { /*========================================== * Allows player to write logs (i.e. Bank NPC, etc) [Lupus] *------------------------------------------*/ -BUILDIN(logmes) +static BUILDIN(logmes) { const char *str = script_getstr(st, 2); struct map_session_data *sd = script->rid2sd(st); @@ -16003,7 +16199,7 @@ BUILDIN(logmes) return true; } -BUILDIN(summon) +static BUILDIN(summon) { int class_, timeout=0; const char *str,*event=""; @@ -16041,7 +16237,8 @@ BUILDIN(summon) /*========================================== * Checks whether it is daytime/nighttime *------------------------------------------*/ -BUILDIN(isnight) { +static BUILDIN(isnight) +{ script_pushint(st,(map->night_flag == 1)); return true; } @@ -16050,7 +16247,7 @@ BUILDIN(isnight) { * Check how many items/cards in the list are * equipped - used for 2/15's cards patch [celest] *------------------------------------------------*/ -BUILDIN(isequippedcnt) +static BUILDIN(isequippedcnt) { int i, j, k, id = 1; int ret = 0; @@ -16099,7 +16296,7 @@ BUILDIN(isequippedcnt) * -- Items checked cannot be reused in another * card set to prevent exploits *------------------------------------------------*/ -BUILDIN(isequipped) +static BUILDIN(isequipped) { int i, j, k, id = 1; int index, flag; @@ -16179,7 +16376,7 @@ BUILDIN(isequipped) * Check how many given inserted cards in the CURRENT * weapon - used for 2/15's cards patch [Lupus] *------------------------------------------------*/ -BUILDIN(cardscnt) +static BUILDIN(cardscnt) { int i, k, id = 1; int ret = 0; @@ -16221,7 +16418,7 @@ BUILDIN(cardscnt) * Returns the refined number of the current item, or an * item with inventory index specified *-------------------------------------------------------*/ -BUILDIN(getrefine) +static BUILDIN(getrefine) { struct map_session_data *sd = script->rid2sd(st); @@ -16238,11 +16435,13 @@ BUILDIN(getrefine) /*======================================================= * Day/Night controls *-------------------------------------------------------*/ -BUILDIN(night) { +static BUILDIN(night) +{ if (map->night_flag != 1) pc->map_night_timer(pc->night_timer_tid, 0, 0, 1); return true; } -BUILDIN(day) { +static BUILDIN(day) +{ if (map->night_flag != 0) pc->map_day_timer(pc->day_timer_tid, 0, 0, 1); return true; } @@ -16250,7 +16449,7 @@ BUILDIN(day) { //======================================================= // Unequip [Spectre] //------------------------------------------------------- -BUILDIN(unequip) +static BUILDIN(unequip) { size_t num; struct map_session_data *sd; @@ -16265,7 +16464,7 @@ BUILDIN(unequip) return true; } -BUILDIN(equip) +static BUILDIN(equip) { int nameid=0,i; struct item_data *item_data; @@ -16276,7 +16475,7 @@ BUILDIN(equip) nameid=script_getnum(st,2); if((item_data = itemdb->exists(nameid)) == NULL) { - ShowError("wrong item ID : equipitem(%i)\n",nameid); + ShowError("wrong item ID : equipitem(%d)\n",nameid); return false; } ARR_FIND( 0, MAX_INVENTORY, i, sd->status.inventory[i].nameid == nameid && sd->status.inventory[i].equip == 0 ); @@ -16286,7 +16485,7 @@ BUILDIN(equip) return true; } -BUILDIN(autoequip) +static BUILDIN(autoequip) { int nameid, flag; struct item_data *item_data; @@ -16313,7 +16512,7 @@ BUILDIN(autoequip) * Equip2 * equip2 <item id>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>; *-------------------------------------------------------*/ -BUILDIN(equip2) +static BUILDIN(equip2) { int i,nameid,ref,attr,c0,c1,c2,c3; struct item_data *item_data; @@ -16332,12 +16531,12 @@ BUILDIN(equip2) return false; } - ref = script_getnum(st,3); - attr = script_getnum(st,4); - c0 = (short)script_getnum(st,5); - c1 = (short)script_getnum(st,6); - c2 = (short)script_getnum(st,7); - c3 = (short)script_getnum(st,8); + ref = script_getnum(st, 3); + attr = script_getnum(st, 4); + c0 = script_getnum(st, 5); + c1 = script_getnum(st, 6); + c2 = script_getnum(st, 7); + c3 = script_getnum(st, 8); ARR_FIND( 0, MAX_INVENTORY, i,( sd->status.inventory[i].equip == 0 && sd->status.inventory[i].nameid == nameid && @@ -16358,7 +16557,7 @@ BUILDIN(equip2) return true; } -BUILDIN(setbattleflag) +static BUILDIN(setbattleflag) { const char *flag, *value; @@ -16373,7 +16572,7 @@ BUILDIN(setbattleflag) return true; } -BUILDIN(getbattleflag) +static BUILDIN(getbattleflag) { const char *flag; int value; @@ -16395,7 +16594,7 @@ BUILDIN(getbattleflag) //======================================================= // strlen [Valaris] //------------------------------------------------------- -BUILDIN(getstrlen) +static BUILDIN(getstrlen) { const char *str = script_getstr(st,2); @@ -16408,7 +16607,7 @@ BUILDIN(getstrlen) //======================================================= // isalpha [Valaris] //------------------------------------------------------- -BUILDIN(charisalpha) +static BUILDIN(charisalpha) { const char *str=script_getstr(st,2); int pos=script_getnum(st,3); @@ -16422,7 +16621,7 @@ BUILDIN(charisalpha) //======================================================= // charisupper <str>, <index> //------------------------------------------------------- -BUILDIN(charisupper) +static BUILDIN(charisupper) { const char *str = script_getstr(st,2); int pos = script_getnum(st,3); @@ -16436,7 +16635,7 @@ BUILDIN(charisupper) //======================================================= // charislower <str>, <index> //------------------------------------------------------- -BUILDIN(charislower) +static BUILDIN(charislower) { const char *str = script_getstr(st,2); int pos = script_getnum(st,3); @@ -16450,7 +16649,8 @@ BUILDIN(charislower) //======================================================= // charat <str>, <index> //------------------------------------------------------- -BUILDIN(charat) { +static BUILDIN(charat) +{ const char *str = script_getstr(st,2); int pos = script_getnum(st,3); @@ -16472,7 +16672,7 @@ BUILDIN(charat) { // 1 - string // 2 - other //------------------------------------------------------- -BUILDIN(isstr) +static BUILDIN(isstr) { if (script_isinttype(st, 2)) { script_pushint(st, 0); @@ -16494,7 +16694,8 @@ enum datatype { DATATYPE_LABEL = 1 << 13, }; -BUILDIN(getdatatype) { +static BUILDIN(getdatatype) +{ int type; if (script_hasdata(st, 2)) { @@ -16541,7 +16742,7 @@ BUILDIN(getdatatype) { //======================================================= // chr <int> //------------------------------------------------------- -BUILDIN(chr) +static BUILDIN(chr) { char output[2]; output[0] = script_getnum(st, 2); @@ -16554,7 +16755,7 @@ BUILDIN(chr) //======================================================= // ord <chr> //------------------------------------------------------- -BUILDIN(ord) +static BUILDIN(ord) { const char *chr = script_getstr(st, 2); script_pushint(st, *chr); @@ -16564,7 +16765,7 @@ BUILDIN(ord) //======================================================= // setchar <string>, <char>, <index> //------------------------------------------------------- -BUILDIN(setchar) +static BUILDIN(setchar) { const char *str = script_getstr(st,2); const char *c = script_getstr(st,3); @@ -16581,7 +16782,7 @@ BUILDIN(setchar) //======================================================= // insertchar <string>, <char>, <index> //------------------------------------------------------- -BUILDIN(insertchar) +static BUILDIN(insertchar) { const char *str = script_getstr(st,2); const char *c = script_getstr(st,3); @@ -16608,7 +16809,7 @@ BUILDIN(insertchar) //======================================================= // delchar <string>, <index> //------------------------------------------------------- -BUILDIN(delchar) +static BUILDIN(delchar) { const char *str = script_getstr(st,2); int index = script_getnum(st,3); @@ -16634,7 +16835,7 @@ BUILDIN(delchar) //======================================================= // strtoupper <str> //------------------------------------------------------- -BUILDIN(strtoupper) +static BUILDIN(strtoupper) { const char *str = script_getstr(st,2); char *output = aStrdup(str); @@ -16652,7 +16853,7 @@ BUILDIN(strtoupper) //======================================================= // strtolower <str> //------------------------------------------------------- -BUILDIN(strtolower) +static BUILDIN(strtolower) { const char *str = script_getstr(st,2); char *output = aStrdup(str); @@ -16670,7 +16871,7 @@ BUILDIN(strtolower) //======================================================= // substr <str>, <start>, <end> //------------------------------------------------------- -BUILDIN(substr) +static BUILDIN(substr) { const char *str = script_getstr(st,2); char *output; @@ -16696,7 +16897,7 @@ BUILDIN(substr) // explode <dest_string_array>, <str>, <delimiter> // Note: delimiter is limited to 1 char //------------------------------------------------------- -BUILDIN(explode) +static BUILDIN(explode) { struct script_data* data = script_getdata(st, 2); const char *str = script_getstr(st,3); @@ -16761,7 +16962,7 @@ BUILDIN(explode) // implode <string_array> // implode <string_array>, <glue> //------------------------------------------------------- -BUILDIN(implode) +static BUILDIN(implode) { struct script_data* data = script_getdata(st, 2); const char *name; @@ -16853,7 +17054,7 @@ BUILDIN(implode) // Implements C sprintf, except format %n. The resulting string is // returned, instead of being saved in variable by reference. //------------------------------------------------------- -BUILDIN(sprintf) +static BUILDIN(sprintf) { struct StringBuf buf; StrBuf->Init(&buf); @@ -16874,7 +17075,8 @@ BUILDIN(sprintf) // sscanf(<str>, <format>, ...); // Implements C sscanf. //------------------------------------------------------- -BUILDIN(sscanf) { +static BUILDIN(sscanf) +{ unsigned int argc, arg = 0; struct script_data* data; struct map_session_data* sd = NULL; @@ -16987,7 +17189,8 @@ BUILDIN(sscanf) { // Implements PHP style strpos. Adapted from code from // http://www.daniweb.com/code/snippet313.html, Dave Sinkula //------------------------------------------------------- -BUILDIN(strpos) { +static BUILDIN(strpos) +{ const char *haystack = script_getstr(st,2); const char *needle = script_getstr(st,3); int i; @@ -17031,7 +17234,7 @@ BUILDIN(strpos) { // instances as specified in <count>. By default will be case // sensitive. //--------------------------------------------------------------- -BUILDIN(replacestr) +static BUILDIN(replacestr) { const char *input = script_getstr(st, 2); const char *find = script_getstr(st, 3); @@ -17114,7 +17317,7 @@ BUILDIN(replacestr) // Note: Counts the number of times <search> occurs in // <input>. By default will be case sensitive. //-------------------------------------------------------- -BUILDIN(countstr) +static BUILDIN(countstr) { const char *input = script_getstr(st, 2); const char *find = script_getstr(st, 3); @@ -17171,7 +17374,8 @@ BUILDIN(countstr) /// setnpcdisplay("<npc name>", "<new display name>", <new class id>) -> <int> /// setnpcdisplay("<npc name>", "<new display name>") -> <int> /// setnpcdisplay("<npc name>", <new class id>) -> <int> -BUILDIN(setnpcdisplay) { +static BUILDIN(setnpcdisplay) +{ const char* name; const char* newname = NULL; int class_ = -1, size = -1; @@ -17217,14 +17421,16 @@ BUILDIN(setnpcdisplay) { return true; } -BUILDIN(atoi) { +static BUILDIN(atoi) +{ const char *value; value = script_getstr(st,2); script_pushint(st,atoi(value)); return true; } -BUILDIN(axtoi) { +static BUILDIN(axtoi) +{ const char *hex = script_getstr(st,2); long value = strtol(hex, NULL, 16); #if LONG_MAX > INT_MAX || LONG_MIN < INT_MIN @@ -17234,7 +17440,8 @@ BUILDIN(axtoi) { return true; } -BUILDIN(strtol) { +static BUILDIN(strtol) +{ const char *string = script_getstr(st, 2); int base = script_getnum(st, 3); long value = strtol(string, NULL, base); @@ -17246,7 +17453,7 @@ BUILDIN(strtol) { } // case-insensitive substring search [lordalfa] -BUILDIN(compare) +static BUILDIN(compare) { const char *message; const char *cmpstring; @@ -17256,7 +17463,7 @@ BUILDIN(compare) return true; } -BUILDIN(strcmp) +static BUILDIN(strcmp) { const char *str1 = script_getstr(st,2); const char *str2 = script_getstr(st,3); @@ -17266,7 +17473,7 @@ BUILDIN(strcmp) // List of mathematics commands ---> -BUILDIN(log10) +static BUILDIN(log10) { double i, a; i = script_getnum(st,2); @@ -17275,7 +17482,7 @@ BUILDIN(log10) return true; } -BUILDIN(sqrt) //[zBuffer] +static BUILDIN(sqrt) //[zBuffer] { double i, a; i = script_getnum(st,2); @@ -17288,7 +17495,7 @@ BUILDIN(sqrt) //[zBuffer] return true; } -BUILDIN(pow) //[zBuffer] +static BUILDIN(pow) //[zBuffer] { double i, a, b; a = script_getnum(st,2); @@ -17298,7 +17505,7 @@ BUILDIN(pow) //[zBuffer] return true; } -BUILDIN(distance) //[zBuffer] +static BUILDIN(distance) //[zBuffer] { int x0, y0, x1, y1; @@ -17313,7 +17520,7 @@ BUILDIN(distance) //[zBuffer] // <--- List of mathematics commands -BUILDIN(min) +static BUILDIN(min) { int i, min; @@ -17328,7 +17535,7 @@ BUILDIN(min) return true; } -BUILDIN(max) +static BUILDIN(max) { int i, max; @@ -17343,7 +17550,7 @@ BUILDIN(max) return true; } -BUILDIN(md5) +static BUILDIN(md5) { const char *tmpstr; char *md5str; @@ -17355,7 +17562,7 @@ BUILDIN(md5) return true; } -BUILDIN(swap) +static BUILDIN(swap) { struct map_session_data *sd = NULL; struct script_data *data1, *data2; @@ -17430,7 +17637,7 @@ BUILDIN(swap) // [zBuffer] List of dynamic var commands ---> -BUILDIN(setd) +static BUILDIN(setd) { struct map_session_data *sd = NULL; char varname[100]; @@ -17460,7 +17667,7 @@ BUILDIN(setd) return true; } -int buildin_query_sql_sub(struct script_state *st, struct Sql *handle) +static int buildin_query_sql_sub(struct script_state *st, struct Sql *handle) { int i, j; struct map_session_data *sd = NULL; @@ -17542,11 +17749,13 @@ int buildin_query_sql_sub(struct script_state *st, struct Sql *handle) return true; } -BUILDIN(query_sql) { +static BUILDIN(query_sql) +{ return script->buildin_query_sql_sub(st, map->mysql_handle); } -BUILDIN(query_logsql) { +static BUILDIN(query_logsql) +{ if( !logs->config.sql_logs ) {// logs->mysql_handle == NULL ShowWarning("buildin_query_logsql: SQL logs are disabled, query '%s' will not be executed.\n", script_getstr(st,2)); script_pushint(st,-1); @@ -17556,7 +17765,7 @@ BUILDIN(query_logsql) { } //Allows escaping of a given string. -BUILDIN(escape_sql) +static BUILDIN(escape_sql) { const char *str; char *esc_str; @@ -17570,7 +17779,8 @@ BUILDIN(escape_sql) return true; } -BUILDIN(getd) { +static BUILDIN(getd) +{ char varname[100]; const char *buffer; int elem; @@ -17588,7 +17798,7 @@ BUILDIN(getd) { // <--- [zBuffer] List of dynamic var commands // Pet stat [Lance] -BUILDIN(petstat) +static BUILDIN(petstat) { struct pet_data *pd; int flag = script_getnum(st,2); @@ -17614,7 +17824,7 @@ BUILDIN(petstat) return true; } -BUILDIN(callshop) +static BUILDIN(callshop) { struct npc_data *nd; const char *shopname; @@ -17654,7 +17864,7 @@ BUILDIN(callshop) return true; } -BUILDIN(npcshopitem) +static BUILDIN(npcshopitem) { const char* npcname = script_getstr(st, 2); struct npc_data* nd = npc->name2id(npcname); @@ -17683,7 +17893,7 @@ BUILDIN(npcshopitem) return true; } -BUILDIN(npcshopadditem) +static BUILDIN(npcshopadditem) { const char* npcname = script_getstr(st,2); struct npc_data* nd = npc->name2id(npcname); @@ -17712,7 +17922,7 @@ BUILDIN(npcshopadditem) return true; } -BUILDIN(npcshopdelitem) +static BUILDIN(npcshopdelitem) { const char* npcname = script_getstr(st,2); struct npc_data* nd = npc->name2id(npcname); @@ -17748,7 +17958,8 @@ BUILDIN(npcshopdelitem) } //Sets a script to attach to a shop npc. -BUILDIN(npcshopattach) { +static BUILDIN(npcshopattach) +{ const char* npcname = script_getstr(st,2); struct npc_data* nd = npc->name2id(npcname); int flag = 1; @@ -17780,7 +17991,7 @@ BUILDIN(npcshopattach) { * 1 - Equip script * 2 - Unequip script *------------------------------------------*/ -BUILDIN(setitemscript) +static BUILDIN(setitemscript) { int item_id,n=0; const char *new_bonus_script; @@ -17826,7 +18037,8 @@ BUILDIN(setitemscript) * is updated to the new rate. Rate must be in the range [1:10000] * Returns 1 if succeeded (added/updated a mob drop) *-------------------------------------------------------*/ -BUILDIN(addmonsterdrop) { +static BUILDIN(addmonsterdrop) +{ struct mob_db *monster; int item_id, rate, i, c = MAX_MOB_DROP; @@ -17886,7 +18098,8 @@ BUILDIN(addmonsterdrop) { * * Returns 1 if succeeded (deleted a mob drop) *-------------------------------------------------------*/ -BUILDIN(delmonsterdrop) { +static BUILDIN(delmonsterdrop) +{ struct mob_db *monster; int item_id, i; @@ -17928,7 +18141,7 @@ BUILDIN(delmonsterdrop) { * Name, Level, race, size, etc... * getmonsterinfo(monsterID,queryIndex); *------------------------------------------*/ -BUILDIN(getmonsterinfo) +static BUILDIN(getmonsterinfo) { struct mob_db *monster; int mob_id; @@ -17972,7 +18185,7 @@ BUILDIN(getmonsterinfo) return true; } -BUILDIN(checkvending) // check vending [Nab4] +static BUILDIN(checkvending) // check vending [Nab4] { struct map_session_data *sd = NULL; @@ -17990,7 +18203,8 @@ BUILDIN(checkvending) // check vending [Nab4] } // check chatting [Marka] -BUILDIN(checkchatting) { +static BUILDIN(checkchatting) +{ struct map_session_data *sd = NULL; if (script_hasdata(st,2)) @@ -18006,7 +18220,8 @@ BUILDIN(checkchatting) { return true; } -BUILDIN(checkidle) { +static BUILDIN(checkidle) +{ struct map_session_data *sd = NULL; if (script_hasdata(st, 2)) @@ -18022,7 +18237,7 @@ BUILDIN(checkidle) { return true; } -BUILDIN(searchitem) +static BUILDIN(searchitem) { struct script_data* data = script_getdata(st, 2); const char *itemname = script_getstr(st,3); @@ -18085,7 +18300,7 @@ BUILDIN(searchitem) } // [zBuffer] List of player cont commands ---> -BUILDIN(rid2name) +static BUILDIN(rid2name) { struct block_list *bl = NULL; int rid = script_getnum(st,2); @@ -18109,7 +18324,8 @@ BUILDIN(rid2name) return true; } -BUILDIN(pcblockmove) { +static BUILDIN(pcblockmove) +{ int id, flag; struct map_session_data *sd = NULL; @@ -18132,7 +18348,7 @@ BUILDIN(pcblockmove) { return true; } -BUILDIN(setpcblock) +static BUILDIN(setpcblock) { struct map_session_data *sd = script->rid2sd(st); enum pcblock_action_flag type = script_getnum(st, 2); @@ -18168,7 +18384,7 @@ BUILDIN(setpcblock) return true; } -BUILDIN(checkpcblock) +static BUILDIN(checkpcblock) { struct map_session_data *sd = script->rid2sd(st); int retval = PCBLOCK_NONE; @@ -18206,7 +18422,7 @@ BUILDIN(checkpcblock) return true; } -BUILDIN(pcfollow) +static BUILDIN(pcfollow) { int id, targetid; struct map_session_data *sd = NULL; @@ -18225,7 +18441,7 @@ BUILDIN(pcfollow) return true; } -BUILDIN(pcstopfollow) +static BUILDIN(pcstopfollow) { int id; struct map_session_data *sd = NULL; @@ -18246,7 +18462,8 @@ BUILDIN(pcstopfollow) // [zBuffer] List of mob control commands ---> //## TODO always return if the request/whatever was successfull [FlavioJS] -BUILDIN(getunittype) { +static BUILDIN(getunittype) +{ struct block_list* bl; int value; @@ -18283,7 +18500,7 @@ BUILDIN(getunittype) { * @param5 Value#3 Optional int value to be passed for certain data types. * @return 1 on success, 0 on failure. */ -BUILDIN(setunitdata) +static BUILDIN(setunitdata) { struct block_list *bl = NULL; const char *mapname = NULL, *udtype = NULL; @@ -19400,7 +19617,7 @@ BUILDIN(setunitdata) * @param3 Variable array reference to store data into. (used for UDT_MAPIDXY) * @return 0 on failure, <value> on success */ -BUILDIN(getunitdata) +static BUILDIN(getunitdata) { struct block_list *bl; const char *udtype = NULL; @@ -19824,7 +20041,7 @@ BUILDIN(getunitdata) * @param GUID Game Object Unique ID. * @return boolean or Name of the game object. */ -BUILDIN(getunitname) +static BUILDIN(getunitname) { const struct block_list* bl = NULL; @@ -19851,7 +20068,7 @@ BUILDIN(getunitname) * @param Name as string. * @return boolean. */ -BUILDIN(setunitname) +static BUILDIN(setunitname) { struct block_list* bl = map->id2bl(script_getnum(st, 2)); @@ -19912,7 +20129,8 @@ BUILDIN(setunitname) /// /// unitwalk(<unit_id>,<x>,<y>) -> <bool> /// unitwalk(<unit_id>,<target_id>) -> <bool> -BUILDIN(unitwalk) { +static BUILDIN(unitwalk) +{ struct block_list* bl; bl = map->id2bl(script_getnum(st,2)); @@ -19939,7 +20157,7 @@ BUILDIN(unitwalk) { /// Kills the unit /// /// unitkill <unit_id>; -BUILDIN(unitkill) +static BUILDIN(unitkill) { struct block_list* bl = map->id2bl(script_getnum(st,2)); if( bl != NULL ) @@ -19952,7 +20170,8 @@ BUILDIN(unitkill) /// Returns if it was successfull /// /// unitwarp(<unit_id>,"<map name>",<x>,<y>) -> <bool> -BUILDIN(unitwarp) { +static BUILDIN(unitwarp) +{ int unit_id; int mapid; short x; @@ -19992,7 +20211,8 @@ BUILDIN(unitwarp) { /// /// unitattack(<unit_id>,"<target name>"{,<action type>}) -> <bool> /// unitattack(<unit_id>,<target_id>{,<action type>}) -> <bool> -BUILDIN(unitattack) { +static BUILDIN(unitattack) +{ struct block_list* unit_bl; struct block_list* target_bl = NULL; int actiontype = 0; @@ -20046,7 +20266,8 @@ BUILDIN(unitattack) { /// Makes the unit stop attacking and moving /// /// unitstop <unit_id>; -BUILDIN(unitstop) { +static BUILDIN(unitstop) +{ int unit_id; struct block_list* bl; @@ -20066,15 +20287,30 @@ BUILDIN(unitstop) { /// Makes the unit say the message /// -/// unittalk <unit_id>,"<message>"; -BUILDIN(unittalk) { +/// unittalk(<unit_id>,"<message>"{, show_name{, <send_target>{, <target_id>}}}); +static BUILDIN(unittalk) +{ int unit_id; const char* message; - struct block_list* bl; + struct block_list *bl, *target_bl = NULL; + bool show_name = true; + enum send_target target = AREA_CHAT_WOC; unit_id = script_getnum(st,2); message = script_getstr(st, 3); + if (script_hasdata(st, 4)) { + show_name = (script_getnum(st, 4) != 0) ? true : false; + } + + if (script_hasdata(st, 5)) { + target = script_getnum(st, 5); + } + + if (script_hasdata(st, 6)) { + target_bl = map->id2bl(script_getnum(st, 6)); + } + bl = map->id2bl(unit_id); if( bl != NULL ) { struct StringBuf sbuf; @@ -20083,8 +20319,17 @@ BUILDIN(unittalk) { safestrncpy(blname, clif->get_bl_name(bl), sizeof(blname)); if(bl->type == BL_NPC) strtok(blname, "#"); - StrBuf->Printf(&sbuf, "%s : %s", blname, message); - clif->disp_overhead(bl, StrBuf->Value(&sbuf)); + if (show_name) { + StrBuf->Printf(&sbuf, "%s : %s", blname, message); + } else { + StrBuf->Printf(&sbuf, "%s", message); + } + + if (bl->type == BL_PC && target == SELF && (target_bl == NULL || bl == target_bl)) { + clif->notify_playerchat(bl, StrBuf->Value(&sbuf)); + } else { + clif->disp_overhead(bl, StrBuf->Value(&sbuf), target, target_bl); + } StrBuf->Destroy(&sbuf); } @@ -20096,7 +20341,8 @@ BUILDIN(unittalk) { /// unitemote <unit_id>,<emotion>; /// /// @see e_* in const.txt -BUILDIN(unitemote) { +static BUILDIN(unitemote) +{ int unit_id; int emotion; struct block_list* bl; @@ -20114,7 +20360,8 @@ BUILDIN(unitemote) { /// /// unitskilluseid <unit_id>,<skill_id>,<skill_lv>{,<target_id>}; /// unitskilluseid <unit_id>,"<skill name>",<skill_lv>{,<target_id>}; -BUILDIN(unitskilluseid) { +static BUILDIN(unitskilluseid) +{ int unit_id; uint16 skill_id; uint16 skill_lv; @@ -20147,7 +20394,8 @@ BUILDIN(unitskilluseid) { /// /// unitskillusepos <unit_id>,<skill_id>,<skill_lv>,<target_x>,<target_y>; /// unitskillusepos <unit_id>,"<skill name>",<skill_lv>,<target_x>,<target_y>; -BUILDIN(unitskillusepos) { +static BUILDIN(unitskillusepos) +{ int unit_id; uint16 skill_id; uint16 skill_lv; @@ -20183,7 +20431,7 @@ BUILDIN(unitskillusepos) { /// Pauses the execution of the script, detaching the player /// /// sleep <mili seconds>; -BUILDIN(sleep) +static BUILDIN(sleep) { int ticks; @@ -20212,7 +20460,8 @@ BUILDIN(sleep) /// Returns if a player is still attached /// /// sleep2(<mili secconds>) -> <bool> -BUILDIN(sleep2) { +static BUILDIN(sleep2) +{ int ticks; ticks = script_getnum(st,2); @@ -20236,7 +20485,7 @@ BUILDIN(sleep2) { /// Awakes all the sleep timers of the target npc /// /// awake "<npc name>"; -BUILDIN(awake) +static BUILDIN(awake) { struct DBIterator *iter; struct script_state *tst; @@ -20279,7 +20528,7 @@ BUILDIN(awake) /// Returns 0 if an error occurs. /// /// getvariableofnpc(<variable>, "<npc name>") -> <reference> -BUILDIN(getvariableofnpc) +static BUILDIN(getvariableofnpc) { struct script_data* data; const char* name; @@ -20321,7 +20570,7 @@ BUILDIN(getvariableofnpc) return true; } -BUILDIN(getvariableofpc) +static BUILDIN(getvariableofpc) { const char* name; struct script_data* data = script_getdata(st, 2); @@ -20375,7 +20624,8 @@ BUILDIN(getvariableofpc) /// warpportal <source x>,<source y>,"<target map>",<target x>,<target y>; /// /// @author blackhole89 -BUILDIN(warpportal) { +static BUILDIN(warpportal) +{ int spx; int spy; unsigned short map_index; @@ -20412,7 +20662,7 @@ BUILDIN(warpportal) { return true; } -BUILDIN(openmail) +static BUILDIN(openmail) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -20423,7 +20673,7 @@ BUILDIN(openmail) return true; } -BUILDIN(openauction) +static BUILDIN(openauction) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -20439,7 +20689,8 @@ BUILDIN(openauction) /// checkcell("<map name>",<x>,<y>,<type>) -> <bool> /// /// @see cell_chk* constants in const.txt for the types -BUILDIN(checkcell) { +static BUILDIN(checkcell) +{ int16 m = map->mapname2mapid(script_getstr(st,2)); int16 x = script_getnum(st,3); int16 y = script_getnum(st,4); @@ -20460,7 +20711,8 @@ BUILDIN(checkcell) { /// setcell "<map name>",<x1>,<y1>,<x2>,<y2>,<type>,<flag>; /// /// @see cell_* constants in const.txt for the types -BUILDIN(setcell) { +static BUILDIN(setcell) +{ int16 m = map->mapname2mapid(script_getstr(st,2)); int16 x1 = script_getnum(st,3); int16 y1 = script_getnum(st,4); @@ -20489,7 +20741,7 @@ BUILDIN(setcell) { /*========================================== * Mercenary Commands *------------------------------------------*/ -BUILDIN(mercenary_create) +static BUILDIN(mercenary_create) { struct map_session_data *sd; int class_, contract_time; @@ -20507,7 +20759,8 @@ BUILDIN(mercenary_create) return true; } -BUILDIN(mercenary_heal) { +static BUILDIN(mercenary_heal) +{ struct map_session_data *sd = script->rid2sd(st); int hp, sp; @@ -20520,7 +20773,8 @@ BUILDIN(mercenary_heal) { return true; } -BUILDIN(mercenary_sc_start) { +static BUILDIN(mercenary_sc_start) +{ struct map_session_data *sd = script->rid2sd(st); enum sc_type type; int tick, val1; @@ -20536,7 +20790,8 @@ BUILDIN(mercenary_sc_start) { return true; } -BUILDIN(mercenary_get_calls) { +static BUILDIN(mercenary_get_calls) +{ struct map_session_data *sd = script->rid2sd(st); int guild_id; @@ -20562,7 +20817,8 @@ BUILDIN(mercenary_get_calls) { return true; } -BUILDIN(mercenary_set_calls) { +static BUILDIN(mercenary_set_calls) +{ struct map_session_data *sd = script->rid2sd(st); int guild_id, value, *calls; @@ -20592,7 +20848,8 @@ BUILDIN(mercenary_set_calls) { return true; } -BUILDIN(mercenary_get_faith) { +static BUILDIN(mercenary_get_faith) +{ struct map_session_data *sd = script->rid2sd(st); int guild_id; @@ -20618,7 +20875,8 @@ BUILDIN(mercenary_get_faith) { return true; } -BUILDIN(mercenary_set_faith) { +static BUILDIN(mercenary_set_faith) +{ struct map_session_data *sd = script->rid2sd(st); int guild_id, value, *calls; @@ -20653,7 +20911,7 @@ BUILDIN(mercenary_set_faith) { /*------------------------------------------ * Book Reading *------------------------------------------*/ -BUILDIN(readbook) +static BUILDIN(readbook) { struct map_session_data *sd; int book_id, page; @@ -20672,66 +20930,180 @@ BUILDIN(readbook) * Questlog script commands * ****************************/ -BUILDIN(questinfo) +static BUILDIN(questinfo) { struct npc_data *nd = map->id2nd(st->oid); - int quest_id, icon; - struct questinfo qi; + struct questinfo qi = { 0 }; + int icon = script_getnum(st, 2); - if( nd == NULL || nd->bl.m == -1 ) + if (nd == NULL) return true; - quest_id = script_getnum(st, 2); - icon = script_getnum(st, 3); - -#if PACKETVER >= 20170315 - if (icon < 0 || (icon > 10 && icon != 9999)) - icon = 9999; -#elif PACKETVER >= 20120410 - if (icon < 0 || (icon > 8 && icon != 9999) || icon == 7) - icon = 9999; // Default to nothing if icon id is invalid. -#else - if (icon < 0 || icon > 7) - icon = 0; - else - icon = icon + 1; -#endif + if (nd->bl.m == -1) { + ShowWarning("buildin_questinfo: questinfo cannot be set for an npc with no valid map.\n"); + return false; + } - qi.quest_id = quest_id; - qi.icon = (unsigned char)icon; qi.nd = nd; - - if (script_hasdata(st, 4)) { - int color = script_getnum(st, 4); + qi.icon = quest->questinfo_validate_icon(icon); + if (script_hasdata(st, 3)) { + int color = script_getnum(st, 3); if (color < 0 || color > 3) { - ShowWarning("buildin_questinfo: invalid color '%d', changing to 0\n",color); + ShowWarning("buildin_questinfo: invalid color '%d', defaulting to 0.\n", color); script->reportfunc(st); color = 0; } qi.color = (unsigned char)color; } - qi.hasJob = false; + map->add_questinfo(nd->bl.m, &qi); + return true; +} - if (script_hasdata(st, 5)) { - int job = script_getnum(st, 5); +static BUILDIN(setquestinfo) +{ + struct npc_data *nd = map->id2nd(st->oid); + struct questinfo *qi = NULL; + uint32 type = script_getnum(st, 2); - if (!pc->db_checkid(job)) { - ShowError("buildin_questinfo: Nonexistant Job Class.\n"); - } else { - qi.hasJob = true; - qi.job = (unsigned short)job; + if (nd == NULL) + return true; + + if (nd->bl.m == -1) { + ShowWarning("buildin_setquestinfo: questinfo cannot be set for an npc with no valid map.\n"); + return false; + } + + qi = &VECTOR_LAST(map->list[nd->bl.m].qi_data); + if (qi == NULL) { + ShowWarning("buildin_setquestinfo: no valide questinfo data has been found for this npc.\n"); + return false; + } + if (qi->nd != nd) { + ShowWarning("buildin_setquestinfo: invalid usage, setquestinfo must be used only after questinfo.\n"); + return false; + } + switch (type) { + case QINFO_JOB: + { + int jobid = script_getnum(st, 3); + if (!pc->db_checkid(jobid)) { + ShowWarning("buildin_setquestinfo: invalid job id given (%d).\n", jobid); + return false; } + qi->hasJob = true; + qi->job = jobid; + break; } + case QINFO_SEX: + { + int sex = script_getnum(st, 3); + if (sex != SEX_MALE && sex != SEX_FEMALE) { + ShowWarning("buildin_setquestinfo: unsupported sex has been given (%d).\n", sex); + return false; + } + qi->sex_enabled = true; + qi->sex = sex; + break; + } + case QINFO_BASE_LEVEL: + { + int min = script_getnum(st, 3); + int max = script_getnum(st, 4); + if (min > max) { + ShowWarning("buildin_setquestinfo: minimal level (%d) is bigger than the maximal level (%d).\n", min, max); + return false; + } + qi->base_level.min = min; + qi->base_level.max = max; + break; + } + case QINFO_JOB_LEVEL: + { + int min = script_getnum(st, 3); + int max = script_getnum(st, 4); + if (min > max) { + ShowWarning("buildin_setquestinfo: minimal level (%d) is bigger than the maximal level (%d).\n", min, max); + return false; + } + qi->job_level.min = min; + qi->job_level.max = max; + break; + } + case QINFO_ITEM: + { + struct item item = { 0 }; - map->add_questinfo(nd->bl.m,&qi); + item.nameid = script_getnum(st, 3); + item.amount = script_getnum(st, 4); + if (itemdb->exists(item.nameid) == NULL) { + ShowWarning("buildin_setquestinfo: non existing item (%d) have been given.\n", item.nameid); + return false; + } + if (item.amount <= 0 || item.amount > MAX_AMOUNT) { + ShowWarning("buildin_setquestinfo: given amount (%d) must be bigger than 0 and smaller than %d.\n", item.amount, MAX_AMOUNT + 1); + return false; + } + if (VECTOR_LENGTH(qi->items) == 0) + VECTOR_INIT(qi->items); + VECTOR_ENSURE(qi->items, 1, 1); + VECTOR_PUSH(qi->items, item); + break; + } + case QINFO_HOMUN_LEVEL: + { + int min = script_getnum(st, 3); + if (min > battle_config.hom_max_level && min > battle_config.hom_S_max_level) { + ShowWarning("buildin_setquestinfo: minimum homunculus level given (%d) is bigger than the max possible level.\n", min); + return false; + } + qi->homunculus.level = min; + break; + } + case QINFO_HOMUN_TYPE: + { + int hom_type = script_getnum(st, 3); + if (hom_type < HT_REG || hom_type > HT_S) { + ShowWarning("buildin_setquestinfo: invalid homunculus type (%d).\n", hom_type); + return false; + } + qi->homunculus_type = hom_type; + break; + } + case QINFO_QUEST: + { + struct questinfo_qreq quest_req = { 0 }; + struct quest_db *quest_data = NULL; + + quest_req.id = script_getnum(st, 3); + quest_req.state = script_getnum(st, 4); + + quest_data = quest->db(quest_req.id); + if (quest_data == &quest->dummy) { + ShowWarning("buildin_setquestinfo: invalid quest given (%d).\n", quest_req.id); + return false; + } + if (quest_req.state < Q_INACTIVE || quest_req.state > Q_COMPLETE) { + ShowWarning("buildin_setquestinfo: invalid quest state given (%d).\n", quest_req.state); + return false; + } + + if (VECTOR_LENGTH(qi->quest_requirement) == 0) + VECTOR_INIT(qi->quest_requirement); + VECTOR_ENSURE(qi->quest_requirement, 1, 1); + VECTOR_PUSH(qi->quest_requirement, quest_req); + break; + } + default: + ShowWarning("buildin_setquestinfo: invalid type given (%u).\n", type); + return false; + } return true; } -BUILDIN(setquest) +static BUILDIN(setquest) { - unsigned short i; int quest_id; unsigned int time_limit; struct map_session_data *sd = script->rid2sd(st); @@ -20743,23 +21115,10 @@ BUILDIN(setquest) time_limit = script_hasdata(st, 3) ? script_getnum(st, 3) : 0; quest->add(sd, quest_id, time_limit); - - // If questinfo is set, remove quest bubble once quest is set. - for (i = 0; i < map->list[sd->bl.m].qi_count; i++) { - struct questinfo *qi = &map->list[sd->bl.m].qi_data[i]; - if (qi->quest_id == quest_id) { -#if PACKETVER >= 20120410 - clif->quest_show_event(sd, &qi->nd->bl, 9999, 0); -#else - clif->quest_show_event(sd, &qi->nd->bl, 0, 0); -#endif - } - } - return true; } -BUILDIN(erasequest) +static BUILDIN(erasequest) { struct map_session_data *sd = script->rid2sd(st); @@ -20782,7 +21141,7 @@ BUILDIN(erasequest) return true; } -BUILDIN(completequest) +static BUILDIN(completequest) { struct map_session_data *sd = script->rid2sd(st); @@ -20805,7 +21164,7 @@ BUILDIN(completequest) return true; } -BUILDIN(changequest) +static BUILDIN(changequest) { struct map_session_data *sd = script->rid2sd(st); @@ -20816,7 +21175,7 @@ BUILDIN(changequest) return true; } -BUILDIN(questactive) +static BUILDIN(questactive) { struct map_session_data *sd = script->rid2sd(st); int qid, i; @@ -20842,7 +21201,7 @@ BUILDIN(questactive) return true; } -BUILDIN(questprogress) +static BUILDIN(questprogress) { struct map_session_data *sd = script->rid2sd(st); enum quest_check_type type = HAVEQUEST; @@ -20870,7 +21229,7 @@ BUILDIN(questprogress) return true; } -BUILDIN(showevent) +static BUILDIN(showevent) { struct map_session_data *sd = script->rid2sd(st); struct npc_data *nd = map->id2nd(st->oid); @@ -20907,9 +21266,82 @@ BUILDIN(showevent) } /*========================================== + * Achievement System [Smokexyz/Hercules] + *-----------------------------------------*/ +/** + * Validates an objective index for the given achievement. + * Can be used for any achievement type. + * @command achievement_progress(<ach_id>,<obj_idx>,<progress>,<incremental?>{,<char_id>}); + * @param aid - achievement ID + * @param obj_idx - achievement objective index. + * @param progress - objective progress towards goal. + * @Param incremental - (boolean) true to add the progress towards the goal, + * false to use the progress only as a comparand. + * @param account_id - (optional) character ID to perform on. + * @return true on success, false on failure. + * @push 1 on success, 0 on failure. + */ +static BUILDIN(achievement_progress) +{ + struct map_session_data *sd = script->rid2sd(st); + int aid = script_getnum(st, 2); + int obj_idx = script_getnum(st, 3); + int progress = script_getnum(st, 4); + int incremental = script_getnum(st, 5); + int account_id = script_hasdata(st, 6) ? script_getnum(st, 6) : 0; + const struct achievement_data *ad = NULL; + + if ((ad = achievement->get(aid)) == NULL) { + ShowError("buildin_achievement_progress: Invalid achievement ID %d received.\n", aid); + script_pushint(st, 0); + return false; + } + + if (obj_idx <= 0 || obj_idx > VECTOR_LENGTH(ad->objective)) { + ShowError("buildin_achievement_progress: Invalid objective index %d received. (min: %d, max: %d)\n", obj_idx, 0, VECTOR_LENGTH(ad->objective)); + script_pushint(st, 0); + return false; + } + + obj_idx--; // convert to array index. + + if (progress <= 0 || progress > VECTOR_INDEX(ad->objective, obj_idx).goal) { + ShowError("buildin_achievement_progress: Progress exceeds goal limit for achievement id %d.\n", aid); + script_pushint(st, 0); + return false; + } + + if (incremental < 0 || incremental > 1) { + ShowError("buildin_achievement_progress: Argument 4 expects boolean (0/1). provided value: %d\n", incremental); + script_pushint(st, 0); + return false; + } + + if (script_hasdata(st, 6)) { + if (account_id <= 0) { + ShowError("buildin_achievement_progress: Invalid Account id %d provided.\n", account_id); + script_pushint(st, 0); + return false; + } else if ((sd = map->id2sd(account_id)) == NULL) { + ShowError("buildin_achievement_progress: Account with id %d was not found.\n", account_id); + script_pushint(st, 0); + return false; + } + } + + if (achievement->validate(sd, aid, obj_idx, progress, incremental ? true : false)) + script_pushint(st, progress); + else + script_pushint(st, 0); + + return true; +} + +/*========================================== * BattleGround System *------------------------------------------*/ -BUILDIN(waitingroom2bg) { +static BUILDIN(waitingroom2bg) +{ struct npc_data *nd; struct chat_data *cd; const char *map_name, *ev = "", *dev = ""; @@ -20963,7 +21395,8 @@ BUILDIN(waitingroom2bg) { return true; } -BUILDIN(waitingroom2bg_single) { +static BUILDIN(waitingroom2bg_single) +{ const char* map_name; struct npc_data *nd; struct chat_data *cd; @@ -20996,7 +21429,7 @@ BUILDIN(waitingroom2bg_single) { return true; } -BUILDIN(bg_team_setxy) +static BUILDIN(bg_team_setxy) { struct battleground_data *bgd; int bg_id; @@ -21010,7 +21443,7 @@ BUILDIN(bg_team_setxy) return true; } -BUILDIN(bg_warp) +static BUILDIN(bg_warp) { int x, y, map_index, bg_id; const char* map_name; @@ -21025,7 +21458,7 @@ BUILDIN(bg_warp) return true; } -BUILDIN(bg_monster) +static BUILDIN(bg_monster) { int class_ = 0, x = 0, y = 0, bg_id = 0; const char *str, *mapname, *evt=""; @@ -21042,7 +21475,7 @@ BUILDIN(bg_monster) return true; } -BUILDIN(bg_monster_set_team) +static BUILDIN(bg_monster_set_team) { int id = script_getnum(st,2), bg_id = script_getnum(st,3); @@ -21061,7 +21494,7 @@ BUILDIN(bg_monster_set_team) return true; } -BUILDIN(bg_leave) +static BUILDIN(bg_leave) { struct map_session_data *sd = script->rid2sd(st); if( sd == NULL || !sd->bg_id ) @@ -21071,14 +21504,14 @@ BUILDIN(bg_leave) return true; } -BUILDIN(bg_destroy) +static BUILDIN(bg_destroy) { int bg_id = script_getnum(st,2); bg->team_delete(bg_id); return true; } -BUILDIN(bg_getareausers) +static BUILDIN(bg_getareausers) { const char *str; int16 m, x0, y0, x1, y1; @@ -21112,7 +21545,7 @@ BUILDIN(bg_getareausers) return true; } -BUILDIN(bg_updatescore) +static BUILDIN(bg_updatescore) { const char *str; int16 m; @@ -21128,7 +21561,7 @@ BUILDIN(bg_updatescore) return true; } -BUILDIN(bg_get_data) +static BUILDIN(bg_get_data) { struct battleground_data *bgd; int bg_id = script_getnum(st,2), @@ -21155,11 +21588,12 @@ BUILDIN(bg_get_data) * Instancing Script Commands *------------------------------------------*/ -BUILDIN(instance_create) +static BUILDIN(instance_create) { const char *name; int owner_id, res; int type = IOT_PARTY; + struct map_session_data *sd = map->id2sd(st->rid); name = script_getstr(st, 2); owner_id = script_getnum(st, 3); @@ -21172,27 +21606,48 @@ BUILDIN(instance_create) } res = instance->create(owner_id, name, (enum instance_owner_type) type); - if( res == -4 ) { // Already exists - script_pushint(st, -1); - return true; - } else if( res < 0 ) { + if (sd != NULL) { + switch (res) { + case -4: // Already exists + clif->msgtable_str(sd, MSG_MDUNGEON_SUBSCRIPTION_ERROR_DUPLICATE, name); + break; + case -3: // No free instances + clif->msgtable_str(sd, MSG_MDUNGEON_SUBSCRIPTION_ERROR_EXIST, name); + break; + case -2: // Invalid type + clif->msgtable_str(sd, MSG_MDUNGEON_SUBSCRIPTION_ERROR_RIGHT, name); + break; + case -1: // Unknown + clif->msgtable_str(sd, MSG_MDUNGEON_SUBSCRIPTION_ERROR_UNKNOWN, name); + break; + default: + if (res < 0) + ShowError("buildin_instance_create: failed to unknown reason [%d].\n", res); + } + } else { const char *err; - switch(res) { - case -3: err = "No free instances"; break; - case -2: err = "Invalid party ID"; break; - case -1: err = "Invalid type"; break; - default: err = "Unknown"; break; + switch (res) { + case -3: + err = "No free instances"; + break; + case -2: + err = "Invalid party ID"; + break; + case -1: + err = "Invalid type"; + break; + default: + err = "Unknown"; + break; } - ShowError("buildin_instance_create: %s [%d].\n", err, res); - script_pushint(st, -2); - return true; + if (res < 0) + ShowError("buildin_instance_create: %s [%d].\n", err, res); } - script_pushint(st, res); return true; } -BUILDIN(instance_destroy) +static BUILDIN(instance_destroy) { int instance_id = -1; @@ -21211,7 +21666,7 @@ BUILDIN(instance_destroy) return true; } -BUILDIN(instance_attachmap) +static BUILDIN(instance_attachmap) { const char *map_name = NULL; int16 m; @@ -21235,7 +21690,8 @@ BUILDIN(instance_attachmap) return true; } -BUILDIN(instance_detachmap) { +static BUILDIN(instance_detachmap) +{ const char *str; int16 m; int instance_id = -1; @@ -21256,7 +21712,7 @@ BUILDIN(instance_detachmap) { return true; } -BUILDIN(instance_attach) +static BUILDIN(instance_attach) { int instance_id = script_getnum(st, 2); @@ -21267,12 +21723,13 @@ BUILDIN(instance_attach) return true; } -BUILDIN(instance_id) { +static BUILDIN(instance_id) +{ script_pushint(st, st->instance_id); return true; } -BUILDIN(instance_set_timeout) +static BUILDIN(instance_set_timeout) { int progress_timeout, idle_timeout; int instance_id = -1; @@ -21292,7 +21749,7 @@ BUILDIN(instance_set_timeout) return true; } -BUILDIN(instance_init) +static BUILDIN(instance_init) { int instance_id = script_getnum(st, 2); @@ -21310,7 +21767,7 @@ BUILDIN(instance_init) return true; } -BUILDIN(instance_announce) +static BUILDIN(instance_announce) { int instance_id = script_getnum(st,2); const char *mes = script_getstr(st,3); @@ -21341,7 +21798,7 @@ BUILDIN(instance_announce) return true; } -BUILDIN(instance_npcname) +static BUILDIN(instance_npcname) { const char *str; int instance_id = -1; @@ -21366,7 +21823,7 @@ BUILDIN(instance_npcname) return true; } -BUILDIN(has_instance) +static BUILDIN(has_instance) { struct map_session_data *sd; const char *str; @@ -21459,7 +21916,7 @@ BUILDIN(has_instance) return true; } -int buildin_instance_warpall_sub(struct block_list *bl, va_list ap) +static int buildin_instance_warpall_sub(struct block_list *bl, va_list ap) { struct map_session_data *sd = NULL; int map_index = va_arg(ap,int); @@ -21475,7 +21932,7 @@ int buildin_instance_warpall_sub(struct block_list *bl, va_list ap) return 0; } -BUILDIN(instance_warpall) +static BUILDIN(instance_warpall) { int16 m; int instance_id = -1; @@ -21514,7 +21971,7 @@ BUILDIN(instance_warpall) * Example: instance_check_party (getcharid(1){,amount}{,min}{,max}); * Example 2: instance_check_party (getcharid(1),1,1,99); *------------------------------------------*/ -BUILDIN(instance_check_party) +static BUILDIN(instance_check_party) { int amount, min, max, i, party_id, c = 0; struct party_data *p = NULL; @@ -21573,7 +22030,7 @@ BUILDIN(instance_check_party) * Example: instance_check_guild (getcharid(2){,amount}{,min}{,max}); * Example 2: instance_check_guild (getcharid(2),1,1,99); *------------------------------------------*/ -BUILDIN(instance_check_guild) +static BUILDIN(instance_check_guild) { int amount, min, max, i, guild_id, c = 0; struct guild *g = NULL; @@ -21625,7 +22082,7 @@ BUILDIN(instance_check_guild) /*========================================== * Custom Fonts *------------------------------------------*/ -BUILDIN(setfont) +static BUILDIN(setfont) { struct map_session_data *sd = script->rid2sd(st); int font = script_getnum(st,2); @@ -21641,7 +22098,7 @@ BUILDIN(setfont) return true; } -int buildin_mobuseskill_sub(struct block_list *bl, va_list ap) +static int buildin_mobuseskill_sub(struct block_list *bl, va_list ap) { struct mob_data *md = NULL; struct block_list *tbl; @@ -21688,7 +22145,7 @@ int buildin_mobuseskill_sub(struct block_list *bl, va_list ap) /*========================================== * areamobuseskill "Map Name",<x>,<y>,<range>,<Mob ID>,"Skill Name"/<Skill ID>,<Skill Lv>,<Cast Time>,<Cancelable>,<Emotion>,<Target Type>; *------------------------------------------*/ -BUILDIN(areamobuseskill) +static BUILDIN(areamobuseskill) { struct block_list center; int16 m; @@ -21718,7 +22175,7 @@ BUILDIN(areamobuseskill) return true; } -BUILDIN(progressbar) +static BUILDIN(progressbar) { struct map_session_data * sd = script->rid2sd(st); const char * color; @@ -21739,7 +22196,7 @@ BUILDIN(progressbar) clif->progressbar(sd, (unsigned int)strtoul(color, (char **)NULL, 0), second); return true; } -BUILDIN(progressbar_unit) +static BUILDIN(progressbar_unit) { const char *color = script_getstr(st, 2); uint32 second = script_getnum(st, 3); @@ -21762,7 +22219,7 @@ BUILDIN(progressbar_unit) } return true; } -BUILDIN(pushpc) +static BUILDIN(pushpc) { uint8 dir; int cells, dx, dy; @@ -21802,7 +22259,7 @@ BUILDIN(pushpc) /// Invokes buying store preparation window /// buyingstore <slots>; -BUILDIN(buyingstore) +static BUILDIN(buyingstore) { struct map_session_data* sd; @@ -21816,7 +22273,7 @@ BUILDIN(buyingstore) /// Invokes search store info window /// searchstores <uses>,<effect>; -BUILDIN(searchstores) +static BUILDIN(searchstores) { unsigned short effect; unsigned int uses; @@ -21847,7 +22304,7 @@ BUILDIN(searchstores) } /// Displays a number as large digital clock. /// showdigit <value>[,<type>]; -BUILDIN(showdigit) +static BUILDIN(showdigit) { unsigned int type = 0; int value; @@ -21877,7 +22334,7 @@ BUILDIN(showdigit) /** * Rune Knight **/ -BUILDIN(makerune) +static BUILDIN(makerune) { struct map_session_data *sd = script->rid2sd(st); if (sd == NULL) @@ -21890,7 +22347,7 @@ BUILDIN(makerune) /** * hascashmount() returns 1 if mounting a cash mount or 0 otherwise **/ -BUILDIN(hascashmount) +static BUILDIN(hascashmount) { struct map_session_data *sd = script->rid2sd(st); @@ -21913,7 +22370,7 @@ BUILDIN(hascashmount) * - Will fail if the player is already riding a standard mount e.g. dragon, peco, wug, mado, etc. * - Will unmount the player is he is already mounting a cash mount **/ -BUILDIN(setcashmount) +static BUILDIN(setcashmount) { struct map_session_data *sd = script->rid2sd(st); @@ -21941,7 +22398,7 @@ BUILDIN(setcashmount) * Retrieves quantity of arguments provided to callfunc/callsub. * getargcount() -> amount of arguments received in a function **/ -BUILDIN(getargcount) +static BUILDIN(getargcount) { struct script_retinfo* ri; @@ -21960,7 +22417,7 @@ BUILDIN(getargcount) /** * getcharip(<account ID>/<character ID>/<character name>) **/ -BUILDIN(getcharip) +static BUILDIN(getcharip) { struct map_session_data* sd = NULL; @@ -21998,7 +22455,7 @@ BUILDIN(getcharip) /** * is_function(<function name>) -> 1 if function exists, 0 otherwise **/ -BUILDIN(is_function) +static BUILDIN(is_function) { const char* str = script_getstr(st,2); @@ -22013,7 +22470,7 @@ BUILDIN(is_function) /** * freeloop(<toggle>) -> toggles this script instance's looping-check ability **/ -BUILDIN(freeloop) +static BUILDIN(freeloop) { if( script_getnum(st,2) ) st->freeloop = 1; @@ -22025,7 +22482,7 @@ BUILDIN(freeloop) return true; } -BUILDIN(sit) +static BUILDIN(sit) { struct map_session_data *sd = NULL; @@ -22046,7 +22503,7 @@ BUILDIN(sit) return true; } -BUILDIN(stand) +static BUILDIN(stand) { struct map_session_data *sd = NULL; @@ -22067,7 +22524,7 @@ BUILDIN(stand) return true; } -BUILDIN(issit) +static BUILDIN(issit) { struct map_session_data *sd = NULL; @@ -22086,7 +22543,7 @@ BUILDIN(issit) return true; } -BUILDIN(add_group_command) +static BUILDIN(add_group_command) { AtCommandInfo *acmd_d; struct atcmd_binding_data *bcmd_d; @@ -22126,7 +22583,7 @@ BUILDIN(add_group_command) /** * @commands (script based) **/ -BUILDIN(bindatcmd) +static BUILDIN(bindatcmd) { const char* atcmd; const char* eventName; @@ -22179,7 +22636,7 @@ BUILDIN(bindatcmd) return true; } -BUILDIN(unbindatcmd) +static BUILDIN(unbindatcmd) { const char* atcmd; int i = 0; @@ -22223,7 +22680,7 @@ BUILDIN(unbindatcmd) return true; } -BUILDIN(useatcmd) +static BUILDIN(useatcmd) { struct map_session_data *sd, *dummy_sd = NULL; int fd; @@ -22261,7 +22718,7 @@ BUILDIN(useatcmd) return true; } -BUILDIN(has_permission) +static BUILDIN(has_permission) { struct map_session_data *sd; enum e_pc_permission perm; @@ -22302,7 +22759,7 @@ BUILDIN(has_permission) return true; } -BUILDIN(can_use_command) +static BUILDIN(can_use_command) { struct map_session_data *sd; const char *cmd = script_getstr(st, 2); @@ -22323,7 +22780,7 @@ BUILDIN(can_use_command) } /* getrandgroupitem <container_item_id>,<quantity> */ -BUILDIN(getrandgroupitem) +static BUILDIN(getrandgroupitem) { struct item_data *data = NULL; struct map_session_data *sd = NULL; @@ -22377,14 +22834,14 @@ BUILDIN(getrandgroupitem) /* cleanmap <map_name>; * cleanarea <map_name>, <x0>, <y0>, <x1>, <y1>; */ -int script_cleanfloor_sub(struct block_list *bl, va_list ap) +static int script_cleanfloor_sub(struct block_list *bl, va_list ap) { map->clearflooritem(bl); return 0; } -BUILDIN(cleanmap) +static BUILDIN(cleanmap) { const char *mapname = script_getstr(st, 2); int16 m = map->mapname2mapid(mapname); @@ -22413,7 +22870,7 @@ BUILDIN(cleanmap) /* Cast a skill on the attached player. * npcskill <skill id>, <skill lvl>, <stat point>, <NPC level>; * npcskill "<skill name>", <skill lvl>, <stat point>, <NPC level>; */ -BUILDIN(npcskill) +static BUILDIN(npcskill) { struct npc_data *nd; uint16 skill_id = script_isstringtype(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2); @@ -22459,7 +22916,7 @@ BUILDIN(npcskill) /* Turns a player into a monster and grants SC attribute effect. [malufett/Hercules] * montransform <monster name/id>, <duration>, <sc type>, <val1>, <val2>, <val3>, <val4>; */ -BUILDIN(montransform) +static BUILDIN(montransform) { int tick; enum sc_type type; @@ -22543,7 +23000,7 @@ BUILDIN(montransform) * * @return The queue, or NULL if it doesn't exist. */ -struct script_queue *script_hqueue_get(int idx) +static struct script_queue *script_hqueue_get(int idx) { if (idx < 0 || idx >= VECTOR_LENGTH(script->hq) || !VECTOR_INDEX(script->hq, idx).valid) return NULL; @@ -22555,7 +23012,7 @@ struct script_queue *script_hqueue_get(int idx) * * @return The index of the created queue. */ -int script_hqueue_create(void) +static int script_hqueue_create(void) { struct script_queue *queue = NULL; int i; @@ -22582,7 +23039,7 @@ int script_hqueue_create(void) * .@queue_id = queue(); * @endcode */ -BUILDIN(queue) +static BUILDIN(queue) { script_pushint(st,script->queue_create()); return true; @@ -22597,7 +23054,7 @@ BUILDIN(queue) * .@size = queuesize(<queue id>); * \endcode */ -BUILDIN(queuesize) +static BUILDIN(queuesize) { int idx = script_getnum(st, 2); @@ -22619,7 +23076,7 @@ BUILDIN(queuesize) * @retval false if the queue is invalid or the entry is already in the queue. * @retval true in case of success. */ -bool script_hqueue_add(int idx, int var) +static bool script_hqueue_add(int idx, int var) { int i; struct map_session_data *sd = NULL; @@ -22657,7 +23114,7 @@ bool script_hqueue_add(int idx, int var) * .@size = queuesize(.@queue_id); * @endcode */ -BUILDIN(queueadd) +static BUILDIN(queueadd) { int idx = script_getnum(st, 2); int var = script_getnum(st, 3); @@ -22678,7 +23135,7 @@ BUILDIN(queueadd) * @retval true if the entry was removed. * @retval false if the entry wasn't in queue. */ -bool script_hqueue_remove(int idx, int var) +static bool script_hqueue_remove(int idx, int var) { int i; struct map_session_data *sd = NULL; @@ -22715,7 +23172,7 @@ bool script_hqueue_remove(int idx, int var) * queueremove(.@queue_id, .@value); * @endcode */ -BUILDIN(queueremove) +static BUILDIN(queueremove) { int idx = script_getnum(st, 2); int var = script_getnum(st, 3); @@ -22731,7 +23188,7 @@ BUILDIN(queueremove) /** * Script command queueopt: Modifies the options of a queue. * - * When the option value isn't provided, the option is removed. + * When the <event label> isn't provided, the option is removed. * * Returns 1 (true) on success, 0 (false) on failure. * @@ -22741,13 +23198,13 @@ BUILDIN(queueremove) * - QUEUEOPT_MAPCHANGE * * When the QUEUEOPT_MAPCHANGE event is triggered, it sets a temporary - * character variable \c @Queue_Destination_Map$ with the destination map name. + * character variable @Queue_Destination_Map$ with the destination map name. * * @code{.herc} - * queueopt(.@queue_id, optionType, <optional val>); + * queueopt(.@queue_id, optionType{, <event label>}); * @endcode */ -BUILDIN(queueopt) +static BUILDIN(queueopt) { int idx = script_getnum(st, 2); int var = script_getnum(st, 3); @@ -22797,7 +23254,7 @@ BUILDIN(queueopt) * @retval true if the queue was correctly deleted. * @retval false if the queue didn't exist. */ -bool script_hqueue_del(int idx) +static bool script_hqueue_del(int idx) { if (!script->queue_clear(idx)) return false; @@ -22816,7 +23273,7 @@ bool script_hqueue_del(int idx) * queuedel(.@queue_id); * @endcode */ -BUILDIN(queuedel) +static BUILDIN(queuedel) { int idx = script_getnum(st, 2); @@ -22836,7 +23293,7 @@ BUILDIN(queuedel) * @retval true if the queue was correctly cleared. * @retval false if the queue didn't exist. */ -bool script_hqueue_clear(int idx) +static bool script_hqueue_clear(int idx) { struct script_queue *queue = NULL; @@ -22873,7 +23330,7 @@ bool script_hqueue_clear(int idx) * .@id = queueiterator(.@queue_id); * @endcode */ -BUILDIN(queueiterator) +static BUILDIN(queueiterator) { int qid = script_getnum(st, 2); struct script_queue *queue = NULL; @@ -22916,7 +23373,7 @@ BUILDIN(queueiterator) * } * @endcode */ -BUILDIN(qiget) +static BUILDIN(qiget) { int idx = script_getnum(st, 2); struct script_queue_iterator *it = NULL; @@ -22950,7 +23407,7 @@ BUILDIN(qiget) * } * @endcode */ -BUILDIN(qicheck) +static BUILDIN(qicheck) { int idx = script_getnum(st, 2); struct script_queue_iterator *it = NULL; @@ -22981,7 +23438,7 @@ BUILDIN(qicheck) * qiclear(.@iter); * @endcode */ -BUILDIN(qiclear) +static BUILDIN(qiclear) { int idx = script_getnum(st, 2); struct script_queue_iterator *it = NULL; @@ -23006,7 +23463,8 @@ BUILDIN(qiclear) * packageitem({<optional container_item_id>}) * when no item id is provided it tries to assume it comes from the current item id being processed (if any) **/ -BUILDIN(packageitem) { +static BUILDIN(packageitem) +{ struct item_data *data = NULL; struct map_session_data *sd = NULL; int nameid; @@ -23040,7 +23498,8 @@ BUILDIN(packageitem) { /* New Battlegrounds Stuff */ /* bg_team_create(map_name,respawn_x,respawn_y) */ /* returns created team id or -1 when fails */ -BUILDIN(bg_create_team) { +static BUILDIN(bg_create_team) +{ const char *map_name, *ev = "", *dev = "";//ev and dev will be dropped. int x, y, map_index = 0, bg_id; @@ -23067,7 +23526,8 @@ BUILDIN(bg_create_team) { /* bg_join_team(team_id{,optional account id}) */ /* when account id is not present it tries to autodetect from the attached player (if any) */ /* returns 0 when successful, 1 otherwise */ -BUILDIN(bg_join_team) { +static BUILDIN(bg_join_team) +{ struct map_session_data *sd; int team_id = script_getnum(st, 2); @@ -23093,7 +23553,7 @@ BUILDIN(bg_join_team) { * 3 - Party Bound * 4 - Character Bound *------------------------------------------*/ -BUILDIN(countbound) +static BUILDIN(countbound) { int i, type, j=0, k=0; struct map_session_data *sd = script->rid2sd(st); @@ -23128,7 +23588,7 @@ BUILDIN(countbound) * 3 - Party Bound * 4 - Character Bound *------------------------------------------*/ -BUILDIN(checkbound) +static BUILDIN(checkbound) { int i, nameid = script_getnum(st,2); int bound_type = 0; @@ -23169,7 +23629,7 @@ BUILDIN(checkbound) /* bg_match_over( arena_name {, optional canceled } ) */ /* returns 0 when successful, 1 otherwise */ -BUILDIN(bg_match_over) +static BUILDIN(bg_match_over) { bool canceled = script_hasdata(st,3) ? true : false; struct bg_arena *arena = bg->name2arena(script_getstr(st, 2)); @@ -23183,7 +23643,7 @@ BUILDIN(bg_match_over) return true; } -BUILDIN(instance_mapname) +static BUILDIN(instance_mapname) { const char *map_name; int m; @@ -23208,7 +23668,7 @@ BUILDIN(instance_mapname) /* modify an instances' reload-spawn point */ /* instance_set_respawn <map_name>,<x>,<y>{,<instance_id>} */ /* returns 1 when successful, 0 otherwise. */ -BUILDIN(instance_set_respawn) +static BUILDIN(instance_set_respawn) { const char *map_name; short instance_id = -1; @@ -23256,7 +23716,7 @@ BUILDIN(instance_set_respawn) * * @return 1 on success, 0 otherwise. **/ -BUILDIN(openshop) +static BUILDIN(openshop) { struct npc_data *nd; struct map_session_data *sd; @@ -23293,7 +23753,7 @@ BUILDIN(openshop) * adds <Item_ID> (or modifies if present) to shop * if price not provided (or -1) uses the item's value_sell **/ -BUILDIN(sellitem) +static BUILDIN(sellitem) { struct npc_data *nd; struct item_data *it; @@ -23369,7 +23829,7 @@ BUILDIN(sellitem) * * @return 1 on success, 0 otherwise **/ -BUILDIN(stopselling) +static BUILDIN(stopselling) { struct npc_data *nd; int i, id = script_getnum(st,2); @@ -23420,7 +23880,7 @@ BUILDIN(stopselling) * updates currently-attached player shop currency **/ /* setcurrency(<Val1>,{<Val2>}) */ -BUILDIN(setcurrency) +static BUILDIN(setcurrency) { int val1 = script_getnum(st,2), val2 = script_hasdata(st, 3) ? script_getnum(st,3) : 0; @@ -23444,7 +23904,7 @@ BUILDIN(setcurrency) * check enum npc_shop_types for list * cleans shop list on use **/ -BUILDIN(tradertype) +static BUILDIN(tradertype) { int type = script_getnum(st, 2); struct npc_data *nd; @@ -23487,7 +23947,7 @@ BUILDIN(tradertype) * * signs the transaction can proceed **/ -BUILDIN(purchaseok) +static BUILDIN(purchaseok) { struct npc_data *nd; @@ -23506,7 +23966,7 @@ BUILDIN(purchaseok) * * @return number of available items in the script's attached shop **/ -BUILDIN(shopcount) +static BUILDIN(shopcount) { struct npc_data *nd; int id = script_getnum(st, 2); @@ -23544,7 +24004,7 @@ BUILDIN(shopcount) * Sends a message through the specified chat channel. * */ -BUILDIN(channelmes) +static BUILDIN(channelmes) { struct map_session_data *sd = map->id2sd(st->rid); const char *channelname = script_getstr(st, 2); @@ -23561,7 +24021,7 @@ BUILDIN(channelmes) return true; } -BUILDIN(addchannelhandler) +static BUILDIN(addchannelhandler) { int i; struct map_session_data *sd = map->id2sd(st->rid); @@ -23587,7 +24047,7 @@ BUILDIN(addchannelhandler) return true; } -BUILDIN(removechannelhandler) +static BUILDIN(removechannelhandler) { int i; struct map_session_data *sd = map->id2sd(st->rid); @@ -23613,10 +24073,10 @@ BUILDIN(removechannelhandler) } /** By Cydh -Display script message -showscript "<message>"{,<GID>}; -*/ -BUILDIN(showscript) + * Display script message + * showscript "<message>"{, <GID>}; + */ +static BUILDIN(showscript) { struct block_list *bl = NULL; const char *msg = script_getstr(st, 2); @@ -23643,7 +24103,7 @@ BUILDIN(showscript) return true; } -BUILDIN(mergeitem) +static BUILDIN(mergeitem) { struct map_session_data *sd = script->rid2sd(st); @@ -23657,7 +24117,7 @@ BUILDIN(mergeitem) // getcalendartime(<day of month>, <day of week>{, <hour>{, <minute>}}); // Returns the UNIX Timestamp of next ocurrency of given time -BUILDIN(getcalendartime) +static BUILDIN(getcalendartime) { struct tm info = { 0 }; int day_of_month = script_hasdata(st, 4) ? script_getnum(st, 4) : -1; @@ -23750,7 +24210,7 @@ BUILDIN(getcalendartime) } /** place holder for the translation macro **/ -BUILDIN(_) +static BUILDIN(_) { return true; } @@ -23769,7 +24229,7 @@ enum dressroom_mode { /** * dressroom({<enum dressroom_mode>}); */ -BUILDIN(dressroom) +static BUILDIN(dressroom) { #if PACKETVER >= 20150513 struct map_session_data *sd = script->rid2sd(st); @@ -23805,7 +24265,7 @@ BUILDIN(dressroom) #endif } -BUILDIN(pcre_match) +static BUILDIN(pcre_match) { const char *input = script_getstr(st, 2); const char *regex = script_getstr(st, 3); @@ -23817,7 +24277,7 @@ BUILDIN(pcre_match) /** * navigateto("<map>"{,<x>,<y>,<flag>,<hide_window>,<monster_id>,<char_id>}); */ -BUILDIN(navigateto) +static BUILDIN(navigateto) { #if PACKETVER >= 20111010 struct map_session_data* sd; @@ -23856,11 +24316,11 @@ BUILDIN(navigateto) #endif } -bool rodex_sendmail_sub(struct script_state* st, struct rodex_message *msg) +static bool rodex_sendmail_sub(struct script_state *st, struct rodex_message *msg) { const char *sender_name, *title, *body; - if (!strcmp(script->getfuncname(st), "rodex_sendmail_acc2")) + if (strcmp(script->getfuncname(st), "rodex_sendmail_acc") == 0 || strcmp(script->getfuncname(st), "rodex_sendmail_acc2") == 0) msg->receiver_accountid = script_getnum(st, 2); else msg->receiver_id = script_getnum(st, 2); @@ -23897,7 +24357,7 @@ bool rodex_sendmail_sub(struct script_state* st, struct rodex_message *msg) return true; } -BUILDIN(rodex_sendmail) +static BUILDIN(rodex_sendmail) { struct rodex_message msg = { 0 }; int item_count = 0, i = 0, param = 7; @@ -23953,7 +24413,7 @@ BUILDIN(rodex_sendmail) return true; } -BUILDIN(rodex_sendmail2) +static BUILDIN(rodex_sendmail2) { struct rodex_message msg = { 0 }; int item_count = 0, i = 0, param = 7; @@ -24034,7 +24494,7 @@ BUILDIN(rodex_sendmail2) /** * Clan System: Add a player to a clan */ -BUILDIN(clan_join) +static BUILDIN(clan_join) { struct map_session_data *sd = NULL; int clan_id = script_getnum(st, 2); @@ -24060,7 +24520,7 @@ BUILDIN(clan_join) /** * Clan System: Remove a player from clan */ -BUILDIN(clan_leave) +static BUILDIN(clan_leave) { struct map_session_data *sd = NULL; @@ -24085,7 +24545,7 @@ BUILDIN(clan_leave) /** * Clan System: Show clan emblem next to npc name */ -BUILDIN(clan_master) +static BUILDIN(clan_master) { struct npc_data *nd = map->id2nd(st->oid); int clan_id = script_getnum(st, 2); @@ -24110,7 +24570,7 @@ BUILDIN(clan_master) return true; } -BUILDIN(airship_respond) +static BUILDIN(airship_respond) { struct map_session_data *sd = map->id2sd(st->rid); int32 flag = script_getnum(st, 2); @@ -24130,7 +24590,7 @@ BUILDIN(airship_respond) /** * hateffect(EffectID, Enable_State) */ -BUILDIN(hateffect) +static BUILDIN(hateffect) { #if PACKETVER >= 20150422 struct map_session_data *sd = script_rid2sd(st); @@ -24163,14 +24623,16 @@ BUILDIN(hateffect) return true; } -BUILDIN(openstylist) +static BUILDIN(openstylist) { struct map_session_data *sd = script_rid2sd(st); if (sd == NULL) return false; - clif->open_ui(sd, STYLIST_UI); +#if PACKETVER >= 20150128 + clif->open_ui(sd, CZ_STYLIST_UI); +#endif return true; } @@ -24182,7 +24644,7 @@ BUILDIN(openstylist) * (i.e. a plugin overriding a built-in function) * @return Whether the function was successfully added. */ -bool script_add_builtin(const struct script_function *buildin, bool override) +static bool script_add_builtin(const struct script_function *buildin, bool override) { int n = 0, offset = 0; size_t slen; @@ -24264,7 +24726,7 @@ bool script_add_builtin(const struct script_function *buildin, bool override) return true; } -bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st), bool isDeprecated) +static bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st), bool isDeprecated) { struct script_function buildin; buildin.name = name; @@ -24274,7 +24736,7 @@ bool script_hp_add(char *name, char *args, bool (*func)(struct script_state *st) return script->add_builtin(&buildin, true); } -void script_run_use_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1))); +static void script_run_use_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1))); /** * Run use script for item. @@ -24283,7 +24745,7 @@ void script_run_use_script(struct map_session_data *sd, struct item_data *data, * @param n item index in inventory. Must be correct and checked before. * @param oid npc id. Can be also 0 or fake npc id. */ -void script_run_use_script(struct map_session_data *sd, struct item_data *data, int oid) +static void script_run_use_script(struct map_session_data *sd, struct item_data *data, int oid) { nullpo_retv(data); script->current_item_id = data->nameid; @@ -24291,7 +24753,7 @@ void script_run_use_script(struct map_session_data *sd, struct item_data *data, script->current_item_id = 0; } -void script_run_item_equip_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1, 2))); +static void script_run_item_equip_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1, 2))); /** * Run item equip script for item. @@ -24300,14 +24762,14 @@ void script_run_item_equip_script(struct map_session_data *sd, struct item_data * @param data equipped item data. Must be correct and checked before. * @param oid npc id. Can be also 0 or fake npc id. */ -void script_run_item_equip_script(struct map_session_data *sd, struct item_data *data, int oid) +static void script_run_item_equip_script(struct map_session_data *sd, struct item_data *data, int oid) { script->current_item_id = data->nameid; script->run(data->equip_script, 0, sd->bl.id, oid); script->current_item_id = 0; } -void script_run_item_unequip_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1, 2))); +static void script_run_item_unequip_script(struct map_session_data *sd, struct item_data *data, int oid) __attribute__((nonnull (1, 2))); /** * Run item unequip script for item. @@ -24316,7 +24778,7 @@ void script_run_item_unequip_script(struct map_session_data *sd, struct item_dat * @param data unequipped item data. Must be correct and checked before. * @param oid npc id. Can be also 0 or fake npc id. */ -void script_run_item_unequip_script(struct map_session_data *sd, struct item_data *data, int oid) +static void script_run_item_unequip_script(struct map_session_data *sd, struct item_data *data, int oid) { script->current_item_id = data->nameid; script->run(data->unequip_script, 0, sd->bl.id, oid); @@ -24327,7 +24789,8 @@ void script_run_item_unequip_script(struct map_session_data *sd, struct item_dat #define BUILDIN_DEF2(x,x2,args) { buildin_ ## x , x2 , args, false } #define BUILDIN_DEF_DEPRECATED(x,args) { buildin_ ## x , #x , args, true } #define BUILDIN_DEF2_DEPRECATED(x,x2,args) { buildin_ ## x , x2 , args, true } -void script_parse_builtin(void) { +static void script_parse_builtin(void) +{ struct script_function BUILDIN[] = { /* Commands for internal use by the script engine */ BUILDIN_DEF(__jump_zero,"il"), @@ -24388,6 +24851,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(checkweight,"vi*"), BUILDIN_DEF(checkweight2,"rr"), BUILDIN_DEF(readparam,"i?"), + BUILDIN_DEF(setparam,"ii?"), BUILDIN_DEF(getcharid,"i?"), BUILDIN_DEF(getnpcid,"i?"), BUILDIN_DEF(getpartyname,"i"), @@ -24575,7 +25039,7 @@ void script_parse_builtin(void) { BUILDIN_DEF2(atcommand,"charcommand","s"), // [MouseJstr] BUILDIN_DEF(movenpc,"sii?"), // [MouseJstr] BUILDIN_DEF(message,"vs"), // [MouseJstr] - BUILDIN_DEF(npctalk,"s?"), // [Valaris] + BUILDIN_DEF(npctalk,"s??"), // [Valaris][Murilo BiO] BUILDIN_DEF(mobcount,"ss"), BUILDIN_DEF(getlook,"i"), BUILDIN_DEF(getsavepoint,"i"), @@ -24704,7 +25168,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(unitwarp,"isii"), BUILDIN_DEF(unitattack,"iv?"), BUILDIN_DEF(unitstop,"i"), - BUILDIN_DEF(unittalk,"is"), + BUILDIN_DEF(unittalk,"is???"), BUILDIN_DEF(unitemote,"ii"), BUILDIN_DEF(unitskilluseid,"ivi?"), // originally by Qamera [Celest] BUILDIN_DEF(unitskillusepos,"iviii"), // [Celest] @@ -24752,6 +25216,8 @@ void script_parse_builtin(void) { BUILDIN_DEF(agitstart2,""), BUILDIN_DEF(agitend2,""), BUILDIN_DEF(agitcheck2,""), + // Achievements [Smokexyz/Hercules] + BUILDIN_DEF(achievement_progress, "iiii?"), // BattleGround BUILDIN_DEF(waitingroom2bg,"siiss?"), BUILDIN_DEF(waitingroom2bg_single,"isiis"), @@ -24824,7 +25290,8 @@ void script_parse_builtin(void) { BUILDIN_DEF(checkbound, "i???????"), //Quest Log System [Inkfish] - BUILDIN_DEF(questinfo, "ii??"), + BUILDIN_DEF(questinfo, "i?"), + BUILDIN_DEF(setquestinfo, "i??"), BUILDIN_DEF(setquest, "i?"), BUILDIN_DEF(erasequest, "i?"), BUILDIN_DEF(completequest, "i?"), @@ -24907,7 +25374,7 @@ void script_parse_builtin(void) { #undef BUILDIN_DEF #undef BUILDIN_DEF2 -void script_label_add(int key, int pos) +static void script_label_add(int key, int pos) { int idx = script->label_count; @@ -24924,7 +25391,7 @@ void script_label_add(int key, int pos) /** * Sets source-end constants for scripts to play with **/ -void script_hardcoded_constants(void) +static void script_hardcoded_constants(void) { script->constdb_comment("Boolean"); script->set_constant("true", 1, false, false); @@ -25285,6 +25752,16 @@ void script_hardcoded_constants(void) script->set_constant("P_AIRSHIP_ITEM_NOT_ENOUGH", P_AIRSHIP_ITEM_NOT_ENOUGH, false, false); script->set_constant("P_AIRSHIP_ITEM_INVALID", P_AIRSHIP_ITEM_INVALID, false, false); + script->constdb_comment("questinfo types"); + script->set_constant("QINFO_JOB", QINFO_JOB, false, false); + script->set_constant("QINFO_SEX", QINFO_SEX, false, false); + script->set_constant("QINFO_BASE_LEVEL", QINFO_BASE_LEVEL, false, false); + script->set_constant("QINFO_JOB_LEVEL", QINFO_JOB_LEVEL, false, false); + script->set_constant("QINFO_ITEM", QINFO_ITEM, false, false); + script->set_constant("QINFO_HOMUN_LEVEL", QINFO_HOMUN_LEVEL, false, false); + script->set_constant("QINFO_HOMUN_TYPE", QINFO_HOMUN_TYPE, false, false); + script->set_constant("QINFO_QUEST", QINFO_QUEST, false, false); + script->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); @@ -25328,7 +25805,7 @@ void script_hardcoded_constants(void) /** * a mapindex_name2id wrapper meant to help with invalid name handling **/ -unsigned short script_mapindexname2id (struct script_state *st, const char* name) +static unsigned short script_mapindexname2id(struct script_state *st, const char *name) { unsigned short index; |